コード例 #1
0
        public void UpdateAllUsers()
        {
            RoadFlow.Platform.Organize       organize1      = new RoadFlow.Platform.Organize();
            RoadFlow.Platform.UsersRelation  usersRelation1 = new RoadFlow.Platform.UsersRelation();
            List <RoadFlow.Data.Model.Users> all            = new RoadFlow.Platform.Users().GetAll();
            DataTable dt = new DataTable();

            dt.Columns.Add("姓名", "".GetType());
            dt.Columns.Add("帐号", "".GetType());
            dt.Columns.Add("微信号", "".GetType());
            dt.Columns.Add("手机号", "".GetType());
            dt.Columns.Add("邮箱", "".GetType());
            dt.Columns.Add("所在部门", "".GetType());
            dt.Columns.Add("职位", "".GetType());
            foreach (RoadFlow.Data.Model.Users users in all)
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (RoadFlow.Data.Model.UsersRelation usersRelation2 in usersRelation1.GetAllByUserID(users.ID))
                {
                    RoadFlow.Data.Model.Organize organize2 = organize1.Get(usersRelation2.OrganizeID);
                    if (organize2 != null)
                    {
                        stringBuilder.Append(organize2.IntID);
                        stringBuilder.Append(",");
                    }
                }
                DataRow row = dt.NewRow();
                row["姓名"]   = (object)this.replaceName(users.Name);
                row["帐号"]   = (object)users.Account;
                row["微信号"]  = (object)users.WeiXin;
                row["手机号"]  = (object)users.Mobile;
                row["邮箱"]   = (object)users.Email;
                row["所在部门"] = (object)stringBuilder.ToString().TrimEnd(',');
                row["职位"]   = (object)"";
                dt.Rows.Add(row);
            }
            string path = RoadFlow.Platform.Files.FilePath + "WeiXinCsv\\";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string str1 = path + Guid.NewGuid().ToString("N") + ".csv";

            NPOIHelper.ExportCSV(dt, str1);
            string str2 = new Media(Config.GetSecret("weixinagents_organize")).UploadTemp(str1, "file");

            if (str2.IsNullOrEmpty())
            {
                return;
            }
            string url    = "https://qyapi.weixin.qq.com/cgi-bin/batch/replaceuser?access_token=" + this.GetAccessToken();
            string oldXML = "{\"media_id\":\"" + str2 + "\"}";
            string data   = oldXML;

            RoadFlow.Platform.Log.Add("调用了微信同步所有人员", "返回:" + HttpHelper.SendPost(url, data), RoadFlow.Platform.Log.Types.微信企业号, oldXML, "", (RoadFlow.Data.Model.Users)null);
        }
コード例 #2
0
        public void UpdateAllOrganize()
        {
            RoadFlow.Platform.Organize          organize1 = new RoadFlow.Platform.Organize();
            List <RoadFlow.Data.Model.Organize> all       = organize1.GetAll();
            DataTable dt = new DataTable();

            dt.Columns.Add("部门名称", "".GetType());
            dt.Columns.Add("部门ID", 1.GetType());
            dt.Columns.Add("父部门ID", 1.GetType());
            dt.Columns.Add("排序", 1.GetType());
            foreach (RoadFlow.Data.Model.Organize organize2 in all)
            {
                int num = -1;
                if (organize2.ParentID.IsEmptyGuid())
                {
                    num = 1;
                }
                else
                {
                    RoadFlow.Data.Model.Organize organize3 = organize1.Get(organize2.ParentID);
                    if (organize3 != null)
                    {
                        num = organize3.IntID;
                    }
                }
                if (num != -1)
                {
                    DataRow row = dt.NewRow();
                    row["部门名称"]  = (object)this.replaceName(organize2.Name);
                    row["部门ID"]  = (object)organize2.IntID;
                    row["父部门ID"] = (object)num;
                    row["排序"]    = (object)organize2.Sort;
                    dt.Rows.Add(row);
                }
            }
            string path = RoadFlow.Platform.Files.FilePath + "WeiXinCsv\\";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string str1 = path + Guid.NewGuid().ToString("N") + ".csv";

            NPOIHelper.ExportCSV(dt, str1);
            string str2 = new Media(Config.GetSecret("weixinagents_organize")).UploadTemp(str1, "file");

            if (str2.IsNullOrEmpty())
            {
                return;
            }
            string url    = "https://qyapi.weixin.qq.com/cgi-bin/batch/replaceparty?access_token=" + this.GetAccessToken();
            string oldXML = "{\"media_id\":\"" + str2 + "\"}";
            string data   = oldXML;

            RoadFlow.Platform.Log.Add("调用了微信同步整个组织架构", "返回:" + HttpHelper.SendPost(url, data), RoadFlow.Platform.Log.Types.微信企业号, oldXML, "", (RoadFlow.Data.Model.Users)null);
        }
コード例 #3
0
ファイル: Organize.cs プロジェクト: zmyz2013/RoadFlowMvc
        public void UpdateAllUsers()
        {
            RoadFlow.Platform.Organize organize  = new RoadFlow.Platform.Organize();
            UsersRelation usersRelation          = new UsersRelation();
            List <RoadFlow.Data.Model.Users> all = new Users().GetAll();
            DataTable dataTable = new DataTable
            {
                Columns =
                {
                    {
                        "姓名",
                        "".GetType()
                    },
                    {
                        "帐号",
                        "".GetType()
                    },
                    {
                        "微信号",
                        "".GetType()
                    },
                    {
                        "手机号",
                        "".GetType()
                    },
                    {
                        "邮箱",
                        "".GetType()
                    },
                    {
                        "所在部门",
                        "".GetType()
                    },
                    {
                        "职位",
                        "".GetType()
                    }
                }
            };

            foreach (RoadFlow.Data.Model.Users item in all)
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (RoadFlow.Data.Model.UsersRelation item2 in usersRelation.GetAllByUserID(item.ID))
                {
                    RoadFlow.Data.Model.Organize organize2 = organize.Get(item2.OrganizeID);
                    if (organize2 != null)
                    {
                        stringBuilder.Append(organize2.IntID);
                        stringBuilder.Append(",");
                    }
                }
                DataRow dataRow = dataTable.NewRow();
                dataRow["姓名"]   = replaceName(item.Name);
                dataRow["帐号"]   = item.Account;
                dataRow["微信号"]  = item.WeiXin;
                dataRow["手机号"]  = item.Mobile;
                dataRow["邮箱"]   = item.Email;
                dataRow["所在部门"] = stringBuilder.ToString().TrimEnd(',');
                dataRow["职位"]   = "";
                dataTable.Rows.Add(dataRow);
            }
            string text = Files.FilePath + "WeiXinCsv\\";

            if (!Directory.Exists(text))
            {
                Directory.CreateDirectory(text);
            }
            string text2 = text + Guid.NewGuid().ToString("N") + ".csv";

            NPOIHelper.ExportCSV(dataTable, text2);
            string text3 = new Media(Config.GetSecret("weixinagents_organize")).UploadTemp(text2, "file");

            if (!text3.IsNullOrEmpty())
            {
                string url   = "https://qyapi.weixin.qq.com/cgi-bin/batch/replaceuser?access_token=" + GetAccessToken();
                string text4 = "{\"media_id\":\"" + text3 + "\"}";
                string str   = HttpHelper.SendPost(url, text4);
                Log.Add("调用了微信同步所有人员", "返回:" + str, Log.Types.微信企业号, text4);
            }
        }
コード例 #4
0
ファイル: Organize.cs プロジェクト: zmyz2013/RoadFlowMvc
        public void UpdateAllOrganize()
        {
            RoadFlow.Platform.Organize          organize = new RoadFlow.Platform.Organize();
            List <RoadFlow.Data.Model.Organize> all      = organize.GetAll();
            DataTable dataTable = new DataTable
            {
                Columns =
                {
                    {
                        "部门名称",
                        "".GetType()
                    },
                    {
                        "部门ID",
                        1.GetType()
                    },
                    {
                        "父部门ID",
                        1.GetType()
                    },
                    {
                        "排序",
                        1.GetType()
                    }
                }
            };

            foreach (RoadFlow.Data.Model.Organize item in all)
            {
                int num = -1;
                if (item.ParentID.IsEmptyGuid())
                {
                    num = 1;
                }
                else
                {
                    RoadFlow.Data.Model.Organize organize2 = organize.Get(item.ParentID);
                    if (organize2 != null)
                    {
                        num = organize2.IntID;
                    }
                }
                if (num != -1)
                {
                    DataRow dataRow = dataTable.NewRow();
                    dataRow["部门名称"]  = replaceName(item.Name);
                    dataRow["部门ID"]  = item.IntID;
                    dataRow["父部门ID"] = num;
                    dataRow["排序"]    = item.Sort;
                    dataTable.Rows.Add(dataRow);
                }
            }
            string text = Files.FilePath + "WeiXinCsv\\";

            if (!Directory.Exists(text))
            {
                Directory.CreateDirectory(text);
            }
            string text2 = text + Guid.NewGuid().ToString("N") + ".csv";

            NPOIHelper.ExportCSV(dataTable, text2);
            string text3 = new Media(Config.GetSecret("weixinagents_organize")).UploadTemp(text2, "file");

            if (!text3.IsNullOrEmpty())
            {
                string url   = "https://qyapi.weixin.qq.com/cgi-bin/batch/replaceparty?access_token=" + GetAccessToken();
                string text4 = "{\"media_id\":\"" + text3 + "\"}";
                string str   = HttpHelper.SendPost(url, text4);
                Log.Add("调用了微信同步整个组织架构", "返回:" + str, Log.Types.微信企业号, text4);
            }
        }