/// <summary> /// Загрузка данных в контрол. /// </summary> /// <param name="data">Обновляемые данные.</param> public bool LoadData(ICollection <AxisInfo> data) { try { var axisCount = data?.Count ?? 12; axisCountTextBox.Text = axisCount.ToString(); dataGridView1.Rows.Clear(); for (int i = 0; i < int.Parse(axisCountTextBox.Text); i++) { dataGridView1.Rows.Add(); } foreach (var axle in data) { dataGridView1.Rows[int.Parse(axle.AxisNum) - 1].Cells[0].Value = axle.AxisNum; dataGridView1.Rows[int.Parse(axle.AxisNum) - 1].Cells[1].Value = axle.AxisStinginess; dataGridView1.Rows[int.Parse(axle.AxisNum) - 1].Cells[2].Value = axle.SuspentionType; dataGridView1.Rows[int.Parse(axle.AxisNum) - 1].Cells[3].Value = axle.Distance2NextAxis; dataGridView1.Rows[int.Parse(axle.AxisNum) - 1].Cells[4].Value = axle.MeasuredAsisWeight; dataGridView1.Rows[int.Parse(axle.AxisNum) - 1].Cells[5].Value = axle.LegalAxisWeight; dataGridView1.Rows[int.Parse(axle.AxisNum) - 1].Cells[6].Value = axle.SpecialAllow; dataGridView1.Rows[int.Parse(axle.AxisNum) - 1].Cells[7].Value = axle.UsedAxisAllow; dataGridView1.Rows[int.Parse(axle.AxisNum) - 1].Cells[8].Value = axle.WeightRecordedExcess; dataGridView1.Rows[int.Parse(axle.AxisNum) - 1].Cells[9].Value = axle.PercentRecordedExcess; dataGridView1.Rows[int.Parse(axle.AxisNum) - 1].Cells[10].Value = axle.Overweight; } return(true); } catch (Exception e) { _console.AddException(e); return(false); } }
/// <summary> /// Загрузка данных в контрол. /// </summary> /// <param name="data">Обновляемые данные.</param> public bool LoadData(CargoInfo data) { try { cargoCharacterTextBox.Text = data.CargoCharacter; cargoTypeTextBox.Text = data.CargoType; legalWeightTextBox.Text = data.LegalWeight .ToString(CultureInfo.CurrentCulture); valetWeightTextBox.Text = data.ValetWeight .ToString(CultureInfo.CurrentCulture); factWeightTextBox.Text = data.FactWeight .ToString(CultureInfo.CurrentCulture); percentWeightOverflowTextBox.Text = data.PercentWeightOverflow .ToString(CultureInfo.CurrentCulture); cargoSpecialAllowTextBox.Text = data.CargoSpecialAllow .ToString(CultureInfo.CurrentCulture); tariffsTextBox.Text = data.Tariffs .ToString(CultureInfo.CurrentCulture); legLengthTextBox.Text = data.LegLength .ToString(CultureInfo.CurrentCulture); roadSectionTextBox.Text = data.RoadSection; passTextBox.Text = data.Pass; otherViolationTextBox.Text = data.OtherViolation; driverExplanationTextBox.Text = data.DriverExplanation; return(true); } catch (Exception e) { _console.AddException(e); return(false); } }
public bool LoadData(ICollection <Dependency> data) { try { dataGrid.Rows.Clear(); foreach (var dep in data) { dep.Register = dep.AllowRoles .Any(p => CompositionRoot.Instance.NodeRoles.Contains(p)); int rowNum = dataGrid.Rows.Add( dep.Order, dep.Abstractions.Name, dep.Realization.Name, dep.Name, dep.Register, WorkflowChainDescription.GetDescription(dep.Realization)); dataGrid.Rows[rowNum].Tag = dep; } dataGrid.Update(); return(true); } catch (Exception e) { _console?.AddException(e); return(false); } }
/// <summary> /// Загрузка данных в контрол. /// </summary> /// <param name="data">Обновляемые данные.</param> public bool LoadData(Act data) { try { actNumberTextBox.LoadData(data.ActNumber); dateTimePicker.Value = data.ActDateTime; ppvkNumberTextBox.LoadData(data.PpvkNumber); weightPointTextBox.LoadData(data.WeightPoint); weighterControl1.LoadData(data.Weighter); vehicleControl1.LoadData(data.Vehicle); vehicleDetailControl1.LoadData(data.Vehicle.Detail); cargoControl1.LoadData(data.Cargo); axisInfoControl1.LoadData(data.Cargo.Axises); driverControl1.LoadData(data.Driver); return(true); } catch (FormatException fe) { _console.AddException(fe); return(false); } catch (Exception e) { _console.AddException(e); return(false); } }
/// <summary> /// Получение данных из контрола после редактирования. /// </summary> /// <returns>Обновляемые данные.</returns> public bool UpdateData(Act data) { try { data.ActNumber = int.Parse(actNumberTextBox.Text); data.ActDateTime = dateTimePicker.Value; data.PpvkNumber = int.Parse(ppvkNumberTextBox.Text); data.WeightPoint = weightPointTextBox.Text; weighterControl1.UpdateData(data.Weighter); vehicleControl1.UpdateData(data.Vehicle); cargoControl1.UpdateData(data.Cargo); driverControl1.UpdateData(data.Driver); vehicleDetailControl1.UpdateData(data.Vehicle.Detail); axisInfoControl1.UpdateData(data.Cargo.Axises); return(true); } catch (FormatException fe) { _console.AddException(fe); return(false); } catch (NullReferenceException nre) { _console?.AddException(nre); return(false); } catch (Exception e) { _console.AddException(e); return(false); } }
private void InitControlEvents() { Disposed += (s, e) => _worker.CancelationToken = WorkFlowCancelationToken.Stoped; Load += (s, e) => LoadData(_worker.GetStatistic()); Paint += (s, e) => { if (_statistics.Status != TaskStatus.Running) { if (_statistics.IsCompleted) { View(_statistics.Result); } LoadData(_worker.GetStatistic()); } }; _timer.Elapsed += (s, e) => { try { this.Invoke((Action)Refresh); } catch (Exception ex) { _console.AddException(ex); } }; }
internal static int LoadToGrid( List <PpvkFileInfo> data, ICollection <ColumnInfo> columns, DataGridView actGridView, IConsoleService console = null) { try { actGridView.Rows.Clear(); foreach (var flatAct in data) { var index = actGridView.Rows.Add(); foreach (var e in columns) { var value = flatAct.GetType().GetProperty(e.Name)?.GetValue(flatAct, null); var isDateType = flatAct.GetType().GetProperty(e.Name)?.PropertyType == typeof(DateTime); var res = DateTime.TryParse(value?.ToString(), out var buf) ? (buf.Equals(DateTime.MinValue) ? String.Empty : buf.ToString()) : string.Empty; actGridView.Rows[index].Cells[e.Name].Value = isDateType ? res : value; } } return(data.Count); } catch (Exception e) { console?.AddException(e); return(0); } }
/// <summary> /// Рабочий процесс по передаче файлов. /// </summary> public virtual void WorkFlow() { try { CancelationToken = WorkFlowCancelationToken.Started; var ct = CancelationToken; while (ct != WorkFlowCancelationToken.Stoped) { if (ct == WorkFlowCancelationToken.Started) { Proccess(); } Thread.Sleep(1000 * int.Parse(_settings[ArgsKeyList.WFProcWaitingFor])); lock (this) { ct = CancelationToken; } } } catch (Exception e) { _console.AddException(e); } }
private static Binding GetCustomBinding( ISettingsStorage settings, IConsoleService console) { var tcpBinding = GetNetBinding(console); try { var binding = (CustomBinding)Activator.CreateInstance( typeof(CustomBinding), tcpBinding); var rbe = new ReliableSessionBindingElement(); binding.Elements.Add(rbe); var bme = Activator.CreateInstance <BinaryMessageEncodingBindingElement>(); bme.CompressionFormat = CompressionFormat.GZip; binding.Elements.Add(bme); var tf = Activator.CreateInstance <TransactionFlowBindingElement>(); binding.Elements.Add(tf); return(binding); } catch (Exception e) { console?.AddException(e); return(tcpBinding); } }
public MainForm( IUnityContainer container, ISettingsStorage settings, IConsoleService console) { _container = container; _settings = settings; _console = console; if (container.Registrations.Any(a => a.RegisteredType == typeof(UpdateClient))) _updateClient = container.Resolve<UpdateClient>(); InitializeComponent(); TopLevel = true; IntitForms(); // Администрирование settingsToolStripMenuItem.Click += (s, e) => StartForm("EditorSettingsStorage"); nodeRolesToolStripMenuItem.Click += (s, e) => StartForm("PackageAdmining"); openHelpToolStripMenuItem.Click += (s, e) => { try { var fileName = $"..\\docs\\help.pdf"; if (!File.Exists(fileName)) throw new FileNotFoundException("Help.pdf not found"); System.Diagnostics.Process.Start(fileName); } catch (Exception ex) { _console.AddException(ex); } }; }
private static void AddServiceMetadata( ISettingsStorage settings, IConsoleService console, ServiceHost host) { try { if (bool.TryParse(settings[ArgsKeyList.IsDebugMode], out bool isDebug) && isDebug) { var smb = new ServiceMetadataBehavior { HttpGetEnabled = true, HttpGetUrl = new Uri( $"http://{settings[ArgsKeyList.ServerName]}:{settings[ArgsKeyList.Port]}/mex") }; host.Description.Behaviors.Add(smb); } } catch (Exception e) { console?.AddException(e); console?.AddEvent("MEX does not activated.", ConsoleMessageType.Information); } }
internal static int LoadToGrid( ICollection <FlatAct> data, ICollection <ColumnInfo> columns, DataGridView actGridView, IConsoleService console = null) { try { actGridView.Rows.Clear(); foreach (var flatAct in data) { var index = actGridView.Rows.Add(); foreach (var e in columns) { actGridView.Rows[index].Cells[e.Name].Value = flatAct.GetType().GetProperty(e.Name)?.GetValue(flatAct, null); } } return(data.Count); } catch (Exception e) { console?.AddException(e); return(0); } }
public bool LoadData(ICollection <NodeRole> data) { try { checkBox1.Checked = data.Contains(NodeRole.PPVK); checkBox2.Checked = data.Contains(NodeRole.AFC); checkBox3.Checked = data.Contains(NodeRole.VerificationStation); checkBox4.Checked = data.Contains(NodeRole.ReportsStation); return(true); } catch (Exception e) { _console?.AddException(e); return(false); } }
public async void Initial(ICollection<NodeRole> roles, bool adminMode = false) { try { syncToolStripMenuItem.Visible = false; storageCommitmentToolStripMenuItem.Visible = false; verificationStationToolStripMenuItem.Visible = false; reportsStationToolStripMenuItem.Visible = false; label1.Visible = false; progressListControl1.Visible = false; adminingToolStripMenuItem.Visible = adminMode; bool debug = Boolean.TryParse(_settings[ArgsKeyList.IsDebugMode], out debug) && debug; if (roles == null || (adminMode && !debug)) return; foreach (var role in roles) { switch (role) { case NodeRole.PPVK: syncToolStripMenuItem.Visible = true; label1.Visible = true; progressListControl1.Visible = true; break; case NodeRole.AFC: storageCommitmentToolStripMenuItem.Visible = true; label1.Visible = true; progressListControl1.Visible = true; break; case NodeRole.VerificationStation: verificationStationToolStripMenuItem.Visible = true; label1.Visible = true; progressListControl1.Visible = true; await ActViewFunc(); break; case NodeRole.ReportsStation: reportsStationToolStripMenuItem.Visible = true; break; } } } catch (Exception e) { _console.AddException(e); } }
public bool LoadData(DriverInfo data) { try { fnMnSnameTextBox.Text = data.FnMnSname; driversLicenseNumberTextBox.Text = data.DriversLicenseNumber; operatorNameTextBox.Text = data.OperatorName; gibddNameTextBox.Text = data.GibddName; getingMarkTextBox.Text = data.GetingMark; return(true); } catch (Exception e) { _console.AddException(e); return(false); } }
public void Initial() { try { if (_proxy != null) { var downloader = _proxy.CreateRemoteProxy <IDownloader>(); if (_proxy.State != CommunicationState.Faulted && downloader != null) { Task.Factory.StartNew(() => GetVersion(downloader)); } } } catch (Exception e) { _console.AddException(e); } }
public bool LoadData(WeighterInfo data) { try { weigherNumberTextBox.Text = data.WeigherNumber; verificationDatePicker.Value = DateTime.Parse(data.VerificationDate); certificateNumberTextBox.Text = data.CertificateNumber; violatioNatureTextBox.Text = data.ViolationNature; // TODO: violationKoapComboBox return(true); } catch (Exception e) { _console.AddException(e); return(false); } }
public int GetLastVersion() { try { string path = $"{AppDomain.CurrentDomain.BaseDirectory}Updates\\"; var dirs = Directory .GetDirectories(path) .Select(m => m.Split('\\').Last()); return(dirs .Select(m => int.TryParse(m, out int buf) ? buf : -1) .Max()); } catch (Exception e) { _console.AddException(e); return(-1); } }
/// <summary> /// Загрузка данных в контрол. /// </summary> /// <param name="data">Обновляемые данные.</param> public bool LoadData(VehicleInfo data) { try { vehicleOwnerTextBox.Text = data.VehicleOwner; vehicleCountryTextBox.Text = data.VehicleCountry; vehicleSubjectCodeTextBox.Text = data.VehicleSubjectCode.ToString(); carriageTypeTextBox.Text = data.CarriageType; vehicleRouteTextBox.Text = data.VehicleRoute; federalHighwaysDistanceTextBox.Text = data.FederalHighwaysDistance; vehicleShipperTextBox.Text = data.VehicleShipper; return(true); } catch (Exception e) { _console.AddException(e); return(false); } }
private void StartTask() { try { _task = Task <List <Act> > .Factory.StartNew( function : () => _context .Set <Act>() .Include(d => d.Driver) .Include(c => c.Cargo) .Include(a => a.Cargo.Axises) .Include(w => w.Weighter) .Include(v => v.Vehicle) .Include(vd => vd.Vehicle.Detail) .ToList(), cancellationToken : CancellationToken); } catch (Exception e) { _console.AddException(e); } }
private Type[] TryGetTypes(Assembly asm) { try { return(asm.GetTypes()); } catch (Exception ex) { _console.AddException(ex); return(new Type[] { }); } }
public bool LoadData(ICollection <ColumnInfo> data) { try { dataGridView1.DataSource = new BindingSource(data, null); return(true); } catch (Exception ex) { _console?.AddException(ex); return(false); } }
public bool LoadData(ICollection <VehicleDetail> data) { try { dataGridView1.Rows.Clear(); foreach (var detail in data) { dataGridView1.Rows.Add( detail.VehicleType, detail.VehicleBrand, detail.VehicleModel, detail.StateNumber); } return(true); } catch (Exception e) { _console.AddException(e); return(false); } }
public void Work() { var form = (ActEditForm)_container.Resolve <Form>("ActEditForm"); var act = _settings.GetKeys().Contains(ArgsKeyList.Mode) && _settings[ArgsKeyList.Mode].Equals("Act") ? new Act().LoadFromJson(LoadJsonFile()) : BlankList.GetList(LoadJsonFile(), ex => _console?.AddException(ex)).ToModelFormat(e => _console?.AddException(e)); if (ActEditForm.ShowModal(_container, act) == null) { return; } _context.Acts.Add(act); _context.SaveChanges(); var item = listBox1.Items[listBox1.SelectedIndex].ToString(); var storeFileName = $"{_settings[ArgsKeyList.StorePath]}\\{_items[item].Id}"; File.Delete(storeFileName); _items.Remove(item); listBox1.Items.RemoveAt(listBox1.SelectedIndex); }
public ModelContext( ISettingsStorage settings, IConsoleService console) : base(GetConnectionString(settings)) { _console = console; try { Database.CreateIfNotExists(); } catch (Exception e) { console.AddException(e); } }
/// <summary> /// Поиск фильтров /// </summary> /// <typeparam name="T"></typeparam> /// <param name="outerList"></param> /// <returns></returns> private List <Guid> FindForFilterGrid <T>(List <Guid> outerList) { try { if (_filters == null || !_filters.Any()) { return(outerList); } foreach (var filter in _filters.Keys) { var filterName = _columns.Single(s => s.Description == filter.Name).Name; var t = typeof(T).GetProperty(filterName); var innerFilterList = _data .Where(f => // поиск по условию "Содержит" _filters[filter].Mode.Mode == SearchingModeEnum.Contains && t.GetValue(f).ToString().ToLower() .Contains(_filters[filter].SearchingData.ToLower()) // поиск по условию "Начинается с" || _filters[filter].Mode.Mode == SearchingModeEnum.StartsWith && t.GetValue(f).ToString().ToLower() .StartsWith(_filters[filter].SearchingData.ToLower())) .Select(m => m.Id); outerList = !outerList.Any() ? innerFilterList.ToList() : innerFilterList.Intersect(outerList).ToList(); } return(outerList); } catch (Exception e) { _console?.AddException(e); return(outerList); } }
private BroserForm( IConsoleService console, string filename, string actNum) { InitializeComponent(); Load += (s, e) => { try { webBrowser1.Navigate(filename); console?.AddEvent($"{filename} opend in webBrowser."); } catch (Exception ex) { console?.AddException(ex); } }; }
public Starter() { try { _compositionRoot = CompositionRoot.Factory(); ContainerRegistations(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var mainForm = CompositionRoot.Container.Resolve <MainForm>(); mainForm.Initial(_compositionRoot.NodeRoles, IsAdminMode); Application.Run(mainForm); Application.ApplicationExit += (s, e) => Dispose(); } catch (Exception e) { _console?.AddException(e); } }
/// <summary> /// Получить адрес. /// </summary> /// <returns>Адрес сервиса.</returns> /// <exception cref="KeyNotFoundException"> /// В DI-контейнере не были найдены настройки соединения. /// <c>MachineUrl</c> или <c>TcpPort</c> /// </exception> internal static Uri GetAddress <T>( Binding binding, ISettingsStorage settings, IConsoleService console) { try { var uriBuilder = new UriBuilder( scheme: binding.Scheme, host: settings[ArgsKeyList.ServerName], port: int.Parse(settings[ArgsKeyList.Port]), pathValue: $"{typeof(T).Name}.svc"); return(new Uri($"{uriBuilder.Scheme}://{uriBuilder.Host}:{uriBuilder.Port}/{uriBuilder.Path}")); } catch (Exception e) { console?.AddException(e); return(null); } }
public bool HostService(Type service, Type implamentation) { try { if (_hosts == null || _hosts.ContainsKey(service)) { return(false); } var binding = WcfSettings.GetBinding( settings: _settings, console: _console); var uri = WcfSettings.GetAddress( type: service, binding: binding, settings: _settings, console: _console); var host = new ServiceHost(implamentation, uri); host.AddServiceEndpoint( implementedContract: service, binding: binding, address: uri); // AddServiceMetadata(); host.Description.Behaviors.Add(_container.Resolve <UnityServiceBehavior>()); host.Open(); _hosts.Add(service, host); _console.AddEvent($"{implamentation} hosted."); return(true); } catch (Exception e) { _console?.AddException(e); return(false); } }