public NotificationView() { InitializeComponent(); ColumnHelper c = new ColumnHelper(); c.Handle(list, "NotificationView"); }
public bool CreateTable(string tableName, List <ColumnData> columns) { try { ColumnHelper.SetDefaultColumns(columns); var sql = ScriptHelper.GetMySQLCreateTableSql(tableName, columns); var result = m_Execute.ExecuteNonQuery(sql); if (result == -2) { return(false); } return(true); } catch (Exception ex) { SLLog.WriteError(new LogData { Source = ToString(), FunctionName = "CreateTable Error!", Ex = ex, }); if (Settings.ThrowExceptions) { throw new Exception("CreateTable Error!", ex); } return(false); } }
public TransactionView() { InitializeComponent(); ColumnHelper c = new ColumnHelper(); c.Handle(list, "TransactionView"); }
public RecipeView() { InitializeComponent(); ColumnHelper c = new ColumnHelper(); c.Handle(treeList, "RecipeView"); }
public override void ItemDeleting(SPItemEventProperties properties) { SPListItem PublishedCopy = null; try { PublishedCopy = properties.ListItem; string sourceURL = ColumnHelper.GetFieldValue(PublishedCopy, ColumnHelper.PublishedFromInternalColumnName); SPListItem sourceItem = ListHelper.GetSPItemFromURL(sourceURL); if (sourceItem != null) { StringBuilder sourceLinks = new StringBuilder(ColumnHelper.GetFieldValue(sourceItem, ColumnHelper.PublishedToInternalColumnName)); string LinkTextInSource = ListHelper.GetDisplayUrl(PublishedCopy) + " ;"; sourceLinks = sourceLinks.Replace(LinkTextInSource, ""); ColumnHelper.SetFieldValue(sourceItem, ColumnHelper.PublishedToInternalColumnName, sourceLinks.ToString()); sourceItem.SystemUpdate(); } } catch { //if exception was caused because the published from field has been removed from this list, //remove the event handler if (!(ColumnHelper.ListContainsField(properties.ListItem.ParentList, ColumnHelper.PublishedFromInternalColumnName))) { RemoveEventReceiver(properties.ListItem.ParentList); } } base.ItemDeleting(properties); }
public SearchView() { InitializeComponent(); ColumnHelper c = new ColumnHelper(); c.Handle(list, "Search"); }
public void TestGetColumn() { CT_Worksheet worksheet = new CT_Worksheet(); CT_Cols cols1 = worksheet.AddNewCols(); CT_Col col1 = cols1.AddNewCol(); col1.min = (1); col1.max = (1); col1.width = (88); col1.hidden = (true); CT_Col col2 = cols1.AddNewCol(); col2.min = (2); col2.max = (3); CT_Cols cols2 = worksheet.AddNewCols(); CT_Col col4 = cols2.AddNewCol(); col4.min = (3); col4.max = (6); // Remember - POI column 0 == OOXML column 1 ColumnHelper helper = new ColumnHelper(worksheet); Assert.IsNotNull(helper.GetColumn(0, false)); Assert.IsNotNull(helper.GetColumn(1, false)); Assert.AreEqual(88.0, helper.GetColumn(0, false).width, 0.0); Assert.AreEqual(0.0, helper.GetColumn(1, false).width, 0.0); Assert.IsTrue(helper.GetColumn(0, false).hidden); Assert.IsFalse(helper.GetColumn(1, false).hidden); Assert.IsNull(helper.GetColumn(99, false)); Assert.IsNotNull(helper.GetColumn(5, false)); }
private void ViewTasks_Click(object sender, EventArgs e) { var props = typeof(DriveWipeTaskModel).GetProperties(); var rows = new List <RowModel>(); foreach (var kvp in Tasks) { foreach (var driveWipeTaskModel in kvp.Value) { var cells = new List <CellModel> { new CellModel { InitialValue = kvp.Key.Name } }; cells.AddRange(props.Select(prop => new CellModel { InitialValue = prop.GetValue(driveWipeTaskModel) })); rows.Add(new RowModel { Cells = cells }); } } using (var viewTasksDialog = new GenericGridForm( ColumnHelper.GetDriveWipeColumnDefinitions(ResourceManager), rows, ResourceManager.GetString("Tasks"))) { viewTasksDialog.ShowDialog(); } }
public override void ItemDeleting(SPItemEventProperties properties) { SPListItem PublishedOriginal = null; try { PublishedOriginal = properties.ListItem; string destinationURLs = ColumnHelper.GetFieldValue(PublishedOriginal, ColumnHelper.PublishedToInternalColumnName); string[] destinationUrlArray = destinationURLs.Split(';'); foreach (string destinationDisplayUrl in destinationUrlArray) { SPListItem destinationItem = ListHelper.GetSPItemFromURL(destinationDisplayUrl); if (destinationItem != null) { //if the destination list has been decoupled then do not delete the item there. if (ColumnHelper.ListContainsField(destinationItem.ParentList, ColumnHelper.PublishedFromInternalColumnName)) { destinationItem.Recycle(); } } } } catch { //if exception was caused because the published to field has been removed from this list, //remove the event handler if (!ColumnHelper.ListContainsField(properties.ListItem.ParentList, ColumnHelper.PublishedToInternalColumnName)) { RemoveEventReceiver(properties.ListItem.ParentList); } } base.ItemDeleting(properties); }
private void SetInitialValues() { enableCheckBox.Checked = ColumnHelper.GetAutomaticUpdateEnabled(); updateServerTextBox.Text = ColumnHelper.GetUpdateServer(); _initialAutomaticUpdateEnabled = enableCheckBox.Checked; _initialUpdateServer = updateServerTextBox.Text; }
public void ParseReference(string reference, long number, bool isFixed) { ColumnHelper c = new ColumnHelper(reference); Assert.AreEqual(number, c.Number); Assert.AreEqual(isFixed, c.IsFixed); }
public void ShouldThrowExceptionWhenTheClassHasNoIgnoreOrColumnAttribute() { Action act = () => { ColumnHelper.GetFildesInfo <TableDummy1>(); }; act.Should() .Throw <InvalidOperationException>(); }
public static void LoadLastSession() { ColumnHelper.ColumnCollectionFileName = RegistryHandler.ReadFromRegistry("ColumnsFileName"); if (ColumnHelper.ColumnCollectionFileName == "") { ColumnHelper.ColumnCollectionFileName = null; string defaultColumnName = RegistryHandler.ReadFromRegistry("DefaultColumnName"); if (defaultColumnName == "TextDataCleaned") { ColumnHelper.ColumnCollection = ColumnHelper.XmlToColumnCollection(SQLEventAnalyzer.Properties.Resources.TextDataCleaned); } } else { ColumnCollection temporaryColumns = ColumnHelper.XmlToColumnCollection(XmlHelper.ReadXmlFromFile(ColumnHelper.ColumnCollectionFileName)); if (ColumnHelper.ColumnCollection == null) { ColumnHelper.ColumnCollectionFileName = null; } else { ColumnHelper.ColumnCollection = temporaryColumns; } } }
private string GetDataAccess(IEnumerable <IDictionary <string, object> > data, IEnumerable <FieldAccessDto> fields) { var jArray = new JArray(); if (data == null) { return(jArray.ToString()); } foreach (var model in data) { var jObject = new JObject(); foreach (var fieldAccessDto in fields) { var proper = model.FirstOrDefault(f => f.Key.ToLower() == ColumnHelper.GetFieldName(fieldAccessDto.Name)?.ToLower()); if (string.IsNullOrWhiteSpace(proper.Key)) { continue; } jObject.Add(proper.Key, new JValue(proper.Value)); } jArray.Add(jObject); } return(jArray.ToString()); }
private void CheckForCustomColumnsUpdate() { if (ColumnHelper.GetAutomaticUpdateEnabled()) { _customColumnsCheckForUpdatesForm = new CustomColumnsCheckForUpdatesForm(ColumnHelper.ColumnCollectionFileName); _customColumnsCheckForUpdatesForm.UpdateCheckCompleteEvent += CustomColumnsUpdateCheckCompleteEvent; _customColumnsCheckForUpdatesForm.CheckForUpdates(); } }
public void TestAddCleanColIntoCols() { CT_Worksheet worksheet = new CT_Worksheet(); ColumnHelper helper = new ColumnHelper(worksheet); CT_Cols cols1 = new CT_Cols(); CT_Col col1 = cols1.AddNewCol(); col1.min = (1); col1.max = (1); col1.width = (88); col1.hidden = (true); CT_Col col2 = cols1.AddNewCol(); col2.min = (2); col2.max = (3); CT_Col col3 = cols1.AddNewCol(); col3.min = (13); col3.max = (16750); Assert.AreEqual(3, cols1.sizeOfColArray()); CT_Col col4 = cols1.AddNewCol(); col4.min = (8); col4.max = (9); Assert.AreEqual(4, cols1.sizeOfColArray()); // No overlap helper.AddCleanColIntoCols(cols1, createCol(4, 5)); Assert.AreEqual(5, cols1.sizeOfColArray()); // Overlaps with 8 - 9 (overlap and after replacements required) CT_Col col6 = createCol(8, 11); col6.hidden = (true); helper.AddCleanColIntoCols(cols1, col6); Assert.AreEqual(6, cols1.sizeOfColArray()); // Overlaps with 8 - 9 (before and overlap replacements required) CT_Col col7 = createCol(6, 8); col7.width = (17.0); helper.AddCleanColIntoCols(cols1, col7); Assert.AreEqual(8, cols1.sizeOfColArray()); // Overlaps with 13 - 16750 (before, overlap and after replacements required) helper.AddCleanColIntoCols(cols1, createCol(20, 30)); Assert.AreEqual(10, cols1.sizeOfColArray()); // Overlaps with 20 - 30 (before, overlap and after replacements required) helper.AddCleanColIntoCols(cols1, createCol(25, 27)); // TODO - assert something interesting Assert.AreEqual(12, cols1.col.Count); Assert.AreEqual(1u, cols1.GetColArray(0).min); Assert.AreEqual(16750u, cols1.GetColArray(11).max); }
private void InitializeOutputTypeComboBox() { outputTypeComboBox.Items.Add(new ComboBoxItem(ColumnHelper.GetColumnTypeName(Column.ColumnType.RegEx), Column.ColumnType.RegEx)); outputTypeComboBox.Items.Add(new ComboBoxItem(ColumnHelper.GetColumnTypeName(Column.ColumnType.SQL), Column.ColumnType.SQL)); outputTypeComboBox.Items.Add(new ComboBoxItem(ColumnHelper.GetColumnTypeName(Column.ColumnType.Constant), Column.ColumnType.Constant)); outputTypeComboBox.Items.Add(new ComboBoxItem(ColumnHelper.GetColumnTypeName(Column.ColumnType.StoredProcedureName), Column.ColumnType.StoredProcedureName)); outputTypeComboBox.Items.Add(new ComboBoxItem(ColumnHelper.GetColumnTypeName(Column.ColumnType.StoredProcedureParameter), Column.ColumnType.StoredProcedureParameter)); outputTypeComboBox.Items.Add(new ComboBoxItem(ColumnHelper.GetColumnTypeName(Column.ColumnType.LogParameter), Column.ColumnType.LogParameter)); }
public IEnumerable <IDictionary <string, object> > Query(bool useHeaderRow, string sheetName, string startCell) { if (startCell != "A1") { throw new NotImplementedException("CSV not Implement startCell"); } if (_stream.CanSeek) { _stream.Position = 0; } var reader = _config.StreamReaderFunc(_stream); { var row = string.Empty; string[] read; var firstRow = true; Dictionary <int, string> headRows = new Dictionary <int, string>(); while ((row = reader.ReadLine()) != null) { read = Split(row); //header if (useHeaderRow) { if (firstRow) { firstRow = false; for (int i = 0; i <= read.Length - 1; i++) { headRows.Add(i, read[i]); } continue; } var cell = CustomPropertyHelper.GetEmptyExpandoObject(headRows); for (int i = 0; i <= read.Length - 1; i++) { cell[headRows[i]] = read[i]; } yield return(cell); continue; } //body { var cell = CustomPropertyHelper.GetEmptyExpandoObject(read.Length - 1, 0); for (int i = 0; i <= read.Length - 1; i++) { cell[ColumnHelper.GetAlphabetColumnName(i)] = read[i]; } yield return(cell); } } } }
/// <summary> /// Получить колонки в формате json /// </summary> /// <param name="fields">Список доступных колонок</param> /// <returns></returns> public async Task <string> GetColumns(IEnumerable <FieldAccessDto> fields) { var jArray = new JArray(); foreach (var field in fields) { if (!(field.IsVisibleList ?? false)) { continue; } var fieldName = ColumnHelper.GetFieldName(field.Name); var jColumn = new JObject(); jColumn.Add("caption", new JValue(field.DisplayName)); jColumn.Add("dataField", new JValue(fieldName)); jColumn.Add("width", new JValue($"{field.WidthList}%")); if (field.TypeControl == TypeControl.Photo) { jColumn.Add("cell-template", new JValue("cellTemplate")); } if (!string.IsNullOrWhiteSpace(field.Mask) && field.TypeControl != TypeControl.TextEdit) { if (field.Mask.StartsWith("{")) { jColumn.Add("format", JObject.Parse(field.Mask)); } else { jColumn.Add("format", new JValue(field.Mask)); } } else if (!string.IsNullOrWhiteSpace(field.Mask) && field.TypeControl == TypeControl.TextEdit) { var jOptions = new JObject(); if (field.Mask.StartsWith("{")) { jOptions.Add("mask", JObject.Parse(field.Mask)); } else { jOptions.Add("mask", new JValue(field.Mask)); } jColumn.Add("editorOptions", jOptions); } jColumn.Add("dataType", new JValue(await GetDataTypeColumn(field))); jArray.Add(jColumn); } return(jArray.ToString()); }
public override void ItemUpdated(SPItemEventProperties properties) { SPListItem PublishedOriginal = null; bool updatePublishedToField = false; try { PublishedOriginal = properties.ListItem; StringBuilder destinationURLs = new StringBuilder(ColumnHelper.GetFieldValue(PublishedOriginal, ColumnHelper.PublishedToInternalColumnName)); string[] destinationUrlArray = destinationURLs.ToString().Split(';'); foreach (string destinationDisplayUrl in destinationUrlArray) { SPListItem destinationItem = ListHelper.GetSPItemFromURL(destinationDisplayUrl); if (destinationItem != null) { if (ColumnHelper.ListContainsField(destinationItem.ParentList, ColumnHelper.PublishedFromInternalColumnName)) { ItemCopier.ListItemCopyOptions options = new ItemCopier.ListItemCopyOptions(); options.IncludeAttachments = true; options.OperationType = ItemCopier.OperationType.Copy; options.Overwrite = true; options.DestinationFolder = ListHelper.GetSPFolderFromURL(destinationDisplayUrl); options.LinkToOriginal = true; using (ItemCopier myCopier = new ItemCopier(PublishedOriginal, destinationItem.ParentList, options)) { myCopier.UpdateItem(destinationItem.ID); } } else //published from column has been deleted, treat this as an unlinked list and do not syndicate the update { string old = destinationURLs.ToString(); destinationURLs = destinationURLs.Replace(destinationDisplayUrl, ""); destinationURLs = new StringBuilder(destinationURLs.Replace("; ;", "; ").ToString().TrimStart(';').Trim()); updatePublishedToField = true; } } if (updatePublishedToField) { ColumnHelper.SetFieldValue(PublishedOriginal, ColumnHelper.PublishedToInternalColumnName, destinationURLs.ToString()); PublishedOriginal.SystemUpdate(); } } } catch { //if exception was caused because the published to field has been removed from this list, //remove the event handler if (!ColumnHelper.ListContainsField(properties.ListItem.ParentList, ColumnHelper.PublishedToInternalColumnName)) { RemoveEventReceiver(properties.ListItem.ParentList); } } base.ItemUpdated(properties); }
public bool RenewTbl(string tableName, List <ColumnData> columns) { try { var result = true; var scriptList = new List <string>(); var oldColumns = new List <ColumnData>(); var timeStamp = DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second + "_" + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString(); //Standart Felder erstellen ColumnHelper.SetDefaultColumns(columns); var oldTblSchema = ExecuteReadTableSchema(string.Format("SELECT * FROM {0}", tableName)); foreach (DataRow row in oldTblSchema.Rows) { var oldCol = columns.Find(i => i.Name == row["ColumnName"].ToString()); if (oldCol == null) { continue; } oldCol.existsInDB = true; oldColumns.Add(oldCol); } scriptList.Add(string.Format("ALTER TABLE {0} RENAME TO {0}_OLD{1}", tableName, timeStamp)); scriptList.Add(ScriptHelper.GetCreateTableSql(tableName, columns)); var insertSQL = string.Format("INSERT INTO {0} ({1}) ", tableName, ColumnHelper.GetColumnString(columns, true)); insertSQL += string.Format("SELECT {2} FROM {0}_OLD{1}", tableName, timeStamp, ColumnHelper.GetColumnString(columns)); scriptList.Add(insertSQL); var exResult = ExecuteNonQuery(scriptList); if (exResult == -2) { result = false; } return(result); } catch (Exception ex) { SLLog.WriteError(new LogData { Source = ToString(), FunctionName = "RenewTbl Error!", Ex = ex, }); return(false); } }
public void TestSortColumns() { CT_Cols cols1 = new CT_Cols(); CT_Col col1 = cols1.AddNewCol(); col1.min = (1); col1.max = (1); col1.width = (88); col1.hidden = (true); CT_Col col2 = cols1.AddNewCol(); col2.min = (2); col2.max = (3); CT_Col col3 = cols1.AddNewCol(); col3.min = (13); col3.max = (16750); Assert.AreEqual(3, cols1.sizeOfColArray()); CT_Col col4 = cols1.AddNewCol(); col4.min = (8); col4.max = (11); Assert.AreEqual(4, cols1.sizeOfColArray()); CT_Col col5 = cols1.AddNewCol(); col5.min = (4); col5.max = (5); Assert.AreEqual(5, cols1.sizeOfColArray()); CT_Col col6 = cols1.AddNewCol(); col6.min = (8); col6.max = (9); col6.hidden = (true); CT_Col col7 = cols1.AddNewCol(); col7.min = (6); col7.max = (8); col7.width = (17.0); CT_Col col8 = cols1.AddNewCol(); col8.min = (25); col8.max = (27); CT_Col col9 = cols1.AddNewCol(); col9.min = (20); col9.max = (30); Assert.AreEqual(9, cols1.sizeOfColArray()); Assert.AreEqual(20u, cols1.GetColArray(8).min); Assert.AreEqual(30u, cols1.GetColArray(8).max); ColumnHelper.SortColumns(cols1); Assert.AreEqual(9, cols1.sizeOfColArray()); Assert.AreEqual(25u, cols1.GetColArray(8).min); Assert.AreEqual(27u, cols1.GetColArray(8).max); }
public override void SetScalarColumnText(int i) { if (_selectColumns == null) { // Dialect function ColumnHelper.GenerateSingleScalarColumn(Walker.ASTFactory, this, i); } else { // Collection 'property function' ColumnHelper.GenerateScalarColumns(Walker.ASTFactory, this, _selectColumns, i); } }
private void AdvancedHardDriveWipeDialog_Load(object sender, EventArgs e) { Text = ResourceManager.GetString("HDDWipeDialog"); OK.Text = ResourceManager.GetString("OK"); Cancel.Text = ResourceManager.GetString("Cancel"); AddTask.Text = ResourceManager.GetString("AddTask"); ClearTasks.Text = ResourceManager.GetString("ClearTasks"); ViewTasks.Text = ResourceManager.GetString("ViewTasks"); DriveSelectionGrid.AddColumns(ColumnHelper.GetDriveSelectionColumnDefinitions(ResourceManager)); DriveSelectionGrid.AddRows(RowHelper.GetDriveSelectionRows()); DriveSelectionGrid.RefreshGrid(); }
/** * Creates and adds a hidden column and then a best fit column with the given min/max pairs. * Suitable for testing handling of overlap. */ private CT_Cols createHiddenAndBestFitColsWithHelper(int hiddenMin, int hiddenMax, int bestFitMin, int bestFitMax) { CT_Worksheet worksheet = new CT_Worksheet(); ColumnHelper helper = new ColumnHelper(worksheet); CT_Cols cols = worksheet.GetColsArray(0); CT_Col hidden = createCol(hiddenMin, hiddenMax); hidden.hidden = (true); helper.AddCleanColIntoCols(cols, hidden); CT_Col bestFit = createCol(bestFitMin, bestFitMax); bestFit.bestFit = (true); helper.AddCleanColIntoCols(cols, bestFit); return(cols); }
public void TestSetColumnAttributes() { CT_Col col = new CT_Col(); col.width = (12); col.hidden = (true); CT_Col newCol = new CT_Col(); Assert.AreEqual(0.0, newCol.width, 0.0); Assert.IsFalse(newCol.hidden); ColumnHelper helper = new ColumnHelper(new CT_Worksheet()); helper.SetColumnAttributes(col, newCol); Assert.AreEqual(12.0, newCol.width, 0.0); Assert.IsTrue(newCol.hidden); }
private string GetModelAccess(IDictionary <string, object> model, IEnumerable <FieldAccessDto> fields) { var jObject = new JObject(); foreach (var fieldAccessDto in fields) { var proper = model.FirstOrDefault(f => f.Key.ToLower() == ColumnHelper.GetFieldName(fieldAccessDto.Name)?.ToLower()); if (string.IsNullOrWhiteSpace(proper.Key)) { continue; } jObject.Add(proper.Key, new JValue(proper.Value)); } return(jObject.ToString()); }
public void Initialize() { InitializeDictionary(); string fileName = null; if (ColumnHelper.ColumnCollectionFileName != null) { fileName = Path.GetFileName(ColumnHelper.ColumnCollectionFileName); } fileNameTextBox.Text = fileName; fileVersionTextBox.Text = ColumnHelper.GetVersion().ToString(); SetInitialValues(); }
private async Task <JObject> CreateSimpleItem(FieldAccessDto field) { var jProperty = new JObject(); jProperty.Add("editorType", new JValue(await GetDataTypeProperty(field))); jProperty.Add("isRequired", new JValue(field.TypeProfileForm == TypeProfileForm.Required)); jProperty.Add("dataField", new JValue(ColumnHelper.GetFieldName(field.Name))); var jLabel = new JObject(); jLabel.Add("text", new JValue(field.DisplayName)); jProperty.Add("label", jLabel); var joptions = new JObject(); joptions.Add("readOnly", new JValue(field.IsKey)); joptions.Add("onValueChanged", new JValue("")); await AddPropSimleComboBox(field, joptions); await AddPropSimleNumberBox(field, jProperty); if (field.TypeControl == TypeControl.DateEdit) { joptions.Add("useMaskBehavior", new JValue(true)); } if (field.MaxLength != 0) { joptions.Add("maxLength", new JValue(field.MaxLength)); } string nameMask = field.TypeControl != TypeControl.NumericEdit ? "mask" : "format"; if (!string.IsNullOrWhiteSpace(field.Mask)) { if (field.Mask.StartsWith("{")) { joptions.Add(nameMask, JObject.Parse(field.Mask)); } else { joptions.Add(nameMask, new JValue(field.Mask)); } } jProperty.Add("editorOptions", joptions); return(jProperty); }
// ReSharper disable once SuggestBaseTypeForParameter private List <PropertyDescriptor> BuildDescriptors(string[] properties) { var descriptors = new List <PropertyDescriptor>(); // ReSharper disable once ForCanBeConvertedToForeach // ReSharper disable once LoopCanBeConvertedToQuery for (var i = 0; i < properties.Length; i++) { var property = properties[i]; var descriptor = new DynamicDataViewModelPropertyDescriptor(property, ColumnHelper.DisplayName(property), GetValue(property).GetType()); descriptors.Add(descriptor); } return(descriptors); }