private void MachineQuotaForm_Load(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; user_TextBox.Text = UserManager.CurrentUserName; scenario_TextBox.Text = _scenario.Name; owner_TextBox.Text = _scenario.Owner; quota_DataGridView.DataSource = _platformUsage; foreach (DataGridViewRow row in quota_DataGridView.Rows) { var data = row.DataBoundItem as ScenarioPlatformUsage; if (data.AuthorizedCount < data.RequiredCount || (data.AuthorizedCount == 0 && data.RequiredCount == 0)) { row.Cells[0].Value = platform_ImageList.Images["Cross"]; } else { row.Cells[0].Value = platform_ImageList.Images["Tick"]; } } submit_LinkLabel.Visible = _platformUsage.Any(x => x.RequiredCount > x.AuthorizedCount); } finally { Cursor = Cursors.Default; } }
private void UserEditForm_Load(object sender, EventArgs e) { var selectedItem = _selectedItemsList.FirstOrDefault(x => x.Name.Equals(_group.Name)); if (selectedItem != null) { var actualGroup = _masterItemsList.FirstOrDefault(x => x.Name.Equals(_group.Name)); if (actualGroup != null) { groupName_ComboBox.Items.Add(actualGroup); groupName_ComboBox.SelectedIndex = 0; groupName_ComboBox.Enabled = false; description_TextBox.Focus(); } else { MessageBox.Show("The group '{0}' is not configured on the Active Directory server, so it will be removed"); _selectedItemsList.Remove(selectedItem); Close(); } } else { foreach (var item in _masterItemsList) { if (!_selectedItemsList.Any(x => x.Name.Equals(item.Name))) { groupName_ComboBox.Items.Add(item); } } } description_TextBox.DataBindings.Add("Text", _group, "Description", false, DataSourceUpdateMode.OnPropertyChanged); }
private static void DeleteApplications(AssetInventoryContext entities, Dictionary <String, SortableBindingList <StringValue> > applicationNames) { if (entities == null) { throw new ArgumentNullException("entities"); } if (applicationNames == null) { throw new ArgumentNullException("applicationNames"); } foreach (CitrixPublishedApp app in entities.CitrixPublishedApps) { SortableBindingList <StringValue> appList = null; // Remove each entry in the system that is found in the target applicationNames by hostname // but where the application names is not included in the target set of application names // for that host. if (applicationNames.TryGetValue(app.CitrixServer, out appList) && !appList.Any(n => n.Value.EqualsIgnoreCase(app.ApplicationName))) { entities.CitrixPublishedApps.Remove(app); } } entities.SaveChanges(); }
private void SaveSourceFile(SortableBindingList <DataItem> data) { if (!data.Any()) { MessageBox.Show("Отсутствуют данные для сохранения.", "XDataConv", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!String.IsNullOrEmpty(_openSourceFileDialog.FileName)) { _saveSourceFileDialog.InitialDirectory = Path.GetDirectoryName(_openSourceFileDialog.FileName); } if (_saveSourceFileDialog.ShowDialog() != DialogResult.OK) { return; } try { var fileManager = new CsvFileManager(_logger); fileManager.WriteToFile(_saveSourceFileDialog.FileName, data); MessageBox.Show($"Данные сохранены в файл {_saveSourceFileDialog.FileName}.", "XDataConv", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { _logger.Error($"Error writing file {_saveSourceFileDialog.FileName}", ex); MessageBox.Show($"Ошибка сохранения файла {_saveSourceFileDialog.FileName}.{Environment.NewLine}{ex.Message}", "XDataConv", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AddButton_Click(object sender, EventArgs e) { decimal newAmount = AmountTextbox.Value; if (newAmount > _origAmount) { ClientHelper.ShowErrorMessage("Amount cannot be greater than original amount."); return; } if (!selectedDebits.Any(a => a.Reference == ReferenceTextbox.Text)) { var newDebit = new DebitDetailModel() { Id = this.id, Reference = ReferenceTextbox.Text, Amount = AmountTextbox.Value }; selectedDebits.Add(newDebit); } else { var oldDebit = selectedDebits.FirstOrDefault(a => a.Reference == ReferenceTextbox.Text); oldDebit.Amount = AmountTextbox.Value; } BindSelectedDebits(); ComputeTotal(); }
private void crearEntradas(Ubicacion u, SortableBindingList <Entrada> entradasVendidas, List <Entrada> entradasDisponibles) { int fila = u.filas, asiento = u.asientos; if (!u.sinNumerar) // Si es numerada { if (fila * asiento == u.ocupados) { return; } while (fila > 0) { while (asiento > 0) { Entrada entradaNueva = new Entrada(u.id, fila, asiento, u); if (!entradasVendidas.Any(e => e.EsIgual(entradaNueva))) { entradasDisponibles.Add(entradaNueva); } asiento -= 1; } asiento = u.asientos; fila -= 1; } } else { if (asiento == u.ocupados) { return; } if (asiento > 0) { Entrada entradaNueva = new Entrada(u.id, fila, asiento, u); if (!entradasVendidas.Any(e => e.EsIgual(entradaNueva))) { entradasDisponibles.Add(entradaNueva); } } } }
private void BindInvoices() { purchaseCounterItemModelBindingSource.DataSource = null; if (invoiceList.Any()) { purchaseCounterItemModelBindingSource.DataSource = invoiceList; } }
private void BindPOs() { purchaseDisplayModelBindingSource.DataSource = null; if (poList.Any()) { purchaseDisplayModelBindingSource.DataSource = poList; } }
void Sort(string key, bool ascending) { if (_bindingList.Any()) // only sort if array contains something { var comparer = _bindingList.First().GetComparer(key, ascending); if (comparer != null) { _bindingList.Sort(comparer); } } }
/// <summary> /// Gets a faculty list /// </summary> /// <param name="sender">Form object</param> public async void GetAllAfaculty(object sender = null) { if (String.IsNullOrWhiteSpace(DataConnectionClass.ConnectionString)) { return; } Sender = sender; SortableBindingList <Faculty> fac = await Task.Run(() => Get_Faculty_List()); SortableBindingList <BuildingClass> b = Get_Building_List(); long cnt = 0; while ((b is null)) { cnt++; System.Threading.Thread.Sleep(150); } foreach (Faculty f in fac) { if (b.Any(g => f.Building_Id == g.BuildingId)) { f.Building_Name = b.FirstOrDefault(i => f.Building_Id == i.BuildingId).ToString(); } else { f.Building_Name = "Needs Updated"; } } if (Sender is Manage) { Manage t = (Manage)Sender; DataConnectionClass.DataLists.FacultyList = fac; BindingSource bs = new BindingSource { DataSource = DataConnectionClass.DataLists.FacultyList }; t.dataGridView1.DataSource = bs; try { t.dataGridView1.Columns["Id"].Visible = false; t.dataGridView1.Columns["Faculty_PersonId"].Visible = false; t.dataGridView1.Columns["Building_Id"].Visible = false; } catch (Exception) { // } } else { DataConnectionClass.DataLists.FacultyList = fac; } }
private static void DeleteProducts(AssetInventoryContext entities, Dictionary <String, SortableBindingList <StringValue> > familyNames) { IEnumerable <PrinterProduct> printerProducts = entities.PrinterProducts.AsEnumerable(); foreach (PrinterProduct product in printerProducts) { SortableBindingList <StringValue> namelist = null; familyNames.TryGetValue(product.Family, out namelist); if (namelist != null && !namelist.Any(n => n.Value.EqualsIgnoreCase(product.Name))) { entities.PrinterProducts.Remove(product); } } entities.SaveChanges(); }
/// <summary> /// Compares all queues for a server with those assigned to activities to determine those not being used. /// </summary> /// <param name="server">The server.</param> /// <param name="queuesInUse">The queues in use.</param> /// <returns></returns> public SortableBindingList <RemotePrintQueue> GetQueuesNotInUse(FrameworkServer server, SortableBindingList <PrintQueueInUse> queuesInUse) { if (server == null) { throw new ArgumentNullException("server"); } SortableBindingList <RemotePrintQueue> queuesToDelete = new SortableBindingList <RemotePrintQueue>(); foreach (var queue in _context.RemotePrintQueues.Where(n => n.PrintServerId == server.FrameworkServerId)) { if (!queuesInUse.Any(x => x.QueueName == queue.Name)) { queuesToDelete.Add(queue); } } return(queuesToDelete); }
/// <summary> /// Determines if the hostname already exists in the inventory /// </summary> /// <param name="hostName">The hostname.</param> /// <returns></returns> public bool HostNameExists(string hostNameOrIp) { if (string.IsNullOrEmpty(hostNameOrIp)) { throw new ArgumentNullException("hostNameOrIp"); } if (IsIpAddress(hostNameOrIp)) { return(_servers.Any(x => x.IPAddress == hostNameOrIp)); } string simpleName = hostNameOrIp.Split('.').First(); return (( from x in _servers where x.HostName.Split('.').First().Equals(simpleName, StringComparison.OrdinalIgnoreCase) select x ).Any()); }
private bool IsFiltered(SeriesInfo info) { return(!_filters.Any(f => info.Key.Contains(f.Substring, StringComparison.OrdinalIgnoreCase))); }
private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e) { int mb = (int)((decimal)e.Argument); long tamanhoMinimo = 1; for (int i = 0; i < mb; i++) { tamanhoMinimo = tamanhoMinimo + 1024 * 1024; } tamanhoMinimo = tamanhoMinimo == 1 ? 0 : tamanhoMinimo; while (listing && runn) { backgroundWorker2.ReportProgress(0); while (FilaFiles.Count > 0 && runn) { if (FilaFiles.TryDequeue(out string file)) { progresso++; XFile obj = new XFile(file); if (obj.Info.Exists) { if (obj.Info.Length >= tamanhoMinimo || tamanhoMinimo == 0) { obj.GerarHash(); if (Source.Any(x => x.Hash == obj.Hash && x.Extensao.ToLower() == obj.Info.Extension.ToLower() && x.Tamanho == obj.Info.Length)) { var src = Source.Where(x => x.Hash == obj.Hash && x.Extensao.ToLower() == obj.Info.Extension.ToLower() && x.Tamanho == obj.Info.Length).FirstOrDefault(); if (src != null) { src.Arquivos.Add(obj); } else { FilaFiles.Enqueue(file); } } else if (SourceAux.Any(x => x.Hash == obj.Hash && x.Extensao.ToLower() == obj.Info.Extension.ToLower() && x.Tamanho == obj.Info.Length)) { var src = SourceAux.Where(x => x.Hash == obj.Hash && x.Extensao.ToLower() == obj.Info.Extension.ToLower() && x.Tamanho == obj.Info.Length).FirstOrDefault(); if (src != null) { src.Arquivos.Add(obj); src.PropertyChanged += (ss, ee) => { if (dataGridView1.InvokeRequired) { dataGridView1.Invoke((MethodInvoker) delegate { dataGridView1.Invalidate(); }); } else { dataGridView1.Invalidate(); } }; if (dataGridView1.InvokeRequired) { dataGridView1.Invoke((MethodInvoker) delegate { Source.Add(src); }); } else { Source.Add(src); } } else { FilaFiles.Enqueue(file); } } else { FileViewModel model = new FileViewModel(obj); SourceAux.Add(model); } processados++; atual = obj.Info.Name; backgroundWorker2.ReportProgress(0); } } } } if (runn) { Thread.Sleep(3000); } } }
private void ServerForm_Load(object sender, EventArgs e) { try { //load NSCC projected needs ProjectedNeedFactory pnf = new ProjectedNeedFactory(); ProjectedNeedParam pnp = new ProjectedNeedParam(); List <ProjectedNeedObject> pn = new List <ProjectedNeedObject>(); pnp.DateOfData_Date.AddParamValue(DateTime.Today); pnp.Todays_Current_Net_Position.AddParamValue(0, "<"); pnp.Participant_Clearing_Number.AddParamValue(Settings.DatabaseName); pnf.Load(pn, pnp); //load up todays projected needs foreach (ProjectedNeedObject p in pn) { ProjectedNeedsSummaryObject ps = new ProjectedNeedsSummaryObject(p); ps.Ticker = calc.UpdateStockInfo(p.CUSIP); ProjectedNeeds.Add(ps); } //load up todays balance orders BalanceOrderViewFactory bof = new BalanceOrderViewFactory(); BalanceOrderViewParam bop = new BalanceOrderViewParam(); List <BalanceOrderViewObject> bol = new List <BalanceOrderViewObject>(); List <BalanceOrderViewObject> combined = new List <BalanceOrderViewObject>(); bop.DateOfData_Date.AddParamValue(Utils.GetNthBusinessDay(DateTime.Today, -1)); bop.Participant_Clearing_Number.AddParamValue(Settings.Account.PadLeft(4, '0')); bof.Load(bol, bop); foreach (BalanceOrderViewObject b in bol) { BalanceOrderViewObject f = combined.Find(c => c.CUSIP == b.CUSIP); if (f == null) { combined.Add(b); } else { f.Quantity += b.Quantity; } } foreach (BalanceOrderViewObject b in combined) { if (ProjectedNeeds.Any(x => x.Cusip != null && b.CUSIP != null && x.Cusip.ToLower() == b.CUSIP.ToLower())) { var item = ProjectedNeeds.SingleOrDefault(x => x.Cusip.ToLower() == b.CUSIP.ToLower()); item.BeginningNeed += Math.Abs(b.Quantity.Value); } else { ProjectedNeedsSummaryObject ps = new ProjectedNeedsSummaryObject(b); ps.Ticker = calc.UpdateStockInfo(b.CUSIP); ProjectedNeeds.Add(ps); } } //ALANDIAS--------Balance orders weren't updating for overnight deliveries------------------------------ if (combined.Count > 0) { List <tblDTFPARTObject> DTFPO = new List <tblDTFPARTObject>(); tblDTFPARTFactory DTFPFact = new tblDTFPARTFactory(); tblDTFPARTParam DTFParam = new tblDTFPARTParam(); DTFParam.DateofData.AddParamValue(DateTime.Today); DTFParam.TransOrigSource.AddParamValue("CFSD", "!="); DTFParam.ParticipantNum.AddParamValue(Settings.Account.PadLeft(4, '0')); DTFParam.SubFunction.AddParamValue("DTFPDQ"); DTFParam.StatusCode.AddParamValue("m"); DTFParam.TransTypeNew.AddParamValue("026"); DTFParam.ContraParticipantNum.AddParamValue("0888"); DTFPFact.Load(DTFPO, DTFParam); var BOinPN = ProjectedNeeds.Where(x => x.NeedType != null && x.NeedType.ToLower() == "balanceorder"); foreach (var b in BOinPN) { var overNightDelivery = DTFPO.SingleOrDefault(x => x.CUSIP.ToLower() == b.Cusip.ToLower()); if (overNightDelivery != null) { b.DeliveredToCns += Convert.ToInt32(overNightDelivery.ShareQuantity); } } } //------------------------------------------------------------------------------------------------------ //ALANDIAS NSCCMISCFILE---------------------------------------- //Please Note //Misc import was done incorrectly. QuantityReceived is actually QuantityDelivered and vice versa //Activity '15' is cancel and '02' is new deliver //quantitydelivered with activity '15' means we received and it reduces the balance order we have to deliver //QuantityReceived with activity '02' means we have to deliver string NSCCMISCNewDeliver = "02"; string NSCCMISCCancel = "15"; vNSCCMiscellaneousActivityFactory MAF = new vNSCCMiscellaneousActivityFactory(); vNSCCMiscellaneousActivityParam MAP = new vNSCCMiscellaneousActivityParam(); List <vNSCCMiscellaneousActivityObject> MAList = new List <vNSCCMiscellaneousActivityObject>(); string Acct = Settings.Account.PadLeft(4, '0'); MAP.DateOfData.AddParamValue(DateTime.Today); MAP.ParticipantClearingNumber.AddParamValue(Acct); MAP.Activity.AddParamValue(NSCCMISCNewDeliver); MAP.Activity.AddParamValue(NSCCMISCCancel); MAF.Load(MAList, MAP); var WhatWeHaveToDeliver = MAList.Where(x => (x.Activity == NSCCMISCNewDeliver) && (x.QuantityReceived != 0)); var ReduceBalanceOrder = MAList.Where(x => (x.Activity == NSCCMISCCancel) && (x.QuantityDelivered != 0)); foreach (vNSCCMiscellaneousActivityObject MAItem in WhatWeHaveToDeliver) { ProjectedNeedsSummaryObject ps = new ProjectedNeedsSummaryObject(MAItem); ps.Ticker = calc.UpdateStockInfo(MAItem.CUSIP); ProjectedNeeds.Add(ps); } foreach (vNSCCMiscellaneousActivityObject rbo in ReduceBalanceOrder) { if (ProjectedNeeds.Any(x => x.Cusip != null && rbo.CUSIP != null && x.Cusip.ToLower() == rbo.CUSIP.ToLower())) { var item = ProjectedNeeds.FirstOrDefault(x => x.Cusip.ToLower() == rbo.CUSIP.ToLower()); item.BeginningNeed -= Math.Abs(Convert.ToInt32(rbo.QuantityDelivered.Value)); } /* * else * { * ProjectedNeedsSummaryObject ps = new ProjectedNeedsSummaryObject(b); * ps.Ticker = calc.UpdateStockInfo(b.CUSIP); * ProjectedNeeds.Add(ps); * } */ } //-------------------------------------------------------------------------------- /*IncomingDeliveryOrderObject o = calc.AllDtcActivity.Find(p => p.ReasonCode == "620"); * * int a = 5;*/ //load the data from the table first foreach (IncomingDeliveryOrderObject ido in calc.AllDtcActivity) { if (ido.Receiver == "00000888" && ido.Deliverer == Settings.Account.Padded()) { int i = ProjectedNeeds.Find("Cusip", ido.Cusip); if (i != -1) { ProjectedNeeds[i].DeliveredToCns += ido.ShareQuantity.Value; } } if (ido.Deliverer == "00000888" && ido.Receiver == Settings.Account.Padded()) { int i = ProjectedNeeds.Find("Cusip", ido.Cusip); if (i != -1) { ProjectedNeeds[i].Received += ido.ShareQuantity.Value; } } if (ido.ReasonCode == "620" /*"030"*/ && ido.Deliverer == Settings.Account.Padded()) { int i = ProjectedNeeds.Find("Cusip", ido.Cusip); if (i != -1 && ProjectedNeeds[i].NeedType == "BalanceOrder") { ProjectedNeeds[i].DeliveredToCns += ido.ShareQuantity.Value; CalcSummary(); ProjectedNeeds.Sort("OpenNeed", ListSortDirection.Descending); } } //ALANDIAS added for NSCCMISC if (ido.ReasonCode == "620" /*"030"*/ && ido.Deliverer == Settings.Account.Padded()) { int i = ProjectedNeeds.Find("Cusip", ido.Cusip); if (i != -1 && ProjectedNeeds[i].NeedType == "MiscellaneousFile") { ProjectedNeeds[i].DeliveredToCns += ido.ShareQuantity.Value; CalcSummary(); ProjectedNeeds.Sort("OpenNeed", ListSortDirection.Descending); } } } ProjectedNeeds.Sort("OpenNeed", ListSortDirection.Descending); foreach (DataGridViewColumn c in dgvRealTimePosition.Columns) { c.ReadOnly = true; } //dgvRealTimePosition.Columns["Ticker"].ReadOnly = false; ColorRows(); //ETB stuff EtbStockViewFactory ef = new EtbStockViewFactory(); EtbStockViewParam ep = new EtbStockViewParam(); List <EtbStockViewObject> temp = new List <EtbStockViewObject>(); ep.DateOfData_Date.AddParamValue(DateTime.Today); ef.Load(temp, ep); etbList = temp.ToDictionary(t => t.Symbol, t => t); ep = new EtbStockViewParam(); temp = new List <EtbStockViewObject>(); ep.DateOfData_Date.AddParamValue(Utils.GetNthBusinessDay(DateTime.Today, -3)); ef.Load(temp, ep); etbT3List = temp.ToDictionary(t => t.Symbol, t => t); } catch (Exception ex) { Trace.WriteLine(ex, TraceEnum.LoggedError); MessageBox.Show("Error starting app: \r\n" + ex.ToString()); } foreach (DataGridViewColumn c in dgvRealTimePosition.Columns) { c.ReadOnly = true; } CalcSummary(); }