Esempio n. 1
0
 /// <summary>
 /// Starting the archive reports search process
 /// </summary>
 /// <param name="accountId">Account to search reports</param>
 /// <returns>List of achive reports</returns>
 internal static async Task <List <ArchiveReport> > SearchAsync(string accountId)
 {
     Processing = true;
     try
     {
         if (Matching.IsAccountId(accountId))
         {
             if (ArchiveReportsInfo == null)
             {
                 GoogleSheets googleSheets = new GoogleSheets();
                 ArchiveReportsInfo = await googleSheets.GetArchiveReportsInfoAsync();
             }
             List <ArchiveReport> reports = new List <ArchiveReport>();
             foreach (var item in ArchiveReportsInfo)
             {
                 if (item[1].ToString() == accountId)
                 {
                     reports.Add(new ArchiveReport(item));
                 }
             }
             return(reports);
         }
         return(null);
     }
     finally
     {
         Processing = false;
     }
 }
        private static async Task AddReportsToArchive(GoogleSheets sheets, ServiceContext serviceContext)
        {
            List <IList <object> > archiveReports = new List <IList <object> >();

            for (int i = 0; i < serviceContext.TotalHouses; i++)
            {
                archiveReports.AddRange(serviceContext.Houses[i].GetObjects());
            }
            UpdateInfo($"Сохранение отчета ...");
            var oldReports = await sheets.GetArchiveReportsInfoAsync();

            archiveReports.AddRange(oldReports);
            await sheets.UpdateArchiveReportsInfoAsync(archiveReports);
        }