private void Form1_Load(object sender, EventArgs e) { _MainLog = new TextBoxLogger(txtLog); _WorkerALog = new TextBoxLogger(txtWorkerALog); _WorkerBLog = new TextBoxLogger(txtWorkerBLog); _ManagerLog = new TextBoxLogger(txtManagerLog); _ClientRef = Reference <ICoreClient> .Create(new CoreClientFactory(_MainLog).Create()); // init controls txtWorkerComputer.Text = Environment.MachineName; txtWorkerInstance.Text = "A"; // - form title WinFormHelper.SetAppFormTitle(this, BuildConst.BuildEnv); cbMarketName.Items.Add(CurveConst.QR_EOD); cbMarketName.Items.Add(CurveConst.NAB_EOD); cbMarketName.SelectedIndex = 0; cbCounterParty.Items.Add("14859,Woolworths"); cbCounterParty.Items.Add("13142,Barclays"); cbCounterParty.SelectedIndex = 0; // setup the request progress view _ProgressViewHelper = new ProgressViewHelper(); _ProgressDataHelper = new ProgressDataHelper(); _ProgressFilters = new ComboxBoxFilterGroup( panelProgress, _ProgressViewHelper, new EventHandler(ProgressSelectionChanged)); _ProgressSelecter = new ProgressSelecter( _ProgressFilters, _ProgressViewHelper, _ProgressDataHelper); _ProgressView = new ListViewManager <ProgressObj>( _MainLog, lvProgress, _ProgressViewHelper, _ProgressSelecter, _ProgressFilters, new ProgressSorter(), _ProgressDataHelper); _ClientRef.Target.SubscribeNoWait <PortfolioValuationRequest>(Expr.ALL, ProgressCallback, null); _ClientRef.Target.SubscribeNoWait <TradeValuationRequest>(Expr.ALL, ProgressCallback, null); _ClientRef.Target.SubscribeNoWait <OrdinaryCurveGenRequest>(Expr.ALL, ProgressCallback, null); _ClientRef.Target.SubscribeNoWait <StressedCurveGenRequest>(Expr.ALL, ProgressCallback, null); _ClientRef.Target.SubscribeNoWait <UnassignedWorkflowRequest>(Expr.ALL, ProgressCallback, null); _ClientRef.Target.SubscribeNoWait <AssignedWorkflowRequest>(Expr.ALL, ProgressCallback, null); _ClientRef.Target.SubscribeNoWait <HandlerResponse>(Expr.ALL, ProgressCallback, null); _ClientRef.Target.SubscribeNoWait <WorkerResponse>(Expr.ALL, ProgressCallback, null); _ClientRef.Target.SubscribeNoWait <ManagerResponse>(Expr.ALL, ProgressCallback, null); // setup the worker availability view _AvailabilityViewHelper = new AvailabilityViewHelper(); _AvailabilityDataHelper = new AvailabilityDataHelper(); _AvailabilityFilters = new ComboxBoxFilterGroup( panelAvailability, _AvailabilityViewHelper, new EventHandler(AvailabilitySelectionChanged)); _AvailabilitySelecter = new AvailabilitySelecter( _AvailabilityFilters, _AvailabilityViewHelper, _AvailabilityDataHelper); _AvailabilityView = new ListViewManager <WorkerAvailability>( _MainLog, lvAvailability, _AvailabilityViewHelper, _AvailabilitySelecter, _AvailabilityFilters, new AvailabilitySorter(), _AvailabilityDataHelper); ICoreCache _AvailabilityCache = _ClientRef.Target.CreateCache( delegate(CacheChangeData update) { _AvailabilityView.UpdateData(new ViewChangeNotification <WorkerAvailability>() { Change = update.Change, OldData = (update.OldItem != null) ? (WorkerAvailability)update.OldItem.Data : null, NewData = (update.NewItem != null) ? (WorkerAvailability)update.NewItem.Data : null }); }, WindowsFormsSynchronizationContext.Current); _AvailabilityCache.SubscribeNoWait <WorkerAvailability>(Expr.ALL, null, null); }
private void Form1Load(object sender, EventArgs e) { // create loggers _loggerRef = Reference <ILogger> .Create(new TextBoxLogger(txtMainLog)); // create client factory and client _clientFactory = new CoreClientFactory(_loggerRef); _clientFactory.SetEnv(BuildConst.BuildEnv); _clientFactory.SetApplication(Assembly.GetExecutingAssembly()); _client = _clientFactory.Create(); // - form title WinFormHelper.SetAppFormTitle(this, EnvHelper.EnvName(BuildEnv)); // setup the AlertRule view _alertRuleViewHelper = new AlertRuleViewHelper(); _alertRuleDataHelper = new AlertRuleDataHelper(); _alertRuleFilters = new ComboxBoxFilterGroup( panelAlertRule, _alertRuleViewHelper, AlertRuleSelectionChanged); _alertRuleSelecter = new AlertRuleSelecter( _alertRuleFilters, _alertRuleViewHelper, _alertRuleDataHelper); _alertRuleView = new ListViewManager <AlertRule>( _loggerRef.Target, lvAlertRule, _alertRuleViewHelper, _alertRuleSelecter, _alertRuleFilters, new AlertRuleSorter(), _alertRuleDataHelper); ICoreCache alertRuleCache = _client.CreateCache( update => _alertRuleView.UpdateData(new ViewChangeNotification <AlertRule> { Change = update.Change, OldData = (AlertRule)update.OldItem?.Data, NewData = (AlertRule)update.NewItem?.Data }), SynchronizationContext.Current); alertRuleCache.SubscribeNoWait <AlertRule>(Expr.ALL, null, null); // setup the AlertSignal view _alertSignalViewHelper = new AlertSignalViewHelper(); _alertSignalDataHelper = new AlertSignalDataHelper(); _alertSignalFilters = new ComboxBoxFilterGroup( panelAlertSignal, _alertSignalViewHelper, AlertSignalSelectionChanged); _alertSignalSelecter = new AlertSignalSelecter( _alertSignalFilters, _alertSignalViewHelper, _alertSignalDataHelper); _alertSignalView = new ListViewManager <AlertSignal>( _loggerRef.Target, lvAlertSignal, _alertSignalViewHelper, _alertSignalSelecter, _alertSignalFilters, new AlertSignalSorter(), _alertSignalDataHelper); ICoreCache alertSignalCache = _client.CreateCache( update => _alertSignalView.UpdateData(new ViewChangeNotification <AlertSignal> { Change = update.Change, OldData = (AlertSignal)update.OldItem?.Data, NewData = (AlertSignal)update.NewItem?.Data }), SynchronizationContext.Current); alertSignalCache.SubscribeNoWait <AlertSignal>(Expr.ALL, null, null); // setup the LogEvent view _logEventViewHelper = new LogEventViewHelper(); _logEventDataHelper = new LogEventDataHelper(); _logEventFilters = new ComboxBoxFilterGroup( panelLogEvent, _logEventViewHelper, LogEventSelectionChanged); _logEventSelecter = new LogEventSelecter( _logEventFilters, _logEventViewHelper, _logEventDataHelper); _logEventView = new ListViewManager <DebugLogEvent>( _loggerRef.Target, lvLogEvent, _logEventViewHelper, _logEventSelecter, _logEventFilters, new LogEventSorter(), _logEventDataHelper); ICoreCache logEventCache = _client.CreateCache( update => _logEventView.UpdateData(new ViewChangeNotification <DebugLogEvent> { Change = update.Change, OldData = (DebugLogEvent)update.OldItem?.Data, NewData = (DebugLogEvent)update.NewItem?.Data }), SynchronizationContext.Current); logEventCache.SubscribeNoWait <DebugLogEvent>(Expr.ALL, null, null); // init controls // server 0 _serverAddress[0] = txtServer0Address; _ping[0] = chkServer0Ping; _lastChecked[0] = txtServer0LastChecked; _lastReplied[0] = txtServer0LastReplied; _serverStatus[0] = txtServer0Status; _serverReason[0] = txtServer0OtherInfo; // server 1 _serverAddress[1] = txtServer1Address; _ping[1] = chkServer1Ping; _lastChecked[1] = txtServer1LastChecked; _lastReplied[1] = txtServer1LastReplied; _serverStatus[1] = txtServer1Status; _serverReason[1] = txtServer1OtherInfo; // server 2 _serverAddress[2] = txtServer2Address; _ping[2] = chkServer2Ping; _lastChecked[2] = txtServer2LastChecked; _lastReplied[2] = txtServer2LastReplied; _serverStatus[2] = txtServer2Status; _serverReason[2] = txtServer2OtherInfo; // server 3 _serverAddress[3] = txtServer3Address; _ping[3] = chkServer3Ping; _lastChecked[3] = txtServer3LastChecked; _lastReplied[3] = txtServer3LastReplied; _serverStatus[3] = txtServer3Status; _serverReason[3] = txtServer3OtherInfo; // server 4 _serverAddress[4] = txtServer4Address; _ping[4] = chkServer4Ping; _lastChecked[4] = txtServer4LastChecked; _lastReplied[4] = txtServer4LastReplied; _serverStatus[4] = txtServer4Status; _serverReason[4] = txtServer4OtherInfo; // server 5 _serverAddress[5] = txtServer5Address; _ping[5] = chkServer5Ping; _lastChecked[5] = txtServer5LastChecked; _lastReplied[5] = txtServer5LastReplied; _serverStatus[5] = txtServer5Status; _serverReason[5] = txtServer5OtherInfo; for (int i = 0; i < NServers; i++) { _lastChecked[i].BackColor = Color.FromKnownColor(KnownColor.Window); _lastReplied[i].BackColor = Color.FromKnownColor(KnownColor.Window); _serverStatus[i].BackColor = Color.FromKnownColor(KnownColor.Window); _serverReason[i].BackColor = Color.FromKnownColor(KnownColor.Window); } }
private void ProgressCallback(ISubscription subscription, ICoreItem item) { try { ProgressObj oldProgress = null; ProgressObj newProgress = null; if (item != null) { // get old request view object Guid requestId = item.AppProps.GetValue <Guid>(RequestBase.Prop.RequestId, true); oldProgress = _ProgressCache.Remove(requestId); // build the new request view object if (item.IsCurrent()) { if (item.DataType.IsSubclassOf(typeof(RequestBase))) { RequestBase request = item.Data as RequestBase; if (request != null) { newProgress = new ProgressObj(requestId, item.Created, oldProgress, request); } } else if (item.DataType.IsSubclassOf(typeof(ResponseBase))) { ResponseBase response = item.Data as ResponseBase; if (response != null) { newProgress = new ProgressObj(requestId, item.Created, oldProgress, response); } } else { throw new NotSupportedException(String.Format("Type: '{0}'", item.DataType.Name)); } } if (newProgress != null) { _ProgressCache.Set(requestId, newProgress); } } else { throw new ArgumentNullException("item"); } // determine the change type CacheChange change = CacheChange.Undefined; if (oldProgress != null) { // updated or deleted if (newProgress != null) { change = CacheChange.ItemUpdated; } else { change = CacheChange.ItemRemoved; } } else { // created or ??? if (newProgress != null) { change = CacheChange.ItemCreated; } } if (change != CacheChange.Undefined) { _ProgressView.UpdateData(new ViewChangeNotification <ProgressObj>() { Change = change, OldData = oldProgress, NewData = newProgress }); } } catch (Exception excp) { _MainLog.Log(excp); } }