コード例 #1
0
ファイル: LoginController.cs プロジェクト: MrBigGreen/CRM
        public ActionResult OutLogin()
        {
            LogEntity logEntity = new LogEntity();

            logEntity.CategoryId        = 1;
            logEntity.OperateTypeId     = ((int)OperationType.Exit).ToString();
            logEntity.OperateType       = EnumAttribute.GetDescription(OperationType.Exit);
            logEntity.OperateAccount    = OperatorProvider.Provider.Current().LoginInfo.Account;
            logEntity.OperateUserId     = OperatorProvider.Provider.Current().LoginInfo.UserId;
            logEntity.ExecuteResult     = 1;
            logEntity.ExecuteResultJson = "退出系统";
            logEntity.Module            = Config.GetValue("SoftName");
            logEntity.WriteLog();
            Session.Abandon();                                          //清除当前会话
            Session.Clear();                                            //清除当前浏览器所有Session
            WebHelper.RemoveCookie("learn_autologin");                  //清除自动登录
            return(Content(new AjaxResult {
                type = ResultType.success, message = "退出系统"
            }.ToJson()));
        }
コード例 #2
0
 public ActionResult GetPropertyJson()
 {
     try
     {
         Busines.TenementManage.PropertyBLL bll = new Busines.TenementManage.PropertyBLL();
         string property_id = "";
         if (OperatorProvider.Provider.Current().IsSystem)
         {
             property_id = "System";
         }
         else
         {
             property_id = OperatorProvider.Provider.Current().UserProperty;
         }
         var data = bll.GetListBySel(property_id);
         if (data.Count() > 0)
         {
             foreach (Entity.TenementManage.PropertyEntity item in data)
             {
                 Util.Utils.WriteCookie("property_id", item.property_id);
                 Util.Utils.WriteCookie("property_name", item.property_name);
                 break;
             }
         }
         return(Content(data.ToJson()));
     }
     catch (Exception ex)
     {
         LogEntity logEntity = new LogEntity();
         logEntity.CategoryId        = 1;
         logEntity.OperateTypeId     = ((int)OperationType.Login).ToString();
         logEntity.OperateType       = EnumAttribute.GetDescription(OperationType.Login);
         logEntity.OperateAccount    = OperatorProvider.Provider.Current().Account + "(" + OperatorProvider.Provider.Current().UserName + ")";
         logEntity.OperateUserId     = OperatorProvider.Provider.Current().UserId;
         logEntity.Module            = Config.GetValue("SoftName");
         logEntity.ExecuteResult     = -1;
         logEntity.ExecuteResultJson = ex.Message;
         logEntity.WriteLog();
         return(Content(""));
     }
 }
コード例 #3
0
        /// <summary>
        /// 写入日志(log4net)
        /// </summary>
        /// <param name="context"></param>
        private void WriteLog(ExceptionContext context)
        {
            if (context == null)
            {
                return;
            }
            if (OperatorProvider.Provider.IsOverdue())
            {
                return;
            }
            var log        = LogFactory.GetLogger(context.Controller.ToString());
            var error      = context.Exception;
            var logMessage = new LogMessage
            {
                OperationTime = DateTime.Now,
                Url           = HttpContext.Current.Request.RawUrl,
                Class         = context.Controller.ToString(),
                Ip            = Net.Ip,
                Host          = Net.Host,
                Browser       = Net.Browser,
                UserName      = OperatorProvider.Provider.Current().Account + "(" +
                                OperatorProvider.Provider.Current().UserName + ")",
                ExceptionInfo = error.InnerException == null ? error.Message : error.InnerException.Message
            };
            var strMessage = new LogFormat().ExceptionFormat(logMessage);

            log.Error(strMessage);
            var logEntity = new LogEntity
            {
                CategoryId        = 4,
                OperateTypeId     = ((int)OperationType.Exception).ToString(),
                OperateType       = EnumAttribute.GetDescription(OperationType.Exception),
                OperateAccount    = logMessage.UserName,
                OperateUserId     = OperatorProvider.Provider.Current().UserId,
                ExecuteResult     = -1,
                ExecuteResultJson = strMessage
            };

            logEntity.WriteLog();
        }
コード例 #4
0
        /// <summary>
        /// 添加访问接口记录
        /// </summary>
        /// <param name="content">记录内容</param>
        public void WriteInfoLog(string content)
        {
            //var userInfo = LoginUserInfo.Get();
            var log        = LogFactory.GetLogger("webapi");
            var logMessage = new LogMessage {
                OperationTime = DateTime.Now
            };

            if (FilterContext.HttpContext.Request.Url != null)
            {
                logMessage.Url = FilterContext.HttpContext.Request.Url.PathAndQuery;
            }
            logMessage.Class   = FilterContext.Controller.ToString();
            logMessage.Ip      = Net.Ip;
            logMessage.Host    = Net.Host;
            logMessage.Browser = Net.Browser;
            //if (userInfo != null)
            //{
            //    logMessage.UserName = userInfo.number + "(" + userInfo.cus_name + ")";
            //}
            logMessage.Content = content;
            string strMessage = new LogFormat().InfoFormat(logMessage);

            log.Info(strMessage);

            var logEntity = new LogEntity
            {
                F_CategoryId        = 2,
                F_OperateTypeId     = ((int)OperationType.Visit).ToString(),
                F_OperateType       = EnumAttribute.GetDescription(OperationType.Visit),
                F_OperateAccount    = logMessage.UserName,
                F_OperateUserId     = "",
                F_ExecuteResult     = 1,
                F_ExecuteResultJson = strMessage
            };

            logEntity.WriteLog();
        }
コード例 #5
0
ファイル: RecordLog.cs プロジェクト: rockygoodluck/framework
        /// <summary>
        /// Action执行前触发
        /// </summary>
        /// <param name="context"></param>
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            if (context.Result is ViewResult)
            {
            }
            else
            {
                var        userInfo   = LoginUserInfo.Get();
                var        log        = LogFactory.GetLogger(context.Controller.ToString());
                LogMessage logMessage = new LogMessage();
                logMessage.OperationTime = DateTime.Now;
                logMessage.Url           = context.HttpContext.Request.Path;
                logMessage.Class         = context.Controller.ToString();
                logMessage.Ip            = Net.Ip;
                logMessage.Host          = Net.Host;
                logMessage.Browser       = Net.Browser;
                if (userInfo != null)
                {
                    logMessage.UserName = userInfo.account + "(" + userInfo.realName + ")";
                }
                string strMessage = new LogFormat().InfoFormat(logMessage);
                log.Info(strMessage);

                LogEntity logEntity = new LogEntity();
                logEntity.F_CategoryId     = 3;
                logEntity.F_OperateTypeId  = ((int)OperationType.Submit).ToString();
                logEntity.F_OperateType    = EnumAttribute.GetDescription(OperationType.Submit);
                logEntity.F_OperateAccount = logMessage.UserName;
                if (userInfo != null)
                {
                    logEntity.F_OperateUserId = userInfo.userId;
                }
                logEntity.F_ExecuteResult     = 1;
                logEntity.F_ExecuteResultJson = strMessage;
                logEntity.WriteLog();
            }
        }
コード例 #6
0
ファイル: LoginController.cs プロジェクト: Mouseww/JYT
        public HttpResponseMessage CheckLogin(string system, string account, string password)
        {
            LogEntity logEntity = new LogEntity();

            logEntity.F_CategoryId     = 1;
            logEntity.F_OperateTypeId  = ((int)OperationType.Login).ToString();
            logEntity.F_OperateType    = EnumAttribute.GetDescription(OperationType.Login);
            logEntity.F_OperateAccount = account;
            logEntity.F_OperateUserId  = account;
            logEntity.F_Module         = system;

            try
            {
                //验证账户
                UserEntity userEntity = new UserBLL().CheckLogin(account, password);

                //生成票据
                var ticket = Guid.NewGuid().ToString();
                //写入票据
                CacheFactory.Cache().WriteCache(userEntity, ticket, DateTime.Now.AddHours(8));

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

                return(Success("登录成功", ticket));
            }
            catch (Exception ex)
            {
                logEntity.F_ExecuteResult     = -1;
                logEntity.F_ExecuteResultJson = ex.Message;
                logEntity.WriteLog();
                return(Error(ex.Message));
            }
        }
コード例 #7
0
        public ActionResult Login(FormCollection form)
        {
            AjaxMsgModel ajaxM = new AjaxMsgModel()
            {
                Statu = "error", Msg = "登录失败!"
            };
            Base_Log logEntity = new Base_Log();

            //1.1 获取数据
            string strName  = Request.Params["UserName"];
            string strPwd   = Request.Params["Password"];
            string vcode    = Request.Params["VCode"];
            bool   isAllway = bool.Parse(Request.Params["isAllway"]);

            logEntity.CategoryId     = 1;
            logEntity.OperateTypeId  = ((int)OperationType.Login).ToString();
            logEntity.OperateType    = EnumAttribute.GetDescription(OperationType.Login);
            logEntity.OperateAccount = strName;
            logEntity.OperateUserId  = strName;
            logEntity.Module         = "我的MVC";
            ////1.2 验证
            //if (vcode!=Session["vcode"].ToString().ToLower())
            //{
            //    ajaxM.Msg = "登录失败,验证码不正确!";
            //    return Json(ajaxM);
            //}
            // 1.3 通过操作上下文获取 用户业务接口对象 ,调用里面的登录方法!
            User usr = _userBLL.Login(strName, strPwd);

            if (usr != null)
            {
                //2.1 保存 用户数据(session or cookie)
                Session["ainfo"] = usr;

                //如果选择了复选框 则要使用cookie 保存数据
                if (isAllway)
                {
                    //2.1.2 将用户id加密成字符串
                    string strCookieValue = SecurityHelper.EncryptUserInfo(usr.ID.ToString());
                    //2.1.3 创建cookie
                    HttpCookie cookie = new HttpCookie("cookieId", strCookieValue);
                    cookie.Expires = DateTime.Now.AddDays(1);
                    cookie.Path    = "/admin";
                    Response.Cookies.Add(cookie);
                    //记录登录cookie
                }
                //2.2 查询当前用户的权限 , 并将权限存入Session 中
                //List<tbMenu> listPers = OperateContext.GetUserPermission(usr.ID);
                //Session["tbMenu"] = listPers;
                ajaxM.Statu                 = "ok";
                ajaxM.Msg                   = "登录成功!";
                ajaxM.BackUrl               = "/Home/Index";//"/Login/LoginOK";
                logEntity.ExecuteResult     = 1;
                logEntity.ExecuteResultJson = "登录成功";
                logEntity.WriteLog();
                return(Json(ajaxM));
            }
            else
            {
                ajaxM.Msg = "登录失败,用户或密码不正确!";
                return(Json(ajaxM));
            }
        }
コード例 #8
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);
            }
        }
コード例 #9
0
ファイル: DepartmentService.cs プロジェクト: durrydu/MyTEST
        /// <summary>
        /// 描述:部门更新
        /// 作者:姚栋
        /// 日期:2018.06.05
        /// </summary>
        public void SyncUpdateDep()
        {
            LogEntity logEntity = new LogEntity();

            logEntity.CategoryId     = 3;
            logEntity.OperateTypeId  = ((int)OperationType.SyncData).ToString();
            logEntity.OperateType    = EnumAttribute.GetDescription(OperationType.SyncData);
            logEntity.OperateAccount = "WinDbSyncSerivce";
            logEntity.OperateUserId  = "WinDbSyncSerivce";
            logEntity.Module         = "WinDbSyncSerivce";
            StringBuilder sqlInsert = new StringBuilder();

            sqlInsert.Append(@"update BaoLi_Dep set 
                                BaoLi_Dep.DepartmentId   =Sync_Dep.OrgID, --组织GUID
                                BaoLi_Dep.EnCode=Sync_Dep. OrgCode, --组织编码
                                BaoLi_Dep.FullName=Sync_Dep.OrgName, --组织名称
                                BaoLi_Dep.ParentId=Sync_Dep.OrgParentID, --上级组织GUID
                                BaoLi_Dep.ParentEnCode=Sync_Dep.OrgParentCode, --上级组织编码
                                BaoLi_Dep.ParentName=Sync_Dep.OrgParentName,--上级组织名称
                                BaoLi_Dep.Layer=Sync_Dep.OrgLevel,--组织层级
                                BaoLi_Dep.OrgClass=Sync_Dep.OrgClass, --组织类型
                                BaoLi_Dep.DeleteMark  =case when DataStatus=0 then 1 when DataStatus=1 then 0 else 0 end,  
                                BaoLi_Dep.SyncTime=getdate(),
                                BaoLi_Dep.SourceID  =Sync_Dep.OrgID,
                                BaoLi_Dep.ManagerId =Sync_Dep. PrincipalID--组织负责人ID            
                                from OPENQUERY(Link_MDM_MiddleBase,'select * from MDM_MiddleBase.dbo.T_OrgUnit') as Sync_Dep
                                inner join Base_Department  BaoLi_Dep
                                on  BaoLi_Dep.DepartmentId=Sync_Dep.OrgID
                                 and(
                                BaoLi_Dep.EnCode!=Sync_Dep. OrgCode or --组织编码
                                BaoLi_Dep.FullName!=Sync_Dep.OrgName or --组织名称
                                BaoLi_Dep.ParentId!=Sync_Dep.OrgParentID or --上级组织GUID
                                BaoLi_Dep.ParentEnCode!=Sync_Dep.OrgParentCode or--上级组织编码
                                BaoLi_Dep.ParentName!=Sync_Dep.OrgParentName or--上级组织名称
                                BaoLi_Dep.Layer!=Sync_Dep.OrgLevel or--组织层级
                                BaoLi_Dep.OrgClass!=Sync_Dep.OrgClass  or --组织类型
                                BaoLi_Dep.DeleteMark!=(case when DataStatus=0 then 1 when DataStatus=1 then 0 else 0 end) or 
                                BaoLi_Dep.SourceID !=Sync_Dep.OrgID or
                                BaoLi_Dep.ManagerId!=Sync_Dep.PrincipalID);--组织负责人ID ");
            try
            {
                var result = this.BaseRepository().ExecuteBySql(sqlInsert.ToString());
                if (result >= 0)
                {
                    //写入日志
                    logEntity.ExecuteResult     = 1;
                    logEntity.ExecuteResultJson = "同步程序SyncUpdateDep执行成功:" + result.ToString() + "条";
                }
                else
                {
                    //写入日志
                    logEntity.ExecuteResult     = -1;
                    logEntity.ExecuteResultJson = "同步程序SyncUpdateDep执行失败";
                }
            }
            catch (Exception ex)
            {
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = "SyncUpdateDep从主数据同步更新部门时出错:" + ex.Message;
                throw new Exception("SyncUpdateDep从主数据同步更新部门时出错:" + ex.Message);
            }
            finally
            {
                logServer.WriteLog(logEntity);
            }
        }
コード例 #10
0
ファイル: DepartmentService.cs プロジェクト: durrydu/MyTEST
        /// <summary>
        /// 描述:部门新增
        /// 作者:姚栋
        /// 日期:2018.06.05
        /// </summary>
        public void SyncNewDep()
        {
            LogEntity logEntity = new LogEntity();

            logEntity.CategoryId     = 3;
            logEntity.OperateTypeId  = ((int)OperationType.SyncData).ToString();
            logEntity.OperateType    = EnumAttribute.GetDescription(OperationType.SyncData);
            logEntity.OperateAccount = "WinDbSyncSerivce";
            logEntity.OperateUserId  = "WinDbSyncSerivce";
            logEntity.Module         = "WinDbSyncSerivce";
            StringBuilder sqlInsert = new StringBuilder();

            sqlInsert.Append(@"insert into Base_Department(
                                DepartmentId--组织GUID
                                ,EnCode --组织编码
                                ,FullName --组织名称
                                 ,ParentId --上级组织GUID
                                 ,ParentEnCode --上级组织编码
                                 ,ParentName--上级组织名称
                                 ,Layer --组织层级
                                 ,OrgClass--组织类型
                                 ,DeleteMark                           
                                 ,CreateDate --创建时间
                                ,SyncTime
                                 ,SourceSys
                                 ,SourceID
                                 ,ManagerId --组织负责人ID
                                 ,OrganizeId                        
                                )select 
                                OrgID, --组织GUID
                                OrgCode, --组织编码
                                OrgName, --组织名称
                                 OrgParentID, --上级组织GUID
                                 OrgParentCode, --上级组织编码
                                 OrgParentName,--上级组织名称
                                 OrgLevel,--组织层级
                                 OrgClass, --组织类型
                              case when DataStatus=0 then 1 when DataStatus=1 then 0 else 0 end, 
                                CreateTime, --创建时间
                                getdate(),
                                 '同步主数据',
                                 OrgID,
                                 PrincipalID,--组织负责人ID
                                 '207fa1a9-160c-4943-a89b-8fa4db0547ce'--写死的公司ID
                                from OPENQUERY(Link_MDM_MiddleBase,'select * from MDM_MiddleBase.dbo.T_OrgUnit') as SyncOrgTable
                                where not exists(select 1 from Base_Department where Base_Department.DepartmentId=SyncOrgTable.OrgID); ");
            try
            {
                var result = this.BaseRepository().ExecuteBySql(sqlInsert.ToString());
                if (result >= 0)
                {
                    //写入日志
                    logEntity.ExecuteResult     = 1;
                    logEntity.ExecuteResultJson = "同步程序SyncNewDep执行成功:" + result.ToString() + "条";
                }
                else
                {
                    //写入日志
                    logEntity.ExecuteResult     = -1;
                    logEntity.ExecuteResultJson = "同步程序SyncNewDep执行失败";
                }
            }
            catch (Exception ex)
            {
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = "SyncNewDep从主数据同步新增部门时出错:" + ex.Message;
                throw new Exception("SyncNewDep从主数据同步新增部门时出错:" + ex.Message);
            }
            finally
            {
                logServer.WriteLog(logEntity);
            }
        }
コード例 #11
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
        }
コード例 #12
0
        public object GetMenuList([FromBody] JObject json)
        {
            try
            {
                string  res            = json.Value <string>("json");
                dynamic dy             = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userId         = dy.userid;         //用户名
                long    themeTypeParam = dy.data.themetype; //0 第一套工作栏  1 第二套
                long    platformParam  = dy.data.platform;  //2 手机APP 1 安卓终端
                int     themeType      = int.Parse(themeTypeParam.ToString());
                int     platform       = int.Parse(platformParam.ToString());
                //获取用户基本信息
                OperatorProvider.AppUserId = userId;  //设置当前用户
                Operator user = OperatorProvider.Provider.Current();
                if (user == null || user.RoleId == null)
                {
                    //logMessage.ExceptionSource = Error.Source;
                    //logMessage.ExceptionRemark = Error.StackTrace;

                    LogEntity logEntity = new LogEntity();
                    logEntity.CategoryId    = 4;
                    logEntity.OperateTypeId = ((int)OperationType.Exception).ToString();
                    logEntity.OperateType   = EnumAttribute.GetDescription(OperationType.Exception);
                    if (null != OperatorProvider.Provider.Current())
                    {
                        logEntity.OperateUserId = OperatorProvider.Provider.Current().UserId;
                    }
                    logEntity.ExecuteResult     = -1;
                    logEntity.ExecuteResultJson = "用户或用户的角色为空";
                    logEntity.Module            = "菜单配置";
                    logEntity.ModuleId          = SystemInfo.CurrentModuleId;
                    logEntity.WriteLog();
                    return(new { Code = -1, Info = "获取数据失败", Message = "用户或用户的角色为空" });
                }
                List <string> roleId = user.RoleId.Replace(" ", "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                if (user.IsTrainAdmin == 1)
                {
                    roleId.Add("15006a63-94d8-479f-8478-575e567671bc");
                }
                else
                {
                    roleId.Add("f405d85b-4f92-4e0d-8030-2f4e7a280f41");
                }
                DepartmentBLL departmentBLL = new DepartmentBLL();
                //先判断当前用户的部门是不是在厂级及以上
                var depart =
                    departmentBLL.GetList()
                    .Where(x => x.Nature.Contains("集团") || x.Nature.Contains("省级") || x.Nature.Contains("厂级"));
                bool   ishave = depart.Any(entity => entity.DepartmentId == user.DeptId);
                string deptId = user.DeptId;
                if (!ishave)
                {
                    deptId = user.OrganizeId;
                }
                //1、先取出所有的栏目
                AppMenuSettingBLL           settingBLL             = new AppMenuSettingBLL();
                List <AppMenuSettingEntity> appMenuSettingEntities = settingBLL.GetList(deptId, themeType, platform);
                //2、取当前用户所有的授权的菜单
                MenuConfigBLL           menuConfigBLL = new MenuConfigBLL();
                List <MenuConfigEntity> menusAll      = menuConfigBLL.GetList("", platform, null).Distinct().ToList();
                List <MenuConfigEntity> menus         = new List <MenuConfigEntity>();
                roleId.ForEach(role =>
                {
                    menus.AddRange(menusAll.Where(p => !string.IsNullOrWhiteSpace(p.AuthorizeId) && p.AuthorizeId.Contains(role)));
                });
                menus = menus.Distinct().ToList();
                DeptMenuAuthBLL deptMenuAuthBll = new DeptMenuAuthBLL();
                var             deptauthList    = deptMenuAuthBll.GetList(deptId).Select(x => x.ModuleId);
                menus = menus.Where(x => deptauthList.Contains(x.ModuleId)).ToList();
                //3、根据栏目与菜单的关系配置取菜单
                AppSettingAssociationBLL           settingAssociationBLL      = new AppSettingAssociationBLL();
                List <AppSettingAssociationEntity> settingAssociationEntities = settingAssociationBLL.GetList(deptId, menus.Select(p => p.ModuleId).ToList());
                //4、组装数据
                List <MenuSettingData> menuSettingDatas = new List <MenuSettingData>();
                foreach (var item in appMenuSettingEntities)
                {
                    MenuSettingData menuSettingData = new MenuSettingData()
                    {
                        Id     = item.Id,
                        Name   = item.Name,
                        Remark = item.Remark,
                        Sort   = item.Sort,
                        Icon   = string.IsNullOrWhiteSpace(item.Icon) ? null : new DataItemDetailBLL().GetItemValue("imgUrl") + item.Icon,
                    };
                    var menusIds = settingAssociationEntities.Where(p => p.ColumnId == item.Id).Select(x => x.ModuleId).ToList();
                    if (menusIds != null && menusIds.Count > 0)
                    {
                        var appMenu = menus.Where(x => menusIds.Contains(x.ModuleId)).ToList();
                        menuSettingData.AddChild(appMenu, settingAssociationEntities.Where(p => p.ColumnId == item.Id).ToList());
                    }
                    menuSettingDatas.Add(menuSettingData);
                }
                var data = menuSettingDatas.OrderBy(x => x.Sort).ToList();
                return(new { Code = 0, data.Count, Info = "获取数据成功", data });
            }
            catch (Exception ex)
            {
                LogMessage logMessage = new LogMessage();
                logMessage.OperationTime = DateTime.Now;
                logMessage.Url           = HttpContext.Current.Request.RawUrl;
                logMessage.Class         = "MenuConfig";
                logMessage.Ip            = Net.Ip;
                logMessage.Host          = Net.Host;
                logMessage.Browser       = Net.Browser;
                if (null != OperatorProvider.Provider.Current())
                {
                    logMessage.UserName = OperatorProvider.Provider.Current().Account + "(" + OperatorProvider.Provider.Current().UserName + ")";
                }

                logMessage.ExceptionInfo = Newtonsoft.Json.JsonConvert.SerializeObject(ex);
                //logMessage.ExceptionSource = Error.Source;
                //logMessage.ExceptionRemark = Error.StackTrace;
                string strMessage = new LogFormat().ExceptionFormat(logMessage);

                LogEntity logEntity = new LogEntity();
                logEntity.CategoryId     = 4;
                logEntity.OperateTypeId  = ((int)OperationType.Exception).ToString();
                logEntity.OperateType    = EnumAttribute.GetDescription(OperationType.Exception);
                logEntity.OperateAccount = logMessage.UserName;
                if (null != OperatorProvider.Provider.Current())
                {
                    logEntity.OperateUserId = OperatorProvider.Provider.Current().UserId;
                }
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = strMessage;
                logEntity.Module            = "菜单配置";
                logEntity.ModuleId          = SystemInfo.CurrentModuleId;
                logEntity.WriteLog();
                return(new { Code = -1, Info = "获取数据失败", ex.Message });
            }
        }
コード例 #13
0
        public JsonResult ImportExcel(HttpPostedFileBase file)
        {
            int count  = 0;
            var result = new ReturnMessage(false)
            {
                Message = "上传失败!"
            };

            try
            {
                var data = ExcelHelper.ExcelImport(file.InputStream, 2);//第2行为头部
                if (data != null)
                {
                    if (data.Columns.Count != 7)
                    {
                        result.Message = "请按照模板格式正确填写内容!";
                        return(Json(result));
                    }
                    int successcount = 0, errorcount = 0;
                    foreach (System.Data.DataRow row in data.Rows)
                    {
                        try
                        {
                            if (row[0].ToString() != "")
                            {
                                int hascount = OwnerBLL.Instance.GetList(new OwnerEntity()
                                {
                                    CarNumber = row[0].ToString()
                                }).Count();
                                if (hascount > 0)
                                {
                                    continue;
                                }
                                OwnerEntity entity = new OwnerEntity();
                                entity.OwnerId      = Util.Util.NewUpperGuid();
                                entity.CreateTime   = DateTime.Now;
                                entity.CarNumber    = row[0].ToString();
                                entity.MemberMobile = row[1].ToString();
                                //entity.CarNumber = row[2].ToString();
                                //entity.CarFrameNum = row[3].ToString();
                                if (row[2].ToString() != "")
                                {
                                    int[] values = (int[])System.Enum.GetValues(typeof(QX360.Model.Enums.UseType));
                                    for (int i = 0; i < values.Length; i++)
                                    {
                                        var discript = EnumAttribute.GetDescription((QX360.Model.Enums.UseType)values[i]);
                                        if (discript == row[2].ToString())
                                        {
                                            entity.UseType     = values[i];
                                            entity.UseTypeName = row[2].ToString();
                                            break;
                                        }
                                    }
                                }
                                if (row[3].ToString() != "")
                                {
                                    int[] values = (int[])System.Enum.GetValues(typeof(QX360.Model.Enums.CarType));
                                    for (int i = 0; i < values.Length; i++)
                                    {
                                        var discript = EnumAttribute.GetDescription((QX360.Model.Enums.CarType)values[i]);
                                        if (discript == row[3].ToString())
                                        {
                                            entity.CarType     = values[i];
                                            entity.CarTypeName = row[3].ToString();
                                            break;
                                        }
                                    }
                                }
                                string registerTime = "";
                                if (row[4].ToString() != "")
                                {
                                    registerTime = row[4].ToString();
                                }
                                if (row[5].ToString() != "")
                                {
                                    registerTime = registerTime + "-" + row[5].ToString();
                                }
                                if (registerTime != "")
                                {
                                    entity.RegisterTime = Convert.ToDateTime(registerTime);
                                }
                                if (row[6].ToString() != "")
                                {
                                    entity.PeopleCount = int.Parse(row[6].ToString());
                                }
                                OwnerBLL.Instance.Add(entity);
                                successcount++;
                            }
                        }
                        catch (Exception)
                        {
                            errorcount++;
                        }
                    }

                    result.IsSuccess = true;
                    result.Message   = string.Format("导入成功({0}条),失败({1}条))!", successcount, errorcount);
                }
            }
            catch (Exception ex)
            {
                ex.Data["Method"] = "OwnerController>>Import";
                new ExceptionHelper().LogException(ex);
            }
            return(Json(result));
        }
コード例 #14
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());
            }
        }
コード例 #15
0
        public ActionResult CheckLogin(string username, string password, string verifycode, int autologin)
        {
            LogEntity logEntity = new LogEntity();

            logEntity.CategoryId     = (int)QSDMS.Model.Enums.LogCategoryEnum.登陆;
            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 第三方账户验证
                //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 = UserBLL.Instance.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          = PermissionBLL.Instance.GetObjectStr(userEntity.UserId);
                    operators.LogTime           = DateTime.Now;
                    operators.Token             = DESEncrypt.Encrypt(Guid.NewGuid().ToString());
                    operators.Theme             = userEntity.Theme == null ? "default" : userEntity.Theme;
                    operators.HeadIcon          = userEntity.HeadIcon == null ? "/Content/default/img/avatar.png" : userEntity.HeadIcon;
                    operators.UserDataAuthorize = UserAuthorizeBLL.Instance.GetUserAuthorizeListStr(userEntity.UserId);
                    //写入当前用户数据权限
                    //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);
                    //登录限制
                    //LoginLimit(username, operators.IPAddress, operators.IPAddressName);
                    //写入日志
                    logEntity.ExecuteResult     = 1;
                    logEntity.ExecuteResultJson = "登录成功";
                    LogBLL.Instance.WriteLog(logEntity);
                    //logEntity.WriteLog();
                }

                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic["theme"] = OperatorProvider.Provider.Current().Theme;
                return(Success("登录成功", dic));

                #endregion
            }
            catch (Exception ex)
            {
                WebHelper.RemoveCookie("dms_autologin");                  //清除自动登录
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = ex.Message;
                LogBLL.Instance.WriteLog(logEntity);
                //Logger.Error(ex);
                return(Error(ex.Message));
            }
        }
コード例 #16
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         = "Hengtex.敏捷开发框架";
            try
            {
                Operator      operators = new Operator();
                loginUserInfo result    = new loginUserInfo();
                #region 第三方账户验证 关闭第三方账号验证
                //AccountEntity accountEntity = accountBLL.CheckLogin(recdata.data.username, recdata.data.password);
                //if (accountEntity != null)
                //{
                //    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;
                //    //登录限制
                //    LoginLimit(recdata.data.username, operators.IPAddress, operators.IPAddressName, recdata.platform);
                //    result.userid = operators.UserId;
                //    result.account = operators.Account;
                //    result.password = operators.Password;
                //    result.realname = operators.UserName;
                //    result.headicon = "";
                //    result.gender = "";
                //    result.mobile = operators.Account;
                //}
                #endregion
                #region 内部登录
                //写入当前用户信息
                AppUserEntity userEntity = new AppUserBLL().CheckLogin(recdata.data.username, recdata.data.password);
                if (userEntity != null)
                {
                    AppAuthorizeBLL authorizeBLL = new AppAuthorizeBLL();
                    operators.UserId       = userEntity.isid.ToString();
                    operators.Code         = userEntity.StationNum;
                    operators.Account      = userEntity.Account;
                    operators.UserName     = userEntity.UserName;
                    operators.Password     = userEntity.Password;
                    operators.Secretkey    = userEntity.Password;
                    operators.CompanyId    = ""; // userEntity.OrganizeId;
                    operators.DepartmentId = ""; //userEntity.DepartmentId;
                    operators.IPAddress    = Net.Ip;
                    operators.ObjectId     = new AppPermissionBLL().GetObjectStr(userEntity.isid.ToString());
                    operators.LogTime      = DateTime.Now;
                    operators.Token        = DESEncrypt.Encrypt(Guid.NewGuid().ToString());
                    if (userEntity.Account == "System")
                    {
                        operators.IsSystem = true;
                    }
                    else
                    {
                        operators.IsSystem = false;
                    }
                    //写入当前用户数据权限
                    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.isid.ToString();
                    result.account  = userEntity.Account;
                    result.password = userEntity.Password;
                    result.realname = userEntity.UserName;
                    result.headicon = "";
                    //result.gender = (userEntity.Gender == 1 ? "男" : "女");
                    result.mobile         = userEntity.Tel;
                    result.telephone      = userEntity.Tel;
                    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;//值不能为null
                    //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.UserId);

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

                return(this.SendData <loginUserInfo>(result, result.userid, operators.Token, ResponseType.Success));
            }
            catch (Exception ex)
            {
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = ex.Message;
                logEntity.WriteLog();
                return(this.SendData(ResponseType.Fail, ex.Message));
            }
        }
コード例 #17
0
        /// <summary>
        /// 描述:项目新增
        /// 作者:姚栋
        /// 日期:2018.06.04
        /// </summary>
        public void SyncNewProject()
        {
            LogEntity logEntity = new LogEntity();

            logEntity.CategoryId     = 3;
            logEntity.OperateTypeId  = ((int)OperationType.SyncData).ToString();
            logEntity.OperateType    = EnumAttribute.GetDescription(OperationType.SyncData);
            logEntity.OperateAccount = "WinDbSyncSerivce";
            logEntity.OperateUserId  = "WinDbSyncSerivce";
            logEntity.Module         = "WinDbSyncSerivce";
            StringBuilder sqlInsert = new StringBuilder();

            sqlInsert.Append(@"insert into Base_ProjectInfo(
                            ProjectID, 
                            ProjectCode,
                            ProjecName, 
                            ProjectGeneralizeName, 
                            ProjectOfficialName, 
                            CompanyId, 
                            CompanyCode, 
                            CompanyName, 
                            CityID, 
                            CityCode, 
                            CityName, 
                            [Address], 
                            PrincipleMan, 
                            DataStatus,
                            SourceSys,
                            SourceID,
                            SyncTime,
                            F1,
                            F2,
                            F3
                            )select 
                            ProjectID, 
                            ProjectCode,
                            ProjectShortName,
                            ProjectGeneralizeName,
                            ProjectOfficialName, 
                            CompanyId,
                            CompanyCode,
                            CompanyName,
                            CityID, 
                            CityCode,
                            CityName, 
                            [Address], 
                            PrincipleMan,
                            case when [Status]=-1 then 1 when [Status]=1 then 0 else 0 end, 
                            '主数据同步',
                            ProjectID,
                            getdate(),
                            F1, 
                            F2,
                            F3
                            from OPENQUERY(Link_yg_mds_middle,'select * from yg_mds_middle.dbo.MDS_BPM_Project ') as SyncProjectTable
                            where not exists(select 1 from Base_ProjectInfo where Base_ProjectInfo.ProjectID=SyncProjectTable.ProjectID); ");
            try
            {
                var result = this.BaseRepository().ExecuteBySql(sqlInsert.ToString());
                if (result >= 0)
                {
                    //写入日志
                    logEntity.ExecuteResult     = 1;
                    logEntity.ExecuteResultJson = "同步程序SyncNewProject执行成功:" + result.ToString() + "条";
                }
                else
                {
                    //写入日志
                    logEntity.ExecuteResult     = -1;
                    logEntity.ExecuteResultJson = "同步程序SyncNewProject执行失败";
                }
            }
            catch (Exception ex)
            {
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = "SyncNewProject从主数据同步新增项目时出错:" + ex.Message;
                throw new Exception("SyncNewProject从主数据同步新增项目时出错:" + ex.Message);
            }
            finally
            {
                logServer.WriteLog(logEntity);
            }
        }
コード例 #18
0
        /// <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();
            }
        }
コード例 #19
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));
                }
            }
        }
コード例 #20
0
        /// <summary>
        /// 描述:项目更新
        /// 作者:姚栋
        /// 日期:2018.06.04
        /// </summary>
        public void SyncUpdateProject()
        {
            LogEntity logEntity = new LogEntity();

            logEntity.CategoryId     = 3;
            logEntity.OperateTypeId  = ((int)OperationType.SyncData).ToString();
            logEntity.OperateType    = EnumAttribute.GetDescription(OperationType.SyncData);
            logEntity.OperateAccount = "WinDbSyncSerivce";
            logEntity.OperateUserId  = "WinDbSyncSerivce";
            logEntity.Module         = "WinDbSyncSerivce";

            StringBuilder sqlInsert = new StringBuilder();

            sqlInsert.Append(@"update BaoLi_ProjectInfo set 
                                BaoLi_ProjectInfo.ProjectID=SyncProjectTable.ProjectID, 
                                BaoLi_ProjectInfo.ProjectCode=SyncProjectTable.ProjectCode,
                                BaoLi_ProjectInfo.ProjecName=SyncProjectTable.ProjectShortName,
                                BaoLi_ProjectInfo.ProjectGeneralizeName=SyncProjectTable.ProjectGeneralizeName,
                                BaoLi_ProjectInfo.ProjectOfficialName=SyncProjectTable.ProjectOfficialName,  
                                BaoLi_ProjectInfo.CompanyId=SyncProjectTable.CompanyId,
                                BaoLi_ProjectInfo.CompanyCode=SyncProjectTable.CompanyCode,
                                BaoLi_ProjectInfo.CompanyName=SyncProjectTable.CompanyName,
                                BaoLi_ProjectInfo.CityID=SyncProjectTable.CityID,
                                BaoLi_ProjectInfo.CityCode=SyncProjectTable.CityCode,
                                BaoLi_ProjectInfo.CityName=SyncProjectTable.CityName, 
                                BaoLi_ProjectInfo.[Address]=SyncProjectTable.[Address],  
                                BaoLi_ProjectInfo.PrincipleMan=SyncProjectTable.PrincipleMan,
                                BaoLi_ProjectInfo.DataStatus=(case when SyncProjectTable.[Status]=-1 then 1 when SyncProjectTable.[Status]=1 then 0 else 0 end), 
                                BaoLi_ProjectInfo.SourceSys='主数据同步',
                                BaoLi_ProjectInfo.SourceID=SyncProjectTable.ProjectID,
                                BaoLi_ProjectInfo.SyncTime=getdate()
                                from OPENQUERY(Link_yg_mds_middle,'select * from yg_mds_middle.dbo.MDS_BPM_Project')  SyncProjectTable 
                                inner join Base_ProjectInfo  BaoLi_ProjectInfo
                                on   BaoLi_ProjectInfo.ProjectID=SyncProjectTable.ProjectID
                                and( BaoLi_ProjectInfo.ProjectCode!=SyncProjectTable.ProjectCode or
                                BaoLi_ProjectInfo.ProjecName!=SyncProjectTable.ProjectShortName or
                                BaoLi_ProjectInfo.ProjectGeneralizeName!=SyncProjectTable.ProjectGeneralizeName or
                                BaoLi_ProjectInfo.ProjectOfficialName!=SyncProjectTable.ProjectOfficialName or  
                                BaoLi_ProjectInfo.CompanyId!=SyncProjectTable.CompanyId or
                                BaoLi_ProjectInfo.CompanyCode!=SyncProjectTable.CompanyCode or
                                BaoLi_ProjectInfo.CompanyName!=SyncProjectTable.CompanyName or
                                BaoLi_ProjectInfo.CityID!=SyncProjectTable.CityID or
                                BaoLi_ProjectInfo.CityCode!=SyncProjectTable.CityCode or
                                BaoLi_ProjectInfo.CityName!=SyncProjectTable.CityName or 
                                BaoLi_ProjectInfo.[Address]!=SyncProjectTable.[Address] or  
                                BaoLi_ProjectInfo.PrincipleMan!=SyncProjectTable.PrincipleMan or
                                BaoLi_ProjectInfo.DataStatus!=(case when SyncProjectTable.[Status]=-1 then 1 when SyncProjectTable.[Status]=1 then 0 else 0 end))");
            try
            {
                var result = this.BaseRepository().ExecuteBySql(sqlInsert.ToString());
                if (result >= 0)
                {
                    //写入日志
                    logEntity.ExecuteResult     = 1;
                    logEntity.ExecuteResultJson = "同步程序SyncUpdateProject执行成功:" + result.ToString() + "条";
                }
                else
                {
                    //写入日志
                    logEntity.ExecuteResult     = -1;
                    logEntity.ExecuteResultJson = "同步程序SyncUpdateProject执行失败";
                }
            }
            catch (Exception ex)
            {
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = "SyncUpdateProject从主数据同步更新项目时出错:" + ex.Message;
                throw new Exception("SyncUpdateProject从主数据同步更新项目时出错:" + ex.Message);
            }
            finally
            {
                logServer.WriteLog(logEntity);
            }
        }
コード例 #21
0
        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.Contains("NewsContent"))
                {
                    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();
        }
コード例 #22
0
ファイル: UserService.cs プロジェクト: durrydu/MyTEST
        /// <summary>
        /// 描述:用户新增
        /// 作者:姚栋
        /// 日期:2018.06.04
        /// </summary>
        public void SyncNewUser()
        {
            LogEntity logEntity = new LogEntity();

            logEntity.CategoryId     = 3;
            logEntity.OperateTypeId  = ((int)OperationType.SyncData).ToString();
            logEntity.OperateType    = EnumAttribute.GetDescription(OperationType.SyncData);
            logEntity.OperateAccount = "WinDbSyncSerivce";
            logEntity.OperateUserId  = "WinDbSyncSerivce";
            logEntity.Module         = "WinDbSyncSerivce";

            StringBuilder sqlInsert = new StringBuilder();

            sqlInsert.Append(@"insert into Base_User(
                            UserId,--用户GUID
                            EnCode,--用户编号
                            Account,--用户登录名
                            EmployeeNum,--员工工号
                            RealName,
                            NickName,--用户显示名称
                            FirstName,--姓
                            LastName,--名
                            UserType,--员工类型
                            Email,--邮箱
                            Mobile,--手机号码
                            Telephone,--办公电话
                            Birthday,--出生日期
                            CredentialNum,--身份证号码
                            HZNum,--护照号码
                            CreateDate,--创建时间
                            CreateUserId,--创建用户
                            ModifyUserName,--修改时间
                            ModifyUserId,--修改用户
                            SyncTime,--同步时间
                            SourceSys,--同步来源
                            SourceID,--同步来源数据主键
                            DeleteMark,       
                            EnabledMark,
                            F1,--备用字段1
                            F2,--备用字段2
                            F3--备用字段3
                            )select 
                            UserID ,--用户GUID
                            CodeName,--用户编号
                            LoginName,--用户登录名
                            EmployeeNum,--员工工号
                            FullName,--用户显示名称
                            FullName,--用户显示名称
                            FirstName,--姓
                            LastName,--名
                            UserType,--员工类型
                            Email,--邮箱
                            MobilePhone,--手机号码
                            BusinessTelephone,--办公电话
                            BirthDay,--出生日期
                            CredentialNum,--身份证号码
                            HZNum,--护照号码
                            CreateTime,--创建时间
                            CreateUser,--创建用户
                            UpdateTime,--修改时间
                            UpdateUser,--修改用户
                            getdate(),--同步时间
                            '主数据同步程序',--同步来源
                            UserId,--同步来源数据主键
                            case when DataStatus=0 then 1 when DataStatus=1 then 0 else 0 end,  
                            1,
                            F1,--备用字段1
                            F2,--备用字段2
                            F3--备用字段3
                            from OPENQUERY(Link_MDM_MiddleBase,'select * from MDM_MiddleBase.dbo.T_User') as SyncUserTable
	                        where not exists(select 1 from Base_User where Base_User.SourceID=SyncUserTable.UserId);
	                         "    );
            try
            {
                var result = this.BaseRepository().ExecuteBySql(sqlInsert.ToString());
                if (result >= 0)
                {
                    //写入日志
                    logEntity.ExecuteResult     = 1;
                    logEntity.ExecuteResultJson = "同步程序SyncNewUser执行成功:" + result.ToString() + "条";
                }
                else
                {
                    //写入日志
                    logEntity.ExecuteResult     = -1;
                    logEntity.ExecuteResultJson = "同步程序SyncNewUser执行失败";
                }
            }
            catch (Exception ex)
            {
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = "SyncNewUser从主数据同步新增用户时出错:" + ex.Message;
                throw new Exception("SyncNewUser从主数据同步新增用户时出错:" + ex.Message);
            }
            finally
            {
                logServer.WriteLog(logEntity);
            }
        }
コード例 #23
0
        public ActionResult CheckLogin(string username, string password, string verifycode, int autologin)
        {
            var logEntity = new LogEntity
            {
                CategoryId     = 1,
                OperateTypeId  = ((int)OperationType.Login).ToString(),
                OperateType    = EnumAttribute.GetDescription(OperationType.Login),
                OperateAccount = username,
                OperateUserId  = username,
                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 内部账户验证
                var userEntity = new UserBll().CheckLogin(username, password);
                if (userEntity != null)
                {
                    var operators = new Operator
                    {
                        UserId        = userEntity.UserId,
                        Code          = userEntity.EnCode,
                        Account       = userEntity.Account,
                        UserName      = userEntity.RealName,
                        Password      = userEntity.Password,
                        Secretkey     = userEntity.Secretkey,
                        CompanyId     = userEntity.OrganizeId,
                        DepartmentId  = userEntity.DepartmentId,
                        IpAddress     = Net.Ip,
                        IpAddressName = IpLocation.GetLocation(Net.Ip),
                        ObjectId      = new PermissionBll().GetObjectStr(userEntity.UserId),
                        LogTime       = DateTime.Now,
                        Token         = DESEncrypt.Encrypt(Guid.NewGuid().ToString())
                    };
                    var authorizeBll  = new AuthorizeBll();
                    var dataAuthorize = new AuthorizeDataModel
                    {
                        ReadAutorize        = authorizeBll.GetDataAuthor(operators),
                        ReadAutorizeUserId  = authorizeBll.GetDataAuthorUserId(operators),
                        WriteAutorize       = authorizeBll.GetDataAuthor(operators, true),
                        WriteAutorizeUserId = authorizeBll.GetDataAuthorUserId(operators, true)
                    };
                    operators.DataAuthorize = dataAuthorize;
                    operators.IsSystem      = userEntity.Account == "System";
                    OperatorProvider.Provider.AddCurrent(operators);
                    //写入日志
                    logEntity.ExecuteResult     = -1;
                    logEntity.ExecuteResultJson = "登陆成功";
                    logEntity.WriteLog();
                }

                #endregion

                #region 第三方账户验证

                #endregion

                return(Success("登陆成功。"));
            }
            catch (Exception ex)
            {
                WebHelper.RemoveCookie("tony_autologin");
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = ex.Message;
                logEntity.WriteLog();
                return(Error(ex.Message));
            }
        }
コード例 #24
0
ファイル: UserService.cs プロジェクト: durrydu/MyTEST
        /// <summary>
        /// 描述:用户更新
        /// 作者:姚栋
        /// 日期:2018.06.04
        /// </summary>
        public void SyncUpdateUser()
        {
            LogEntity logEntity = new LogEntity();

            logEntity.CategoryId     = 3;
            logEntity.OperateTypeId  = ((int)OperationType.SyncData).ToString();
            logEntity.OperateType    = EnumAttribute.GetDescription(OperationType.SyncData);
            logEntity.OperateAccount = "WinDbSyncSerivce";
            logEntity.OperateUserId  = "WinDbSyncSerivce";
            logEntity.Module         = "WinDbSyncSerivce";
            StringBuilder sqlInsert = new StringBuilder();

            sqlInsert.Append(@"
                        update BaoLi_User set 
                        BaoLi_User.UserId=Sync_User.UserID,--用户GUID
                        BaoLi_User.DeleteMark  =case when DataStatus=0 then 1 when DataStatus=1 then 0 else 0 end, 
                        BaoLi_User.EnCode=Sync_User.CodeName,--用户编号
                        BaoLi_User.Account=Sync_User.LoginName,--用户登录名
                        BaoLi_User.EmployeeNum=Sync_User.EmployeeNum,--员工工号
                        BaoLi_User.RealName=Sync_User.FullName,--用户显示名称
                        BaoLi_User.NickName=Sync_User.FullName,--用户显示名称
                        BaoLi_User.FirstName=Sync_User.FirstName,--姓
                        BaoLi_User.LastName=Sync_User.LastName,--名
                        BaoLi_User.UserType=Sync_User.UserType,--员工类型
                        BaoLi_User.Email=Sync_User.Email,--邮箱
                        BaoLi_User.Mobile=Sync_User.MobilePhone,--手机号码
                        BaoLi_User.Telephone=Sync_User.BusinessTelephone,--办公电话
                        BaoLi_User.Birthday=Sync_User.BirthDay,--出生日期
                        BaoLi_User.CredentialNum=Sync_User.CredentialNum,--身份证号码
                        BaoLi_User.HZNum=Sync_User.HZNum,--护照号码                          
                        BaoLi_User.ModifyUserName=getdate(),--修改时间
                        BaoLi_User.SyncTime=getdate(),--同步时间
                        BaoLi_User.SourceSys='主数据同步程序',--同步来源
                        BaoLi_User.SourceID=Sync_User.UserId,--同步来源数据主键
                        BaoLi_User.F1=Sync_User.F1,--备用字段1
                        BaoLi_User.F2=Sync_User.F2,--备用字段2
                        BaoLi_User.F3=Sync_User.F3--备用字段3
                        from OPENQUERY(Link_MDM_MiddleBase,'select * from MDM_MiddleBase.dbo.T_User')  Sync_User 
                        inner join Base_User  BaoLi_User
                        on   BaoLi_User.UserId=Sync_User.UserID
                        and( BaoLi_User.EnCode!=Sync_User.CodeName--用户编号
                        or  BaoLi_User.Account!=Sync_User.LoginName--用户登录名
                        or  BaoLi_User.EmployeeNum!=Sync_User.EmployeeNum--员工工号
                        or  BaoLi_User.RealName!=Sync_User.FullName--用户显示名称
                        or  BaoLi_User.NickName!=Sync_User.FullName--用户显示名称
                        or  BaoLi_User.FirstName!=Sync_User.FirstName--姓
                        or  BaoLi_User.LastName!=Sync_User.LastName--名
                        or BaoLi_User.UserType!=Sync_User.UserType--员工类型
                        or BaoLi_User.Email!=Sync_User.Email--邮箱
                        or BaoLi_User.Mobile!=Sync_User.MobilePhone--手机号码
                        or BaoLi_User.Telephone!=Sync_User.BusinessTelephone--办公电话
                        or BaoLi_User.Birthday!=Sync_User.BirthDay--出生日期
                        or BaoLi_User.CredentialNum!=Sync_User.CredentialNum--身份证号码
                        or BaoLi_User.HZNum!=Sync_User.HZNum--护照号码  
                        or BaoLi_User.DeleteMark!=(case when DataStatus=0 then 1 when DataStatus=1 then 0 else 0 end)                         
                        or BaoLi_User.F1!=Sync_User.F1--备用字段1
                        or BaoLi_User.F2!=Sync_User.F2--备用字段2
                        or BaoLi_User.F3!=Sync_User.F3);--备用字段3");
            try
            {
                var result = this.BaseRepository().ExecuteBySql(sqlInsert.ToString());
                if (result >= 0)
                {
                    //写入日志
                    logEntity.ExecuteResult     = 1;
                    logEntity.ExecuteResultJson = "同步程序SyncUpdateUser执行成功:" + result.ToString() + "条";
                }
                else
                {
                    //写入日志
                    logEntity.ExecuteResult     = -1;
                    logEntity.ExecuteResultJson = "同步程序SyncUpdateUser执行失败";
                }
            }
            catch (Exception ex)
            {
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = "SyncUpdateUser从主数据同步更新用户时出错:" + ex.Message;
                throw new Exception("SyncUpdateUser从主数据同步更新用户时出错:" + ex.Message);
            }
            finally
            {
                logServer.WriteLog(logEntity);
            }
        }
コード例 #25
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 第三方账户验证
                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());
                    //写入当前用户数据权限
                    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);
                    //登录限制
                    LoginLimit(username, operators.IPAddress, operators.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));
            }
        }
コード例 #26
0
        public AjaxResult CheckLogin(string loginName, string pwd, bool rememberMe)
        {
            LogMessage logEntity = new LogMessage
            {
                CategoryId     = 1,
                OperateType    = EnumAttribute.GetDescription(DbLogType.Login),
                OperateAccount = loginName,
                Module         = Configs.GetValue("SoftName")
            };
            AjaxResult ajaxResult;

            try
            {
                var userEntity = this.Queryable().FirstOrDefault(t => (t.LoginName == loginName || t.Email == loginName) && t.DeleteMark == false);

                if (userEntity != null)
                {
                    if (userEntity.UserSecretkey.IsNullOrEmpty())
                    {
                        throw new Exception("用户密钥丢失,请联系管理员!");
                    }
                    //登录成功
                    string dbPassword = Md5Helper.Md5(DesEncrypt.Encrypt(pwd.ToLower(), userEntity.UserSecretkey).ToLower(), 32).ToLower();
                    //登录成功
                    if (dbPassword == userEntity.LoginPassword)
                    {
                        string backUrl = "";
                        //根据登录实体,去缓存用户数据
                        this.SaveUserSession(userEntity);

                        backUrl = OperatorProvider.Provider.CurrentUser.IsSystem == true
                            ? "/Home/Index"
                            : "/App/Index";

                        //记住密码
                        if (rememberMe == true)
                        {
                        }

                        ajaxResult = AjaxResult.Success("登录成功!", backUrl);

                        DateTime now = DateTime.Now;
                        userEntity.LoginCount    += 1;
                        userEntity.LastLoginTime  = now;
                        userEntity.LastLogIp      = Net.Ip;
                        userEntity.LastModifyTime = now;

                        logEntity.ExecuteResult     = 1;
                        logEntity.ExecuteResultJson = "登录成功";

                        this.Update(userEntity, "LoginCount", "LastLoginTime", "LastLogIp", "LastModifyTime");
                    }
                    else
                    {
                        throw new Exception("密码不正确,请重新输入");
                    }
                }
                else
                {
                    throw new Exception("账户不存在,请重新输入");
                }
            }
            catch (Exception ex)
            {
                ajaxResult = AjaxResult.Error(ex.Message);

                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = ex.Message;// new logformat().exceptionformat(logentity);
                //logEntity.ExceptionInfo = ex.Message ;

                _logService.LogError(logEntity, "登录日志");
            }

            return(ajaxResult);
        }
コード例 #27
0
        public ActionResult CheckLogin(string username, string password)
        {
            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 账户验证
                RegisterUserEntity userEntity = new RegisterUserBLL().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.HeadIcon      = userEntity.HeadIcon;
                    operators.Post          = userEntity.Post;
                    operators.Position      = userEntity.Position;
                    operators.PositionName  = dataItemCache.GetDataItemList("PositionCategory").Where(t => t.ItemValue == userEntity.Position).FirstOrDefault().ItemName;;
                    operators.WorkUnit      = userEntity.WorkUnit;
                    //operators.ObjectId = new PermissionBLL().GetObjectStr(userEntity.UserId);
                    operators.LogTime = DateTime.Now;
                    operators.Token   = DESEncrypt.Encrypt(Guid.NewGuid().ToString());
                    //判断是否系统管理员
                    if (userEntity.Account == "System")
                    {
                        operators.IsSystem = true;
                    }
                    else
                    {
                        operators.IsSystem = false;
                    }
                    OperatorProvider.Provider.AddCurrent(operators);
                    //登录限制
                    //LoginLimit(username, operators.IPAddress, operators.IPAddressName);
                    //写入日志
                    logEntity.ExecuteResult     = 1;
                    logEntity.ExecuteResultJson = "登录成功";
                    logEntity.WriteLog();
                }
                return(Content(new AjaxResult {
                    type = ResultType.success, message = "登录成功"
                }.ToJson()));

                #endregion
            }
            catch (Exception ex)
            {
                WebHelper.RemoveCookie("sys_autologin");                  //清除自动登录
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = ex.Message;
                logEntity.WriteLog();
                return(Content(new AjaxResult {
                    type = ResultType.error, message = ex.Message
                }.ToJson()));
            }
        }
コード例 #28
0
        public Object checkLogin([FromBody] JObject json)
        {
            string    res       = json.Value <string>("json");
            dynamic   dy        = JsonConvert.DeserializeObject <ExpandoObject>(res);
            string    username  = dy.data.useraccount;
            string    password  = dy.data.password;
            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         = "APP";

            try
            {
                #region 内部账户验证
                UserBLL        userBLL    = new UserBLL();
                UserInfoEntity userEntity = userBLL.CheckLogin(username, password);
                if (userEntity != null)
                {
                    if (userEntity.AllowStartTime != null && userEntity.AllowEndTime != null)
                    {
                        if (DateTime.Now > userEntity.AllowEndTime)
                        {
                            return(new { code = -1, count = 0, info = "您的账号使用期限已过期,请联系管理员或客服,谢谢" });
                        }
                    }
                    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.DeptId       = userEntity.DepartmentId;
                    operators.ParentId     = userEntity.ParentId;
                    operators.DeptCode     = userEntity.DepartmentCode;
                    operators.OrganizeCode = userEntity.OrganizeCode;
                    operators.DeptName     = userEntity.DeptName;
                    operators.IsTrain      = userEntity.IsTrain;
                    operators.SignImg      = userEntity.SignImg;
                    DepartmentEntity dept = userBLL.GetUserOrgInfo(userEntity.UserId); //获取当前用户所属的机构
                    operators.OrganizeId    = dept.DepartmentId;                       //所属机构ID
                    operators.OrganizeCode  = dept.EnCode;                             //所属机构编码
                    operators.NewDeptCode   = dept.DeptCode;                           //所属机构新的编码(对应部门表中新加的编码字段deptcode)
                    operators.OrganizeName  = dept.FullName;                           //所属机构名称
                    operators.SpecialtyType = userEntity.SpecialtyType;

                    ////公司级用户
                    if (new UserBLL().HaveRoleListByKey(userEntity.UserId, dataitemdetailbll.GetItemValue("HidOrganize")).Rows.Count > 0)
                    {
                        operators.DeptId   = userEntity.OrganizeId;
                        operators.DeptCode = userEntity.OrganizeCode;
                        operators.DeptName = userEntity.OrganizeName;
                    }
                    operators.PostName   = userBLL.GetObjectName(userEntity.UserId, 3);
                    operators.RoleName   = userBLL.GetObjectName(userEntity.UserId, 2);
                    operators.RoleId     = userEntity.RoleId;
                    operators.PostId     = userEntity.PostId;
                    operators.DutyName   = userBLL.GetObjectName(userEntity.UserId, 4);
                    operators.IPAddress  = Net.Ip;
                    operators.Photo      = dataitemdetailbll.GetItemValue("imgUrl") + userEntity.HeadIcon; //头像
                    operators.IdentifyID = userEntity.IdentifyID;                                          //身份证号码
                    //operators.SendDeptID = userEntity.SendDeptID;
                    //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;
                    }

                    string userMode = "";

                    string roleCode = dataitemdetailbll.GetItemValue("HidApprovalSetting");

                    string HidApproval = dataitemdetailbll.GetItemValue("HidApproval");

                    string[] pstr = HidApproval.Split('#');  //分隔机构组

                    foreach (string strArgs in pstr)
                    {
                        string[] str = strArgs.Split('|');

                        //当前机构相同,且为本部门安全管理员验证  第一种 层层上报
                        if (str[0].ToString() == userEntity.OrganizeId && str[1].ToString() == "0")
                        {
                            /*************临时使用,后续需要进行调整,原有隐患基于角色,较为固定,后期则废弃*************/
                            //WfControlObj wfentity = new WfControlObj();
                            //wfentity.businessid = ""; //
                            //wfentity.startflow = "隐患评估";
                            //wfentity.submittype = "上报";
                            //wfentity.rankname = "一般隐患";
                            //wfentity.user = operators;
                            //wfentity.mark = "厂级隐患排查"; //厂级隐患排查
                            //wfentity.isvaliauth = true;

                            ////获取下一流程的操作人
                            //WfControlResult result = new  WfControlBLL().GetWfControl(wfentity);
                            //bool ishaveapproval = result.ishave;  //具有评估权限的人

                            int count = new UserBLL().GetUserListByRole(userEntity.DepartmentCode, roleCode, userEntity.OrganizeId).ToList().Where(p => p.UserId == userEntity.UserId).Count();
                            if (count > 0)//包含安全管理员、负责人
                            {
                                userMode = "0";
                            }
                            else
                            {
                                userMode = "1";
                            }

                            break;
                        }
                        if (str[0].ToString() == userEntity.OrganizeId && str[1].ToString() == "1")
                        {
                            //获取指定部门的所有人员
                            int count = new UserBLL().GetUserListByDeptCode(str[2].ToString(), null, false, userEntity.OrganizeId).ToList().Where(p => p.UserId == userEntity.UserId).Count();
                            if (count > 0)
                            {
                                userMode = "2";
                            }
                            else
                            {
                                userMode = "3";
                            }
                            break;
                        }
                    }
                    if (userEntity.RoleName.Contains("省级用户"))
                    {
                        userMode = "4";
                    }
                    string rankArgs = dataitemdetailbll.GetItemValue("GeneralHid"); //一般隐患
                    operators.rankArgs = rankArgs;
                    operators.wfMode   = userMode;

                    string hidPlantLevel = dataitemdetailbll.GetItemValue("HidPlantLevel");

                    string hidOrganize = dataitemdetailbll.GetItemValue("HidOrganize");

                    string CompanyRole = hidPlantLevel + "," + hidOrganize;

                    var userList = userBLL.GetUserListByDeptCode(userEntity.DepartmentCode, CompanyRole, false, userEntity.OrganizeId).Where(p => p.UserId == userEntity.UserId).ToList();

                    string isPlanLevel = "";
                    //当前用户是公司级及厂级用户
                    if (userList.Count() > 0)
                    {
                        isPlanLevel = "1"; //厂级用户
                    }
                    else
                    {
                        isPlanLevel = "0";  //非公司及厂级
                    }
                    operators.isPlanLevel = isPlanLevel;

                    string             pricipalCode = dataitemdetailbll.GetItemValue("HidPrincipalSetting");
                    IList <UserEntity> ulist        = new UserBLL().GetUserListByRole(userEntity.DepartmentCode, pricipalCode, userEntity.OrganizeId).ToList();
                    //返回的记录数,大于0,标识当前用户拥有部门负责人身份,反之则无
                    int uModel = ulist.Where(p => p.UserId == userEntity.UserId).Count();
                    operators.isPrincipal = uModel > 0 ? "1" : "0";
                    var deptEntity = new DepartmentBLL().GetEntity(userEntity.DepartmentId);
                    if (null != deptEntity)
                    {
                        operators.SendDeptID = deptEntity.SendDeptID;
                    }
                    else
                    {
                        operators.SendDeptID = "";
                    }
                    //用于违章的用户标记
                    string mark = string.Empty;

                    mark = userbll.GetSafetyAndDeviceDept(operators);                                                                                            //1 安全管理部门, 2 装置部门   5.发包部门

                    string isPrincipal = userbll.HaveRoleListByKey(operators.UserId, dataitemdetailbll.GetItemValue("PrincipalUser")).Rows.Count > 0 ? "3" : ""; //第一级核准人
                    if (!string.IsNullOrEmpty(isPrincipal))
                    {
                        if (!string.IsNullOrEmpty(mark))
                        {
                            mark = mark + "," + isPrincipal;
                        }
                        else
                        {
                            mark = isPrincipal;
                        }
                    }
                    string isEpiboly = userbll.HaveRoleListByKey(operators.UserId, dataitemdetailbll.GetItemValue("EpibolyUser")).Rows.Count > 0 ? "4" : "";  //承包商

                    if (!string.IsNullOrEmpty(isEpiboly))
                    {
                        if (!string.IsNullOrEmpty(mark))
                        {
                            mark = mark + "," + isEpiboly;
                        }
                        else
                        {
                            mark = isEpiboly;
                        }
                    }
                    operators.uMark = mark;
                    //国电新疆红雁池专用
                    string GDXJ_HYC_ORGCODE = dataitemdetailbll.GetItemValue("GDXJ_HYC_ORGCODE");
                    //国电新疆红雁池专用
                    operators.IsGdxjUser = userEntity.OrganizeCode == GDXJ_HYC_ORGCODE ? 1 : 0;
                    OperatorProvider.Provider.AddCurrent(operators);
                    //登录限制
                    //LoginLimit(username, operators.IPAddress, operators.IPAddressName);
                    //写入日志
                    logEntity.ExecuteResult     = 1;
                    logEntity.ExecuteResultJson = "登录成功";
                    logEntity.WriteLog();

                    //异步处理与培训平台对接功能
                    //UserEntity ue = userbll.GetEntity(userEntity.UserId);
                    //UserInfoExtension uinfoextesion = GoToTrainee(ue);

                    var    di           = new DataItemDetailBLL();
                    string webPath      = di.GetItemValue("imgPath");
                    string webUrl       = di.GetItemValue("imgUrl");
                    string signUrl      = "";
                    string qrCodeImgUrl = webUrl + "/Resource/AppFile/download.jpg";
                    if (!string.IsNullOrEmpty(userEntity.SignImg))
                    {
                        if (userEntity.SignImg.ToLower().Trim().StartsWith("http://"))
                        {
                            signUrl = userEntity.SignImg;
                        }
                        else
                        {
                            string fname = "";
                            string sImg  = "";
                            if (userEntity.SignImg.ToLower().Contains("/resource/sign/"))
                            {
                                fname = userEntity.SignImg.Replace("/", "\\");
                                string name = userEntity.SignImg.Substring(userEntity.SignImg.LastIndexOf("/") + 1);
                                sImg = "s" + name.Replace("/", "\\");
                            }
                            else
                            {
                                fname = "\\Resource\\sign\\" + userEntity.SignImg.Replace("/", "\\");
                                sImg  = "\\Resource\\sign\\s" + userEntity.SignImg.Replace("/", "\\");
                            }

                            if (File.Exists(webPath + sImg))
                            {
                                signUrl = webUrl + sImg.Replace("\\", "/");
                            }
                            else
                            {
                                if (File.Exists(webPath + fname))
                                {
                                    signUrl = webUrl + fname.Replace("\\", "/");
                                }
                            }
                        }
                    }
                    return(new
                    {
                        code = 0,
                        count = -1,
                        info = "登陆成功",
                        data = new
                        {
                            userid = operators.UserId,
                            tokenid = operators.Token,
                            useraccount = operators.Account,
                            telephone = userEntity.Telephone,
                            phone = userEntity.Mobile,
                            username = operators.UserName,
                            password = operators.Password,
                            logtime = operators.LogTime,
                            secretkey = operators.Secretkey,
                            gender = operators.Gender,
                            organizeid = operators.OrganizeId,
                            deptid = operators.DeptId,
                            deptcode = operators.DeptCode,
                            deptname = operators.DeptName,
                            organizecode = operators.OrganizeCode,
                            organizename = operators.OrganizeName,
                            objectid = operators.ObjectId,
                            ipaddress = operators.IPAddress,
                            ipaddressname = operators.IPAddressName,
                            issystem = operators.IsSystem,
                            roleid = operators.RoleId,
                            rolename = operators.RoleName,
                            postid = operators.PostId,
                            postname = operators.PostName,
                            dutyname = operators.DutyName,
                            photo = operators.Photo,
                            wfmode = operators.wfMode,
                            senddeptid = operators.SendDeptID,
                            rankargs = operators.rankArgs,
                            isprincipal = operators.isPrincipal,
                            identifyid = operators.IdentifyID,
                            mark = operators.uMark,
                            signurl = signUrl,
                            isgdxjuser = operators.IsGdxjUser,
                            qrimgurl = qrCodeImgUrl,
                            //ticket = uinfoextesion.ticket,
                            //openid = uinfoextesion.openId,
                            //traineeaccount = uinfoextesion.traineeAccount,
                            //traineepwd = uinfoextesion.traineePwd,
                            dataauthorize = new
                            {
                                moduleid = operators.DataAuthorize.ModuleId,
                                readautorize = operators.DataAuthorize.ReadAutorize,
                                readautorizeuserid = operators.DataAuthorize.ReadAutorizeUserId,
                                writeautorize = operators.DataAuthorize.WriteAutorize,
                                writeautorizeuserid = operators.DataAuthorize.WriteAutorizeUserId
                            }
                        }
                    });
                }
                else
                {
                    return(new { code = -1, count = 0, info = "密码输入错误" });
                }
                #endregion
            }
            catch (Exception ex)
            {
                WebHelper.RemoveCookie("autologin");                  //清除自动登录
                logEntity.ExecuteResult     = -1;
                logEntity.ExecuteResultJson = ex.Message;
                logEntity.WriteLog();
                return(new { code = -1, count = 0, info = "账号或密码错误!" });
            }
        }
コード例 #29
0
ファイル: LoginModule.cs プロジェクト: Mouseww/JYT
        //登录
        private Negotiator CheckLogin(dynamic _)
        {
            var       recdata   = this.GetModule <ReceiveModule <loginData> >();
            LogEntity logEntity = new LogEntity();

            logEntity.F_CategoryId     = 1;
            logEntity.F_OperateTypeId  = ((int)OperationType.Login).ToString();
            logEntity.F_OperateType    = EnumAttribute.GetDescription(OperationType.Login);
            logEntity.F_OperateAccount = recdata.data.username;
            logEntity.F_OperateUserId  = recdata.data.username;
            logEntity.F_Module         = "LeaRun.敏捷开发框架";
            try
            {
                Operator      operators = new Operator();
                loginUserInfo result    = new loginUserInfo();

                #region 内部登录
                {
                    //写入当前用户信息
                    UserEntity userEntity = new UserBLL().CheckLogin(recdata.data.username, recdata.data.password);
                    if (userEntity != null)
                    {
                        AuthorizeBLL authorizeBLL = new AuthorizeBLL();
                        operators.UserId       = userEntity.F_UserId;
                        operators.Code         = userEntity.F_EnCode;
                        operators.Account      = userEntity.F_Account;
                        operators.UserName     = userEntity.F_RealName;
                        operators.Password     = userEntity.F_Password;
                        operators.Secretkey    = userEntity.F_Secretkey;
                        operators.CompanyId    = userEntity.F_OrganizeId;
                        operators.DepartmentId = userEntity.F_DepartmentId;
                        operators.IPAddress    = Net.Ip;
                        operators.ObjectId     = new PermissionBLL().GetObjectStr(userEntity.F_UserId);
                        operators.LogTime      = DateTime.Now;
                        operators.Token        = DESEncrypt.Encrypt(Guid.NewGuid().ToString());
                        if (userEntity.F_Account == "System")
                        {
                            operators.IsSystem = true;
                        }
                        else
                        {
                            operators.IsSystem = false;
                        }
                        //写入当前用户数据权限
                        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);

                        result.userid         = userEntity.F_UserId;
                        result.account        = userEntity.F_Account;
                        result.password       = userEntity.F_Password;
                        result.realname       = userEntity.F_RealName;
                        result.headicon       = "";
                        result.gender         = (userEntity.F_Gender == 1 ? "男" : "女");
                        result.mobile         = userEntity.F_Mobile;
                        result.telephone      = userEntity.F_Telephone;
                        result.email          = userEntity.F_Email;
                        result.oicq           = userEntity.F_OICQ;
                        result.wechat         = userEntity.F_WeChat;
                        result.msn            = userEntity.F_MSN;
                        result.managerid      = userEntity.F_ManagerId;
                        result.manager        = userEntity.F_Manager;
                        result.organizeid     = userEntity.F_OrganizeId;
                        result.organizename   = organizeCache.GetEntity(result.organizeid).F_FullName;
                        result.departmentid   = userEntity.F_DepartmentId;
                        result.departmentname = departmentCache.GetEntity(userEntity.F_DepartmentId).F_FullName;
                        result.roleid         = userEntity.F_RoleId;
                        result.rolename       = roleCache.GetEntity(userEntity.F_RoleId).F_FullName;
                        result.dutyid         = userEntity.F_DutyId;
                        result.dutyname       = userEntity.F_DutyName;
                        result.postid         = userEntity.F_PostId;
                        result.postname       = userEntity.F_PostName;
                        result.description    = userEntity.F_Description;
                    }
                }
                #endregion
                //移动端不采用cookie的方式
                this.WriteCache <Operator>(operators, operators.UserId);

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

                return(this.SendData <loginUserInfo>(result, result.userid, operators.Token, ResponseType.Success));
            }
            catch (Exception ex)
            {
                logEntity.F_ExecuteResult     = -1;
                logEntity.F_ExecuteResultJson = ex.Message;
                logEntity.WriteLog();
                return(this.SendData(ResponseType.Fail, ex.Message));
            }
        }
コード例 #30
0
        private bool AnalogLogon(AuthorizationContext filterContext, string LoginName, Operator Current)
        {
            bool needLogin = false;

            //当前用户未登录且SSO登录用户信息不为空,需要进行模拟登录
            if (Current == null && !string.IsNullOrEmpty(LoginName))
            {
                needLogin = true;
            }
            //判断当前用户是否登录如果登录了,检查当前登录的用户是否和SSO用户不一致,如果不一致就进行重写登录
            else if (Current != null && (Current.Account != LoginName))
            {
                LoginOut(filterContext);
                needLogin = true;
            }
            // 当前用户已经登录且用户相同,不需要登录
            else if (Current != null && (Current.Account == LoginName))
            {
                needLogin = false;
            }
            #region  模拟登录

            if (needLogin)
            {
                var userEntity = new UserBLL().CheckLogin(LoginName);
                if (userEntity != null)
                {
                    AuthorizeBLL authorizeBLL = new AuthorizeBLL();
                    Operator     operators    = new Operator();
                    operators.UserId       = userEntity.UserId;
                    operators.Account      = userEntity.Account;
                    operators.UserName     = userEntity.RealName;
                    operators.DepartmentId = userEntity.DepartmentId;
                    //operators.IPAddress = Net.Ip;
                    //operators.IPAddressName = IPLocation.GetLocation(Net.Ip);
                    operators.LogTime        = DateTime.Now;
                    operators.DepartmentName = userEntity.DepartmentName;
                    //写入当前用户数据权限
                    AuthorizeDataModel dataAuthorize = new AuthorizeDataModel();
                    //dataAuthorize.ReadAutorize = authorizeBLL.GetDataAuthor(operators);
                    dataAuthorize.GetReadProjectId = authorizeBLL.GetReadProjectId(operators);
                    //dataAuthorize.WriteAutorize = authorizeBLL.GetDataAuthor(operators, true);
                    //dataAuthorize.WriteAutorizeUserId = authorizeBLL.GetDataAuthorUserId(operators, true);
                    operators.DataAuthorize = dataAuthorize;

                    OperatorProvider.Provider.AddCurrent(operators);
                    #region 写入登录日志
                    LogEntity logEntity = new LogEntity();
                    logEntity.CategoryId     = 1;
                    logEntity.OperateTypeId  = ((int)OperationType.Login).ToString();
                    logEntity.OperateType    = EnumAttribute.GetDescription(OperationType.Login);
                    logEntity.OperateAccount = userEntity.RealName;
                    logEntity.OperateUserId  = userEntity.UserId;
                    logEntity.Module         = "SSOLogin=>System";
                    //写入日志
                    logEntity.ExecuteResult     = 1;
                    logEntity.ExecuteResultJson = "登录成功";
                    logEntity.WriteLog();
                    #endregion
                }
            }
            #endregion
            return(true);
        }