Пример #1
0
        public Task <Try <Exception, bool> > WriteAllDataAsync(string path, Task <DataTable> dataSourceAsync)
        {
            OutputDirectory = path;
            var task = new Task <Try <Exception, bool> >(() =>
            {
                return(TryHelper.Try(this, (ctx) =>
                {
                    dataSourceAsync.Wait();
                    var datasource = dataSourceAsync.Result;
                    if (datasource.Rows.Count == 0)
                    {
                        return false;
                    }
                    var validators = Settings.Get <IEnumerable <IValidator> >();
                    Assert(ExecutionOrder.FileIsWritting, validators);
                    StringBuilder text = new StringBuilder();
                    Parser.CopyTo(text, datasource);
                    File.WriteAllText(path, text.ToString());
                    OutputDirectory = null;
                    return true;
                }));
            });

            task.Start();
            return(task);
        }
Пример #2
0
        private void btnPopularGrid_Click(object sender, EventArgs e)
        {
            int    age        = 0;
            string tipoFiltro = cbxFilterType.SelectedItem?.ToString();

            int.TryParse(txtAge.Text, out age);
            dataGridView1.DataSourceAsync(TryHelper.TryAsync(this, (frm) => FilterData(tipoFiltro).Result));
        }
Пример #3
0
 public Try <Exception, DataTable> Read()
 {
     return(TryHelper.Try(this, (ctx) =>
     {
         throw new Exception("Teste");
         var validators = Settings.Get <IEnumerable <IParsingValidator> >().ToArray();
         return Parser.Run(Lines, validators).AsDataTable();
     }));
 }
Пример #4
0
 public Try <Exception, IFileHandler> Open(string fileName)
 {
     return(TryHelper.Try((IFileHandler)this, (ctx) =>
     {
         var validators = Settings.Get <IEnumerable <IValidator> >();
         this.Parser = Settings.Get <IParser>();
         this.FileName = fileName;
         Assert(ExecutionOrder.FileIsOpenning, validators);
         Lines = File.ReadAllLines(fileName, Encoding.Default);
         return ctx;
     }));
 }
Пример #5
0
        public static EmployeeInfo GetEmployeeInfo(this IIdentity identity)
        {
            EmployeeInfo result = null;

            var claimsIdentity = (ClaimsIdentity)identity;

            var employeeInfoJson = claimsIdentity.FindFirstValue(EmployeeInfo.CalimName);

            if (!String.IsNullOrWhiteSpace(employeeInfoJson))
            {
                result = TryHelper.Try(() => Serialization.DeSerialize <EmployeeInfo>(employeeInfoJson));
            }

            return(result);
        }
Пример #6
0
        static void Main(string[] args)
        {
            GmiApp.Initialize();
            //Update Fiat Currencies Exchange Rate
            TryHelper.Try(FiatCurrencyService.Instance.AddOrUpdate, Log);

            //Update Crypto Currencies info, and update Algorithms
            TryHelper.Try(CoinService.Instance.AddOrUpdate, Log);
            //Update USD Exchange Rates;
            TryHelper.Try(CoinService.Instance.UpdateUsdExchangeRates, Log);

            //Generate Profitability Report
            GpusInsightsReport report = TryHelper.Try(GpuInsightsService.GenerateReport, Log);

            //Save the Report To DB
            TryHelper.Try(() => GpusInsightsReportService.Instance.Add(report), Log);
        }