예제 #1
0
        protected void ExcuteSend()
        {
            string responseContent = string.Empty;
            string url             = string.Format(urlSendTemplateMsg, AccessTokenManage.GetAccessTokenName());

            string first   = @"first"": {""value"":""#"",""color"":""$"" },";
            string keynote = @"""keyword1"":{""value"":""#"", ""color"":""$"" }";
            string sendTemplateMsgContent = @"{ ""touser"":""$"",""template_id"":""#"",""url"":""%"",""data"":{""*""}}";

            first   = first.Replace("#", templateMsgContent.DicFirst.First().Key).Replace("$", templateMsgContent.DicFirst.First().Value);
            keynote = keynote.Replace("#", templateMsgContent.DicKeynote.First().Key).Replace("$", templateMsgContent.DicKeynote.First().Value);
            string dataTemp        = first + keynote;
            string sendTemplateMsg = sendTemplateMsgContent.Replace("$", templateMsgContent.OpenId).Replace("#", templateMsgContent.Template_id).Replace("%", templateMsgContent.Url).Replace("*", dataTemp);

            sendTemplateMsg = sendTemplateMsg.Remove(sendTemplateMsg.LastIndexOf('"'), 1);
            HttpManager.Request(url, out responseContent, WebRequestMethods.Http.Post, data: sendTemplateMsg);
            if (responseContent.Contains("40001"))            //token失效码
            {
                url = string.Format(urlSendTemplateMsg, AccessTokenManage.GetAccessTokenName(true));
                HttpManager.Request(url, out responseContent, WebRequestMethods.Http.Post, data: sendTemplateMsg);
            }
        }
예제 #2
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Logger.Error("网站启动了:" + DateTime.Now);

            AccessTokenManage.GetAccessTokenName(true);
            ButtonHelp.InitButton();

            Task.Factory.StartNew(() =>
            {
                var msgContext = new MsgContext(new SendData());
                while (true)
                {
                    msgContext.Process();
                    Thread.Sleep(60000 * 1435);
                }
            });
        }
예제 #3
0
 public void Send()
 {
     try
     {
         var     lsOpenId = new List <string>();
         var     ret      = UserManage.GetOpenIdListByAccessTokenNameAndOpenId(AccessTokenManage.GetAccessTokenName());
         JObject Jo       = (JObject)JsonConvert.DeserializeObject(ret);
         JArray  Jarows   = JArray.Parse(Jo["data"]["openid"].ToString());
         for (int i = 0; i < Jarows.Count; i++)
         {
             lsOpenId.Add(Jarows[i].ToString());
         }
         var record = ControllerHelper.GetMatchedRecord();
         lsOpenId.ForEach(p => SendCore(p, record));
     }
     catch (Exception ex)
     {
         Logger.Error("给用户发送通知时失败:" + ex);
     }
 }
예제 #4
0
        /// <summary>
        /// 集团组织架构推送
        /// </summary>
        /// <param name="ZRFC_HR_OA_001_REQ"></param>
        public void SaveOrUpdateDeptInfo(ZRFC_HR_OA_001_REQ req)
        {
            ZRFC_HR_OA_001_HEAD[] heads = req.HEAD;
            ZRFC_HR_OA_RESP       resp  = new ZRFC_HR_OA_RESP();

            for (int i = 0; i < heads.Count(); i++)
            {
                Logger.Log("总共部门数:" + heads.Count().ToString());
                ZRFC_HR_OA_001_HEAD entity = heads[i];
                //部门编号
                string sapdept_id = entity.BJID;
                string sappid     = entity.PUP;
                string dept_name  = entity.STEXT + "(sap)";
                string dept_no    = entity.NUM;
                string log        = "";
                string xmlStr     = XmlSerializeHelper.XmlSerialize <ZRFC_HR_OA_001_HEAD>(entity) + "\r\n";
                log += xmlStr;
                List <DbParameter> paramList = new List <DbParameter>();
                #region 排除特殊情况
                if (sapdept_id == "10000000")
                {
                    continue;
                }
                string[] stringdeptname = { "挂靠部门", "挂证部门", "虚拟组织" };
                if (Array.IndexOf(stringdeptname, entity.STEXT) > -1)
                {
                    log = log + "排除特殊情况_部门" + "\r\n";
                    //Logger.Log("排除特殊情况_部门");
                    continue;
                }
                // < BJID > 13000000 </ BJID >
                //< STEXT > 杭州九洲大药房连锁有限公司 </ STEXT >
                //< PUP > 10000000 </ PUP >
                //< NUM > 4 </ NUM >

                //< BJID > 50002303 </ BJID >
                //< STEXT > 商采中心 </ STEXT >
                //< PUP > 11000000 </ PUP >
                //< NUM > 23 </ NUM >
                #region 测试
                //List <DbParameter> paramList = new List<DbParameter>();
                //string sql = "SELECT DEPT_ID FROM department WHERE dept_name=@name";
                //paramList.Add(oaDB.MakeInParam("name", name+ "(新)"));
                //DataSet dataSet = oaDB.ExecuteDataset(CommandType.Text, sql, paramList.ToArray());
                //if (dataSet != null && dataSet.Tables.Count > 0)
                //{
                //    DataRowCollection rows = dataSet.Tables[0].Rows;
                //    if (rows.Count > 0)
                //    {
                //        DataRow row = rows[0];
                //        int DEPT_ID = Int32.Parse(row[0].ToString());
                //        //string SAP_DEPT_ID =row[1].ToString();
                //        string operate_sql = "UPDATE department SET SAP_DEPT_ID=@SAP_DEPT_ID WHERE DEPT_ID=@dept_id";
                //        paramList.Clear();
                //        paramList.Add(oaDB.MakeInParam("DEPT_ID", DEPT_ID));
                //        paramList.Add(oaDB.MakeInParam("SAP_DEPT_ID", bjid));
                //        num = oaDB.ExecuteNonQuery(CommandType.Text, operate_sql, paramList.ToArray());
                //    }
                //}
                #endregion
                //xmlStr = XmlSerializeHelper.XmlSerialize<ZRFC_HR_OA_001_HEAD>(entity) + "\r\n";
                #endregion
                //string ret_code;
                //string ret_msg;
                //生成用户账号
                //IN p_username varchar(30),IN p_sapid varchar(30),IN p_sapdeptid int,IN  p_sex varchar(30),IN  p_mobil_no varchar(30),IN  p_birthday varchar(30),IN  p_not_login varchar(30),OUT ret_code INT,OUT ret_msg VARCHAR(30)
                // string tsql = "call proc_sap_addUser(@username,@p_sapid,@p_sapdeptid,@p_sex,@p_mobil_no,@p_birthday,@p_not_login,@ret_code,@ret_msg)";
                string tsql = "call proc_sap_addDept(@p_sapdeptid,@p_sapparentdeptid,@p_deptname)";
                paramList.Clear();
                paramList.Add(oaDB.MakeInParam("p_sapdeptid", sapdept_id));   //
                paramList.Add(oaDB.MakeInParam("p_sapparentdeptid", sappid)); //
                paramList.Add(oaDB.MakeInParam("p_deptname", dept_name));     //
                //paramList.Add(oaDB.MakeParam("ret_msg", "", ParameterDirection.Output));
                //paramList.Add(oaDB.MakeParam("ret_code", 0, ParameterDirection.Output));
                DataSet pResult = oaDB.ExecuteDataset(CommandType.Text, tsql, paramList.ToArray());
                //ret_code = paramList[7].Value.ToString();
                //ret_msg = paramList[8].Value.ToString();
                if (pResult != null && pResult.Tables.Count > 0)
                {
                    DataRowCollection rows = pResult.Tables[0].Rows;
                    if (rows.Count > 0)
                    {
                        DataRow row = rows[0];
                        if (Convert.ToInt16(row[1]) > 0)
                        {
                            // select ret_msg,ret_code,v_uid,p_username,p_sapid,p_sapdeptid,p_sex,p_mobil_no,p_birthday,v_wx_dept_id;
                            CreateDept dept = new CreateDept();
                            //dept.id = Convert.ToInt16(row[4]);
                            dept.name     = dept_name;
                            dept.parentid = Convert.ToInt16(row[5]);
                            //更新数据
                            log = log + string.Format("{0}_{1}", dept.name, dept.parentid) + "\r\n";
                            //Logger.Log(string.Format("{0}_{1}", dept.name, dept.parentid));
                            if (Convert.ToInt16(row[1]) == 1)
                            {
                                //添加日志
                                dept.id = Convert.ToInt16(row[4]);
                                AccessTokenManage.UpdateDeptApi(dept, ref log);
                            }
                            //添加数据
                            if (Convert.ToInt16(row[1]) == 2)
                            {
                                int id = AccessTokenManage.CreateDeptApi(dept, ref log);
                                if (id > 0)
                                {
                                    string updatewxdeptid = "update department set WEIXIN_DEPT_ID=@weixindeptid where  dept_id=@dept_id";
                                    paramList.Clear();
                                    paramList.Add(oaDB.MakeInParam("weixindeptid", id));
                                    paramList.Add(oaDB.MakeInParam("dept_id", Convert.ToInt16(row[2])));
                                    int issuc = oaDB.ExecuteNonQuery(CommandType.Text, updatewxdeptid, paramList.ToArray());
                                    if (issuc == 1)
                                    {
                                        log = log + string.Format("更新成功WEIXIN_DEPT_ID成功,WEIXIN_DEPT_ID{0}", id) + "\r\n";
                                    }
                                    else
                                    {
                                        log = log + "更新WEIXIN_DEPT_ID失败" + "\r\n";
                                    }
                                }
                            }
                        }
                        else
                        {
                            log = log + (string.Format("存储过程返回错误,错误值{0},错误描述{1}", row[0].ToString(), row[1]) + "\r\n");
                            //Logger.Log(string.Format("存储过程返回错误,错误值{0},错误描述{1}", row[0].ToString(), row[1]));
                        }
                        //resp.MSGTXT += xmlStr + row[1].ToString() + "\r\n";
                    }
                }
                else
                {
                    log = log + "存储过程范围值为空" + "\r\n";
                    //Logger.Log("存储过程范围值为空");
                    //resp.MSGTXT += xmlStr + "操作失败没有table" + "\r\n";
                }
                Logger.Log(log);
            }
        }
예제 #5
0
        /// <summary>
        /// 员工信息推送
        /// </summary>
        /// <param name="req"></param>
        public void SaveOrUpdateStaffInfo(ZRFC_HR_OA_003_REQ req)
        {
            ZRFC_HR_OA_003_HEAD[] heads = req.HEAD;
            ZRFC_HR_OA_RESP       resp  = new ZRFC_HR_OA_RESP();

            // string xmlStr = "";
            for (int i = 0; i < heads.Count(); i++)
            {
                Logger.Log("总共员工数:" + heads.Count().ToString());
                resp.MSGTXT = "";
                ZRFC_HR_OA_003_HEAD entity = heads[i];
                //部门编号
                string NACHN = entity.NACHN;         //姓名
                string PERNR = entity.PERNR;         //员工编号
                string PERSG = entity.PERSG;         //员工组
                string PERSK = entity.PERSK;         //员工子组
                string GESCH = entity.GESCH;         //性别
                //string ULONG = entity.USRID_LONG; //电子邮件
                string USRID     = entity.USRID;     //手机
                string OBJID_DEP = entity.OBJID_DEP; //所属部门编码
                string ORGTX     = entity.ORGTX;     //所属部门名称
                //string OBJID_COM = entity.OBJID_COM;//所属GSP部门编码
                string OBJID_S = entity.OBJID_S;     //岗位编码
                string GBDAT   = entity.GBDAT;       //生日
                string BEGDA   = entity.BEGDA;       //入职日期
                string SYSTEM  = entity.SYSTEM;      //人员账号类别
                //string LOGID = entity.LOGID;//人员账号
                string STELL = entity.STELL;         //职务编码
                string STLTX = entity.STLTX;         //职务文本
                string STAT2 = entity.STAT2;         //在职状态1:离职  2:退休  3:在职
                string log   = "";
                #region 排除特殊情况
                List <DbParameter> paramList = new List <DbParameter>();
                string             xmlStr    = XmlSerializeHelper.XmlSerialize <ZRFC_HR_OA_003_HEAD>(entity) + "\r\n";
                //Logger.Log(xmlStr);
                log = xmlStr;
                string[] idarray = { "4317", "4320", "4322", "4321", "4319", "4323", "4325", "4309", "4310", "4312", "4318", "4311", "4327", "4313", "4314" };
                if (Array.IndexOf(idarray, PERNR.TrimStart('0')) > -1)
                {
                    log = log + "排除特殊情况_人员" + "\r\n";
                    continue;
                }

                string[] stringdeptname = { "挂靠部门", "挂证部门", "虚拟组织" };
                if (Array.IndexOf(stringdeptname, ORGTX) > -1)
                {
                    log = log + "排除特殊情况_部门" + "\r\n";
                    continue;
                }
                #endregion
                #region
                //List<DbParameter> paramList = new List<DbParameter>();
                //string xmlStr = XmlSerializeHelper.XmlSerialize<ZRFC_HR_OA_003_HEAD>(entity) + "\r\n";
                //判断该账号是否存在

                //if (string.IsNullOrEmpty(LOGID))
                //{
                //    LOGID = PERNR;
                //}
                // 获取deptid
                #endregion
                string username    = NACHN + "(sap)";
                string p_sapid     = PERNR.TrimStart('0');
                string p_sapdeptid = OBJID_DEP;
                string p_sex       = GESCH == "1" ? "0" : "1";
                string p_mobil_no  = string.IsNullOrEmpty(USRID) ? "" : USRID;
                string p_birthday  = string.IsNullOrEmpty(GBDAT) ? "" : GBDAT;
                string p_not_login = string.IsNullOrEmpty(STAT2) ? "0" : (STAT2 == "3" ? "0" : "1");
                //string ret_code;
                //string ret_msg;
                //生成用户账号
                //IN p_username varchar(30),IN p_sapid varchar(30),IN p_sapdeptid int,IN  p_sex varchar(30),IN  p_mobil_no varchar(30),IN  p_birthday varchar(30),IN  p_not_login varchar(30),OUT ret_code INT,OUT ret_msg VARCHAR(30)
                // string tsql = "call proc_sap_addUser(@username,@p_sapid,@p_sapdeptid,@p_sex,@p_mobil_no,@p_birthday,@p_not_login,@ret_code,@ret_msg)";
                string tsql = "call proc_sap_addUser(@username,@p_sapid,@p_sapdeptid,@p_sex,@p_mobil_no,@p_birthday,@p_not_login)";
                paramList.Clear();
                paramList.Add(oaDB.MakeInParam("username", username));       //姓名
                paramList.Add(oaDB.MakeInParam("p_sapid", p_sapid));         //sapid todo去除前导0
                paramList.Add(oaDB.MakeInParam("p_sapdeptid", p_sapdeptid)); //所属部门编码
                paramList.Add(oaDB.MakeInParam("p_sex", p_sex));             //性别
                paramList.Add(oaDB.MakeInParam("p_mobil_no", p_mobil_no));   //手机
                paramList.Add(oaDB.MakeInParam("p_birthday", p_birthday));   //生日//在职状态1:离职  2:退休  3:在职
                paramList.Add(oaDB.MakeInParam("p_not_login", p_not_login)); //
                                                                             //paramList.Add(oaDB.MakeParam("ret_msg", "", ParameterDirection.Output));
                                                                             //paramList.Add(oaDB.MakeParam("ret_code", 0, ParameterDirection.Output));
                log = log + (string.Format("{0}_{1}_{2}_{3}_{4}_{5}_{6}", username, p_sapid, p_sapdeptid, p_sex, p_mobil_no, p_birthday, p_not_login) + "\r\n");
                DataSet pResult = oaDB.ExecuteDataset(CommandType.Text, tsql, paramList.ToArray());
                //ret_code = paramList[7].Value.ToString();
                //ret_msg = paramList[8].Value.ToString();
                if (pResult != null && pResult.Tables.Count > 0)
                {
                    DataRowCollection rows = pResult.Tables[0].Rows;
                    if (rows.Count > 0)
                    {
                        DataRow row = rows[0];
                        if (Convert.ToInt16(row[1]) > 0)
                        {
                            // select ret_msg,ret_code,v_uid,p_username,p_sapid,p_sapdeptid,p_sex,p_mobil_no,p_birthday,v_wx_dept_id;
                            CreateUser user = new CreateUser();
                            user.userid     = row[2].ToString();
                            user.name       = row[3].ToString();
                            user.mobile     = row[7].ToString();
                            user.gender     = GESCH == "1" ? "1" : "2";
                            user.email      = "";
                            user.department = new List <int> {
                                Convert.ToInt32(row[9])
                            };
                            user.to_invite = false;
                            //更新数据
                            //log = log + (string.Format("{0}_{1}_{2}_{3}_{4}", user.userid, user.name, user.mobile, user.gender, Convert.ToInt32(row[9])));
                            if (Convert.ToInt16(row[1]) == 1)
                            {
                                //添加日志
                                if (user.mobile != "")
                                {
                                    AccessTokenManage.UpdateUserApi(user, ref log);
                                }
                                else
                                {
                                    log = log + "手机号为空不更新" + "\r\n";
                                }
                                //AccessTokenManage.CreateUserApi(user);
                            }
                            //添加数据
                            if (Convert.ToInt16(row[1]) == 2)
                            {
                                AccessTokenManage.CreateUserApi(user, ref log);
                            }
                        }
                        else
                        {
                            log = log + string.Format("存储过程值{0},描述{1}", row[0].ToString(), row[1]) + "\r\n";
                            //Logger.Log(string.Format("存储过程值{0},描述{1}", row[0].ToString(), row[1]));
                        }
                        //resp.MSGTXT += xmlStr + row[1].ToString() + "\r\n";
                    }
                }
                else
                {
                    log = log + "存储过程范围值为空" + "\r\n";
                    //Logger.Log("存储过程范围值为空");
                    //resp.MSGTXT += xmlStr + "操作失败没有table" + "\r\n";
                }
                Logger.Log(log);
                //loginfo.loginfor(resp.MSGTXT);
            }
            // }
        }