当前位置: 首页>>代码示例>>C#>>正文


C# BusinessContext.GetTargetPrimaryKeyId方法代码示例

本文整理汇总了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());
        }
开发者ID:0anion0,项目名称:IBN,代码行数:35,代码来源:AssignmentRequestHandler.cs

示例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);
 }
开发者ID:smchristenson,项目名称:CommerceStarterKit,代码行数:8,代码来源:BusinessFoundationGenericHandler.cs

示例3: PreDeleteInsideTransaction

        protected override void PreDeleteInsideTransaction(BusinessContext context)
        {
            base.PreDeleteInsideTransaction(context);

            // Remove SecureRole From Principal
            DirectoryManager.DeletePrincipal(context.GetTargetPrimaryKeyId().Value);
        }
开发者ID:0anion0,项目名称:IBN,代码行数:7,代码来源:DirectoryWorkGroupRequestHandler.cs

示例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();
        }
开发者ID:0anion0,项目名称:IBN,代码行数:12,代码来源:OutgoingMessageQueueRequestHandler.cs

示例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());
        }
开发者ID:0anion0,项目名称:IBN,代码行数:13,代码来源:ListRequestHandler.cs

示例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));
                    }
                }
            }
        }
开发者ID:0anion0,项目名称:IBN,代码行数:23,代码来源:AssignmentAutoCompletePlugin.cs

示例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;
            }
        }
开发者ID:0anion0,项目名称:IBN,代码行数:46,代码来源:LocalDiskEntityObjectPlugin.cs

示例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
        }
开发者ID:0anion0,项目名称:IBN,代码行数:15,代码来源:ListObjectRequestHandler.cs

示例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);
                        }
                    }
                }
            }
        }
开发者ID:0anion0,项目名称:IBN,代码行数:24,代码来源:CleanupBridgeElementPlugin.cs

示例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]);
            }
        }
开发者ID:0anion0,项目名称:IBN,代码行数:11,代码来源:DirectoryWorkGroupRequestHandler.cs

示例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;
         }
     }
 }
开发者ID:0anion0,项目名称:IBN,代码行数:44,代码来源:RaiseAssignmentEventPlugin.cs

示例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
        }
开发者ID:0anion0,项目名称:IBN,代码行数:17,代码来源:ResetBusinessProcessOwnerReadOnlyPlugin.cs

示例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
            }
        }
开发者ID:0anion0,项目名称:IBN,代码行数:21,代码来源:SetBusinessProcessOwnerReadOnlyPlugin.cs

示例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()));
        }
开发者ID:0anion0,项目名称:IBN,代码行数:44,代码来源:CustomizationProfileRequestHandler.cs

示例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);
                        }
                    }
                }
            }
        }
开发者ID:0anion0,项目名称:IBN,代码行数:28,代码来源:StickedObjectCleanUpPlugin.cs


注:本文中的BusinessContext.GetTargetPrimaryKeyId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。