示例#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
        private string send(string data)
        {
            if (agentId != -1 && secret.IsNullOrEmpty())
            {
                secret = Config.GetSecret(agentId);
            }
            string   text     = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" + GetAccessToken();
            string   text2    = HttpHelper.SendPost(text, data);
            JsonData jsonData = JsonMapper.ToObject(text2);

            if (jsonData.ContainsKey("errcode") && "0" == jsonData["errcode"].ToString())
            {
                Log.Add("调用了微信发送消息", "返回:" + text2, Log.Types.微信企业号, text, data);
                return("");
            }
            Log.Add("调用了微信发送消息错误", "返回:" + text2, Log.Types.微信企业号, text, data);
            return(text2);
        }
示例#4
0
        private string send(string data)
        {
            if (this.agentId != -1 && this.secret.IsNullOrEmpty())
            {
                this.secret = Config.GetSecret(this.agentId);
            }
            string   str      = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" + this.GetAccessToken();
            string   json     = HttpHelper.SendPost(str, data);
            JsonData jsonData = JsonMapper.ToObject(json);

            if (jsonData.ContainsKey("errcode") && "0" == jsonData["errcode"].ToString())
            {
                RoadFlow.Platform.Log.Add("调用了微信发送消息", "返回:" + json, RoadFlow.Platform.Log.Types.微信企业号, str, data, (RoadFlow.Data.Model.Users)null);
                return("");
            }
            RoadFlow.Platform.Log.Add("调用了微信发送消息错误", "返回:" + json, RoadFlow.Platform.Log.Types.微信企业号, str, data, (RoadFlow.Data.Model.Users)null);
            return(json);
        }
示例#5
0
 public Message(string agentCode)
 {
     secret = Config.GetSecret(agentCode);
 }
示例#6
0
 public Message(int agentId)
 {
     secret = Config.GetSecret(agentId);
 }
示例#7
0
 public Media(int agentId)
 {
     this.secret = Config.GetSecret(agentId);
 }
示例#8
0
 public Organize(string agentCode)
 {
     this.secret = Config.GetSecret(agentCode);
 }
示例#9
0
 public Organize(int agentId)
 {
     this.secret = Config.GetSecret(agentId);
 }
示例#10
0
        public Organize()
        {
            string secret = Config.GetSecret("weixinagents_organize");

            this.secret = secret.IsNullOrEmpty() ? Config.OrganizeSecret : secret;
        }
示例#11
0
        public Organize()
        {
            string text = Config.GetSecret("weixinagents_organize");

            secret = (text.IsNullOrEmpty() ? Config.OrganizeSecret : text);
        }
示例#12
0
        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);
            }
        }
示例#13
0
        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);
            }
        }