Esempio n. 1
0
        private static string GenerateClassificationJson(GeneralConfigItem config, string cacheFilename)
        {
            var mailsync = new MailSync(config.Host, config.Port, config.Username, config.Password, config.MailBox, config.Assignments.Select(t => t.ConvertBack()).ToList());

            ICachePersistence cache = null;

            if (cacheFilename != null)
            {
                cache = new JsonCachePersistence(cacheFilename);
                mailsync.CacheService.LoadCache(cache);
            }

            var assignments = (from ass in mailsync.Assignments
                               select new AssignmentUpdateItemDto()
            {
                Name = ass.Name,
                Items = (from u in mailsync.Classify(ass) select u.SerializeJson()).ToList()
            }).ToList();

            if (cacheFilename != null)
            {
                mailsync.CacheService.SaveCache(cache);
            }


            return(JsonConvert.SerializeObject(assignments));
        }
Esempio n. 2
0
        public static void GenerateDownload(GeneralConfigItem config, string outputDirectory)
        {
            if (!Directory.Exists(outputDirectory))
            {
                Directory.CreateDirectory(outputDirectory);
            }

            var mailsync = new MailSync(config.Host, config.Port, config.Username, config.Password, config.MailBox, config.Assignments.Select(t => t.ConvertBack()).ToList());

            config.Assignments.ToList().ForEach(a =>
            {
                Directory.CreateDirectory(Path.Combine(outputDirectory, a.Name));
                mailsync.Download(a.ConvertBack(), Path.Combine(outputDirectory, a.Name));
            });
        }