コード例 #1
0
ファイル: Form1.cs プロジェクト: ManosPrk/CvEv6
        private void button1_Click(object sender, EventArgs e)
        {
            generateMainBody            = new GenerateMainBody();
            cvERepo.currentNumberOfDocs = cvERepo.MaxNumberOfDocs;
            var mainBodies = new List <MainBody>();

            for (int i = 0; i < 30; i++)
            {
                if (!DataFromApi.IsApiOnline())
                {
                    break;
                }
                var mainbody = new MainBody {
                    Name = generateMainBody.Get()
                };
                if (!mainBodies.Any(m => m.Name == mainbody.Name))
                {
                    cvERepo.sendData(new MainBody {
                        Name = generateMainBody.Get()
                    }, Options.Create);
                    mainBodies.Add(mainbody);
                }
            }
            MessageBox.Show("Done!");
        }
コード例 #2
0
        //private void setMaxNumberOfDocs()
        //{
        //    foreach (var domain in Domains)
        //    {
        //        if (domain.Documents.Count > maxNumberOfDocs)
        //        {
        //            maxNumberOfDocs = domain.Documents.Count;
        //        }
        //    }
        //}

        public async Task getData()
        {
            dataFromApi = new DataFromApi();
            Domains     = await dataFromApi.getApiDomains();

            titles = await dataFromApi.getTitles();

            MainBodies = await dataFromApi.getMainBodies();
        }
コード例 #3
0
 private CvERepo()
 {
     if (DataFromApi.IsApiOnline())
     {
         Task.Run(() => instance.getData());
     }
     else
     {
         RestoreOfflineData();
     }
 }
コード例 #4
0
        public void sendData(IDto _dto, Options options)
        {
            if (!DataFromApi.IsApiOnline())
            {
                MessageBox.Show("API offline, unable to send data at the moment");
                return;
            }
            StoreDataToApi store = new StoreDataToApi(_dto);

            if (options == Options.Create)
            {
                store.CreateData();
            }
            else if (options == Options.Delete)
            {
                store.delData();
            }
            Task.Run(() => refreshData()).Wait();
        }