Ejemplo n.º 1
0
        private void Downloaded(DownloadedFile_v2 <DownloadPostKey_v1> downloadedFile)
        {
            string             message = GetDownloadStateText2(downloadedFile.State);
            IPostToDownload_v1 post    = LoadPost(downloadedFile.Key);
            //if (post != null)
            //    TracePost(post, message, null, null);
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(GetPostMessage(post, message));
            if (downloadedFile.DownloadedFiles != null)
            {
                foreach (string file in downloadedFile.DownloadedFiles)
                {
                    sb.AppendLine(string.Format("  file : \"{0}\"", file));
                }
            }
            if (downloadedFile.UncompressFiles != null)
            {
                foreach (string file in downloadedFile.UncompressFiles)
                {
                    sb.AppendLine(string.Format("  uncompress file : \"{0}\"", file));
                }
            }
            Trace.Write(sb.ToString());

            //MailAddLine(string.Format("{0} {1:dd-MM-yyyy HH:mm:ss}", message, DateTime.Now));
            MailAddLine(GetPostMessage(post, message, formated: false));
            if (downloadedFile.DownloadedFiles != null)
            {
                foreach (string file in downloadedFile.DownloadedFiles)
                {
                    MailAddLine(string.Format("  file : \"{0}\"", file));
                }
            }
            if (downloadedFile.UncompressFiles != null)
            {
                foreach (string file in downloadedFile.UncompressFiles)
                {
                    MailAddLine(string.Format("  uncompress file : \"{0}\"", file));
                }
            }
            //if (downloadedFile.State == DownloadState.DownloadCompleted)
            //{
            //    if (downloadedFile.UncompressFiles != null)
            //    {
            //        foreach (string uncompressFile in downloadedFile.UncompressFiles)
            //        {
            //            MailAddLine(string.Format("  {0}\r\n", zPath.GetFileName(uncompressFile)));
            //        }
            //    }
            //}
        }
Ejemplo n.º 2
0
        public static bool Save(MongoCollectionManager_v1 <DownloadPostKey_v1, DownloadedFile_v2 <DownloadPostKey_v1> > mongoDownloadedFileManager, DownloadedFile_v2 <DownloadPostKey_v1> downloadedFile)
        {
            bool saved = false;

            if (mongoDownloadedFileManager.Load(downloadedFile.Key) == null)
            {
                downloadedFile.Id = mongoDownloadedFileManager.GetNewId();
                mongoDownloadedFileManager.Save(downloadedFile.Id, downloadedFile);
                saved = true;
            }
            //Trace.WriteLine("{0} : key {1}, file \"{2}\"", saved ? "saved    " : "not saved", downloadedFile.Key, downloadedFile.UncompressFiles != null ? downloadedFile.UncompressFiles.FirstOrDefault() : "null");
            Trace.WriteLine("{0} : key {1}, file \"{2}\"", saved ? "saved    " : "not saved", downloadedFile.Key,
                            downloadedFile.DownloadItemLinks != null ? downloadedFile.DownloadItemLinks.FirstOrDefault().ServerLinks.FirstOrDefault().FilePartLinks.FirstOrDefault().DownloadedFile : "null");
            return(true);
        }