public void AddData(ApprovalChainData data)
 {
     if (ApprovalChainData == null)
     {
         this.ApprovalChainData = new List <ApprovalChainData>();
     }
     ApprovalChainData.Add(data);
 }
 public bool RemoveData(ApprovalChainData data)
 {
     return(ApprovalChainData.Remove(data));
 }
Exemple #3
0
        /// <summary>
        /// 通过节点与人员对应关系生成审批XML
        /// </summary>
        /// <param name="pairList"></param>
        /// <returns></returns>
        private static string CreateApproveXML(string requestor, List <Triplet> pairList, string xml, string infoSource)
        {
            ApprovalChainProcess process = new ApprovalChainProcess("自定义流程", "");

            process.DefinitionType = infoSource;
            ApprovalChainData data = new ApprovalChainData();

            process.AddData(data);

            //发起人节点
            ApprovalChainActivity activity = new ApprovalChainActivity(Guid.NewGuid().ToString(), "发起人", true, "http://localhost:3373/Resubmit.aspx?SN=", EnumActivityType.SP.ToString());

            activity.Status           = EnumStatus.Completed.ToString();
            activity.ActionWeightType = EnumActionWeightType.N.ToString();
            ApprovalChainDestination originator = new ApprovalChainDestination("", requestor, "", "", EnumDestinationUserType.User.ToString());

            originator.Status = EnumStatus.Completed.ToString();
            activity.AddDestination(originator);
            process.AddActivity(activity);

            foreach (Triplet tl in pairList)
            {
                //string nodeName = K2DBHelper.GetProcessNodeName(tl.First.ToString());
                DataSet ds = K2DBHelper.GetProcessNodeByNodeID(tl.First.ToString());
                if (ds != null)
                {
                    string nodeName     = ds.Tables[0].Rows[0]["NodeName"].ToString();
                    string weightedType = ds.Tables[0].Rows[0]["WeightedType"].ToString();
                    string samplingRate = string.Empty;
                    if (ds.Tables[0].Rows[0]["SamplingRate"] != DBNull.Value)
                    {
                        samplingRate = ds.Tables[0].Rows[0]["SamplingRate"].ToString();
                    }

                    activity = new ApprovalChainActivity(tl.First.ToString(), nodeName, true, tl.Third.ToString(), EnumActivityType.SP.ToString());
                    string[] users = tl.Second.ToString().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    ApprovalChainDestination des = new ApprovalChainDestination();

                    if (weightedType == EnumActionWeightType.P.ToString())
                    {
                        activity.ActionWeightType = weightedType;
                        activity.ActionWeight     = samplingRate;
                        foreach (string user in users)
                        {
                            ds = K2DBHelper.GetEmployeeInfoByUserAd(user);
                            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            {
                                string Id    = ds.Tables[0].Rows[0]["EmployeeCode"].ToString();
                                string email = ds.Tables[0].Rows[0]["Email"].ToString();
                                string name  = ds.Tables[0].Rows[0]["EmployeeName"].ToString();
                                des.AddDestinationUser(new ApprovalChainDestinationUser(Id, user, name, email, EnumDestinationUserType.User.ToString()));
                            }
                        }
                        activity.AddDestination(des);
                    }
                    else if (weightedType == EnumActionWeightType.R.ToString())
                    {
                        activity.ActionWeightType = weightedType;
                        activity.ActionWeight     = "1";
                        foreach (string user in users)
                        {
                            ds = K2DBHelper.GetEmployeeInfoByUserAd(user);
                            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            {
                                string Id    = ds.Tables[0].Rows[0]["EmployeeCode"].ToString();
                                string email = ds.Tables[0].Rows[0]["Email"].ToString();
                                string name  = ds.Tables[0].Rows[0]["EmployeeName"].ToString();
                                des.AddDestinationUser(new ApprovalChainDestinationUser(Id, user, name, email, EnumDestinationUserType.User.ToString()));
                            }
                        }
                        activity.AddDestination(des);
                    }
                    else
                    {
                        activity.ActionWeightType = weightedType;
                        foreach (string user in users)
                        {
                            ds = K2DBHelper.GetEmployeeInfoByUserAd(user);
                            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            {
                                string Id    = ds.Tables[0].Rows[0]["EmployeeCode"].ToString();
                                string email = ds.Tables[0].Rows[0]["Email"].ToString();
                                string name  = ds.Tables[0].Rows[0]["EmployeeName"].ToString();
                                activity.AddDestination(new ApprovalChainDestination(Id, user, name, email, EnumDestinationUserType.User.ToString()));
                            }
                        }
                    }
                    process.AddActivity(activity);
                }
            }

            string processApprovalChain = SerializationHelper.Serialize(process);

            return(processApprovalChain);
        }