public IList <EndAheadMinuteInfo> GetEndAheadMinuteList()
        {
            string    sql   = "SELECT DISTINCT [GameName],[SystemEndAheadMinute] FROM [T_Lottery_PlayTypes]";
            DataTable table = DbAccess.GetDataTableBySQL(sql);

            return(ORMHelper.DataTableToList <EndAheadMinuteInfo>(table));
        }
Esempio n. 2
0
        public AgentWithdrawRecordCollection GetAgentWithdrawRecord(string userId, DateTime fromDate, DateTime toDate, int pageIndex, int pageSize)
        {
            Session.Clear();
            int totalCount = 0;

            pageIndex = pageIndex < 0 ? 0 : pageIndex;
            pageSize  = pageSize > BusinessHelper.MaxPageSize ? BusinessHelper.MaxPageSize : pageSize;

            Dictionary <string, object> outputs;
            var query = CreateOutputQuery(Session.GetNamedQuery("P_Agent_GetWithdrawRecord"));

            query = query.AddInParameter("userId", userId);
            query = query.AddInParameter("fromDate", fromDate);
            query = query.AddInParameter("toDate", toDate);
            query = query.AddInParameter("pageIndex", pageIndex);
            query = query.AddInParameter("pageSize", pageSize);
            query = query.AddOutParameter("totalCount", "Int32");
            var ds = query.GetDataSet(out outputs);

            totalCount = UsefullHelper.GetDbValue <int>(outputs["totalCount"]);
            var list = ORMHelper.DataTableToList <AgentWithdrawRecordInfo>(ds.Tables[0]);

            var requestingMoney = UsefullHelper.GetDbValue <decimal>(ds.Tables[1].Rows[0]["RequestingMoney"]);
            var successMoney    = UsefullHelper.GetDbValue <decimal>(ds.Tables[1].Rows[0]["SuccessMoney"]);
            var refusedMoney    = UsefullHelper.GetDbValue <decimal>(ds.Tables[1].Rows[0]["RefusedMoney"]);

            return(new AgentWithdrawRecordCollection()
            {
                AgentWithdrawRecordList = list,
                TotalCount = totalCount,
                RequestingMoney = requestingMoney,
                SuccessMoney = successMoney,
                RefusedMoney = refusedMoney
            });
        }
        public IList <IssuseInfo> GetCommonIsuseList(int lotteryId)
        {
            StringBuilder sqlBuilder = new StringBuilder();

            sqlBuilder.AppendLine("SELECT * FROM (");
            sqlBuilder.AppendLine("SELECT * FROM (");
            sqlBuilder.AppendLine("	SELECT TOP 1 ID,Name,WinLotteryNumber,StartTime,EndTime,IsOpened ");
            sqlBuilder.AppendLine("	FROM T_Lottery_Isuses ");
            sqlBuilder.AppendLine("	WHERE LotteryID={0} AND   ISNULL(WinLotteryNumber, '')<>'' ");
            sqlBuilder.AppendLine("	ORDER BY EndTime DESC");
            sqlBuilder.AppendLine(")a UNION ");
            sqlBuilder.AppendLine("SELECT * FROM (");
            sqlBuilder.AppendLine("	SELECT TOP 1 ID,Name,WinLotteryNumber,StartTime,EndTime,IsOpened ");
            sqlBuilder.AppendLine("	FROM T_Lottery_Isuses ");
            sqlBuilder.AppendLine("	WHERE LotteryID={0} AND GETDATE()>EndTime  ");
            sqlBuilder.AppendLine("	ORDER BY EndTime DESC");
            sqlBuilder.AppendLine(")a UNION ");
            sqlBuilder.AppendLine("SELECT TOP 1 ID,Name,WinLotteryNumber,StartTime,EndTime,IsOpened ");
            sqlBuilder.AppendLine("FROM T_Lottery_Isuses ");
            sqlBuilder.AppendLine("WHERE LotteryID={0} and IsOpened = 0 AND GETDATE() BETWEEN StartTime AND EndTime ");
            sqlBuilder.AppendLine("UNION SELECT * FROM (	");
            sqlBuilder.AppendLine("	SELECT TOP 49 ID,Name,WinLotteryNumber,StartTime,EndTime,IsOpened ");
            sqlBuilder.AppendLine("	FROM T_Lottery_Isuses ");
            sqlBuilder.AppendLine("	WHERE LotteryID={0} AND GETDATE()<StartTime ");
            sqlBuilder.AppendLine("	ORDER BY StartTime");
            sqlBuilder.AppendLine(")a)b ORDER BY EndTime");
            DataTable table = DbAccess.GetDataTableBySQL(sqlBuilder.ToString(), lotteryId);

            return(ORMHelper.DataTableToList <IssuseInfo>(table));
        }
Esempio n. 4
0
        public IList <AgentSchemeInfo> GetAgentScheme(string agentId, string userId, string displayName, int progressStatus, int ticketStatus
                                                      , DateTime fromDate, DateTime toDate, int pageIndex, int pageSize, out int totalCount, out int totalUser, out int totalScheme, out decimal totalMoney1)
        {
            Session.Clear();

            pageIndex = pageIndex < 0 ? 0 : pageIndex;
            pageSize  = pageSize > BusinessHelper.MaxPageSize ? BusinessHelper.MaxPageSize : pageSize;

            Dictionary <string, object> outputs;
            var query = CreateOutputQuery(Session.GetNamedQuery("P_Agent_GetScheme"));

            query = query.AddInParameter("agentId", agentId);
            query = query.AddInParameter("userId", userId);
            query = query.AddInParameter("displayName", displayName);
            query = query.AddInParameter("progressStatus", progressStatus);
            query = query.AddInParameter("ticketStatus", ticketStatus);
            query = query.AddInParameter("fromDate", fromDate);
            query = query.AddInParameter("toDate", toDate);
            query = query.AddInParameter("pageIndex", pageIndex);
            query = query.AddInParameter("pageSize", pageSize);
            query = query.AddOutParameter("totalCount", "Int32");
            var ds = query.GetDataSet(out outputs);

            totalCount  = UsefullHelper.GetDbValue <int>(outputs["totalCount"]);
            totalUser   = UsefullHelper.GetDbValue <int>(ds.Tables[1].Rows[0]["TotalUser"]);
            totalScheme = UsefullHelper.GetDbValue <int>(ds.Tables[1].Rows[0]["TotalScheme"]);
            totalMoney1 = UsefullHelper.GetDbValue <decimal>(ds.Tables[1].Rows[0]["TotalMoney1"]);
            return(ORMHelper.DataTableToList <AgentSchemeInfo>(ds.Tables[0]));
        }
Esempio n. 5
0
        /// <summary>
        /// 构造一个实体的数据源节点。
        /// </summary>
        /// <param name="repository">本实体数据源来自于这个实体仓库。</param>
        /// <param name="alias">同一个实体仓库可以表示多个不同的数据源。这时,需要这些不同的数据源指定不同的别名。</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">entityRepository</exception>
        public ITableSource Table(IRepository repository, string alias = null)
        {
            if (repository == null)
            {
                throw new ArgumentNullException("entityRepository");
            }

            var dbTable = (repository as IRepositoryInternal).RdbDataProvider.DbTable;

            if (dbTable == null)
            {
                ORMHelper.ThrowBasePropertyNotMappedException(repository.EntityType);
            }

            //构造一个 EntitySource 对象。
            //在构造 TableSource 时,不必立刻为所有属性生成相应的列。必须使用懒加载。
            var table = new TableSource();

            table._dbTable = dbTable;

            var res = table as ITableSource;

            res.EntityRepository = repository;
            table.TableName      = dbTable.Name;
            table.Alias          = alias;

            return(table);
        }
        protected override void NoTask()
        {
            var first = ORMHelper.GetModel <Tmall_Skechers_Detail>(" where LastUpdate > '2017-03-19 5:51:33' and LastUpdate < '2017-03-19 23:59:34'");
            Dictionary <Int64, Tmall_Skechers_Detail> dic_First = first.ToDictionary(key => key.Id, Tmall_Skechers_Detail => Tmall_Skechers_Detail);

            var last = ORMHelper.GetModel <Tmall_Skechers_Detail>(" where LastUpdate > '2017-03-27 0:00:00' and LastUpdate < '2017-03-28 23:59:34'");
            Dictionary <Int64, Tmall_Skechers_Detail> dic_Last = last.ToDictionary(key => key.Id, Tmall_Skechers_Detail => Tmall_Skechers_Detail);

            List <Tmall_Skechers_Detail> putAway  = new List <Tmall_Skechers_Detail>();
            List <Tmall_Skechers_Detail> saleOut  = new List <Tmall_Skechers_Detail>();
            List <Tmall_Skechers_Detail> onSaling = new List <Tmall_Skechers_Detail>();

            #region  架
            using (StreamWriter sw = new StreamWriter("新品.csv", false, Encoding.Default))
            {
                sw.WriteLine("{0},{1},{2},{3},{4},{5},{6}", "商品ID", "首页价格", "本日月销量", "总销量", "库存", "月评价", "总评价");
                foreach (var it in last)
                {
                    if (!dic_First.ContainsKey(it.Id))
                    {
                        sw.WriteLine("{0},{1},{2},{3},{4},{5},{6}", "=\"" + it.Id + "\"", it.indexPrice, it.Sales_Mon, it.Sales_Total, it.Repertory, it.Comments_Mon, it.Comments_Total);
                    }
                }
                sw.Close();
                ShowMsg("新上架写入完成");
            }
            #endregion

            #region  架
            using (StreamWriter sw = new StreamWriter("下架.csv", false, Encoding.Default))
            {
                sw.WriteLine("{0},{1},{2},{3},{4},{5},{6}", "商品ID", "首页价格", "本日月销量", "总销量", "库存", "月评价", "总评价");
                foreach (var it in first)
                {
                    if (!dic_Last.ContainsKey(it.Id))
                    {
                        sw.WriteLine("{0},{1},{2},{3},{4},{5},{6}", "=\"" + it.Id + "\"", it.indexPrice, it.Sales_Mon, it.Sales_Total, it.Repertory, it.Comments_Mon, it.Comments_Total);
                    }
                }
                sw.Close();
                ShowMsg("下架写入完成");
            }
            #endregion

            #region 热卖
            using (StreamWriter sw = new StreamWriter("热卖.csv", false, Encoding.Default))
            {
                sw.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}", "商品ID", "首页价格(前)", "首页价格(本)", "上期月销量", "本日月销量", "上期总销量", "总销量", "上期库存", "库存", "月评价", "总评价");
                foreach (var it in last)
                {
                    if (dic_First.ContainsKey(it.Id))
                    {
                        sw.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}", "=\"" + it.Id + "\"", dic_First[it.Id].indexPrice, it.indexPrice, dic_First[it.Id].Sales_Mon, it.Sales_Mon, dic_First[it.Id].Sales_Total, it.Sales_Total, dic_First[it.Id].Repertory, it.Repertory, it.Comments_Mon, it.Comments_Total);
                    }
                }
                sw.Close();
                ShowMsg("热卖商品写入完成");
            }
            #endregion
        }
Esempio n. 7
0
        public List <OCAagentDetailInfo> QueryAgentDetail(string agentId, string gameCode, DateTime starTime, DateTime endTime, int pageIndex, int pageSize, out int totalCount, out decimal totalBuyMoney
                                                          , out decimal totalBounsMoney, out decimal totalRedBagAwardsMoney, out decimal totalBonusAwardsMoney, out decimal totalFillMoney, out decimal totalWithdrawalsMoney)
        {
            Session.Clear();
            starTime = starTime.Date;
            endTime  = endTime.AddDays(1).Date;
            // 通过数据库存储过程进行查询
            var query = CreateOutputQuery(Session.GetNamedQuery("P_Agent_QueryAgentDetail"))
                        .AddInParameter("agentId", agentId)
                        .AddInParameter("gameCode", gameCode)
                        .AddInParameter("starTime", starTime)
                        .AddInParameter("endTime", endTime)
                        .AddInParameter("pageIndex", pageIndex)
                        .AddInParameter("pageSize", pageSize);
            var ds = query.GetDataSet();

            totalFillMoney = ds.Tables[0].Rows[0]["TotalFillMoney"].ToString() == string.Empty ? 0M : (decimal)ds.Tables[0].Rows[0]["TotalFillMoney"];
            totalBuyMoney  = ds.Tables[1].Rows[0]["TotalBuyMoney"].ToString() == string.Empty ? 0M : (decimal)ds.Tables[1].Rows[0]["TotalBuyMoney"];

            totalBounsMoney        = ds.Tables[1].Rows[0]["TotalBounsMoney"].ToString() == string.Empty ? 0M : (decimal)ds.Tables[1].Rows[0]["TotalBounsMoney"];
            totalRedBagAwardsMoney = ds.Tables[1].Rows[0]["TotalRedBagAwardsMoney"].ToString() == string.Empty ? 0M : (decimal)ds.Tables[1].Rows[0]["TotalRedBagAwardsMoney"];
            totalBonusAwardsMoney  = ds.Tables[1].Rows[0]["TotalBonusAwardsMoney"].ToString() == string.Empty ? 0M : (decimal)ds.Tables[1].Rows[0]["TotalBonusAwardsMoney"];

            totalCount            = ds.Tables[2].Rows[0]["TotalCount"].ToString() == string.Empty ? 0 : (int)ds.Tables[2].Rows[0]["TotalCount"];
            totalWithdrawalsMoney = ds.Tables[4].Rows[0]["TotalWithdrawalsMoney"].ToString() == string.Empty ? 0M : (decimal)ds.Tables[4].Rows[0]["TotalWithdrawalsMoney"];
            return(ORMHelper.DataTableToInfoList <OCAagentDetailInfo>(ds.Tables[3]).ToList());
        }
Esempio n. 8
0
        /// <summary>
        /// 设置一个命令
        /// </summary>
        /// <param name="ob"></param>
        /// <param name="command"></param>
        /// <param name="TagetType"></param>
        /// <param name="cxt"></param>
        public void SetValues(object ob, System.Data.SqlClient.SqlCommand command, Type TagetType, String ParamPre = "", bool GernerateSerialNo = false, IDBContext cxt = null)
        {
            var Propertitest = TagetType.GetProperties();
            var factory      = new MSSQLScriptSqlPatternFactory();

            foreach (var property in Propertitest)
            {
                foreach (var colattr in helper.GetColNameAttributes(property))
                {
                    if (colattr.NoMap)
                    {
                        continue;
                    }
                    var    paramName  = "@" + ParamPre + helper.GetColName(colattr, property);
                    object propertyob = new ORMHelper().GetDbObject(property, ob, colattr.PropertyName) ?? "";


                    if (command.Parameters.Contains(paramName))
                    {
                        if (GernerateSerialNo && cxt != null
                            &&
                            String.IsNullOrEmpty(
                                //(command.Parameters[paramName].Value ?? ""
                                (new ORMHelper().GetDbObject(property, ob, colattr.PropertyName) ?? ""

                                ).ToString()
                                )
                            == true

                            )
                        {
                            var auto = property.GetCustomAttributes(typeof(SerialNoObject), true);
                            if (auto.Length > 0)
                            {
                                var seriSetting = auto[0] as SerialNoObject;
                                command.Parameters[paramName].Value = cxt.GetSerialNo(seriSetting.SerialPre, seriSetting.Len, seriSetting.DateFormateStr, "");
                                property.SetValue(ob,
                                                  command.Parameters[paramName].Value, null);
                            }
                            else
                            {
                                command.Parameters[paramName].Value = propertyob;
                            }

                            //else if(String.IsNullOrEmpty( (command.Parameters[paramName].Value ?? "").ToString())==false)
                            //command.Parameters[paramName].Value = new ORMHelper().GetDbObject(property, ob, colattr.PropertyName) ?? "";
                        }
                        else
                        {
                            var insertDb = new ORMHelper().GetDbObject(property, ob, colattr.PropertyName);
                            if (insertDb is DateTime && insertDb != null && String.IsNullOrEmpty(colattr.FormatStr) == false)
                            {
                                insertDb = ((DateTime)insertDb).ToString(colattr.FormatStr);
                            }
                            command.Parameters[paramName].Value = insertDb ?? "";
                        }
                    }
                }
            }
        }
        protected override void Fun(List <urlInfo> task)
        {
            string date    = DateTime.Now.Date.ToShortDateString() + " 0:00:00";
            var    gotList = ORMHelper.GetModel <Tmall_Name_Anta>(" where State = '" + (Program.UpdateTimes + 1) + "' ");
            Dictionary <UInt64, Tmall_Name_Anta> dic_Got = new Dictionary <ulong, Tmall_Name_Anta>();

            foreach (var dg in gotList)
            {
                if (!dic_Got.ContainsKey(dg.Id))
                {
                    dic_Got.Add(dg.Id, dg);
                }
            }
            int a = 0;
            List <Tmall_Detail_Anta> dsList = new List <Tmall_Detail_Anta>();
            List <Tmall_Name_Anta>   nsList = new List <Tmall_Name_Anta>();

            foreach (var t in task)
            {
                a++;
                ShowMsg(t.dataId.ToString());
                if (dic_Got.ContainsKey(t.dataId))
                {
                    continue;
                }

                var result           = PageDataHelper.GotDetailData(t);
                Tmall_Detail_Anta td = new Tmall_Detail_Anta();
                Tmall_Name_Anta   tn = new Tmall_Name_Anta();
                td.Id             = tn.Id = (UInt64)result.Id;
                tn.Name           = result.Name;
                td.LastUpdate     = tn.LastUpdate = result.LastUpdate;
                td.IndexPrice     = result.IndexPrice;
                td.AvePrice       = result.AvePrice;
                td.Comments_Mon   = result.IndexComment;
                td.Comments_Total = result.TotalComment;
                td.Repertory      = (uint)result.Repertory;
                td.Sales_Mon      = result.MonSales;
                td.Sales_Total    = result.TotalSales;
                tn.State          = td.State = byte.Parse(Program.UpdateTimes);
                ShowMsg(t.dataId + "  " + t.name + " " + td.AvePrice + " " + td.Sales_Mon + " " + td.Comments_Mon + td.LastUpdate);
                nsList.Add(tn);
                dsList.Add(td);
                Random random   = new Random();
                int    interval = random.Next(25, 76);
                ShowMsg(interval.ToString());
                System.Threading.Thread.Sleep(interval * 100);
                if (a == 50)
                {
                    ShowMsg("<加入50条数据>");
                    DataToBase.SaveData(nsList);
                    DataToBase.SaveData(dsList);
                }
            }
            //更新配置文件
            CC.Utility.iniHelper ini = new CC.Utility.iniHelper(Program.FilePath);
            ini.Write("state", "times", (byte.Parse(Program.UpdateTimes) + 1).ToString());
            driver.Close();
        }
Esempio n. 10
0
        protected override void Fun(List <urlInfo> task)
        {
            System.Threading.Thread.Sleep(10 * 1000);
            string date    = DateTime.Now.Date.AddDays(-1).ToShortDateString() + " 0:00:00";
            var    gotList = ORMHelper.GetModel <Tmall_Skechers_Name>(" where State =" + Program.UpdateTimes);
            Dictionary <Int64, Tmall_Skechers_Name> dic_Got = new Dictionary <long, Tmall_Skechers_Name>();

            foreach (var dg in gotList)
            {
                if (!dic_Got.ContainsKey(dg.Id))
                {
                    dic_Got.Add(dg.Id, dg);
                }
            }

            List <Tmall_Skechers_Name>   nsList = new List <Tmall_Skechers_Name>();
            List <Tmall_Skechers_Detail> dsList = new List <Tmall_Skechers_Detail>();
            int a = 0;

            foreach (var t in task)
            {
                ShowMsg(t.dataId.ToString());
                if (dic_Got.ContainsKey((long)t.dataId))
                {
                    continue;
                }
                //if (++a == 20)
                //{
                //    System.Threading.Thread.Sleep(60 * 1000);
                //    a = 0;
                //}
                var result = PageDataHelper.GotDetailData(t);
                Tmall_Skechers_Detail td = new Tmall_Skechers_Detail();
                Tmall_Skechers_Name   tn = new Tmall_Skechers_Name();
                td.Id             = tn.Id = (Int64)result.Id;
                tn.Name           = result.Name;
                td.LastUpdate     = tn.LastUpdate = result.LastUpdate;
                td.indexPrice     = result.IndexPrice;
                td.AvePrice       = result.AvePrice;
                td.Comments_Mon   = result.IndexComment;
                td.Comments_Total = result.TotalComment;
                td.Repertory      = (int)result.Repertory;
                td.Sales_Mon      = result.MonSales;
                tn.State          = td.State = sbyte.Parse(Program.UpdateTimes);
                td.Sales_Total    = result.TotalSales;
                ShowMsg(t.dataId + "  " + t.name + " " + td.AvePrice + " " + td.Sales_Mon + " " + td.Comments_Mon + td.LastUpdate);
                nsList.Add(tn);
                dsList.Add(td);
                Random random   = new Random();
                int    interval = random.Next(35, 80);
                ShowMsg(interval.ToString());
                System.Threading.Thread.Sleep(interval * 100);
            }
            DataToBase.SaveData(nsList);
            DataToBase.SaveData(dsList);
            //更新配置文件
            CC.Utility.iniHelper ini = new CC.Utility.iniHelper(Program.FilePath);
            ini.Write("state", "times", (sbyte.Parse(Program.UpdateTimes) + 1).ToString());
        }
Esempio n. 11
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ob"></param>
        /// <returns></returns>
        /// <remarks>
        /// 2013.8.7</remarks>
        public System.Data.IDbCommand GenerateSaveSql <T>(T ob)
        {
            if (!updateCommand.ContainsKey(typeof(T)))
            {
                //初始化一个Command
                System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand();
                var TargetType = typeof(T);
                //得到表名
                var    factory    = new MSSQLScriptSqlPatternFactory();//.GetTable(TargetType);
                var    table      = helper.GetTableAttribute(TargetType);
                String TableName  = helper.GetTable(TargetType);
                var    Properties = TargetType.GetProperties();
                String Cols       = "";


                for (int i = 0; i < Properties.Length; i++)
                {
                    var attribute = helper.GetColNameAttributes(Properties[i]);

                    string ColName = "";
                    if (attribute.Count > 0)
                    {
                        for (int j = 0; j < attribute.Count; j++)
                        {
                            var Col = (ColumnAttribute)attribute[j];
                            if (Col.IsAutoGenerate != GenerationType.Never || Col.NoMap == true || Col.IsIdentify)
                            {
                                continue; //如果自动生成
                            }
                            else
                            {
                                ColName = helper.GetColName(Col, Properties[i]);
                            }
                            String paramName = "@" + ColName;
                            // ColName = factory.GetColName(Col, Properties[i]);
                            var dbValue = new ORMHelper().GetDbObject(Properties[i], ob, Col.PropertyName);
                            //      if (dbValue != null)
                            //  {
                            Cols += "[" + ColName + "]=" + paramName + ",";
                            command.Parameters.Add(new System.Data.SqlClient.SqlParameter(paramName, dbValue ?? ""));
                        }
                    }
                }

                var parity = new MSSQLScriptSqlPatternFactory().GetExistSql <T>(Properties, ob, true, "Pre");
                command.Parameters.AddRange(parity.Params.ToArray());
                command.CommandText = "Update " + TableName + " SET " + Cols.Substring(0, Cols.Length - 1) + " WHERE " + parity.SqlScript;
                updateCommand.Add(typeof(T), command);
            }

            var upatecommand = (updateCommand[typeof(T)] as SqlCommand).Clone();

            SetValues <T>(ob, upatecommand);
            SetValues <T>(ob, upatecommand, "Pre");
            // + " SET " + Cols.Substring(0, Cols.Length - 1) + " WHERE " + parity.SqlScript;
            return(upatecommand);
        }
Esempio n. 12
0
 static MSSSqlCommandGenerater()
 {
     insertCommand = new Hashtable();
     SeletctAutoGernertateCommands = new Hashtable();
     selectedCommand     = new Hashtable();
     selectedItemsCommad = new Hashtable();
     updateCommand       = new Hashtable();
     deleteCommand       = new Hashtable();
     helper = new ORMHelper();
 }
Esempio n. 13
0
        /// <summary>
        /// 数据库通用方法
        /// </summary>
        /// <typeparam name="T">数据集合类型</typeparam>
        /// <param name="datas">数据集</param>
        public static void SaveData <T>(IEnumerable <T> datas)
            where T : CC.ORM.SqlDataBase, new()
        {
            Console.WriteLine("开始数据库事务...");
            var dc = ORMHelper.DefaultDataFactory.Create();

            dc.BeginTransaction();
            foreach (var item in datas)
            {
                ORMHelper.InsertOrUpdate(item, dc);
            }
            dc.Commit();
            dc.Close();
        }
Esempio n. 14
0
        /// <summary>
        /// 数据库录入
        /// </summary>
        /// <param name="list">缓存列表</param>
        static void DataToBase(List <baidutb> list)
        {
            MysqlFactory.Instance.DefaultConnStr = MysqlFactory.GetConnStr("localhost", "root", "456123", "fortest");
            ORMHelper.DefaultDataFactory         = MysqlFactory.Instance;
            DataControl dc = ORMHelper.DefaultDataFactory.Create();

            dc.BeginTransaction();
            foreach (var item in list)
            {
                ORMHelper.InsertOrUpdate(item, dc);
            }
            dc.Commit();
            dc.Close();
        }
Esempio n. 15
0
        public T GetLastOdds <T>(string oddsType, string matchId, bool IsDS)
            where T : JingCai_Odds, new()
        {
            Session.Clear();
            var isDS = IsDS == true ? 1 : 0;
            // 通过数据库存储过程进行查询
            var query = CreateOutputQuery(Session.GetNamedQuery("P_JCZQ_GetLastOddsByMatchId"))
                        .AddInParameter("MatchId", matchId)
                        .AddInParameter("OddsType", oddsType)
                        .AddInParameter("IsDS", isDS);

            var dt = query.GetDataTable();

            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            return(ORMHelper.ConvertDataRowToInfo <T>(dt.Rows[0]));
        }
Esempio n. 16
0
        public IList <AgentWaitingCommissionOrderInfo> QueryAgentWaitingCommissionOrderList(DateTime fromDate, DateTime toDate, int pageIndex, int pageSize, out int totalCount)
        {
            Session.Clear();

            pageIndex = pageIndex < 0 ? 0 : pageIndex;
            pageSize  = pageSize > BusinessHelper.MaxPageSize ? BusinessHelper.MaxPageSize : pageSize;
            Dictionary <string, object> outputs;
            var query = CreateOutputQuery(Session.GetNamedQuery("P_Agent_QueryWaitingCommissionOrderList"));

            query = query.AddInParameter("fromDate", fromDate);
            query = query.AddInParameter("toDate", toDate);
            query = query.AddInParameter("pageIndex", pageIndex);
            query = query.AddInParameter("pageSize", pageSize);
            query = query.AddOutParameter("totalCount", "Int32");
            var dt = query.GetDataTable(out outputs);

            totalCount = UsefullHelper.GetDbValue <int>(outputs["totalCount"]);

            return(ORMHelper.DataTableToList <AgentWaitingCommissionOrderInfo>(dt));
        }
Esempio n. 17
0
        /// <summary>
        /// 查询代理用户
        /// </summary>
        public IList <AgentUserInfo> GetAgentUserByKeyword(string keyword, int isAgent, string pAgentId, int pageIndex, int pageSize, out int totalCount)
        {
            Session.Clear();

            pageIndex = pageIndex < 0 ? 0 : pageIndex;
            pageSize  = pageSize > BusinessHelper.MaxPageSize ? BusinessHelper.MaxPageSize : pageSize;
            Dictionary <string, object> outputs;
            var query = CreateOutputQuery(Session.GetNamedQuery("P_Agent_QueryUserList"));

            query = query.AddInParameter("keyword", keyword);
            query = query.AddInParameter("pAgentId", pAgentId);
            query = query.AddInParameter("isAgent", isAgent);
            query = query.AddInParameter("pageIndex", pageIndex);
            query = query.AddInParameter("pageSize", pageSize);
            query = query.AddOutParameter("totalCount", "Int32");
            var dt = query.GetDataTable(out outputs);

            totalCount = UsefullHelper.GetDbValue <int>(outputs["totalCount"]);
            return(ORMHelper.DataTableToList <AgentUserInfo>(dt));
        }
Esempio n. 18
0
        protected FacadeException HandleException(string category, string errMsg, Exception innerException, params object[] objs)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(errMsg);
            if (objs != null && objs.Length > 0)
            {
                foreach (object obj in objs)
                {
                    sb.AppendLine(ORMHelper.GetEntityInfoMessage(objs[0]));
                    sb.AppendLine();
                }
            }
            FacadeException ex = new FacadeException(sb.ToString(), innerException);

            if (LogWriter != null)
            {
                LogWriter.Write(category, errMsg, ex);
            }
            return(ex);
        }
Esempio n. 19
0
        public IList <AgentCommissionDetailInfo> GetCommissionReport(string userId, string displayName, DateTime fromDate, DateTime toDate, string pAgentId, int applyState, out decimal saleTotal, out decimal actualCommissionTotal)
        {
            Session.Clear();

            Dictionary <string, object> outputs;
            var query = CreateOutputQuery(Session.GetNamedQuery("P_Agent_GetCommissionReport"));

            query = query.AddInParameter("pAgentId", pAgentId);
            query = query.AddInParameter("userId", userId);
            query = query.AddInParameter("displayName", displayName);
            query = query.AddInParameter("fromDate", fromDate);
            query = query.AddInParameter("toDate", toDate);
            query = query.AddInParameter("applyState", applyState);
            query = query.AddOutParameter("saleTotal", "Decimal");
            query = query.AddOutParameter("actualCommissionTotal", "Decimal");
            var dt   = query.GetDataTable(out outputs);
            var list = ORMHelper.DataTableToList <AgentCommissionDetailInfo>(dt);

            saleTotal             = list.Sum(o => o.Sale);
            actualCommissionTotal = list.Sum(o => o.BeforeCommission);
            return(list);
        }
Esempio n. 20
0
        public IList <AgentCommissionDetailInfo> GetAgentCommissionDetailList(string pAgentId, string userId, string displayName, DateTime fromDate, DateTime toDate, int pageIndex, int pageSize, int applyState, out int totalCount)
        {
            Session.Clear();

            pageIndex = pageIndex < 0 ? 0 : pageIndex;
            pageSize  = pageSize > BusinessHelper.MaxPageSize ? BusinessHelper.MaxPageSize : pageSize;
            Dictionary <string, object> outputs;
            var query = CreateOutputQuery(Session.GetNamedQuery("P_Agent_QueryCommissionDetailList"));

            query = query.AddInParameter("fromDate", fromDate);
            query = query.AddInParameter("toDate", toDate);
            query = query.AddInParameter("pAgentId", pAgentId);
            query = query.AddInParameter("userId", userId);
            query = query.AddInParameter("displayName", displayName);
            query = query.AddInParameter("pageIndex", pageIndex);
            query = query.AddInParameter("pageSize", pageSize);
            query = query.AddInParameter("applyState", applyState);
            query = query.AddOutParameter("totalCount", "Int32");
            var dt = query.GetDataTable(out outputs);

            totalCount = UsefullHelper.GetDbValue <int>(outputs["totalCount"]);
            return(ORMHelper.DataTableToList <AgentCommissionDetailInfo>(dt));
        }
Esempio n. 21
0
        public AgentCommissionDetailCollection GetAgentGetCommissionReportList(string gameCode, string gameType, string pAgentId, string userId, string displayName, int category, DateTime fromDate, DateTime toDate, int pageIndex, int pageSize)
        {
            Session.Clear();

            pageIndex = pageIndex < 0 ? 0 : pageIndex;
            pageSize  = pageSize > BusinessHelper.MaxPageSize ? BusinessHelper.MaxPageSize : pageSize;
            Dictionary <string, object> outputs;
            var query = CreateOutputQuery(Session.GetNamedQuery("P_Agent_GetCommissionReportList"));

            query = query.AddInParameter("GameCode", gameCode);
            query = query.AddInParameter("GameType", gameType);
            query = query.AddInParameter("PAgentId", pAgentId);
            query = query.AddInParameter("UserId", userId);
            query = query.AddInParameter("DisplayName", displayName);
            query = query.AddInParameter("Category", category);
            query = query.AddInParameter("FromDate", fromDate);
            query = query.AddInParameter("ToDate", toDate);
            query = query.AddInParameter("PageIndex", pageIndex);
            query = query.AddInParameter("PageSize", pageSize);
            query = query.AddOutParameter("TotalCount", "Int32");
            var ds                    = query.GetDataSet(out outputs);
            var totalCount            = UsefullHelper.GetDbValue <int>(outputs["TotalCount"]);
            var listReport            = ORMHelper.DataTableToList <AgentCommissionDetailInfo>(ds.Tables[0]);
            var list                  = ORMHelper.DataTableToList <AgentCommissionDetailInfo>(ds.Tables[1]);
            var saleTotal             = listReport.Sum(o => o.Sale);
            var actualCommissionTotal = listReport.Sum(o => o.BeforeCommission);

            return(new AgentCommissionDetailCollection()
            {
                AgentCommissionDetailList = list,
                AgentCommissionReport = listReport,
                ActualCommissionTotal = actualCommissionTotal,
                SaleTotal = saleTotal,
                TotalCount = totalCount
            });
        }
Esempio n. 22
0
        public System.Data.IDbCommand GenerateDynamicUpateSql <T>(T ob)
        {
            //初始化一个Command
            System.Data.SqlClient.SqlCommand command = null;
            var TargetType     = typeof(T);
            var patternfactory = new MSSQLScriptSqlPatternFactory();
            var helper         = new ORMHelper();

            command = new System.Data.SqlClient.SqlCommand();
            String TableName  = helper.GetTable(TargetType);
            var    Properties = TargetType.GetProperties();
            String Cols       = "";

            String update = "SELECT ";

            String WhereSql = "";

            for (int i = 0; i < Properties.Length; i++)
            {
                var attribute = Properties[i].GetCustomAttributes(typeof(DynamicColumnAttribute), true);
                if (attribute.Length > 0)
                {
                    var dynamicAttr = attribute[0] as DynamicColumnAttribute;
                    var proerpty    = TargetType.GetProperty(dynamicAttr.SourcePropertyName);
                    if (proerpty != null)
                    {
                        var colattributes = helper.GetColNameAttributes(Properties[i]);

                        if (colattributes.Count > 0)
                        {
                            if (colattributes[0].NoMap)
                            {
                                continue;
                            }
                            else
                            {
                                string ColName   = helper.GetColName(colattributes[0], Properties[i]);
                                String paramName = "@" + dynamicAttr.SourcePropertyName;
                                ColName = TableName + ".[" + ColName + "]";
                                command.Parameters.Add(paramName, proerpty.GetValue(ob, new object[] {}));
                                Cols += ColName + "=" + ColName + (dynamicAttr.Operation == DanymicOperationType.Add?"+":"-") + paramName + ",";
                            }
                        }
                    }
                }
                else
                {
                    var cols = helper.GetColNameAttributes(Properties[i]);
                    if (cols.Count > 0)
                    {
                        foreach (var col in cols)
                        {
                            if (col.IsKey == true && String.IsNullOrEmpty(col.KeyGroupName))
                            {
                                var colname   = helper.GetColName(col, Properties[i]);
                                var paramName = "@Pre" + colname;
                                WhereSql = " WHERE " + TableName + ".[" + colname + "]=" + paramName;
                                command.Parameters.Add(paramName, Properties[i].GetValue(ob, new object[] {}));
                            }
                        }
                    }
                }
            }

            command.CommandText = "UPDATE " + TableName + " SET " + Cols.Substring(0, Cols.Length - 1) + WhereSql;
            //selectedCommand.Add(TargetType, command);
            return(command);
        }
Esempio n. 23
0
        public static void GotResultCsv(string excelPath, string tableName, string excelName)
        {
            var dic_Excel = ExcelToDs(excelPath, tableName, excelName);
            List <Tmall_Detail_Anta> orm_List = ORMHelper.GetModel <Tmall_Detail_Anta>("where  LastUpdate > '2017-04-09 00:00:00'");
            var orm_Dic      = orm_List.ToDictionary(key => key.Id, Tmall_Detail_Anta => Tmall_Detail_Anta);
            var dic_Xiajia   = new Dictionary <ulong, string[]>();
            var dic_Shangjia = new Dictionary <ulong, Tmall_Detail_Anta>();
            var dic_SjNo     = new Dictionary <ulong, Tmall_Detail_Anta>();//上期没有数据但是以前有的

            #region 本次没有 上次-本次
            foreach (var del in dic_Excel)
            {
                if (!orm_Dic.ContainsKey((UInt64)del.Key))
                {
                    dic_Xiajia.Add((UInt64)del.Key, del.Value);
                }
            }
            #endregion

            #region 本次新上
            foreach (var od in orm_Dic)
            {
                if (!dic_Excel.ContainsKey((Int64)od.Key))
                {
                    dic_Shangjia.Add(od.Key, od.Value);
                }
            }
            #endregion
            string date = DateTime.Now.Date.ToShortDateString();
            using (System.IO.StreamWriter sw = new System.IO.StreamWriter("result_Anta.csv", false, Encoding.UTF8))
            {
                sw.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18}", "商品ID", "首页价格(周)", "", "", "首页价格(月)", "期末月销量", "", "", "期末总销量", "", "", "库存", "", "", "月评论", "总评论", "期末月销售额", "期间销售量", "期间销售额");
                sw.WriteLine("{0}", "新品");
                List <long> have = new List <long>();
                foreach (var dsj in dic_Shangjia)
                {
                    if (IsNew((long)dsj.Key, dsj.Value.LastUpdate, "tmall_detail_anta"))
                    {
                        have.Add((long)dsj.Key);
                        sw.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15}", "=" + "\"" + dsj.Key + "\"", 0, 0, dsj.Value.IndexPrice, 0, 0, 0, dsj.Value.Sales_Mon, 0, 0, dsj.Value.Sales_Total, 0, 0, dsj.Value.Repertory, dsj.Value.Comments_Mon, dsj.Value.Comments_Total);
                    }
                    else
                    {
                        dic_SjNo.Add(dsj.Key, dsj.Value);
                    }
                }
                sw.WriteLine("{0}", "旧款");
                foreach (var dx in dic_Xiajia)
                {
                    have.Add((long)dx.Key);
                    sw.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15}", "=" + "\"" + dx.Key + "\"", dx.Value[1], dx.Value[2], 0, dx.Value[3], dx.Value[4], dx.Value[5], 0, dx.Value[6], dx.Value[7], 0, dx.Value[8], dx.Value[9], 0, 0, 0, 0, 0);
                }
                sw.WriteLine("{0}", "热卖");
                foreach (var die in dic_Excel)
                {
                    if (!have.Contains((long)die.Key))
                    {
                        sw.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15}", "=" + "\"" + die.Key + "\"", die.Value[1], die.Value[2], orm_Dic[(ulong)die.Key].IndexPrice, die.Value[3], die.Value[4], die.Value[5], orm_Dic[(ulong)die.Key].Sales_Mon, die.Value[6], die.Value[7], orm_Dic[(ulong)die.Key].Sales_Total, die.Value[8], die.Value[9], orm_Dic[(ulong)die.Key].Repertory, orm_Dic[(ulong)die.Key].Comments_Mon, orm_Dic[(ulong)die.Key].Comments_Total, 0, 0);
                    }
                }
                sw.WriteLine("{0}", "总计:");

                sw.Close();
            }
            Console.WriteLine("---------输出Csv----------");
        }
Esempio n. 24
0
        static Common()
        {
            string supportDataBaseList = "MySql\r\n" +
                                         "SqlServer\r\n" +
                                         "PostgreSQL\r\n" +
                                         "Oracle\r\n" +
                                         "Firebird\r\n" +
                                         "Sqlite\r\n" +
                                         "OdbcOracle\r\n" +
                                         "OdbcSqlServer\r\n" +
                                         "OdbcMySql\r\n" +
                                         "OdbcPostgreSQL\r\n" +
                                         "Odbc\r\n" +
                                         "[Odbc说明]\r\n" +
                                         "[通用的 Odbc 实现,只能做基本的 Crud 操作]\r\n" +
                                         "[不支持实体结构迁移、不支持分页(只能 Take 查询]\r\n" +
                                         "[通用实现为了让用户自己适配更多的数据库,比如连接 mssql 2000、db2 等数据库]\r\n" +
                                         "[默认适配 SqlServer,可以继承后重新适配 FreeSql.Odbc.Default.OdbcAdapter,最好去看下代码]\r\n" +
                                         "[适配新的 OdbcAdapter,请在 FreeSqlBuilder.Build 之后调用 IFreeSql.SetOdbcAdapter 方法设置]\r\n" +
                                         "OdbcDameng+\r\n" +
                                         "[OdbcDameng说明]-武汉达梦数据库有限公司,基于 Odbc 的实现\r\n" +
                                         "MsAccess+\r\n" +
                                         "[MsAccess说明]-Microsoft Office Access 是由微软发布的关联式数据库管理系统\r\n" +
                                         "Dameng+\r\n" +
                                         "[Dameng说明]-武汉达梦数据库有限公司,基于 DmProvider.dll 的实现\r\n" +
                                         "OdbcKingbaseES+\r\n" +
                                         "[OdbcKingbaseES说明]-北京人大金仓信息技术股份有限公司,基于 Odbc 的实现\r\n" +
                                         "ShenTong+\r\n" +
                                         "[ShenTong说明]-天津神舟通用数据技术有限公司,基于 System.Data.OscarClient.dll 的实现\r\n" +
                                         "KingbaseES+\r\n" +
                                         "[KingbaseES说明]-Firebird 是一个跨平台的关系数据库,能作为多用户环境下的数据库服务器运行,也提供嵌入式数据库的实现";

            try
            {
                ResponseStruct rs;
                var            ret = ReadConfigFile(out rs);
                if (!ret || !rs.Code.Equals(ErrorNumber.None))
                {
                    Logger.Error(
                        $"[{LoggerHead}]->获取AKStream配置文件时异常,系统无法运行->\r\n{JsonHelper.ToJson(rs, Formatting.Indented)}");
                    Environment.Exit(0); //退出程序
                }

                Logger.Info(
                    $"[{LoggerHead}]->AKStreamWeb配置文件加完成");
            }
            catch (AkStreamException ex)
            {
                Logger.Error(
                    $"[{LoggerHead}]->获取AKStream配置文件时异常,系统无法运行->\r\n{JsonHelper.ToJson(ex.ResponseStruct, Formatting.Indented)}");
                Environment.Exit(0); //退出程序
            }

#if (DEBUG)
            Console.WriteLine("[Debug]\t当前程序为Debug编译模式");
            Console.WriteLine("[Debug]\t程序启动路径:" + GCommon.BaseStartPath);
            Console.WriteLine("[Debug]\t程序启动全路径:" + GCommon.BaseStartFullPath);
            Console.WriteLine("[Debug]\t程序运行路径:" + GCommon.WorkSpacePath);
            Console.WriteLine("[Debug]\t程序运行全路径:" + GCommon.WorkSpaceFullPath);
            Console.WriteLine("[Debug]\t程序启动命令:" + GCommon.CommandLine);
            Console.WriteLine("[Debug]\t程序版本标识:" + Version);
            IsDebug = true;
#endif
            try
            {
                GCommon.Ldb.VideoOnlineInfo.DeleteAll();
                OrmHelper = new ORMHelper(AkStreamWebConfig.OrmConnStr, AkStreamWebConfig.DbType);
            }
            catch (Exception ex)
            {
                ResponseStruct rsa = new ResponseStruct()
                {
                    Code    = ErrorNumber.Sys_DataBaseNotReady,
                    Message = ErrorMessage.ErrorDic ![ErrorNumber.Sys_DataBaseNotReady] +",请检查配置文件中的数据库相关配置信息",
Esempio n. 25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ob"></param>
        /// <param name="cxt"></param>
        /// <param name="TargetType"></param>
        /// <returns></returns>
        /// <remarks>
        /// 2013.8.7
        /// 将MSSQLScriptSqlPatternFactory改为可以得到列信息和名称信息
        /// </remarks>
        private System.Data.IDbCommand GenerateCreateSql(object ob, IDBContext cxt, Type TargetType)
        {
            System.Data.SqlClient.SqlCommand command = null;

            var patternFactory = new MSSQLScriptSqlPatternFactory();

            if (insertCommand.ContainsKey(TargetType) == false)
            {
                //得到表名
                command = new System.Data.SqlClient.SqlCommand();
                String TableName  = helper.GetTable(TargetType);
                var    Properties = TargetType.GetProperties();
                String Cols       = "";
                String Values     = "";
                for (int i = 0; i < Properties.Length; i++)
                {
                    if (Properties[i].PropertyType.IsArray)
                    {
                        continue;
                    }
                    var    attribute = helper.GetColNameAttributes(Properties[i]);
                    String paramName = "@" + Properties[i].Name;
                    string ColName   = "";
                    if (attribute.Count > 0)
                    {
                        for (int k = 0; k < attribute.Count; k++)
                        {
                            var Col = attribute[k];
                            if (Col.NoMap == true)
                            {
                                continue;
                            }
                            else if (Col.IsAutoGenerate == GenerationType.OnInSert)
                            {
                                var auto = Properties[i].GetCustomAttributes(typeof(SerialNoObject), true);
                                if (auto.Length > 0)
                                {
                                    var seriSetting = auto[0] as SerialNoObject;
                                    Properties[i].SetValue(ob,
                                                           cxt.GetSerialNo(seriSetting.SerialPre, seriSetting.Len, seriSetting.DateFormateStr, ""), null);
                                }
                                else
                                {
                                    continue;
                                }
                            }

                            ColName   = helper.GetColName(Col, Properties[i]);
                            paramName = "@" + ColName;
                            var valueObject = new ORMHelper().GetDbObject(Properties[i], ob, Col.PropertyName);
                            if (valueObject is DateTime && valueObject != null && String.IsNullOrEmpty(Col.FormatStr) == false)
                            {
                                valueObject = ((DateTime)valueObject).ToString(Col.FormatStr);
                            }
                            Cols   += "[" + ColName + "],";
                            Values += paramName + ",";
                            command.Parameters.Add(new System.Data.SqlClient.SqlParameter(paramName, valueObject ?? ""));
                        }
                    }
                }
                command.CommandText = "INSERT " + TableName + "(" + Cols.Substring(0, Cols.Length - 1) + ") VALUES(" + Values.Substring(0, Values.Length - 1) + ")";
                insertCommand.Add(TargetType, command);
                //return command;
            }

            command =
                (insertCommand[TargetType] as System.Data.SqlClient.SqlCommand).Clone();
            SetValues(ob, command, TargetType, "", true, cxt);
            return(command);
        }
Esempio n. 26
0
        public System.Data.IDbCommand GenerateSelectItemsSql <T>(object ob, PropertyInfo ParentInfo)
        {
            //初始化一个Command
            System.Data.SqlClient.SqlCommand command = null;
            var       TargetType = typeof(T);
            var       ParentType = ob.GetType();
            ORMHelper helper     = new ORMHelper();

            command = new System.Data.SqlClient.SqlCommand();
            String TableName = helper.GetTable(TargetType);

            var Properties = TargetType.GetProperties();


            String Cols = "";


            String       WhereSql   = "";
            PropertyInfo ParentKey  = null;
            String       ColumnName = "";


            var parentAttribute = ParentInfo.GetCustomAttributes(typeof(ParentRelationAttribute), true);

            if (parentAttribute.Length > 0)
            {
                ColumnName = (parentAttribute[0] as ParentRelationAttribute).ColumnName;
                //  ParentKey = ParentType.GetProperty(parentInfo.PropertyName);
            }
            else
            {
                var columAttribute = ParentInfo.GetCustomAttributes(typeof(ColumnAttribute), true);

                if (columAttribute.Length > 0)
                {
                    ColumnName = (columAttribute[0] as ColumnAttribute).ColumnName;
                }
            }


            ParentKey = new ORMHelper().GetKeyPropertyInfo(ParentInfo.PropertyType);
            if (ParentKey != null)
            {
                command.Parameters.Add(new SqlParameter("@" + ColumnName,
                                                        ParentKey.GetValue(ob, null) ?? ""));
                WhereSql = "where  [" + ColumnName + "]=@" + ColumnName
                ;
            }

            for (int i = 0; i < Properties.Length; i++)
            {
                if (Properties[i] != ParentInfo)
                {
                    foreach (var Col in helper.GetColNameAttributes(Properties[i]))
                    {
                        String paramName = "@" + helper.GetColName(Col, Properties[i]);
                        string ColName   = helper.GetColName(Col, Properties[i]);

                        if (Col.NoMap)
                        {
                            continue;
                        }
                        ColName = Col.ColumnName;

                        if (String.IsNullOrEmpty(ColName))
                        {
                            ColName = Properties[i].Name;
                        }
                        Cols += TableName + ".[" + ColName + "],";
                        //   }
                    }
                }
            }

            command.CommandText = "SELECT " + Cols.Substring(0, Cols.Length - 1) + " FROM " + TableName + WhereSql;   //+ "(" +

            return(command);
        }
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="Properties"></param>
        /// <param name="ob"></param>
        /// <param name="IsIncludeAutoGerateCols">在查询时是否包含自动生成列</param>
        /// <param name="ParamNamePre"></param>
        /// <returns></returns>
        public SqlCommandPaterns  GetExistSql <T>(System.Reflection.PropertyInfo[] Properties, T ob,
                                                  bool IsIncludeAutoGerateCols = true, String ParamNamePre = null)
        {
            SqlCommandPaterns pataerns = new SqlCommandPaterns();

            //如果有主键,则生成键查找的条件,如果没有,则生成所有列的查询
            Hashtable hashTable = new Hashtable();

            hashTable.Add(0, ""); //
            String ColName       = "";
            String parameterName = "";
            var    helper        = new ORMHelper();

            for (int i = 0; i < Properties.Length; i++)
            {
                var    attribute = helper.GetColNameAttributes(Properties[i]);
                object keyName   = 0;
                ColName = Properties[i].Name;
                foreach (var Col in attribute)
                {
                    if (Col.NoMap)
                    {
                        continue;
                    }

                    ColName = helper.GetColName(Col, Properties[i]);


                    parameterName = "@"
                                    + ParamNamePre + ColName;

                    if (IsIncludeAutoGerateCols == false && (Col.IsAutoGenerate != GenerationType.Never))
                    {
                        continue;
                    }
                    if (Col.IsKey)
                    {
                        keyName = Col.KeyGroupName;
                        keyName = keyName ?? 1;
                        if (!hashTable.ContainsKey(keyName))
                        {
                            //如果不含主键组,则加入
                            hashTable.Add(keyName, "");
                        }
                        if (hashTable.ContainsKey(0))
                        {
                            //有主键了就不需要对所有的值进行判断了
                            hashTable.Remove(0);
                        }
                    }
                    else
                    {
                        keyName = 0;
                    }

                    if (hashTable.ContainsKey(keyName))
                    {
                        var dbValue = new ORMHelper().GetDbObject(Properties[i], ob);
                        if (dbValue != null)
                        {
                            pataerns.Params.Add(new System.Data.SqlClient.SqlParameter(parameterName,
                                                                                       dbValue));
                            string exp = "[" + ColName + "]=" + parameterName;
                            hashTable[keyName] = hashTable[keyName].ToString() + " AND [" + (ColName) + "]=" + parameterName;
                        }
                    }
                }
            }
            foreach (var item in hashTable.Values)
            {
                pataerns.SqlScript += "OR (" + item.ToString().Substring(4) + ")";
            }
            pataerns.SqlScript = pataerns.SqlScript.Substring(3);
            return(pataerns);
        }
Esempio n. 28
0
        public void AddAgentCommissionDetailByTicketing(string userId, string gameCode, string gameType, decimal money, decimal deduction, string schemeId, SchemeType schemeType, DateTime complateTime, AgentCaculateHistory history)
        {
            try
            {
                gameType = ConvertGameType(gameCode, gameType);
                var    manager  = new AgentManager();
                int    category = 0;
                string agentId  = userId;
                while (!string.IsNullOrWhiteSpace(agentId))
                {
                    category += 1;
                    AgentCloseReturnPointInfo info;
                    var rows = AgentReturnPointCollection.Select("AgentId='" + agentId + "' and GameCode='" + gameCode + "' and GameType='" + gameType + "'");
                    if (rows.Length == 0)
                    {
                        info = manager.GetAgentReturnPointByUserId(agentId, gameCode, gameType);
                        if (info == null)
                        {
                            throw new Exception("没有返点信息");
                        }
                        AgentReturnPointCollection.Rows.Add
                        (
                            info.GameCode,
                            info.GameType,
                            info.AgentId,
                            info.SetLevel,
                            info.ReturnPoint,
                            info.PAgentId,
                            info.PSetLevel,
                            info.PReturnPoint
                        );
                    }
                    else
                    {
                        info = ORMHelper.ConvertDataRowToEntity <AgentCloseReturnPointInfo>(rows[0]);
                    }

                    if (string.IsNullOrWhiteSpace(info.PAgentId))
                    {
                        break;
                    }

                    decimal initialPoint = info.PReturnPoint;
                    decimal lowerPoint   = info.ReturnPoint;
                    decimal actualPoint  = initialPoint - lowerPoint;
                    if (actualPoint < 0)
                    {
                        throw new Exception("实际返点小于0");
                    }
                    if (actualPoint == 0)
                    {
                        break;
                    }
                    agentId = info.PAgentId;

                    var beforeCommission = money * actualPoint / 100;
                    var actualCommission = beforeCommission * (100 - deduction) / 100;

                    history.TotalCommisionMoney += actualCommission;

                    //需要添加用户佣金明细资金
                    manager.AddAgentCommissionDetail(new AgentCommissionDetail()
                    {
                        GameCode         = gameCode,
                        GameType         = ConvertGameType(gameCode, gameType),
                        ApplyState       = 0,
                        CreateTime       = DateTime.Now,
                        PAgentId         = agentId, //给上级用户
                        UserId           = userId,  //传个来的用户
                        Category         = category,
                        Sale             = money,
                        InitialPoint     = initialPoint, //上级用户的返点
                        LowerPoint       = lowerPoint,   //传个来的用户的返点
                        ActualPoint      = actualPoint,  // 0,//上级用户的返点 - 传个来的用户的返点
                        Deduction        = deduction,
                        BeforeCommission = beforeCommission,
                        ActualCommission = actualCommission,
                        //代购方案¥100.00 返点2.00%=¥2.00-扣量5%=¥1.90///去除扣量2012-11-23 23:15:51
                        Remark = string.Format("{0}¥{1:N2} 返点{2:#.##}%=¥{3:N2}"
                                               , schemeType == SchemeType.TogetherBetting ? "成功发起合买" : "代购方案", money, actualPoint, beforeCommission),
                        DetailKeyword    = schemeId,
                        ComplateDateTime = complateTime
                    });

                    userId = agentId;
                }

                //需要添加用户资金
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 29
0
        private void SetObject(object ob, DataRow Row, PropertyInfo[] properties, bool GetDetail = false)
        {
            MSSQL.MSSQLScriptSqlPatternFactory patternFactory = new MSSQL.MSSQLScriptSqlPatternFactory();

            if (ob is Soway.Data.IObjectFromDataBase)
            {
                (ob as Soway.Data.IObjectFromDataBase).Row = Row;
            }
            ORMHelper helper = new ORMHelper();

            for (int j = 0; j < properties.Length; j++)
            {
                try
                {
                    var attribute = helper.GetColNameAttributes(properties[j]);


                    object propertyob   = new object();
                    var    isBO         = new ORMHelper().IsBusinessType(properties[j].PropertyType);
                    var    propertyType = properties[j].PropertyType;



                    for (int i = 0; i < attribute.Count; i++)
                    {
                        var attr = attribute[i];
                        if (attr.NoMap)
                        {
                            continue;
                        }
                        String ColName = helper.GetColName(attr, properties[j]);
                        if (String.IsNullOrEmpty(ColName))
                        {
                            continue;
                        }

                        if (Row.Table.Columns.Contains(ColName))
                        {
                            var dbObject = Row[ColName];



                            if ((dbObject is DBNull))
                            {
                                continue;
                            }
                            if (propertyType == typeof(DateTime) && String.IsNullOrEmpty(attr.FormatStr) == false && dbObject != null)
                            {
                                dbObject = DateTime.ParseExact(dbObject.ToString(), attr.FormatStr, null);
                            }
                            if (attribute.Count == 1)
                            {
                                if (isBO)
                                {
                                    if (GetDetail)
                                    {
                                        if (!(dbObject is DBNull))
                                        {
                                            properties[j].SetValue(ob, DBContext.GetMethod.MakeGenericMethod(
                                                                       new Type[] { properties[j].PropertyType, properties[j].PropertyType }).Invoke(
                                                                       this, new object[] { Row[ColName] }), new object[] { });
                                        }
                                    }
                                    else
                                    {
                                        propertyob = propertyType.Assembly.CreateInstance(propertyType.FullName);
                                        properties[j].SetValue(ob, propertyob
                                                               , new object[] { });

                                        PropertyInfo key;
                                        if (String.IsNullOrEmpty(attr.PropertyName))
                                        {
                                            key = new ORMHelper().GetKeyPropertyInfo(propertyType);
                                        }
                                        else
                                        {
                                            key = propertyType.GetProperty(attr.PropertyName);
                                        }
                                        if (!(dbObject is DBNull))
                                        {
                                            key.SetValue(propertyob, dbObject, new object[] { });
                                        }
                                    }
                                }
                                else
                                if (String.IsNullOrEmpty(attr.PropertyName))
                                {
                                    if (!(dbObject is DBNull))
                                    {
                                        properties[j].SetValue(ob, dbObject is DBNull ? null : dbObject, new object[] { });
                                    }
                                }
                                else if (GetDetail && isBO)
                                {
                                    if (!(dbObject is DBNull))
                                    {
                                        properties[j].SetValue(ob, DBContext.GetMethod.MakeGenericMethod(new Type[] { properties[j].PropertyType, properties[j].PropertyType }).Invoke(
                                                                   new Soway.DB.DBContext(), new object[] { Row[ColName] }), new object[] { });
                                    }
                                }
                            }
                            else
                            {
                                if (i == 0)//{
                                {
                                    propertyob = propertyType.Assembly.CreateInstance(propertyType.FullName);
                                    properties[j].SetValue(ob, propertyob, new object[] { });
                                }

                                if (String.IsNullOrEmpty(attr.PropertyName) == false)
                                {
                                    if (!(dbObject is DBNull))
                                    {
                                        if (propertyType.GetProperty(attr.PropertyName).PropertyType
                                            == typeof(DateTime) && String.IsNullOrEmpty(attr.FormatStr) == false && dbObject != null)
                                        {
                                            dbObject = DateTime.ParseExact(dbObject.ToString(), attr.FormatStr, null);
                                        }
                                        propertyType.GetProperty(attr.PropertyName).SetValue(propertyob, dbObject, new object[] { });
                                    }
                                }

                                //  }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Esempio n. 30
0
        public void AgentCommissionClose(string createByUserId)
        {
            var manager = new AgentManager();
            var history = manager.GetAgentCaculateHistoryByDesc();

            if (history == null)
            {
                history = new AgentCaculateHistory()
                {
                    CaculateTimeFrom = DateTime.Parse("2012-10-01"),
                    CaculateTimeTo   = DateTime.Now
                };
            }
            else
            {
                history = new AgentCaculateHistory()
                {
                    CaculateTimeFrom = history.CaculateTimeTo,
                    CaculateTimeTo   = DateTime.Now
                };
            }

            if (history.CaculateTimeFrom >= history.CaculateTimeTo)
            {
                return;
            }

            bool tag        = true;
            int  totalCount = 0;
            int  pageIndex  = 0;
            int  pageSize   = 100;

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            do
            {
                var waitingOrderList = manager.QueryAgentWaitingCommissionOrderList(history.CaculateTimeFrom, history.CaculateTimeTo, pageIndex, pageSize, out totalCount);

                foreach (var item in waitingOrderList)
                {
                    try
                    {
                        AddAgentCommissionDetailByTicketing(item.UserId, item.GameCode, item.GameType, item.TotalBuyMoney, 5, item.SchemeId, item.SchemeType, item.ComplateTime, history);
                        history.TotalOrderCount += 1;
                        history.TotalOrderMoney += item.TotalMoney;
                        history.TotalBuyMoney   += item.TotalBuyMoney;
                    }
                    catch (Exception ex)
                    {
                        history.ErrorCount        += 1;
                        history.ErrorOrderMoney   += item.TotalMoney;
                        history.ErrorBuyMoney     += item.TotalBuyMoney;
                        history.ErrorSchemeIdList += item.SchemeId + ";";
                        var writer = Common.Log.LogWriterGetter.GetLogWriter();
                    }
                }

                pageIndex += 1;
                if (((totalCount + pageSize - 1) / pageSize) <= pageIndex)
                {
                    tag = false;
                }
            }while (tag);

            stopwatch.Stop();

            history.MillisecondSpan = stopwatch.ElapsedMilliseconds;
            history.CreateBy        = createByUserId;
            history.CreateTime      = DateTime.Now;
            history.TotalAgentCount = ORMHelper.DataTableToList <AgentCloseReturnPointInfo>(AgentReturnPointCollection).GroupBy(o => o.AgentId).Count();
            manager.AddAgentCaculateHistory(history);
        }