本文整理汇总了C#中BusinessContext.GetTargetPrimaryKeyId方法的典型用法代码示例。如果您正苦于以下问题:C# BusinessContext.GetTargetPrimaryKeyId方法的具体用法?C# BusinessContext.GetTargetPrimaryKeyId怎么用?C# BusinessContext.GetTargetPrimaryKeyId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BusinessContext
的用法示例。
在下文中一共展示了BusinessContext.GetTargetPrimaryKeyId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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());
}
示例2: 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);
}
示例3: PreDeleteInsideTransaction
protected override void PreDeleteInsideTransaction(BusinessContext context)
{
base.PreDeleteInsideTransaction(context);
// Remove SecureRole From Principal
DirectoryManager.DeletePrincipal(context.GetTargetPrimaryKeyId().Value);
}
示例4: 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();
}
示例5: 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());
}
示例6: Execute
/// <summary>
/// Executes the specified contex.
/// </summary>
/// <param name="context">The context.</param>
protected virtual void Execute(BusinessContext context)
{
if ((context.GetMethod() == RequestMethod.Update ||
context.GetMethod() == RequestMethod.Create) &&
context.GetTargetPrimaryKeyId().HasValue)
{
if (context.Request.Target.Properties.GetValue<bool>(AssignmentEntity.FieldAutoComplete, false))
{
decimal planWork = context.Request.Target.Properties.GetValue<decimal>(AssignmentEntity.FieldPlanWork, decimal.MaxValue);
decimal actualWork = context.Request.Target.Properties.GetValue<decimal>(AssignmentEntity.FieldActualWork, decimal.MinValue);
if (planWork == actualWork)
{
// Invoke Auto Complete
BusinessManager.Execute(new CloseAssignmentRequest(context.GetTargetPrimaryKeyId().Value, (int)AssignmentExecutionResult.Accepted));
}
}
}
}
示例7: Execute
/// <summary>
/// Executes the specified context.
/// </summary>
/// <param name="context">The context.</param>
public void Execute(BusinessContext context)
{
switch (context.GetMethod())
{
case RequestMethod.Load:
if (context.GetTargetPrimaryKeyId().HasValue)
{
EntityObject item = LoadEntityObject(context.GetTargetMetaClassName(), context.GetTargetPrimaryKeyId().Value);
if (item != null)
{
LoadResponse response = new LoadResponse(item);
context.SetResponse(response);
}
}
break;
case RequestMethod.List:
{
// Filters Not Implemented
ListResponse response = context.Response as ListResponse;
if (response != null)
{
EntityObject[] items = LoadEntityObjects(context.GetTargetMetaClassName(), ((ListRequest)context.Request).Filters);
if (items.Length > 0)
{
List<EntityObject> newArray = new List<EntityObject>(response.EntityObjects.Length + items.Length);
newArray.AddRange(response.EntityObjects);
newArray.AddRange(items);
// TODO: Sorting Not Implemented
response.EntityObjects = newArray.ToArray();
}
}
}
break;
}
}
示例8: PreDeleteInsideTransaction
/// <summary>
/// Pres the delete inside transaction.
/// </summary>
/// <param name="context">The context.</param>
protected override void PreDeleteInsideTransaction(BusinessContext context)
{
base.PreDeleteInsideTransaction(context);
#region Remove references from IBN 4.7 objects
SqlHelper.ExecuteNonQuery(SqlContext.Current, System.Data.CommandType.StoredProcedure,
"bus_cls_ListObject_Delete",
SqlHelper.SqlParameter("@ClassName", SqlDbType.NVarChar, 250, context.GetTargetMetaClassName()),
SqlHelper.SqlParameter("@ObjectId", SqlDbType.VarChar, 36, context.GetTargetPrimaryKeyId().Value.ToString()));
#endregion
}
示例9: foreach
/// <summary>
/// Executes the specified context.
/// </summary>
/// <param name="context">The context.</param>
void IPlugin.Execute(BusinessContext context)
{
if (context.GetMethod() == RequestMethod.Delete &&
context.GetTargetPrimaryKeyId().HasValue)
{
MetaClass currentMetaClass = DataContext.Current.GetMetaClass(context.GetTargetMetaClassName());
foreach (MetaField mf in currentMetaClass.FindReferencesTo())
{
if (mf.Owner.IsBridge)
{
foreach(EntityObject entity in BusinessManager.List(mf.Owner.Name,
new FilterElement[] { FilterElement.EqualElement(mf.Name, context.GetTargetPrimaryKeyId().Value) }))
{
BusinessManager.Delete(entity);
}
}
}
}
}
示例10: 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]);
}
}
示例11: Execute
/// <summary>
/// Executes the specified context.
/// </summary>
/// <param name="context">The context.</param>
public void Execute(BusinessContext context)
{
if (context.PluginStage == EventPipeLineStage.PreMainOperationInsideTranasaction)
{
switch (context.GetMethod())
{
case RequestMethod.Delete:
// TODO: Pre Method
OnAssignmentDeleting(context.GetTargetPrimaryKeyId().Value);
break;
case AssignmentRequestMethod.AssignUser:
case RequestMethod.Update:
case AssignmentRequestMethod.Activate:
case AssignmentRequestMethod.Close:
case AssignmentRequestMethod.Resume:
case AssignmentRequestMethod.Suspend:
// Save Old AssignmentEntity
SaveOldAssignmentEntity(context, (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value));
break;
}
}
else if (context.PluginStage == EventPipeLineStage.PostMainOperationInsideTranasaction)
{
switch (context.GetMethod())
{
case RequestMethod.Create:
OnAssignmentCreated(((CreateResponse)context.Response).PrimaryKeyId);
break;
case AssignmentRequestMethod.AssignUser:
case RequestMethod.Update:
case AssignmentRequestMethod.Activate:
case AssignmentRequestMethod.Close:
case AssignmentRequestMethod.Resume:
case AssignmentRequestMethod.Suspend:
// TODO: Pre Method
OnAssignmentUpdated(LoadOldAssignmentEntity(context), (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value));
break;
}
}
}
示例12: Execute
/// <summary>
/// Executes the specified context.
/// </summary>
/// <param name="context">The context.</param>
public virtual void Execute(BusinessContext context)
{
WorkflowInstanceEntity entityObject = (WorkflowInstanceEntity)BusinessManager.Load(context.GetTargetMetaClassName(), context.GetTargetPrimaryKeyId().Value);
if (entityObject.OwnerDocumentId.HasValue)
{
Document.SetReadOnly(
entityObject.OwnerDocumentId.Value,
false);
}
// TODO: Add New Owner Here
}
示例13: Execute
/// <summary>
/// Executes the specified context.
/// </summary>
/// <param name="context">The context.</param>
public virtual void Execute(BusinessContext context)
{
WorkflowInstanceEntity entityObject = (WorkflowInstanceEntity)BusinessManager.Load(context.GetTargetMetaClassName(), context.GetTargetPrimaryKeyId().Value);
if (entityObject.State == (int)BusinessProcessState.Closed &&
entityObject.ExecutionResult == (int)BusinessProcessExecutionResult.Accepted)
{
if (entityObject.OwnerDocumentId.HasValue)
{
Document.SetReadOnly(
entityObject.OwnerDocumentId.Value,
WorkflowParameters.GetOwnerReadOnly(entityObject));
}
// TODO: Add New Owner Here
}
}
示例14: PreDeleteInsideTransaction
/// <summary>
/// Pres the delete inside transaction.
/// </summary>
/// <param name="context">The context.</param>
protected override void PreDeleteInsideTransaction(BusinessContext context)
{
base.PreDeleteInsideTransaction(context);
CustomizationProfileEntity entity = (CustomizationProfileEntity)BusinessManager.Load(CustomizationProfileEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
int profileId = (int)entity.PrimaryKeyId.Value;
// Reset users to default profile
if (profileId != -1)
{
EntityObject[] list = BusinessManager.List(CustomizationProfileUserEntity.ClassName,
new FilterElementCollection(FilterElement.EqualElement(CustomizationProfileUserEntity.FieldProfileId, profileId)).ToArray());
foreach (CustomizationProfileUserEntity userProfile in list)
{
string userId = userProfile.PrincipalId.ToString();
BusinessManager.Delete(userProfile);
DataCache.RemoveByUser(userId);
}
}
// Delete profile info from cls_CustomizationItem
EntityObject[] customizationItems = BusinessManager.List(CustomizationItemEntity.ClassName,
new FilterElementCollection(FilterElement.EqualElement(CustomizationItemEntity.FieldProfileId, profileId)).ToArray());
foreach (EntityObject obj in customizationItems)
BusinessManager.Delete(obj);
// Delete profile info from cls_CustomPage
EntityObject[] customPageItems = BusinessManager.List(CustomPageEntity.ClassName,
new FilterElementCollection(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId)).ToArray());
foreach (EntityObject obj in customizationItems)
BusinessManager.Delete(obj);
// Delete history
SqlHelper.ExecuteNonQuery(SqlContext.Current,
System.Data.CommandType.StoredProcedure,
"HistoryEntityDelete",
SqlHelper.SqlParameter("@ClassName", SqlDbType.NVarChar, 250, CustomizationProfileEntity.ClassName),
SqlHelper.SqlParameter("@ObjectId", SqlDbType.VarChar, 36, profileId.ToString()));
}
示例15: Execute
/// <summary>
/// Deletes sticked items if the method is "delete" or assignment state is not active
/// </summary>
/// <param name="context">The context.</param>
public void Execute(BusinessContext context)
{
if (context.GetMethod() == RequestMethod.Load ||
context.GetMethod() == RequestMethod.List)
return;
PrimaryKeyId? pkId = context.GetTargetPrimaryKeyId();
if (pkId.HasValue)
{
AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, pkId.Value);
if (entity.OwnerDocumentId.HasValue)
{
if (context.GetMethod() == RequestMethod.Delete ||
entity.State != (int)AssignmentState.Active)
{
if (entity.UserId.HasValue)
{
Calendar.DeleteStickedObject(entity.UserId.Value, entity.OwnerDocumentId.Value, (int)ObjectTypes.Document, (Guid)pkId.Value);
}
}
}
}
}