public void btnConfirm_Click(object sender, EventArgs e) { switch (InputBoxType) { case InputBoxTypes.NewFile: if (!Regex.IsMatch(txtInput.Text, JValidate.FileNameRegex)) { RabbitCouriers.SentErrorMessageByResource("JE_INPUTBOX_WRONG_FILE_NAME", Res.JE_TMI_NEW_JSON_FILE); return; } else if (File.Exists(Path.Combine(Var.JFI.DirectoryPath, $"{txtInput.Text}.json"))) { RabbitCouriers.SentErrorMessageByResource("JE_INPUTBOX_FILE_EXISTS", Res.JE_TMI_NEW_JSON_FILE, $"{Var.JFI.DirectoryPath}\\{txtInput.Text}.json"); return; } break; case InputBoxTypes.RenameFile: if (!Regex.IsMatch(txtInput.Text, JValidate.FileNameRegex)) { RabbitCouriers.SentErrorMessageByResource("JE_INPUTBOX_WRONG_FILE_NAME", Res.JE_TMI_RENAME_JSON_FILE); return; } else if (File.Exists(Path.Combine(Var.JFI.DirectoryPath, $"{txtInput.Text}.json"))) { RabbitCouriers.SentErrorMessageByResource("JE_INPUTBOX_FILE_EXISTS", Res.JE_TMI_RENAME_JSON_FILE, $"{Var.JFI.DirectoryPath}\\{txtInput.Text}.json"); return; } break; case InputBoxTypes.AddColumn: if (!Regex.IsMatch(txtInput.Text, JValidate.ColumnNameRegex)) { RabbitCouriers.SentErrorMessageByResource("JE_INPUTBOX_WRONG_COLUMN_NAME", Res.JE_TMI_ADD_COLUMN); return; } break; case InputBoxTypes.RenameColumn: if (!Regex.IsMatch(txtInput.Text, JValidate.ColumnNameRegex)) { RabbitCouriers.SentErrorMessageByResource("JE_INPUTBOX_WRONG_COLUMN_NAME", Res.JE_TMI_RENAME_COLUMN); return; } break; case InputBoxTypes.RenameDataBase: if (!Regex.IsMatch(txtInput.Text, JValidate.DatabaseRegex)) { RabbitCouriers.SentErrorMessageByResource("JE_INPUTBOX_WRONG_DATABASE_NAME", Res.JE_TMI_RENAME_DATABASE); return; } break; default: break; } ReturnValue = txtInput.Text; DialogResult = DialogResult.OK; }
public void btnAddItem_Click(object sender, EventArgs e) { if (ReturnValue.Contains(txtItemName.Text.Trim())) { RabbitCouriers.SentErrorMessageByResource("JE_CHOICE_DUPLICATE_ITEM", Res.JE_COLUMN_CHOICES, txtItemName.Text.Trim()); return; } ReturnValue.Add(txtItemName.Text.Trim()); RefreshList(); lsbItems.SelectedIndex = lsbItems.Items.Count - 1; }
public static void JTableLoadOrScanJsonFailed(JTable jt, JFileInvalidException ex, bool isScan) { string title = isScan ? Res.JE_ERR_SCAN_JSON_FAILED_TITLE : Res.JE_ERR_LOAD_JSON_FAILED_TITLE; switch (ex.Reason) { case JFileInvalidReasons.RootElementNotArray: RabbitCouriers.SentErrorMessageByResource("JE_ERR_ROOT_ELEMENT_NOT_ARRAY", title, jt.Name); break; case JFileInvalidReasons.ChildElementNotObject: RabbitCouriers.SentErrorMessageByResource("JE_ERR_CHILD_ELEMENT_NOT_OBJECT", title, jt.Name, ex.LineIndex + 1); break; case JFileInvalidReasons.ChildColumnCountVary: RabbitCouriers.SentErrorMessageByResource("JE_ERR_CHILD_COLUMN_COUNT_VARY", title, jt.Name, ex.LineIndex + 1); break; case JFileInvalidReasons.ChildColumnNameVary: RabbitCouriers.SentErrorMessageByResource("JE_ERR_CHILD_COLUMN_NAME_VARY", title, jt.Name, ex.LineIndex + 1, ex.ColumnName); break; case JFileInvalidReasons.ChildColumnOrderVary: RabbitCouriers.SentErrorMessageByResource("JE_ERR_CHILD_COLUMN_ORDER_VARY", title, jt.Name, ex.LineIndex + 1, ex.ColumnName); break; case JFileInvalidReasons.ChildColumnTypeVary: RabbitCouriers.SentErrorMessageByResource("JE_ERR_CHILD_COLUMN_TYPE_VARY", title, jt.Name, ex.LineIndex + 1, ex.ColumnName); break; default: RabbitCouriers.SentErrorMessageByResource("JE_ERR_TABLE_LOAD_JSON_FAILED_DEFAULT", title, jt.Name); //Trace break; } }
public static void SaveXMLFileFailed(Exception ex, string file) => RabbitCouriers.SentErrorMessageByResource("JE_ERR_SAVE_XML_FAILED", Res.JE_TMI_EXPORT_TO_XML, file);
public static void TableConvertToXMLFailed(Exception ex, JTable jt) => RabbitCouriers.SentErrorMessageByResource("JE_ERR_TABLE_CONVERT_TO_XML_FAILED", Res.JE_TMI_EXPORT_TO_XML, jt.Name, ex.Message);
public static void JsonConvertDeserializeJFIFailed(Exception ex) => RabbitCouriers.SentErrorMessageByResource("JE_ERR_JSONCONVERT_DESERIALIZE_JFI_FAILED_DEFAULT", Res.JE_ERR_DEFAULT_TITLE, ex.Message);
public static void ScanCSVFilesFailed(JTable jt, Exception ex) => RabbitCouriers.SentErrorMessageByResource("JE_ERR_SCAN_CSV_FILE_FAILED_DEFAULT", Res.JE_ERR_DEFAULT_TITLE, jt.Name, ex.Message);
public static void JsonConvertDeserializeObjectFailed(string fileName, Exception ex) => RabbitCouriers.SentErrorMessageByResource("JE_ERR_JSONCONVERT_DESERIALIZE_OBJECT_FAILED_DEFAULT", Res.JE_ERR_DEFAULT_TITLE, fileName, ex.Message);
public static void OpenJsonFileFailed(string filePath, Exception ex) => RabbitCouriers.SentErrorMessageByResource("JE_ERR_LOAD_JSON_FILE_FAILED_DEFAULT", Res.JE_ERR_DEFAULT_TITLE, filePath);