コード例 #1
0
 public InternalRequest(Guid requestId, DateTimeOffset created, PortfolioValuationRequest pvReq)
 {
     RequestId    = requestId;
     Created      = created;
     Request      = pvReq;
     LatestResult = new ServerRequestStatus()
     {
         RequestId     = pvReq.RequestId,
         RequesterData = pvReq.PortfolioId,
         Status        = RequestStatusEnum.Received
     };
 }
コード例 #2
0
        protected override void OnFirstCallback()
        {
            base.OnFirstCallback();

            // initialise workflow
            _Workflow.Initialise(_WorkContext);

            // subscribe to portfolio valuation requests and results
            // note: load results first
            _ResultSubs = this.Client.Subscribe <ServerRequestStatus>(
                Expr.ALL,
                delegate(ISubscription subs, ICoreItem item)
            {
                ServerRequestStatus pvRes = (ServerRequestStatus)item.Data;
                _ManageThreadQueue.Dispatch(pvRes, ReceivePortfolioValuationResult);
            },
                null);
            _RequestSubs = this.Client.Subscribe <PortfolioValuationRequest>(
                Expr.ALL,
                delegate(ISubscription subs, ICoreItem pvReqItem)
            {
                _ManageThreadQueue.Dispatch(pvReqItem, ReceivePortfolioValuationRequest);
            },
                null);

            // start timers
            // - request queue manager
            // - request scheduler
            _TimerRequestManager = new Timer(
                (notUsed) => _MainThreadQueue.Dispatch <object>(null, RequestManagerTimeout),
                null, RequestManagerPeriod, RequestManagerPeriod);
            // hack - start the daily 4am portfolio reval schedule
            // todo - attach this as a workflow step to the daily file/trade import process
            TimeSpan dueTime = (DateTime.Today.Add(TimeSpan.FromHours(4)) - DateTime.Now);

            if (dueTime < TimeSpan.Zero)
            {
                dueTime += TimeSpan.FromDays(1);
            }
            _TimerRequestScheduler = new Timer(
                (notUsed) => _MainThreadQueue.Dispatch <object>(null, RequestSchedulerTimeout),
                null, dueTime, TimeSpan.FromDays(1));
        }
コード例 #3
0
        private void ReceivePortfolioValuationResult(ServerRequestStatus pvRes)
        {
            Guid requestId = new Guid(pvRes.RequestId);

            _OutstandingRequests.Locked((requests) =>
            {
                InternalRequest request;
                if (requests.TryGetValue(requestId, out request))
                {
                    // exists
                    request.LatestResult = pvRes;
                }
                else
                {
                    // not found
                    request             = new InternalRequest(requestId, pvRes);
                    requests[requestId] = request;
                }
            });

            // dispatch worker request
            EnqueueWorkerRequest();
        }
コード例 #4
0
 public InternalRequest(Guid requestId, ServerRequestStatus pvRes)
 {
     RequestId    = requestId;
     Created      = DateTimeOffset.Now;
     LatestResult = pvRes;
 }