示例#1
0
        /// <summary>
        /// 公司页面,添加或选择公司
        /// </summary>
        /// <param name="session">用户session</param>
        /// <param name="companyName">公司全名称</param>
        /// <returns></returns>
        public string AddOrSelectCompany_EditCompany(string session, string companyName)
        {
            string resultStr = "";

            Common.Logger.Error("AddOrSelectCompany_EditCompany方法获取到的参数session:" + session + "---companyName:" + companyName);
            //公司表查看数据库是否有此公司,1有的话就给session用户绑定上此公司,2没有的话就先给公司表添加公司再给session用户绑定公司
            //获取公司ID (调用AddOrSelectCompany方法即可)
            string companyID = AddOrSelectCompany(companyName);

            Common.Logger.Error("AddOrSelectCompany_EditCompany方法获取公司ID为:" + companyID);
            //通过session修改个人绑定的公司ID
            SB_UserEL userEL = new SB_UserEL();

            userEL.CompanyID    = long.Parse(companyID);
            userEL.Session_True = session;
            int  ra;
            long excuteUpdate = userEL.ExecNonQuery(26, out ra);

            Common.Logger.Error("AddOrSelectCompany_EditCompany方法用户绑定公司结果为(大于0成功):" + excuteUpdate);
            if (ra > 0)
            {
                resultStr = "success";
            }
            else
            {
                resultStr = "error";
            }
            return(resultStr);
        }
示例#2
0
        /// <summary>
        /// 获取个人小程序码图片
        /// </summary>
        /// <param name="path">小程序码跳转的路径</param>
        /// <param name="session">用户session</param>
        /// <returns></returns>
        public string GetUserQRCode(string path, string session)
        {
            HF.Cloud.BLL.Common.Logger.Error("GetUserQRCode方法,参数path:" + path + "------session:" + session);
            string imgPath = "";
            //判断数据库中是否有值
            SB_UserEL userEL = GetUserELBySession(session);

            //如果QRCode有值,则返回数据库中QRCode的值
            if (!string.IsNullOrEmpty(userEL.QRCode) && userEL.QRCode != "")
            {
                //获取图片名称
                string qrCodeImageName = userEL.QRCode;
                //获取图片路径
                string qrCodeImagePath = System.Configuration.ConfigurationManager.AppSettings["QRCodeGet_User"];
                imgPath = qrCodeImagePath + qrCodeImageName;
            }
            //数据库中QRCode没有数据,则需要获取小程序码图片保存图片,并把图片名称保存到数据库中
            else
            {
                //获取token
                WX_TokenBLL tokenBLL = new WX_TokenBLL();
                string      token    = tokenBLL.GetToken();
                //获取小程序码接口
                string url = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" + token;
                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic.Add("path", path);
                JavaScriptSerializer js = new JavaScriptSerializer();
                js.MaxJsonLength = int.MaxValue;
                string json = js.Serialize(dic);
                HF.Cloud.BLL.Common.Logger.Error("GetUserQRCode方法,获取小程序码的json:" + json);
                HF.Cloud.BLL.Common.Logger.Error("GetUserQRCode方法,url:" + url + "-----Path:" + path);
                //post返回的小程序码流
                Stream QRCodeStream = WeChatAppDecrypt.Post(url, json);
                //将图片流转换成图片
                Bitmap tp = new Bitmap(QRCodeStream);
                string QRCodeSave_User = System.Configuration.ConfigurationManager.AppSettings["QRCodeSave_User"];
                string image_userName  = Guid.NewGuid().ToString();
                string qrCodeImageName = image_userName + ".jpg";
                HF.Cloud.BLL.Common.Logger.Error("GetUserQRCode方法,保存小程序图片路径名称:" + QRCodeSave_User + qrCodeImageName);
                tp.Save(QRCodeSave_User + qrCodeImageName);
                //把小程序码图片名称保存到数据库中
                userEL.QRCode = qrCodeImageName;
                int  ra;
                long returnValue = userEL.ExecNonQuery(27, out ra);
                HF.Cloud.BLL.Common.Logger.Error("GetUserQRCode方法,保存小程序图片名称结果:" + ra);
                if (ra > 0)
                {
                    string QRCodeGet_User = System.Configuration.ConfigurationManager.AppSettings["QRCodeGet_User"];
                    imgPath = QRCodeGet_User + qrCodeImageName;
                }
                else
                {
                    imgPath = "error";
                }
            }
            HF.Cloud.BLL.Common.Logger.Error("GetUserQRCode方法,返回的结果:" + imgPath);
            return(imgPath);
        }
示例#3
0
        protected void LnkBtnDelete_Command(object sender, CommandEventArgs e)
        {
            string     cn     = e.CommandName;
            string     cnArgs = e.CommandArgument.ToString();
            SB_UserMEL userM  = new SB_UserMEL();
            int        flag;

            using (TransactionScope scope = new TransactionScope())
            {
                switch (cn)
                {
                case "Stop":
                    userM.ID = long.Parse(cnArgs);
                    userM.ExecNonQuery(3, out flag);

                    SB_UserEL user = new SB_UserEL()
                    {
                        Valid  = 0,
                        MainID = userM.ID
                    };

                    user.ExecNonQuery(25, out flag);

                    BindDataList();
                    break;

                case "Enable":
                    userM.ID = long.Parse(cnArgs);
                    userM.ExecNonQuery(31, out flag);

                    SB_UserEL userE = new SB_UserEL()
                    {
                        Valid  = 1,
                        MainID = userM.ID
                    };

                    userE.ExecNonQuery(25, out flag);

                    BindDataList();

                    break;
                }

                scope.Complete();
            }
        }
示例#4
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="strAddUser"></param>
        /// <returns></returns>
        public string InsertUser(string strAddUser)
        {
            BLL.Common.Logger.Error("InsertUser方法新增加用户接受到的参数string:" + strAddUser);
            string InsertUserRes    = "";//返回的数据
            JavaScriptSerializer js = new JavaScriptSerializer();
            var       info          = js.Deserialize <Dictionary <string, object> >(strAddUser);
            SB_UserEL SB_User_el    = new SB_UserEL();

            SB_User_el.UserName  = info["UserName"].ToString();
            SB_User_el.UserTel   = info["UserTel"].ToString();
            SB_User_el.Duty      = info["Duty"].ToString();
            SB_User_el.UserEmail = info["UserEmail"].ToString();
            SB_User_el.Detail    = info["Detail"].ToString();
            SB_User_el.ImgUrl    = info["ImgUrl"].ToString();
            SB_User_el.CompanyID = long.Parse(info["CompanyID"].ToString());

            SB_User_el.Popularity = 0;
            SB_User_el.Thumbs     = 0;
            SB_User_el.CreateTime = DateTime.Now.ToString();
            SB_User_el.Valid      = 1;
            SB_User_el.UnionID    = "";

            //string strOpneID = info["OpenID"].ToString();
            //SB_User_el.OpenID = strOpneID;
            //string strSession_Key= info["Session_Key"].ToString();
            //SB_User_el.Session_Key = strSession_Key;

            //SB_User_el.UnionID = "";

            //string strSession_true = "";
            //string strRandom = new Random().Next(100000, 1000000).ToString();
            //strSession_true = strSession_Key.Substring(0, strSession_Key.Length - 2) + strOpneID + strRandom;
            //SB_User_el.Session_True = strSession_true;
            //----------------------------------------------------------------------------------
            //string code = info["Code"].ToString();
            //string strSession_true = "";
            //string strOpneID = "";
            //if (!string.IsNullOrEmpty(code))
            //{
            //    //获取openid和Session_Key
            //    WeChatAppDecrypt Wechat = new WeChatAppDecrypt();
            //    string str_res = Wechat.GetOpenIdAndSessionKeyString(code);
            //    BLL.Common.Logger.Error("新增加用户获取到openid和Sessionkey:" + str_res);
            //    var openidAndSessionKey = js.Deserialize<Dictionary<string, object>>(str_res);
            //    strOpneID = openidAndSessionKey["openid"].ToString();
            //    SB_User_el.OpenID = strOpneID;
            //    SB_User_el.Session_Key = openidAndSessionKey["session_key"].ToString();
            //    SB_User_el.UnionID = "";
            //    string strRandom = new Random().Next(100000, 1000000).ToString();
            //    strSession_true = openidAndSessionKey["session_key"].ToString() + strRandom;
            //    SB_User_el.Session_True = strSession_true;
            //}


            //string strOpneID = "";
            //string strSession_key = "";
            ////如果传过来OpenID和Session_Key(小程序获取手机号从而得到OpenID和Session_key)
            //if (!string.IsNullOrEmpty(info["OpenID"].ToString()) && !string.IsNullOrEmpty(info["Session_Key"].ToString()))
            //{
            //    strOpneID = info["OpenID"].ToString();
            //    strSession_key = info["Session_Key"].ToString();
            //}
            ////如果没有openID和Session_Key的话就用Code去换取(小程序中直接填写的手机号,没有获取)
            //else if (!string.IsNullOrEmpty(info["Code"].ToString()))
            //{
            //    //获取openid和Session_Key
            //    WeChatAppDecrypt Wechat = new WeChatAppDecrypt();
            //    string str_res = Wechat.GetOpenIdAndSessionKeyString(info["Code"].ToString());
            //    BLL.Common.Logger.Error("InsertUser方法新增加用户获取到openid和Sessionkey:" + str_res);
            //    var openidAndSessionKey = js.Deserialize<Dictionary<string, object>>(str_res);
            //    strOpneID = openidAndSessionKey["openid"].ToString();
            //    strSession_key = openidAndSessionKey["session_key"].ToString();
            //}
            //SB_User_el.OpenID = strOpneID;
            //SB_User_el.Session_Key = strSession_key;


            string session_True = info["Session_True"].ToString();

            //判断Session_True是否为空
            if (!string.IsNullOrEmpty(session_True) && session_True != "")
            {
                //User表中判断Session_True,看是否有Session_True,有的话就是修改,没有的话就是添加
                SB_UserEL SB_User_el_IsHadSession = new SB_UserEL();
                SB_User_el_IsHadSession.Session_True = session_True;
                DataTable dt = SB_User_el_IsHadSession.ExecDT(45);
                BLL.Common.Logger.Error("InsertUser方法用户表中查询用户个数为:" + dt.Rows.Count);

                if (dt != null && dt.Rows.Count > 0)
                {
                    //修改用户记录
                    SB_User_el.Session_True = session_True;
                    int  aff;
                    long executeResul = SB_User_el.ExecNonQuery(24, out aff);
                    BLL.Common.Logger.Error("InsertUser方法修改用户信息结果为:" + aff);
                    if (aff > 0)
                    {
                        //返回数据库中的Session_True
                        InsertUserRes = session_True;
                        BLL.Common.Logger.Error("InsertUser方法这里是修改用户信息成功,返回的session为:" + InsertUserRes);
                    }
                    else
                    {
                        InsertUserRes = "error";
                    }
                }
                else//添加用户
                {
                    SB_User_el.Session_True = session_True;
                    //拆分sesison_True,获取openid和sesison_key
                    string str_session_key = session_True.Substring(0, 22) + "==";
                    string str_openid      = session_True.Substring(22, 28);
                    SB_User_el.Session_Key = str_session_key;
                    SB_User_el.OpenID      = str_openid;
                    //添加
                    int  aff;
                    long executeResul = SB_User_el.ExecNonQuery(1, out aff);
                    BLL.Common.Logger.Error("InsertUser方法添加用户信息结果为:" + executeResul);
                    if (executeResul > 0)
                    {
                        InsertUserRes = session_True;
                        BLL.Common.Logger.Error("InsertUser方法添加用户信息成功!返回的session为:" + InsertUserRes);
                    }
                    else
                    {
                        InsertUserRes = "error";
                    }
                }
            }

            ////User表中判断openid,看是否有openid,有的话就是修改,没有的话就是添加
            //SB_UserEL SB_User_el_IsHaveOpenID = new SB_UserEL();
            //SB_User_el_IsHaveOpenID.OpenID = strOpneID;
            //SB_User_el_IsHaveOpenID.ExecuteEL(43);
            //if (SB_User_el_IsHaveOpenID.ID > 0)
            //{
            //    //修改用户记录
            //    int aff;
            //    long executeResul = SB_User_el.ExecNonQuery(24, out aff);
            //    if (aff > 0)
            //    {
            //        //返回数据库中的Session_True
            //        InsertUserRes = SB_User_el_IsHaveOpenID.Session_True;
            //        BLL.Common.Logger.Error("InsertUser方法这里是修改用户信息成功,返回的session为:" + InsertUserRes);
            //    }
            //    else
            //    {
            //        InsertUserRes = "";
            //    }
            //}
            //else
            //{
            //    //添加用户记录
            //    //生成session
            //    string strSession_true = "";
            //    string strRandom = new Random().Next(100000, 1000000).ToString();
            //    strSession_true = strSession_key.Substring(0, strSession_key.Length - 2) + strOpneID + strRandom;
            //    SB_User_el.Session_True = strSession_true;
            //    //添加
            //    int aff;
            //    long executeResul = SB_User_el.ExecNonQuery(1, out aff);
            //    if (executeResul > 0)
            //    {
            //        InsertUserRes = strSession_true;
            //        BLL.Common.Logger.Error("InsertUser方法添加用户信息成功!返回的session为:" + InsertUserRes);
            //    }
            //    else
            //    {
            //        InsertUserRes = "";
            //    }
            //}

            return(InsertUserRes);
        }