private void AddRecommend(Recommend rec)
 {
     if (!Recommends.Any((i) => i.Time2 == rec.Time2))
     {
         Recommends.Add(rec);
     }
 }
Example #2
0
        public static Recommend RecommendFromReader(IDataRecord reader)
        {
            Recommend rec = new Recommend();
            // 处理string类型
            var ps = typeof(Recommend).Properties<string>();
            try
            {
                foreach (var p in ps)
                {
                    if (p.StartsWith("Time"))
                    {
                        continue;
                    }
                    rec.SetProperty(p, reader[p] as string);
                }
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("ex:" + ex.StackTrace);
            }

            // 处理时间类型
            DateTime t1 = (DateTime)reader["Time1"];
            DateTime t2 = (DateTime)reader["Time2"];

            rec.Time1 = t1.ToString("yy-MM-dd HH:mm");
            rec.Time2 = t2.ToString("yy-MM-dd HH:mm");

            rec.PreferResult = (PreferResult)reader["PreferResult"];

            rec.Odds = (float)((double)reader["Odds"]);

            return rec;
        }
Example #3
0
 private static float GainLose(Recommend r)
 {
     switch (r.PreferResult)
     {
         case PreferResult.Waiting: return .0f;
         case PreferResult.Lose: return -1.0f;
         case PreferResult.LoseHalf: return -.5f;
         case PreferResult.Useless: return .0f;
         case PreferResult.WinHalf: return 0.5f * r.Odds;
         case PreferResult.Win: return 1.0f * r.Odds;
         default:
             return .0f;
     }
 }
Example #4
0
        public void TestProperty()
        {
            B b1 = new B() { A = new A() { szA = "szA1" }, szB = "szB1" };
            var x = b1.Property("szB");
            var y = b1.Property("A");
            var z = b1.Property("A.szA");
            var m = b1.Property("A.iA");

            Recommend r = new Recommend();
            var properties = r.GetType().Properties<string>();
            foreach (var p in properties)
            {
                System.Diagnostics.Debug.WriteLine(p);
            }
            b1.SetProperty("A.iA", 999);
        }
Example #5
0
        public void TestOutPutSql()
        {
            var rec = new Recommend()
            {
                Current = "第43期",
                League = "无联赛",
                Time1 = "05-01 02:45",
                Host = "車斯曼",
                OddStake = "半球",
                Guest = "赫默爾亨普斯特德城",
                Prefer = "赫默爾亨普斯特德城",
                Odds = 0.800f,
                Result = "-",
                PreferResult = PreferResult.Waiting,
                Time2 = "04-30 22:57",
                Person = "sos73"
            };

            string sz = DBHelper.ReplaceCommand(rec);
        }
Example #6
0
        public static string ReplaceCommand(Recommend rec)
        {
            var pros = typeof(Recommend).GetProperties();
            string prms = "";
            string vals = "";

            foreach (var p in pros)
            {
                if (p.Name.Contains("Time") || p.PropertyType.Name != "String")
                {
                    continue;
                }
                prms = prms + "'" + p.Name + "',";
                vals = vals + "'" + rec.Property(p.Name) + "',";
            }

            // handle Time1 & Time2
            var t1 = DateTimeToSqlTime(TimeFromString(rec.Time1));
            var t2 = DateTimeToSqlTime(TimeFromString(rec.Time2));

            var sz = "replace into Recommends(" + prms + "'Time1','Time2','Odds','PreferResult') values(" + vals + "'" + t1 + "','" + t2 + "'," + rec.Odds + "," + (int)rec.PreferResult + ");";
            return sz;
        }
 public YieldRoiRecommend(Recommend recommend)
 {
     this.Recommend = recommend;
     this.Person = YieldRoiProvider.Instance.GetPerson(recommend.Person);
 }
 public RecommendModifyViewModel(Recommend rec)
 {
     Recommends.Add(rec);
 }
 private bool Match(Recommend i, Recommend j)
 {
     return i.Time2 == j.Time2;
 }
 private string RecommendToString(Recommend item)
 {
     string body = item.Person + " :"
         + item.Host + " " + item.OddStake + " "
         + item.Guest + " 推荐:" + item.Prefer + " " + item.Odds;
     return body;
 }
Example #11
0
 public void SaveRecommend(Recommend rec)
 {
     localHelper.SaveRecommend(rec);
 }
 private void OnRecommend(Recommend rec)
 {
     AllRecommends.Add(new YieldRoiRecommend(rec));
 }
 private bool IsTopNewRecommend(Recommend item)
 {
     return IsTopPerson(item.Person) && item.PreferResult == PreferResult.Waiting;
 }
 public string GetReplaceRecommendSql(Recommend rec)
 {
     return DBHelper.ReplaceCommand(rec);
 }
Example #15
0
 private static bool IsValidRecommend(Recommend rec)
 {
     return rec.Odds > 0 && !string.IsNullOrEmpty(rec.Host) && !string.IsNullOrEmpty(rec.Guest) && !string.IsNullOrEmpty(rec.OddStake);
 }
Example #16
0
 private void onRecommend(Recommend obj)
 {
     var sz = DBHelper.ReplaceCommand(obj);
     Write(sz);
 }
Example #17
0
        private static Recommend RecommendFromStrings(IList<string> results)
        {
            string r6 = results[6]; // 艾斯迪格拿/0.900
            string szOdds = "0.0";
            int lastSlash = r6.LastIndexOf("/");
            string prefer = "推荐";
            if (lastSlash >= 0)
            {
                szOdds = r6.Substring(r6.LastIndexOf("/") + 1);
                prefer = r6.Substring(0, r6.LastIndexOf("/"));
            }
            float odds = 0.0f;
            float.TryParse(szOdds, out odds);
            Recommend rec = new Recommend()
            {
                // 擂台期数:第45期
                Current = results[0],
                // 所属赛事:挪威超
                League = results[1],
                // 开赛时间:04-27 16:30
                Time1 = results[2],
                // 主队:中央海岸學院
                Host = results[3],
                // 盘口:2.5/3球
                OddStake = results[4],
                // 客队:馬柯尼
                Guest = results[5],
                // 推荐内容:大球
                Prefer = prefer,
                // 赔率:0.86
                Odds = odds,
                // 比赛最终结果:0-1
                Result = results[7],
                // 推荐最终结果:输盘
                PreferResult = PreferResultHelper.ConvertBack(results[8], typeof(PreferResult), null, null),
                // 推荐时间:04-27 16:00
                Time2 = results[9],
                // 推荐人:地狱黑仔王
                Person = results[10]
            };

            return rec;
        }
Example #18
0
 public void SaveRecommend(Recommend rec)
 {
     using (var cmd = commandFactory.GetDbCommand())
     {
         cmd.CommandText = commandFactory.GetReplaceRecommendSql(rec);
         cmd.CommandType = CommandType.Text;
         cmd.ExecuteNonQuery();
     }
 }