private void LoadDataToGrid() { try { if (_fileInfos == null || !_fileInfos.Any()) { LoadDataFromDataBase(); } actGridControl1.LoadData(_fileInfos); // загрузка отображаемых колонок if (File.Exists(_fileName)) { var json = File.ReadAllText(_fileName); var columns = JsonConvert.DeserializeObject <List <ColumnInfo> >(json); actGridControl1.UpdateData(columns); filtersDockControl1.InitColumns(columns); } _console?.AddEvent($"Loaded acts from DB. Count: {_fileInfos.Count}"); } catch (Exception e) { _console?.AddException(e); this.Close(); } }
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); } }
public FilterControl( IConsoleService console) { _console = console; InitializeComponent(); InitialComponentsEvents(); console?.AddEvent($"{nameof(FilterControl)} created."); }
public ValidatioinControl( IConsoleService console, ISettingsStorage settings, IWorkFlowProducerConsumer consumer, IUnityContainer container, DbContext context) { _consumer = consumer; _container = container; _context = (ModelContext)context; _console = console; _settings = settings; console.AddEvent($"{nameof(ValidatioinControl)} created."); InitializeComponent(); _items = new Dictionary <string, FileTransferInfo>(); }
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 MonitorDbView( ISettingsStorage settings, IConsoleService console, IUnityContainer container, DbContext context) { _settings = settings; _console = console; _container = container; _context = (ModelContext)context; InitializeComponent(); InitialComponentsEvents(); ((IObservable <IDictionary <ColumnInfo, SearchingTerm> >) this.filtersDockControl1).Subscribe(this.actGridControl1); ((IObservable <IList <DateFilter> >) this.filtersDockControl1).Subscribe(this.actGridControl1); _console?.AddEvent($"{nameof(ActDbView)} form created."); }
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); } }
private void LoadDataToGrid() { try { actGridControl1.LoadData(_acts.Result.Select(FlatAct.Expand).ToList()); // загрузка отображаемых колонок if (File.Exists(_fileName)) { var json = File.ReadAllText(_fileName); var columns = JsonConvert.DeserializeObject <List <ColumnInfo> >(json); actGridControl1.UpdateData(columns); filtersDockControl1.InitColumns(columns); } _console?.AddEvent($"Loaded acts from DB. Count: {_acts.Result.Count}"); } catch (Exception e) { _console?.AddException(e); this.Close(); } }
private void InitialComponentsEvents() { editActButton.Click += (s, e) => { throw new ApplicationException(); Guid index = actGridControl1.GetMarked(); var act = _fileInfos.FirstOrDefault(f => f.Id == index); //ActEditForm.ShowModal(_container, act); int changed = _context.SaveChanges(); _console.AddEvent($"Внесено {changed} изменений"); if (changed != 0) { LoadDataToGrid(); } }; columnsListEditButton.Click += (s, e) => { try { var columns = new List <ColumnInfo>(); actGridControl1.LoadData(columns); using (var form = new ChosingColumnsForm(_console)) { if (form.LoadData(columns) && form.ShowDialog() == DialogResult.OK && actGridControl1.UpdateData(columns)) { } } var json = JsonConvert.SerializeObject(columns, Formatting.Indented); File.WriteAllText(_fileName, json); } catch (Exception ex) { _console?.AddException(ex); } }; openOriginalFileButton.Click += (s, e) => { try { Guid index = actGridControl1.GetMarked(); var pfi = _fileInfos.FirstOrDefault(f => f.Id == index); string directory = _settings[ArgsKeyList.BackUpPath]; var fileName = Directory.GetFiles( _settings[ArgsKeyList.BackUpPath] , $"{pfi.Id}.*") .FirstOrDefault(f => !f.Contains(".json")); if (fileName == null) { return; } BroserForm.ShowModal(_console, fileName, pfi.Id.ToString()); } catch (Exception ex) { _console?.AddException(ex); } }; updateDataButton.Click += (s, e) => Task.Factory.StartNew( () => Invoke((Action)LoadDataToGrid)); excelExportButton.Click += (s, e) => ExportToExcel(); Load += (s, e) => Task.Factory.StartNew( () => Invoke((Action)LoadDataToGrid)); }