public static Cell BuildCell(int index, ExcelColumn col, RowHandler row) { Cell cell = null; CellConstruct constr = new CellConstruct(index, col, row); switch (col.ColumnType) { case ExcelColumn.ColumnTypes.Counter: case ExcelColumn.ColumnTypes.Text: case ExcelColumn.ColumnTypes.Note: case ExcelColumn.ColumnTypes.Number: case ExcelColumn.ColumnTypes.Unknown: cell = new CellText(constr); break; case ExcelColumn.ColumnTypes.Choice: cell = new CellTextDropdown(constr); break; case ExcelColumn.ColumnTypes.Custom: cell = col.CellBuilder(constr, col.BuilderArgs); break; default: break; } return cell; }
void grdRowGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { RowHandler row = HitTestRow(e.GetPosition(ExcelParams.GridControl.grdRowGrid)); if (startRow == null) startRow = row; if (Keyboard.Modifiers == ModifierKeys.Shift) { endRow = row; } else { startRow = row; endRow = null; } if (endRow == null) endRow = startRow; int startIndex = startRow.RowIndex; int endIndex = endRow.RowIndex; int tempIndex; if (endIndex < startIndex) { tempIndex = startIndex; startIndex = endIndex; endIndex = tempIndex; } ExcelParams.SelectHandler.ChangeSelection(SelectHandler.SelectTypes.Row, startIndex, endIndex); }
/// <summary> /// Creates a data reader extractor that delegates each row to a row handler /// </summary> /// <param name="rowHandler">a row handler that will be executed on each row</param> /// <returns>a data reader extractor</returns> private static DataReaderExtractor<object> GetDataReaderExtractor(RowHandler rowHandler) { return dataReader => { while (dataReader.Read()) { rowHandler(dataReader); } return null; }; }
public static void ExecuteHandler(this DbCommand cmd, RowHandler handler) { cmd.Connection.TryOpen(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { handler(reader); } } }
public static async Task ExecuteHandlerAsync(this DbCommand cmd, RowHandler handler) { await cmd.Connection.TryOpenAsync(); using (var reader = await cmd.ExecuteReaderAsync()) { while (await reader.ReadAsync()) { handler(reader); } } }
public void UpdateStatus(RowHandler handler, Status.StatusTypes statusType, string column, string message) { string statusMessage = message; string logMessage = message; if (statusType == Status.StatusTypes.ValidationError) { UpdateInfo("Validation Error!"); statusMessage = string.Format("Validation failed on: '{0}' {1}", column, message); logMessage = string.Format("Row: {0} - {1}", handler.ID, statusMessage); } UpdateStatus(statusMessage, logMessage, statusType); }
public void UpdatePlacement(RowHandler r) { //lastRow = currentRow; //currentRow = r; //currentAisle = r.sector; row = r.place; aisle = r.aisle; //if (lastRow) //{ // lastRow.RemoveOccupier(gameObject); //} //currentRow.AddGroupDictionary(this); }
/// <summary> /// Retrieves job parameters for an execution. /// </summary> /// <param name="executionId">the job execution id</param> /// <returns>the job parameters of that execution</returns> private JobParameters GetJobParameters(long executionId) { var parameters = new OrderedDictionary <string, JobParameter>(16); RowHandler handler = dataRecord => { var wrapper = new DataRecordWrapper(dataRecord); var type = (ParameterType)Enum.Parse(typeof(ParameterType), wrapper.Get <string>(2)); JobParameter parameter; switch (type) { case ParameterType.String: parameter = new JobParameter(wrapper.Get <string>(3), string.Equals(wrapper.Get <string>(7), "Y", StringComparison.OrdinalIgnoreCase)); break; case ParameterType.Long: parameter = new JobParameter(wrapper.Get <long>(5), string.Equals(wrapper.Get <string>(7), "Y", StringComparison.OrdinalIgnoreCase)); break; case ParameterType.Double: parameter = new JobParameter(wrapper.Get <double>(6), string.Equals(wrapper.Get <string>(7), "Y", StringComparison.OrdinalIgnoreCase)); break; case ParameterType.Date: parameter = new JobParameter(wrapper.Get <DateTime>(4), string.Equals(wrapper.Get <string>(7), "Y", StringComparison.OrdinalIgnoreCase)); break; default: throw new InvalidOperationException("Unsupported type :[" + type + "]"); //should never happen } parameters.Add(wrapper.Get <string>(1), parameter); }; DbOperator.Select(InsertTablePrefix(FindParamsFromIdQuery), handler, new Dictionary <string, object> { { "id", executionId } }); return(new JobParameters(parameters)); }
public void SetStatus(RowHandler.RowStatuss rowStatus, string tooltip) { if (tooltip == "") ToolTipService.SetToolTip(txtStatus, null); else ToolTipService.SetToolTip(txtStatus, tooltip); switch (rowStatus) { case RowHandler.RowStatuss.Normal: txtStatus.Text = ""; break; case RowHandler.RowStatuss.Updating: txtStatus.Text = "<>"; break; case RowHandler.RowStatuss.ValidationPending: txtStatus.Text = "O"; break; case RowHandler.RowStatuss.Deleting: txtStatus.Text = "D"; break; case RowHandler.RowStatuss.Errored: txtStatus.Text = "!"; break; case RowHandler.RowStatuss.Invalid: txtStatus.Text = "!V"; break; case RowHandler.RowStatuss.Adding: txtStatus.Text = "+"; break; case RowHandler.RowStatuss.New: txtStatus.Text = "*"; break; default: break; } }
/// <summary> /// Executes a select query using a DataAdapter. A row handler is run on each returned row. /// </summary> /// <param name="query">the SQL query</param> /// <param name="rowHandler">a mapper that will be executed on each returned row</param> /// <param name="parameters">the parameters of the query</param> public void Select(string query, RowHandler rowHandler, IDictionary<string, object> parameters) { Select(query, GetDataReaderExtractor(rowHandler), new DictionaryParameterSource { Parameters = parameters }); }
public void HideRow(RowHandler handler) { // Instead of removing just hide the rows grdRowGrid.RowDefinitions[handler.RowIndex].Height = new GridLength(0); grdMain.RowDefinitions[handler.RowIndex].Height = new GridLength(0); }
public void UpdateRow(RowHandler rowHandler) { if (!UpdateHandlerQueue.Contains(rowHandler)) { UpdateHandlerQueue.Add(rowHandler); } }
public void SetupRow(RowHandler row) { if(MoveOptimiseEnabled) row.Hide(); }
public DbfReader(Dbf dbf, Encoding textEncoding) { DbfTypeMap.Add('C', (i, b, f, e) => { if (f.Length == 1) { return(e.GetString(b)[0]); } return(e.GetString(b).TrimEnd('\0')); }); DbfTypeMap.Add('M', (i, b, f, e) => BitConverter.ToInt32(b)); DbfTypeMap.Add('W', (i, b, f, e) => BitConverter.ToInt32(b)); DbfTypeMap.Add('G', (i, b, f, e) => BitConverter.ToInt32(b)); DbfTypeMap.Add('Y', (i, b, f, e) => BitConverter.ToInt64(b) / 10000m); // Stored as int64 with 4 implicit decimal places DbfTypeMap.Add('D', (i, b, f, e) => { var dateStr = e.GetString(b).Trim(); return(dateStr == "" ? DateTime.MinValue : DateTime.ParseExact(dateStr, "yyyyMMdd", null)); }); DbfTypeMap.Add('T', (i, b, f, e) => JulianDateHelper.FromULongBuffer(b)); DbfTypeMap.Add('N', (i, b, f, e) => { var numStr = e.GetString(b).Trim(); if (f.DecimalCount == 0) { if (f.Length < 3) { if (numStr == "") { return((byte)0); } return(byte.Parse(numStr)); } else if (f.Length < 5) { if (numStr == "") { return((short)0); } return(short.Parse(numStr)); } else if (f.Length < 10) { if (numStr == "") { return((int)0); } return(int.Parse(numStr)); } else if (f.Length < 19) { if (numStr == "") { return((long)0); } return(long.Parse(numStr)); } } return(numStr == "" ? 0m : decimal.Parse(numStr)); }); DbfTypeMap.Add('B', (i, b, f, e) => BitConverter.ToInt32(b)); DbfTypeMap.Add('O', (i, b, f, e) => BitConverter.ToDouble(b)); DbfTypeMap.Add('F', (i, b, f, e) => { var numStr = e.GetString(b).Trim(); return(numStr == "" ? 0f : float.Parse(numStr)); }); DbfTypeMap.Add('I', (i, b, f, e) => BitConverter.ToInt32(b)); DbfTypeMap.Add('L', (i, b, f, e) => BitConverter.ToBoolean(b)); DbfTypeMap.Add('Q', CopyFieldBuffer); DbfTypeMap.Add('P', CopyFieldBuffer); this.dbf = dbf; TextEncoding = textEncoding; dbfHeader = dbf.GetHeader(); if (IsVisualFoxPro(dbfHeader)) { // Special handling for VFP DbfTypeMap['B'] = (i, b, f, e) => BitConverter.ToDouble(b); // VarChar/VarBinary // SPECIAL CASE for VARCHAR/BINARY DbfTypeMap['V'] = (i, b, f, e) => f.Flags.HasFlag(DbfFieldFlags.Binary) ? CopyFieldBuffer(i, b, f, e) : e.GetString(b); // _NullFlags nullField = dbfHeader.Fields.FirstOrDefault(x => x.Type == '0'); nullFieldDataHandler = DbfTypeMap['0'] = CopyFieldBuffer; if (nullField != null) { if (nullField.Length == 1) { nullFieldHandlerFactory = (i, b, f, e) => new UIntNullFieldHandler(b[0]); } else { nullFieldHandlerFactory = (i, b, f, e) => new BitArrayNullFieldHandler(b.ToArray()); } } } }
public void AddNewRow() { UndoHandler.DisableUndo(); if (EnableAdd) { Dictionary<string, object> newData = new Dictionary<string, object>(); foreach (string key in Columns.Keys) { newData.Add(Columns[key].PropertyBind,null); } RowHandler newRow = new RowHandler(this, Rows.Count, rowHeight, newData, RowHandler.RowStatuss.New); foreach (string key in Columns.Keys) { if (Columns[key].Default != null) newRow.FindCell(key).UpdateData(Columns[key].Default, false, true, false); } Rows.Add(newRow); } UndoHandler.EnableUndo(); }
void ListsService_GetListItemsCompleted(object sender, GetListItemsCompletedEventArgs e) { var tasks = new List<Task>(); XNamespace ns = "#RowsetSchema"; IEnumerable<XElement> rows = e.Result.Descendants(ns + "row"); string currentId1 = _currentUpdateCheck[_currentIndex].Data[ID1].ToString(); // Get all the rows for that tasks that have an ID foreach (XElement row in rows) { var task = new Task { ID = GetXElementAtt(row, "ID"), ID1 = GetXElementAtt(row, ID1), RegionalOffset = Convert.ToInt32(GetXElementAtt(row, "RegionalOffset") == "" ? "0" : GetXElementAtt(row, "RegionalOffset")), Created = Constants.CreateUTCDateTime(GetXElementAtt(row, "Created")), Status = GetXElementAtt(row, "Status"), Checklist = GetXElementAtt(row, "Checklist") }; tasks.Add(task); } // Work out which one(s) were created today, using the same algorithm as the dashboard uses var todayTasks = tasks.Where(t => t.Created > _currentDateAnchor.Date.AddMinutes(t.RegionalOffset)); List<Task> foundTasks = todayTasks.ToList(); _mainPage.AddToLog(string.Format("{0}: {1} tasks found in the live system. {2} tasks for today", currentId1, tasks.Count(), foundTasks.Count())); var updateRow = new RowHandler(); AddUpdateValue(updateRow, "Title"); AddUpdateValue(updateRow, ID1); AddUpdateValue(updateRow, "High_x0020_Level_x0020_Descripti"); AddUpdateValue(updateRow, "Asset_x0020_Category"); AddUpdateValue(updateRow, "Business_x0020_Area"); AddUpdateValue(updateRow, "Due_x0020_Time"); AddUpdateValue(updateRow, "Alert_x0020_Time"); AddUpdateValue(updateRow, "Escalation_x0020_Level_x0020_1_x"); AddUpdateValue(updateRow, "Key_x0020_Control"); AddUpdateValue(updateRow, "KPI"); AddUpdateValue(updateRow, "Matrix_x0020_Definition"); AddUpdateValue(updateRow, "Locations"); AddUpdateValue(updateRow, "Assign_x0020_to"); AddUpdateValue(updateRow, "Manager"); AddUpdateValue(updateRow, "Link_x0020_to_x0020_Process"); AddUpdateValue(updateRow, "Managing_x0020_Director"); AddUpdateValue(updateRow, "Director"); AddUpdateValue(updateRow, "Asset_x0020_Sub_x0020_Category"); AddUpdateValue(updateRow, "BypassManagerApproval"); AddUpdateValue(updateRow, "ManagerSelfApproval"); updateRow.rowUpdate.UpdateValues.Add("Checklist", _mainPage.CurrentList.ListName); if (!foundTasks.Any()) { updateRow.Data.Add("ID", 0); // If its being created, also add the following fields AddUpdateValue(updateRow, "Functional"); AddUpdateValue(updateRow, "Frequency"); AddUpdateValue(updateRow, "Specific_x0020_Frequency"); AddUpdateValue(updateRow, "RandomFrequency"); AddUpdateValue(updateRow, "Comments"); AddUpdateValue(updateRow, "Holiday_x0020_Calendar"); _mainPage.AddToLog(currentId1 + " not found in live system. Set to 'Add'"); updateRow.rowUpdate.UpdateType = RowUpdate.UpdateTypes.New; _addCount++; } else if(foundTasks.Count() == 1) { if(foundTasks[0].Status == "Outstanding") { _mainPage.AddToLog(currentId1 + " found in live system and 'Outstanding'. Set to 'Update'"); updateRow.Data.Add("ID", foundTasks[0].ID); updateRow.rowUpdate.UpdateType = RowUpdate.UpdateTypes.Update; _updateCount++; } else { _mainPage.AddToLog(currentId1 + " found in live system but no longer 'Outstanding'. Will not be updated."); updateRow = null; _notOutstandingCount++; } } else { string dupChecklists = ""; foreach (Task foundTask in foundTasks) { if(dupChecklists != "") dupChecklists += ","; dupChecklists += foundTask.Checklist; } _mainPage.AddToLog(currentId1 + " found more than once for the following checklists: " + dupChecklists + ". These tasks will not be updated."); updateRow = null; _duplicateCount++; } if(updateRow != null) _currentUpdateData.Add(_currentIndex, updateRow); // Locate and process the next update _currentIndex++; if (_currentIndex < _currentUpdateCheck.Count) RetrieveNextUpdate(); else { string message = "You are about to perform the following on the live system:\n\n"; bool confirmMessage = true; if (_addCount == 0 && _updateCount == 0) { confirmMessage = false; message += "Nothing will be updated in the live system.\n"; } else { if (_addCount > 0) message += string.Format("Add {0} tasks.\n", _addCount); if (_updateCount > 0) message += string.Format("Update {0} tasks.\n", _updateCount); } message += "\n"; if (_notOutstandingCount > 0) message += _notOutstandingCount + " tasks will not be updated because they have already been completed.\n"; if (_duplicateCount > 0) message += _duplicateCount + " tasks will not be updated because duplicate ID1's have been found. See the log for more details.\n"; if (confirmMessage) message += "\nDo you want to continue?"; if (_updateCount > 0) message += "\n\nPlease note, for the update tasks, the following live fields will not be changed:\nFunctional, Freq, Spec Freq, Rand Freq, Comments, Holiday Calendar.\n"; _mainPage.AddToLog("User confirmation required:\n************************************\n" + message + "\n****************************************"); _mainPage.StatusHide(); if (confirmMessage) MessageDialog.ShowConfirmation(message, LiveUpdateConfirmation, null, false); else { MessageDialog.ShowMessage(message); Clear(); } } }
// Remove a flag to stop the page closing if its tried. public void RemoveStoppingRow(RowHandler rowHandler, bool invalid) { if (invalid) { InvalidRows.Remove(rowHandler); } else { UpdatingRows.Remove(rowHandler); } }
public void SetStatus(RowHandler.RowStatuss rowStatus) { SetStatus(rowStatus, ""); }
public void SetCurrentRow(RowHandler r) { //currentRow = r; }
public virtual void PopulateData(List<Dictionary<string, object>> data) { InvalidRows = new List<RowHandler>(); UpdatingRows = new List<RowHandler>(); if (ItemsSource == null) ItemsSource = data; PopulateDataInitialize(); for (int i = 0; i < data.Count; i++) { RowHandler row = new RowHandler(this, i, rowHeight, data[i]); PopulateDataIterate(row); } PopulateDataPostSetup(data.Count); UndoHandler.ClearUndos(); }
public void RowChanged(RowHandler rowHandler) { if (RowChangedEvent != null) { RowChangedEventArgs e = new RowChangedEventArgs(); e.rowHandler = rowHandler; RowChangedEvent(this, e); } }
public virtual void RowSelected(RowHandler rowHandler) { if (RowSelectedEvent != null) { RowSelectedEventArgs e = new RowSelectedEventArgs(); e.SelectedItem = rowHandler; RowSelectedEvent(this, e); } }
internal void ChangeSelection(SelectTypes type, int rowStart, int rowEnd, int cellStart, int cellEnd, Cell cell) { Debug.WriteLine(string.Format("select:({0},{1}) ({2} {3})", cellStart, rowStart, cellEnd, rowEnd )); if (ExcelParams.GlobalRowSelect) { if (type == SelectTypes.Multi) { rowEnd -= 1; } type = SelectTypes.Row; rowStart = rowEnd; } SelectType = type; if (CurrentEditCell != cell || (cell == null && CurrentEditCell == null)) { if (CurrentEditCell != null) CurrentEditCell.IsSelected = false; if (type == SelectTypes.Single) { CurrentEditCell = cell; if (CurrentEditCell != null) { CurrentEditCell.IsSelected = true; CellAnchor = new Point(CurrentEditCell.Col, CurrentEditCell.Row); Debug.WriteLine(string.Format("{0}, {1}", CellAnchor.X, CellAnchor.Y)); } } // Unselect Rows HighlightRows(false); startRow = null; endRow = null; if(selectControl != null) selectControl.DisableConfig(); switch (SelectType) { case SelectTypes.Single: DisplaySelectControl(cellStart, rowStart, 1, 1); break; case SelectTypes.Multi: double oldBottom = multiArea.Bottom; if (selectControl.filling) cellEnd = (int)multiArea.Right; DisplaySelectControl(cellStart, rowStart,cellEnd - cellStart, rowEnd - rowStart); if (multiArea.Height > 1 && !selectControl.filling) selectControl.DisableFill(); if ((int)multiArea.Width == 1) if (GetCell(cellStart, 0).Column.ProcessMultiCellConfig != null) selectControl.EnableConfig(); if (oldBottom != rowEnd && selectControl.filling) { fillHandler.ProcessFill(); } break; case SelectTypes.Row: if (rowStart >= ExcelParams.Rows.Count) { rowStart = ExcelParams.Rows.Count - 1; rowEnd = rowStart; } if (rowEnd <= rowStart) rowEnd = rowStart; startRow = ExcelParams.Rows[rowStart]; endRow = ExcelParams.Rows[rowEnd]; HighlightRows(true); if(CurrentEditCell != null) CurrentEditCell.rowHandler.Update(); DisplaySelectControl(0, rowStart, ExcelParams.Columns.Count, rowEnd - rowStart + 1); selectControl.DisableFill(); if (startRow == endRow) ExcelParams.RowSelected(startRow); break; case SelectTypes.None: break; default: break; } } }
void AddUpdateValue(RowHandler newRow, string column) { Cell cell = _currentUpdateCheck[_currentIndex].FindCell(column); if(cell != null) newRow.rowUpdate.UpdateValues.Add(column, cell.rawData); }
internal void UnSelectRows() { startRow = null; endRow = null; CurrentEditCell = null; }
protected void PopulateDataIterate(RowHandler row) { Rows.Add(row); moveOptimise.SetupRow(row); }
void UpdateListItem(Dictionary<string, object> state, string listName, string listItemId, RowUpdate.UpdateTypes action, Dictionary<string, object> values) { RowHandler configListUpdate = new RowHandler(); configListUpdate.Data.Add("ID", HtmlEncode(listItemId)); configListUpdate.rowUpdate.UpdateType = action; if (action == RowUpdate.UpdateTypes.Update && values != null) { if (values.Count > 0) { foreach (KeyValuePair<string, object> field in values) { configListUpdate.rowUpdate.UpdateValues.Add(field.Key, HtmlEncode(values[field.Key].ToString())); } } } Dictionary<int, RowHandler> listitems = new Dictionary<int, RowHandler>(); listitems.Add(1, configListUpdate); _serviceParent.UpdateListItemsAsync(listName, BuildBatchStringWebService(null, listitems), state); }
// Add a flag to stop the page closing if its tried. public void AddStoppingRow(RowHandler rowHandler, bool invalid) { if (invalid) { if(!InvalidRows.Contains(rowHandler)) InvalidRows.Add(rowHandler); } else { if (!UpdatingRows.Contains(rowHandler)) UpdatingRows.Add(rowHandler); } }
public CellConstruct(int _col, ExcelColumn _column, RowHandler _rowHandler) { Col = _col; Column = _column; rowHandler = _rowHandler; }