// This is only used by build artifact. This isn't a officially supported artifact type in RM
        public async Task DownloadArtifactAsync(IExecutionContext executionContext, IHostContext hostContext, ArtifactDefinition artifactDefinition, string dropLocation, string localFolderPath)
        {
            ArgUtil.NotNull(artifactDefinition, nameof(artifactDefinition));
            ArgUtil.NotNull(executionContext, nameof(executionContext));
            ArgUtil.NotNullOrEmpty(localFolderPath, nameof(localFolderPath));
            ArgUtil.NotNullOrEmpty(dropLocation, nameof(dropLocation));

            var trimChars = new[] { '\\', '/' };
            var relativePath = artifactDefinition.Details.RelativePath;

            // If user has specified a relative folder in the drop, change the drop location itself. 
            dropLocation = Path.Combine(dropLocation.TrimEnd(trimChars), relativePath.Trim(trimChars));

            var fileSystemManager = hostContext.CreateService<IReleaseFileSystemManager>();
            List<string> filePaths =
                new DirectoryInfo(dropLocation).EnumerateFiles("*", SearchOption.AllDirectories)
                    .Select(path => path.FullName)
                    .ToList();

            if (filePaths.Any())
            {
                foreach (var filePath in filePaths)
                {
                    var filePathRelativeToDrop = filePath.Replace(dropLocation, string.Empty).Trim(trimChars);
                    using (var fileReader = fileSystemManager.GetFileReader(filePath))
                    {
                        await fileSystemManager.WriteStreamToFile(fileReader.BaseStream, Path.Combine(localFolderPath, filePathRelativeToDrop));
                    }
                }
            }
            else
            {
                executionContext.Warning(StringUtil.Loc("RMNoArtifactsFound", relativePath));
            }
        }
        public async Task WritesAStreamAsync()
        {
            const string testoutputfilename = "test";
            string dir =  Config.GetDefaultDownloadDirectory();
            var files = new DirectoryInfo(dir).GetFiles().Where(n => n.Name == testoutputfilename + ".zip");
            var fileInfos = files as IList<FileInfo> ?? files.ToList();
            if (fileInfos.Any())
            {
                foreach (var file in fileInfos)
                {
                    File.Delete(file.FullName);
                }
            }
            FileInfo spyfile = new FileInfo(dir + @"\SPY_Companies.csv");

            AllDataDownloader dl = new AllDataDownloader(spyfile, null)
            {
                ZipOutput = true
            };
            await dl.WriteStreamAsync(DateTime.Now, "Test Data", dir, testoutputfilename);

            files = new DirectoryInfo(dir).GetFiles().Where(n => n.Name == testoutputfilename + ".zip");

            Assert.IsTrue(files.Any());
        }
Exemple #3
0
        private void Configure(WidgetDefinition widget)
        {
            var files = new DirectoryInfo(Server.MapPath(widget.VirtualPath)).GetFiles();

            var iconFile = files.FirstOrDefault(f => f.Name.IgnoreCaseStartsWith("icon."));
            if (iconFile != null)
            {
                widget.IconUrl = UrlUtil.Combine(widget.VirtualPath, iconFile.Name);
            }

            widget.Editable = files.Any(f => f.Name.IgnoreCaseEquals("Editor.aspx"));

            var configFile = files.FirstOrDefault(f => f.Name.IgnoreCaseEquals("config.config"));
            if (configFile != null)
            {
                ApplyXmlConfig(widget, XDocument.Load(configFile.FullName).Root);
            }

            if (widget.DisplayName == null)
            {
                widget.DisplayName = new LocalizableText(String.Format("{{ Plugin={0}, Key={1} }}", widget.Plugin.Name, widget.Name));
            }
        }
 protected void btnDownload_OnClick(object sender, EventArgs e)
 {
     ExportStatus(null);
     var files = new DirectoryInfo(Helper.SyncDataPath).GetFiles("*.xml");
     if (!files.Any())
     {
         DownloadStatus("No export files found for download.");
     }
     else
     {
         var xdocument = new XDocument(new XElement("uCommerceSync"));
         foreach (var fileInfo in files)
         {
             var root = XDocument.Load(fileInfo.FullName).Root;
             if (root == null)
             {
                 DownloadStatus("Export file " + fileInfo.Name + " is empty.");
                 return;
             }
             var xelement = new XElement("Entities", new XAttribute("file", fileInfo.Name), root);
             xdocument.Root.Add(xelement);
         }
         using (var memoryStream = new MemoryStream())
         {
             xdocument.Save(memoryStream, SaveOptions.None);
             var buffer = memoryStream.ToArray();
             Response.Clear();
             Response.AppendHeader("Content-Disposition",
                 "filename=uCommerceSync_" + DateTime.Now.ToString("yyyy_MM_dd_hh_mm") + ".xml");
             Response.AppendHeader("Content-Length", buffer.Length.ToString());
             Response.ContentType = "application/octet-stream";
             Response.BinaryWrite(buffer);
             Response.End();
         }
     }
     ;
 }
Exemple #5
0
        public void ParseEmlFiles(CancellationToken token)
        {

            var emails = new DirectoryInfo(Settings.WorkingDirectory).GetFiles();

            if (emails.Any())
            {

                if (Settings.ParserMaxBatchSize > 0 && emails.Count() > Settings.ParserMaxBatchSize)
                {
                    emails = emails.Take(Settings.ParserMaxBatchSize).ToArray();
                }

                foreach (var eml in emails)
                {
                    if (token.IsCancellationRequested)
                    {
                        break;
                    }
                    var yahooHeatData = new YahooHeatData() {IsFirst = true, ServerId = Settings.ServerID};
                    var archiveFolder = Path.Combine(Settings.ArchiveDirectory, DateTime.Now.ToString("yyyyMMdd"));

                    if (!Directory.Exists(archiveFolder))
                    {
                        log.Info("Creating archive folder: " + archiveFolder);
                        Directory.CreateDirectory(archiveFolder);
                    }

                    try
                    {
                        log.Info("Parsing email " + eml.FullName);

                        var emailMessage = new MailBuilder().CreateFromEmlFile(eml.FullName);

                        yahooHeatData.RawText = emailMessage.RenderEml(true);

                        yahooHeatData.HeatTime = DateTime.Parse(emailMessage.Document.Root.Headers["x-heat-time"]);
                        yahooHeatData.heat_ip = emailMessage.Document.Root.Headers["x-heat-ip"];

                        const string fromRegex = @"\""?(?<fromname>.+)""?\s+<(?<email>.+)>";
                        var match = Regex.Match(emailMessage.Document.Root.Headers["from"], fromRegex);
                        var fromAddress = new MailAddress(match.Groups["email"].ToString(),
                            match.Groups["fromname"].ToString());

                        // FROM
                        //TODO: Where do these go?
                        //yahooHeatData.from = emailMessage.Document.Root.Headers["from"].Replace("\"", string.Empty);
                        yahooHeatData.fromnamedisplay = fromAddress.DisplayName.Replace("\"", "");
                        //yahooHeatData.FromAddress = fromAddress.Address;
                        yahooHeatData.fromemailaddress_user = fromAddress.User;
                        yahooHeatData.fromemailaddress_host = fromAddress.Host;

                        // TO
                        yahooHeatData.toemailaddress = emailMessage.Document.Root.Headers["to"];

                        var recipient = new MailAddress(emailMessage.Document.Root.Headers["to"]);
                        string recipientDomain = recipient.Host;

                        // BULK/INBOX
                        if (recipientDomain == "yahoo.com" || recipientDomain == "ymail.com" ||
                            recipientDomain == "rocketmail.com" ||
                            recipientDomain == "yahoo.co.uk" || recipientDomain == "att.net")
                        {
                            yahooHeatData.foldername =
                                string.IsNullOrEmpty(emailMessage.Document.Root.Headers["x-yahoofilteredbulk"])
                                    ? "INBOX"
                                    : "BULK";
                        }
                        else if (recipientDomain == "aol.com")
                        {
                            yahooHeatData.foldername = emailMessage.Document.Root.Headers["x-heat-folder"].ToLower() ==
                                                       "inbox"
                                ? "INBOX"
                                : "BULK";
                        }

                        yahooHeatData.subject = emailMessage.Document.Root.Headers["subject"];

                        // SENT TIME
                        yahooHeatData.DateSent = DateTime.Parse(emailMessage.Document.Root.Headers["date"]);

                        var receivedRegex = string.Empty;

                        if (recipientDomain == "yahoo.com" || recipientDomain == "ymail.com" ||
                            recipientDomain == "rocketmail.com" ||
                            recipientDomain == "yahoo.co.uk" || recipientDomain == "att.net")
                        {
                            receivedRegex =
                                @"\(EHLO\s(?<ehlodomain>[a-zA-Z0-9\-\.]+)\)\s+\((?<ehloip>(?:[0-9]{1,3}.?){4})\)\s+by\s+(?<receivedmx>[a-zA-Z0-9\.\-]+)\s+with\s+SMTP;\s+(?<receiveddate>.+)";
                        }
                        else if (recipientDomain == "aol.com")
                        {
                            receivedRegex =
                                @"\((?<ehlodomain>[a-zA-Z0-9\-\.]+)\s+\[(?<ehloip>(?:[0-9]{1,3}\.?){4})\]\)\s+by\s+(?<receivedmx>[a-zA-Z0-9\.\-]+)\s.+;\s(?<receiveddate>.+)\s\(";
                        }

                        bool matched = false;

                        foreach (var headerValue in emailMessage.Document.Root.Headers.GetValues("received"))
                        {
                            match = Regex.Match(headerValue, receivedRegex,
                                RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);

                            if (match.Success)
                            {
                                yahooHeatData.ehlodomain = match.Groups["ehlodomain"].ToString(); // ehlo domain
                                yahooHeatData.ehloip = match.Groups["ehloip"].ToString(); // ehlo ip
                                yahooHeatData.receivedmx = match.Groups["receivedmx"].ToString(); // received mx
                                yahooHeatData.DateReceived = DateTime.Parse(match.Groups["receiveddate"].ToString());
                                matched = true;
                                break;
                            }

                        }

                        if (!matched)
                        {
                            throw new Exception("Failed to find EHLO info from \"received\" headers");
                        }

                        // SPF
                        string spfHeader = string.Empty;
                        string spfRegex = string.Empty;

                        if (recipientDomain == "yahoo.com" || recipientDomain == "ymail.com" ||
                            recipientDomain == "rocketmail.com"
                            || recipientDomain == "yahoo.co.uk" || recipientDomain == "att.net")
                        {
                            spfRegex = @"^(\w+)";
                            spfHeader = "received-spf";
                        }
                        else if (recipientDomain == "aol.com")
                        {
                            spfRegex = @"SPF : (\w+)";
                            spfHeader = "x-aol-spf";
                        }

                        if (!string.IsNullOrWhiteSpace(emailMessage.Document.Root.Headers[spfHeader]))
                        {
                            match = Regex.Match(emailMessage.Document.Root.Headers[spfHeader], spfRegex);
                            yahooHeatData.spfheader = match.Groups[1].ToString();
                        }

                        // DomainKey
                        string domainkeysHeader;
                        string domainkeysRegex;

                        if (recipientDomain == "yahoo.com" || recipientDomain == "ymail.com" ||
                            recipientDomain == "rocketmail.com"
                            || recipientDomain == "yahoo.co.uk" || recipientDomain == "att.net")
                        {
                            domainkeysHeader = "Authentication-Results";
                            domainkeysRegex = @"domainkeys=(\w+)";

                            match = Regex.Match(emailMessage.Document.Root.Headers[domainkeysHeader], domainkeysRegex);
                            yahooHeatData.domainkeysAuthenticationResults = match.Groups[1].ToString();
                        }

                        // DKIM
                        string dkimHeader = string.Empty;
                        string dkimRegex = string.Empty;

                        if (recipientDomain == "yahoo.com" || recipientDomain == "ymail.com" ||
                            recipientDomain == "rocketmail.com"
                            || recipientDomain == "yahoo.co.uk" || recipientDomain == "att.net")
                        {
                            dkimHeader = "Authentication-Results";
                            dkimRegex = @"dkim=(\w+)";
                        }
                        else if (recipientDomain == "aol.com")
                        {
                            dkimHeader = "x-aol-scoll-authentication";
                            dkimRegex = @"DKIM\s:\s(\w+)";
                        }

                        if (!string.IsNullOrWhiteSpace(emailMessage.Document.Root.Headers[dkimHeader]))
                        {
                            match = Regex.Match(emailMessage.Document.Root.Headers[dkimHeader], dkimRegex);
                            yahooHeatData.dkimAuthenticationResults = match.Groups[1].ToString();
                        }

                        // Recipient domain
                        yahooHeatData.recipientDomain = recipientDomain;

                        const string unsubscribeHeader = "list-unsubscribe";

                        // Base 26 Info
                        if (!string.IsNullOrWhiteSpace(emailMessage.Document.Root.Headers[unsubscribeHeader]))
                        {
                            // Batch-Subscriber-List Id
                            
                            IDictionary<string, int> base26Values;

                            MailingSystem mailingSystem = DetermineMailingSystemFromListUnsubscribe(emailMessage.Document.Root.Headers[unsubscribeHeader]);

                            switch (mailingSystem)
                            {
                                case MailingSystem.WhiteDelivery:
                                    base26Values = GetWdBase26Info(emailMessage.Document.Root.Headers[unsubscribeHeader]);
                                    yahooHeatData.BatchId = base26Values["batch_id"];
                                    yahooHeatData.SubscriberID = base26Values["subscriber_id"];
                                    yahooHeatData.ListID = base26Values["list_id"];
                                    break;
                                case MailingSystem.Avenlo:
                                    base26Values = GetAvenloBase26Info(emailMessage.Document.Root.Headers[unsubscribeHeader]);
                                    yahooHeatData.AvenloDeploymentId = base26Values["action_id"];
                                    yahooHeatData.AvenloRecipientId = base26Values["redirect_id"];
                                    break;
                            }
                        }

                        const string apperentlyToHeader = "x-apparently-to";

                        if (!string.IsNullOrWhiteSpace(emailMessage.Document.Root.Headers[apperentlyToHeader]))
                        {
                            const string apparentlyToRegex =
                                @"(?<apparentFromEmail>.+)\s+via\s+(?<apparentReceivedIp>.+);\s+(?<apparentReceivedDate>.+)";
                            match = Regex.Match(emailMessage.Document.Root.Headers[apperentlyToHeader],
                                apparentlyToRegex);

                            yahooHeatData.received_ip = match.Groups["apparentReceivedIp"].ToString();
                        }

                        if (!PublishMessage(yahooHeatData))
                        {
                            if (Settings.ParserBatchWaitTime < MinimumWaitSecondsOnQueueConnectionFailure)
                            {
                                System.Threading.Thread.Sleep(MinimumWaitSecondsOnQueueConnectionFailure -
                                                              Settings.ParserProcessingDelay);
                            }
                            return;
                        }

                        // archive file
                        string archiveFile = Path.Combine(archiveFolder, eml.Name);
                        eml.MoveTo(archiveFile);
                        log.Debug("Archived file: " + archiveFile);

                    }
                    catch (Exception ex)
                    {
                        log.Error("Failed to parse: " + eml.FullName);
                        log.Error(ex.ToString());
                        eml.MoveTo(Path.Combine(Settings.ErrorDirectory, eml.Name));
                        continue;
                    }
                    if (Settings.ParserProcessingDelay > 0)
                    {
                        System.Threading.Thread.Sleep(Settings.ParserProcessingDelay);
                    }
                }
            }
            else
            {
                log.Info("No emails to parse");
            }
        }
        public void DropBox_Drop(object sender, DragEventArgs e)
        {
            dropimage.Visibility = Visibility.Hidden;

            try
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    string[] DroppedFiles = (string[])e.Data.GetData(DataFormats.FileDrop);
                    string[] SupplierArray = SearchDirs.ToArray();


                    foreach (string filepath in DroppedFiles)
                    {
                        //Creating FileInfo object of path
                        FileInfo infoFile = new FileInfo(filepath);

                        string[] names = infoFile.Name.Split(new Char[] { '_', '.' });
                        string FileState;

                        if (names.Length != 5)
                        {
                            FileState = "Error";
                        }
                        else
                            switch (names[3])
                            {
                                case "C":
                                case "c":
                                    FileState = "Concept";
                                    break;
                                case "D":
                                case "d":
                                    FileState = "Design";
                                    break;
                                case "P":
                                case "p":
                                    FileState = "Pre-Released";
                                    break;
                                case "R":
                                case "r":
                                    FileState = "Released";
                                    break;
                                default:
                                    FileState = "Null";
                                    break;
                            }

                        //Creating viewer object to show info
                        ViewFile viewer = new ViewFile()
                        {
                            Extension = infoFile.Extension.ToUpper(),
                            FileSize = (infoFile.Length / 1024).ToString() + " kB",
                            PartNo = infoFile.Name.Substring(0, 7),
                            SourceLocation = filepath,
                            FileName = infoFile.Name,
                            SiteFound = false,
                            Supplier = "",
                            Version = names[1] + "." + names[2],
                            Status = FileState,
                            FolderName = ""

                        };

                        //Add the newFilename property
                        if (viewer.Extension == ".PDF")
                        {
                            viewer.NewFileName = viewer.NewFileName = $"{viewer.PartNo}D_{names[1]}_{names[2]}{viewer.Extension}";

                        }
                        else
                        {
                            viewer.NewFileName = viewer.NewFileName = $"{viewer.PartNo}_{names[1]}_{names[2]}{viewer.Extension}";
                        }

                        //Adding FileInfo object to Datagrid
                        _source.Add(viewer);

                        //Looping through every dropped file
                        string filename = viewer.PartNo;

                        //Looping through all suppliersites
                        foreach (string location in SupplierArray)
                        {
                            //Getting directories matching the filename
                            string POLib = location + @"\POLib\";
                            IEnumerable<DirectoryInfo> foundDirectories = new DirectoryInfo(POLib).EnumerateDirectories(filename);

                            bool haselements = foundDirectories.Any();
                            if (haselements)
                            {
                                if (viewer.SiteFound == false)
                                {
                                    viewer.CopySite = location;
                                    viewer.SiteFound = true;
                                    viewer.Supplier = location.Remove(0, 43);
                                    viewer.FolderName = (location + "\\POLib\\" + viewer.PartNo).Replace("\\", "/");
                                }
                                else
                                {
                                    _source.Add(new ViewFile
                                    {
                                        Extension = infoFile.Extension.ToUpper(),
                                        FileSize = (infoFile.Length / 1024).ToString() + " kB",
                                        PartNo = infoFile.Name.Substring(0, 7),
                                        SourceLocation = filepath,
                                        FileName = infoFile.Name,
                                        CopySite = location,
                                        SiteFound = true,
                                        Version = names[1] + "." + names[2],
                                        Status = FileState,
                                        Supplier = location.Remove(0, 43),
                                        FolderName = (location + "\\POLib\\" + viewer.PartNo).Replace("\\", "/"),
                                        NewFileName = $"{viewer.PartNo}_{names[1]}_{names[2]}{viewer.Extension}"
                                    });

                                }
                            }
                            if (viewer.Status == "Error")
                            {
                                viewer.SiteFound = false;
                            }
                        }
                    }

                    //StatusIndicator.Text = "STATUS: FILES ADDED";
                    ShowMessageBox("ADDED", "Files have been added. Check the files and remember to press the button to send them.");
                };
            }
            catch (IndexOutOfRangeException)
            {
                //StatusIndicator.Text = "STATUS: FILE NOT FORMATTED CORRECTLY";
                ShowMessageBox("ERROR", "One or more files are not formatted correctly.");
            }

        }
Exemple #7
0
        /// <summary>
        ///     Gets the previous data file.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        /// <exception cref="System.IO.FileNotFoundException">
        ///     Attempts to locate the newest file in the list of parsed data files
        ///     returned null.
        /// </exception>
        private static FileSystemInfo GetPreviousDataFile(string name)
        {
            Debug.Assert(!string.IsNullOrWhiteSpace(name), "The file name cannot be null or empty.");

            string searchPattern = string.Format("{0}*", name);
            IEnumerable<FileSystemInfo> fileInfo = new DirectoryInfo(DataPath).GetFileSystemInfos(searchPattern, SearchOption.TopDirectoryOnly);

            if (!fileInfo.Any())
            {
                return null;
            }

            // Get the newest file in the list
            FileSystemInfo newestFile = fileInfo.OrderByDescending(f => f.CreationTime).FirstOrDefault();

            if (newestFile == null)
            {
                throw new FileNotFoundException("Attempts to locate the newest file in the list of parsed data files returned null.");
            }

            return newestFile;
        }
 private void TrimOlgLogFiles(string archiveLogDir, int maxMegabytes)
 {
     var files = new DirectoryInfo(archiveLogDir).GetFiles();
     if (files.Any())
     {
         var totalSize = files.Sum(info => info.Length);
         if (totalSize > ((long)maxMegabytes) * 1024L * 1024L)
         {
             var fileToDelete = files.Single(file => file.CreationTime == files.Min(info => info.CreationTime));
             fileToDelete.Delete();
             TrimOlgLogFiles(archiveLogDir, maxMegabytes);
         }
     }
 }
            /// <summary>
            /// Determines if the given file exists in the given folder
            /// </summary>
            /// <returns></returns>
            protected bool FolderNotEmpty(string relFolderPath, string fileTypes = "*.*", Anomalies anomalies = null)
            {
                var dirPath = Path.Combine(this.TargetDir, relFolderPath);
                var exists = Directory.Exists(dirPath);
                if (!exists)
                {
                    if (anomalies != null)
                    {
                        anomalies.ExpectedFiles.Add(relFolderPath);
                    }

                    return false;
                }
                else
                {
                    var filesInFolder = new DirectoryInfo(dirPath).GetFiles(fileTypes);
                    if (!filesInFolder.Any())
                    {
                        if (anomalies != null)
                        {
                            anomalies.ExpectedFiles.Add(fileTypes);
                        }
                    }

                    return filesInFolder.Any();
                }
            }
Exemple #10
0
 public string GetFileName(TeaseMedia media)
 {
     if (media.Id.StartsWith("http://") || media.Id.StartsWith("https://"))
     {
         return media.Id;
     }
     if (FullMediaDirectoryPath.StartsWith("http://") || FullMediaDirectoryPath.StartsWith("https://"))
     {
         return FullMediaDirectoryPath + media.Id;
     }
     var matchingFiles = new DirectoryInfo(FullMediaDirectoryPath).GetFiles(media.Id);
     if (matchingFiles.Any())
     {
         return matchingFiles[random.Next(matchingFiles.Length)].FullName;
     }
     return null;
 }
 private void RenameAndSetImagesInDocument(LawSyncDocumentDetail lawDocument)
 {
     try
     {
         var lawDocumentId = lawDocument.DocumentControlNumber;
         var files =
             new DirectoryInfo(lawDocument.ImagesFolderPath).GetFiles(
                 string.Format("{0}{1}*", lawDocumentId,Constants.RedactItPagingNameFormat));
         if (!files.Any()) return;
         var convertedImages = new List<ConvertedImage>(); // hold the list of converted iamges. 
         foreach (var file in files)
         {
             if (String.IsNullOrEmpty(file.Name)) continue;
             var fileExtenstion = Path.GetExtension(file.Name);
             var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file.Name);
             var currentPage = fileNameWithoutExtension.Replace(lawDocumentId, "").Replace(Constants.RedactItPagingNameFormat, "");
             int pageNumber;
             if (!int.TryParse(currentPage,
                 out pageNumber))
             {
                 continue;
             }
             var imageStartingNumber = (lawDocument.ImageStartingNumber + 1) + pageNumber;
             var newFileName = string.Format("{0:D3}", imageStartingNumber) + fileExtenstion;
             var image = Path.Combine(lawDocument.ImagesFolderPath, newFileName);
             File.Move(file.FullName, image);
             var evImageRelativePath = image.Replace(_imageArchiveDirectory, string.Empty);
             evImageRelativePath = evImageRelativePath.StartsWith(@"\") ? evImageRelativePath.Remove(0, 1) : evImageRelativePath;
             convertedImages.Add(new ConvertedImage { PageNo = pageNumber, RelativePath = evImageRelativePath });
         }
         // DEVBug 169433: Page order mess up for LAW Sync reprocess. For example the first page in LAW is not the first page in EV NNV viewer,
         // e.g. the first page is 701.tif instead of 001.tif. 
         // To solve this, we need to sort the image by page Number
         var imagePaths = convertedImages.OrderBy(o => o.PageNo).Select(o => o.RelativePath).ToList();
         if (lawDocument.ProducedImages == null)
         {
             lawDocument.ProducedImages = new List<string>();
         }
         lawDocument.ProducedImages.AddRange( imagePaths );
     }
     catch (Exception ex)
     {
         //continue the image process with out rename images
         ex.Trace().Swallow();
         ReportToDirector(ex);
     }
 }