Exemplo n.º 1
0
        public bool CanRegisterConfirm()
        {
            if (string.IsNullOrEmpty(Pseudo) || StringChecker.HasSpaces(Pseudo))
            {
                return(false);
            }

            if (!StringChecker.IsValidEmail(Email))
            {
                return(false);
            }

            if (string.IsNullOrEmpty(Password) || StringChecker.HasSpaces(Password))
            {
                return(false);
            }


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

            if (EmailAlreadyExist())
            {
                return(false);
            }

            if (PseudoAlreadyExist())
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 指定された文字列が郵便 番号
        /// (日本, ハイフン無し)形式であるか。
        /// </summary>
        /// <param name="input">入力文字列</param>
        /// <returns>
        /// true:郵便 番号(日本, ハイフン無し)形式である。
        /// false:郵便 番号(日本, ハイフン無し)形式でない。
        /// </returns>
        public static bool IsJpZipCode7_NoHyphen(string input)
        {
            // 先頭xxxxxxx末尾(xは10進数)

            // return StringChecker.Match(input, "^[0-9]{7}$");
            return(StringChecker.Match(input, "^\\d{7}$"));
        }
Exemplo n.º 3
0
 public void FindMoreThanAverageTest()
 {
     string[] input    = { "1234", "12345", "string" };
     string[] expected = { "string" };
     string[] actual   = StringChecker.FindMoreThanAverage(input);
     CollectionAssert.AreEqual(expected, actual);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 指定された文字列が郵便 番号
        /// (日本, ハイフン有り)形式であるか。
        /// </summary>
        /// <param name="input">入力文字列</param>
        /// <returns>
        /// true:郵便 番号(日本, ハイフン有り)形式である。
        /// false:郵便 番号(日本, ハイフン有り)形式でない。
        /// </returns>
        public static bool IsJpZipCode7_Hyphen(string input)
        {
            // 先頭xxx-xxxx末尾(xは10進数)

            // return StringChecker.Match(input, "^[0-9]{3}[-][0-9]{4}$");
            return(StringChecker.Match(input, @"^\d{3}[-]\d{4}$"));
        }
        public static List <SupplierOrderModel> SelectOrderByOrderDate(string keyword)
        {
            DateTime date = new DateTime();

            if (!StringChecker.IsDate(keyword))
            {
                throw new MyException("请输入一个日期");
            }
            else
            {
                date = Convert.ToDateTime(keyword);
            }
            using (IDbConnection connection = new SqlConnection(Tools.GetConnectionStringValue()))
            {
                string sql = @"SELECT   dbo.SupplierOrders.*, dbo.SupplierOrderStatus.*, dbo.Suppliers.*
                                FROM      dbo.SupplierOrders INNER JOIN
                                dbo.SupplierOrderStatus ON dbo.SupplierOrders.status_id = dbo.SupplierOrderStatus.id INNER JOIN
                                dbo.Suppliers ON dbo.SupplierOrders.supplier_id = dbo.Suppliers.id
                                WHERE DATEPART(YEAR, dbo.SupplierOrders.order_date) = @Year and DATEPART(MONTH, dbo.SupplierOrders.order_date) = @Month and DATEPART(DAY, dbo.SupplierOrders.order_date)";
                List <SupplierOrderModel> supplierOrders = connection.Query <SupplierOrderModel, SupplierOrderStatusModel, SupplierModel, SupplierOrderModel>(sql,
                                                                                                                                                              (order, status, supplier) =>
                {
                    order.Status   = status;
                    order.Supplier = supplier;
                    return(order);
                }, new { Year = date.Year, Month = date.Month, Day = date.Day }, splitOn: "id,id").ToList();
                return(supplierOrders);
            }
        }
Exemplo n.º 6
0
        public void _1_SelectCount(
            string screenId, string controlId, string actionType,
            string userName, string ipAddress, string isolationLevel)
        {
            string methodName = "SelectCount";

            // 引数クラスを生成
            // 下位(B・D層)は、テスト クラスを流用する
            TestParameterValue testParameterValue
                = new TestParameterValue(
                      screenId, controlId, methodName, actionType, new MyUserInfo(userName, ipAddress));

            // 戻り値
            TestReturnValue testReturnValue = null;

            // B層呼出し
            LayerB layerB = new LayerB();

            try
            {
                testReturnValue = (TestReturnValue)layerB.DoBusinessLogic(
                    testParameterValue, this.SelectIsolationLevel(isolationLevel));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            // 戻り値検証。
            Assert.AreEqual(testReturnValue.ErrorFlag, false);
            Assert.AreEqual(StringChecker.IsNumbers(testReturnValue.Obj.ToString()), true);
        }
Exemplo n.º 7
0
        public int Save <T>(BaseItem item) where T : class, new()
        {
            var inst    = item as T;
            var db      = DataStorage.GetInstance(DBType.MongoDB);
            var session = SESSION.Current;

            if (item._OID == ObjectId.Empty)
            {
                item._OID       = ObjectId.GenerateNewId();
                item.CreateTime = DateTime.Now;
                item.UpdateTime = DateTime.Now;

                item.CreatorID    = session.UserID;
                item.CreatorName  = session.UserName;
                item.ModifierID   = session.UserID;
                item.ModifierName = session.UserName;

                item.CompanyID   = session.CompanyID;
                item.CompanyName = session.CompanyName;
                //item.Status = CONST.Status.Normal;
                if (!StringChecker.IsNotEmptyObjectId(item.OwnerID)) ///默认指定则不赋值
                {
                    item.OwnerID = session.UserID;                   ///数据所有者
                }

                db.Save3(item._DbName, item._CollectionName, inst);
            }
            else
            {
                var query = MongoDBFilterCreator.SearchByObjectId(item.ID);
                db.Save3(item._DbName, item._CollectionName, inst, query);
            }
            return(0);
        }
Exemplo n.º 8
0
        public static List <CustomerOrderModel> SelectOrderByOrderDate(string keyword)
        {
            DateTime date = new DateTime();

            if (!StringChecker.IsDate(keyword))
            {
                throw new MyException("请输入一个日期");
            }
            else
            {
                date = Convert.ToDateTime(keyword);
            }
            using (IDbConnection connection = new SqlConnection(Tools.GetConnectionStringValue()))
            {
                string sql = @"SELECT co.*, cu.username, bo.title, cs.*
                                FROM [dbo].[CustomerOrders] co
                                LEFT JOIN [dbo].[Customers] cu ON co.customer_id = cu.id
                                LEFT JOIN [dbo].[Books] bo ON co.book_isbn = bo.ISBN
                                LEFT JOIN [dbo].[CustomerOrderStatus] cs ON co.status_id = cs.id
                                WHERE DATEPART(YEAR, co.order_date) = @Year and DATEPART(MONTH, co.order_date) = @Month and DATEPART(DAY, co.order_date) = @Day";
                List <CustomerOrderModel> customerOrders = connection.Query <CustomerOrderModel, CustomerOrderStatusModel, CustomerOrderModel>(sql,
                                                                                                                                               (order, status) => { order.Status = status; return(order); },
                                                                                                                                               new { Year = date.Year, Month = date.Month, Day = date.Day }, splitOn: "id").ToList();
                return(customerOrders);
            }
        }
Exemplo n.º 9
0
        public ActionResult QueryBook([FromBody] BookQuery bookQuery)
        {
            if (!BookChecker.existBook(bookQuery))
            {
                return(BadRequest(new { message = "没有此书" }));
            }
            String titledBookName = StringChecker.AddBookTitle(bookQuery.Name);

            using (MySqlConnection conn = SqlProvider.GetMySqlConnection())
            {
                MySqlCommand cmd = new MySqlCommand($"SELECT * from books WHERE name='{titledBookName}'OR GUID='{bookQuery.guid}';", conn);

                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                //创建DataSet类的对象
                DataSet dataset = new DataSet();

                //使用SQLDataAdapter对象sda将查询结果填充到DataTable对象ds中
                adapter.Fill(dataset);

                MySqlCommandBuilder cmdBuilder = new MySqlCommandBuilder(adapter);

                DataRow dataRow = dataset.Tables[0].Rows[0];

                Book book = new Book()
                {
                    GUID         = Guid.Parse(dataRow["GUID"].ToString()),
                    Name         = dataRow["Name"].ToString(),
                    TotalNumber  = (int)dataRow["TotalNumber"],
                    RemainNumber = (int)dataRow["RemainNumber"]
                };
                return(Ok(book));
            }
        }
Exemplo n.º 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            Task executing = new Task(() =>
            {
                string root         = "E:\\Judge\\";
                FileFactory factory = new FileFactory("E:\\Judge\\");

                string code     = textBox1.Text;
                string language = comboBox1.Text;
                Submit submit   = new Submit(code, language);
                Problem sum     = new Problem();
                sum.Tests       = new List <TestCase> {
                    new TestCase("5 5", "10"),
                    new TestCase("3 9", "12"),
                    new TestCase("3 6", "9"),
                    new TestCase("5 5", "10"),
                    new TestCase("3 9", "12"),
                    new TestCase("3 6", "9")
                };
                IChecker checker = new StringChecker();
                Judger judger    = new Judger(factory, checker);
                judger.Judge(submit, new ExecutingOptions(5, 1000));

                string current     = "";
                this.textBox2.Text = "";
                foreach (var result in judger.Assessment(judger.BuildedFileName + ".exe", sum))
                {
                    current            = String.Format("\nStatus:{0}     Memory:{1}     Execution Time:{2}", result.Verdict, result.Memory.ToString(), result.Time.ToString()); //
                    this.textBox2.Text = textBox2.Text + current;
                }
            });

            executing.Start();
        }
Exemplo n.º 11
0
        public static void MatchesTest(string input, string pattern, RegexOptions options, int result)
        {
            MatchCollection output = StringChecker.Matches(input, pattern, options);

            Assert.NotNull(output);
            Assert.AreEqual(output.Count, result);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 指定された文字列が郵便 区 番号
        /// (日本, ハイフン無し)形式であるか。
        /// </summary>
        /// <param name="input">入力文字列</param>
        /// <returns>
        /// true:郵便 区 番号(日本, ハイフン無し)形式である。
        /// false:郵便 区 番号(日本, ハイフン無し)形式でない。
        /// </returns>
        public static bool IsJpZipCode5_NoHyphen(string input)
        {
            // 先頭xxx末尾(xは10進数)
            // 先頭xxxxx末尾(xは10進数)

            return(StringChecker.Match(input, "^\\d{3}$")
                   | StringChecker.Match(input, "^\\d{5}$"));
        }
Exemplo n.º 13
0
        /// <summary>
        /// 指定された文字列が郵便 区 番号
        /// (日本, ハイフン有り)形式であるか。
        /// </summary>
        /// <param name="input">入力文字列</param>
        /// <returns>
        /// true:郵便 区 番号(日本, ハイフン有り)形式である。
        /// false:郵便 区 番号(日本, ハイフン有り)形式でない。
        /// </returns>
        public static bool IsJpZipCode5_Hyphen(string input)
        {
            // 先頭xxx末尾(xは10進数)
            // 先頭xxx-xx末尾(xは10進数)

            return(StringChecker.Match(input, @"^\d{3}$")
                   | StringChecker.Match(input, @"^\d{3}[-]\d{2}$"));
        }
Exemplo n.º 14
0
        public void CountAverageLengthTest()
        {
            string[] input    = { "1234", "12345", "string" };
            int      expected = 5;
            int      actual   = StringChecker.FindAverageLength(input);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 15
0
        public int SaveAs(string id            = null, string title = null, string content = null, string categoryID = null, string status = null, string plainText = null
                          , string publishTime = "1990-01-01", string thumbnailSrc = null, string bizMode = null)
        {
            var session = SESSION.Current;

            var inst  = new DocItem();
            var isNew = false;

            if (StringChecker.IsNotEmptyObjectId(id))
            {
                inst._id = ObjectId.Parse(id);
            }
            else
            {
                inst._id = ObjectId.GenerateNewId();
                //inst.ID = Guid.NewGuid();
                inst.CreateTime  = DateTime.Now.AddDays(new Random().Next(-100, 100));
                inst.CreatorName = session.UserName;
                inst.CreatorID   = session.UserID;
                isNew            = true;
            }
            inst.Title         = title;
            inst.Keyword       = "暂空";
            inst.Summary       = "暂空";
            inst.Content       = content;
            inst.ContentLength = content.Length;
            //inst.CategoryID = categoryID;
            //inst.CategoryName = CategoryManager.GetInstance().Get(categoryID).Name;
            //inst.ContentType = "文档库模板";
            inst.PublishTime     = DateTime.Parse(publishTime);
            inst.Status          = status;
            inst.PlainText       = plainText;
            inst.PlainTextLength = plainText.Length;
            inst.UpdateTime      = DateTime.Now;
            if (StringChecker.IsHttpUrl(thumbnailSrc))
            {
                inst.ImageUrl = thumbnailSrc;
            }
            else
            {
                var pic = (DataSourceBaidu.GetInstance().GetPic(inst.Title)[0] as Dictionary <string, object>)["thumbURL"].ToString();
                inst.ImageUrl = pic;
            }

            inst.Save();

            ///添加记录
            //if (isNew)
            //{
            //    ModifyLogItem.LogAsNew(inst.id, CONST.DB.DBName_DocService, CONST.DB.CollectionName_DocItem);
            //}
            //else
            //{
            //    ModifyLogItem.LogAsModify(inst.id, CONST.DB.DBName_DocService, CONST.DB.CollectionName_DocItem);
            //}

            return(0);
        }
Exemplo n.º 16
0
 ///<summary>
 ///下载链接入队
 /// </summary>
 public void UrlEnqueue(string url)
 {
     if (StringChecker.IsHttpUrl(url)) ///若数据符合要求
     {
         var dict = new Dictionary <string, object>();
         dict["Url"] = url;
         this.UrlEnqueue(dict);
     }
 }
Exemplo n.º 17
0
        public void WriteSimpleTests()
        {
            StringChecker checker = null;
            string        expectedFirst = "First", expectedSecond = "Second";

            this.When(_ => WhenCreatingAStringCheckerWithDifferentStrings(expectedFirst, expectedSecond, out checker), false)
            .Then(_ => ThenTheCheckerStoresTheStringValues(expectedFirst, expectedSecond, checker), false)
            .BDDfy <__AcceptanceTestTemplate>("Write a simple test to check constructors and public properties of StringChecker");
        }
Exemplo n.º 18
0
        public void WriteParameterizedTests(string password, string confirmPassword)
        {
            StringChecker checker = null;

            this.Given(_ => GivenNonEmptyStrings(password, confirmPassword))
            .When(_ => WhenCheckingTheStrings(password, confirmPassword, out checker))
            .Then(_ => ThenTheStringsMatch(checker))
            .BDDfy <__AcceptanceTestTemplate>("Write a parameterized test to compare strings for equality");
        }
Exemplo n.º 19
0
 public int Remove(BaseItem item)
 {
     if (StringChecker.IsNotEmptyObjectId(item.ID))
     {
         var db    = DataStorage.GetInstance(DBType.MongoDB);
         var query = MongoDBFilterCreator.SearchByObjectId(item.ID);
         db.Save3(item._DbName, item._CollectionName, "{StatusCode:" + CONST.APP.Status.除 + ",Status:'" + CONST.APP.Status.GetString(CONST.APP.Status.除) + "'}", query, false);
         ClientBehaviorItem.Save(item, ClientBehaviorItem.BehaviorType.移除, SESSION.Current);
     }
     return(0);
 }
Exemplo n.º 20
0
        /// <summary>指定された文字列が固定電話番号(日本, ハイフン有り)であるか。</summary>
        /// <param name="input">入力文字列</param>
        /// <returns>
        /// true:固定電話番号(日本, ハイフン有り)である。
        /// false:固定電話番号(日本, ハイフン有り)でない。
        /// </returns>
        /// <remarks>
        /// <総務省>
        /// 電話番号に関するQ&A
        /// http://www.soumu.go.jp/main_sosiki/joho_tsusin/top/tel_number/q_and_a-2001aug.html
        /// 電気通信番号指定状況-固定電話の電話番号
        /// http://www.soumu.go.jp/main_sosiki/joho_tsusin/top/tel_number/fixed.html
        /// ※ FMC(Fixed Mobile Convergence)は含まず。
        /// </remarks>
        public static bool IsJpFixedLinePhoneNumber_Hyphen(string input)
        {
            // 先頭0x(1~4個)-x(1~4個)-x(4個)末尾(xは10進数)
            // そして、全体が10桁(ハイフン入れて12文字)であること。
            if (input.Length == 12)
            {
                return(StringChecker.Match(input, "^0\\d{1,4}-\\d{1,4}-\\d{4}$"));
            }

            return(false);
        }
Exemplo n.º 21
0
 public int Delete(BaseItem item)
 {
     if (StringChecker.IsNotEmptyObjectId(item.ID))
     {
         var db    = DataStorage.GetInstance(DBType.MongoDB);
         var query = MongoDBFilterCreator.SearchByObjectId(item.ID);
         db.Remove(item._DbName, item._CollectionName, query);
         ClientBehaviorItem.Save(item, ClientBehaviorItem.BehaviorType.除, SESSION.Current);
     }
     return(0);
 }
Exemplo n.º 22
0
 private void OnCheckStringDone(object s)
 {
     try
     {
         isCensored = !StringChecker.EndCheckString(asyncResult);
         isVerified = true;
     }
     catch
     {
     }
     asyncResult = null;
 }
Exemplo n.º 23
0
        public T Get <T>(BaseItem item) where T : class, new()
        {
            if (StringChecker.IsNotEmptyObjectId(item.ID))
            {
                var db    = DataStorage.GetInstance(DBType.MongoDB);
                var query = MongoDBFilterCreator.SearchByObjectId(item.ID);
                var data  = db.Get(item._DbName, item._CollectionName, query);


                return(Convertor.FromDictionaryToObject <T>(data));
            }
            return(new T());
        }
Exemplo n.º 24
0
        private bool CheckInfo()
        {
            StringBuilder tip = new StringBuilder();

            if (textBoxRealName.Text.Length == 0)
            {
                tip.Append("真实姓名不得为空\r\n");
            }
            if (textBoxAddress.Text.Length == 0)
            {
                tip.Append("住址不得为空\r\n");
            }
            if (textBoxPhoneNumber.Text.Length == 0)
            {
                tip.Append("手机号码不得为空\r\n");
            }
            if (textBoxRealName.Text.Length == 0)
            {
                tip.Append("电子邮箱不得为空\r\n");
            }
            if (textBoxRealName.Text.Length > 50)
            {
                tip.Append("真实姓名不得超过50个字符\r\n");
            }
            if (textBoxAddress.Text.Length > 100)
            {
                tip.Append("住址不得超过100个字符\r\n");
            }
            if (textBoxEmailAddress.Text.Length > 100)
            {
                tip.Append("电子邮箱不得超过100个字符\r\n");
            }
            if (!StringChecker.IsEmailAddress(textBoxEmailAddress.Text))
            {
                tip.Append("电子邮箱格式不正确\r\n");
            }
            if (!StringChecker.IsPhoneNumber(textBoxPhoneNumber.Text))
            {
                tip.Append("手机号码格式不正确\r\n");
            }

            if (tip.Length == 0)
            {
                return(true);
            }
            else
            {
                MessageBox.Show(tip.ToString());
                return(false);
            }
        }
Exemplo n.º 25
0
 public static List <BasicBookModel> SelectBookByPrice(string keyword)
 {
     if (!StringChecker.IsNumberic(keyword))
     {
         throw new MyException("价格搜索字段无效");
     }
     using (IDbConnection connection = new SqlConnection(Tools.GetConnectionStringValue()))
     {
         string sql = @"SELECT ISBN, title, quantity, is_on_sale FROM [dbo].[Books]
                         WHERE price = @Keyword";
         List <BasicBookModel> books = connection.Query <BasicBookModel>(sql, new { Keyword = keyword }).ToList();
         return(books);
     }
 }
 public static List <CustomerModel> SelectCustomerByWalletBalance(string keyword)
 {
     if (!StringChecker.IsNumberic(keyword))
     {
         throw new MyException("钱包余额搜索字段无效");
     }
     using (IDbConnection connection = new SqlConnection(Tools.GetConnectionStringValue()))
     {
         string sql = @"SELECT * FROM [dbo].[Customers]
                         WHERE wallet_balance = @Keyword";
         List <CustomerModel> customers = connection.Query <CustomerModel>(sql, new { Keyword = keyword }).ToList();
         return(customers);
     }
 }
 public static List <SupplierModel> SelectSupplierById(string keyword)
 {
     if (!StringChecker.IsNumber(keyword))
     {
         throw new MyException("请输入一个数字");
     }
     using (IDbConnection connection = new SqlConnection(Tools.GetConnectionStringValue()))
     {
         string sql = @"SELECT * FROM [dbo].[Suppliers]
                         WHERE id = @Keyword";
         List <SupplierModel> suppliers = connection.Query <SupplierModel>(sql, new { Keyword = keyword }).ToList();
         return(suppliers);
     }
 }
Exemplo n.º 28
0
 public static List <BasicBookModel> SelectBookByPublicationYear(string keyword)
 {
     if (!StringChecker.IsYear(keyword))
     {
         throw new MyException("请输入正确的年份");
     }
     using (IDbConnection connection = new SqlConnection(Tools.GetConnectionStringValue()))
     {
         string sql = @"SELECT ISBN, title, quantity, is_on_sale FROM [dbo].[Books]
                         WHERE DATEPART(YEAR, publication_date) = @Keyword";
         List <BasicBookModel> books = connection.Query <BasicBookModel>(sql, new { Keyword = keyword }).ToList();
         return(books);
     }
 }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            var option = 9;

            switch (option)
            {
            case 1:
                UniqueChecker.Run();
                break;

            case 2:
                Permutation.Run();
                break;

            case 3:
                StringCompression.Run();
                break;

            case 4:
                StringChecker.Run();
                break;

            case 5:
                MatrixModifier.Run();
                break;

            case 6:
                ImageRotation.Run();
                break;

            case 7:
                LinkedListDeduplicator.Run();
                break;

            case 8:
                BitManipulationHelper.Run();
                break;

            case 9:
                FibonacciHelper.Run();
                break;

            default:
                Console.WriteLine("No option selected.");
                break;
            }

            Console.WriteLine("Press any key to close this app.");
            Console.ReadKey();
        }
Exemplo n.º 30
0
 private void textBoxPassword_TextChanged(object sender, EventArgs e)
 {
     if (!StringChecker.IsPassword(textBoxPassword.Text))
     {
         labelTipForPassword.Text = "*密码由6-16个字符组成\n*区分大小写\n*至少包含一个字母、一个数字\n和一个特殊字符";
         _isPasswordValid         = false;
     }
     else
     {
         labelTipForPassword.Text = "";
         _isPasswordValid         = true;
         _password = textBoxPassword.Text;
     }
 }
Exemplo n.º 31
0
 private void ThenTheStringsMatch(StringChecker checker)
 {
     Assert.True(checker.IsMatch());
 }
Exemplo n.º 32
0
 private void WhenCheckingTheStrings(string firstString, string secondString, out StringChecker checker)
 {
     checker = new StringChecker(firstString, secondString);
     Assert.NotNull(checker);
 }
Exemplo n.º 33
0
 private void WhenCreatingAStringCheckerWithDifferentStrings(string first, string second, out StringChecker checker)
 {
     checker = new StringChecker(first, second);
 }
Exemplo n.º 34
0
 private void ThenTheCheckerStoresTheStringValues(string first, string second, StringChecker checker)
 {
     Assert.Equal(first, checker.FirstString);
     Assert.Equal(second, checker.SecondString);
 }