/// <summary>
        /// 加载批注标签数据
        /// </summary>
        private async void LoadPostilTagData()
        {
            PostilTagList.Clear();
            var listParams = new ListParams {
                Search = Query.Eq(Hubs.Tag.ProjectId, Mg.Get <IMgContext>().ProjectId)
            };
            var result = await DataApi.GetListAsync(Hubs.Tag.T, listParams);

            if (!result.IsOk)
            {
                return;
            }
            var records = result.GetRecords();

            foreach (var record in records)
            {
                var name  = record[Hubs.Tag.Name].As <string>();
                var model = new TagInfoModel
                {
                    Id   = record.Id,
                    Name = $" {name} "
                };
                PostilTagList.Add(model);
            }
        }
Exemple #2
0
        static void PerfTest(DataApi dapi)
        {
            //var code = "RB1810.SHF";
            var code = "600000.SH";

            dapi.Subscribe(new string[] { code });

            long begin_time = DateTime.Now.Ticks;

            int count = 3000;

            for (var i = 0; i < count; i++)
            {
                if (i % 100 == 0)
                {
                    Console.WriteLine(i);
                }
                var r = dapi.GetTick(code, 20180612);
                //var r = dapi.GetBar(code, "1m");
                if (r.Value == null)
                {
                    Console.WriteLine("GetTick error: " + r.Msg);
                }
            }

            long end_time = DateTime.Now.Ticks;

            Console.WriteLine("Used time: " + (end_time - begin_time) / 10000.0 + "ms");
            Console.WriteLine("Each time: " + (end_time - begin_time) / 10000.0 / count + "ms");
            Console.Read();
        }
Exemple #3
0
        private async void DataAdd(WebMsgEventArgs eventArgs)
        {
            await Task.Delay(300);

            var addId = eventArgs.Data.As <Id>();

            if (addId == null)
            {
                return;
            }
            var result = await DataApi.GetDataInfoAsync(Hubs.Postil.T, addId);

            if (!result.IsOk)
            {
                return;
            }
            var model  = result.GetRecord().As <PostilInfoModel>();
            var urlDic = await Util.Data.GetPictureUrlsAsync(new[] { model.FileId });

            var userDic = await Util.Data.GetUserInfosAsync(new[] { model.CreateUser });

            model.ImageUrl   = urlDic?[model.FileId];
            model.PostilUser = userDic?[model.CreateUser];
            model.FirstTag   = $" {model.Tags[0]} ";
            model.LastTime   = DateDiff(Convert.ToDateTime(model.CreateTime), DateTime.Now);
            PostilInfoModels.Insert(0, model);
            _backupPostilInfoModels.Insert(0, model);
        }
Exemple #4
0
        static void PerfTest2(DataApi dapi)
        {
            var codes = new List <String>();

            var result = CSVReader.ParseCSV(File.ReadAllText(@"d:\\tmp\\000300.SH.csv"));

            foreach (var line in result)
            {
                codes.Add(line[3]);
            }
            codes.RemoveAt(0);

            dapi.Subscribe(new String[] { "000001.SH" });
            dapi.Subscribe(codes.ToArray());

            var begin_time = DateTime.Now;

            foreach (var bar in dapi.GetDailyBar("000001.SH").Value)
            {
                if (bar.Date < 20180101 || bar.Date > 20180501)
                {
                    continue;
                }
                foreach (var code in codes)
                {
                    dapi.GetBar(code, "1m", bar.Date);
                }
            }
            var end_time = DateTime.Now;

            Console.Out.WriteLine(String.Format("time: {0}", (end_time - begin_time).TotalSeconds));
        }
Exemple #5
0
        /// <summary>
        /// Chargement de l'IHM et declenchement de la requete POST
        /// </summary>
        private void Form1_Load(object sender, EventArgs e)
        {
            Log.Info("Initialisation de l'application : Form.Load");

            Visible       = false; // Hide form window.
            ShowInTaskbar = false; // Remove from taskbar.

            //recupere le nom host et le nom de l'utilisateur
            InitNotify();

            //TODO voir ce qu'on en fait
            Log.Debug("Version du projet: " + CurrentVersion);;

            //Initalisation du design du popup
            InitPopup();

            // Mise en place de la connexion avec l'API
            Api = new DataApi(this);

            // Recupère dynamiquement la configuration de l'application
            SetupConfiguration();

            // Met en place le menu de maniere dynamique
            SetMenu();

            //Connexion a l'API
            threadConnexion = new Thread(ConnexionApi);
            threadConnexion.IsBackground = true;
            threadConnexion.Start();

            //TODO Verifie si il y a une nouvelle version d'HylaNotify
            //new AppUpdate(Config.items.update);
        }
        public async Task <IEnumerable <Data> > GetQuickDataForLocation(int month, string locationId, [FromQuery] bool ignoreCache = false)
        {
            if (!ignoreCache && _memCache.TryGetValue(month + "MonthlyData" + locationId, out IEnumerable <Data> data))
            {
                return(data);
            }

            var dataApi  = new DataApi(_ncdcApiManager);
            var taskList = new List <Task <IEnumerable <Data> > >();

            for (int i = 0; i <= 5; i++)
            {
                var endDateString = DateTime.Now.Year - i + "-" + month.ToString().PadLeft(2, '0') + "-" + DateTime.DaysInMonth(DateTime.Now.Year, month).ToString().PadLeft(2, '0');
                var endDate       = DateTime.Parse(endDateString);
                var startDate     = DateTime.Parse(DateTime.Now.Year - i + "-" + month.ToString().PadLeft(2, '0') + "-01");

                taskList.Add(dataApi.GetDataAsync(new List <DataType> {
                    DataType.PRCP, DataType.DP01, DataType.TMAX, DataType.TMIN
                }, DataSet.GSOM, locationId, startDate, endDate));
            }

            var results = await Task.WhenAll(taskList);

            var result = results.SelectMany(r => r).ToList();

            var cacheEntryOptions = new MemoryCacheEntryOptions()
                                    .SetAbsoluteExpiration(TimeSpan.FromDays(1));

            _memCache.Set(month + "MonthlyData" + locationId, result, cacheEntryOptions);
            return(result);
        }
        public void DataAPIGetItems()
        {
            // Arrange
            JsonObject JsonResponse;

            string endpoint = this.baseDataAPIUrl + "/itembank/items";

            string action = "get";

            JsonObject security = new JsonObject();

            security.set("consumer_key", this.consumerKey);
            security.set("domain", this.domain);

            JsonObject request = new JsonObject();

            request.set("limit", 3);

            // Act
            DataApi da = new DataApi();
            Remote  r  = da.request(endpoint, security, this.consumerSecret, request, action);

            JsonResponse = JsonObjectFactory.fromString(r.getBody());

            // Assert
            Assert.True(JsonResponse.getJsonObject("meta").getBool("status"));
        }
Exemple #8
0
        public void TestBasedViewModel()
        {
            var d = new DataApi();

            d.Register(typeof(MyTableViewModel));
            d.TestApinameExists("MyTable", true);
            d.TestApinameExists("myTable", true);
        }
Exemple #9
0
        public void TestBasedOnEntity()
        {
            var d = new DataApi();

            d.Register(typeof(MyTable));
            d.TestApinameExists("mytable", true);
            d.TestApinameExists("myTable", true);
        }
        /// <summary>
        /// Get Youbora Data
        /// </summary>
        /// <param name="system">Your Nice PeopleAtWork account code that indicates Youbora Analytics
        /// which customer account you are sending the data to. This parameter will be provided by
        /// NicePeopleAtWork, if you don't have it yet, please contact your Customer Engineer or Support
        /// Agent</param>
        /// <param name="pluginVersion">The version of the plugin in the format described below this table.
        /// This parameter lets you to have a version control of new deployed plugins and see which
        /// users are using an older version (cached in the system), so you can force them to clean
        /// their cache and download the new version</param>
        /// <param name="complete">Complete Action</param>
        public static void GetData(string system,
                                   string pluginVersion,
                                   Action <DataRoot> complete)
        {
            var url = DataApi.PlayerData(system, pluginVersion);

            ApiClient.GetContent(url, complete);
        }
        /// <summary>
        /// Get Youbora Data
        /// </summary>
        /// <param name="system">Your Nice PeopleAtWork account code that indicates Youbora Analytics
        /// which customer account you are sending the data to. This parameter will be provided by
        /// NicePeopleAtWork, if you don't have it yet, please contact your Customer Engineer or Support
        /// Agent</param>
        /// <param name="pluginVersion">The version of the plugin in the format described below this table.
        /// This parameter lets you to have a version control of new deployed plugins and see which
        /// users are using an older version (cached in the system), so you can force them to clean
        /// their cache and download the new version</param>
        /// <returns>Data</returns>
        public static Models.Data.Data GetData(string system,
                                               string pluginVersion)
        {
            var url = DataApi.PlayerData(system, pluginVersion);

            var result = ApiClient.GetSynchronousContent <DataRoot>(url);

            return((result != null) ? result.Data : null);
        }
Exemple #12
0
 static void TestDataApi(DataApi dapi)
 {
     {
         var r = dapi.GetBar("000001.SH", "1m", 0, true);
         if (r.Value != null)
         {
             foreach (var bar in r.Value)
             {
                 Console.WriteLine(bar.Code + "|"
                                   + bar.Date + "|" + bar.Time + "|"
                                   + bar.Open + "|" + bar.High + "|"
                                   + bar.Low + "|" + bar.Close + "|"
                                   + bar.Volume + "|" + bar.Turnover);
             }
             Console.WriteLine("bars : " + r.Value.Length);
         }
         else
         {
             Console.WriteLine("GetBar error:" + r.Msg);
         }
     }
     {
         var r = dapi.GetTick("600000.SH");
         if (r.Value != null)
         {
             foreach (var tick in r.Value)
             {
                 Console.WriteLine(tick.Code + "|"
                                   + tick.Date + "|" + tick.Time + "|"
                                   + tick.Open + "|" + tick.High + "|"
                                   + tick.Low + "|" + tick.Close + "|"
                                   + tick.Volume + "|" + tick.Turnover);
             }
             Console.Write("ticks: " + r.Value.Length);
         }
     }
     {
         var r = dapi.GetDailyBar("000001.SH", "", true);
         if (r.Value != null)
         {
             foreach (var bar in r.Value)
             {
                 Console.WriteLine(bar.Code + "|"
                                   + bar.Date + "|"
                                   + bar.Open + "|" + bar.High + "|"
                                   + bar.Low + "|" + bar.Close + "|"
                                   + bar.Volume + "|" + bar.Turnover);
             }
             Console.WriteLine("dailybars : " + r.Value.Length);
         }
         else
         {
             Console.WriteLine("GetBar error:" + r.Msg);
         }
     }
 }
Exemple #13
0
        /// <summary>
        /// 加载图片数据
        /// </summary>
        public static async Task <Dictionary <Id, string> > GetPictureUrlsAsync(Id[] fileIds)
        {
            var result = await DataApi.GetFilesUrlAsync(fileIds);

            if (!result.IsOk)
            {
                Mg.Get <IMgLog>().Error("获取批注的图片数据失败" + result.Message);
                Mg.Get <IMgDialog>().ShowDesktopAlert("获取批注的图片数据失败", result.Message);
                return(null);
            }
            return(result.Data.As <Dictionary <Id, string> >());
        }
        /// <summary>
        /// 删除标签事件
        /// </summary>
        /// <param name="model"></param>
        public async void OnDeleteTag(TagInfoModel model)
        {
            //var showResult = this.ShowMessage("确定删除[" + model.Name + "]标签吗?", "提示", MessageBoxButton.OKCancel);
            //if (showResult == MessageBoxResult.Cancel)
            //    return;
            var result = await DataApi.DeleteAsync(Hubs.Tag.T, new[] { model.Id });

            if (result.IsOk)
            {
                PostilTagList.Remove(model);
            }
        }
        /// <summary>
        /// 删除某条批注事件
        /// </summary>
        /// <param name="delPicModel"></param>
        private async void OnDeletePostilItem(PictureModel delPicModel)
        {
            if (delPicModel == null)
            {
                return;
            }
            if (this.ShowMessage("删除后将无法恢复信息,确定删除这条批注吗?", "警告", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
            {
                return;
            }
            var index    = delPicModel.SelectedPicIndex;
            var deleteId = delPicModel.PostilId;
            var result   = await DataApi.DeleteAsync(Hubs.Postil.T, new[] { deleteId });

            if (!result.IsOk)
            {
                Mg.Get <IMgLog>().Error("删除批注信息失败" + result.Message);
                Mg.Get <IMgDialog>().ShowDesktopAlert("删除批注信息失败", result.Message);
                return;
            }
            if (ViewPictureModels.Count == 8)
            {
                if (SelectedViewPicModel.PostilId == deleteId)
                {
                    LoadPostilInfosAsync(_currentPageIndex, () => SelectedViewPicModel = ViewPictureModels.ElementAtOrDefault(index) ?? ViewPictureModels.LastOrDefault());
                }
                else
                {
                    var selectId = SelectedViewPicModel.PostilId;
                    LoadPostilInfosAsync(_currentPageIndex, () => SelectedViewPicModel = ViewPictureModels.FirstOrDefault(t => t.PostilId == selectId) ?? ViewPictureModels.FirstOrDefault());
                }
            }
            else
            {
                var selectId = SelectedViewPicModel.PostilId;
                ViewPictureModels.Remove(delPicModel);
                for (var i = 0; i < ViewPictureModels.Count; i++)//重新给索引
                {
                    ViewPictureModels[i].SelectedPicIndex = i;
                }
                _listPostilInfoModel.Remove(_listPostilInfoModel.FirstOrDefault(t => t._id == deleteId));
                if (deleteId == selectId)
                {
                    SelectedViewPicModel = ViewPictureModels.ElementAtOrDefault(index) ?? ViewPictureModels.LastOrDefault();
                }
                if (ViewPictureModels.Count == 0 && _currentPageIndex != 0)
                {
                    LoadPostilInfosAsync(--_currentPageIndex, () => SelectedViewPicModel = ViewPictureModels.LastOrDefault());
                }
            }
            _isSelfDelPostil = true;
            await Mg.Get <IMgWeb>().SendWebMsgAsync("demoPostil/delete", deleteId.ToString(), BoardcastType.ProjectGroup);//发送广播
        }
        public async void OnAddPostil()
        {
            var inputTagList = PostilTag.Split(',', ',').ToList().Select(t => t.Trim()).ToList();
            var tagSet       = new HashSet <string>(inputTagList.Where(t => t != ""));

            if (!File.Exists(_screenshotPicPath))
            {
                return;
            }
            var result = await DataApi.UploadFilesAsync(new[] { _screenshotPicPath }, Mg.Get <IMgContext>().ProjectId);

            if (!result.IsOk)
            {
                Mg.Get <IMgLog>().Error("上传截图失败:" + result.Message);
                Mg.Get <IMgDialog>().ShowDesktopAlert("上传截图失败", result.Message);
                return;
            }
            var fileId = result.Data.AsList <Id>().FirstOrDefault();
            var data   = new DynamicRecord
            {
                [Hubs.Postil.ProjectId]    = Mg.Get <IMgContext>().ProjectId,
                [Hubs.Postil.Title]        = PostilTitle,
                [Hubs.Postil.CreateTime]   = DateTime.Now,
                [Hubs.Postil.CreateUser]   = Mg.Get <IMgContext>().UserId,
                [Hubs.Postil.Tags]         = tagSet,
                [Hubs.Postil.IsPublic]     = IsPublic,
                [Hubs.Postil.FileId]       = fileId,
                [Hubs.Postil.CameraMatrix] = _matrixArray
            };
            var createResult = await DataApi.AddAsync(Hubs.Postil.T, new IRecord[] { data });

            if (!createResult.IsOk)
            {
                Mg.Get <IMgLog>().Error("添加批注失败:" + createResult.Message);
                Mg.Get <IMgDialog>().ShowDesktopAlert("添加批注失败", createResult.Message);
                return;
            }
            var originalTagList = PostilTagList.Select(tag => tag.Name.Trim()).ToList();
            var tagData         = (from tag in tagSet
                                   where !originalTagList.Contains(tag)
                                   select new DynamicRecord
            {
                [Hubs.Tag.ProjectId] = Mg.Get <IMgContext>().ProjectId,
                [Hubs.Tag.Name] = tag
            }).ToList();
            await DataApi.AddAsync(Hubs.Tag.T, tagData.AsArray <IRecord>());

            var addRecord = createResult.Data.AsList <DynamicRecord>().FirstOrDefault();
            await Mg.Get <IMgWeb>().SendWebMsgAsync("demoPostil/add", addRecord?.Id.ToString(), BoardcastType.ProjectGroup);//发送广播

            //Close();
        }
        /// <summary>
        /// 加载指定页的批注信息
        /// </summary>
        private async void LoadPostilInfosAsync(int pageIndex, Action action = null)
        {
            IsBusy = true;
            var listParams = new ListParams
            {
                Search = Query.Eq(Hubs.Postil.ProjectId, Mg.Get <IMgContext>().ProjectId),
                Page   = new ListParams.PageInfo(pageIndex, 8),
                Sort   = new[] { new ListParams.SortProperty(Hubs.Postil.CreateTime, false) }
            };
            var dataResult = await DataApi.GetListAsync(Hubs.Postil.T, listParams);

            _listPostilInfoModel.Clear();
            if (!dataResult.IsOk)
            {
                Mg.Get <IMgLog>().Error("获取批注信息失败" + dataResult.Message);
                Mg.Get <IMgDialog>().ShowDesktopAlert("获取批注信息失败", dataResult.Message);
                IsBusy = false;
                return;
            }
            var models = dataResult.GetRecords().Select(t => t.As <PostilInfoModel>()).ToList();

            if (models.Count == 0)
            {
                IsBusy = false;
                return;
            }
            var urlDic = await Util.Data.GetPictureUrlsAsync(models.Select(t => t.FileId).ToArray());

            var userDic = await Util.Data.GetUserInfosAsync(models.Select(t => t.CreateUser).ToArray());

            foreach (var postilInfoModel in models)
            {
                postilInfoModel.ImageUrl   = urlDic?[postilInfoModel.FileId];
                postilInfoModel.PostilUser = userDic?[postilInfoModel.CreateUser];
                _listPostilInfoModel.Add(postilInfoModel);
            }
            ViewPictureModels.Clear();
            for (var index = 0; index < models.Count; index++)
            {
                var model = models[index];
                ViewPictureModels.Add(new PictureModel
                {
                    SelectedPicIndex = index,
                    PostilId         = model._id,
                    ImageUrl         = model.ImageUrl
                });
            }
            SelectedViewPicModel = ViewPictureModels.FirstOrDefault();
            action?.Invoke();
            LoadNextPageCountAsync();
            IsBusy = false;
        }
Exemple #18
0
        static void TestDataApi2(DataApi dapi)
        {
            dapi.Subscribe(new string[] {
                //"CU1806.SHF", "RB1810.SHF",
                "000001.SH", "399001.SZ",
                "600000.SH", "000001.SZ"
            });

            dapi.OnBar         += OnBar;
            dapi.OnMarketQuote += OnMarketQuote;

            while (true)
            {
                Thread.Sleep(1000);
            }
        }
        public static void Main()
        {
            using (var httpClient = new HttpClient())
            {
                var authenticator =
                    new PasswordFlowAuthenticator(ClientId, ClientSecret, Username, Password, AuthEndpoint, httpClient);

                var dataApi    = new DataApi(authenticator, httpClient, 44);
                var toolingApi = new ToolingApi(authenticator, httpClient, 44);
                var customApi  = new CustomApi(authenticator, httpClient);

                new DataApiSample(dataApi).RunAsync().GetAwaiter().GetResult();
                new ToolingApiSample(toolingApi).RunAsync().GetAwaiter().GetResult();
                new CustomApiSample(customApi).RunAsync().GetAwaiter().GetResult();
            }
        }
Exemple #20
0
        public AuctionHandlerService(
            ILogger <AuctionHandlerService> logger,
            IOptions <DataApi> dataApiConfig,
            IHubContext <AuctionHub> auctionContext,
            IMapper mapper
            )
        {
            _logger         = logger;
            _dataApi        = dataApiConfig.Value;
            _auctionAuction = auctionContext;
            _players        = new List <Player>();
            _soldPlayers    = new List <SoldPlayer>();
            _mapper         = mapper;

            _waitingTime = 10;
            _biddingTime = 20;
        }
        /// <summary>
        /// 读取下一页批注是否还有数据
        /// </summary>
        private async void LoadNextPageCountAsync()
        {
            var listParams = new ListParams
            {
                Search = Query.Eq(Hubs.Postil.ProjectId, Mg.Get <IMgContext>().ProjectId),
                Page   = new ListParams.PageInfo(_currentPageIndex + 1, 8),
                Sort   = new[] { new ListParams.SortProperty(Hubs.Postil.CreateTime, true) },
                Map    = new[] { Id.Name }
            };
            var result = await DataApi.GetListAsync(Hubs.Postil.T, listParams);

            if (!result.IsOk)
            {
                _canNextPage = false;
                return;
            }
            _canNextPage = result.GetRecords().Count > 0;
        }
Exemple #22
0
        static void PerfTest3(DataApi dapi)
        {
            LoadCodeMapping();

            //String code = "IF.CFE";
            String code = "RB.SHF";

            dapi.Subscribe(new String[] { code });


            var begin_time  = DateTime.Now;
            int total_count = 0;
            int date_count  = 0;

            var begin_date = new System.DateTime(2017, 1, 1);
            var end_date   = new System.DateTime(2018, 1, 1);

            for (var date = begin_date; date < end_date; date = date.AddDays(1))
            {
                int    i_date    = date.Year * 10000 + date.Month * 100 + date.Day;
                string real_code = GetCode(code, i_date);
                //auto ticks = dapi->bar(real_code, "1m", bar.date, false);
                var ticks = dapi.GetTick(real_code, i_date);
                if (ticks.Value != null)
                {
                    date_count++;
                    total_count += ticks.Value.Length;
                }
                else
                {
                    Console.WriteLine(String.Format("tick error: {0}, {1}, {2}", real_code, i_date, ticks.Msg));
                }
            }

            var end_time = DateTime.Now;

            var used_time = end_time - begin_time;

            Console.Out.WriteLine(String.Format("used time     : {0} milliseconds", (int)used_time.TotalMilliseconds));
            Console.Out.WriteLine(String.Format("total records : {0}", total_count));
            Console.Out.WriteLine(String.Format("total date    : {0}", date_count));
            Console.Out.WriteLine(String.Format("ticks per day : {0}", total_count / date_count));
            Console.Out.WriteLine(String.Format("time per day  : {0}", used_time.TotalMilliseconds * 1.0 / date_count));
        }
Exemple #23
0
        /// <summary>
        /// 加载所有批注信息数据
        /// </summary>
        private async void LoadPostilInfos()
        {
            IsBusy = true;
            PostilInfoModels.Clear();
            _backupPostilInfoModels.Clear();
            var listParams = new ListParams
            {
                Search = Query.Eq(Hubs.Postil.ProjectId, Mg.Get <IMgContext>().ProjectId),
                Sort   = new[] { new ListParams.SortProperty(Hubs.Postil.CreateTime, false) }
            };
            var result = await DataApi.GetListAsync(Hubs.Postil.T, listParams);

            if (!result.IsOk)
            {
                Mg.Get <IMgLog>().Error("获取批注信息失败" + result.Message);
                Mg.Get <IMgDialog>().ShowDesktopAlert("获取批注信息失败", result.Message);
                IsBusy = false;
                return;
            }
            var models = result.GetRecords().Select(t => t.As <PostilInfoModel>()).ToList();

            if (models.Count == 0)
            {
                IsBusy = false;
                return;
            }
            var urlDic = await Util.Data.GetPictureUrlsAsync(models.Select(t => t.FileId).ToArray());

            var userDic = await Util.Data.GetUserInfosAsync(models.Select(t => t.CreateUser).ToArray());

            foreach (var postilInfoModel in models)
            {
                postilInfoModel.ImageUrl   = urlDic?[postilInfoModel.FileId];
                postilInfoModel.PostilUser = userDic?[postilInfoModel.CreateUser];
                postilInfoModel.FirstTag   = $" {postilInfoModel.Tags[0]} ";
                var dt1 = Convert.ToDateTime(postilInfoModel.CreateTime);
                var dt2 = DateTime.Now;
                postilInfoModel.LastTime = DateDiff(dt1, dt2);
                PostilInfoModels.Add(postilInfoModel);
                _backupPostilInfoModels.Add(postilInfoModel);
            }
            IsBusy = false;
        }
        protected override async Task OnStartupAsync()
        {
            //获取RibbonTab
            _projectTab = Mg.Get <IMgRibbon>().GetRibbonTab(LocalConfig.InsertTabName);
            if (_projectTab != null)
            {
                _groupVm = new PostilGroupViewModel();
                _projectTab.Groups.Add(_groupVm);
            }
            else
            {
                Mg.Get <IMgLog>().Warn($"没有找到名称为{LocalConfig.InsertTabName}的RibbonTab!批注管理应用无法插入相关Ribbon菜单!");
            }
            await DataApi.CreateIndexAsync(Hubs.Postil.T, new[] { Hubs.Postil.ProjectId });

            await DataApi.CreateIndexAsync(Hubs.Tag.T, new[] { Hubs.Postil.ProjectId });

            await Task.Yield();
        }
        public async Task <IEnumerable <Data> > GetAllDataForLocation(string locationId)
        {
            if (_memCache.TryGetValue("AllData" + locationId, out IEnumerable <Data> data))
            {
                return(data);
            }

            var dataApi = new DataApi(_ncdcApiManager);

            var dataTask = await dataApi.GetDataAsync(new List <DataType> {
                DataType.PRCP, DataType.TMAX, DataType.TMIN, DataType.TAVG, DataType.DP01
            },
                                                      DataSet.GSOM, locationId, _historicalStartDate, DateTime.Now);

            var cacheEntryOptions = new MemoryCacheEntryOptions()
                                    .SetAbsoluteExpiration(TimeSpan.FromDays(1));

            _memCache.Set("AllData" + locationId, dataTask, cacheEntryOptions);
            return(dataTask);
        }
        public IEnumerable <Data> GetPrecipitationForLocation(string locationId)
        {
            if (_memCache.TryGetValue("PrcpData" + locationId, out IEnumerable <Data> data))
            {
                return(data);
            }

            var dataApi = new DataApi(_ncdcApiManager);

            var dataTask = dataApi.GetDataAsync(new List <DataType> {
                DataType.PRCP, DataType.DP01
            }, DataSet.GSOM, locationId, _historicalStartDate, DateTime.Now);

            dataTask.Wait();

            var cacheEntryOptions = new MemoryCacheEntryOptions()
                                    .SetAbsoluteExpiration(TimeSpan.FromDays(1));

            _memCache.Set("PrcpData" + locationId, dataTask.Result, cacheEntryOptions);
            return(dataTask.Result);
        }
Exemple #27
0
        /// <summary>
        /// Run the request using DataApi and returns result
        /// </summary>
        /// <returns></returns>
        public static string DataApi()
        {
            string url = "https://data.learnosity.com/v1/sessions/responses";

            JsonObject security = new JsonObject();

            security.set("consumer_key", Credentials.ConsumerKey);
            security.set("domain", Credentials.Domain);

            string secret = Credentials.ConsumerSecret;

            JsonObject request = new JsonObject();

            request.set("limit", 1000);

            string action = "get";

            DataApi da = new DataApi();
            Remote  r  = da.request(url, security, secret, request, action);

            return(r.getBody());
        }
Exemple #28
0
        /// <summary>
        /// Run the request using recursive version of DataApi and returns result
        /// </summary>
        /// <returns></returns>
        public static string DataApiRecursive()
        {
            string url = "https://data.learnosity.com/v1/sessions/responses";

            JsonObject security = new JsonObject();

            security.set("consumer_key", Credentials.ConsumerKey);
            security.set("domain", Credentials.Domain);

            string secret = Credentials.ConsumerSecret;

            JsonObject request = new JsonObject();

            request.set("limit", 1000);

            string action = "get";

            ProcessData callback = new ProcessData(Data.DataApiRecursiveCallback);

            DataApi    da = new DataApi();
            JsonObject jo = da.requestRecursive(url, security, secret, request, action, callback);

            return(jo.toJson());
        }
Exemple #29
0
 public static void Init()
 {
     dapi = TQuantApi.CreateDataApi("ipc://tqc_10001");
     tapi = TQuantApi.CreateTradeApi("ipc://tqc_10001");
 }
        public void TestApi()
        {
            var dapi = new DataApi();

            dapi.Register(typeof(MockTable));
        }