Esempio n. 1
0
        public ActionResult Index(string urlstr)
        {
            //1.2根据注册的微信id去用户表中匹配是否有此员工
            WeChat_UsersEntity entity = wechatUserBll.GetEntity(CurrentWxUser.OpenId);

            //WeChat_UsersEntity entity = wechatUserBll.GetEntity("o7HEd1LjnupfP0BBBMz5f69MFYVE");
            if (!string.IsNullOrEmpty(entity.UserName) && !string.IsNullOrEmpty(entity.UserId))
            {
                UserEntity userEntity = new UserBLL().GetEntity(entity.UserId);

                LogEntity logEntity = new LogEntity();
                logEntity.CategoryId     = 1;
                logEntity.OperateTypeId  = ((int)OperationType.Login).ToString();
                logEntity.OperateType    = EnumAttribute.GetDescription(OperationType.AppLogin);
                logEntity.OperateAccount = userEntity.RealName;
                logEntity.OperateUserId  = userEntity.RealName;
                logEntity.Module         = Config.GetValue("SoftName");
                //写入日志
                logEntity.ExecuteResult     = 1;
                logEntity.ExecuteResultJson = "登录成功";
                logEntity.WriteLog();

                AuthorizeBLL authorizeBLL = new AuthorizeBLL();
                Operator     operators    = new Operator();
                operators.UserId        = userEntity.UserId;
                operators.Code          = userEntity.EnCode;
                operators.Account       = userEntity.Account;
                operators.UserName      = userEntity.RealName;
                operators.Password      = userEntity.Password;
                operators.Secretkey     = userEntity.Secretkey;
                operators.CompanyId     = userEntity.OrganizeId;
                operators.DepartmentId  = userEntity.DepartmentId;
                operators.IPAddress     = Net.Ip;
                operators.IPAddressName = IPLocation.GetLocation(Net.Ip);
                operators.ObjectId      = new PermissionBLL().GetObjectStr(userEntity.UserId);
                operators.LogTime       = DateTime.Now;
                operators.Token         = DESEncrypt.Encrypt(Guid.NewGuid().ToString());

                //写入当前用户数据权限
                AuthorizeDataModel dataAuthorize = new AuthorizeDataModel();
                dataAuthorize.ReadAutorize        = authorizeBLL.GetDataAuthor(operators);
                dataAuthorize.ReadAutorizeUserId  = authorizeBLL.GetDataAuthorUserId(operators);
                dataAuthorize.WriteAutorize       = authorizeBLL.GetDataAuthor(operators, true);
                dataAuthorize.WriteAutorizeUserId = authorizeBLL.GetDataAuthorUserId(operators, true);
                operators.DataAuthorize           = dataAuthorize;
                //判断是否系统管理员
                if (userEntity.Account == "System")
                {
                    operators.IsSystem = true;
                }
                else
                {
                    operators.IsSystem = false;
                }
                OperatorProvider.Provider.AddCurrent(operators);
                //return RedirectToAction("Index", "WeiXinHome");
                return(RedirectToAction("Index", "WeiXinHome", new { urlstr = urlstr }));
            }
            else
            {
                return(View());
            }
        }
Esempio n. 2
0
        //登录
        private Negotiator CheckLogin(dynamic _)
        {
            var       recdata   = this.GetModule <ReceiveModule <loginData> >();
            LogEntity logEntity = new LogEntity();

            logEntity.CategoryId     = 1;
            logEntity.OperateTypeId  = ((int)OperationType.Login).ToString();
            logEntity.OperateType    = EnumAttribute.GetDescription(OperationType.Login);
            logEntity.OperateAccount = recdata.data.username;
            logEntity.OperateUserId  = recdata.data.username;
            logEntity.Module         = "Offertech.敏捷开发框架";
            try
            {
                Operator       operators = new Operator();
                LoginUserModel loginUser = new LoginUserModel();
                loginUserInfo  result    = new loginUserInfo();

                #region 第三方账户验证
                AccountEntity accountEntity = accountBLL.CheckLogin(recdata.data.username, recdata.data.password);
                if (accountEntity != null)
                {
                    loginUser.UserId        = accountEntity.AccountId;
                    loginUser.Code          = accountEntity.MobileCode;
                    loginUser.Account       = accountEntity.MobileCode;
                    loginUser.UserName      = accountEntity.FullName;
                    loginUser.Password      = accountEntity.Password;
                    loginUser.IPAddress     = Net.Ip;
                    loginUser.IPAddressName = IPLocation.GetLocation(Net.Ip);
                    loginUser.LogTime       = DateTime.Now;
                    loginUser.Token         = DESEncrypt.Encrypt(Guid.NewGuid().ToString());
                    loginUser.IsSystem      = true;
                    //登录限制
                    LoginLimit(recdata.data.username, loginUser.IPAddress, loginUser.IPAddressName, recdata.platform);
                    result.userid   = loginUser.UserId;
                    result.account  = loginUser.Account;
                    result.password = loginUser.Password;
                    result.realname = loginUser.UserName;
                    result.headicon = "";
                    result.gender   = "";
                    result.mobile   = loginUser.Account;
                }
                #endregion

                #region 内部登录
                else
                {
                    //写入当前用户信息
                    UserEntity userEntity = new UserBLL().CheckLogin(recdata.data.username, recdata.data.password);
                    if (userEntity != null)
                    {
                        AuthorizeBLL authorizeBLL = new AuthorizeBLL();
                        loginUser.UserId       = userEntity.UserId;
                        loginUser.Code         = userEntity.EnCode;
                        loginUser.Account      = userEntity.Account;
                        loginUser.UserName     = userEntity.RealName;
                        loginUser.Password     = userEntity.Password;
                        loginUser.Secretkey    = userEntity.Secretkey;
                        loginUser.CompanyId    = userEntity.OrganizeId;
                        loginUser.DepartmentId = userEntity.DepartmentId;
                        loginUser.IPAddress    = Net.Ip;
                        loginUser.ObjectId     = new PermissionBLL().GetObjectStr(userEntity.UserId);
                        loginUser.LogTime      = DateTime.Now;
                        loginUser.Token        = DESEncrypt.Encrypt(Guid.NewGuid().ToString());
                        if (userEntity.Account == "System")
                        {
                            loginUser.IsSystem = true;
                        }
                        else
                        {
                            loginUser.IsSystem = false;
                        }
                        operators.LoginInfo = loginUser;
                        //写入当前用户数据权限
                        AuthorizeDataModel dataAuthorize = new AuthorizeDataModel();
                        dataAuthorize.ReadAutorize        = authorizeBLL.GetDataAuthor(operators);
                        dataAuthorize.ReadAutorizeUserId  = authorizeBLL.GetDataAuthorUserId(operators);
                        dataAuthorize.WriteAutorize       = authorizeBLL.GetDataAuthor(operators, true);
                        dataAuthorize.WriteAutorizeUserId = authorizeBLL.GetDataAuthorUserId(operators, true);
                        operators.DataAuthorize           = dataAuthorize;



                        result.userid         = userEntity.UserId;
                        result.account        = userEntity.Account;
                        result.password       = userEntity.Password;
                        result.realname       = userEntity.RealName;
                        result.headicon       = "";
                        result.gender         = (userEntity.Gender == 1 ? "男" : "女");
                        result.mobile         = userEntity.Mobile;
                        result.telephone      = userEntity.Telephone;
                        result.email          = userEntity.Email;
                        result.oicq           = userEntity.OICQ;
                        result.wechat         = userEntity.WeChat;
                        result.msn            = userEntity.MSN;
                        result.managerid      = userEntity.ManagerId;
                        result.manager        = userEntity.Manager;
                        result.organizeid     = userEntity.OrganizeId;
                        result.organizename   = organizeCache.GetEntity(result.organizeid).FullName;
                        result.departmentid   = userEntity.DepartmentId;
                        result.departmentname = departmentCache.GetEntity(userEntity.DepartmentId).FullName;
                        result.roleid         = userEntity.RoleId;
                        result.rolename       = roleCache.GetEntity(userEntity.RoleId).FullName;
                        result.dutyid         = userEntity.DutyId;
                        result.dutyname       = userEntity.DutyName;
                        result.postid         = userEntity.PostId;
                        result.postname       = userEntity.PostName;
                        result.description    = userEntity.Description;
                    }
                }
                #endregion

                //移动端不采用cookie的方式
                this.WriteCache <Operator>(operators, operators.LoginInfo.UserId);

                //写入日志
                logEntity.ExecuteResult     = 1;
                logEntity.ExecuteResultJson = "登录成功";
                logEntity.WriteLog();

                return(this.SendData <loginUserInfo>(result, result.userid, operators.LoginInfo.Token, ResponseType.Success));
            }
            catch (Exception ex)
            {
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = ex.Message;
                logEntity.WriteLog();
                return(this.SendData(ResponseType.Fail, ex.Message));
            }
        }
Esempio n. 3
0
        public ActionResult CheckLogin(string username, string password, string verifycode, int autologin)

        {
            LogEntity logEntity = new LogEntity();

            logEntity.CategoryId     = 1;
            logEntity.OperateTypeId  = ((int)OperationType.Login).ToString();
            logEntity.OperateType    = EnumAttribute.GetDescription(OperationType.Login);
            logEntity.OperateAccount = username;
            logEntity.OperateUserId  = username;
            logEntity.Module         = Config.GetValue("SoftName");

            try
            {
                #region 验证码验证
                if (autologin == 0)
                {
                    verifycode = Md5Helper.MD5(verifycode.ToLower(), 16);
                    if (Session["session_verifycode"].IsEmpty() || verifycode != Session["session_verifycode"].ToString())
                    {
                        throw new Exception("验证码错误,请重新输入");
                    }
                }
                #endregion

                #region 第三方账户验证 modify by chengzg 20160812 关闭该验证
                //AccountEntity accountEntity = accountBLL.CheckLogin(username, password);
                //if (accountEntity != null)
                //{
                //    Operator operators = new Operator();
                //    operators.UserId = accountEntity.AccountId;
                //    operators.Code = accountEntity.MobileCode;
                //    operators.Account = accountEntity.MobileCode;
                //    operators.UserName = accountEntity.FullName;
                //    operators.Password = accountEntity.Password;
                //    operators.IPAddress = Net.Ip;
                //    operators.IPAddressName = IPLocation.GetLocation(Net.Ip);
                //    operators.LogTime = DateTime.Now;
                //    operators.Token = DESEncrypt.Encrypt(Guid.NewGuid().ToString());
                //    operators.IsSystem = true;
                //    OperatorProvider.Provider.AddCurrent(operators);
                //    //登录限制
                //    LoginLimit(username, operators.IPAddress, operators.IPAddressName);
                //    return Success("登录成功。");
                //}
                #endregion

                #region 内部账户验证
                UserEntity userEntity = new UserBLL().CheckLogin(username, password);
                if (userEntity != null)
                {
                    AuthorizeBLL authorizeBLL = new AuthorizeBLL();
                    Operator     operators    = new Operator();
                    operators.UserId        = userEntity.UserId;
                    operators.Code          = userEntity.EnCode;
                    operators.Account       = userEntity.Account;
                    operators.UserName      = userEntity.RealName;
                    operators.Password      = userEntity.Password;
                    operators.Secretkey     = userEntity.Secretkey;
                    operators.CompanyId     = userEntity.OrganizeId;
                    operators.DepartmentId  = userEntity.DepartmentId;
                    operators.IPAddress     = Net.Ip;
                    operators.IPAddressName = IPLocation.GetLocation(Net.Ip);
                    operators.ObjectId      = new PermissionBLL().GetObjectStr(userEntity.UserId);
                    operators.LogTime       = DateTime.Now;
                    operators.Token         = DESEncrypt.Encrypt(Guid.NewGuid().ToString());
                    operators.Description   = userEntity.Description;
                    //写入当前用户数据权限
                    AuthorizeDataModel dataAuthorize = new AuthorizeDataModel();
                    dataAuthorize.ReadAutorize        = authorizeBLL.GetDataAuthor(operators);
                    dataAuthorize.ReadAutorizeUserId  = authorizeBLL.GetDataAuthorUserId(operators);
                    dataAuthorize.WriteAutorize       = authorizeBLL.GetDataAuthor(operators, true);
                    dataAuthorize.WriteAutorizeUserId = authorizeBLL.GetDataAuthorUserId(operators, true);
                    operators.DataAuthorize           = dataAuthorize;
                    //判断是否系统管理员
                    if (userEntity.Account == "System")
                    {
                        operators.IsSystem = true;
                    }
                    else
                    {
                        operators.IsSystem = false;
                    }
                    OperatorProvider.Provider.AddCurrent(operators);
                    //登录限制  modify by chengzg 20160812 关闭该验证
                    //LoginLimit(username, operators.IPAddress, operators.IPAddressName);
                    //写入日志
                    logEntity.ExecuteResult     = 1;
                    logEntity.ExecuteResultJson = "登录成功";
                    logEntity.WriteLog();
                }
                return(Success("登录成功。"));

                #endregion
            }
            catch (Exception ex)
            {
                WebHelper.RemoveCookie("learn_autologin");                  //清除自动登录
                WebHelper.RemoveCookie("learn_username");
                WebHelper.RemoveCookie("learn_password");
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = ex.Message;
                logEntity.WriteLog();
                return(Error(ex.Message));
            }
        }
        /// <summary>
        /// 图片上传
        /// </summary>
        /// <param name="folderId"></param>
        /// <param name="Filedata"></param>
        public void UploadifyFile(string folderId, string foldername, HttpFileCollection fileList)
        {
            try
            {
                if (fileList.Count > 0)
                {
                    for (int i = 0; i < fileList.AllKeys.Length; i++)
                    {
                        HttpPostedFile file = fileList[i];

                        if (fileList.AllKeys[i].Contains(foldername))
                        {
                            //获取文件完整文件名(包含绝对路径)
                            //文件存放路径格式:/Resource/ResourceFile/{userId}{data}/{guid}.{后缀名}
                            string userId         = OperatorProvider.Provider.Current().UserId;
                            string fileGuid       = Guid.NewGuid().ToString();
                            long   filesize       = file.ContentLength;
                            string FileEextension = Path.GetExtension(file.FileName);
                            string uploadDate     = DateTime.Now.ToString("yyyyMMdd");
                            string virtualPath    = string.Format("~/Resource/ht/images/{0}/{1}{2}", uploadDate, fileGuid, FileEextension);
                            string virtualPath1   = string.Format("/Resource/ht/images/{0}/{1}{2}", uploadDate, fileGuid, FileEextension);
                            string fullFileName   = dataitemdetailbll.GetItemValue("imgPath") + virtualPath1;
                            //创建文件夹
                            string path = Path.GetDirectoryName(fullFileName);
                            Directory.CreateDirectory(path);
                            FileInfoEntity fileInfoEntity = new FileInfoEntity();
                            if (!System.IO.File.Exists(fullFileName))
                            {
                                //保存文件
                                file.SaveAs(fullFileName);
                            }
                            //文件信息写入数据库
                            fileInfoEntity.Create();
                            fileInfoEntity.FileId         = fileGuid;
                            fileInfoEntity.RecId          = folderId; //关联ID
                            fileInfoEntity.FolderId       = "ht/images";
                            fileInfoEntity.FileName       = file.FileName;
                            fileInfoEntity.FilePath       = virtualPath;
                            fileInfoEntity.FileSize       = filesize.ToString();
                            fileInfoEntity.FileExtensions = FileEextension;
                            fileInfoEntity.FileType       = FileEextension.Replace(".", "");
                            fileInfoBLL.SaveForm("", fileInfoEntity);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogEntity logEntity = new LogEntity();
                logEntity.CategoryId        = 4;
                logEntity.OperateTypeId     = ((int)OperationType.Exception).ToString();
                logEntity.OperateType       = EnumAttribute.GetDescription(OperationType.Exception);
                logEntity.OperateAccount    = curUser.UserName;
                logEntity.OperateUserId     = curUser.UserId;
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = ex.Message;
                logEntity.Module            = SystemInfo.CurrentModuleName;
                logEntity.ModuleId          = SystemInfo.CurrentModuleId;
                logEntity.WriteLog();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 登录验证
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <param name="verifycode">验证码</param>
        /// <param name="autologin">下次自动登录</param>
        /// <returns></returns>
        //[HttpPost]
        //[HttpGet]
        //[AjaxOnly]
        public ActionResult CheckLogin(string username, string password, string verifycode, int autologin)
        {
            LogEntity logEntity = new LogEntity();

            logEntity.CategoryId     = 1;
            logEntity.OperateTypeId  = ((int)OperationType.Login).ToString();
            logEntity.OperateType    = EnumAttribute.GetDescription(OperationType.Login);
            logEntity.OperateAccount = username;
            logEntity.OperateUserId  = username;
            logEntity.Module         = Config.GetValue("SoftName");

            try
            {
                #region 验证码验证
                if (autologin == 0)
                {
                    verifycode = Md5Helper.MD5(verifycode.ToLower(), 16);
                    if (Session["session_verifycode"].IsEmpty() || verifycode != Session["session_verifycode"].ToString())
                    {
                        throw new Exception("验证码错误,请重新输入");
                    }
                }
                #endregion

                #region 内部账户验证

                UserEntity userEntity;
                if (Session["WxUserID"].IsEmpty())
                {
                    Logger.Info("普通登录");
                    userEntity = new UserBLL().CheckLogin(username, password);
                }
                else
                {
                    string WxUserID = Session["WxUserID"].ToString();
                    Logger.Info("微信登录" + WxUserID);
                    userEntity = new UserBLL().CheckLogin(WxUserID, username, password);
                }
                if (userEntity != null)
                {
                    AuthorizeBLL   authorizeBLL = new AuthorizeBLL();
                    Operator       operators    = new Operator();
                    LoginUserModel LoginUser    = new LoginUserModel();
                    LoginUser.UserId        = userEntity.UserId;
                    LoginUser.Code          = userEntity.EnCode;
                    LoginUser.Account       = userEntity.Account;
                    LoginUser.UserName      = userEntity.RealName;
                    LoginUser.Password      = userEntity.Password;
                    LoginUser.Secretkey     = userEntity.Secretkey;
                    LoginUser.CompanyId     = userEntity.OrganizeId;
                    LoginUser.DepartmentId  = userEntity.DepartmentId;
                    LoginUser.ManagerId     = userEntity.ManagerId;
                    LoginUser.Manager       = userEntity.Manager;
                    LoginUser.HeadIcon      = userEntity.HeadIcon;
                    LoginUser.IPAddress     = Net.Ip;
                    LoginUser.IPAddressName = IPLocation.GetLocation(Net.Ip);
                    LoginUser.ObjectId      = new PermissionBLL().GetObjectStr(userEntity.UserId);
                    LoginUser.LogTime       = DateTime.Now;
                    LoginUser.Token         = DESEncrypt.Encrypt(Guid.NewGuid().ToString());

                    operators.LoginInfo = LoginUser;

                    //写入当前用户数据权限
                    AuthorizeDataModel dataAuthorize = new AuthorizeDataModel();
                    dataAuthorize.ReadAutorize        = authorizeBLL.GetDataAuthor(operators);
                    dataAuthorize.ReadAutorizeUserId  = authorizeBLL.GetDataAuthorUserId(operators);
                    dataAuthorize.WriteAutorize       = authorizeBLL.GetDataAuthor(operators, true);
                    dataAuthorize.WriteAutorizeUserId = authorizeBLL.GetDataAuthorUserId(operators, true);
                    operators.DataAuthorize           = dataAuthorize;
                    OperatorProvider.AppUserId        = userEntity.UserId;
                    OperatorProvider.Provider.AddCurrent(operators);
                    //登录限制
                    LoginLimit(username, operators.LoginInfo.IPAddress, operators.LoginInfo.IPAddressName);
                    //写入日志
                    logEntity.ExecuteResult     = 1;
                    logEntity.ExecuteResultJson = "登录成功";
                    logEntity.WriteLog();
                }
                return(Success("登录成功。"));

                #endregion
            }
            catch (Exception ex)
            {
                WebHelper.RemoveCookie("learn_autologin");                  //清除自动登录
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = ex.Message;
                logEntity.WriteLog();
                return(Error(ex.Message));
            }
        }
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            string argsString = string.Empty;

            string tempValue = "";

            NameValueCollection npara = HttpContext.Current.Request.Form;

            //NameValueCollection npara = HttpContext.Current.Request.Params;

            foreach (String s in npara.AllKeys)
            {
                if (s.Equals("NewsContent") || s.Equals("EmailContent"))
                {
                    continue;
                }
                if (!s.Contains("HTTP") && !s.Contains("ALL_RAW") && !s.Contains("_") && !s.Contains("LoginUserKey"))
                {
                    if (npara[s] == null)
                    {
                        tempValue = "空值";
                    }
                    else
                    {
                        tempValue = npara[s].ToString();
                    }
                    argsString += s + ":" + tempValue + "|";
                }
            }
            if (argsString.Length > 0)
            {
                argsString = argsString.Substring(0, argsString.Length - 1);
            }

            if (filterContext == null)
            {
                return;
            }
            if (OperatorProvider.Provider.IsOverdue())
            {
                return;
            }
            var        log        = LogFactory.GetLogger(filterContext.Controller.ToString());
            LogMessage logMessage = new LogMessage();

            logMessage.OperationTime = DateTime.Now;
            logMessage.Url           = HttpContext.Current.Request.RawUrl;
            logMessage.Class         = filterContext.Controller.ToString();
            logMessage.Ip            = Net.Ip;
            logMessage.Host          = Net.Host;
            logMessage.Browser       = Net.Browser;
            logMessage.UserName      = OperatorProvider.Provider.Current().Account + "(" + OperatorProvider.Provider.Current().UserName + ")";
            string strMessage = new LogFormat().ExceptionFormat(logMessage);

            LogEntity logEntity = new LogEntity();

            logEntity.CategoryId        = 3;
            logEntity.OperateTypeId     = _actionType.ToString();
            logEntity.OperateType       = EnumAttribute.GetDescription(GetOperationType(_actionType.ToString()));
            logEntity.OperateAccount    = logMessage.UserName;
            logEntity.OperateUserId     = OperatorProvider.Provider.Current().UserId;
            logEntity.ExecuteResult     = 1;
            logEntity.Module            = SystemInfo.CurrentModuleName;
            logEntity.ModuleId          = SystemInfo.CurrentModuleId;
            logEntity.ExecuteResultJson = "操作信息:" + _actionName + ", 请求引用:" + argsString + " , 其他信息:" + strMessage;
            logEntity.WriteLog();
        }
Esempio n. 7
0
        protected virtual ActionResult FailException(Exception ex)
        {
            #region 写入日志
            StackTrace trace     = new StackTrace();
            StackFrame frame     = trace.GetFrame(1);//1代表上级,2代表上上级,以此类推
            MethodBase method    = frame.GetMethod();
            String     className = method.ReflectedType.Name;

            Exception  Error      = ex;
            LogMessage logMessage = new LogMessage();
            logMessage.OperationTime = DateTime.Now;
            logMessage.Url           = className + "/" + method.Name;
            logMessage.Class         = className;
            logMessage.Ip            = Net.Ip;
            logMessage.Host          = Net.Host;
            logMessage.Browser       = Net.Browser;
            logMessage.RequestParam  = GetParamInfo(base.Request.Params);

            if (Error.InnerException == null)
            {
                logMessage.ExceptionInfo = Error.Message;
            }
            else
            {
                logMessage.ExceptionInfo = Error.InnerException.Message;
            }
            logMessage.ExceptionSource = Error.Source;
            logMessage.ExceptionRemark = Error.StackTrace;
            logMessage.UserName        = GetOperateUserName(base.Request.Headers);
            string strMessage = new LogFormat().ExceptionFormat(logMessage);

            LogEntity logEntity = new LogEntity();
            logEntity.F_CategoryId        = 5;
            logEntity.F_OperateTypeId     = ((int)OperationType.Exception).ToString();
            logEntity.F_OperateType       = EnumAttribute.GetDescription(OperationType.Exception);
            logEntity.F_OperateAccount    = "调用接口";
            logEntity.F_OperateUserId     = "api";
            logEntity.F_ExecuteResult     = -1;
            logEntity.F_ExecuteResultJson = strMessage;
            logEntity.F_Description       = logMessage.ExceptionInfo.Length > 50 ? logMessage.ExceptionInfo.Substring(0, 50) : logMessage.ExceptionInfo;
            logEntity.WriteLog();
            #endregion

            if (ex.InnerException.IsEmpty())
            {
                if (ex.Message.Contains("账户余额不足"))
                {
                    return(FailNoPrice(ex.Message));
                }
                else if (ex.Message.Contains("您的账号未实名"))
                {
                    return(FailNoRealName(ex.Message));
                }
                else if (ex.Message.Contains("支付宝账号未绑定"))
                {
                    return(FailNoBindAliPay(ex.Message));
                }
                else
                {
                    return(Fail(ex.Message));
                }
            }
            else
            {
                if (ex.InnerException.Message.Contains("账户余额不足"))
                {
                    return(FailNoPrice(ex.InnerException.Message));
                }
                else if (ex.InnerException.Message.Contains("您的账号未实名"))
                {
                    return(FailNoRealName(ex.InnerException.Message));
                }
                else if (ex.InnerException.Message.Contains("支付宝账号未绑定"))
                {
                    return(FailNoBindAliPay(ex.InnerException.Message));
                }
                else
                {
                    return(Fail(ex.InnerException.Message));
                }
            }
        }
Esempio n. 8
0
        public ActionResult Update(string keyValue, TransferEntity entity)
        {
            Operator curuser = ERCHTMS.Code.OperatorProvider.Provider.Current();

            transferbll.Update(keyValue, entity);
            SyZg(entity, true);
            HikUpdateUserInfo(entity);
            string     uid     = entity.UserId;//获取到需要转岗的用户id
            UserEntity ue      = userBLL.GetEntity(uid);
            string     GdhcUrl = new DataItemDetailBLL().GetItemValue("GdhcUrl");
            string     pcrul   = "http://" + Request.Url.Host + ":" + Request.Url.Port + "/" + Request.ApplicationPath;
            string     LogUrl  = Server.MapPath("~/logs/RYZG");

            try
            {
                DesktopBLL deskBll      = new DesktopBLL();
                string[]   receiverList = userBLL.GetList().Where(t => ((t.RoleName.Contains("负责人") || t.RoleName.Contains("公司领导") || t.RoleName.Contains("厂级部门用户")) && entity.OutDeptCode.StartsWith(t.DepartmentCode)) || (entity.OutDeptCode.StartsWith(t.DepartmentCode) && entity.OutDeptCode != t.DepartmentCode) && t.Account != "System" && !string.IsNullOrWhiteSpace(t.EnCode)).Select(t => t.EnCode).ToArray();
                if (!string.IsNullOrWhiteSpace(GdhcUrl))
                {
                    Task.Factory.StartNew(() =>
                    {
                        GdhcDbsxEntity DbEntity = new GdhcDbsxEntity();
                        DbEntity.syscode        = "GSI";
                        DbEntity.flowid         = entity.TID;
                        DbEntity.requestname    = ue.RealName + "转岗申请";
                        DbEntity.workflowname   = "RYZG";
                        DbEntity.nodename       = "人员转岗审批完成";
                        DbEntity.receiver       = string.Join(",", receiverList);
                        DbEntity.requestlevel   = "0";
                        DbEntity.GdhcUrl        = GdhcUrl;
                        DbEntity.LogUrl         = LogUrl;
                        deskBll.GdhcDbsxSyncYB(DbEntity);
                        DbEntity.receiver = string.Join(",", receiverList);
                        DbEntity.nodename = "人员转岗审批完成";
                        deskBll.GdhcDbsxSyncBJ(DbEntity);
                    });
                }
            }
            catch (Exception ex)
            {
                if (!string.IsNullOrWhiteSpace(LogUrl))
                {
                    if (!System.IO.Directory.Exists(LogUrl))
                    {
                        System.IO.Directory.CreateDirectory(LogUrl);
                    }
                }
                System.IO.File.AppendAllText(LogUrl + "/" + DateTime.Now.ToString("yyyyMMdd") + ".txt", "异常信息:" + ex.ToString());
            }
            DataItemDetailBLL di            = new DataItemDetailBLL();
            string            way           = di.GetItemValue("WhatWay");
            DepartmentBLL     departmentBLL = new DepartmentBLL();
            DepartmentEntity  org           = departmentBLL.GetEntity(ue.OrganizeId);

            if (org.IsTrain == 1)
            {
                //对接.net培训平台
                if (way == "0")
                {
                }
                //对接java培训平台
                if (way == "1")
                {
                    var user = ERCHTMS.Code.OperatorProvider.Provider.Current();
                    DepartmentEntity dept = departmentBLL.GetEntity(entity.OutDeptId);
                    if (dept != null)
                    {
                        string deptId = dept.DepartmentId;
                        string enCode = dept.EnCode;
                        if (!string.IsNullOrWhiteSpace(dept.DeptKey))
                        {
                            string[] arr = dept.DeptKey.Split('|');
                            deptId = arr[0];
                            if (arr.Length > 1)
                            {
                                enCode = arr[1];
                            }
                        }
                        Task.Factory.StartNew(() =>
                        {
                            object obj = new
                            {
                                action     = "edit",
                                time       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                                userId     = ue.UserId,
                                userName   = ue.RealName,
                                account    = ue.Account,
                                deptId     = deptId,
                                deptCode   = enCode,
                                password   = "", //为null时不要修改密码!
                                sex        = ue.Gender,
                                idCard     = ue.IdentifyID,
                                email      = ue.Email,
                                mobile     = ue.Mobile,
                                birth      = ue.Birthday == null ? "" : ue.Birthday.Value.ToString("yyyy-MM-dd"), //生日
                                postId     = entity.OutPostId,
                                postName   = entity.OutPostName,                                                  //岗位
                                age        = ue.Age,                                                              //年龄
                                native     = ue.Native,                                                           //籍贯
                                nation     = ue.Nation,                                                           //民族
                                encode     = ue.EnCode,                                                           //工号
                                jobTitle   = entity.OutJobName,
                                techLevel  = ue.TechnicalGrade,
                                workType   = ue.Craft,
                                companyId  = org.InnerPhone,
                                trainRoles = ue.TrainRoleId,
                                role       = ue.IsTrainAdmin == null ? 0 : ue.IsTrainAdmin //角色(0:学员,1:培训管理员)
                            };
                            List <object> list = new List <object>();
                            list.Add(obj);
                            Busines.JPush.JPushApi.PushMessage(list, 1);

                            LogEntity logEntity      = new LogEntity();
                            logEntity.CategoryId     = 5;
                            logEntity.OperateTypeId  = ((int)OperationType.Update).ToString();
                            logEntity.OperateType    = "人员转岗";
                            logEntity.OperateAccount = user.Account + "(" + user.UserName + ")";
                            logEntity.OperateUserId  = user.UserId;

                            logEntity.ExecuteResult     = 1;
                            logEntity.ExecuteResultJson = string.Format("同步人员(转岗)到java培训平台,同步信息:\r\n{0}", list.ToJson());
                            logEntity.Module            = "人员档案";
                            logEntity.ModuleId          = "ea93dc6b-83fc-4ac2-a1b7-56ef6909445c";
                            logEntity.WriteLog();
                        });
                    }
                }
            }
            return(Success("操作成功。"));
        }
Esempio n. 9
0
        /// <summary>
        /// 推送当前用户到培训平台,建立相关培训及考试任务
        /// </summary>
        /// <param name="userAccount">学员账号</param>
        /// <param name="projectid">培训项目id</param>
        /// <param name="startdate">培训开始时间</param>
        /// <param name="enddate">培训结束时间</param>
        /// <param name="stationname">受训角色名称</param>
        public dynamic PushUserToTrainee(List <FwzTrainUserInfo> ulist)
        {
            Operator curUser = OperatorProvider.Provider.Current();

            try
            {
                string fileName = "推送违章对接培训平台接口" + DateTime.Now.ToString("yyyyMMdd") + ".log";
                //服务请求地址
                var trainserviceurl   = dataitemdetailbll.GetItemValue("TrainServiceUrl");   //.net 版本
                var wztrainserviceurl = dataitemdetailbll.GetItemValue("WzTrainServiceUrl"); //java版本
                var whatway           = dataitemdetailbll.GetItemValue("WhatWay");
                //.net版本
                if (!string.IsNullOrEmpty(trainserviceurl) && whatway == "0")
                {
                    WebClient wc = new WebClient();
                    wc.Credentials = CredentialCache.DefaultCredentials;
                    //发送请求到web api并获取返回值,默认为post方式
                    System.Collections.Specialized.NameValueCollection nc = new System.Collections.Specialized.NameValueCollection();
                    string queryJson = Newtonsoft.Json.JsonConvert.SerializeObject(new
                    {
                        Business             = "SaveFwzTrainUserInfo",
                        FwzTrainUserInfoList = ulist
                    });
                    nc.Add("json", queryJson);
                    System.IO.File.AppendAllText(HttpContext.Current.Server.MapPath("~/logs/" + fileName), "推送违章对接培训平台接口:" + queryJson + ",地址:" + wztrainserviceurl + ",请求入口:Net" + "\r\n");
                    wc.UploadValuesCompleted += wc_UploadValuesCompleted;
                    byte[] arr = wc.UploadValues(new Uri(trainserviceurl), nc);
                    return(JsonConvert.DeserializeObject <ExpandoObject>(System.Text.Encoding.UTF8.GetString(arr)));
                }
                //java 版本
                else if (!string.IsNullOrEmpty(wztrainserviceurl) && whatway == "1")
                {
                    WebClient wc = new WebClient();
                    wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
                    wc.Credentials = CredentialCache.DefaultCredentials;
                    //发送请求到web api并获取返回值,默认为post方式
                    System.Collections.Specialized.NameValueCollection nc = new System.Collections.Specialized.NameValueCollection();
                    List <object> resultlist = new List <object>();
                    foreach (FwzTrainUserInfo entity in ulist)
                    {
                        resultlist.Add(new {
                            trainProjectId = entity.TrainProjectid,
                            userAccount    = entity.Useraccount,
                            trainStartTime = entity.TrainStartTime,
                            trainEndTime   = entity.TrainEndTime
                        });
                    }
                    string jsonData = Newtonsoft.Json.JsonConvert.SerializeObject(new
                    {
                        Business             = "SaveFwzTrainUserInfo",
                        FwzTrainUserInfoList = resultlist
                    });
                    System.IO.File.AppendAllText(HttpContext.Current.Server.MapPath("~/logs/" + fileName), "推送违章对接培训平台接口:" + jsonData.ToJson() + ",地址:" + wztrainserviceurl + ",请求入口:java" + ";\r\n");
                    byte[] bsdata = Encoding.UTF8.GetBytes(jsonData);
                    wc.UploadValuesCompleted += wc_UploadValuesCompleted;
                    byte[] arr = wc.UploadData(new Uri(wztrainserviceurl), "POST", bsdata);
                    System.IO.File.AppendAllText(HttpContext.Current.Server.MapPath("~/logs/" + fileName), "推送违章对接培训平台接口:返回的结果:" + System.Text.Encoding.UTF8.GetString(arr) + ";\r\n");
                    return(new
                    {
                        Code = 0,
                        Info = "推送成功!"
                    });
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                LogEntity logEntity = new LogEntity();
                logEntity.CategoryId        = 4;
                logEntity.OperateTypeId     = ((int)OperationType.Exception).ToString();
                logEntity.OperateType       = EnumAttribute.GetDescription(OperationType.Exception);
                logEntity.OperateAccount    = curUser.UserName;
                logEntity.OperateUserId     = curUser.UserId;
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = ex.ToJson();
                logEntity.Module            = SystemInfo.CurrentModuleName;
                logEntity.ModuleId          = SystemInfo.CurrentModuleId;
                logEntity.WriteLog();
                string fileName = "推送当前用户到培训平台,建立相关培训及考试任务_" + DateTime.Now.ToString("yyyyMMdd") + ".log";
                System.IO.File.AppendAllText(HttpContext.Current.Server.MapPath("~/logs/" + fileName), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "推送当前用户到培训平台,建立相关培训及考试任务:" + ex.ToJson() + "\r\n");

                return(null);
            }
        }
Esempio n. 10
0
        public void AddLllegalScore(LllegalRegisterEntity entity)
        {
            //当前用户
            Operator curUser = OperatorProvider.Provider.Current();

            #region 违章评分对象
            try
            {
                string           fileName         = "推送违章对接培训平台接口" + DateTime.Now.ToString("yyyyMMdd") + ".log";
                LllegalPunishBLL lllegalpunishbll = new LllegalPunishBLL();
                #region 添加用户积分
                string lllegaluserids  = string.Empty;
                string lllegaldeptcode = string.Empty;
                //考核人
                var relevanceList = lllegalpunishbll.GetListByLllegalId(entity.ID, "");
                foreach (LllegalPunishEntity lpEntity in relevanceList)
                {
                    if (lpEntity.ASSESSOBJECT.Contains("人员") && !string.IsNullOrEmpty(lpEntity.PERSONINCHARGEID))
                    {
                        //违章责任人
                        lllegalpunishbll.SaveUserScore(lpEntity.PERSONINCHARGEID, entity.LLLEGALLEVEL);
                        lllegaluserids += lpEntity.PERSONINCHARGEID + ",";
                    }
                    else if (lpEntity.ASSESSOBJECT.Contains("单位"))
                    {
                        lllegaldeptcode += lpEntity.PERSONINCHARGEID + ","; //记录单位编码
                    }
                }
                #endregion
                //考核用户id
                if (!string.IsNullOrEmpty(lllegaluserids))
                {
                    lllegaluserids = lllegaluserids.Substring(0, lllegaluserids.Length - 1);
                }
                //考核部门
                if (!string.IsNullOrEmpty(lllegaldeptcode))
                {
                    lllegaldeptcode = lllegaldeptcode.Substring(0, lllegaldeptcode.Length - 1);
                }

                #region 消息提醒考核的人员、考核的单位
                //消息通知的用户
                string pushaccount   = string.Empty;
                string pushusernames = string.Empty;
                string pushcode      = "WZ012"; //违章考核消息通知
                //考核人员
                if (!string.IsNullOrEmpty(lllegaluserids))
                {
                    DataTable dt = userbll.GetUserByDeptCodeAndRoleName(lllegaluserids, null, null);
                    if (dt.Rows.Count == 1)
                    {
                        pushaccount   += dt.Rows[0]["account"].ToString() + ",";  //账户
                        pushusernames += dt.Rows[0]["realname"].ToString() + ","; //姓名
                    }
                }
                //考核单位(获取单位负责人)
                if (!string.IsNullOrEmpty(lllegaldeptcode))
                {
                    DataTable dt = userbll.GetUserByDeptCodeAndRoleName(null, lllegaldeptcode, "负责人");
                    if (dt.Rows.Count == 1)
                    {
                        pushaccount   += dt.Rows[0]["account"].ToString() + ",";  //账户
                        pushusernames += dt.Rows[0]["realname"].ToString() + ","; //姓名
                    }
                }
                if (!string.IsNullOrEmpty(pushaccount))
                {
                    pushaccount   = pushaccount.Substring(0, pushaccount.Length - 1);
                    pushusernames = pushusernames.Substring(0, pushusernames.Length - 1);
                    //极光消息推送
                    JPushApi.PushMessage(pushaccount, pushusernames, pushcode, entity.ID);
                }
                #endregion


                #region 违章评分对象
                List <FwzTrainUserInfo> fwzlist = new List <FwzTrainUserInfo>();
                var lllegalPoint = dataitemdetailbll.GetDataItemListByItemCode("'LllegalTrainPointSetting'");

                if (lllegalPoint.Count() > 0)
                {
                    var    LllegalTrainingPointValue    = lllegalPoint.Where(p => p.ItemName == "LllegalTrainingPointValue").FirstOrDefault();    //违章培训积分值
                    var    LllegalTrainingPointStandard = lllegalPoint.Where(p => p.ItemName == "LllegalTrainingPointStandard").FirstOrDefault(); //违章培训积分标准
                    string basePoint     = string.Empty;                                                                                          //基础分数值
                    string pointStandard = string.Empty;                                                                                          //评分标准
                    string lllegaltypetraineeprojectid = string.Empty;                                                                            //违章类型培训项目
                    string safetyruletraineeprojectid  = string.Empty;                                                                            //安规培训项目
                    if (null != LllegalTrainingPointValue)
                    {
                        basePoint = LllegalTrainingPointValue.ItemValue;
                    }
                    if (null != LllegalTrainingPointStandard)
                    {
                        pointStandard = LllegalTrainingPointStandard.ItemValue;
                    }
                    ////违章类型培训项目
                    string wzKey = "LllegalTypeTraineeProjectId_" + curUser.OrganizeCode;
                    if (lllegalPoint.Where(p => p.ItemName == wzKey).Count() > 0)
                    {
                        var LllegalTypeTraineeProjectId = lllegalPoint.Where(p => p.ItemName == wzKey).FirstOrDefault();
                        if (null != LllegalTypeTraineeProjectId)
                        {
                            if (LllegalTypeTraineeProjectId.EnabledMark == 1)
                            {
                                lllegaltypetraineeprojectid = LllegalTypeTraineeProjectId.ItemValue;
                            }
                        }
                    }
                    //安规培训项目
                    string agKey = "SafetyRuleTraineeProjectId_" + curUser.OrganizeCode;
                    var    SafetyRuleTraineeProjectId = lllegalPoint.Where(p => p.ItemName == agKey).FirstOrDefault();
                    if (null != SafetyRuleTraineeProjectId)
                    {
                        if (SafetyRuleTraineeProjectId.EnabledMark == 1)
                        {
                            safetyruletraineeprojectid = SafetyRuleTraineeProjectId.ItemValue;
                        }
                    }
                    //评分标准
                    #region 评分标准
                    if (!string.IsNullOrEmpty(pointStandard))
                    {
                        DataTable resultDt = new DataTable();
                        resultDt.Columns.Add("username");
                        resultDt.Columns.Add("account");
                        resultDt.Columns.Add("score");
                        resultDt.Columns.Add("lllegalpoint");

                        string[] standardarr = pointStandard.Split(',');

                        //0分人员
                        foreach (string standard in standardarr)
                        {
                            DataTable upointdt = new DataTable();

                            upointdt = GetLllegalPointData(basePoint, DateTime.Now.Year.ToString(), lllegaluserids, standard);

                            foreach (DataRow row in upointdt.Rows)
                            {
                                decimal score        = !string.IsNullOrEmpty(row["score"].ToString()) ? Convert.ToDecimal(row["score"].ToString()) : 0;               //剩余分数
                                decimal lllegalpoint = !string.IsNullOrEmpty(row["lllegalpoint"].ToString()) ? Convert.ToDecimal(row["lllegalpoint"].ToString()) : 0; //扣除分数
                                DataRow rrow         = resultDt.NewRow();
                                rrow["username"]     = row["realname"].ToString();                                                                                    //人员姓名
                                rrow["account"]      = row["account"].ToString();                                                                                     //人员账号
                                rrow["score"]        = score.ToString();                                                                                              //剩余分数
                                rrow["lllegalpoint"] = lllegalpoint.ToString();                                                                                       //扣除分数
                                resultDt.Rows.Add(rrow);

                                FwzTrainUserInfo fwzuser = new FwzTrainUserInfo();
                                fwzuser.Useraccount    = row["account"].ToString();
                                fwzuser.TrainStartTime = null != entity.LLLEGALTIME ? entity.LLLEGALTIME.Value.ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                                fwzuser.TrainEndTime   = null != entity.LLLEGALTIME ? entity.LLLEGALTIME.Value.AddMonths(1).ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.AddMonths(1).ToString("yyyy-MM-dd HH:mm:ss");
                                //安规培训
                                if (standard.Trim() == "score=0")
                                {
                                    fwzuser.StationName    = "所有人员";
                                    fwzuser.TrainProjectid = safetyruletraineeprojectid; //安规
                                }
                                else
                                {
                                    fwzuser.StationName = dataitemdetailbll.GetEntity(entity.LLLEGALTYPE).ItemName;
                                    if (!string.IsNullOrEmpty(lllegaltypetraineeprojectid))
                                    {
                                        fwzuser.TrainProjectid = lllegaltypetraineeprojectid;
                                    }
                                    else
                                    {
                                        var lllegalPointObj = lllegalPoint.Where(P => P.ItemName == fwzuser.StationName);
                                        if (lllegalPointObj.Count() > 0)
                                        {
                                            fwzuser.TrainProjectid = lllegalPointObj.FirstOrDefault().ItemValue;
                                        }
                                    }
                                }
                                fwzlist.Add(fwzuser);
                            }
                        }

                        if (fwzlist.Count() > 0)
                        {
                            dynamic lllegaldy = PushUserToTrainee(fwzlist);

                            if (null != lllegaldy)
                            {
                                //返回成功状态下
                                if (lllegaldy.Code.ToString() == "0")
                                {
                                    string curcode = "WZ013";
                                    string content = string.Empty;
                                    foreach (DataRow rrow in resultDt.Rows)
                                    {
                                        string score        = rrow["score"].ToString();        //剩余分数
                                        string lllegalpoint = rrow["lllegalpoint"].ToString(); //扣除分数
                                        string curaccount   = rrow["account"].ToString();      //账户
                                        string curname      = rrow["username"].ToString();     //姓名
                                        content = "您于" + DateTime.Now.ToString("yyyy-MM-dd") + "因违章被考核了" + lllegalpoint + "分,现反违章积分为" + score + "分,需进行反违章培训,请前去参加培训.";
                                        JPushApi.PushMessage(curaccount, curname, curcode, "违章考核信息", content, entity.ID);
                                    }
                                }
                                string    resultInfo = JsonConvert.SerializeObject(lllegaldy);
                                LogEntity logEntity  = new LogEntity();
                                logEntity.Browser           = System.Web.HttpContext.Current.Request.Browser.Browser;
                                logEntity.CategoryId        = 5;
                                logEntity.OperateTypeId     = ((int)OperationType.Submit).ToString();
                                logEntity.OperateType       = EnumAttribute.GetDescription(OperationType.Submit);
                                logEntity.OperateAccount    = curUser.UserName;
                                logEntity.OperateUserId     = curUser.UserId;
                                logEntity.ExecuteResult     = 1;
                                logEntity.Module            = SystemInfo.CurrentModuleName;
                                logEntity.ModuleId          = SystemInfo.CurrentModuleId;
                                logEntity.ExecuteResultJson = resultInfo;
                                LogBLL.WriteLog(logEntity);
                            }
                        }
                    }
                    #endregion
                }

                #endregion
            }
            catch (Exception ex)
            {
                LogEntity logEntity = new LogEntity();
                logEntity.CategoryId        = 4;
                logEntity.OperateTypeId     = ((int)OperationType.Exception).ToString();
                logEntity.OperateType       = EnumAttribute.GetDescription(OperationType.Exception);
                logEntity.OperateAccount    = curUser.UserName;
                logEntity.OperateUserId     = curUser.UserId;
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = ex.Message;
                logEntity.Module            = SystemInfo.CurrentModuleName;
                logEntity.ModuleId          = SystemInfo.CurrentModuleId;
                logEntity.ExecuteResultJson = ex.ToJson();
                logEntity.WriteLog();

                string fileName = "推送当前用户到培训平台,建立相关培训及考试任务_" + DateTime.Now.ToString("yyyyMMdd") + ".log";
                System.IO.File.AppendAllText(HttpContext.Current.Server.MapPath("~/logs/" + fileName), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "推送当前用户到培训平台,建立相关培训及考试任务:" + ex.ToJson() + "\r\n");
            }
            #endregion
        }