Esempio n. 1
0
        protected override string GetPushJson(U_UploadResult uploadResult, U_Content contentModel)
        {
            string pageUrl = ConfigSugar.GetAppString("OpenHttpAddress") + "/WeChatPush/Salary/Salary?Vguid=" + contentModel.VGUID;  //工资页面
            string url     = string.Format(_oAuthUrl, ConfigSugar.GetAppString("WeChatCorpID"), pageUrl);

            //List<U_WeChatUser> weChatUserList = SearchWeChatUserList();
            //string pushObject = GetPushObject(contentModel, weChatUserList);
            string pushObject     = GetPushObject(contentModel);
            string responeJsonStr = "";

            responeJsonStr  = "{";
            responeJsonStr += "\"touser\": \"" + pushObject + "\",";
            responeJsonStr += "\"toparty\": \"\",";
            responeJsonStr += "\"totag\": \"\",";
            responeJsonStr += "\"msgtype\": \"news\",";
            responeJsonStr += "\"agentid\":\"" + ConfigSugar.GetAppString("WeChatAgentID") + "\",";
            responeJsonStr += "\"news\": {";
            responeJsonStr += "\"articles\":[";
            responeJsonStr += " {";
            responeJsonStr += "\"title\": \"" + contentModel.Title + "\",";
            responeJsonStr += "\"description\": \"" + contentModel.CoverDescption + "\",";
            responeJsonStr += "\"url\": \"" + url + "\",";
            responeJsonStr += "\"picurl\": \"" + ConfigSugar.GetAppString("OpenHttpAddress") + contentModel.CoverImg + "\",";
            responeJsonStr += "}";
            responeJsonStr += "]";
            responeJsonStr += "}";
            responeJsonStr += "}";
            return(responeJsonStr);
        }
Esempio n. 2
0
        protected override string GetPushJson(U_UploadResult uploadResult, U_Content contentModel)
        {
            //List<U_WeChatUser> weChatUserList = SearchWeChatUserList();
            //string pushObject = GetPushObject(contentModel, weChatUserList);
            string pushObject     = GetPushObject(contentModel);
            string responeJsonStr = "";

            responeJsonStr  = "{";
            responeJsonStr += "\"touser\": \"" + pushObject + "\",";
            responeJsonStr += "\"toparty\": \"\",";
            responeJsonStr += "\"totag\": \"\",";
            responeJsonStr += "\"msgtype\": \"news\",";
            responeJsonStr += "\"agentid\":\"" + _weChatAgentID + "\",";
            responeJsonStr += "\"news\": {";
            responeJsonStr += "\"articles\":[";
            responeJsonStr += " {";
            responeJsonStr += "\"title\": \"" + contentModel.Title + "\",";
            responeJsonStr += "\"description\": \"" + contentModel.CoverDescption + "\",";
            responeJsonStr += "\"url\": \"" + ConfigSugar.GetAppString("OpenHttpAddress") + "/BasicDataManagement/WeChatExercise/Index\",";
            responeJsonStr += "\"picurl\": \"http://wx.qlogo.cn/mmhead/Q3auHgzwzM5eGibkia18N1q7icAdkgOIS3gvWZYaXTqbq3Tr8iaZM6S5jw/0\",";
            responeJsonStr += "}";
            responeJsonStr += "]";
            responeJsonStr += "}";
            responeJsonStr += "}";
            return(responeJsonStr);
        }
Esempio n. 3
0
        protected override string GetPushJson(U_UploadResult uploadResult, U_Content contentModel)
        {
            string exerciseUrl = ConfigSugar.GetAppString("OpenHttpAddress") + "/BasicDataManagement/WeChatExercise/Index?exerciseVguid=" + contentModel.ExercisesVGUID;//跳转习题界面Url

            string url = string.Format(_oAuthUrl, ConfigSugar.GetAppString("WeChatCorpID"), exerciseUrl);
            ////企业获取Code
            //string code = GetCorpCode();

            //List<U_WeChatUser> weChatUserList = SearchWeChatUserList();
            //string pushObject = GetPushObject(contentModel, weChatUserList);
            string pushObject     = GetPushObject(contentModel);
            string responeJsonStr = "";

            responeJsonStr  = "{";
            responeJsonStr += "\"touser\": \"" + pushObject + "\",";
            responeJsonStr += "\"toparty\": \"\",";
            responeJsonStr += "\"totag\": \"\",";
            responeJsonStr += "\"msgtype\": \"news\",";
            responeJsonStr += "\"agentid\":\"" + ConfigSugar.GetAppString("WeChatAgentID") + "\",";
            responeJsonStr += "\"news\": {";
            responeJsonStr += "\"articles\":[";
            responeJsonStr += " {";
            responeJsonStr += "\"title\": \"" + contentModel.Title + "\",";
            responeJsonStr += "\"description\": \"" + contentModel.CoverDescption + "\",";
            //responeJsonStr += "\"url\": \" " + url + "\",";
            responeJsonStr += "\"url\": \"" + url + "\",";
            responeJsonStr += "\"picurl\": \"" + ConfigSugar.GetAppString("OpenHttpAddress") + contentModel.CoverImg + "\",";
            responeJsonStr += "}";
            responeJsonStr += "]";
            responeJsonStr += "}";
            responeJsonStr += "}";
            return(responeJsonStr);
        }
Esempio n. 4
0
        /// <summary>
        /// 保存用户信息
        /// </summary>
        /// <param name="userModel"></param>
        /// <param name="isEdit"></param>
        /// <returns></returns>
        public bool SaveUserInfo(Sys_User userModel, bool isEdit)
        {
            bool     result        = false;
            Sys_User userInfoModel = new Sys_User();

            if (isEdit)//编辑
            {
                userInfoModel               = _us.GetUserInfoByVguid(userModel.Vguid.ToString());
                userInfoModel.ChangeDate    = DateTime.Now;
                userInfoModel.ChangeUser    = Common.CurrentUser.GetCurrentUser().LoginName;
                userInfoModel.Company       = userModel.Company;
                userInfoModel.Department    = userModel.Department;
                userInfoModel.Email         = userModel.Email;
                userInfoModel.Enable        = userModel.Enable;
                userInfoModel.LoginName     = userModel.LoginName;
                userInfoModel.MobileNnumber = userModel.MobileNnumber;
                userInfoModel.Remark        = userModel.Remark;
                userInfoModel.Role          = userModel.Role;
                userInfoModel.UserName      = userModel.UserName;
                userInfoModel.WorkPhone     = userModel.WorkPhone;
                result = _us.SaveUserInfo(userInfoModel, isEdit);
            }
            else//新增
            {
                userModel.Vguid       = Guid.NewGuid();
                userModel.CreatedUser = Common.CurrentUser.GetCurrentUser().LoginName;
                userModel.CreatedDate = DateTime.Now;
                userModel.ChangeDate  = DateTime.Now;
                userModel.Password    = ConfigSugar.GetAppString("DefaultPassword");
                result = _us.SaveUserInfo(userModel, isEdit);
            }

            return(result);
        }
Esempio n. 5
0
        protected string GetPushJson(U_UploadResult uploadResult, List <U_Content> contentModels)
        {
            string pushUrl        = string.Empty;
            string url            = string.Empty;
            string responeJsonStr = "";
            List <U_WeChatUser> weChatUserList = SearchWeChatUserList();
            string pushObject = GetPushObject(contentModels[0], weChatUserList);

            responeJsonStr  = "{";
            responeJsonStr += "\"touser\": \"" + pushObject + "\",";
            responeJsonStr += "\"toparty\": \"\",";
            responeJsonStr += "\"totag\": \"\",";
            responeJsonStr += "\"msgtype\": \"news\",";
            responeJsonStr += "\"agentid\":\"" + ConfigSugar.GetAppString("WeChatAgentID") + "\",";
            responeJsonStr += "\"news\": {";
            responeJsonStr += "\"articles\":[";
            foreach (var content in contentModels)
            {
                pushUrl         = ConfigSugar.GetAppString("OpenHttpAddress") + "/WeChatPush/PushDetail/PushDetail?Vguid=" + content.VGUID;//跳转推送内容界面Url
                url             = string.Format(_oAuthUrl, ConfigSugar.GetAppString("WeChatCorpID"), pushUrl);
                responeJsonStr += " {";
                responeJsonStr += "\"title\": \"" + content.Title + "\",";
                responeJsonStr += "\"description\": \"" + content.CoverDescption + "\",";
                responeJsonStr += "\"url\": \"" + url + "\",";
                responeJsonStr += "\"picurl\": \"" + ConfigSugar.GetAppString("OpenHttpAddress") + content.CoverImg + "\"";
                responeJsonStr += "}";
                responeJsonStr += ",";
            }
            responeJsonStr += "]";
            responeJsonStr += "}";
            responeJsonStr += "}";
            return(responeJsonStr);
        }
Esempio n. 6
0
        private bool APICount()
        {
            int    apiCount    = ConfigSugar.GetAppInt("APICount");
            string path        = this.Server.MapPath("APICount");
            string fileName    = "apicount.ini";
            string filePath    = Path.Combine(path, fileName);
            string fileContent = System.IO.File.ReadAllText(filePath);

            if (string.IsNullOrEmpty(fileContent))
            {
                fileContent = DateTime.Now.ToString("yyyy-MM-dd") + "|0";
            }
            string[] fileStrs = fileContent.Split('|');
            int      count    = 0;

            if (DateTime.Now.ToString("yyyy-MM-dd") == fileStrs[0])
            {
                count = Convert.ToInt32(fileStrs[1]);
            }
            if (count > apiCount)
            {
                return(false);
            }
            else
            {
                count++;
                fileContent = DateTime.Now.ToString("yyyy-MM-dd") + "|" + count.ToString();
                System.IO.File.WriteAllText(filePath, fileContent);
                return(true);
            }
        }
        public ActionResult CodeGenerate(string code)
        {
            string         accessToken = Common.WeChatPush.WeChatTools.GetAccessoken();
            U_WeChatUserID userInfo    = new U_WeChatUserID();
            string         userInfoStr = Common.WeChatPush.WeChatTools.GetUserInfoByCode(accessToken, code);

            userInfo = Common.JsonHelper.JsonToModel <U_WeChatUserID>(userInfoStr); //用户ID
            //userInfo.UserId = "WangCunBiao";
            var    personInfoModel = _wl.GetUserInfo(userInfo.UserId);              //获取人员表信息
            string file            = personInfoModel.Vguid + ".jpg";
            string forder          = "UploadFile/WeChatQRCode";
            string filePath        = Path.Combine(forder, file);

            string fileName = Server.MapPath(filePath);

            if (System.IO.File.Exists(fileName))
            {
                System.IO.File.Delete(fileName);
            }
            var configStr = _codeGenerateLogic.GetPersonConfiguration(personInfoModel);

            QRCodeHelper.GenerateQRCode(configStr, "/Areas/WeChatPush/Views/_img/logo1.png", forder, file);
            ViewData["Vguid"] = personInfoModel.Vguid;
            ViewData["url"]   = ConfigSugar.GetAppString("OpenHttpAddress") + forder + "/" + file;
            return(View());
        }
        public static SqlSugarClient GetInstance()
        {
            string connection = ConfigSugar.GetAppString("msSqlLinck");
            var    db         = new SqlSugarClient(connection);

            return(db);
        }
Esempio n. 9
0
        /// <summary>
        /// 保存上传保养信息的Excel
        /// </summary>
        /// <param name="salaryTable"></param>
        /// <param name="notExists"></param>
        /// <returns></returns>
        public bool SaveUpLoadMaintence(DataTable salaryTable)
        {
            DataTable dt = new DataTable();
            var       db = SugarDao_MsSql.GetInstance();

            db.Delete <Car_Maintain>(it => it.PushVGUID == null);   //删除推送为空的数据
            dt = db.Queryable <Car_Maintain>().Where("1=2").ToDataTable();
            db.Dispose();
            string connectionString = ConfigSugar.GetAppString("msSqlLinck");

            using (SqlBulkCopy sqlbulkcopy = new SqlBulkCopy(connectionString, SqlBulkCopyOptions.UseInternalTransaction))
            {
                try
                {
                    sqlbulkcopy.BulkCopyTimeout      = 60;
                    sqlbulkcopy.DestinationTableName = "Car_Maintain";
                    for (int i = 0; i < salaryTable.Columns.Count; i++)
                    {
                        sqlbulkcopy.ColumnMappings.Add(salaryTable.Columns[i].ColumnName, dt.Columns[i].ColumnName);
                    }
                    sqlbulkcopy.WriteToServer(salaryTable);
                    return(true);
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog(ex.ToString());
                    throw;
                }
                finally
                {
                    //db.Dispose();
                }
            }
        }
        /// <summary>
        /// 获取营收信息
        /// </summary>
        /// <param name="driverModel"></param>
        /// <returns></returns>
        public API_PaymentMonthly GetRevenueAPI_PaymentMonthlyData(Driver driverModel)
        {
            API_PaymentMonthly payment = new API_PaymentMonthly();

            try
            {
                WebClient wc = new WebClient();
                //测试数据
                //driverModel.OrganizationID = 17904;
                //driverModel.Id = 55;
                //driverModel.EmployeeNo = "993594";
                var data = "{" +
                           "\"OrganizationId\":\"{OrganizationId}\",".Replace("{OrganizationId}", driverModel.OrganizationID.ToString()) +
                           "\"DriverID\":\"{DriverID}\",".Replace("{DriverID}", driverModel.Id.ToString()) +
                           "\"EmployeeNo\":\"{EmployeeNo}\"".Replace("{EmployeeNo}", driverModel.EmployeeNo.ToString()) +
                           "}";
                wc.Headers.Clear();
                wc.Headers.Add("Content-Type", "application/json;charset=utf-8");
                wc.Encoding = System.Text.Encoding.UTF8;
                var result = wc.UploadString(new Uri(ConfigSugar.GetAppString("RevenueSytemPaymentMonthlyPath")), data);
                result = result.Replace("[]", "{}");
                API_Result apiResult = result.JsonToModel <API_Result>();
                if (apiResult.success)
                {
                    payment = apiResult.data;
                }
                Common.LogHelper.LogHelper.WriteLog(string.Format("{0}-{1}:{2}", driverModel.Name, driverModel.Id, result));
            }
            catch (Exception ex)
            {
                Common.LogHelper.LogHelper.WriteLog(string.Format("{0}-{1}:{2}", driverModel.Name, driverModel.Id, ex.ToString()));
            }
            return(payment);
        }
Esempio n. 11
0
        protected void btnCreateClassCode_Click(object sender, EventArgs e)
        {
            string connection = ConfigSugar.GetConfigString("connstring"); //这里可以动态根据cookies或session实现多库切换
            var    db         = new SqlSugarClient(connection);

            txtResult.Value = db.ClassGenerating.SqlToClass(db, txtSql.Text, txtClassName.Text);
            db.Dispose();
        }
        //
        // GET: /ValidateLogin/

        public ActionResult Index()
        {
            string resulMess = "";
            string vguid     = Request["vguid"];
            string token     = Request["token"];

            if (!string.IsNullOrEmpty(vguid) && !string.IsNullOrEmpty(token))
            {
                string toolKitValidateUrl = ConfigSugar.GetAppString("ToolKitValidateUrl");
                string url               = string.Format(toolKitValidateUrl + "?userVguid={0}&tokenVal={1}", vguid, token);
                string htmlResult        = HttpGet(url);
                var    actionResultModel = htmlResult.JsonToModel <ActionResultModel <string> >();
                if (actionResultModel.isSuccess)//登录令牌验证成功
                {
                    //UserServer us = new UserServer();
                    //RoleTypeServer rts = new RoleTypeServer();
                    bool isExist = false;//us.IsExistUserAccountByVGUID(vguid);
                    if (isExist)
                    {
                        bool isHavePersion = false;//rts.IsHaveMoudePermision(vguid);
                        if (isHavePersion)
                        {
                            //将用户信息保存到Cookie中
                            //T_User userModel = us.GetUserDetailModelByVguid(vguid);
                            //var cm = CookiesManager<T_User>.GetInstance();
                            //cm.Add(BiomobieAppSystem.Common.CostCookies.COOKIES_KEY_LOGIN, userModel, cm.Hour * 8);
                            resulMess = "";
                        }
                        else
                        {
                            resulMess = "您在本系统中未被分配任何模块访问权限,请联系本系统的管理人员!";
                        }
                    }
                    else
                    {
                        resulMess = "系统中不存在此用户信息!";
                    }
                }
                else//登录令牌验证失败
                {
                    resulMess = "您的登录令牌无效!";
                }
            }
            else
            {
                resulMess = "您的登录令牌无效!";
            }

            if (!string.IsNullOrEmpty(resulMess))
            {
                ViewBag.Message = resulMess;
                return(View());
            }
            else
            {
                return(RedirectToAction("Index", "Main"));
            }
        }
 /// <summary>
 /// 根据配置的系统参数结合具体人员形成最后的url地址加参数的形式
 /// </summary>
 /// <param name="personnelInfo"></param>
 /// <returns></returns>
 public string GetSysConfiguration(Business_Personnel_Information personnelInfo)
 {
     using (var db = SugarDao_MsSql.GetInstance())
     {
         var    configurations = db.Queryable <Master_Configuration>().Where(i => i.CreateUser == "QRCode" && i.ModifyUser == null).OrderBy(i => i.ID).ToList();
         string symbol         = ConfigSugar.GetAppString("Symbol") ?? "^";
         var    configParas    = configurations.Select(configuration => configuration.ConfigValue + symbol + configuration.ConfigDescription.Trim() + "?" + GetPersonConfiguration(personnelInfo, configuration.ID.ToString())).ToList();
         return(string.Join("|", configParas));
     }
 }
Esempio n. 14
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            string connection = ConfigSugar.GetConfigString("connstring"); //这里可以动态根据cookies或session实现多库切换
            var    db         = new SqlSugarClient(connection);;

            db.ClassGenerating.CreateClassFiles(db, txtPath.Text, txtNS.Text);
            db.Dispose();
            //还有其它方法我这边只是最简单的
            //db.ClassGenerating.CreateClassFilesByTableNames
            //db.ClassGenerating....
        }
Esempio n. 15
0
        /// <summary>
        /// 被动响应给微信的数据加密
        /// </summary>
        /// <param name="wcp"></param>
        /// <param name="postString"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static string EncryptMessage(U_WeChatCallbackParameter wcp, string postString, string message)
        {
            WXBizMsgCrypt wxcpt     = new WXBizMsgCrypt(ConfigSugar.GetAppString("WeChatCallbackToken"), ConfigSugar.GetAppString("WeChatCallbackEncodingAESKey"), ConfigSugar.GetAppString("CorpID"));
            string        result    = postString;
            int           errorCode = wxcpt.EncryptMsg(message, wcp.timestamp, wcp.nonce, ref result);

            if (errorCode != 0)
            {
                //错误记录日志
                LogHelper.WriteLog(errorCode.ToString());
            }
            return(result);
        }
        /// <summary>
        /// 同步人员数据
        /// </summary>
        public static void UpdatePersonData()
        {
            while (true)
            {
                bool result = false;
                int  time   = 0;
                if (DateTime.Now.Hour == 3)//时间为三点的时候time初始化
                {
                    time = 0;
                }
                if (DateTime.Now.Hour == 2 && time == 0)//时间为凌晨两点并且time为0的时候执行同步操作
                {
                    //  LogManager.WriteLog(LogFile.Trace, DateTime.Now.ToString("yyyy-MM-dd") + "开始启动定时同步离职人员服务");
                    try
                    {
                        U_AccessToken accessTokenModel = new U_AccessToken();
                        accessTokenModel.UserKey      = ConfigSugar.GetAppString("WeChatCorpID");
                        accessTokenModel.UserPassword = ConfigSugar.GetAppString("WeChatSecret");

                        UpdatePersonLogic             _updatePersonLogic = new UpdatePersonLogic();
                        List <V_UserNotexistsmiddata> personList         = new List <V_UserNotexistsmiddata>();
                        personList = _updatePersonLogic.GetPeosonList();   //获取离职人员列表(存在于Person表而不存在与middata表的人员列表)
                        _updatePersonLogic.UpdateStatus2Focus(personList); //首先将人员状态改为已关注
                        if (personList.Count >= 10)
                        {
                            result = _updatePersonLogic.UpdatePersonStatus(personList, 3);   //状态更改为未匹配
                        }
                        else if (personList.Count > 0)
                        {
                            result = _updatePersonLogic.DisableWeChatData(accessTokenModel, personList);  //同时将微信禁用
                            if (result)
                            {
                                result = _updatePersonLogic.UpdatePersonStatus(personList, 4);  //状态更改为已离职
                            }
                        }
                        //  result = _updatePersonLogic.DeletePersonData(personList);
                        //if (result)
                        //{
                        //    //删除微信通讯录中人员
                        //  result = _updatePersonLogic.DeleteWeChatData(accessTokenModel, personList);
                        //}
                        //   LogManager.WriteLog(LogFile.Trace, DateTime.Now.ToString("yyyy-MM-dd") + "定时同步离职人员服务启动完成");
                    }
                    catch (Exception exp)
                    {
                        LogManager.WriteLog(LogFile.Error, "同步离职人员数据:" + result + "/n" + exp.ToString());
                    }
                    time++;
                }
            }
        }
        /// <summary>
        /// 通过OAuth验证企业获取code
        /// </summary>
        /// <returns></returns>
        public string GetCorpCode()
        {
            string          url      = string.Format(_oAuthUrl, ConfigSugar.GetAppString("WeChatCorpID"), ConfigSugar.GetAppString("OpenHttpAddress") + "/BasicDataManagement/WeChatExercise/Index");
            HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            using (Stream resStream = response.GetResponseStream())
            {
                StreamReader reader   = new StreamReader(resStream, Encoding.UTF8);
                string       respText = reader.ReadToEnd();
                resStream.Close();
                return(respText);
            }
        }
Esempio n. 18
0
        public override string ExecuteButtonHandle()
        {
            string response                   = string.Empty;
            string revenueQueryReply          = _rl.GetRevenueQueryReply();                                   //获取营收数据查询成功回复
            string revenueQueryRefuse         = _rl.GetRevenueQueryRefuse();                                  //获取您不是司机,无法查询营收数据
            string revenueQueryTimeUp         = _rl.GetRevenueQueryTimesRefuse();                             //获取查询营收数据超过次数回复
            int    revenueSearchTimes         = int.Parse(_rl.GetRevenueSearchTimes());                       //获取每月可查收营收数据次数
            int    queryTimes                 = _rl.GetUserCurrentMonthQueryTimes(_eventHandle.FromUserName); //获取当前用户当月查询营收次数
            var    revenueQueryExceptionReply = _cs.GetConfigList()[12].ConfigValue;                          //营收异常回复
            var    queryReply                 = _cs.GetConfigList()[15].ConfigValue;                          //微信和短信都为勾选时回复

            string isSmsPush     = _ss.GetIsSmsPush();
            string isWeChatPush  = _ss.GetIsWeChatPush();
            string isRevenuePush = _ss.GetIsRevenuePush();

            if (isSmsPush == "0" && isWeChatPush == "0" && isRevenuePush == "0")
            {
                response = queryReply;
            }
            else if (queryTimes < revenueSearchTimes)
            {
                int result = _rl.SaveRevenueMsg(_eventHandle.FromUserName);
                if (result == 0)
                {
                    response = revenueQueryExceptionReply;//营收异常回复
                }
                if (result == 1)
                {
                    response = revenueQueryReply;//营收数据已经通过短信发送到您的手机,请及时查收
                }
                else if (result == 3)
                {
                    response = revenueQueryRefuse;//您不是司机,无法查询营收数据
                }
                else
                {
                    response = "查询失败!";
                }
            }
            else
            {
                response = revenueQueryTimeUp;//获取查询营收数据超过次数回复
            }
            string sReplyMsg   = string.Format(WeChatReplyType.Message_Text, _eventHandle.FromUserName, _eventHandle.ToUserName, DateTime.Now.Ticks, response);
            string sEncryptMsg = Cryptography.AES_encrypt(sReplyMsg, ConfigSugar.GetAppString("WeChatCallbackEncodingAESKey"), ConfigSugar.GetAppString("CorpID"));

            response = WeChatCallbackLogic.EncryptMessage(_eventHandle.U_WeChatCallbackParameter, sEncryptMsg, sReplyMsg);
            return(response);
        }
Esempio n. 19
0
 /// <summary>
 /// 开启微信回调模式
 /// </summary>
 /// <returns></returns>
 public string OpenWeChatCallbackMode(U_WeChatCallbackParameter wcp)
 {
     //数据不为空,表示验证开启微信回调模式
     //数据为空,表示微信数据正常回调
     if (!string.IsNullOrEmpty(wcp.echostr))
     {
         string corpid  = "";
         string echostr = Cryptography.AES_decrypt(wcp.echostr, ConfigSugar.GetAppString("WeChatCallbackEncodingAESKey"), ref corpid);
         return(echostr);
     }
     else
     {
         WeChatHandle wch = WeChatEventFactory.GetWeChatHandle(wcp, Request.InputStream);
         return(wch.ExecuteEventHandle());
     }
 }
Esempio n. 20
0
 public static SqlSugarClient GetInstance()
 {
     try
     {
         var db = new SqlSugarClient(new ConnectionConfig()
         {
             ConnectionString      = ConfigSugar.GetConnectionString("DefaultConnection"),
             IsAutoCloseConnection = true,
             DbType = DbType.SqlServer
         });
         return(db);
     }
     catch (Exception ex)
     {
         throw new Exception("连接数据库出错,请检查您的连接字符串,和网络。 ex:".AppendString(ex.Message));
     }
 }
        public JsonResult GetPaySignWX(string driverId, string organizationId, string revenueFee, Guid personVguid, Guid pushContentVguid, int revenueType, string factPayAmount)
        {
            var models    = new ActionResultModel <string>();
            var modelData = new QRCodeRevenueInfo();
            var url       = ConfigSugar.GetAppString("QRCodeRevenue");
            //Developer,Product 开发,正式
            var data = "{" +
                       "\"OperatorDeviceName\":\"{OperatorDeviceName}\",".Replace("{OperatorDeviceName}", "WXQYH") +
                       "\"OrganizationId\":\"{OrganizationId}\",".Replace("{OrganizationId}", organizationId) +
                       "\"DriverID\":\"{DriverID}\",".Replace("{DriverID}", driverId) +
                       "\"RunEnvironment\":\"{RunEnvironment}\",".Replace("{RunEnvironment}", "Product") +
                       "\"FactPayAmount\":\"{FactPayAmount}\"".Replace("{FactPayAmount}", factPayAmount) +
                       "}";

            try
            {
                WebClient wc = new WebClient();
                wc.Headers.Clear();
                wc.Headers.Add("Content-Type", "application/json;charset=utf-8");
                wc.Encoding = System.Text.Encoding.UTF8;
                var resultData = wc.UploadString(new Uri(url), data);
                modelData = resultData.JsonToModel <QRCodeRevenueInfo>();
                if (modelData.Code == "0")
                {
                    //接口调用成功,获取支付界面url
                    models.isSuccess   = true;
                    models.respnseInfo = modelData.data.BillQRCodeURL + "," + modelData.data.BillNo;
                    //var key = PubGet.GetUserKey + driverId;
                    //CacheManager<QRCodeRevenue>.GetInstance().Add(key, modelData.data, 8 * 60 * 60 * 1000);
                    SavePaymentHistory(driverId, revenueFee, personVguid, pushContentVguid, revenueType, modelData.data);
                }
                else
                {
                    //接口调用失败,支付二维码失效
                    WeChatRevenueServer.sendQRCodeMessage(modelData.data.BillNo);
                    models.isSuccess   = false;
                    models.respnseInfo = "接口调用失败";
                }
                LogHelper.WriteLog(string.Format("Data:{0},result:{1}", data, resultData));
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(string.Format("Data:{0},result:{1},error:{2}", data, modelData.message, ex.ToString()));
            }
            return(Json(models, JsonRequestBehavior.AllowGet));
        }
Esempio n. 22
0
        /// <summary>
        /// 生成controller
        /// </summary>
        private void BuildController(string controllerDir, string controllerPath, string controllerDomainPath, XDocument doc)
        {
            //写入控制器
            if (!FileSugar.IsExistFile(controllerPath))
            {
                FileSugar.CreateDirectory(controllerDir);
                ContainFileToCsproj(@"Areas\{0}\Controllers\{1}App\{1}Controller.cs".ToFormat(_data.AreaName, _data.ControllerName), _solutionDir, _projectName, doc);
            }

            //获取controller.cshtml的Model
            BuildControllerModel controllerModel = new BuildControllerModel()
            {
                areaName       = _data.AreaName,
                controllerName = _data.ControllerName,
                actionName     = _data.ActionName,
                siteName       = ConfigSugar.GetAppString("siteName")
            };

            var apiList    = _db.Queryable <SysBest_DataApi>().ToList();//获取所有api
            int addressId  = _data.Id;
            int languageId = _languageId;
            var eleList    = _db.Queryable <SysBest_Element>().Where(it => it.AddressId == addressId && it.LanguageId == languageId).ToList();

            var eleApidList = eleList.Where(it => it.ApiId != null && it.ApiId > 0).Select(it => it.ApiId).Distinct().ToList();//获取所有元素

            //获取元素表里面的数据接口
            controllerModel.apiList = apiList.Join(eleApidList, api => api.Id, ele => ele, (api, ele) => api).ToList();
            //获取属性表里面的数据接口
            controllerModel.apiList.AddRange(GetDataApiWithEleEventByEleId(eleList));
            controllerModel.apiList = controllerModel.apiList.Distinct().ToList();

            string controllerCode = GetTemplateCodeByName("controller.cshtml", controllerModel);

            FileSugar.WriteFile(controllerPath, controllerCode);

            //写入Domain
            if (!FileSugar.IsExistFile(controllerDomainPath))
            {
                var domainCode = GetTemplateCodeByName("controller_domain.cshtml", new { controllerName = _data.ControllerName, areaName = _data.AreaName });
                FileSugar.WriteFile(controllerDomainPath, domainCode);
                ContainFileToCsproj(@"Areas\{0}\Controllers\{1}App\Domain\{1}Domain.cs".ToFormat(_data.AreaName, _data.ControllerName), _solutionDir, _projectName, doc);
            }
        }
        public ActionResult PushDetail(string code)
        {
            string pushContentVguid = Request.QueryString["Vguid"]; //"55ca3608-93d3-4245-b6f7-e4af76482edd";//
            var    pushContentModel = _pl.GetPushDetail(pushContentVguid);
            string openHttpAddress  = ConfigSugar.GetAppString("OpenHttpAddress");
            bool   isValidTime      = false;//未过有效期

            if (pushContentModel != null)
            {
                if (pushContentModel.PeriodOfValidity != null)
                {
                    if (DateTime.Now > pushContentModel.PeriodOfValidity)
                    {
                        isValidTime = true;//已过有效期
                    }
                }
            }
            string accessToken = Common.WeChatPush.WeChatTools.GetAccessoken();
            string userInfoStr = Common.WeChatPush.WeChatTools.GetUserInfoByCode(accessToken, code);
            var    userInfo    = JsonHelper.JsonToModel <U_WeChatUserID>(userInfoStr); //用户ID

            _pl.UpdateIsRead(userInfo.UserId, pushContentVguid);                       //更新用户是否阅读推送
            if (pushContentModel.MessageType == 5)                                     //培训推送
            {
                if (pushContentModel.RevenueType != 0)
                {
                    ViewBag.countDownConfig = pushContentModel.RevenueType;
                }
                else
                {
                    string countDownStr    = _pl.GetCountDown();
                    double countDownConfig = double.Parse(countDownStr);//double.Parse(ConfigSugar.GetAppString("CountDown"));//倒计时配置
                    ViewBag.countDownConfig = countDownConfig;
                }
            }

            ViewBag.isValidTime          = isValidTime;
            ViewBag.code                 = code;
            ViewBag.openHttpAddress      = openHttpAddress;
            ViewData["PushContentModel"] = pushContentModel;
            return(View());
        }
        protected override string GetPushJson(U_UploadResult uploadResult, U_Content contentModel)
        {
            //List<U_WeChatUser> weChatUserList = SearchWeChatUserList();
            //string pushObject = GetPushObject(contentModel, weChatUserList);
            string pushObject     = GetPushObject(contentModel);
            string responeJsonStr = "";

            responeJsonStr  = "{";
            responeJsonStr += "\"touser\": \"" + pushObject + "\",";
            responeJsonStr += "\"toparty\": \"\",";
            responeJsonStr += "\"totag\": \"\",";
            responeJsonStr += "\"msgtype\": \"image\",";
            responeJsonStr += "\"agentid\":\"" + ConfigSugar.GetAppString("WeChatAgentID") + "\",";
            responeJsonStr += "\"image\": {";
            responeJsonStr += "\"media_id\":\"" + uploadResult.media_id + "\"";
            responeJsonStr += "},";
            responeJsonStr += "\"safe\":\"0\"";
            responeJsonStr += "}";
            return(responeJsonStr);
        }
        public string getWeChatQRCode(Business_CleaningCompany cleaning)
        {
            string file     = cleaning.CompanyName + ".jpg";
            string forder   = "UploadFile/WeChatQRCode";
            string filePath = Path.Combine(forder, file);
            string fileName = Server.MapPath(filePath);

            if (System.IO.File.Exists(fileName))
            {
                System.IO.File.Delete(fileName);
            }
            string guid  = cleaning.Vguid.ToString();
            string url   = ConfigSugar.GetAppString("CleaningAddress");
            string appid = ConfigSugar.GetAppString("CorpID");

            url = url + "?VGUID=" + guid;
            var configStr = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + url + "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";

            QRCodeHelper.GenerateQRCode(configStr, "/Areas/WeChatPush/Views/_img/logo1.png", forder, file);
            return(filePath);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string userId  = Convert.ToString(Request["userId"]);                //Toolkit系统传过来的用户识别码
            string tokenId = Convert.ToString(Request["tokenId"]);               //用户点击登录时产生的登录时的随机令牌

            if (!string.IsNullOrEmpty(userId) && !string.IsNullOrEmpty(tokenId))
            {
                string toolKitPath      = ConfigSugar.GetAppString("ToolKitValidateUrl"); //配置主系统的站点地址
                string url              = string.Format(toolKitPath + "?userid={0}&tokenid={1}", userId, tokenId);
                System.Net.WebClient wc = new System.Net.WebClient();
                wc.UseDefaultCredentials = true;
                string html = wc.DownloadString(url);

                if (html == "True")
                {
                    //UserBLL userBLL = new BLL.UserBLL();
                    //UserModel userModel = userBLL.GetModel(userId);
                    //if (userModel != null)
                    //{
                    //    Response.Redirect("FramePage/Main.aspx");
                    //}
                    //else
                    //{
                    //    string script = string.Format(@"<script>alert('系统中没有此账号信息,请联系管理员!');  window.close();</script>");
                    //    Response.Write(script);
                    //}
                }
                else
                {
                    string script = string.Format(@"<script>alert('您没有权限访问此系统!'); window.close();</script>");
                    Response.Write(script);
                }
            }
            else
            {
                string script = string.Format(@"<script>alert('您没有权限访问此系统!');window.close();</script>");
                Response.Write(script);
            }
        }
Esempio n. 27
0
        public void SynchronousReceivableSystem(Business_Personnel_Information personModel, Business_PaymentHistory_Information paymentHistoryInfo, Business_PaymentHistory_Information paymentHistoryInfoOld)
        {
            //获取司机ID和车辆ID
            try
            {
                var driverModel = _rl.GetDriverMsg(personModel);

                WebClient wc   = new WebClient();
                var       data = "{" +
                                 "\"BillLable\":\"WX\"," +
                                 "\"DriverID\":\"{DriverID}\",".Replace("{DriverID}", driverModel.Id.ToString()) +
                                 "\"JobNumber\":\"{JobNumber}\",".Replace("{JobNumber}", driverModel.EmployeeNo) +
                                 "\"Name\":\"{Name}\",".Replace("{Name}", personModel.Name == null ? "" : personModel.Name) +
                                 "\"OriginalId\":\"{OriginalId}\",".Replace("{OriginalId}", driverModel.OriginalId.ToString()) +
                                 "\"OrganizationID\":\"{OrganizationID}\",".Replace("{OrganizationID}", driverModel.OrganizationID.ToString()) +
                                 "\"PayDate\":\"{PayDate}\",".Replace("{PayDate}", paymentHistoryInfo.PayDate.ToString("yyyy-MM-dd HH:mm:ss")) +
                                 "\"TransactionId\":\"{TransactionId}\",".Replace("{TransactionId}", paymentHistoryInfo.TransactionID) +
                                 "\"PaymentBrokers\":\"WeiChat\"," +
                                 "\"Channel_Id\":\"1465779302\"," +
                                 "\"SubjectId\":\"1465779302_{0}\",".Replace("{0}", driverModel.OrganizationID.ToString()) +
                                 "\"PaymentAmount\":{PaymentAmount}, ".Replace("{PaymentAmount}", paymentHistoryInfoOld.RevenueReceivable.ToString()) +
                                 "\"CopeFee\":{CopeFee},".Replace("{CopeFee}", (paymentHistoryInfo.ActualAmount * paymentHistoryInfoOld.RevenueReceivable).ToString()) +
                                 "\"ActualAmount\":{ActualAmount},".Replace("{ActualAmount}", paymentHistoryInfo.ActualAmount.ToString()) +
                                 "\"ReceiptCategory\":11," +
                                 "\"Remark\":\"WeiChat\"," +
                                 "\"CompanyAccount\":0" +
                                 "}";
                wc.Headers.Clear();
                wc.Headers.Add("Content-Type", "application/json;charset=utf-8");
                wc.Encoding = System.Text.Encoding.UTF8;
                var result = wc.UploadString(new Uri(ConfigSugar.GetAppString("RevenueSytemSyncPath")), data);
                Common.LogHelper.LogHelper.WriteLog(string.Format("{0}-{1}:{2}", personModel.Name, paymentHistoryInfo.TransactionID, result));
            }
            catch (Exception ex)
            {
                Common.LogHelper.LogHelper.WriteLog(string.Format("{0}-{1}:{2}", personModel.Name, paymentHistoryInfo.TransactionID, ex.ToString()));
            }
        }
Esempio n. 28
0
        public static void sendQRCodeMessage(string billNo)
        {
            var resultData = "";
            var url        = ConfigSugar.GetAppString("ClosePayQRCode");
            //Developer,Product 开发,正式
            var data = "{" +
                       "\"billNo\":\"{billNo}\",".Replace("{billNo}", billNo) +
                       "\"RunEnvironment\":\"{RunEnvironment}\"".Replace("{RunEnvironment}", "Product") +
                       "}";

            try
            {
                WebClient wc = new WebClient();
                wc.Headers.Clear();
                wc.Headers.Add("Content-Type", "application/json;charset=utf-8");
                wc.Encoding = System.Text.Encoding.UTF8;
                resultData  = wc.UploadString(new Uri(url), data);
                //var modelData = resultData.JsonToModel<QRCodeRevenueInfo>();
                //if (modelData.Code == "0")
                //{
                //    //接口调用成功,跳转进入支付界面
                //    models.isSuccess = true;
                //    models.respnseInfo = modelData.QRCodeRevenue.BillQRCodeURL;
                //}
                //else
                //{
                //    //接口调用失败,支付二维码失效
                //    sendQRCodeMessage(modelData.QRCodeRevenue.BillNo);
                //    models.isSuccess = false;
                //    models.respnseInfo = modelData.message;
                //}
                LogHelper.WriteLog(string.Format("Data:{0},result:{1}", data, resultData));
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(string.Format("Data:{0},result:{1},error:{2}", data, resultData, ex.ToString()));
            }
        }
Esempio n. 29
0
        /// <summary>
        /// 微信二次验证
        /// </summary>
        /// <param name="code">微信用户Code</param>
        /// <returns></returns>
        public ActionResult WeChatSecondValidation(string code)
        {
            U_WeChatUserID userInfo    = new U_WeChatUserID();
            U_UserInfo     userDetail  = new U_UserInfo();
            string         accessToken = Common.WeChatPush.WeChatTools.GetAccessoken();
            //UserInfoUrl
            string userInfoStr = Common.WeChatPush.WeChatTools.GetUserInfoByCode(accessToken, code);

            userInfo = Common.JsonHelper.JsonToModel <U_WeChatUserID>(userInfoStr);//用户ID
            string GetUserInfoByUserID = Common.WeChatPush.WeChatTools.GetUserInfoByUserID(accessToken, userInfo.UserId);

            userDetail = Common.JsonHelper.JsonToModel <U_UserInfo>(GetUserInfoByUserID);//用户信息
            string openHttpAddress = ConfigSugar.GetAppString("OpenHttpAddress");

            Common.LogHelper.LogHelper.WriteLog("用户打开注册二次验证页面:Code为-" + code + "-UserID为-" + userInfo.UserId + "-打开注册页面时间为:" + DateTime.Now);

            ViewBag.openHttpAddress = openHttpAddress;
            ViewBag.accessToken     = accessToken;
            ViewBag.Code            = code;
            ViewBag.userInfo        = userInfo;
            ViewBag.userDetail      = userDetail;
            return(View());
        }
Esempio n. 30
0
        /// <summary>
        /// 发送短信验证码
        /// </summary>
        /// <param name="accessTokenModel">授权对象</param>
        /// <param name="contentModel">消息模板</param>
        /// <returns></returns>
        public override string Push(U_AccessToken accessTokenModel, U_Content contentModel)
        {
            HttpClient httpClient = new HttpClient();

            //将服务凭证转换为Base64编码格式
            byte[] auth   = Encoding.UTF8.GetBytes(string.Format("{0}:{1}", ConfigSugar.GetAppString("SMSAppKey"), ConfigSugar.GetAppString("MasterSecret")));
            String auth64 = Convert.ToBase64String(auth);

            //创建并指定服务凭证,认证方案为Basic
            httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", auth64);
            U_Notification_Teamp_Para ntp = new U_Notification_Teamp_Para();

            //将短信营收实体转换微信
            ntp.Notification = contentModel.Message;

            /*U_Temp_Para tp = new U_Temp_Para();*/

            U_Para para = new U_Para();

            para.mobile    = contentModel.PushObject[0].PhoneNumber.Trim();
            para.temp_id   = Convert.ToInt32(ConfigSugar.GetAppString("Notification_Temp_ID"));
            para.temp_para = ntp;

            string json = Common.JsonHelper.ModelToJson <U_Para>(para);

            System.Net.Http.StringContent sc = new System.Net.Http.StringContent(json);
            sc.Headers.Remove("Content-Type");
            sc.Headers.Add("Content-Type", "application/json");
            Task <HttpResponseMessage> taskHrm = httpClient.PostAsync(_noticeUrl, sc);

            Task.WaitAll(taskHrm);
            Task <string> taskStr = taskHrm.Result.Content.ReadAsStringAsync();

            Task.WaitAll(taskStr);
            UpdatePushStatus(contentModel);
            return(taskStr.Result);
        }