コード例 #1
0
ファイル: TableService.cs プロジェクト: aspdotnetmvc/mvc
 void CreateTable()
 {
     try
     {
         if (operatorFlag)
         {
             string tableName = "SMSStatusReport_" + DateTime.Now.AddDays(1).ToString("yyyyMMdd");
             if (!statusReportTables.Contains(tableName.ToLower()))
             {
                 StatusReportDB.CloneTable(tableName);
                 statusReportTables.Add(tableName.ToLower());
             }
             tableName = "ReportStatistics_" + DateTime.Now.AddDays(1).ToString("yyyyMMdd");
             if (!statisticsReportTables.Contains(tableName.ToLower()))
             {
                 ReportStatisticsDB.CloneTable(tableName);
                 statisticsReportTables.Add(tableName.ToLower());
             }
         }
     }
     catch
     {
         operatorFlag = true;
     }
 }
コード例 #2
0
        public void AddStatusReportTest()
        {
            var accountId = "account";
            SMS sms       = new SMS()
            {
                Account      = "account",
                Audit        = AuditType.Auto,
                AuditTime    = DateTime.Now.ToString(),
                AuditUser    = "******",
                Channel      = "default",
                Content      = "ceshi neirong",
                Level        = LevelType.Level0,
                IsSplit      = true,
                SendTime     = DateTime.Now,
                SerialNumber = System.Guid.NewGuid(),
                Signature    = "【1111】",
                LinkID       = System.Guid.NewGuid().ToString(),
                SPNumber     = "1234",
                StatusReport = StatusReportType.Enabled,
                Extend       = null,
                FailureCase  = "",
                Filter       = FilterType.Failure,
                Number       = new List <string> {
                    "123", "1235", "234"
                },
                NumberCount = 3,
                WapURL      = "wapurl"
            };

            StatusReport report = new StatusReport();

            report.StatusCode  = 3100;
            report.Describe    = "发送成功";
            report.Gateway     = "CMPP";
            report.Message     = sms;
            report.Serial      = sms.SerialNumber.ToString();
            report.SplitNumber = 1;
            report.SplitTotal  = 1;
            report.Succeed     = true;

            var b = StatusReportDB.AddStatusReport(accountId, report);

            Assert.IsTrue(b);
            report.Succeed = false;
            b = StatusReportDB.Update(report);
            Assert.IsTrue(b);

            b = StatusReportDB.CloneTable("statusReport_" + UnitTestDBAccess.Util.GenRandStr(5));
            Assert.IsTrue(b);
            var tables = StatusReportDB.GetTables();

            Assert.IsTrue(tables.Count > 0);

            var sr = StatusReportDB.GetStatusReport(sms.SerialNumber, DateTime.Now);

            Assert.IsTrue(sr.Count > 0);
        }
コード例 #3
0
ファイル: TableService.cs プロジェクト: aspdotnetmvc/mvc
        /// <summary>
        /// 状态报告表
        /// </summary>
        void LoadStatusReportTables()
        {
            List <string> tables = StatusReportDB.GetTables();

            if (tables.Count == 0)
            {
                string name = "SMSStatusReport_" + DateTime.Now.ToString("yyyyMMdd");
                StatusReportDB.CloneTable(name);
                statusReportTables.Add(name.ToLower());
                return;
            }
            int min = 99991231;

            foreach (var table in tables)
            {
                statusReportTables.Add(table.ToLower());
                if (min > int.Parse(table.Remove(0, 16)))
                {
                    min = int.Parse(table.Remove(0, 16));
                }
            }
            string date = min.ToString();

            date = date.Insert(4, "-");
            date = date.Insert(7, "-");
            DateTime beginTime = DateTime.Parse(date).AddDays(1);

            while (DateTime.Compare(DateTime.Now, beginTime) > 0)
            {
                string name = "SMSStatusReport_" + beginTime.ToString("yyyyMMdd");
                if (!statusReportTables.Contains(name.ToLower()))
                {
                    StatusReportDB.CloneTable(name);
                    statusReportTables.Add(name.ToLower());
                }
                beginTime = beginTime.AddDays(1);
            }
        }