Пример #1
0
        //private const string CACHE_DIR = "BasicAuthBulkCacheReader";


        public static (List <IDocumentDTO>, List <IDocumentDTO>) QueryBothSources(this ComparisonsListBase compList)
        {
            var byfDir = compList.MainWindow.CacheDir;
            var rntDir = compList.AppArgs;
            List <IDocumentDTO> byfs = null;
            List <IDocumentDTO> rnts = null;

            Parallel.Invoke(() => byfs = QueryBYF(compList, byfDir),
                            () => rnts = compList.GetListFromRNT(rntDir));
            return(byfs, rnts);
        }
Пример #2
0
        private static List <IDocumentDTO> ConcurrentCast(ComparisonsListBase compList, List <object> byfList)
        {
            var jobs = new List <Action>();
            var bag  = new ConcurrentBag <IDocumentDTO>();

            foreach (var rec in byfList)
            {
                jobs.Add(() => bag.Add(SafeCastByfToDTO(compList, rec)));
            }

            Parallel.Invoke(jobs.ToArray());

            return(bag.ToList());
        }
Пример #3
0
 private static IDocumentDTO SafeCastByfToDTO(ComparisonsListBase compList, object byf)
 {
     try
     {
         return(compList.CastByfToDTO(byf));
     }
     catch (Exception ex)
     {
         return(new DocumentDTOBase
         {
             Id = compList.GetByfId(byf),
             Remarks = ex.Info(true)
         });
     }
 }
Пример #4
0
        private static List <IDocumentDTO> QueryBYF(ComparisonsListBase compList, string cacheDir)
        {
            List <object> byfList = null;

            try
            {
                byfList = compList.GetListFromBYF(cacheDir);
            }
            catch (Exception ex)
            {
                Alert.Show(ex, "Querying list from BYF");
                return(null);
            }
            return(ConcurrentCast(compList, byfList));
        }
Пример #5
0
        public static async Task ImportAll(this ComparisonsListBase compList)
        {
            var win = compList.MainWindow;

            win.StartBeingBusy($"Importing all {win.PickedListName} ...");
            await Task.Delay(1);

            await Task.Run(() =>
            {
                try
                {
                    var recs = compList.Select(_ => _.Document1 as IDocumentDTO);
                    compList.ReplaceAll(recs, win.AppArgs.MarketState);
                }
                catch (Exception ex)
                {
                    Alert.Show(ex, $"Importing all {win.PickedListName}");
                }
            });

            win.StopBeingBusy();
            win.ClickRefresh();
        }
Пример #6
0
 public static List <JsonComparer> AlignByIDs(this ComparisonsListBase compList, (List <IDocumentDTO>, List <IDocumentDTO>) tupl)