Example #1
0
        public CaseModel Func_Exception()
        {
            return(new CaseModel()
            {
                NameSign = @"异常",
                ExeEvent = () => {
                    try {
                        YTS.Model.AjaxResult ajax = null;
                        Console.WriteLine(ajax.Msg);
                    } catch (Exception ex) {
                        SystemLog log = new SystemLog()
                        {
                            AddTime = DateTime.Now,
                            Message = @"维权及其减少时浏览量",
                            Position = ex.StackTrace,
                            Type = SystemLog.LogType.Exception,
                        };

                        SystemLog.Write(ex);
                        SystemLog.Write(ex);
                        log.Write();
                        log.Write();
                        log.Write();
                        SystemLog.Write(ex);
                        log.Write();
                        log.Write();
                    }
                    return true;
                },
            });
        }
        //获取一个用户所有的设备列表

        public ActionResult GetUserTelList(GetUserTelListModels modles)
        {
            DbDataController mDbDataController = new DbDataController();
            DataTable        mDataTable;

            //是否为Ajax请求
            if (!Request.IsAjaxRequest())
            {
                return(null);
            }

            try
            {
                if (modles.Operation == "GetUserTelList")
                {
                    //身份验证-使用用户名与密码md5进行验证
                    if (mDbDataController.AuthenticationMD5(modles.UserName, modles.PasswordMD5) != null)
                    {
                        mDataTable = mDbDataController.GetUserTelName(modles.UserName); //获取指定用户的所有设备列表包含站点名称信息,[0]:站点名称;[1]:站点编号
                        return(StaticActionResult.JsonActionResult(StaticJson.DataTableToJsonWithJsonNet(mDataTable)));
                    }
                    else
                    {
                        return(StaticActionResult.JsonActionResult("用户名与密码验证失败"));
                    }
                }
            }
            catch (Exception e)
            {
                SystemLog.Write(e.StackTrace + e.Message);  //日志
            }

            return(null);
        }
        public void Remove(Security security)
        {
            lock (removeObjLock)
            {
                SystemLog.Write("-------Removing: " + this);

                DataTable table = _mainTables[security.ID];

                if (table != null)
                {
                    DataRowCollection rows = table.Rows;
                    if (rows.Count == 0)
                    {
                        return;
                    }

                    DataRow row = rows[0];
                    row.Delete();
                    Database.DB["Quant"].UpdateDataTable(table);
                }
                Security outs = null;
                _securityIdDB.TryRemove(security.ID, out outs);
                if (_securityIsinDB.ContainsKey(security.Isin))
                {
                    Dictionary <int, Security> outss = null;
                    _securityIsinDB.TryRemove(security.Isin, out outss);
                }
            }
        }
        // POST api/values
        public JsonResult Post([FromBody] string value)
        {
            try
            {
                JsonResult jsonResult = new JsonResult();
                jsonResult.Data                = StaticJson.DefaultResponseJsonStructPack(1, "测试编号1510260128", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
                jsonResult.ContentEncoding     = null;               //只能设置为null,不知为何,其它值会导致错误500
                jsonResult.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                jsonResult.ContentType         = "application/json"; //内容
                jsonResult.MaxJsonLength       = int.MaxValue;       //最大长度
                jsonResult.RecursionLimit      = 50;                 //递归限制

                return(jsonResult);

                /* //响应数据
                 * return new HttpResponseMessage
                 * {
                 *    Content = new StringContent(
                 *        StaticJson.DefaultResponseJsonStructPack(1, "1510260128", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")),
                 *        System.Text.Encoding.UTF8, "application/json")
                 * };*/
            }
            catch (Exception e)
            {
                SystemLog.Write(e.StackTrace + e.Message);  //日志
                throw;
            }
        }
 private CaseModel ExeEvent_Random_DateTime_CreateLibray()
 {
     return(new CaseModel()
     {
         NameSign = @"随机时间范围",
         ExeEvent = () => {
             const string timeFormat = @"MM-dd HH:mm";
             const int addDayNum = 2;
             const int year = 2017;
             DateTime min_time = new DateTime(year, 01, 01, 08, 08, 08);
             DateTime max_time = min_time.AddHours(addDayNum);
             List <string> list = new List <string>();
             Print.WriteLine("Init: {0}-{1}", min_time.ToString(timeFormat), max_time.ToString(timeFormat));
             for (int i = 0; i < 20000; i++)
             {
                 DateTime time = RandomData.GetDateTime(min_time, max_time);
                 if (time.Year > year)
                 {
                     break;
                 }
                 list.Add(time.ToString(timeFormat));
                 min_time = time;
                 max_time = time.AddHours(addDayNum);
             }
             SystemLog.Write("NULL", ConvertTool.IListToString(list, "#"));
             Print.WriteLine(list.Count);
         },
     });
 }
Example #6
0
 public void RemoveFrom(Strategy strategy, DateTime date)
 {
     try
     {
         Database.DB[strategy.StrategyDB].ExecuteCommand("DELETE FROM " + _StrategyMemoryTableName + " WHERE ID = " + strategy.ID + " AND Timestamp >= '" + date.ToString("yyyy/MM/dd HH:mm:ss.fff") + "'");
     }
     catch (Exception e) { SystemLog.Write(e); }
 }
Example #7
0
        //获取用户相关信息
        public ActionResult WeixinPayAttention(string json)
        {
            UniversalResponse resp = new UniversalResponse();
            DbDataController  mDbDataController = new DbDataController();
            DataTable         mDataTable;
            int status;

            resp.obj = null;
            try
            {
                WeixinUserInfo info = new WeixinUserInfo();

                info = (WeixinUserInfo)StaticJson.JsonToObject(json, info);
                if (info == null || info.openid == null)
                {
                    resp.rel = 0;
                    resp.msg = "无效的数据";
                }
                else
                {
                    mDataTable = mDbDataController.GetWeixinUser(info.openid);
                    if (mDataTable != null && mDataTable.Rows.Count > 0) //已经存在
                    {
                        status = mDbDataController.UpdateWeixinUser(info);
                    }
                    else
                    {
                        status = mDbDataController.AddWeixinUser(info);
                    }
                    if (status <= 0)
                    {
                        resp.rel = 0;
                        resp.msg = "添加数据到数据库失败";
                    }
                    else
                    {
                        resp.rel = 1;
                        resp.msg = "添加/修改成功";
                    }
                }

                return(Json(resp));
            }
            catch (Exception e)
            {
                SystemLog.Write(e.StackTrace + e.Message);  //日志

                resp.rel = 0;
                resp.msg = "发生了异常," + e.Message;
                return(Json(resp));
            }
        }
Example #8
0
 /// <summary>
 /// 继承自接口: IHttpHandler 处理请求 一般情况下继承此类不需要重写此方法
 /// </summary>
 /// <param name="context">HTTP 请求信息上下文</param>
 public virtual void ProcessRequest(HttpContext context)
 {
     StructureInitTool();
     Model.AjaxResult jsonResult = GetInitAjaxJsonResultModel();
     try {
         jsonResult = LogicalProcessing(context, jsonResult);
     } catch (Exception ex) {
         SystemLog.Write(ex);
         jsonResult.Status = Model.AjaxResult.StatusValue.Error;
         jsonResult.Msg    = @"服务器出错了, 已记录日志...请联系管理员!";
     } finally {
         ReturnResponseResult(context, jsonResult);
     }
 }
Example #9
0
        public ActionResult WeixinApi(WeixinModel model)
        {
            try
            {
                if (model.GetFun == "WeixinPayAttention") //关注微信公众号
                {
                    if (model.data != null)
                    {
                        return(WeixinPayAttention(model.data));
                    }
                }
            }
            catch (Exception error)
            {
                SystemLog.Write("WeixinApi," + error.Message + error.StackTrace);   //写入日志
            }


            return(null);
        }
        public ActionResult GetRealTimeData(string value)
        {
            try
            {
                JsonResult jsonResult = new JsonResult();
                jsonResult.Data                = StaticJson.DefaultResponseJsonStructPack(1, "测试编号1510260128", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
                jsonResult.ContentEncoding     = null;               //只能设置为null,不知为何,其它值会导致错误500
                jsonResult.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                jsonResult.ContentType         = "application/json"; //内容
                jsonResult.MaxJsonLength       = int.MaxValue;       //最大长度
                jsonResult.RecursionLimit      = 50;                 //递归限制

                return(jsonResult);
            }
            catch (Exception e)
            {
                SystemLog.Write(e.StackTrace + e.Message);  //日志
            }
            return(null);
        }
Example #11
0
        public CaseModel Func_Use()
        {
            return(new CaseModel()
            {
                NameSign = @"日常使用",
                ExeEvent = () => {
                    SystemLog log = new SystemLog()
                    {
                        Position = @"Test.ConsoleProgram.Tools.Test_UseSystemLog",
                        Type = SystemLog.LogType.Record,
                    };

                    log.Message = @"测试使用方法";

                    // 将当前的日志的内容写入文件
                    string log_file_path = log.Write();

                    Console.WriteLine("log_file_path: {0}", log_file_path);
                    return true;
                },
            });
        }
Example #12
0
        /// <summary>
        /// 第一个事件执行
        /// </summary>
        private void BeginRequest(object sender, EventArgs e)
        {
            HttpContext context = ((HttpApplication)sender).Context;

            // 获得请求页面路径页面(含目录)
            string request_path = context.Request.Path.ToLower();

            if (request_path == @"/")
            {
                context.Response.Redirect(@"index.aspx");
                return;
            }

            // 检查请求的文件是否存在 如:存在,跳出,没必要做任何处理
            string request_absfilepath = PathHelp.ToAbsolute(request_path);

            request_absfilepath = ConvertTool.ToString(request_absfilepath);
            if (File.Exists(request_absfilepath))
            {
                return;
            }

            // 执行生成执行页面内容
            string redirect_path = ReWriteURLPath(context.Request.Url);

            if (!CheckData.IsStringNull(redirect_path))
            {
                SystemLog log = new SystemLog()
                {
                    Type     = SystemLog.LogType.Record,
                    Position = @"YTS.Web.UI.HttpModule.BeginRequest",
                    Message  = string.Format("new redirect path: {0}", redirect_path),
                };
                log.Write();

                // HTTP请求重写路径
                context.RewritePath(redirect_path);
            }
        }
Example #13
0
        // GET: /Weixin/WeixinUserInfo
        public ActionResult WeixinUserInfo(String state, String p, String id)
        {
            try
            {
                if (state == "WeiXin" && id != null && id.Length > 10 && p != null)
                {
                    DbDataController mDbDataController = new DbDataController();
                    id = id.Replace("2B%", "+");              //还原转换的+
                    String openid = StaticAES.AESDecrypt(id); //解密

                    //获取当前的时间戳
                    TimeSpan cha   = (DateTime.Now - TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)));
                    long     count = (long)cha.TotalSeconds;
                    p = p.Replace("2B%", "+");                   //还原转换的+
                    String time       = StaticAES.AESDecrypt(p); //解密
                    long   time_count = 0;
                    try
                    {
                        time_count = Convert.ToInt32(time);
                    }
                    catch (Exception e)
                    {
                        time_count = 0;
                    }

                    count -= time_count;
                    if (count < -7200 || count > 7200) //链接过期了
                    {
                        //去掉登录的状态
                        Session["UserName"]    = "";           //存储全局用户名称
                        Session["Password"]    = "";           //存储全局用户密码MD5
                        Session["LoginStatus"] = "";           //登录状态
                        Session["Openid"]      = openid;       //存储openid
                        return(View());
                    }

                    DataTable mDataTable = mDbDataController.GetWeixinBindUserInfo(openid); //从数据库中读取指定的微信绑定的用户信息
                    if (mDataTable != null && mDataTable.Rows.Count > 0)                    //当前微信已经绑定过用户
                    {
                        //获取

                        String UserName    = mDataTable.Rows[0]["USER"].ToString();         //获取用户名
                        String PasswordMD5 = mDataTable.Rows[0]["PASSWORD_MD5"].ToString(); //获取密码
                        //保存帐户登录名
                        //SaveCookie("UserName", UserName, DateTime.Now.AddDays(30));  //保存cookie 30天
                        //保存密码
                        //SaveCookie("PasswordMD5", PasswordMD5, DateTime.Now.AddDays(30));  //保存cookie 30天
                        //自动登录
                        Session["UserName"]    = UserName;                  //存储全局用户名称
                        Session["Password"]    = PasswordMD5;               //存储全局用户密码MD5
                        Session["LoginStatus"] = "Login Success";           //登录状态
                        Session["Openid"]      = openid;                    //存储openid
                    }
                    else //没有绑定过,则跳转到登录,登录成功后会进行绑定
                    {
                        //去掉登录的状态
                        Session["UserName"]    = "";            //存储全局用户名称
                        Session["Password"]    = "";            //存储全局用户密码MD5
                        Session["LoginStatus"] = "";            //登录状态
                        Session["Openid"]      = openid;        //存储openid
                        return(View());
                    }
                }
            }
            catch (Exception e)
            {
                SystemLog.Write(e.StackTrace + e.Message);  //日志
            }

            return(View());
        }