public void Run() { try { int imageCount = 0; _userInterface.WriteMessage("Le rangement des fichiers commence."); foreach (var sourcePath in _photoSource.GetFilePaths()) { var imageDateTime = _photoSource.GetPhotoDateTimeFromPath(sourcePath); var imageFileName = _photoSource.GetPhotoFileNameFromPath(sourcePath); var targetPath = _fileMover.ComputeDestinationPath(sourcePath, imageDateTime, imageFileName); _fileMover.MoveFile(sourcePath, targetPath); imageCount++;; } _userInterface.WriteMessage(String.Format("Le rangement de {0} fichier(s) est terminé.", imageCount)); } catch (Exception e) { _userInterface.WriteError("Une erreur s'est produite pendant le traitement :"); _userInterface.WriteError(e.Message); _userInterface.WriteError(e.StackTrace); } }
/// <summary> /// Load the XML data from file to Message Queue. /// </summary> /// <param name="strPath"></param> public void LoadUSRDetailsFromXML(string strPath) { using (loggingHelper.RMTraceManager.StartTrace("Service.LoadUSRDetailsFromXML")) { List <AddressLocationUSRDTO> lstUSRFiles = null; List <AddressLocationUSRDTO> lstUSRInsertFiles = null; string methodName = MethodBase.GetCurrentMethod().Name; LogMethodInfoBlock(methodName, LoggerTraceConstants.MethodExecutionStarted, LoggerTraceConstants.COLON); loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ThirdPartyPriority, LoggerTraceConstants.ThirdPartyLoaderMethodEntryEventId, LoggerTraceConstants.Title); if (CheckFileName(new FileInfo(strPath).Name)) { if (IsFileValid(strPath)) { lstUSRFiles = GetValidRecords(strPath); lstUSRInsertFiles = lstUSRFiles.Where(insertFiles => insertFiles.ChangeType == ThirdPartyLoaderConstants.INSERT || insertFiles.ChangeType == ThirdPartyLoaderConstants.DELETE || insertFiles.ChangeType == ThirdPartyLoaderConstants.UPDATE).ToList(); lstUSRInsertFiles.ForEach(addressLocation => { //Message is created and the Postal Address DTO is passed as the object to be queued along with the queue name and queue path where the object //needs to be queued. IMessage USRMsg = msgBroker.CreateMessage(addressLocation, ThirdPartyLoaderConstants.QUEUETHIRDPARTY, ThirdPartyLoaderConstants.QUEUEPATH); //The messge object created in the above code is then pushed onto the queue. This internally uses the MSMQ Send function to push the message //to the queue. msgBroker.SendMessage(USRMsg); }); fileMover.MoveFile(new string[] { strPath }, new string[] { processed, AppendTimeStamp(new FileInfo(strPath).Name) }); } else { loggingHelper.Log(string.Format(ThirdPartyLoaderConstants.LOGMESSAGEFORUSRDATAVALIDATION, new FileInfo(strPath).Name, DateTime.UtcNow.ToString()), TraceEventType.Information, null); fileMover.MoveFile(new string[] { strPath }, new string[] { error, AppendTimeStamp(new FileInfo(strPath).Name) }); } } LogMethodInfoBlock(methodName, LoggerTraceConstants.MethodExecutionCompleted, LoggerTraceConstants.COLON); loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.ThirdPartyPriority, LoggerTraceConstants.ThirdPartyLoaderMethodExitEventId, LoggerTraceConstants.Title); } }