private static void ServerTargetsToClient(IWfActivity server, WfClientProcessInfo client)
        {
            WfClientActivity ccActivity = client.CurrentActivity;

            foreach (WfTransitionDescriptor st in server.Descriptor.ToTransitions.GetAllCanTransitTransitions(true))
            {
                WfClientActivity targetActivity = null;

                if (st.Key != ccActivity.Descriptor.Key)
                {
                    WfClientActivityConverter.Instance.ServerToClient(st.ToActivity.Instance, ref targetActivity);
                }
                else
                {
                    targetActivity = ccActivity;
                }

                if (targetActivity != null)
                {
                    WfClientTransitionDescriptor ct = null;

                    WfClientTransitionDescriptorConverter.Instance.ServerToClient(st, ref ct);

                    WfClientNextActivity cnat = new WfClientNextActivity();

                    cnat.Transition = ct;
                    cnat.Activity   = targetActivity;

                    client.NextActivities.Add(cnat);
                }
            }
        }
        private static void ServerActivitiesToClient(IWfProcess server, WfClientProcess client)
        {
            foreach (IWfActivity activity in server.Activities)
            {
                WfClientActivity clientActivity = null;

                WfClientActivityConverter.WithoutDescriptorInstance.ServerToClient(activity, ref clientActivity);

                client.Activities.Add(clientActivity);
            }
        }
Ejemplo n.º 3
0
        public static void Output(this WfClientActivity activity, string title)
        {
            if (activity != null)
            {
                Console.WriteLine(title);
                Console.WriteLine("Activity ID = {0}, Name = {1}, Status = {2}", activity.ID, activity.Descriptor.Key, activity.Status);

                activity.Assignees.Output("Assignees");
                activity.Candidates.Output("Candidates");
            }
        }
        public WfClientActivity ServerToClient(IWfActivity server, ref WfClientActivity client)
        {
            if (server != null)
            {
                if (client == null)
                {
                    client = new WfClientActivity();
                }

                client.ID = server.ID;

                if (server.Descriptor != null)
                {
                    client.DescriptorKey = server.Descriptor.Key;
                }

                client.LoadingType              = server.LoadingType.ToClientDataLoadingType();
                client.StartTime                = server.StartTime;
                client.EndTime                  = server.EndTime;
                client.MainStreamActivityKey    = server.MainStreamActivityKey;
                client.BranchProcessReturnValue = server.BranchProcessReturnValue.ToClientBranchProcessReturnType();
                client.BranchProcessGroupsCount = server.BranchProcessGroups.Count;
                client.Operator                 = (WfClientUser)server.Operator.ToClientOguObject();
                client.Status = server.Status.ToClientActivityStatus();

                WfClientAssigneeCollectionConverter.Instance.ServerToClient(server.Assignees, client.Assignees);
                WfClientAssigneeCollectionConverter.Instance.ServerToClient(server.Candidates, client.Candidates);

                if (this._ConvertDescriptor)
                {
                    WfClientActivityDescriptor clientActDesp = null;

                    WfClientActivityDescriptorConverter.Instance.ServerToClient((WfActivityDescriptor)server.Descriptor, ref clientActDesp);
                    client.Descriptor = clientActDesp;
                }
            }
            else
            {
                client = null;
            }

            return(client);
        }
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfClientActivity activity = new WfClientActivity();

            activity.ID = dictionary.GetValue("id", string.Empty);
            activity.DescriptorKey = dictionary.GetValue("descriptorKey", string.Empty);
            activity.StartTime = dictionary.GetValue("startTime", DateTime.MinValue);
            activity.EndTime = dictionary.GetValue("endTime", DateTime.MinValue);
            activity.LoadingType = dictionary.GetValue("loadingType", WfClientDataLoadingType.Memory);
            activity.MainStreamActivityKey = dictionary.GetValue("mainStreamActivityKey", string.Empty);
            activity.BranchProcessReturnValue = dictionary.GetValue("branchProcessReturnValue", WfClientBranchProcessReturnType.AllFalse);
            activity.BranchProcessGroupsCount = dictionary.GetValue("branchProcessGroupsCount", 0);
            activity.Operator = JSONSerializerExecute.Deserialize<WfClientUser>(dictionary.GetValue("operator", (object)null));
            activity.Status = dictionary.GetValue("status", WfClientActivityStatus.NotRunning);

            JSONSerializerExecute.FillDeserializedCollection(dictionary.GetValue("assignees", (object)null), activity.Assignees);
            JSONSerializerExecute.FillDeserializedCollection(dictionary.GetValue("candidates", (object)null), activity.Candidates);

            activity.Descriptor = JSONSerializerExecute.Deserialize<WfClientActivityDescriptor>(dictionary.GetValue("descriptor", (object)null));

            return activity;
        }
Ejemplo n.º 6
0
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            WfClientActivity activity = (WfClientActivity)obj;

            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            dictionary.AddNonDefaultValue("id", activity.ID);
            dictionary.AddNonDefaultValue("descriptorKey", activity.DescriptorKey);
            dictionary.AddNonDefaultValue("startTime", activity.StartTime);
            dictionary.AddNonDefaultValue("endTime", activity.EndTime);
            dictionary.AddNonDefaultValue("loadingType", activity.LoadingType);
            dictionary.AddNonDefaultValue("mainStreamActivityKey", activity.MainStreamActivityKey);
            dictionary.AddNonDefaultValue("operator", activity.Operator);
            dictionary.AddNonDefaultValue("status", activity.Status);
            dictionary.Add("assignees", activity.Assignees);
            dictionary.Add("candidates", activity.Candidates);
            dictionary.Add("branchProcessReturnValue", activity.BranchProcessReturnValue);
            dictionary.Add("branchProcessGroupsCount", activity.BranchProcessGroupsCount);
            dictionary.AddNonDefaultValue("descriptor", activity.Descriptor);

            return(dictionary);
        }
Ejemplo n.º 7
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfClientActivity activity = new WfClientActivity();

            activity.ID                       = dictionary.GetValue("id", string.Empty);
            activity.DescriptorKey            = dictionary.GetValue("descriptorKey", string.Empty);
            activity.StartTime                = dictionary.GetValue("startTime", DateTime.MinValue);
            activity.EndTime                  = dictionary.GetValue("endTime", DateTime.MinValue);
            activity.LoadingType              = dictionary.GetValue("loadingType", WfClientDataLoadingType.Memory);
            activity.MainStreamActivityKey    = dictionary.GetValue("mainStreamActivityKey", string.Empty);
            activity.BranchProcessReturnValue = dictionary.GetValue("branchProcessReturnValue", WfClientBranchProcessReturnType.AllFalse);
            activity.BranchProcessGroupsCount = dictionary.GetValue("branchProcessGroupsCount", 0);
            activity.Operator                 = JSONSerializerExecute.Deserialize <WfClientUser>(dictionary.GetValue("operator", (object)null));
            activity.Status                   = dictionary.GetValue("status", WfClientActivityStatus.NotRunning);

            JSONSerializerExecute.FillDeserializedCollection(dictionary.GetValue("assignees", (object)null), activity.Assignees);
            JSONSerializerExecute.FillDeserializedCollection(dictionary.GetValue("candidates", (object)null), activity.Candidates);

            activity.Descriptor = JSONSerializerExecute.Deserialize <WfClientActivityDescriptor>(dictionary.GetValue("descriptor", (object)null));

            return(activity);
        }
        public WfClientActivity ServerToClient(IWfActivity server, ref WfClientActivity client)
        {
            if (server != null)
            {
                if (client == null)
                    client = new WfClientActivity();

                client.ID = server.ID;

                if (server.Descriptor != null)
                    client.DescriptorKey = server.Descriptor.Key;

                client.LoadingType = server.LoadingType.ToClientDataLoadingType();
                client.StartTime = server.StartTime;
                client.EndTime = server.EndTime;
                client.MainStreamActivityKey = server.MainStreamActivityKey;
                client.BranchProcessReturnValue = server.BranchProcessReturnValue.ToClientBranchProcessReturnType();
                client.BranchProcessGroupsCount = server.BranchProcessGroups.Count;
                client.Operator = (WfClientUser)server.Operator.ToClientOguObject();
                client.Status = server.Status.ToClientActivityStatus();

                WfClientAssigneeCollectionConverter.Instance.ServerToClient(server.Assignees, client.Assignees);
                WfClientAssigneeCollectionConverter.Instance.ServerToClient(server.Candidates, client.Candidates);

                if (this._ConvertDescriptor)
                {
                    WfClientActivityDescriptor clientActDesp = null;

                    WfClientActivityDescriptorConverter.Instance.ServerToClient((WfActivityDescriptor)server.Descriptor, ref clientActDesp);
                    client.Descriptor = clientActDesp;
                }
            }
            else
                client = null;

            return client;
        }
        public WfClientProcessInfo ServerToClient(IWfProcess process, ref WfClientProcessInfo client)
        {
            process.NullCheck("process");

            if (client == null)
            {
                client = new WfClientProcessInfo();
            }

            WfClientProcessInfoBaseConverter.Instance.ServerToClient(process, client);

            WfClientActivity currentActivity = null;

            WfClientActivityConverter.Instance.ServerToClient(process.CurrentActivity, ref currentActivity);

            client.CurrentActivity = currentActivity;

            IWfActivity previousServerActivity = FindPreviousActivity(process.CurrentActivity);

            if (previousServerActivity != null)
            {
                WfClientActivity previousActivity = null;

                WfClientActivityConverter.Instance.ServerToClient(previousServerActivity, ref previousActivity);

                client.PreviousActivity = previousActivity;
            }

            client.NextActivities.Clear();

            if (client.CurrentActivity != null)
            {
                ServerTargetsToClient(process.CurrentActivity, client);
            }

            return(client);
        }
Ejemplo n.º 10
0
        public static WfClientProcess GetClientProcess(IWfProcess process)
        {
            process.NullCheck("process");

            WfClientProcess clientProcess = new WfClientProcess()
            {
                ProcessID     = process.ID,
                ProcessStatus = process.Status.ToString(),
                Activities    = new List <WfClientActivity>(),
                ResourceID    = process.ResourceID
            };

            if (process.Status == WfProcessStatus.Completed)
            {
                clientProcess.ProcessStatusString = "已完成";
            }
            else
            if (process.Status == WfProcessStatus.Aborted)
            {
                clientProcess.ProcessStatusString = "已驳回";
            }

            clientProcess.UISwitches.FillByProcess(process, process.CurrentActivity.ID, DeluxeIdentity.CurrentUser);

            GenericOpinionCollection opinions = GenericOpinionAdapter.Instance.Load(
                builder => builder.AppendItem("RESOURCE_ID", process.ResourceID));

            clientProcess.CurrentOpinion = GetUserActivityOpinion(opinions, process.CurrentActivity, DeluxeIdentity.CurrentUser);

            WfMainStreamActivityDescriptorCollection activityCollection = process.GetMainStreamActivities(false);

            foreach (var item in activityCollection)
            {
                IWfActivity activity = item.Activity.Instance;

                WfClientActivity clientActivity = new WfClientActivity()
                {
                    ActivityID     = item.Activity.Instance.ID,
                    ActivityName   = item.Activity.Name,
                    ActivityStatus = item.Activity.Instance.Status.ToString(),
                    IsActive       = (item.Activity.Instance.Status == WfActivityStatus.Running),
                    Approvers      = (item.Activity.Instance.Candidates.Count > 0 ? item.Activity.Instance.Candidates[0].User.Name : ""),
                    ApproverCount  = item.Activity.Instance.Candidates.Count,
                    ActivityScene  = item.Activity.Scene,
                    StartTime      = item.Activity.Instance.StartTime
                };

                if (item.Activity.Instance.Candidates.Count > 1)
                {
                    clientActivity.Approvers += "...";
                }

                clientActivity.ApproverList = string.Join(",", item.Activity.Instance.Candidates.Select(a => a.User.Name).ToArray());

                if (item.Activity.Instance.Status == WfActivityStatus.Running)
                {
                    clientProcess.CurrentActivity = clientActivity;
                }
                else if (item.Activity.Instance.Status == WfActivityStatus.Completed || item.Activity.Instance.Status == WfActivityStatus.Aborted)
                {
                    var opinion = opinions.Where(o => o.ActivityID == clientActivity.ActivityID).FirstOrDefault();
                    if (opinion != null)
                    {
                        clientActivity.Comment             = opinion.Content;
                        clientActivity.Action              = opinion.OpinionType;
                        clientActivity.Approver            = opinion.IssuePerson.DisplayName;
                        clientActivity.ApprovalTime        = opinion.IssueDatetime;
                        clientActivity.ApprovalElapsedTime = FormatElapsedTime(opinion.IssueDatetime - activity.StartTime);
                    }
                }

                clientProcess.Activities.Add(clientActivity);
            }

            foreach (GenericOpinion go in opinions)
            {
                WfClientActivity parentActivity = clientProcess.Activities.Where(a => a.ActivityID == go.ActivityID).FirstOrDefault();
                if (parentActivity != null)
                {
                    WfClientActivityHistory history = new WfClientActivityHistory()
                    {
                        ID                  = go.ID,
                        ActivityID          = go.ActivityID,
                        ActivityName        = parentActivity.ActivityName,
                        Action              = go.OpinionType,
                        Comment             = go.Content,
                        Approver            = go.IssuePerson.DisplayName,
                        ApprovalType        = parentActivity.ApprovalType,
                        ApprovalTime        = go.IssueDatetime,
                        ApprovalElapsedTime = FormatElapsedTime(go.IssueDatetime - parentActivity.StartTime)
                    };
                    clientProcess.ActivityHistories.Add(history);
                }
            }
            clientProcess.ActivityHistories = clientProcess.ActivityHistories.OrderBy(a => a.ApprovalTime).ToList();

            foreach (string key in process.ApplicationRuntimeParameters.Keys)
            {
                clientProcess.ProcessParameters.Add(key, process.ApplicationRuntimeParameters[key]);
            }

            return(clientProcess);
        }