Пример #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));
        }
Пример #2
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));
        }
Пример #3
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));
        }
Пример #4
0
        //登录用户名,密码验证
        public bool IsValid(LoginRequestDTO req)
        {
            //var logger = NLog.LogManager.GetLogger("rlf");

            if (req == null || string.IsNullOrEmpty(req.Username) || string.IsNullOrEmpty(req.Password))
            {
                return(false);
            }

            //logger.Debug(req.Username);

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

            Users users = fsql.Select <Users>().Where(t => t.UserName == req.Username && t.Password == req.Password).ToOne();

            if (users == null)
            {
                return(false);
            }

            //更新登录时间
            fsql.Update <Users>().Set(x => x.LoginTime, System.DateTime.Now).Where(x => x.Id == users.Id).ExecuteAffrows();

            return(true);
        }
Пример #5
0
        public string AppConfig()
        {
            string strRtn = "Get:处理完成";

            #region //添加数据库配置

            //sqlite3
            IFreeSql fsql = FreeSqlFactory.GetIFreeSql("rlfconfig", FreeSql.DataType.Sqlite);
            fsql.Insert <AppConfig>(
                new AppConfig()
            {
                AppKey   = "rlfstock",
                AppValue = @"Data Source=D:\sqlitedb\rlfstock.db;Initial Catalog=sqlite;Integrated Security=True;Pooling=true;Max Pool Size=10",
                DataType = (int)FreeSql.DataType.Sqlite
            }).ExecuteAffrows();

            //SqlServer
            //IFreeSql fsql = FreeSqlFactory.GetIFreeSql("rlfconfig", FreeSql.DataType.SqlServer);

            //fsql.Insert<AppConfig>(
            //    new AppConfig()
            //    {
            //        AppKey = "rlfstock",
            //        //AppValue = @"Data Source=D:\sqlitedb\rlfstock.db;Initial Catalog=sqlite;Integrated Security=True;Pooling=true;Max Pool Size=10",
            //        AppValue = @"Data Source=localhost,1433;Initial Catalog=rlfstock;User ID=sa;Password=Abc!@#123456;Connect Timeout=1200",
            //        DataType = (int)FreeSql.DataType.SqlServer

            //    }).ExecuteAffrows();

            #endregion

            return(strRtn);
        }
Пример #6
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));
        }
Пример #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));
        }
Пример #8
0
        //取得用户Id
        public int GetUserId(string strUserName)
        {
            //var logger = NLog.LogManager.GetLogger("rlf");

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

            Users users = fsql.Select <Users>().Where(t => t.UserName == strUserName).ToOne();

            return(users.Id);
        }
Пример #9
0
        public string Get()
        {
            string strRtn = "Get";

            //测试数据
            IFreeSql fsql = FreeSqlFactory.GetIFreeSql("rlfstock", FreeSql.DataType.Sqlite);

            var model = fsql.Select <TradeLog>()
                        .Where(t => t.Id == 1)
                        .ToOne();

            return(strRtn);
        }
Пример #10
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));
        }
Пример #11
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));
        }
Пример #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));
        }
Пример #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));
        }