예제 #1
0
 private void EvaluateRule(object sender, ConditionalEventArgs e)
 {
     if (K2.EventInstance.ActivityInstanceDestination.ActivityInstance.SingleInstance)
     {
         e.Result = SucceedingRuleHelper.AnyOutcomesEvaluatedSuccessfully(K2);
     }
     else
     {
         e.Result = true;
     }
 }
예제 #2
0
        public void Main($contexttype$ K2)
        {
            if (SucceedingRuleHelper.AnyOutcomesEvaluatedSuccessfully(K2))
            {
                try
                {
                    using (SourceCode.Workflow.Common.HostedServers.SmartObjects smartObjects = new SmartObjects(K2.Configuration.SmartObjectServer))
                    {
                        SourceCode.SmartObjects.Client.SmartObject smartObject = smartObjects.GetSmartObject(K2.Configuration.CRMFunctionsSmartObject);

                        SourceCode.SmartObjects.Client.SmartMethod smartMethod = smartObjects.GetSingleMethod(smartObject, "BulkActionTasksSetCriteria");

                        smartObject.Properties["FromState"].Value           = "0";
                        smartObject.Properties["FromStatus"].Value          = "3";
                        smartObject.Properties["ToState"].Value             = "2";
                        smartObject.Properties["ToStatus"].Value            = "6";
                        smartObject.Properties["Regarding"].Value           = K2.Configuration.CRMEntityType;
                        smartObject.Properties["RegardingId"].Value         = K2.Configuration.CRMEntityId;;
                        smartObject.Properties["K2ActivityName"].Value      = K2.ActivityInstance.Activity.Name;
                        smartObject.Properties["K2ProcessName"].Value       = K2.ProcessInstance.Process.Name;
                        smartObject.Properties["K2ProcessInstanceId"].Value = K2.ProcessInstance.ID.ToString();

                        SourceCode.SmartObjects.Client.SmartObject smo = smartObjects.ExecuteSingleMethod(smartMethod);
                        K2.SucceedingRule = true;
                    }
                }
                catch (Exception ex)
                {
                    K2.ProcessInstance.Logger.LogErrorMessage("CRM Client Event - Completing task", ex.Message);
                }
            }
            else
            {
                K2.SucceedingRule = false;
            }
        }