public WfProcessCurrentAssignee(WfAssignee assignee)
        {
            assignee.NullCheck("assignee");

            this.UserID       = assignee.User.ID;
            this.UserName     = assignee.User.DisplayName;
            this.UserPath     = assignee.User.FullPath;
            this.AssigneeType = assignee.AssigneeType;
            this.Url          = assignee.Url;
        }
        private static WfAssignee DataRowToAssignee(DataRow row)
        {
            WfAssignee result = new WfAssignee();

            result.AssigneeType = (WfAssigneeType)Enum.Parse(typeof(WfAssigneeType), row["ASSIGNEE_TYPE"].ToString(), true);

            OguUser user = new OguUser();

            user.ID       = row["USER_ID"].ToString();
            user.Name     = row["USER_NAME"].ToString();
            user.FullPath = row["USER_PATH"].ToString();

            result.User = user;

            return(result);
        }
Ejemplo n.º 3
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfAssignee assignee = new WfAssignee();

            assignee.AssigneeType = DictionaryHelper.GetValue(dictionary, "AssigneeType", WfAssigneeType.Normal);
            assignee.User         = JSONSerializerExecute.Deserialize <OguUser>(dictionary["User"]);
            assignee.Url          = DictionaryHelper.GetValue(dictionary, "Url", (string)null);
            assignee.Selected     = DictionaryHelper.GetValue(dictionary, "Selected", true);

            if (dictionary.ContainsKey("Delegator"))
            {
                assignee.Delegator = JSONSerializerExecute.Deserialize <OguUser>(dictionary["Delegator"]);
            }

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

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

            DictionaryHelper.AddNonDefaultValue(dictionary, "AssigneeType", assignee.AssigneeType);
            dictionary.Add("User", assignee.User);
            DictionaryHelper.AddNonDefaultValue(dictionary, "Url", assignee.Url);

            DictionaryHelper.AddNonDefaultValue(dictionary, "Selected", assignee.Selected);

            if (assignee.Delegator != null)
            {
                dictionary.Add("Delegator", assignee.Delegator);
            }

            dictionary["__type"] = obj.GetType().AssemblyQualifiedName;

            return(dictionary);
        }
Ejemplo n.º 5
0
        private static WfTransferParams PrepareTransferParams(IWfProcess process, WfAssignee assignee, WfSimulationContext simulationContext)
        {
            IWfActivity originalActivity = process.CurrentActivity;

            IWfTransitionDescriptor transition = FindNextTransitionDescriptor(process);

            WfTransferParams transferParams = null;

            if (transition != null)
            {
                transferParams = new WfTransferParams(transition.ToActivity);

                transferParams.Assignees.CopyFrom(transition.ToActivity.Instance.Candidates);
                transferParams.FromTransitionDescriptor = transition;

                if (assignee != null)
                {
                    transferParams.Operator = assignee.User;
                }
            }

            return(transferParams);
        }
Ejemplo n.º 6
0
        public void GenerateCandidatesFromResources()
        {
            WfAssigneeCollection candidates = this.Descriptor.Resources.ToAssignees();

            //根据是否允许多个候选人,设置Selected属性
            if (this.Descriptor.Properties.GetValue("AllowAssignToMultiUsers", true) == false)
            {
                //先查找原来选中的
                WfAssignee originalSelected = this.Candidates.Find(a => a.Selected);

                candidates.ForEach(a => a.Selected = false);

                WfAssignee matchedSelected = null;

                if (originalSelected != null)
                {
                    matchedSelected = candidates.Find(a => string.Compare(a.User.ID, originalSelected.User.ID, true) == 0);
                }

                if (matchedSelected != null)
                {
                    matchedSelected.Selected = true;
                }
                else
                {
                    if (candidates.Count > 0)
                    {
                        candidates[0].Selected = true;
                    }
                }
            }

            this.Candidates.Clear();
            this.Candidates.CopyFrom(candidates);

            this.Candidates.Distinct((a1, a2) => string.Compare(a1.User.ID, a2.User.ID, true) == 0 && a1.AssigneeType == a2.AssigneeType);
        }