Exemple #1
0
        public List<ManageLoginQuery> GetManageLoginList(ManageLoginQuery query, out int totalCount)
        {
            List<ManageLoginQuery> list = new List<ManageLoginQuery>();
            StringBuilder sbSql = new StringBuilder();
            StringBuilder sbSqlWhere = new StringBuilder();
            StringBuilder sbSqlFrom = new StringBuilder();
            try
            {

                sbSql.Append("select ml.login_id as loginID,ml.user_id,ml.login_ipfrom,FROM_UNIXTIME(ml.login_createdate) as login_createtime,mu.user_username as user_name ");
                sbSqlFrom.Append("  from manage_login ml ");
                sbSqlFrom.Append("  left join manage_user mu on ml.user_id = mu.user_id ");

                if (query.login_id != 0)
                {
                    sbSqlWhere.AppendFormat(" and ml.login_id = '{0}' ", query.login_id);
                }
                if (query.login_start != 0)
                {
                    sbSqlWhere.AppendFormat(" and ml.login_createdate >= '{0}' ", query.login_start);
                }
                if (query.login_end != 0)
                {
                    sbSqlWhere.AppendFormat(" and ml.login_createdate <= '{0}' ", query.login_end);
                }
                if (!string.IsNullOrEmpty(query.user_name))
                {
                    sbSqlWhere.AppendFormat(" and  mu.user_username like '%{0}%' ", query.user_name);
                }
                if (!string.IsNullOrEmpty(query.login_ipfrom))
                {
                    sbSqlWhere.AppendFormat(" and ml.login_ipfrom like '%{0}%'", query.login_ipfrom);
                }
                if (sbSqlWhere.Length > 0)
                {
                    sbSqlFrom.Append(" where " + sbSqlWhere.ToString().TrimStart().Remove(0, 3));
                }
                totalCount = 0;
                if (query.IsPage)
                {
                    DataTable _dt = _access.getDataTable("select count(ml.login_id) as totalCount " + sbSqlFrom.ToString());
                    if (_dt.Rows.Count > 0)
                    {
                        totalCount = int.Parse(_dt.Rows[0]["totalCount"].ToString());
                    }
                    sbSqlFrom.AppendFormat(" order by ml.login_id desc limit {0},{1} ", query.Start, query.Limit);
                }
                sbSql.Append(sbSqlFrom.ToString());
                return list = _access.getDataTableForObj<ManageLoginQuery>(sbSql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("ManageLoginDao-->GetManageLoginList-->" + ex.Message + sbSql.ToString(), ex);
            }

        }
Exemple #2
0
 public List<ManageLoginQuery> GetManageLoginList(ManageLoginQuery query, out int totalCount)
 {
     try
     {
         return _ManageLoginDao.GetManageLoginList(query,out totalCount);
     }
     catch (Exception ex)
     {
         throw new Exception("ManageLoginMgr-->GetManageLoginList-->"+ex.Message,ex);
     }
 }
        public HttpResponseBase GetManageLoginList()
        {
            string json = string.Empty;
            int totalCount = 0;
            List<ManageLoginQuery> list = new List<ManageLoginQuery>();
            _managelogionMgr = new ManageLoginMgr(mySqlConnectionString);
            ManageLoginQuery query = new ManageLoginQuery();
            query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
            query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
            try
            {

                query.login_start = CommonFunction.GetPHPTime(Request.Params["time_start"]);
                query.login_end = CommonFunction.GetPHPTime(Request.Params["time_end"]);
                if (!String.IsNullOrEmpty(Request.Params["LoginSearch"]))//登錄人
                {
                    query.user_name = Request.Params["LoginSearch"];
                }
                if (!String.IsNullOrEmpty(Request.Params["IPSearch"]))//IP
                {

                    query.login_ipfrom = Request.Params["IPSearch"];
                }

                list = _managelogionMgr.GetManageLoginList(query, out totalCount);

                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";

                //listUser是准备转换的对象
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(list, Formatting.Indented, timeConverter) + "}";//返回json數據
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
        public bool Start(string schedule_code)
        {
            if (string.IsNullOrEmpty(schedule_code))
            {
                return false;
            }
            try
            {
                MailModel mailModel = new MailModel();
                mailModel.MysqlConnectionString = mySqlConnectionString;

                string GroupCode = string.Empty;
                string MailTitle = string.Empty;
                string MailBody = string.Empty;
                bool IsSeparate = false;
                bool IsDisplyName = true;

                //獲取該排程參數
                List<ScheduleConfigQuery> store_config = new List<ScheduleConfigQuery>();
                ScheduleConfigQuery query_config = new ScheduleConfigQuery();
                query_config.schedule_code = schedule_code;
                _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString);
                store_config = _secheduleServiceMgr.GetScheduleConfig(query_config);
                #region mailhelp賦值
                foreach (ScheduleConfigQuery item in store_config)
                {
                    if (item.parameterCode.Equals("MailFromAddress"))
                    {
                        mailModel.MailFromAddress = item.value;
                    }
                    else if (item.parameterCode.Equals("MailHost"))
                    {
                        mailModel.MailHost = item.value;
                    }
                    else if (item.parameterCode.Equals("MailPort"))
                    {
                        mailModel.MailPort = item.value;
                    }
                    else if (item.parameterCode.Equals("MailFromUser"))
                    {
                        mailModel.MailFromUser = item.value;
                    }
                    else if (item.parameterCode.Equals("EmailPassWord"))
                    {
                        mailModel.MailFormPwd = item.value;
                    }
                    else if (item.parameterCode.Equals("GroupCode"))
                    {
                        GroupCode = item.value;
                    }
                    else if (item.parameterCode.Equals("MailTitle"))
                    {
                        MailTitle = item.value;
                    }
                    else if (item.parameterCode.Equals("MailTitle"))
                    {
                        MailTitle = item.value;
                    }
                    else if (item.parameterCode.Equals("MailBody"))
                    {
                        MailBody = item.value;
                    }
                    else if (item.parameterCode.Equals("IsSeparate"))
                    {
                        if (item.value.ToString().Trim().ToLower() == "false")
                        {
                            IsSeparate = false;
                        }
                        else if (item.value.ToString().Trim().ToLower() == "true")
                        {
                            IsSeparate = true;
                        }
                    }
                    else if (item.parameterCode.Equals("IsDisplyName"))
                    {
                        if (item.value.ToString().Trim().ToLower() == "false")
                        {
                            IsDisplyName = false;
                        }
                        else if (item.value.ToString().Trim().ToLower() == "true")
                        {
                            IsDisplyName = true;
                        }
                    }
                }
                #endregion
                ///獲取用戶登陸信息
                ///
                int totalCount = 0;
                List<ManageLoginQuery> list = new List<ManageLoginQuery>();
                ManageLoginMgr _managelogionMgr = new ManageLoginMgr(mySqlConnectionString);
                ManageLoginQuery query = new ManageLoginQuery();
                query.Start = Convert.ToInt32("0");
                query.Limit = Convert.ToInt32("999");

                query.login_start = CommonFunction.GetPHPTime(DateTime.Now.AddHours(-1).ToString());
                query.login_end = CommonFunction.GetPHPTime(DateTime.Now.ToString());

                DataTable _dt = new DataTable();
                DataRow dr;
                _dt.Columns.Add("登入編號", typeof(string));
                _dt.Columns.Add("登入人名稱", typeof(string));
                _dt.Columns.Add("登入時間", typeof(string));
                _dt.Columns.Add("來源IP", typeof(string));
                list = _managelogionMgr.GetManageLoginList(query, out totalCount);
                foreach (var item in list)
                {
                    dr = _dt.NewRow();
                    dr["登入編號"] = item.loginID.ToString();
                    dr["登入人名稱"] = item.user_name.ToString();
                    dr["登入時間"] = CommonFunction.DateTimeToString(item.login_createtime);
                    dr["來源IP"] = item.login_ipfrom.ToString();
                    _dt.Rows.Add(dr);
                }
                if (_dt.Rows.Count > 0)
                {
                    MailBody = GetHtmlByDataTable(_dt);
                    /////////////////
                    _secheduleServiceMgr.SendMail(mailModel, GroupCode, MailTitle, MailBody, IsSeparate, IsDisplyName);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("UserLoginLogMgr-->Start-->" + ex.Message);
            }
            return true;
        }