예제 #1
0
파일: DailyReport.cs 프로젝트: radtek/EMIP
        public virtual object GetTeamReports(HttpContext context)
        {
            YZRequest request   = new YZRequest(context);
            string    myaccount = request.GetString("account", YZAuthHelper.LoginUserAccount);
            DateTime  date      = request.GetDateTime("date");

            BPMObjectNameCollection accounts = new BPMObjectNameCollection();

            accounts.Add(myaccount);

            using (BPMConnection bpmcn = new BPMConnection())
            {
                bpmcn.WebOpen();

                MemberCollection positions = OrgSvr.GetUserPositions(bpmcn, myaccount);
                foreach (Member position in positions)
                {
                    DirectXSCollection xss = position.GetDirectXSs(bpmcn);
                    foreach (DirectXS xs in xss)
                    {
                        if (!accounts.Contains(xs.UserAccount))
                        {
                            accounts.Add(xs.UserAccount);
                        }
                    }
                }

                DailyReportCollection rv = new DailyReportCollection();
                foreach (string account in accounts)
                {
                    DailyReport dailyReport;

                    using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
                    {
                        using (IDbConnection cn = provider.OpenConnection())
                        {
                            dailyReport = DailyReportManager.TryGetReport(provider, cn, account, date);

                            if (dailyReport == null)
                            {
                                dailyReport         = new DailyReport();
                                dailyReport.Account = account;
                                dailyReport.Date    = date;
                            }

                            rv.Add(dailyReport);
                        }
                    }

                    User user = User.TryGetUser(bpmcn, account);
                    dailyReport["ShortName"] = user == null ? "" : user.ShortName;
                }

                return(rv);
            }
        }
예제 #2
0
    protected void _btnSubmit_Click(object sender, EventArgs e)
    {
        BPMObjectNameCollection rejectedNotifys = new BPMObjectNameCollection();

        foreach (ListItem lstItem in this._chksProvider.Items)
        {
            if (!lstItem.Selected)
            {
                rejectedNotifys.Add(lstItem.Value);
            }
        }

        using (BPMConnection cn = new BPMConnection())
        {
            try
            {
                cn.WebOpen();

                BPM.Client.User.SaveNotifySetting(cn, YZAuthHelper.LoginUserAccount, rejectedNotifys);

                this._labErr.Visible  = false;
                this._labInfo.Visible = true;
                this._labInfo.Text    = Resources.YZStrings.Aspx_ChgNotify_Success;
            }
            catch (Exception exp)
            {
                this._labInfo.Visible = true;
                this._labInfo.Text    = Resources.YZStrings.Aspx_ChgNotify_Fail;
                this._labErr.Visible  = true;
                this._labErr.Text     = exp.Message;
            }
        }
    }
예제 #3
0
    public static void ApplayRecordPermision(BPMConnection cn, JsonItemCollection items, string rsid, string tableName, string jsonitemKeyAttrName)
    {
        //获得资源上的记录级权限种类
        UserResourcePermisionCollection resourcePerms = UserResourceSecurityManager.GetResourcePermisions(cn, rsid);
        BPMObjectNameCollection         permNames     = new BPMObjectNameCollection();

        foreach (UserResourcePermision resourcePerm in resourcePerms)
        {
            if (resourcePerm.PermType == UserResourcePermisionType.Record)
            {
                permNames.Add(resourcePerm.PermName);
            }
        }

        //应用权限
        foreach (JsonItem item in items)
        {
            string key = Convert.ToString(item.Attributes[jsonitemKeyAttrName]);
            bool[] rv  = RecordSecurityManager.CheckPermision(cn, tableName, key, permNames);

            JsonItem jsonPerm = new JsonItem();
            item.Attributes["perm"] = jsonPerm;
            for (int i = 0; i < permNames.Count; i++)
            {
                jsonPerm.Attributes[permNames[i]] = rv[i];
            }
        }
    }
예제 #4
0
        public static BPMObjectNameCollection GetNotifyUsers(YZResourceType resType, string resId)
        {
            BPMObjectNameCollection uids = new BPMObjectNameCollection();

            switch (resType)
            {
            case YZResourceType.Group:
                using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
                {
                    using (IDbConnection cn = provider.OpenConnection())
                    {
                        MemberCollection members = GroupManager.GetGroupMembers(provider, cn, Int32.Parse(resId));
                        foreach (Member member in members)
                        {
                            uids.Add(member.UID);
                        }
                    }
                }
                break;

            case YZResourceType.SingleChat:
                using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
                {
                    using (IDbConnection cn = provider.OpenConnection())
                    {
                        P2PGroup.P2PGroup group = P2PGroupManager.GetGroup(provider, cn, Int32.Parse(resId));
                        uids.Add(group.Account1);
                        uids.Add(group.Account2);
                    }
                }
                break;

            case YZResourceType.Task:
                using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
                {
                    using (IDbConnection cn = provider.OpenConnection())
                    {
                        uids = NotifyManager.GetNotifyUsersTaskSocial(provider, cn, Int32.Parse(resId));
                    }
                }
                break;
            }

            return(uids);
        }
예제 #5
0
        public virtual JObject GetUserDataESB(BPMConnection cn, JObject request)
        {
            string esbObjectName         = (string)request["ESB"];
            YZDSFilterCollection filters = request["Filter"] != null ? request["Filter"].ToObject <YZDSFilterCollection>() : null;

            //获取参数
            string[]                strs       = esbObjectName.Split(':');
            SourceTypeEnum          sourceType = (SourceTypeEnum)Enum.Parse(typeof(SourceTypeEnum), strs[0]);
            SourceInfo              sourceInfo = SourceInfoManager.GetSourceInfo(sourceType, strs[1]);
            SourceVisit             visit      = new SourceVisit(sourceInfo);
            BPMObjectNameCollection names      = new BPMObjectNameCollection();
            List <ColumnInfo>       values     = new List <ColumnInfo>();

            if (filters != null)
            {
                foreach (KeyValuePair <string, YZDSFilter> filter in filters)
                {
                    names.Add(filter.Key);
                    values.Add(new ColumnInfo()
                    {
                        columnName   = filter.Key,
                        defaultValue = filter.Value.value
                    });
                }

                foreach (ColumnInfo column in visit.GetParameter())
                {
                    if (!names.Contains(column.rename))
                    {
                        names.Add(column.rename);
                        values.Add(new ColumnInfo()
                        {
                            columnName   = column.rename,
                            defaultValue = column.defaultValue
                        });
                    }
                }
            }
            DataTable     dt    = visit.GetResult(values);
            FlowDataTable table = new FlowDataTable(dt);

            return(this.ToResult(table, false));
        }
예제 #6
0
파일: DataSource.cs 프로젝트: radtek/EMIP
        public virtual DataTable GetESBDataNoPaged(HttpContext context)
        {
            YZRequest            request       = new YZRequest(context);
            string               esbObjectName = request.GetString("ESB");
            YZDSFilterCollection filters       = JObject.Parse(request.GetString("Filter", "{}")).ToObject <YZDSFilterCollection>();

            //获取参数
            string[]                strs       = esbObjectName.Split(':');
            SourceTypeEnum          sourceType = (SourceTypeEnum)Enum.Parse(typeof(SourceTypeEnum), strs[0]);
            SourceInfo              sourceInfo = SourceInfoManager.GetSourceInfo(sourceType, strs[1]);
            SourceVisit             visit      = new SourceVisit(sourceInfo);
            BPMObjectNameCollection names      = new BPMObjectNameCollection();
            List <ColumnInfo>       values     = new List <ColumnInfo>();

            if (filters != null)
            {
                foreach (KeyValuePair <string, YZDSFilter> filter in filters)
                {
                    names.Add(filter.Key);
                    values.Add(new ColumnInfo()
                    {
                        columnName   = filter.Key,
                        defaultValue = filter.Value.value
                    });
                }

                foreach (ColumnInfo column in visit.GetParameter())
                {
                    if (!names.Contains(column.rename))
                    {
                        names.Add(column.rename);
                        values.Add(new ColumnInfo()
                        {
                            columnName   = column.rename,
                            defaultValue = column.defaultValue
                        });
                    }
                }
            }

            return(visit.GetResult(values));
        }
예제 #7
0
    public static string GetUserShortNameListString(UserCollection users)
    {
        BPMObjectNameCollection names = new BPMObjectNameCollection();

        foreach (User user in users)
        {
            names.Add(YZStringHelper.GetUserShortName(user.Account, user.DisplayName));
        }

        return(names.ToStringList(';'));
    }
예제 #8
0
    public static string GetUserNameListString(StepRecipientCollection recps)
    {
        BPMObjectNameCollection names = new BPMObjectNameCollection();

        foreach (StepRecipient recp in recps)
        {
            names.Add(YZStringHelper.GetRecpientDisplayName(recp));
        }

        return(names.ToStringList(';'));
    }
예제 #9
0
파일: Footmark.cs 프로젝트: radtek/EMIP
        public virtual object GetTeamList(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            DateTime  date    = request.GetDateTime("date");

            string uid = YZAuthHelper.LoginUserAccount;
            BPMObjectNameCollection accounts = new BPMObjectNameCollection();

            accounts.Add(uid);

            using (BPMConnection bpmcn = new BPMConnection())
            {
                bpmcn.WebOpen();

                MemberCollection positions = OrgSvr.GetUserPositions(bpmcn, uid);
                foreach (Member position in positions)
                {
                    DirectXSCollection xss = position.GetDirectXSs(bpmcn);
                    foreach (DirectXS xs in xss)
                    {
                        if (!accounts.Contains(xs.UserAccount))
                        {
                            accounts.Add(xs.UserAccount);
                        }
                    }
                }

                using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
                {
                    using (IDbConnection cn = provider.OpenConnection())
                    {
                        FootmarkCollection footmarks = FootmarkManager.GetFootmarks(provider, cn, accounts, date);
                        return(new
                        {
                            children = this.SerializeAsTeamList(bpmcn, footmarks),
                            unsignedusers = footmarks.GetUnSignedUsers(bpmcn, accounts)
                        });
                    }
                }
            }
        }
예제 #10
0
파일: DataSource.cs 프로젝트: radtek/EMIP
        public virtual BPMObjectNameCollection GetESBObjects(HttpContext context)
        {
            YZRequest request = new YZRequest(context);

            BPMObjectNameCollection rv   = new BPMObjectNameCollection();
            SourceInfoCollection    list = SourceInfoManager.GetSourceList();

            foreach (var item in list.ToArray())
            {
                rv.Add(string.Format("{0}:{1}", item.sourceType.ToString(), item.sourceName));
            }
            return(rv);
        }
예제 #11
0
        public virtual JObject GetResourcePerms(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    rsid    = request.GetString("rsid");
            JObject   rv      = new JObject();

            //获得数据
            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                UserResource userResource = UserResource.Open(cn, rsid);
                rv["ResourceName"] = userResource.ResourceName;

                UserResourcePermisionCollection perms = UserResource.GetPermisions(cn, rsid);
                URACL acl = UserResource.GetACL(cn, rsid);

                JArray jperms = new JArray();
                rv["perms"] = jperms;
                foreach (UserResourcePermision perm in perms)
                {
                    JObject jperm = JObject.FromObject(perm);
                    jperms.Add(jperm);
                    JArray jRoles = new JArray();
                    jperm["roles"] = jRoles;
                    BPMObjectNameCollection checkedSids = new BPMObjectNameCollection();

                    foreach (URACE ace in acl.ACEs)
                    {
                        if (checkedSids.Contains(ace.SID))
                        {
                            continue;
                        }

                        checkedSids.Add(ace.SID);

                        SecurityToken token = new SecurityToken();
                        token.SIDs.Add(ace.SID);
                        if (acl.HasPermision(token, perm.PermName))
                        {
                            JObject jRole = new JObject();
                            jRoles.Add(jRole);

                            jRole["Name"] = ace.GetSIDDisplayName(cn);
                        }
                    }
                }
            }

            return(rv);
        }
예제 #12
0
        public virtual string GetDbInList(BPMObjectNameCollection sids, string uid)
        {
            if (sids == null)
            {
                return(null);
            }

            BPMObjectNameCollection lsids = new BPMObjectNameCollection();

            sids.CopyTo(lsids);
            lsids.Add(uid);

            return(this.GetDbInList(lsids));
        }
예제 #13
0
        public string GetDBInString(BPMObjectNameCollection sids, string uid)
        {
            if (sids == null)
            {
                return(null);
            }

            BPMObjectNameCollection lsids = new BPMObjectNameCollection();

            sids.CopyTo(lsids);
            lsids.Add(uid);

            return(this.GetDBInString(lsids));
        }
예제 #14
0
        public virtual JObject GetReActiveSteps(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            int       taskid  = request.GetInt32("TaskID");

            JArray children = new JArray();

            //获得数据
            BPMStepCollection steps = null;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                steps = BPMTask.GetAllSteps(cn, taskid);

                BPMObjectNameCollection stepNames = new BPMObjectNameCollection();
                for (int i = steps.Count - 1; i >= 0; i--)
                {
                    BPMProcStep step = steps[i];

                    if (!step.IsHumanStep)
                    {
                        continue;
                    }

                    if (step.IsTaskOptStep || step.IsIndicateStep || step.IsInformStep || step.IsConsignStep)
                    {
                        continue;
                    }

                    if (stepNames.Contains(step.NodeName))
                    {
                        continue;
                    }

                    stepNames.Add(step.NodeName);
                    children.Add(Serialize(cn, step));
                }
            }

            //输出数据
            JObject rv = new JObject();

            rv[YZJsonProperty.success]  = true;
            rv[YZJsonProperty.total]    = children.Count;
            rv[YZJsonProperty.children] = children;
            return(rv);
        }
예제 #15
0
        public virtual JObject Public(HttpContext context)
        {
            YZRequest request         = new YZRequest(context);
            int       count           = request.GetInt32("Count");
            int       sidCount        = request.GetInt32("SIDCount");
            string    dataSource      = request.GetString("DataSource", null);
            string    rsid            = request.GetString("RSID");
            string    publicPermision = request.GetString("PublicPerm");
            bool      leadershipToken = request.GetBool("LeadershipToken", false);
            string    comments        = request.GetString("Comments", null);

            JArray processedItems = new JArray();

            BPMObjectNameCollection permisions = new BPMObjectNameCollection();

            permisions.Add(publicPermision);

            SIDPairCollection sidPairs = new SIDPairCollection();

            for (int j = 0; j < sidCount; j++)
            {
                string sid = request.GetString("SID" + j.ToString());
                sidPairs.Add(new SIDPair(SIDType.UserSID, sid));
            }

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                for (int i = 0; i < count; i++)
                {
                    string key = request.GetString("ID" + i.ToString());

                    RecordSecurityManager.Public(cn, rsid, key, sidPairs, permisions, leadershipToken, comments, dataSource);

                    JObject processedItem = new JObject();
                    processedItem["ID"] = key;
                    processedItems.Add(processedItem);
                }

                JObject rv = new JObject();
                rv["success"]        = true;
                rv["processedItems"] = processedItems;
                return(rv);
            }
        }
예제 #16
0
        public virtual BPMObjectNameCollection GetOUExtAttrNames(HttpContext context)
        {
            YZRequest request    = new YZRequest(context);
            String    @namespace = request.GetString("namespace", Namespace.BPMOU);

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                DataColumnCollection columns = OU.GetExtColumns(cn, @namespace);

                BPMObjectNameCollection attrNames = new BPMObjectNameCollection();
                foreach (DataColumn column in columns)
                {
                    attrNames.Add(column.ColumnName);
                }

                return(attrNames);
            }
        }
예제 #17
0
 public static BPMObjectNameCollection GetUidsFromRegisterId(IYZDbProvider provider, IDbConnection cn, string registerId)
 {
     try
     {
         BPMObjectNameCollection uids = new BPMObjectNameCollection();
         using (YZReader reader = new YZReader(provider.GetUidsFromPushNotificationRegisterId(cn, registerId)))
         {
             while (reader.Read())
             {
                 uids.Add(reader.ReadString(0));
             }
             return(uids);
         }
     }
     catch (Exception e)
     {
         throw new BPMException(BPMExceptionType.DBLoadDataErr, "BPMSysUserCommonInfo", e.Message);
     }
 }
예제 #18
0
        public virtual BPMObjectNameCollection GetFormApplicationNames(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    folder  = request.GetString("folder", null);

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                FormApplicationCollection formApplications = cn.GetFormApplicationList(folder, BPMPermision.None);

                BPMObjectNameCollection names = new BPMObjectNameCollection();
                foreach (FormApplication formApplication in formApplications)
                {
                    names.Add(formApplication.Name);
                }

                return(names);
            }
        }
예제 #19
0
    protected static void FormServiceStatesRender(HSSFCell cell, string varName, DataSet dataset, object value, string emptyText)
    {
        string strValue = Convert.ToString(value);
        string rv       = null;

        if (!String.IsNullOrEmpty(strValue))
        {
            JArray array = JArray.Parse(strValue);

            BPMObjectNameCollection names = new BPMObjectNameCollection();
            foreach (JObject item in array)
            {
                names.Add((string)(item["Name"]));
            }

            rv = String.Join(",", names.ToArray());
        }
        DefaultRender(cell, varName, dataset, rv, String.Empty);
    }
예제 #20
0
 public static BPMObjectNameCollection GetNotifyUsersTaskSocial(IYZDbProvider provider, IDbConnection cn, int taskid)
 {
     try
     {
         BPMObjectNameCollection uids = new BPMObjectNameCollection();
         using (YZReader reader = new YZReader(provider.GetNotifyUsersTaskSocial(cn, taskid)))
         {
             while (reader.Read())
             {
                 uids.Add(reader.ReadString(0));
             }
             return(uids);
         }
     }
     catch (Exception e)
     {
         throw new BPMException(BPMExceptionType.DBLoadDataErr, "BPMInstProcSteps", e.Message);
     }
 }
예제 #21
0
파일: GroupManager.cs 프로젝트: radtek/EMIP
        public static BPMObjectNameCollection AddGroupMembers(IYZDbProvider provider, IDbConnection cn, int groupid, BPMObjectNameCollection uids, string role)
        {
            BPMObjectNameCollection added   = new BPMObjectNameCollection();
            MemberCollection        members = GroupManager.GetGroupMembers(provider, cn, groupid);

            foreach (string uid in uids)
            {
                Member member = new Member();
                member.GroupID = groupid;
                member.UID     = uid;
                member.Role    = role;

                if (!members.Contains(uid))
                {
                    GroupManager.Insert(provider, cn, member);
                    added.Add(uid);
                }
            }

            return(added);
        }
예제 #22
0
    public static void ApplayPermision(BPMConnection cn, JsonItemCollection items)
    {
        for (int moduleIndex = 0; moduleIndex < items.Count; moduleIndex++)
        {
            JsonItem item          = items[moduleIndex];
            bool     moduleExecute = true;

            if (item.Attributes.ContainsKey("modulePerm"))
            {
                YZModulePermision perm = item.Attributes["modulePerm"] as YZModulePermision;
                item.Attributes.Remove("modulePerm");

                //检查模块权限
                moduleExecute = UserResourceSecurityManager.CheckPermision(cn, perm.RSID, "Execute");

                if (moduleExecute)
                {
                    //获得模块config配置项
                    JsonItem config = null;
                    if (item.Attributes.ContainsKey("config"))
                    {
                        config = item.Attributes["config"] as JsonItem;
                    }
                    else
                    {
                        config = new JsonItem();
                        item.Attributes["config"] = config;
                    }

                    //在config配置项下建perm配置
                    JsonItem jsonPerm = new JsonItem();
                    config.Attributes["perm"] = jsonPerm;

                    //记录模块rsid
                    jsonPerm.Attributes["rsid"] = perm.RSID;

                    //生成工具条上的访问权限
                    if (perm.GenToolbarPermision)
                    {
                        //获得工具条上的模块级权限种类
                        UserResourcePermisionCollection resourcePerms = UserResourceSecurityManager.GetResourcePermisions(cn, perm.RSID);
                        BPMObjectNameCollection         permNames     = new BPMObjectNameCollection();
                        foreach (UserResourcePermision resourcePerm in resourcePerms)
                        {
                            if (resourcePerm.PermType == UserResourcePermisionType.Module)
                            {
                                permNames.Add(resourcePerm.PermName);
                            }
                        }

                        //记录工具条上的模块级权限许可情况
                        bool[] rv = UserResourceSecurityManager.CheckPermision(cn, perm.RSID, permNames);
                        for (int i = 0; i < permNames.Count; i++)
                        {
                            jsonPerm.Attributes[permNames[i]] = rv[i];
                        }
                    }
                }
                else
                {
                    items.RemoveAt(moduleIndex);
                    moduleIndex--;
                }
            }

            //此模块可见则检查子级
            if (moduleExecute)
            {
                if (item.Attributes.ContainsKey("children"))
                {
                    JsonItemCollection children = item.Attributes["children"] as JsonItemCollection;
                    if (children != null)
                    {
                        int allCount = children.Count;
                        ApplayPermision(cn, children);

                        if (allCount != 0 && children.Count == 0)
                        {
                            //item.Attributes["empty"] = true;
                            items.RemoveAt(moduleIndex);
                            moduleIndex--;
                            continue;
                        }
                    }
                }

                if (item.Attributes.ContainsKey("tabs"))
                {
                    JsonItemCollection tabs = item.Attributes["tabs"] as JsonItemCollection;
                    if (tabs != null)
                    {
                        int allCount = tabs.Count;
                        ApplayPermision(cn, tabs);

                        if (allCount != 0 && tabs.Count == 0)
                        {
                            //item.Attributes["empty"] = true;
                            items.RemoveAt(moduleIndex);
                            moduleIndex--;
                            continue;
                        }
                    }
                }
            }
        }
    }
예제 #23
0
    public static string GetUserShortNameListString(UserCollection users)
    {
        BPMObjectNameCollection names = new BPMObjectNameCollection();
        foreach (User user in users)
            names.Add(YZStringHelper.GetUserShortName(user.Account, user.DisplayName));

        return names.ToStringList(';');
    }
예제 #24
0
    public static string GetUserNameListString(StepRecipientCollection recps)
    {
        BPMObjectNameCollection names = new BPMObjectNameCollection();
        foreach (StepRecipient recp in recps)
            names.Add(YZStringHelper.GetRecpientDisplayName(recp));

        return names.ToStringList(';');
    }
예제 #25
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                YZAuthHelper.OAuth();

                //YZAuthHelper.AshxAuthCheck();

                string   method = context.Request.Params["Method"];
                JsonItem rv     = new JsonItem();

                if (YZStringHelper.EquName(method, "GET"))
                {
                    string uid = YZAuthHelper.LoginUserAccount;
                    using (BPMConnection cn = new BPMConnection())
                    {
                        JsonItem data = new JsonItem();
                        rv.Attributes.Add("data", data);

                        cn.WebOpen();

                        User user = User.FromAccount(cn, uid);
                        UserInfoSelfMantSetting setting = new UserInfoSelfMantSetting();
                        setting.Load(cn);

                        data.Attributes["Account"]     = user.Account;
                        data.Attributes["HRID"]        = user.HRID;
                        data.Attributes["DisplayName"] = user.DisplayName;
                        data.Attributes["Mobile"]      = user.Mobile;
                        data.Attributes["OfficePhone"] = user.OfficePhone;
                        data.Attributes["HomePhone"]   = user.HomePhone;
                        data.Attributes["EMail"]       = user.EMail;
                        data.Attributes["Office"]      = user.Office;
                        data.Attributes["Birthday"]    = YZStringHelper.DateToString(user.Birthday);
                        data.Attributes["DateHired"]   = YZStringHelper.DateToString(user.DateHired);

                        data.Attributes["editableFields"] = "DisplayName,HRID,Mobile,OfficePhone,HomePhone,EMail,Office,Birthday,DateHired";
                        //data.Attributes["editableFields"] = "Mobile,OfficePhone,HomePhone,EMail,Office";

                        //获得所有主管
                        BPMObjectNameCollection depts       = new BPMObjectNameCollection();
                        BPMObjectNameCollection supervisors = new BPMObjectNameCollection();
                        MemberCollection        members     = OrgSvr.GetUserPositions(cn, uid);
                        foreach (Member member in members)
                        {
                            OU ou = member.GetParentOU(cn);
                            depts.Add(ou.Name);

                            SupervisorCollection spvs = Member.GetSupervisors(cn, member.FullName);
                            foreach (Supervisor spv in spvs)
                            {
                                if (!supervisors.Contains(spv.UserFriendlyName))
                                {
                                    supervisors.Add(spv.UserFriendlyName);
                                }
                            }
                        }

                        data.Attributes["Supervisor"] = String.Join(",", supervisors.ToArray());
                        data.Attributes["Dept"]       = String.Join(",", depts.ToArray());
                    }
                }
                else if (YZStringHelper.EquName(method, "UPDATE"))
                {
                    string   uid       = YZAuthHelper.LoginUserAccount;
                    string   fieldName = context.Request.Params["fieldName"];
                    string   strValue  = context.Request.Params["value"];
                    DateTime date;
                    using (BPMConnection cn = new BPMConnection())
                    {
                        cn.WebOpen();

                        User user = User.FromAccount(cn, uid);

                        switch (fieldName)
                        {
                        case "DisplayName":
                            user.DisplayName = strValue;
                            break;

                        case "HRID":
                            user.HRID = strValue;
                            break;

                        case "Mobile":
                            user.Mobile = strValue;
                            break;

                        case "OfficePhone":
                            user.OfficePhone = strValue;
                            break;

                        case "HomePhone":
                            user.HomePhone = strValue;
                            break;

                        case "EMail":
                            user.EMail = strValue;
                            break;

                        case "Office":
                            user.Office = strValue;
                            break;

                        case "Birthday":
                            if (DateTime.TryParse(strValue, out date))
                            {
                                user.Birthday = date;
                            }
                            else
                            {
                                user.Birthday = DateTime.MinValue;
                            }
                            break;

                        case "DateHired":
                            if (DateTime.TryParse(strValue, out date))
                            {
                                user.DateHired = date;
                            }
                            else
                            {
                                user.DateHired = DateTime.MinValue;
                            }
                            break;
                        }

                        User.Update(cn, uid, user);
                    }
                }
                else
                {
                    throw new Exception(String.Format(JosonStrings.Aspx_UnknowCommand, method));
                }

                //System.Threading.Thread.Sleep(500);

                rv.Attributes.Add("success", true);
                context.Response.Write(rv.ToString());
            }
            catch (Exception e)
            {
                JsonItem rv = new JsonItem();
                rv.Attributes.Add("success", false);
                rv.Attributes.Add("errorMessage", e.Message);
                context.Response.Write(rv.ToString());
            }

            context.Response.AppendHeader("Access-Control-Allow-Origin", "*");      // 响应类型
            context.Response.AppendHeader("Access-Control-Allow-Methods", "POST");  // 响应头设置
            context.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

            context.Response.Charset         = "gb2312"; //设置字符集类型
            context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
            context.Response.ContentType     = "application/json;charset=gb2312";
        }
예제 #26
0
        public virtual object GetTemplateCategories(HttpContext context)
        {
            YZRequest request  = new YZRequest(context);
            int       folderid = request.GetInt32("folderid");
            BPMObjectNameCollection folderNames = new BPMObjectNameCollection();

            Folder folder;

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    folder = DirectoryManager.GetFolderByID(provider, cn, folderid);
                }
            }

            switch (folder.FolderType)
            {
            case "BPAProcess":
                folderNames.Add("EVC");
                folderNames.Add("BPMN");
                folderNames.Add("FlowChart");
                break;

            case "BPAProduct":
                folderNames.Add("Product");
                break;

            case "BPAOU":
                folderNames.Add("Org");
                break;

            case "BPAData":
                folderNames.Add("Data");
                break;

            case "BPAITSystem":
                folderNames.Add("ITSystem");
                break;

            case "BPAControl":
                folderNames.Add("KPI");
                folderNames.Add("Risk");
                folderNames.Add("Regulation");
                break;

            default:
                folderNames.Add("BPMN");
                break;
            }

            return(folderNames);
        }
예제 #27
0
    public static void ApplayRecordPermision(BPMConnection cn, JsonItemCollection items,string rsid, string tableName,string jsonitemKeyAttrName)
    {
        //获得资源上的记录级权限种类
        UserResourcePermisionCollection resourcePerms = UserResourceSecurityManager.GetResourcePermisions(cn, rsid);
        BPMObjectNameCollection permNames = new BPMObjectNameCollection();
        foreach (UserResourcePermision resourcePerm in resourcePerms)
        {
            if (resourcePerm.PermType == UserResourcePermisionType.Record)
                permNames.Add(resourcePerm.PermName);
        }

        //应用权限
        foreach(JsonItem item in items)
        {
            string key = Convert.ToString(item.Attributes[jsonitemKeyAttrName]);
            bool[] rv = RecordSecurityManager.CheckPermision(cn, tableName, key, permNames);

            JsonItem jsonPerm = new JsonItem();
            item.Attributes["perm"] = jsonPerm;
            for (int i = 0; i < permNames.Count; i++)
                jsonPerm.Attributes[permNames[i]] = rv[i];
        }
    }
예제 #28
0
        public string GetDBInString(BPMObjectNameCollection sids, string uid)
        {
            if (sids == null)
                return null;

            BPMObjectNameCollection lsids = new BPMObjectNameCollection();
            sids.CopyTo(lsids);
            lsids.Add(uid);

            return this.GetDBInString(lsids);
        }
예제 #29
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                YZAuthHelper.OAuth();

                //YZAuthHelper.AshxAuthCheck();

                string   method  = context.Request.Params["Method"];
                JsonItem JosonRv = new JsonItem();

                if (YZStringHelper.EquName(method, "GET"))
                {
                    string uid = YZAuthHelper.LoginUserAccount;
                    using (BPMConnection cn = new BPMConnection())
                    {
                        JsonItem data = new JsonItem();
                        JosonRv.Attributes.Add("data", data);

                        cn.WebOpen();

                        UserAccount currentUser = cn.getCurrentUser(uid);


                        User user = User.FromAccount(cn, uid);

                        #region 用户信息
                        data.Attributes["Account"]     = user.Account;
                        data.Attributes["HRID"]        = user.HRID;
                        data.Attributes["DisplayName"] = user.ShortName;
                        data.Attributes["Mobile"]      = user.Mobile;
                        data.Attributes["OfficePhone"] = user.OfficePhone;
                        data.Attributes["HomePhone"]   = user.HomePhone;
                        data.Attributes["EMail"]       = user.EMail;
                        data.Attributes["Office"]      = user.Office;
                        data.Attributes["Birthday"]    = YZStringHelper.DateToString(user.Birthday);
                        data.Attributes["DateHired"]   = YZStringHelper.DateToString(user.DateHired);
                        data.Attributes["Desc"]        = user.Description;
                        #endregion

                        #region 获得OU
                        //获得OU
                        String OULevel = String.Empty;
                        String OUName  = String.Empty;
                        String Dept    = String.Empty;
                        BPMObjectNameCollection depts   = new BPMObjectNameCollection();
                        MemberCollection        members = OrgSvr.GetUserPositions(cn, uid);
                        foreach (Member member in members)
                        {
                            OU ou = member.GetParentOU(cn);
                            OULevel = ou.OULevel;
                            Dept    = ou.Name;

                            String FullName    = member.GetParentOU(cn).FullName;
                            String mFullName   = member.FullName;
                            String mDepartment = member.Department;


                            if (!ou.IsRootOU)
                            {
                                OUName = mFullName.Split(new char[2] {
                                    '/', '/'
                                })[2];
                                depts.Add(OUName);
                            }
                            else
                            {
                                OUName = ou.Name;
                            }

                            if (String.IsNullOrEmpty(member.LeaderTitle))
                            {
                                depts.Add(ou.Name);
                            }
                            else
                            {
                                depts.Add(String.Format("{0}({1})", ou.Name, member.LeaderTitle));
                            }
                        }

                        data.Attributes["Dept"] = String.Join(" > ", depts.ToArray());
                        #endregion


                        UserCommonInfo userCommonInfo = UserCommonInfo.FromAccount(cn, uid);

                        data.Attributes["AppSN"]      = Net.Common.JosonRandom.GetRandomByDateTime(1, 999).Replace("/", "");
                        data.Attributes["AppCompany"] = OUName.GetShortName();
                        data.Attributes["AppDept"]    = Dept;
                        data.Attributes["AppDate"]    = DateTime.Now;
                        data.Attributes["AppHRName"]  = user.ShortName;
                        data.Attributes["AppHRID"]    = YZAuthHelper.LoginUserAccount;
                        data.Attributes["isSkyWorth"] = currentUser.AppFristDept != "制造中心" ? 0 : 1;
                        data.Attributes["AppComDept"] = currentUser.AppCompany.ToConnects("\\") + currentUser.AppDept;



                        JosonRv.Attributes.Add("success", true);
                        JosonRv.Attributes.Add("successMessage", "ok");
                        context.Response.Write(JosonRv.ToString());
                    }
                }
                else if (YZStringHelper.EquName(method, "Submit"))
                {
                    //遍历File表单元素
                    //HttpFileCollection files = HttpContext.Current.Request.Files;
                    //try
                    //{
                    //    for (int iFile = 0; iFile < files.Count; iFile++)
                    //    {
                    //        ///检查文件扩展名字
                    //        HttpPostedFile postedFile = files[iFile];
                    //        string fileName, fileExtension;
                    //        fileName = System.IO.Path.GetFileName(postedFile.FileName);
                    //        if (fileName != "")
                    //        {
                    //            ///注意:可能要修改你的文件夹的匿名写入权限。
                    //            postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("YZSoft/attachment/") + fileName);
                    //        }
                    //    }

                    //    HttpContext.Current.Response.Write("{success:true,msg:'File was successfully uploaded.'}");
                    //}
                    //catch (System.Exception Ex)
                    //{
                    //    HttpContext.Current.Response.Write("{success:true,msg:'File was successfully uploaded.'}");
                    //}



                    #region 接收数据
                    string uid = YZAuthHelper.LoginUserAccount;

                    string EmpID       = Convert.ToString(context.Request.Params["AppHRID"]);
                    string EmpName     = Convert.ToString(context.Request.Params["AppHRName"]);
                    string LeaveID     = Convert.ToString(context.Request.Params["LeaveID"]);
                    string LeaveName   = Convert.ToString(context.Request.Params["LeaveName"]);
                    string LeaveTypeID = Convert.ToString(context.Request.Params["LeaveTypeID"]);


                    String   AppSN      = Convert.ToString(context.Request.Params["AppSN"]);
                    String   AppCompany = Convert.ToString(context.Request.Params["AppCompany"]);
                    String   AppDept    = Convert.ToString(context.Request.Params["AppDept"]);
                    DateTime AppDate    = Convert.ToDateTime(context.Request.Params["AppDate"]);
                    String   AppHRName  = Convert.ToString(context.Request.Params["AppHRName"]);
                    String   AppHRID    = Convert.ToString(context.Request.Params["AppHRID"]);

                    String Address = Convert.ToString(context.Request.Params["Address"]);

                    DateTime FromDate = YZStringHelper.StringToDate(context.Request.Params["startTime"]);
                    DateTime ToDate   = YZStringHelper.StringToDate(context.Request.Params["endTime"]);

                    String allHours = Convert.ToString(context.Request.Params["allHours"]);
                    int    DayInt   = Convert.ToInt32(allHours.Split('天')[0]);
                    int    HourInt  = Convert.ToInt32(allHours.Split('天')[1].Split('小')[0]);


                    String reasonWhyNote = Convert.ToString(context.Request.Params["reasonWhy"]);
                    String suggestionMsg = Convert.ToString(context.Request.Params["suggestionMsg"]);
                    String strAttachment = Convert.ToString(context.Request.Params["strAttachment"]);

                    int isSkyWorth = Convert.ToInt32(context.Request.Params["isSkyWorth"]);



                    #region  iPHone 早期版本 客户端Bug修改

                    String strFromClient = submitFrom.UserAgent(context);

                    //if (suggestionMsg.IndexOf("iphone") > -1 || suggestionMsg.IndexOf("iPhone") > -1)
                    //{

                    //    if (LeaveTypeID == "20")
                    //    {
                    //        LeaveTypeID = "30";

                    //    }
                    //    else
                    //    {
                    //        LeaveTypeID = LeaveTypeID == "30" ? "20" : LeaveTypeID;
                    //    }
                    //}

                    #endregion


                    #endregion

                    using (BPMConnection cn = new BPMConnection())
                    {
                        cn.WebOpen();

                        //  Net.Common.GetRequestForm.Post<T>

                        //   http://extjs.org.cn/node/712


                        #region 提交数据
                        MemoryStream xmlStream = GeneratePostXML(Guid.NewGuid(), cn
                                                                 , AppSN
                                                                 , AppHRID
                                                                 , AppHRName
                                                                 , AppDate
                                                                 , AppDept
                                                                 , AppCompany

                                                                 , EmpID
                                                                 , EmpName
                                                                 , LeaveID
                                                                 , LeaveName
                                                                 , LeaveTypeID
                                                                 , FromDate
                                                                 , ToDate
                                                                 , DayInt
                                                                 , HourInt
                                                                 , reasonWhyNote + suggestionMsg + "\n\r" + strFromClient
                                                                 , strAttachment
                                                                 , isSkyWorth

                                                                 );
                        #endregion

                        PostResult result      = BPMProcess.Post(cn, xmlStream);
                        String     DisplayName = result.Recipients[0].Owner.DisplayName;

                        //JsonItem JosonRv = new JsonItem();
                        JosonRv.Attributes.Add("success", true);
                        JosonRv.Attributes.Add("successMessage", "\n\r <BR> 流程【" + result.SN + "】\n\r <BR> 成功提交给 " + DisplayName);
                        context.Response.Write(JosonRv.ToString());
                    }
                }
                else
                {
                    String strMsg = String.Format(JosonStrings.Aspx_UnknowCommand, method);

                    //JsonItem JosonRv = new JsonItem();
                    JosonRv.Attributes.Add("success", false);
                    JosonRv.Attributes.Add("errorMessage", strMsg);

                    context.Response.Write(JosonRv.ToString());

                    throw new Exception(strMsg);
                }

                //System.Threading.Thread.Sleep(500);
            }
            catch (Exception e)
            {
                JsonItem JosonRv = new JsonItem();
                JosonRv.Attributes.Add("success", false);
                JosonRv.Attributes.Add("errorMessage", e.Message);
                context.Response.Write(JosonRv.ToString());
            }
        }
예제 #30
0
    public static void ApplayPermision(BPMConnection cn, JsonItemCollection items)
    {
        for(int moduleIndex = 0; moduleIndex < items.Count ; moduleIndex++)
        {
            JsonItem item = items[moduleIndex];
            bool moduleExecute = true;
             
            if (item.Attributes.ContainsKey("modulePerm"))
            {
                YZModulePermision perm = item.Attributes["modulePerm"] as YZModulePermision;
                item.Attributes.Remove("modulePerm");

                //检查模块权限
                moduleExecute = UserResourceSecurityManager.CheckPermision(cn, perm.RSID, "Execute");

                if (moduleExecute)
                {
                    //获得模块config配置项
                    JsonItem config = null;
                    if (item.Attributes.ContainsKey("config"))
                        config = item.Attributes["config"] as JsonItem;
                    else
                    {
                        config = new JsonItem();
                        item.Attributes["config"] = config;
                    }

                    //在config配置项下建perm配置
                    JsonItem jsonPerm = new JsonItem();
                    config.Attributes["perm"] = jsonPerm;

                    //记录模块rsid
                    jsonPerm.Attributes["rsid"] = perm.RSID;

                    //生成工具条上的访问权限
                    if (perm.GenToolbarPermision)
                    {
                        //获得工具条上的模块级权限种类
                        UserResourcePermisionCollection resourcePerms = UserResourceSecurityManager.GetResourcePermisions(cn, perm.RSID);
                        BPMObjectNameCollection permNames = new BPMObjectNameCollection();
                        foreach (UserResourcePermision resourcePerm in resourcePerms)
                        {
                            if (resourcePerm.PermType == UserResourcePermisionType.Module)
                                permNames.Add(resourcePerm.PermName);
                        }

                        //记录工具条上的模块级权限许可情况
                        bool[] rv = UserResourceSecurityManager.CheckPermision(cn, perm.RSID, permNames);
                        for (int i = 0; i < permNames.Count; i++)
                            jsonPerm.Attributes[permNames[i]] = rv[i];
                    }
                }
                else
                {
                    items.RemoveAt(moduleIndex);
                    moduleIndex--;
                }
            }

            //此模块可见则检查子级
            if (moduleExecute)
            {
                if (item.Attributes.ContainsKey("children"))
                {
                    JsonItemCollection children = item.Attributes["children"] as JsonItemCollection;
                    if (children != null)
                    {
                        int allCount = children.Count;
                        ApplayPermision(cn, children);

                        if (allCount != 0 && children.Count == 0)
                        {
                            //item.Attributes["empty"] = true;
                            items.RemoveAt(moduleIndex);
                            moduleIndex--;
                            continue;
                        }
                    }
                }

                if (item.Attributes.ContainsKey("tabs"))
                {
                    JsonItemCollection tabs = item.Attributes["tabs"] as JsonItemCollection;
                    if (tabs != null)
                    {
                        int allCount = tabs.Count;
                        ApplayPermision(cn, tabs);

                        if (allCount != 0 && tabs.Count == 0)
                        {
                            //item.Attributes["empty"] = true;
                            items.RemoveAt(moduleIndex);
                            moduleIndex--;
                            continue;
                        }
                    }
                }
            }
        }
    }
예제 #31
0
    public static void ApplayPermision(BPMConnection cn, JArray items, bool userResource)
    {
        for (int moduleIndex = 0; moduleIndex < items.Count; moduleIndex++)
        {
            JObject item          = items[moduleIndex] as JObject;
            bool    moduleExecute = true;

            JToken token = item["modulePerm"];
            if (token != null)
            {
                YZModulePermision perm = token.ToObject <YZModulePermision>();
                item.Remove("modulePerm");

                //检查模块权限
                if (userResource)
                {
                    moduleExecute = UserResource.CheckPermision(cn, perm.RSID, "Execute");
                }
                else
                {
                    moduleExecute = SecurityManager.CheckPermision(cn, perm.RSID, BPMPermision.Execute);
                }

                if (moduleExecute)
                {
                    //获得模块config配置项
                    JObject config = item["config"] as JObject;
                    if (config == null)
                    {
                        config         = new JObject();
                        item["config"] = config;
                    }

                    //在config配置项下建perm配置
                    JObject jsonPerm = new JObject();
                    config["perm"] = jsonPerm;

                    //记录模块rsid
                    jsonPerm["rsid"] = perm.RSID;

                    //生成工具条上的访问权限
                    if (userResource)
                    {
                        if (perm.GenToolbarPermision)
                        {
                            //获得工具条上的模块级权限种类
                            UserResourcePermisionCollection resourcePerms = UserResource.GetPermisions(cn, perm.RSID);
                            BPMObjectNameCollection         permNames     = new BPMObjectNameCollection();
                            foreach (UserResourcePermision resourcePerm in resourcePerms)
                            {
                                if (resourcePerm.PermType == UserResourcePermisionType.Module)
                                {
                                    permNames.Add(resourcePerm.PermName);
                                }
                            }

                            //记录工具条上的模块级权限许可情况
                            bool[] rv = UserResource.CheckPermision(cn, perm.RSID, permNames);
                            for (int i = 0; i < permNames.Count; i++)
                            {
                                jsonPerm[permNames[i]] = rv[i];
                            }
                        }
                    }
                }
                else
                {
                    items.RemoveAt(moduleIndex);
                    moduleIndex--;
                }
            }

            //此模块可见则检查子级
            if (moduleExecute)
            {
                JArray children = item[YZJsonProperty.children] as JArray;
                if (children != null)
                {
                    int allCount = children.Count;
                    ApplayPermision(cn, children, userResource);

                    if (allCount != 0 && children.Count == 0)
                    {
                        //item.Attributes["empty"] = true;
                        items.RemoveAt(moduleIndex);
                        moduleIndex--;
                        continue;
                    }
                }

                JArray tabs = item["tabs"] as JArray;
                if (tabs != null)
                {
                    int allCount = tabs.Count;
                    ApplayPermision(cn, tabs, userResource);

                    if (allCount != 0 && tabs.Count == 0)
                    {
                        //item.Attributes["empty"] = true;
                        items.RemoveAt(moduleIndex);
                        moduleIndex--;
                        continue;
                    }
                }
            }
        }
    }
예제 #32
0
        public void ProcessRequest(HttpContext context)
        {
            YZAuthHelper.OAuth();

            //YZAuthHelper.AshxAuthCheck();

            string method = context.Request.Params["method"];

            if (method == "GetUsers")
            {
                string keyword = context.Request.Params["keyword"];

                keyword = string.IsNullOrEmpty(keyword) ? "ASDT" : keyword;

                //获得数据

                UserCollection users = new UserCollection();
                int            rowcount;
                JsonItem       rootItem = new JsonItem();
                using (BPMConnection cn = new BPMConnection())
                {
                    cn.WebOpen();
                    users = OrgSvr.SearchUser(cn, keyword);

                    List <User> usersLst = users.Where(s => s.NameSpace == "LDAP").ToList <User>();

                    //usersLst = users.Where(s => s.ExtAttributes["Supplayer"]=="SDT").ToList<User>();
                    //usersLst = users.Select(u => u.ExtAttributes["Supplayer"] == "").ToList<User>();

                    usersLst.Sort(new UserCompare());
                    rowcount = usersLst.Count;

                    //将数据转化为Json集合
                    rootItem.Attributes.Add(JsonItem.TotalRows, rowcount);

                    JsonItemCollection children = new JsonItemCollection();
                    rootItem.Attributes.Add("children", children);
                    rootItem.Attributes.Add("total", rowcount);

                    int i = 0;
                    foreach (User user in usersLst)
                    {
                        i++;

                        //if (i > 8)
                        //    break;

                        if (user.Account == "sa")
                        {
                            continue;
                        }
                        JsonItem item = new JsonItem();
                        children.Add(item);

                        item.Attributes.Add("Name", user.DisplayName);
                        item.Attributes.Add("Account", user.Account);
                        item.Attributes.Add("HRID", user.HRID);
                        item.Attributes.Add("user", user.ShortName);
                        item.Attributes.Add("group", YZPinYinHelper.GetShortPinyin(user.ShortName.Substring(0, 1)).ToUpper());

                        item.Attributes.Add("Mobile", user.Mobile);
                        item.Attributes.Add("HomePhone", user.HomePhone);
                        item.Attributes.Add("OfficePhone", user.OfficePhone);
                        item.Attributes.Add("Mail", user.EMail);
                    }
                }

                //输出数据
                context.Response.Write(rootItem.ToString());
            }
            else if (method == "GetUser")
            {
                string   uid = context.Request.Params["uid"];
                JsonItem rv  = new JsonItem();
                if (!String.IsNullOrEmpty(uid))
                {
                    using (BPMConnection cn = new BPMConnection())
                    {
                        JsonItem data = new JsonItem();
                        rv.Attributes.Add("data", data);

                        cn.WebOpen();
                        User user = User.FromAccount(cn, uid);

                        data.Attributes["Account"]     = user.Account;
                        data.Attributes["HRID"]        = user.HRID;
                        data.Attributes["DisplayName"] = user.ShortName;
                        data.Attributes["Mobile"]      = user.Mobile;
                        data.Attributes["OfficePhone"] = user.OfficePhone;
                        data.Attributes["HomePhone"]   = user.HomePhone;
                        data.Attributes["EMail"]       = user.EMail;
                        data.Attributes["Office"]      = user.Office;
                        data.Attributes["Birthday"]    = YZStringHelper.DateToString(user.Birthday);
                        data.Attributes["DateHired"]   = YZStringHelper.DateToString(user.DateHired);
                        data.Attributes["Desc"]        = user.Description;

                        //获得所有主管
                        BPMObjectNameCollection depts       = new BPMObjectNameCollection();
                        UserCollection          supervisors = new UserCollection();
                        MemberCollection        members     = OrgSvr.GetUserPositions(cn, uid);
                        foreach (Member member in members)
                        {
                            OU     ou      = member.GetParentOU(cn);
                            String OULevel = ou.OULevel;
                            String OUName  = ou.Name;

                            String FullName    = member.GetParentOU(cn).FullName;
                            String mFullName   = member.FullName;
                            String mDepartment = member.Department;


                            if (!ou.IsRootOU)
                            {
                                OUName = mFullName.Split(new char[2] {
                                    '/', '/'
                                })[2].GetShortName().ToString();
                                depts.Add(OUName);
                            }

                            if (String.IsNullOrEmpty(member.LeaderTitle))
                            {
                                depts.Add(ou.Name);
                            }
                            else
                            {
                                depts.Add(ou.Name);
                            }
                            //depts.Add(String.Format("{0}({1})", ou.Name, member.LeaderTitle));



                            SupervisorCollection spvs = Member.GetSupervisors(cn, member.FullName);
                            foreach (Supervisor spv in spvs)
                            {
                                User spvUser = User.TryGetUser(cn, spv.UserAccount);
                                if (spvUser == null)
                                {
                                    spvUser         = new User();
                                    spvUser.Account = spv.UserAccount;
                                }

                                spv.UserFullName = YZStringHelper.GetUserShortName(spvUser.Account, spvUser.DisplayName);

                                if (!supervisors.Contains(spvUser.Account))
                                {
                                    supervisors.Add(spvUser);
                                }
                            }
                        }

                        JsonItemCollection jsonSupervisors = new JsonItemCollection();
                        data.Attributes["Supervisors"] = jsonSupervisors;
                        foreach (User spv in supervisors)
                        {
                            JsonItem jsonSupervisor = new JsonItem();
                            jsonSupervisors.Add(jsonSupervisor);
                            jsonSupervisor.Attributes["uid"]       = spv.Account;
                            jsonSupervisor.Attributes["ShortName"] = spv.ShortName;
                        }

                        data.Attributes["Dept"] = String.Join(" > ", depts.ToArray());
                    }
                }
                rv.Attributes.Add("success", true);

                context.Response.AppendHeader("Access-Control-Allow-Origin", "*");      // 响应类型
                context.Response.AppendHeader("Access-Control-Allow-Methods", "POST");  // 响应头设置
                context.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

                context.Response.Charset         = "gb2312"; //设置字符集类型
                context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
                context.Response.ContentType     = "application/json;charset=gb2312";
                context.Response.Write(rv.ToString());
            }
        }
예제 #33
0
        private JObject GetFormInfo(BPMConnection cn, string UserAccount, int TaskID, int StepID)
        {
            FlowDataSet formData = null;
            BPMTask     task     = null;
            string      FormXml  = "";  //获取表单名称

            JObject rv = new JObject(); //最终组合的

            JArray TaskCommList = new JArray();

            rv["TaskCommList"] = TaskCommList;

            JArray FormInfo = new JArray();

            rv["FormInfo"] = FormInfo;
            JArray ButtonList = new JArray();

            rv["ButtonList"] = ButtonList;


            if (StepID < 0)
            {
                BPMStepCollection Steps = BPM.Client.BPMTask.GetAllSteps(cn, TaskID);
                foreach (BPM.Client.BPMProcStep item in Steps)
                {
                    if (item.NodeName.Equals("开始"))
                    {
                        StepID = item.StepID;
                        break;
                    }
                }
            }

            //按钮开始
            BPM.Client.ProcessInfo processInfo = BPM.Client.BPMProcess.GetProcessInfo(cn, StepID);
            BPMTask bt = BPMTask.Load(cn, TaskID);

            JObject TaskComm = new JObject();

            TaskCommList.Add(TaskComm);

            TaskComm["TaskID"]           = bt.TaskID;
            TaskComm["ParentStepID"]     = bt.ParentStepID;
            TaskComm["SerialNum"]        = bt.SerialNum;
            TaskComm["ProcessName"]      = bt.ProcessName;
            TaskComm["ApplicantAccount"] = bt.ApplicantAccount;

            TaskComm["AgentAccount"]     = bt.AgentAccount;
            TaskComm["AgentDisplayName"] = bt.AgentDisplayName;
            TaskComm["AgentDisplayName"] = bt.AgentDisplayName;

            TaskComm["OwnerAccount"]     = bt.OwnerAccount;
            TaskComm["OwnerDisplayName"] = bt.OwnerDisplayName;
            TaskComm["OwnerFullName"]    = bt.OwnerFullName;

            TaskComm["CreateAt"] = bt.CreateAt;
            TaskComm["FinishAt"] = bt.FinishAt;
            TaskComm["OptAt"]    = bt.OptAt;
            TaskComm["OptUser"]  = bt.OptUser;
            TaskComm["OptMemo"]  = bt.OptMemo;
            //TaskComm["Description"] = bt.Description;
            // TaskComm["ReturnToParent"] = bt.ReturnToParent;

            TaskComm["TaskState"] = bt.TaskState.ToString();
            TaskComm["State"]     = bt.State.ToString();


            if (IsCurrentStep(cn, UserAccount, StepID, TaskID) && bt.TaskState.ToString().Equals("Running", StringComparison.OrdinalIgnoreCase))
            {
                BPM.Client.LinkCollection links = processInfo.Links;//提交按钮
                foreach (Link link in links)
                {
                    JObject button = new JObject();
                    ButtonList.Add(button);
                    string s = link.DisplayString;
                    button["Text"]   = s;
                    button["Action"] = s;
                    button["Type"]   = "Post";
                }
                bool canReject = (processInfo.NodePermision & NodePermision.Reject) == NodePermision.Reject;//拒绝按钮
                if (canReject)
                {
                    JObject button = new JObject();
                    ButtonList.Add(button);
                    button["Text"]   = "拒绝";
                    button["Action"] = "Reject";
                    button["Type"]   = "Reject";
                }
                bool canTransfer = (processInfo.NodePermision & NodePermision.Transfer) == NodePermision.Transfer;//委托按钮
                if (canTransfer)
                {
                    JObject button = new JObject();
                    ButtonList.Add(button);
                    button["Text"]   = "委托";
                    button["Action"] = "Transfer";
                    button["Type"]   = "Transfer";
                }
                bool canConsign = (processInfo.NodePermision & NodePermision.Consign) == NodePermision.Consign;//加签按钮
                if (canConsign)
                {
                    string  s      = links[0].DisplayString;
                    JObject button = new JObject();
                    ButtonList.Add(button);
                    button["Text"]   = "加签";
                    button["Action"] = s;
                    button["Type"]   = "Consign";
                }
                bool canRecedeBack = (processInfo.NodePermision & NodePermision.RecedeBack) == NodePermision.RecedeBack;//退回重填按钮
                if (canRecedeBack)
                {
                    JObject button = new JObject();
                    ButtonList.Add(button);
                    button["Text"]   = "退回某步";
                    button["Action"] = "RecedeBack";
                    button["Type"]   = "RecedeBack";
                }
                bool recedeRestart = (processInfo.NodePermision & NodePermision.RecedeRestart) == NodePermision.RecedeRestart;//退回重填


                BPMProcStep stepLoad = BPMProcStep.Load(cn, StepID);
                int         idx      = processInfo.SystemLinks.Find(SystemLinkType.DirectSend);
                if (stepLoad.RecedeFromStep != -1 && idx != -1 && processInfo.SystemLinks[idx].Enabled)
                {
                    BPMStepCollection       directSendToSteps = BPMProcStep.LoadPrevSteps(cn, StepID);
                    BPMObjectNameCollection stepNames         = new BPMObjectNameCollection();
                    foreach (BPMProcStep step in directSendToSteps)
                    {
                        if (step.IsHumanStep)
                        {
                            stepNames.Add(step.NodeName + ":" + YZStringHelper.GetUserFriendlyName(step.RecipientAccount, step.RecipientFullName));

                            string  buttonText = "直送->" + stepNames.ToStringList(';');
                            JObject button     = new JObject();
                            ButtonList.Add(button);
                            button["Text"]   = buttonText;
                            button["Action"] = "DirectSend";
                            button["Type"]   = "DirectSend";
                        }
                    }
                }
            }

            //按钮结束
            FormXml = processInfo.FormFile;

            //获取表单数据
            formData = BPMProcess.GetFormData(cn, StepID);

            if (formData.Tables.Count == 0)
            {
                throw new Exception("获取表单数据失败");
            }

            //初始化布局文件
            task = BPMTask.Load(cn, TaskID);


            if (task == null)
            {
                throw new Exception("通过TaskID获取任务失败");
            }

            //int startIndex=FormXml.LastIndexOf(@"\");
            //int endIndex=FormXml.LastIndexOf(".aspx");
            // FormXml = FormXml.Substring(startIndex+1, endIndex - startIndex-1);
            FormXml = FormXml.Replace(".aspx", "");
            FormXml = FormXml.Replace("\\", "(");
            //throw new Exception(FormXml);
            XmlDocument layoutDoc      = new XmlDocument();
            string      layoutFilePath = HttpContext.Current.Server.MapPath(String.Format("~/FormLayout/{0}.xml", FormXml));

            string debugger = "";

            if (System.IO.File.Exists(layoutFilePath))
            {
                layoutDoc.Load(layoutFilePath);

                XmlNodeList layoutTables = layoutDoc.SelectNodes("Layout/Table");
                foreach (XmlNode layoutTable in layoutTables)
                {
                    string TableID = TryGetNodeAttribute(layoutTable, "ID");
                    //测试报文中Table是否与流程中的Table匹配
                    debugger += "[TableID]" + TableID;
                    foreach (FlowDataTable item in formData.Tables)
                    {
                        debugger += "[TableName]" + item.TableName;
                    }
                    //

                    FlowDataTable formDataTable = formData.Tables[TableID];

                    try
                    {
                        if (formDataTable != null)
                        {
                            JObject bwTable = new JObject();
                            FormInfo.Add(bwTable);
                            bwTable["TableName"]    = TableID;
                            bwTable["DisplayName"]  = TryGetNodeAttribute(layoutTable, "Name");
                            bwTable["IsRepeatable"] = formDataTable.IsRepeatableTable;

                            JArray bwRows = new JArray();
                            bwTable["Rows"] = bwRows;
                            foreach (FlowDataRow formDataRow in formDataTable.Rows)
                            {
                                JObject bwRow = new JObject();
                                bwRows.Add(bwRow);

                                XmlNodeList layoutColumns = layoutTable.ChildNodes;
                                int         i             = 0;
                                foreach (XmlNode layoutColumn in layoutColumns)
                                {
                                    //debugger += "**" + TryGetNodeAttribute(layoutColumn, "Type") + "**";
                                    if (!string.IsNullOrEmpty(TryGetNodeAttribute(layoutColumn, "Type")) && TryGetNodeAttribute(layoutColumn, "Type").Equals("Attachment", StringComparison.OrdinalIgnoreCase))
                                    {
                                        JObject bwColumn = new JObject();

                                        bwRow["Attachments_" + layoutColumn.Name] = bwColumn;
                                        bwColumn["Name"] = TryGetNodeAttribute(layoutColumn, "Name");

                                        string FileID = Convert.ToString(formDataRow[layoutColumn.Name]);

                                        //调用方法获取附件名称,附件路径
                                        JObject Attachments = GetAttachments(FileID);

                                        JArray bwAttachments = new JArray();
                                        bwColumn["Items"] = bwAttachments;
                                        foreach (JObject item in JTokenToJArray(Attachments["files"]))
                                        {
                                            JObject attachment1 = new JObject();
                                            bwAttachments.Add(attachment1);
                                            attachment1["FileName"]    = item["name"];
                                            attachment1["DownloadUrl"] = item["DownloadUrl"];
                                        }
                                        i++;
                                    }
                                    else
                                    {
                                        JObject bwColumn = new JObject();
                                        bwRow[layoutColumn.Name] = bwColumn;
                                        bwColumn["DataType"]     = TryGetNodeAttribute(layoutColumn, "DataType");
                                        bwColumn["DataFormat"]   = TryGetNodeAttribute(layoutColumn, "DataFormat");
                                        bwColumn["Order"]        = TryGetNodeAttribute(layoutColumn, "Order");

                                        bwColumn["Name"]  = TryGetNodeAttribute(layoutColumn, "Name");
                                        bwColumn["Value"] = Convert.ToString(formDataRow[layoutColumn.Name]);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        throw new Exception(debugger + "---------" + e.Message);
                    }
                }
            }
            else
            {
                //throw new Exception(String.Format("流程[{0}]没有布局文件[{1}]", task.ProcessName, layoutFilePath));
            }


            return(rv);
        }