Пример #1
0
        public string Getjsapi_ticket()
        {
            EnterpriceService.MfWeiXinEmpServiceSoapClient c = new EnterpriceService.MfWeiXinEmpServiceSoapClient();

            string strjson = c.Getticket("Marisfrolg");

            return(strjson);
        }
Пример #2
0
        public string GetPersonInfomation()
        {
            try
            {
                EnterpriceService.MfWeiXinEmpServiceSoapClient wsc = new EnterpriceService.MfWeiXinEmpServiceSoapClient();

                var    employee = Marisfrolg.Public.Common.GetEmployeeInfo();
                string result   = wsc.GetuseridInfo(Identify, employee.EmployeeNo);


                return(result);
            }
            catch (Exception ex)
            {
                Logger.Write("微信方法报错:" + ex.ToString() + "," + System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
            return("{\"errcode\":60111,\"errmsg\":\"userid not found\"}");
        }
Пример #3
0
        public ActionResult AutoLogin()
        {
            string errorMsg = "";

            //从微信获取传入参数

            #region 从微信平台引入的自动登陆
            string code  = Request["code"];
            string state = Request["state"];
            Logger.Write("code:" + code + "|state:" + state);

            EnterpriceService.MfWeiXinEmpServiceSoapClient wsc = new EnterpriceService.MfWeiXinEmpServiceSoapClient();


            string userId = "";
            int    result = 0;

            try
            {
                result = wsc.GetUserId(Identify, code, ref userId);
            }
            catch (Exception)
            {
                Logger.Write("企业微信调用失败");
            }

            Logger.Write("result:" + result + "|userid:" + userId);
            #endregion

            #region 从ODS平台引入的自动登陆
            if (string.IsNullOrEmpty(userId))
            {
                userId = Public.Common.Decryption(Request["uc"].ToString());
                string passWord = Request["up"].ToString();
                Logger.Write("userId:" + userId + "|passWord:"******"Login", "Account"));
            }


            try
            {
                EMPLOYEE employee = DbContext.EMPLOYEE.Where(m => m.NO == userId).FirstOrDefault();
                if (employee == null)
                {
                    errorMsg = "工号不存在!";
                }
                else
                {
                    if (employee.LEAVE == "1" || employee.AVAILABLE == "0")
                    {
                        errorMsg = "此账号不可用!";
                    }
                }


                if (string.IsNullOrEmpty(errorMsg))
                {
                    var query = (from a in DbContext.EMPLOYEE
                                 join b in DbContext.SHOP on a.SHOPCODE equals b.CODE
                                 into temp
                                 from b in temp.DefaultIfEmpty()
                                 join c in DbContext.DEPARTMENT on a.DEPID equals c.ID
                                 where a.NO == userId
                                 select new
                    {
                        IsUcStar = a.IS_UCSTAR,
                        EmployeeNo = a.NO,
                        CompanyCode = c.COMPANYCODE,

                        DepartmentID = a.DEPID,
                        ShopCode = a.SHOPCODE,
                        ShopName = (b == null ? "" : b.NAME),
                        ShopType = (b == null ? "" : b.SHOP_PROPERTY),
                        Oversea = (b == null ? 0 : b.OVERSEA),
                        EmployeeName = a.NAME,
                        DepartmentName = (c == null ? "" : c.NAME)
                    }).FirstOrDefault();


                    //获取当前员工可操作的店柜
                    UIVALUE uiValue = DbContext.UIVALUE.Where(m => m.EMPLOYEENO == query.EmployeeNo && m.VALUETYPE == 4).FirstOrDefault();
                    string  uivalue = (uiValue == null || string.IsNullOrEmpty(uiValue.VALUE)) ? "" : uiValue.VALUE;
                    var     Shops   = (from m in DbContext.SHOP
                                       join d in DbContext.DEPARTMENT on m.DEPARTMENTID equals d.ID
                                       where uivalue.Contains(m.CODE)
                                       select new
                    {
                        shopCode = m.CODE,
                        shopName = m.NAME,
                        currency = m.CURRENCY.CODE,
                        departmentName = d.NAME,
                        departmentId = d.ID,
                        property = m.SHOP_PROPERTY,
                        oversea = m.OVERSEA
                    }).Union(
                        from x in DbContext.SHOP
                        join y in DbContext.DEPARTMENT on x.DEPARTMENTID equals y.ID
                        where (string.IsNullOrEmpty(query.ShopCode) ? false : x.CODE == query.ShopCode)
                        select new
                    {
                        shopCode       = x.CODE,
                        shopName       = x.NAME,
                        currency       = x.CURRENCY.CODE,
                        departmentName = y.NAME,
                        departmentId   = y.ID,
                        property       = x.SHOP_PROPERTY,
                        oversea        = x.OVERSEA
                    }
                        ).OrderBy(s => s.shopCode).ToList();


                    DEPARTMENT root         = GetRootDepartment(employee.DEPARTMENT);
                    var        CompanyName  = DbContext.COMPANY.Where(c => c.CODE == root.COMPANYCODE).Select(x => x.NAME).FirstOrDefault();
                    string     employeeInfo = "{CompanyCode:'" + query.CompanyCode
                                              + "',CompanyName:'" + HttpUtility.UrlEncode(CompanyName)
                                              + "',DepartmentID:'" + query.DepartmentID
                                              + "',ShopCode:'" + (string.IsNullOrEmpty(query.ShopCode) ? "" : query.ShopCode)
                                              + "',ShopName:'" + HttpUtility.UrlEncode((string.IsNullOrEmpty(query.ShopName) ? "" : query.ShopName), System.Text.Encoding.UTF8)
                                              + "',ShopType:'" + (string.IsNullOrEmpty(query.ShopType) ? "" : query.ShopType)
                                              + "',EmployeeNo:'" + query.EmployeeNo
                                              + "',Oversea:'" + query.Oversea
                                              + "',IsUcStar:'" + query.IsUcStar.ToString()
                                              + "',EmployeeName:'" + HttpUtility.UrlEncode((string.IsNullOrEmpty(query.EmployeeName) ? "" : query.EmployeeName), System.Text.Encoding.UTF8)
                                              + "',DepartmentName:'" + HttpUtility.UrlEncode((string.IsNullOrEmpty(query.DepartmentName) ? "" : query.DepartmentName), System.Text.Encoding.UTF8)
                                              + "',RootDepartmentName:'" + HttpUtility.UrlEncode((string.IsNullOrEmpty(root.NAME) ? "" : root.NAME), System.Text.Encoding.UTF8)
                                              + "',RootDepartmentID:'" + root.ID
                                              + "',COST_ACCOUNT:'" + (string.IsNullOrEmpty(root.COST_ACCOUNT) ? "" : root.COST_ACCOUNT)
                                              + "',IsHeadOffice:'" + (root.IsHeadOffice ? "1" : "0") //是否总部人员,1表示是
                                              + "',BankCardNo:'" + HttpUtility.UrlEncode("********", System.Text.Encoding.UTF8)
                                              + "',WebSocketConnection:'" + System.Web.Configuration.WebConfigurationManager.AppSettings["WebSocketConnection"]
                                              + "',UPCODE:'" + Common.Encryption(query.EmployeeNo)
                                              + "'}";

                    Marisfrolg.Public.CookieHelper.RemoveEmployeeInfo();
                    Marisfrolg.Public.CookieHelper.SetEmplyeeInfo(employeeInfo);

                    //操作日志
                    Marisfrolg.Public.Common.OperationLog(Common.GetClientComputerName(), employee.NO, employee.NO, this.GetType().ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, "Employee", "员工登陆", "", "");
                    DbContext.SaveChanges();
                    errorMsg = "success";
                }
            }
            catch (System.Data.Common.DbException ex)
            {
                Logger.Write("登陆失败:" + ex.ToString() + "," + System.Reflection.MethodBase.GetCurrentMethod().Name + ",登陆账号:" + userId);
                errorMsg = "数据库连接失败!";
            }
            catch (Exception ex)
            {
                Logger.Write("登陆失败:" + ex.ToString() + "," + System.Reflection.MethodBase.GetCurrentMethod().Name + ",登陆账号:" + userId);
                errorMsg = "系统错误!";
            }


            return(RedirectToAction("Index"));
            //return RedirectToAction("Index", "Home");
        }