本文整理汇总了C#中BusinessContext类的典型用法代码示例。如果您正苦于以下问题:C# BusinessContext类的具体用法?C# BusinessContext怎么用?C# BusinessContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BusinessContext类属于命名空间,在下文中一共展示了BusinessContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostCreateInsideTransaction
protected override void PostCreateInsideTransaction(BusinessContext context)
{
// Call Base method
base.PostCreateInsideTransaction(context);
#region Create a new Document Card
PrimaryKeyId pkDocumentType = ((CreateResponse)context.Response).PrimaryKeyId;
// Create a new Document Card
using (MetaClassManagerEditScope scope = DataContext.Current.MetaModel.BeginEdit())
{
// TODO: Check Card Name
string cardName = context.Request.Target["Name"].ToString();
string cardFriendlyName = context.Request.Target["FriendlyName"].ToString();
string cardPluralName = cardFriendlyName;
string tableName = "cls_Document_" + context.Request.Target["Name"].ToString();
MetaClass newCard = DataContext.Current.MetaModel.CreateCardMetaClass(DataContext.Current.GetMetaClass(DocumentEntity.GetAssignedMetaClassName()),
cardName, cardFriendlyName,
cardPluralName, tableName);
scope.SaveChanges();
}
#endregion
}
示例2: InitializeMappingDocument
/// <summary>
/// Initializes the mapping document.
/// </summary>
/// <param name="context">The context.</param>
protected override void InitializeMappingDocument(BusinessContext context)
{
InitializeMappingDocumentRequest request = ((InitializeMappingDocumentRequest)context.Request);
MetaClass metaClass = DataContext.Current.GetMetaClass(context.GetTargetMetaClassName());
List<PrimaryKeyId> primaryKeyIds = new List<PrimaryKeyId>();
// Create Default Mapping
MappingDocument retVal = new MappingDocument();
DataTable dataTable = request.Data.Tables[request.TableIndex];
MappingElement mapping = new MappingElement(dataTable.TableName, metaClass.Name);
retVal.Add(mapping);
MappingElementBuilder builder = new MappingElementBuilder(retVal);
//Call creation mapping document by saved patterns
DefaultMappingHelper.CreateMapingByPatternComparision(dataTable, metaClass, builder);
// Write Response
InitializeMappingDocumentResponse response = new InitializeMappingDocumentResponse();
response.MappingDocument = retVal;
context.SetResponse(response);
}
示例3: List
protected override void List(BusinessContext context)
{
base.List(context);
ListRequest request = (ListRequest)context.Request;
ListResponse response = (ListResponse)context.Response;
// Check if sorting contains OutlineNumber
bool bSortByName = request.Sorting.Length == 1 &&
request.Sorting[0].Source == DirectoryOrganizationalUnitEntity.FieldOutlineNumber;
List<EntityObject> items = new List<EntityObject>(response.EntityObjects);
// Load Name From GlobalResource
foreach (DirectoryOrganizationalUnitEntity entity in items)
{
entity.Name = GlobalResource.GetString(entity.Name);
}
if (bSortByName)
{
SortEntityObjectTreeByName(items);
}
response.EntityObjects = items.ToArray();
}
示例4: CloseAssignment
/// <summary>
/// Closes the assignment.
/// </summary>
/// <param name="context">The context.</param>
protected virtual void CloseAssignment(BusinessContext context)
{
CloseAssignmentRequest request = (CloseAssignmentRequest)context.Request;
// Load Assignment
MetaObject metaObject = MetaObjectActivator.CreateInstance(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
if (((int)metaObject[AssignmentEntity.FieldState]) != (int)AssignmentState.Active)
throw new InvalidOperationException();
DateTime dateTimeNow = DataContext.Current.CurrentUserTimeZone.ToLocalTime(DateTime.UtcNow);
// Update Meta Object Fields
metaObject[AssignmentEntity.FieldClosedBy] = (int)DataContext.Current.CurrentUserId;
metaObject[AssignmentEntity.FieldState] = (int)AssignmentState.Closed;
metaObject[AssignmentEntity.FieldExecutionResult] = request.ExecutionResult;
metaObject[AssignmentEntity.FieldComment] = request.Comment;
metaObject[AssignmentEntity.FieldActualFinishDate] = dateTimeNow;
// Save Meta Object
metaObject.Save();
if (metaObject[AssignmentEntity.FieldWorkflowInstanceId]!=null)
{
// Run Workflow
AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
RunWorkflow(entity);
}
context.SetResponse(new Response());
}
示例5: DeleteKeywordIsPersisted
public void DeleteKeywordIsPersisted()
{
using (var businessContext = new BusinessContext())
{
var language = new Language
{
Name = "LanguageName"
};
businessContext.AddNewLanguage(language);
var keyword = new Keyword
{
Name = "KeywordName",
LanguageId = 1,
};
businessContext.AddNewKeyword(keyword);
//businessContext.DeleteKeyword(keyword);
bool notDeleted = businessContext.DataContext.Keywords.Any(k => k.Id == keyword.Id);
//Assert.IsFalse(notDeleted);
}
}
示例6: UpdateKeywordIsPersisted
public void UpdateKeywordIsPersisted()
{
using (var businessContext = new BusinessContext())
{
var language = new Language
{
Name = "LanguageName"
};
businessContext.AddNewLanguage(language);
var keyword = new Keyword
{
Name = "KeywordName",
LanguageId = 1,
};
businessContext.AddNewKeyword(keyword);
keyword.Name = "New KeywordName";
businessContext.UpdateKeyword(keyword);
bool updated = businessContext.DataContext.Keywords.Any(k => k.Id == keyword.Id && k.Name == keyword.Name);
Assert.IsTrue(updated);
}
}
示例7: PreDeleteInsideTransaction
protected override void PreDeleteInsideTransaction(BusinessContext context)
{
base.PreDeleteInsideTransaction(context);
// Remove SecureRole From Principal
DirectoryManager.DeletePrincipal(context.GetTargetPrimaryKeyId().Value);
}
示例8: Load
protected override void Load(BusinessContext context)
{
// solve problem if item was load in LocalDiskEntityObjectPlugin
if (context.Response == null)
{
base.Load(context);
}
}
示例9: ResetDeliveryAttempts
/// <summary>
/// Resets the delivery attempts.
/// </summary>
/// <param name="context">The context.</param>
protected virtual void ResetDeliveryAttempts(BusinessContext context)
{
MetaObject metaObject = MetaObjectActivator.CreateInstance(context.GetTargetMetaClassName(), context.GetTargetPrimaryKeyId().Value);
metaObject[OutgoingMessageQueueEntity.FieldDeliveryAttempts] = 0;
metaObject.Save();
}
示例10: Execute
public void Execute(BusinessContext context)
{
_log.Debug("Execute (IPlugin) for {0}. Metaclass: {1}. PrimaryKey: {2}. Plugin Stage: {3}",
context.GetMethod(),
context.GetTargetMetaClassName(),
context.GetTargetPrimaryKeyId().HasValue ? context.GetTargetPrimaryKeyId().Value.ToString() : "null",
context.PluginStage);
}
示例11: Delete
/// <summary>
/// Deletes the specified context.
/// </summary>
/// <param name="context">The context.</param>
protected override void Delete(BusinessContext context)
{
// OZ: Comment base logic and call custom business logic ListManager.DeleteList
//base.Delete(context);
ListManager.DeleteList((int)context.GetTargetPrimaryKeyId().Value);
context.SetResponse(new Response());
}
示例12: PostCreateInsideTransaction
protected override void PostCreateInsideTransaction(BusinessContext context)
{
base.PostCreateInsideTransaction(context);
// Add SecureRole To Principal
DirectoryManager.CreatePrincipal(DirectoryPrincipalType.WorkGroup,
((CreateResponse)context.Response).PrimaryKeyId,
((DirectoryWorkGroupEntity)context.Request.Target).Name);
}
示例13: PostCreateInsideTransaction
protected override void PostCreateInsideTransaction(BusinessContext context)
{
base.PostCreateInsideTransaction(context);
// Add User To Principal
DirectoryManager.CreatePrincipal(DirectoryPrincipalType.User,
((CreateResponse)context.Response).PrimaryKeyId,
((DirectoryUserEntity)context.Request.Target).FullName);
}
示例14: CustomMethod
/// <summary>
/// Customs the method.
/// </summary>
/// <param name="context">The context.</param>
protected override void CustomMethod(BusinessContext context)
{
base.CustomMethod(context);
switch (context.GetMethod())
{
case OutgoingMessageQueueMethod.ResetDeliveryAttempts:
ResetDeliveryAttempts(context);
break;
}
}
示例15: PostUpdateInsideTransaction
protected override void PostUpdateInsideTransaction(BusinessContext context)
{
base.PostUpdateInsideTransaction(context);
// Update Principal
if(context.Request.Target.Properties.Contains(DirectoryWorkGroupEntity.FieldName))
{
DirectoryManager.UpdatePrincipal(context.GetTargetPrimaryKeyId().Value,
(string)context.Request.Target[DirectoryWorkGroupEntity.FieldName]);
}
}