Exemplo n.º 1
0
        public HttpResponseBase GetSecretInfoLog()
        {
            List<SecretInfoLog> store = new List<SecretInfoLog>();
            string json = string.Empty;
            int totalCount = 0;
            try
            {
                _secretLogMgr = new SecretInfoLogMgr(mySqlConnectionString);

                SecretInfoLog query = new SecretInfoLog();
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");

                if (!string.IsNullOrEmpty(Request.Params["limit"]))
                {
                    query.Limit = Convert.ToInt32(Request.Params["limit"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["user_id"]))
                {
                    query.user_id = uint.Parse(Request.Params["user_id"]);
                }
                query.user_email = Request.Params["login_mail"];
                query.ipfrom = Request.Params["login_ipfrom"];
                if (!string.IsNullOrEmpty(Request.Params["start_date"]))
                {
                    query.date_one = Convert.ToDateTime(Request.Params["start_date"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["end"]))
                {
                    query.date_two = Convert.ToDateTime(Request.Params["end"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["sumtotal"]))
                {
                    query.sumtotal = int.Parse(Request.Params["sumtotal"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["is_count"]))
                {
                    int is_count = int.Parse(Request.Params["is_count"]);
                    if (is_count == 1)
                    {
                        if (!string.IsNullOrEmpty(Request.Params["ismail"]))
                        {
                            query.ismail = int.Parse(Request.Params["ismail"]);
                        }
                        if (!string.IsNullOrEmpty(Request.Params["countClass"]))
                        {
                            query.countClass = int.Parse(Request.Params["countClass"]);
                        }
                    }
                    else
                    {
                        query.ismail = -1;
                        query.countClass = -1;
                    }
                }
                if (!string.IsNullOrEmpty(Request.Params["type"]))
                {
                    query.type = int.Parse(Request.Params["type"]);
                }


                DataTable DT = _secretLogMgr.GetSecretInfoLog(query, out totalCount);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(DT, 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;
        }
Exemplo n.º 2
0
        public HttpResponseBase GetSecretLog()
        {
            string json = string.Empty;
            try
            {
                _secretLogMgr = new SecretInfoLogMgr(mySqlConnectionString);
                SecretInfoLog query = new SecretInfoLog();
                query.user_id = Convert.ToUInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                query.ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString());
                List<SecretInfoLog> store = _secretLogMgr.GetSecretInfoLog(query);//first是輸入密碼最近的
                if (store.Count != 0)
                {
                    DateTime dtNow = DateTime.Now.AddMinutes(-5);
                    if (dtNow.CompareTo(Convert.ToDateTime(store[0].input_pwd_date)) >= 0)
                    {
                        json = "{success:true,data:true}";//超出密保時間,需輸入密碼
                    }
                    else
                    {
                        json = "{success:true,data:false}";//未超出密保時間,則不需輸入密碼
                    }
                }
                else
                {
                    json = "{success:true,data:true}";//超出密保時間,需輸入密碼
                }


            }
            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,data:true}";//異常
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }