static void Main(string[] args) { RegexCheck regexCheck = new RegexCheck(); List <string> results = new List <string>(); int N = Convert.ToInt32(Console.ReadLine()); for (int NItr = 0; NItr < N; NItr++) { string[] firstNameEmailID = Console.ReadLine().Split(' '); string firstName = firstNameEmailID[0]; string emailID = firstNameEmailID[1]; if (regexCheck.rgx.IsMatch(emailID)) { results.Add(firstName); } } results.Sort(); foreach (string s in results) { Console.WriteLine(s); } }
/// <summary> /// 创建(描述当前用户自定义dbtune配置的)XML文件 /// </summary> private static void CreateXml(IDBHelper dbHelper, string filePath) { XDocument xml = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), new XElement(ROOT_NAME)); xml.Save(string.Format("{0}\\{1}.xml", Environment.CurrentDirectory, UtilityConst.XML_NAME)); DbtuneHelper dbtuneHelper = new DbtuneHelper(filePath, dbHelper.DBServiceName.Split('/')[0], dbHelper.DBPort, dbHelper.DBUser, dbHelper.DBPwd); List <string> keywordSet = dbtuneHelper.ListConfig(); List <string> keywordScreenedSet = new List <string>(); for (int i = 0; i < keywordSet.Count; i++) { if (!RegexCheck.IsExist(ScreenTemplate.ScreenDbtuneReservedKeyWord, keywordSet[i])) { keywordScreenedSet.Add(keywordSet[i]); } } for (int i = 0; i < keywordScreenedSet.Count; i++) { InsertKeyWord(new DbtuneInfo() { KeyWord = keywordScreenedSet[i], ParamName = PartitionKeyWordInfo.DBTUNE_PARAM_NAME, ParamValue = dbtuneHelper.ListConfig(keywordScreenedSet[i], PartitionKeyWordInfo.DBTUNE_PARAM_NAME) }); } }
/// <summary> /// 展示配置(展示关键字集合) /// </summary> /// <param name="keyWord"></param> /// <param name="paramName"></param> /// <returns></returns> public List <string> ListConfig() { try { List <string> cmdParamSet = new List <string>(); string listParam = DbtuneTemplate.DBTUNE_LIST_PARAM_3; listParam = SetBaseParam(listParam); cmdParamSet.Add(listParam); string[] cmdInvorkOutput = RegexCheck.Split(Environment.NewLine, CmdInvork(cmdParamSet).Trim().Replace("\t", string.Empty)); List <string> keywordSet = new List <string>(); for (int i = 0; i < cmdInvorkOutput.Length; i++) { keywordSet.Add(cmdInvorkOutput[i]); } return(keywordSet); } catch (Exception ex) { LogHelper.Error.Append(ex); return(null); } }
/// <summary> /// 插入配置参数 /// </summary> /// <param name="keyWord">配置关键字</param> /// <param name="paramName">参数名</param> /// <param name="paramValue">参数内容</param> /// <returns></returns> public bool InsertConfig(string keyWord, string paramName, string paramValue) { try { List <string> cmdParamSet = new List <string>(); string insertParam = DbtuneTemplate.DBTUNE_INSERT_PARAM; insertParam = SetBaseParam(insertParam); insertParam = insertParam.Replace("{key_word}", keyWord).Replace("{param_name}", paramName).Replace("{parameter_value}", paramValue); cmdParamSet.Add(insertParam); //这里因为dbtune配置参数的导入命令需要用户确认,故在参数列表里传入一个'Y' cmdParamSet.Add("Y"); string cmdInvorkOutput = CmdInvork(cmdParamSet); if (RegexCheck.IsExist(cmdInvorkOutput, CMD_ERROR_STATE)) { LogHelper.Error.Append(cmdInvorkOutput); return(false); } else { return(true); } } catch (Exception ex) { LogHelper.Error.Append(ex); return(false); } }
/// <summary> /// 删除配置(删除整个关键字) /// </summary> /// <param name="keyWord">配置关键字</param> /// <returns></returns> public bool DeleteConfig(string keyWord) { try { List <string> cmdParamSet = new List <string>(); string deleteParam = DbtuneTemplate.DBTUNE_DELETE_PARAM_1; deleteParam = SetBaseParam(deleteParam); deleteParam = deleteParam.Replace("{key_word}", keyWord); cmdParamSet.Add(deleteParam); //这里因为dbtune配置参数的导入命令需要用户确认,故在参数列表里传入一个'Y' cmdParamSet.Add("Y"); string cmdInvorkOutput = CmdInvork(cmdParamSet); if (RegexCheck.IsExist(cmdInvorkOutput, CMD_ERROR_STATE)) { LogHelper.Error.Append(cmdInvorkOutput); return(false); } else { return(true); } } catch (Exception ex) { LogHelper.Error.Append(ex); return(false); } }
/// <summary> /// 测试连接 /// </summary> /// <returns></returns> public bool TryConnect() { try { //外部命令行方法参数列表 List <string> cmdParamSet = new List <string>(); //使用变量替换参数模板 string exportParam = DbtuneTemplate.DBTUNE_EXPORT_PARAM; exportParam = SetBaseParam(exportParam); exportParam = exportParam.Replace("{file_path}", this._filePath + DBTUNE_FILE_NAME); cmdParamSet.Add(exportParam); string cmdInvorkOutput = CmdInvork(cmdParamSet); if (RegexCheck.IsExist(cmdInvorkOutput, CMD_ERROR_STATE)) { LogHelper.Error.Append(cmdInvorkOutput); return(false); } else { return(true); } } catch (Exception ex) { LogHelper.Error.Append(ex); return(false); } }
//обработка события нажатия кнопки "Отправить" private void btnSend_Click(object sender, RoutedEventArgs e) { // Проверка валидности введённого адреса if (RegexCheck.IsValidEmail(tTo.Text)) { // Загрузка параметров smtp-сервера var smtpParams = GetSmtpParams(); // Формирование письма: тело, адрес отправителя и получателя EmailSender emailSender = new EmailSender(smtpParams.host, smtpParams.pass, smtpParams.port, smtpParams.user); MailAddress from = new MailAddress(tFrom.Text + tcbServer.Text); MailAddress to = new MailAddress(tTo.Text); MailMessage mail = new MailMessage(from, to); mail.Subject = tSubject.Text; mail.Body = tBody.Text; // Проверка на наличие аттача if (tbAttachmentAddress.Text != "") { mail.Attachments.Add(new Attachment(tbAttachmentAddress.Text)); } emailSender.Send(mail); lWarningIncEmail.Visibility = Visibility.Hidden; } else { SystemSounds.Exclamation.Play(); lWarningIncEmail.Visibility = Visibility.Visible; } }
/// <summary> /// 指定各分区表空间按钮的点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAssignTablespace_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { //如果分区信息集合已经初始化 if (this._partitionInfoSet.Count != 0) { if (this._frmAssignTablespace == null || this._frmAssignTablespace.IsDisposed) { this._frmAssignTablespace = new FormAssignTablespace(this._partitionInfoSet, QueryUnityInfo.QueryTablespace(this._dbHelper)); } this._frmAssignTablespace.ShowDialog(); for (int i = 0; i < this._partitionInfoSet.Count; i++) { this._partitionInfoSet[i].Tablespace = this._frmAssignTablespace.PartitionInfoSet.Rows[i]["Tablespace"].ToString(); if (!RegexCheck.IsEmpty(this._partitionInfoSet[i].Tablespace)) { this.btnAssignTablespace.Text += this._partitionInfoSet[i].Tablespace + " | "; } } this._frmAssignTablespace = null; } }
public override bool InputControl(string fullText) { if (fullText.Length == 1) { if (".".Equals(fullText)) { return(false); } } return(RegexCheck.IsPlusDecimal(fullText) || (fullText.Count(c => c == '.') == 1 && fullText.IndexOf('.') == fullText.Length - 1));//有一个小数点且在末尾 }
/// <summary> /// 检查Dbtune配置流程涉及参数 /// </summary> /// <returns></returns> internal static bool CheckDbtuneConfigParam(MemoEdit txbBlog, DbtuneConfigParam dbtuneConfigParam) { if (dbtuneConfigParam.DBHelper == null) { WriteBlog(txbBlog, "--- 数据库连接异常, 请查看错误日志"); return(false); } else if (dbtuneConfigParam.FeatureClass == null) { WriteBlog(txbBlog, "--- 未指定要素类"); return(false); } else if (RegexCheck.IsEmpty(dbtuneConfigParam.BasicField)) { WriteBlog(txbBlog, "--- 未指定分区列"); return(false); } else if (dbtuneConfigParam.PartitionWay == EnumPartitionWay.Unknow) { WriteBlog(txbBlog, "--- 未指定分区方式"); return(false); } else if (!RegexCheck.IsFull(dbtuneConfigParam.TablespaceSet)) { WriteBlog(txbBlog, "--- 存在没有指定表空间的分区"); return(false); } else if (DbtuneXMLOperate.CheckKeyWordExist(dbtuneConfigParam.DbtuneKeyWord)) { WriteBlog(txbBlog, "--- 关键字为 " + dbtuneConfigParam.DbtuneKeyWord + "的配置项已经存在,请更改关键字"); return(false); } else { if (dbtuneConfigParam.PartitionWay == EnumPartitionWay.Range) { if (dbtuneConfigParam.PartitionCount == -1) { WriteBlog(txbBlog, "--- 未指定范围分区数"); return(false); } else { return(true); } } else { return(true); } } }
private void btnConfirm_Click(object sender, EventArgs e) { if (RegexCheck.IsNotNagtive(this.txbPartitionCount.Text)) { this.PartitionCount = int.Parse(this.txbPartitionCount.Text); this.IsCancel = false; this.Close(); } else { DevMessageUtil.ShowMessageDialog("输入的参数不正确"); } }
/// <summary> /// 检查所有分区是否都已指定表空间 /// </summary> /// <returns></returns> private bool CheckInfoComplete() { bool isInfoComplete = true; for (int i = 0; i < PartitionInfoSet.Rows.Count; i++) { if (RegexCheck.IsEmpty(PartitionInfoSet.Rows[i]["Tablespace"].ToString())) { isInfoComplete = false; break; } } return(isInfoComplete); }
/// <summary> /// 检查分区流程涉及参数 /// </summary> /// <returns></returns> internal static bool CheckPartitionParam(MemoEdit txbBlog, PartitionParam partitionParam) { if (partitionParam.DBHelper == null) { WriteBlog(txbBlog, "--- 数据库连接异常, 请查看错误日志"); return(false); } else if (RegexCheck.IsEmpty(partitionParam.TablespaceName)) { WriteBlog(txbBlog, "--- 未指定表空间"); return(false); } else if (RegexCheck.IsEmpty(partitionParam.OriginTableName)) { WriteBlog(txbBlog, "--- 未指定初始表"); return(false); } else if (RegexCheck.IsEmpty(partitionParam.BasicField)) { WriteBlog(txbBlog, "--- 未指定分区列"); return(false); } else if (partitionParam.PartitionWay == EnumPartitionWay.Unknow) { WriteBlog(txbBlog, "--- 未指定分区方式"); return(false); } else if (!RegexCheck.IsFull(partitionParam.TablespaceSet)) { WriteBlog(txbBlog, "--- 存在没有指定表空间的分区"); return(false); } else if (RegexCheck.IsExist(QueryUnityInfo.QueryTotalTable(partitionParam.DBHelper, partitionParam.TablespaceName), partitionParam.PartitionedTableName)) { WriteBlog(txbBlog, "--- 名字为 " + partitionParam.PartitionedTableName + "的表已经存在,请更改导出名"); return(false); } else { if (partitionParam.PartitionWay == EnumPartitionWay.Range && partitionParam.PartitionCount == -1) { WriteBlog(txbBlog, "---未指定范围分区数"); return(false); } else { return(true); } } }
public void 檢查是否為時間_不是時間() { // arrange IChecker checker = new RegexCheck(); string militaryTime = "2!:22"; //期望值 string expected = "Error"; // 實際結果 string actual = checker.MilitaryTimeToRegularTime(militaryTime); // assert Assert.AreEqual(expected, actual); }
public void 檢查是否為時間_是時間() { // arrange IChecker checker = new RegexCheck(); string militaryTime = "00:00"; //期望值 String expected = "12:00 AM"; // 實際結果 String actual = checker.MilitaryTimeToRegularTime(militaryTime); // assert Assert.AreEqual(expected, actual); }
/// <summary> /// 设置分区工作流程参数 /// </summary> private void SetPartitionParam() { if (this._dbHelper != null) { this._partitionParam.DBHelper = this._dbHelper; } if (this.cmbTablespace.SelectedIndex != -1) { this._partitionParam.TablespaceName = this.cmbTablespace.SelectedItem.ToString(); } if (this.cmbOriginTable.SelectedIndex != -1) { this._partitionParam.OriginTableName = this.cmbOriginTable.SelectedItem.ToString(); } if (this.cmbColumnIdentity.SelectedIndex != -1) { this._partitionParam.BasicField = this.cmbColumnIdentity.SelectedItem.ToString(); } if (this.cmbPartitionWay.SelectedIndex != -1) { if (this.cmbPartitionWay.SelectedIndex == (int)EnumPartitionWay.List) { this._partitionParam.PartitionWay = EnumPartitionWay.List; } else if (this.cmbPartitionWay.SelectedIndex == (int)EnumPartitionWay.Range) { this._partitionParam.PartitionWay = EnumPartitionWay.Range; } } if (this._partitionCount != -1 && this.cmbPartitionWay.SelectedIndex == (int)EnumPartitionWay.Range) { this._partitionParam.PartitionCount = this._partitionCount; } if (this._partitionInfoSet != null) { List <string> tablespaceSet = new List <string>(); for (int i = 0; i < this._partitionInfoSet.Count; i++) { tablespaceSet.Add(this._partitionInfoSet[i].Tablespace); } this._partitionParam.TablespaceSet = tablespaceSet; } if (!RegexCheck.IsEmpty(this.txbTargetName.Text)) { this._partitionParam.PartitionedTableName = this.txbTargetName.Text; } }
/// <summary> /// 获取分区基准字段的基本类型 /// </summary> /// <returns></returns> private EnumBaseDataType GetFieldBaseType() { Dictionary <string, string> columnInfoSet = QueryUnityInfo.QueryColumnInfo(this._featureClass); if (RegexCheck.IsExist(ScreenTemplate.ScreenNumericType, this._basicField)) { return(EnumBaseDataType.NUMERIC); } else if (RegexCheck.IsExist(ScreenTemplate.ScreenCharacterType, this._basicField)) { return(EnumBaseDataType.CHARACTER); } else { return(EnumBaseDataType.DATATIME); } }
/// <summary> /// 验证控件输入键盘事件之后是否为数字 /// </summary> /// <param name="e">控件输入的键盘事件</param> /// <returns></returns> public bool ValidateNumeric(KeyPressEventArgs e) { do { if (e.KeyChar == (char)Keys.Back) { e.Handled = false; break; } if (!e.KeyChar.IsNumeric()) { e.Handled = true; break; } string newString = this.ClcNewText(e.KeyChar); e.Handled = !RegexCheck.IsDecimalInputing(newString); } while (false); return(!e.Handled); }
public override bool InputControl(string fullText) { if (fullText == null) { return(false); } if (fullText.Length == 1) { if ("-".Equals(fullText) || RegexCheck.IsInteger(fullText)) { return(true); } else { return(false); } } return(RegexCheck.IsInteger(fullText)); }
/// <summary> /// 检查数据库连接参数 /// </summary> /// <returns></returns> internal static bool CheckConnectParam(MemoEdit txbBlog, DbConnectParam dbConnectParam) { if (RegexCheck.IsEmpty(dbConnectParam.DBServer)) { WriteBlog(txbBlog, "--- 未指定IP地址"); return(false); } else if (!RegexCheck.IsIPv4(dbConnectParam.DBServer)) { WriteBlog(txbBlog, "--- 指定的IP地址格式不正确"); return(false); } else if (RegexCheck.IsEmpty(dbConnectParam.DbPort)) { WriteBlog(txbBlog, "--- 未指定端口号"); return(false); } else if (!RegexCheck.IsUint(dbConnectParam.DbPort)) { WriteBlog(txbBlog, "--- 指定的端口号格式不正确"); return(false); } else if (RegexCheck.IsEmpty(dbConnectParam.DbSid)) { WriteBlog(txbBlog, "--- 未指定实例名"); return(false); } else if (RegexCheck.IsEmpty(dbConnectParam.DbUser)) { WriteBlog(txbBlog, "--- 未指定登陆名"); return(false); } else if (RegexCheck.IsEmpty(dbConnectParam.DbPwd)) { WriteBlog(txbBlog, "--- 未指定口令"); return(false); } else { return(true); } }
public Dictionary <string, string> Validate() { RegexCheck regexCheck = new RegexCheck(); //Email: if (string.IsNullOrEmpty(email)) { errors.Add("email", "Email is required!"); } else if (!regexCheck.MailCheck(email)) { errors.Add("email", "Email is not valid!"); } //Password: if (string.IsNullOrEmpty(password)) { errors.Add("password", "Password is required!"); } return(errors); }
/// <summary> /// 导入配置 /// </summary> /// <returns></returns> public bool ImportConfig() { try { string filePath = this._filePath + DBTUNE_FILE_NAME; if (!File.Exists(filePath)) { return(false); } List <string> cmdParamSet = new List <string>(); string importParam = DbtuneTemplate.DBTUNE_IMPORT_PARAM; importParam = SetBaseParam(importParam); importParam = importParam.Replace("{file_path}", filePath); cmdParamSet.Add(importParam); //这里因为dbtune配置参数的导入命令需要用户确认,故在参数列表里传入一个'Y' cmdParamSet.Add("Y"); string cmdInvorkOutput = CmdInvork(cmdParamSet); if (RegexCheck.IsExist(cmdInvorkOutput, CMD_ERROR_STATE)) { LogHelper.Error.Append(cmdInvorkOutput); return(false); } else { return(true); } } catch (Exception ex) { LogHelper.Error.Append(ex); return(false); } }
/// <summary> /// 设置数据库连接参数 /// </summary> private void SetDbConnectParam() { if (!RegexCheck.IsEmpty(this.txbDBServer.Text)) { this._dbConnectParam.DBServer = this.txbDBServer.Text; } if (!RegexCheck.IsEmpty(this.txbDbPort.Text)) { this._dbConnectParam.DbPort = this.txbDbPort.Text; } if (!RegexCheck.IsEmpty(this.txbDbSid.Text)) { this._dbConnectParam.DbSid = this.txbDbSid.Text; } if (!RegexCheck.IsEmpty(this.txbDbUser.Text)) { this._dbConnectParam.DbUser = this.txbDbUser.Text; } if (!RegexCheck.IsEmpty(this.txbDbPwd.Text)) { this._dbConnectParam.DbPwd = this.txbDbPwd.Text; } }
/// <summary> /// 选择分区基准列下拉列表的关闭事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbColumnIdentity_Closed(object sender, DevExpress.XtraEditors.Controls.ClosedEventArgs e) { this._comboBox = (ComboBoxEdit)sender; if (this._comboBox.SelectedIndex != -1) { //判断分区基准列是否是字符型,若是,关闭分区方式下拉列表的权限,只能使用列表分区 if (RegexCheck.IsExist(ScreenTemplate.ScreenCharacterType, this._columnInfoSet[this._comboBox.SelectedItem.ToString()])) { this.cmbPartitionWay.SelectedIndex = (int)EnumPartitionWay.List; this.cmbPartitionWay.Enabled = false; PrepareListPartition("所选字段为字符型,只可使用列表分区,正在分析分区数量"); } else { this.cmbPartitionWay.Enabled = true; this.cmbPartitionWay.SelectedIndex = -1; this.txbTips.Text = string.Empty; } this.btnAssignTablespace.Text = string.Empty; } }
public Dictionary <string, string> Validate() { RegexCheck regexCheck = new RegexCheck(); //Firstname: if (string.IsNullOrEmpty(firstName)) { errors.Add("firstName", "Firstname is required!"); } else if (firstName.Length > 50) { errors.Add("firstName", "Max length is 50!"); } //Lastname: if (string.IsNullOrEmpty(lastName)) { errors.Add("lastName", "Lastname is required!"); } else if (lastName.Length > 50) { errors.Add("lastName", "Max length is 50!"); } //Phone: if (string.IsNullOrEmpty(phone)) { errors.Add("phone", "Phone is required!"); } else if (!regexCheck.CheckPattern(phone, RegexCheck.phonePattern)) { errors.Add("phone", "Phone is not valid!"); } //Address if (string.IsNullOrEmpty(address)) { errors.Add("address", "Address is required!"); } else if (address.Length > 255) { errors.Add("address", "Max length is 255!"); } //Introduction if (string.IsNullOrEmpty(introduction)) { errors.Add("introduction", "Introduction is required!"); } else if (introduction.Length > 255) { errors.Add("introduction", "Max length is 255!"); } //Gender: if (gender != 0 && gender != 1) { errors.Add("gender", "Please choose!"); } //Birthday: if (birthday.Equals("1601-01-01")) { errors.Add("birthday", "Please choose!"); } //Password: if (string.IsNullOrEmpty(password)) { errors.Add("password", "Password is required!"); } //Email: if (string.IsNullOrEmpty(email)) { errors.Add("email", "Email is required!"); } else if (!regexCheck.MailCheck(email)) { errors.Add("email", "Email is not valid!"); } return(errors); }
public override bool InputControl(string fullText) { return(RegexCheck.IsPlusInteger(fullText)); }