예제 #1
0
        public FhirResponse History(string type, string id)
        {
            Key key        = Key.Create(type, id);
            var parameters = new HistoryParameters(Request);

            return(_fhirService.History(key, parameters));
        }
예제 #2
0
        public async Task <FhirResponse> History(string type, string id)
        {
            Key key        = Key.Create(type, id);
            var parameters = new HistoryParameters(Request);

            return(await _fhirService.HistoryAsync(key, parameters).ConfigureAwait(false));
        }
예제 #3
0
        private List <Bar> GenerateHistory(HistoryParameters chartSelection, int maxBars, double lastPrice)
        {
            List <Bar> bars    = new List <Bar>();
            DateTime   barTime = DateTime.UtcNow;

            barTime = new DateTime(barTime.Year, barTime.Month, barTime.Day, barTime.Hour, barTime.Minute, 0);

            for (int i = 0; i < maxBars; i++)
            {
                Bar aBar = new Bar
                {
                    Date   = barTime,
                    Close  = lastPrice,
                    High   = lastPrice + (double)m_Random.Next(1000) / 100,
                    Low    = lastPrice - (double)m_Random.Next(1000) / 100,
                    Volume = m_Random.Next(1000000)
                };
                aBar.Open = lastPrice + (aBar.High - lastPrice > lastPrice - aBar.Low ? -1 : 1) * (double)m_Random.Next(1000) / 100;
                aBar.High = Math.Max(aBar.High, aBar.Open);
                aBar.Low  = Math.Min(aBar.Low, aBar.Open);

                bars.Add(aBar);

                barTime   = PrevDate(barTime, chartSelection.Periodicity, chartSelection.Interval);
                lastPrice = aBar.Open;
            }

            return(bars);
        }
예제 #4
0
        public async Task <List <RemontuVesture> > RemontuVestureAsync(HistoryParameters parameters)
        {
            var query = _context.ServisaLapas
                        .Include(s => s.Klients)
                        .Include(s => s.Transportlidzeklis)
                        .Where(s => s.Apmaksata != null)
                        .AsQueryable();

            query = query.OrderByDescending(q => q.Datums); // jaunākās servisa lapas pirmās

            if (!string.IsNullOrEmpty(parameters.Filter))
            {
                query = query.Where(l => l.Klients.Nosaukums.ToLower().Contains(parameters.Filter.ToLower()) ||
                                    l.Transportlidzeklis.Numurs.Contains(parameters.Filter.ToUpper()));
            }

            var items = await query.Skip((parameters.Page) *parameters.PageSize).Take(parameters.PageSize).ToListAsync();

            return(items.Select(i => new RemontuVesture
            {
                Datums = i.Datums,
                KlientaId = i.KlientaId,
                Klients = i.Klients.Nosaukums,
                TransportlidzeklaId = i.TransportlidzeklaId,
                Marka = i.Transportlidzeklis.Marka + " " + i.Transportlidzeklis.Modelis,
                Numurs = i.Transportlidzeklis.Numurs,
                ServisaLapasId = i.Id
            }).ToList());
        }
예제 #5
0
        public Snapshot History(HistoryParameters parameters)
        {
            var clauses = new List <FilterDefinition <BsonDocument> >();

            if (parameters.Since != null)
            {
                clauses.Add(Builders <BsonDocument> .Filter.Gt(Field.WHEN, BsonDateTime.Create(parameters.Since)));
            }

            return(CreateSnapshot(FetchPrimaryKeys(clauses), parameters.Count));
        }
예제 #6
0
파일: HistoryStore.cs 프로젝트: jjrdk/spark
        public async Task <Snapshot> History(HistoryParameters parameters)
        {
            var clauses = new List <FilterDefinition <BsonDocument> >();

            if (parameters.Since != null)
            {
                clauses.Add(Builders <BsonDocument> .Filter.Gt(Field.WHEN, BsonDateTime.Create(parameters.Since)));
            }

            return(CreateSnapshot(await FetchPrimaryKeysAsync(clauses).ConfigureAwait(false), parameters.Count));
        }
예제 #7
0
        public FhirResponse History(string type, HistoryParameters parameters)
        {
            Validate.TypeName(type);
            Uri link = localhost.Uri(type, RestOperation.HISTORY);

            IEnumerable <string> keys = fhirStore.History(type, parameters.Since);
            var    snapshot           = pager.CreateSnapshot(Bundle.BundleType.History, link, keys, parameters.SortBy, parameters.Count, null);
            Bundle bundle             = pager.GetFirstPage(snapshot);

            return(Respond.WithResource(bundle));
        }
예제 #8
0
        public Snapshot History(HistoryParameters parameters)
        {
            var clauses = new List <IMongoQuery>();

            if (parameters.Since != null)
            {
                clauses.Add(MongoDB.Driver.Builders.Query.GT(Field.WHEN, BsonDateTime.Create(parameters.Since)));
            }

            return(CreateSnapshot(FetchPrimaryKeys(clauses), parameters.Count));
        }
예제 #9
0
        public FhirResponse History(IKey key, HistoryParameters parameters)
        {
            IResourceStorageService storageService = GetFeature <IResourceStorageService>();

            if (storageService.Get(key) == null)
            {
                return(Respond.NotFound(key));
            }
            IHistoryService historyExtension = this.GetFeature <IHistoryService>();

            return(CreateSnapshotResponse(historyExtension.History(key, parameters)));
        }
예제 #10
0
        public Snapshot History(IKey key, HistoryParameters parameters)
        {
            var clauses = new List <FilterDefinition <BsonDocument> >();

            clauses.Add(Builders <BsonDocument> .Filter.Eq(Field.TYPENAME, key.TypeName));
            clauses.Add(Builders <BsonDocument> .Filter.Eq(Field.RESOURCEID, key.ResourceId));
            if (parameters.Since != null)
            {
                clauses.Add(Builders <BsonDocument> .Filter.Gt(Field.WHEN, BsonDateTime.Create(parameters.Since)));
            }

            return(CreateSnapshot(FetchPrimaryKeys(clauses), parameters.Count));
        }
예제 #11
0
        public FhirResponse History(HistoryParameters parameters)
        {
            var since = parameters.Since ?? DateTimeOffset.MinValue;
            Uri link  = localhost.Uri(RestOperation.HISTORY);

            IEnumerable <string> keys = fhirStore.History(since);
            var    snapshot           = pager.CreateSnapshot(Bundle.BundleType.History, link, keys, parameters.SortBy, parameters.Count, null);
            Bundle bundle             = pager.GetFirstPage(snapshot);

            // DSTU2: export
            // exporter.Externalize(bundle);
            return(Respond.WithBundle(bundle));
        }
예제 #12
0
        public Snapshot History(IKey key, HistoryParameters parameters)
        {
            var clauses = new List <IMongoQuery>();

            clauses.Add(MongoDB.Driver.Builders.Query.EQ(Field.TYPENAME, key.TypeName));
            clauses.Add(MongoDB.Driver.Builders.Query.EQ(Field.RESOURCEID, key.ResourceId));
            if (parameters.Since != null)
            {
                clauses.Add(MongoDB.Driver.Builders.Query.GT(Field.WHEN, BsonDateTime.Create(parameters.Since)));
            }

            return(CreateSnapshot(FetchPrimaryKeys(clauses), parameters.Count));
        }
예제 #13
0
        public Bundle History(HistoryParameters parameters = null)
        {
            if (parameters == null)
            {
                parameters = new HistoryParameters();
            }

            var historyResponse = FHIRbase.Call("fhir.history")
                                  .WithText(parameters.ToString())
                                  .Cast <string>();

            return(FHIRbaseHelper.JsonToBundle(historyResponse));
        }
예제 #14
0
파일: HistoryStore.cs 프로젝트: jjrdk/spark
        public async Task <Snapshot> History(IKey key, HistoryParameters parameters)
        {
            var clauses = new List <FilterDefinition <BsonDocument> >
            {
                Builders <BsonDocument> .Filter.Eq(Field.TYPENAME, key.TypeName),
                Builders <BsonDocument> .Filter.Eq(Field.RESOURCEID, key.ResourceId)
            };

            if (parameters.Since != null)
            {
                clauses.Add(Builders <BsonDocument> .Filter.Gt(Field.WHEN, BsonDateTime.Create(parameters.Since)));
            }

            return(CreateSnapshot(await FetchPrimaryKeysAsync(clauses).ConfigureAwait(false), parameters.Count));
        }
예제 #15
0
        public FhirResponse History(Key key, HistoryParameters parameters)
        {
            if (!fhirStore.Exists(key))
            {
                return(Respond.NotFound(key));
            }

            Uri link = localhost.Uri(key);

            IEnumerable <string> keys = fhirStore.History(key, parameters.Since);
            var    snapshot           = pager.CreateSnapshot(Bundle.BundleType.History, link, keys, parameters.SortBy, parameters.Count);
            Bundle bundle             = pager.GetFirstPage(snapshot);

            return(Respond.WithResource(key, bundle));
        }
예제 #16
0
        public Bundle AllResourcesHistory(HistoryParameters parameters = null)
        {
            if (parameters == null)
            {
                parameters = HistoryParameters.Empty;
            }

            var historyResponse = _context.Call(FhirSchema.Name, FhirSchema.Func.InstanceHistory)
                                  .WithString(parameters.ToString())
                                  .Cast <String>();

            var resultBundle = ResourceDataHelper.JsonToBundle(historyResponse);

            return(resultBundle);
        }
예제 #17
0
        public void RunBacktest(BacktestGetRequest aRequest)
        {
            var errorString = TradeScript.ValidateBuySell(aRequest.BuyScript, aRequest.SellScript);

            if (aRequest.BuyScript == string.Empty || aRequest.SellScript == string.Empty)
            {
                errorString = "Buy and sell script can not be empty";
            }

            if (errorString != string.Empty)
            {
                var response = new BacktestGetResponse
                {
                    Id    = aRequest.Id,
                    Error = errorString,
                    User  = aRequest.User
                };
                PushResponses(aRequest.User.ID, new ResponseMessage[] { response });
                return;
            }

            var       selection = new HistoryParameters(aRequest.Id, aRequest.Symbol, aRequest.Periodicity, aRequest.Interval, aRequest.BarsCount);
            IDataFeed aDataFeed = GetDataFeedByName(aRequest.Symbol.DataFeed);

            if (aDataFeed != null)
            {
                GetHistoryCtx aCtx = GetHistoryCtx(selection, aDataFeed.TimeZoneInfo);
                aCtx.Request  = new HistoryRequest(selection);
                aCtx.DataFeed = aDataFeed;
                ThreadPool.QueueUserWorkItem(o =>
                {
                    aDataFeed.GetHistory(aCtx, (ctx, bars) =>
                    {
                        string backtestOutput = TradeScript.Backtest(aRequest.BuyScript, aRequest.SellScript, bars);
                        var response          = new BacktestGetResponse
                        {
                            Id          = aRequest.Id,
                            User        = aRequest.User,
                            Symbol      = aRequest.Symbol,
                            Information = TradeScript.ExtractBacktestInformation(backtestOutput),
                            Trades      = TradeScript.ExtractBacktestTrades(backtestOutput)
                        };
                        PushResponses(aRequest.User.ID, new ResponseMessage[] { response });
                    });
                });
            }
        }
예제 #18
0
        public Bundle ResourceTypeHistory(string resourceType, HistoryParameters parameters = null)
        {
            if (parameters == null)
            {
                parameters = HistoryParameters.Empty;
            }

            var request = new HistoryRequest()
            {
                ResourceType = resourceType,
                Query        = parameters.ToString()
            };

            var historyResponse = _context.Call(FhirSchema.Name, FhirSchema.Func.TypeHistory)
                                  .WithJson(request.ToJson())
                                  .Cast <String>();

            var resultBundle = ResourceDataHelper.JsonToBundle(historyResponse);

            return(resultBundle);
        }
예제 #19
0
        public FhirResponse History()
        {
            var parameters = new HistoryParameters(Request);

            return(_fhirService.History(parameters));
        }
예제 #20
0
        public FhirResponse History(string type)
        {
            var parameters = new HistoryParameters(Request);

            return(_fhirService.History(type, parameters));
        }
        private string BuildUrl2(HistoryParameters aRequest, DateTime aFromF, DateTime aToF, int nBars)
        {
            string aPage;
            string aURL;
            string requestData;
            string aStart    = aFromF.ToString("yyyyMMddHHmmss");
            string aEnd      = aToF.ToString("yyyyMMddHHmmss");
            int    aInterval = aRequest.Interval;

            switch (aRequest.Periodicity)
            {
            case Periodicity.Minute:
                aPage       = "queryminutes";
                requestData = "minute";
                break;

            case Periodicity.Hour:
                aPage       = "queryminutes";
                requestData = "minute";
                if (aInterval >= 18)
                {
                    aInterval = 60;
                }
                else
                {
                    aInterval = aInterval * 60;
                }
                break;

            case Periodicity.Day:
                aPage       = "queryeod";
                requestData = "daily";
                break;

            case Periodicity.Week:
                aPage       = "queryeod";
                requestData = "weekly";
                break;

            case Periodicity.Month:
                aPage       = "queryeod";
                requestData = "monthly";
                break;

            case Periodicity.Year:
                aPage       = "queryeod";
                requestData = "monthly";
                aInterval   = aInterval * 12;
                break;

            default:
                throw new ApplicationException("{0} periodicity is not supported");
            }

            aURL = string.Format("{0}?username={1}&password={2}&symbol={3}&interval={4}&start={5}&end={6}&maxrecords={7}&data={8}&format=csv&order=desc"
                                 , String.Format(HistoryBaseUrl, aPage)
                                 , HttpUtility.UrlEncode(m_UserName), HttpUtility.UrlEncode(m_Password), BuildSymbolName(aRequest.Symbol.Symbol, aRequest.Symbol.Type),
                                 aInterval, aStart, aEnd, nBars, requestData);

            return(aURL);
        }
예제 #22
0
        public FhirResponse History(string type, HistoryParameters parameters)
        {
            IHistoryService historyExtension = this.GetFeature <IHistoryService>();

            return(CreateSnapshotResponse(historyExtension.History(type, parameters)));
        }
예제 #23
0
 public ServerFhirResponse History(string type, HistoryParameters parameters)
 {
     throw new NotImplementedException();
 }
예제 #24
0
        public async Task <FhirResponse> History()
        {
            var parameters = new HistoryParameters(Request);

            return(await _fhirService.HistoryAsync(parameters).ConfigureAwait(false));
        }
예제 #25
0
 /// <inheritdoc />
 public Task <Snapshot> History(HistoryParameters parameters) => throw new NotImplementedException();
예제 #26
0
 public Snapshot History(HistoryParameters parameters)
 {
     return(historyStore.History(parameters));
 }
예제 #27
0
 public ServerFhirResponse History(IKey key, HistoryParameters parameters)
 {
     throw new NotImplementedException();
 }
예제 #28
0
 public Snapshot History(IKey key, HistoryParameters parameters)
 {
     return(historyStore.History(key, parameters));
 }
예제 #29
0
 public Snapshot History(string typename, HistoryParameters parameters)
 {
     return(historyStore.History(typename, parameters));
 }
예제 #30
0
    protected void Page_Load(object sender, EventArgs e)
    {
        _presenter.Initialize();

        HistoryParameters parameters = new HistoryParameters(Request);
        RenderHeader(parameters);

        if (parameters.Id > 0 && parameters.Action == HistoryPresentationMode.Detail)
        {
            _presenter.ShowLog(parameters.Id);
        }
        else if (parameters.Action == HistoryPresentationMode.Resolve)
        {
            _presenter.ShowLog(parameters.Id);
            _presenter.ResolveConflictData(parameters.ProfileId);
        }
    }
예제 #31
0
    private void RenderHeader(HistoryParameters parameters)
    {
        divTitleBar.InnerHtml =
            _styleHelper.GetTitleBar(_siteApi.EkMsgRef.GetMessage("sync log history"));

        HtmlTableCell cellBackButton = new HtmlTableCell();

        string referrer = "Sync.aspx";
        if (!string.IsNullOrEmpty(parameters.Referrer))
        {
            referrer = parameters.Referrer;
        }

        cellBackButton.InnerHtml = _styleHelper.GetButtonEventsWCaption(
            _siteApi.AppPath + "images/ui/icons/" + "back.png",
            referrer,
            _siteApi.EkMsgRef.GetMessage("alt back button text"),
            _siteApi.EkMsgRef.GetMessage("btn back"),
            String.Empty,
            StyleHelper.BackButtonCssClass,
            true);

        rowToolbarButtons.Cells.Add(cellBackButton);
    }
예제 #32
0
        private GetHistoryCtx GetHistoryCtx(HistoryParameters aParameters, TimeZoneInfo datafeedTimeZone)
        {
            int      nBars = aParameters.BarsCount;
            DateTime aFromF;
            DateTime aToF;
            int      maxBars = nBars;

            if (aParameters.Interval != 1)
            {
                nBars = aParameters.Interval * nBars;
            }
            if ((aParameters.From == DateTime.MinValue || aParameters.From == DateTime.MaxValue) && (aParameters.To == DateTime.MinValue || aParameters.To == DateTime.MaxValue))
            {
                TimeZoneInfo aTZI    = datafeedTimeZone;
                DateTime     aUTCNow = DateTime.UtcNow;

                aToF = TimeZoneInfo.ConvertTimeFromUtc(aUTCNow, aTZI);
                switch (aParameters.Periodicity)
                {
                case Periodicity.Second:
                    aFromF = aToF.Date.AddMinutes(-nBars);
                    //not supported
                    break;

                case Periodicity.Minute:
                    //need check
                    if (aParameters.Symbol.Type == Instrument.Forex)
                    {
                        double nDays = 3.0 * (1 + nBars / (24.0 * 60.0) * (7.0 / 5.0));

                        aFromF = aToF.Date.AddDays(-(int)nDays);
                    }
                    else
                    {
                        aFromF = aToF.Date.AddMinutes(-6 * nBars - 5000);
                    }
                    break;

                case Periodicity.Hour:
                    //need check
                    if (aParameters.Symbol.Type == Instrument.Forex)
                    {
                        double nDays = 3.0 * (1 + nBars / (24.0) * (7.0 / 5.0));

                        aFromF = aToF.Date.AddDays(-(int)nDays);
                    }
                    else
                    {
                        aFromF = aToF.Date.AddMinutes(-6 * nBars * 24 - 5000);
                    }
                    break;

                case Periodicity.Day:
                    aFromF = aToF.Date.AddDays(-(int)nBars * 7 / 5);
                    break;

                case Periodicity.Week:
                    aFromF = aToF.Date.AddDays(-(int)7 * nBars * 7 / 5);
                    break;

                case Periodicity.Month:
                    aFromF  = aToF.Date.AddMonths(-nBars);
                    maxBars = nBars;
                    break;

                case Periodicity.Year:
                    aToF    = new DateTime(aToF.Year, 1, 1);
                    aFromF  = aToF.Date.AddYears(-nBars);
                    nBars  *= 12;
                    maxBars = nBars;
                    break;

                default:
                    System.Diagnostics.Debug.Assert(false);
                    aFromF = aToF.Date.AddMinutes(-nBars);
                    break;
                }

                aParameters.To   = TimeZoneInfo.ConvertTimeToUtc(aToF, aTZI);
                aParameters.From = TimeZoneInfo.ConvertTimeToUtc(aFromF, aTZI);
            }
            else if (aParameters.From == DateTime.MinValue || aParameters.From == DateTime.MaxValue || aParameters.To == DateTime.MinValue || aParameters.To == DateTime.MaxValue)
            {
                throw new ApplicationException("Hitory period is specified incorrectly");
            }
            else
            {
                TimeZoneInfo aTZI    = datafeedTimeZone;
                DateTime     aUTCNow = DateTime.UtcNow;

                aToF             = TimeZoneInfo.ConvertTimeFromUtc(aParameters.To, aTZI);
                aFromF           = TimeZoneInfo.ConvertTimeFromUtc(aParameters.From, aTZI).Date;
                aParameters.From = TimeZoneInfo.ConvertTimeToUtc(aFromF, aTZI);
            }

            GetHistoryCtx aCtx = new GetHistoryCtx();

            aCtx.MaxBars = maxBars;
            //aCtx.Request = aRequest;
            aCtx.Bars  = new List <Bar>();
            aCtx.FromF = aFromF;
            aCtx.ToF   = aToF;
            //aCtx.DataFeed = aDataFeed;
            aCtx.Interval = aParameters.Interval;

            return(aCtx);
        }