Exemplo n.º 1
0
        public JsonResult SaveDescription(JObject jsonObj)
        {
            //_logger.LogInformation("开始运行");

            AjaxRtnJsonData ajaxRtnJsonData = HandlerHelper.ActionWrap(() =>
            {
                //保存备注
                string Id          = HandlerHelper.GetValue(jsonObj, "Id");
                string Description = HandlerHelper.GetValue(jsonObj, "Description");

                IFreeSql fsql = FreeSqlFactory.GetIFreeSql("rlfstock", FreeSql.DataType.Sqlite);

                Company source = fsql.Select <Company>().Where(t => t.Id == int.Parse(Id, CultureInfo.CurrentCulture)).ToOne();

                source.Description = Description;

                if (source != null)
                {
                    fsql.Update <Company>().SetSource(source).UpdateColumns(a => a.Description).ExecuteAffrows();
                }

                return(null);
            });

            //_logger.LogInformation("结束运行");

            return(new JsonResult(ajaxRtnJsonData));
        }
Exemplo n.º 2
0
        public static AjaxRtnJsonData ActionWrap(dlgMethod1 dlg)
        {
            //string strRtn = string.Empty;

            AjaxRtnJsonData RtnJsonData = new AjaxRtnJsonData();

            try
            {
                //WebLogHelper.WriteLog("ActionWrap start ");
                //WebLogHelper.WriteLog("debug", context.Request.Cookies["UserIDFileCheck"].Value.ToString());

                //if (context.Request.Cookies["UserIDFileCheck"] == null
                //|| string.IsNullOrEmpty(context.Request.Cookies["UserIDFileCheck"]))
                //{

                //    throw new BusinessExcption() { Value = "Token已过期!" };

                //}

                RtnJsonData.ResultData = dlg();

                //WebLogHelper.WriteLog("ActionWrap end ");
            }
            catch (BusinessException ex)
            {
                RtnJsonData.ErrCode = "1";
                RtnJsonData.Status  = "false";
                RtnJsonData.ErrMsg  = ex.Message;
                //string typeName = this.GetType().ToString();//当类名用
                //string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                //string methodName = context.Request.Form["Action"];
                //ex.Source = typeName + "." + methodName + "->" + ex.Source;
                //WebLogHelper.WriteLog("","BusinessExcption=>" + ex.ToString());
                //WebLogHelper.WriteLog("","ex.Source=>" + ex.Source);
            }
            catch (DBOperatorException ex)
            {
                RtnJsonData.ErrCode = "2";
                RtnJsonData.Status  = "false";
                RtnJsonData.ErrMsg  = ex.Message;
                //string typeName = this.GetType().ToString();//当类名用
                //string methodName = context.Request.Form["Action"];
                //ex.Source = typeName + "." + methodName + "->" + ex.Source;
                //WebLogHelper.WriteLog("HandlerDBOperatorException", "DBOperatorException=>" + ex.ToString());
                //WebLogHelper.WriteLog("HandlerDBOperatorException", "ex.Source=>" + ex.Source);
            }
            catch (Exception ex)
            {
                RtnJsonData.ErrCode = "3";
                RtnJsonData.Status  = "false";
                RtnJsonData.ErrMsg  = "系统异常!" + ex.Message;
                //string typeName = this.GetType().ToString();//当类名用
                //string methodName = context.Request.Form["Action"];
                //ex.Source = typeName + "." + methodName + "->" + ex.Source;
                //WebLogHelper.WriteLog("HandlerException", "Exception=>" + ex.ToString());
                //WebLogHelper.WriteLog("HandlerException", "ex.Source=>" + ex.Source);
            }

            return(RtnJsonData);
        }
Exemplo n.º 3
0
        public JsonResult SaveArtContent(JObject jsonObj)
        {
            //_logger.LogInformation("开始运行");

            AjaxRtnJsonData ajaxRtnJsonData = HandlerHelper.ActionWrap(() =>
            {
                //参数
                string Id         = HandlerHelper.GetValue(jsonObj, "Id");
                string ArtContent = HandlerHelper.GetValue(jsonObj, "ArtContent");

                IFreeSql fsql = FreeSqlFactory.GetIFreeSql("rlfstock", FreeSql.DataType.Sqlite);

                StockArt source = fsql.Select <StockArt>().Where(t => t.Id == int.Parse(Id)).ToOne();

                source.ArtContent = ArtContent;

                if (source != null)
                {
                    fsql.Update <StockArt>().SetSource(source).UpdateColumns(a => a.ArtContent).ExecuteAffrows();
                }

                return(null);
            });

            //_logger.LogInformation("结束运行");

            return(new JsonResult(ajaxRtnJsonData));
        }
Exemplo n.º 4
0
        public JsonResult Delete(JObject jsonObj)
        {
            //_logger.LogInformation("开始运行");

            AjaxRtnJsonData ajaxRtnJsonData = HandlerHelper.ActionWrap(() =>
            {
                //throw new BusinessException("asdfasdf");

                //参数
                string[] arrayId = HandlerHelper.GetValue(jsonObj, "Id").Split(',');

                IFreeSql fsql = FreeSqlFactory.GetIFreeSql("rlfstock", FreeSql.DataType.Sqlite);

                foreach (string Id in arrayId)
                {
                    StockArt source = fsql.Select <StockArt>().Where(t => t.Id == int.Parse(Id)).ToOne();

                    source.Deleted = 1;

                    fsql.Update <StockArt>().SetSource(source).UpdateColumns(a => a.Deleted).ExecuteAffrows();
                }

                return(null);
            });

            //_logger.LogInformation("结束运行");

            return(new JsonResult(ajaxRtnJsonData));
        }
Exemplo n.º 5
0
        public JsonResult SaveAnalysisContent(JObject jsonObj)
        {
            //_logger.LogInformation("Search 开始运行");

            AjaxRtnJsonData ajaxRtnJsonData = HandlerHelper.ActionWrap(() =>
            {
                //保存备注
                string strId = jsonObj["Id"].ToString();
                string strAnalysisContent = jsonObj["AnalysisContent"].ToString();

                IFreeSql fsql = FreeSqlFactory.GetIFreeSql("rlfstock", FreeSql.DataType.Sqlite);

                PositionAnalysis source = fsql.Select <PositionAnalysis>().Where(t => t.Id == int.Parse(strId, CultureInfo.CurrentCulture)).ToOne();

                source.AnalysisContent = strAnalysisContent;

                if (source != null)
                {
                    fsql.Update <PositionAnalysis>().SetSource(source).UpdateColumns(a => a.AnalysisContent).ExecuteAffrows();
                }

                return(null);
            });

            //_logger.LogInformation("Search 结束运行");

            return(new JsonResult(ajaxRtnJsonData));
        }
Exemplo n.º 6
0
        public static AjaxRtnJsonData ActionWrap(string action, JObject jsonObj, dlgMethod dlg)
        {
            //string strRtn = string.Empty;

            AjaxRtnJsonData RtnJsonData = new AjaxRtnJsonData();

            try
            {
                //WebLogHelper.WriteLog("ActionWrap start ");
                if (string.IsNullOrEmpty(action) || action.IndexOf("RequestToken") == -1)
                {
                    string UserId = HandlerHelper.GetValue(jsonObj, "UserId");
                    if (string.IsNullOrEmpty(UserId))
                    {
                        throw new BusinessException("UserId为空!");
                    }
                }

                RtnJsonData.ResultData = dlg(action, jsonObj);

                //WebLogHelper.WriteLog("ActionWrap end ");
            }
            catch (BusinessException ex)
            {
                RtnJsonData.ErrCode = "1";
                RtnJsonData.Status  = "false";
                RtnJsonData.ErrMsg  = ex.Message;
                //string typeName = this.GetType().ToString();//当类名用
                //string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                //string methodName = context.Request.Form["Action"];
                //ex.Source = typeName + "." + methodName + "->" + ex.Source;
                //WebLogHelper.WriteLog("","BusinessExcption=>" + ex.ToString());
                //WebLogHelper.WriteLog("","ex.Source=>" + ex.Source);
            }
            catch (DBOperatorException ex)
            {
                RtnJsonData.ErrCode = "2";
                RtnJsonData.Status  = "false";
                RtnJsonData.ErrMsg  = ex.Message;
                //string typeName = this.GetType().ToString();//当类名用
                //string methodName = context.Request.Form["Action"];
                //ex.Source = typeName + "." + methodName + "->" + ex.Source;
                //WebLogHelper.WriteLog("HandlerDBOperatorException", "DBOperatorException=>" + ex.ToString());
                //WebLogHelper.WriteLog("HandlerDBOperatorException", "ex.Source=>" + ex.Source);
            }
            catch (Exception ex)
            {
                RtnJsonData.ErrCode = "3";
                RtnJsonData.Status  = "false";
                RtnJsonData.ErrMsg  = "系统异常!" + ex.Message;
                //string typeName = this.GetType().ToString();//当类名用
                //string methodName = context.Request.Form["Action"];
                //ex.Source = typeName + "." + methodName + "->" + ex.Source;
                //WebLogHelper.WriteLog("HandlerException", "Exception=>" + ex.ToString());
                //WebLogHelper.WriteLog("HandlerException", "ex.Source=>" + ex.Source);
            }

            return(RtnJsonData);
        }
Exemplo n.º 7
0
        public JsonResult SaveRow(JObject jsonObj)
        {
            //_logger.LogInformation("开始运行");

            AjaxRtnJsonData ajaxRtnJsonData = HandlerHelper.ActionWrap(() =>
            {
                //参数
                string Id = HandlerHelper.GetValue(jsonObj, "Id");

                string CompanyCode     = HandlerHelper.GetValue(jsonObj, "CompanyCode");
                string CompanyName     = HandlerHelper.GetValue(jsonObj, "CompanyName");
                string CompanyType     = HandlerHelper.GetValue(jsonObj, "CompanyType");
                string HoldCompanyName = HandlerHelper.GetValue(jsonObj, "HoldCompanyName");
                string Tag             = HandlerHelper.GetValue(jsonObj, "Tag");

                string UserId = HandlerHelper.GetValue(jsonObj, "UserId");

                //更新
                IFreeSql fsql = FreeSqlFactory.GetIFreeSql("rlfstock", FreeSql.DataType.Sqlite);

                Company model = null;

                if (string.IsNullOrEmpty(Id))
                {
                    model = new Company();
                }
                else
                {
                    model = fsql.Select <Company>().Where(t => t.Id == int.Parse(Id, CultureInfo.CurrentCulture)).ToOne();
                }

                //model.UserId = int.Parse(UserId);
                model.CompanyCode     = CompanyCode;
                model.CompanyName     = CompanyName;
                model.CompanyType     = CompanyType;
                model.HoldCompanyName = HoldCompanyName;
                model.Tag             = Tag;

                if (!string.IsNullOrEmpty(Id))
                {
                    fsql.Update <Company>().SetSource(model).ExecuteAffrows();
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(UserId))
                    {
                        throw new BusinessException("用户Id为空!");
                    }
                    model.UserId = int.Parse(UserId);
                    fsql.Insert <Company>(model).ExecuteAffrows();
                }

                return(null);
            });

            //_logger.LogInformation("结束运行");

            return(new JsonResult(ajaxRtnJsonData));
        }
Exemplo n.º 8
0
        public JsonResult RequestToken1(JObject jsonObj)
        {
            //_logger.LogInformation("RequestToken 开始运行");

            string strAction = "RequestToken1";

            AjaxRtnJsonData ajaxRtnJsonData = HandlerHelper.ActionWrap(strAction, jsonObj, (strAction, jsonObj) =>
            {
                Dictionary <string, object> dictRtn = new Dictionary <string, object>();

                string username = HandlerHelper.GetValue(jsonObj, "username");
                string password = HandlerHelper.GetValue(jsonObj, "password");

                LoginRequestDTO loginRequestDTO = new LoginRequestDTO()
                {
                    Username = username, Password = password
                };

                if (!ModelState.IsValid)
                {
                    throw new BusinessException("无效请求!");
                }

                string token;
                string userid;

                bool isAuth = _authService.IsAuthenticated(loginRequestDTO, out token, out userid);
                if (isAuth == false)
                {
                    throw new BusinessException("用户名或密码错误!");
                }

                dictRtn.Add("Token", token);
                dictRtn.Add("UserId", userid);

                return(dictRtn);
            });

            //_logger.LogInformation("结束运行");

            return(new JsonResult(ajaxRtnJsonData));
        }
Exemplo n.º 9
0
        public JsonResult Search(JObject jsonObj)
        {
            _logger.LogInformation("Search 开始运行");

            AjaxRtnJsonData ajaxRtnJsonData = HandlerHelper.ActionWrap(() =>
            {
                Dictionary <string, object> dictRtn = new Dictionary <string, object>();

                string PerPageNum      = HandlerHelper.GetValue(jsonObj, "PerPageNum");
                string CurPage         = HandlerHelper.GetValue(jsonObj, "CurPage");
                string CompanyCode     = HandlerHelper.GetValue(jsonObj, "CompanyCode");
                string CompanyName     = HandlerHelper.GetValue(jsonObj, "CompanyName");
                string Tag             = HandlerHelper.GetValue(jsonObj, "Tag");
                string HoldCompanyName = HandlerHelper.GetValue(jsonObj, "HoldCompanyName");

                string UserId = HandlerHelper.GetValue(jsonObj, "UserId");

                IFreeSql fsql = FreeSqlFactory.GetIFreeSql("rlfstock", FreeSql.DataType.Sqlite);

                //where 条件
                Expression <Func <Company, bool> > where = x => true;

                if (!string.IsNullOrEmpty(UserId))
                {
                    where = where.And(x => x.UserId == int.Parse(UserId));
                }

                //证券代码
                if (!string.IsNullOrEmpty(CompanyCode))
                {
                    where = where.And(x => x.CompanyCode == CompanyCode);
                }
                //证券名称
                if (!string.IsNullOrEmpty(CompanyName))
                {
                    string[] array = CompanyName.Split(' ');

                    Expression <Func <Company, bool> > whereSub = x => x.CompanyName.Contains(array[0]);
                    foreach (string one in array)
                    {
                        if (array[0].Equals(HoldCompanyName))
                        {
                            continue;
                        }
                        whereSub = whereSub.Or(x => x.CompanyName.Contains(one));
                    }
                    where = where.And(whereSub);
                }
                //概念/标签
                if (!string.IsNullOrEmpty(Tag))
                {
                    string[] arrayTag = Tag.Split(' ');

                    Expression <Func <Company, bool> > whereSub = x => x.Tag.Contains(arrayTag[0]);
                    foreach (string tag in arrayTag)
                    {
                        if (arrayTag[0].Equals(tag))
                        {
                            continue;
                        }
                        whereSub = whereSub.And(x => x.Tag.Contains(tag));
                    }
                    where = where.And(whereSub);
                }
                //控股公司
                if (!string.IsNullOrEmpty(HoldCompanyName))
                {
                    string[] array = HoldCompanyName.Split(' ');

                    Expression <Func <Company, bool> > whereSub = x => x.HoldCompanyName.Contains(array[0]);
                    foreach (string one in array)
                    {
                        if (array[0].Equals(HoldCompanyName))
                        {
                            continue;
                        }
                        whereSub = whereSub.Or(x => x.HoldCompanyName.Contains(one));
                    }
                    where = where.And(whereSub);
                }

                //var sql = fsql.Select<Company>()
                //  .Where(where)
                //  .OrderBy("Id asc")
                //  .Page(int.Parse(CurPage, CultureInfo.CurrentCulture), int.Parse(PerPageNum, CultureInfo.CurrentCulture)).ToSql();

                var lstModel = fsql.Select <Company>()
                               .Where(where)
                               .Count(out var total) //总记录数量
                               .OrderBy("Id asc")
                               .Page(int.Parse(CurPage, CultureInfo.CurrentCulture), int.Parse(PerPageNum, CultureInfo.CurrentCulture)).ToList();

                dictRtn.Add("GridData", lstModel);

                dictRtn.Add("Count", total);

                return(dictRtn);
            });

            //_logger.LogInformation("Search 结束运行");

            return(new JsonResult(ajaxRtnJsonData));
        }
Exemplo n.º 10
0
        public JsonResult Search(JObject jsonObj)
        {
            //_logger.LogInformation("开始运行");

            AjaxRtnJsonData ajaxRtnJsonData = HandlerHelper.ActionWrap(() =>
            {
                Dictionary <string, object> dictRtn = new Dictionary <string, object>();

                string PerPageNum = HandlerHelper.GetValue(jsonObj, "PerPageNum");
                string CurPage    = HandlerHelper.GetValue(jsonObj, "CurPage");
                string ArtTitle   = HandlerHelper.GetValue(jsonObj, "ArtTitle");
                string Tag        = HandlerHelper.GetValue(jsonObj, "Tag");

                string UserId = HandlerHelper.GetValue(jsonObj, "UserId");

                IFreeSql fsql = FreeSqlFactory.GetIFreeSql("rlfstock", FreeSql.DataType.Sqlite);

                //where 条件
                Expression <Func <StockArt, bool> > where = x => x.Deleted == 0;

                if (!string.IsNullOrEmpty(UserId))
                {
                    where = where.And(x => x.UserId == int.Parse(UserId));
                }

                //标题
                if (!string.IsNullOrEmpty(ArtTitle))
                {
                    string[] array = ArtTitle.Split(' ');

                    Expression <Func <StockArt, bool> > whereSub = x => x.ArtTitle.Contains(array[0]);
                    foreach (string one in array)
                    {
                        if (array[0].Equals(one))
                        {
                            continue;
                        }
                        whereSub = whereSub.And(x => x.ArtTitle.Contains(one));
                    }
                    where = where.And(whereSub);
                }
                //标签
                if (!string.IsNullOrEmpty(Tag))
                {
                    string[] array = Tag.Split(' ');

                    Expression <Func <StockArt, bool> > whereSub = x => x.Tag.Contains(array[0]);
                    foreach (string one in array)
                    {
                        if (array[0].Equals(one))
                        {
                            continue;
                        }
                        whereSub = whereSub.And(x => x.Tag.Contains(one));
                    }
                    where = where.And(whereSub);
                }

                var lstModel = fsql.Select <StockArt>()
                               .Where(where)
                               .Count(out var total) //总记录数量
                               .OrderBy("Id desc")
                               .Page(int.Parse(CurPage), int.Parse(PerPageNum)).ToList();

                dictRtn.Add("gridData", lstModel);

                dictRtn.Add("count", total);

                return(dictRtn);
            });

            //_logger.LogInformation("结束运行");

            return(new JsonResult(ajaxRtnJsonData));
        }
Exemplo n.º 11
0
        public JsonResult Upload(IFormFile file)
        {
            AjaxRtnJsonData ajaxRtnJsonData = HandlerHelper.ActionWrap(() =>
            {
                Dictionary <string, object> dictRtn = new Dictionary <string, object>();

                //NLog.LogManager.GetLogger("rlf").Debug("参数:");

                if (file == null)
                {
                    var files = Request.Form.Files;
                    if (files == null || files.Count <= 0)
                    {
                        throw new BusinessException("参数为空!");
                    }
                    else
                    {
                        file = files[0];
                    }
                }
                //if (jsonObj == null)
                //{
                //    throw new BusinessException("参数为空!");
                //}

                var fileDir = @"C:\rlf\uploadspace\image";

                if (!Directory.Exists(fileDir))
                {
                    Directory.CreateDirectory(fileDir);
                }

                //文件名称
                string strExt          = Path.GetExtension(file.FileName).ToLower();
                string projectFileName = Path.GetFileNameWithoutExtension(file.FileName) + "_" + System.DateTime.Now.ToString("yyyyMMddhhmmss") + strExt;

                //上传的文件的路径
                string filePath = fileDir + $@"\{projectFileName}";
                using (FileStream fs = System.IO.File.Create(filePath))
                {
                    file.CopyTo(fs);
                    fs.Flush();
                }

                string strImgPath = $"http://image.rlf99.com/image/{projectFileName}";
                dictRtn.Add("FileUrl", strImgPath);

                //文件类型
                string strFileType = string.Empty;
                if (strExt.IndexOf("jpg") > -1 ||
                    strExt.IndexOf("jpeg") > -1 ||
                    strExt.IndexOf("png") > -1)
                {
                    strFileType = "image";
                }
                if (strExt.IndexOf("mp4") > -1 ||
                    strExt.IndexOf("avi") > -1 ||
                    strExt.IndexOf("mpeg") > -1)
                {
                    strFileType = "video";
                }
                if (strExt.IndexOf("mp3") > -1 ||
                    strExt.IndexOf("wav") > -1 ||
                    strExt.IndexOf("m4a") > -1)
                {
                    strFileType = "audio";
                }
                dictRtn.Add("FileType", strFileType);

                return(dictRtn);
            });

            return(new JsonResult(ajaxRtnJsonData));
        }
Exemplo n.º 12
0
        public JsonResult SaveRow(JObject jsonObj)
        {
            //_logger.LogInformation("开始运行");

            AjaxRtnJsonData ajaxRtnJsonData = HandlerHelper.ActionWrap(() =>
            {
                //参数
                string Id = HandlerHelper.GetValue(jsonObj, "Id");

                string TradeTime         = HandlerHelper.GetValue(jsonObj, "TradeTime");
                string CompanyCode       = HandlerHelper.GetValue(jsonObj, "CompanyCode");
                string CompanyName       = HandlerHelper.GetValue(jsonObj, "CompanyName");
                string AgentType         = HandlerHelper.GetValue(jsonObj, "AgentType");
                string TradeVol          = HandlerHelper.GetValue(jsonObj, "TradeVol");
                string TradePriceAverage = HandlerHelper.GetValue(jsonObj, "TradePriceAverage");
                string TradePrice        = HandlerHelper.GetValue(jsonObj, "TradePrice");
                string Commission        = HandlerHelper.GetValue(jsonObj, "Commission");
                string TradeFees         = HandlerHelper.GetValue(jsonObj, "TradeFees");
                string StampTax          = HandlerHelper.GetValue(jsonObj, "StampTax");
                string TransferFees      = HandlerHelper.GetValue(jsonObj, "TransferFees");
                string TradeMkPlace      = HandlerHelper.GetValue(jsonObj, "TradeMkPlace");
                string Tag = HandlerHelper.GetValue(jsonObj, "Tag");

                string UserId = HandlerHelper.GetValue(jsonObj, "UserId");

                //更新/插入
                IFreeSql fsql = FreeSqlFactory.GetIFreeSql("rlfstock", FreeSql.DataType.Sqlite);

                TradeLog tradelog = null;

                if (string.IsNullOrEmpty(Id))
                {
                    tradelog = new TradeLog();
                }
                else
                {
                    tradelog = fsql.Select <TradeLog>().Where(t => t.Id == int.Parse(Id, CultureInfo.CurrentCulture)).ToOne();
                }

                //tradelog.UserId = int.Parse(UserId);
                tradelog.TradeTime         = Convert.ToDateTime(TradeTime, CultureInfo.CurrentCulture);
                tradelog.CompanyCode       = CompanyCode;
                tradelog.CompanyName       = CompanyName;
                tradelog.AgentType         = AgentType;
                tradelog.TradeVol          = int.Parse(TradeVol, CultureInfo.CurrentCulture);
                tradelog.TradePriceAverage = float.Parse(TradePriceAverage, CultureInfo.CurrentCulture);
                tradelog.TradePrice        = float.Parse(TradePrice, CultureInfo.CurrentCulture);

                tradelog.Commission   = float.Parse(Commission, CultureInfo.CurrentCulture);
                tradelog.TradeFees    = float.Parse(TradeFees, CultureInfo.CurrentCulture);
                tradelog.StampTax     = float.Parse(StampTax, CultureInfo.CurrentCulture);
                tradelog.TransferFees = float.Parse(TransferFees, CultureInfo.CurrentCulture);

                tradelog.TradeMkPlace = TradeMkPlace;
                tradelog.Tag          = Tag;

                if (!string.IsNullOrEmpty(Id))
                {
                    fsql.Update <TradeLog>().SetSource(tradelog).ExecuteAffrows();
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(UserId))
                    {
                        throw new BusinessException("用户Id为空!");
                    }
                    tradelog.UserId = int.Parse(UserId);
                    fsql.Insert <TradeLog>(tradelog).ExecuteAffrows();
                }

                return(null);
            });

            //_logger.LogInformation("结束运行");

            return(new JsonResult(ajaxRtnJsonData));
        }
Exemplo n.º 13
0
        public JsonResult SaveRow(JObject jsonObj)
        {
            //_logger.LogInformation("开始运行");

            AjaxRtnJsonData ajaxRtnJsonData = HandlerHelper.ActionWrap(() =>
            {
                //参数
                string Id = HandlerHelper.GetValue(jsonObj, "Id");

                string PositionStartTime = HandlerHelper.GetValue(jsonObj, "PositionStartTime");
                string PositionEndTime   = HandlerHelper.GetValue(jsonObj, "PositionEndTime");
                string CompanyCode       = HandlerHelper.GetValue(jsonObj, "CompanyCode");
                string CompanyName       = HandlerHelper.GetValue(jsonObj, "CompanyName");
                string PositionVol       = HandlerHelper.GetValue(jsonObj, "PositionVol");
                string CostPrice         = HandlerHelper.GetValue(jsonObj, "CostPrice");
                string CurrentPrice      = HandlerHelper.GetValue(jsonObj, "CurrentPrice");
                string TradeMkPlace      = HandlerHelper.GetValue(jsonObj, "TradeMkPlace");
                string Tag = HandlerHelper.GetValue(jsonObj, "Tag");

                string UserId = HandlerHelper.GetValue(jsonObj, "UserId");

                //更新/插入
                IFreeSql fsql = FreeSqlFactory.GetIFreeSql("rlfstock", FreeSql.DataType.Sqlite);

                PositionAnalysis model = null;

                if (string.IsNullOrEmpty(Id))
                {
                    model = new PositionAnalysis();
                }
                else
                {
                    model = fsql.Select <PositionAnalysis>().Where(t => t.Id == int.Parse(Id, CultureInfo.CurrentCulture)).ToOne();

                    //插入更新日志
                    if (model.Tag.IndexOf("更新日志") == -1)
                    {
                        model.Tag = "更新日志";
                        fsql.Insert <PositionAnalysis>(model).ExecuteAffrows();
                    }
                }

                //model.UserId = int.Parse(UserId);
                model.PositionStartTime = string.IsNullOrEmpty(PositionStartTime) ? (DateTime?)null : Convert.ToDateTime(PositionStartTime, CultureInfo.CurrentCulture);
                model.PositionEndTime   = string.IsNullOrEmpty(PositionEndTime) ? (DateTime?)null : Convert.ToDateTime(PositionEndTime, CultureInfo.CurrentCulture);
                model.CompanyCode       = CompanyCode;
                model.CompanyName       = CompanyName;
                model.PositionVol       = int.Parse(PositionVol, CultureInfo.CurrentCulture);
                model.CostPrice         = float.Parse(CostPrice, CultureInfo.CurrentCulture);
                model.CurrentPrice      = float.Parse(CurrentPrice, CultureInfo.CurrentCulture);
                model.TradeMkPlace      = TradeMkPlace;
                model.Tag = Tag;

                if (!string.IsNullOrEmpty(Id))
                {
                    fsql.Update <PositionAnalysis>().SetSource(model).ExecuteAffrows();
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(UserId))
                    {
                        throw new BusinessException("用户Id为空!");
                    }
                    model.UserId = int.Parse(UserId);
                    fsql.Insert <PositionAnalysis>(model).ExecuteAffrows();
                }

                return(null);
            });

            //_logger.LogInformation("结束运行");

            return(new JsonResult(ajaxRtnJsonData));
        }