private void FileTransferToNewDocument(object currentObject) { Document currentDocument; MezzoObject.moDocumentProperties currentDocProperties = new MezzoObject.moDocumentProperties(); FileInfo localFile; try { // Get localFile localFile = FileGetFromObject(currentObject); // Static document creation currentDocProperties = CurrentConfig.OutputDocAttributes; Utils.MaMessage(String.Format(tsl.T("[NEWDOCCREATING]"), DateTime.Now.ToString(TimeFormat), CurrentConfig.OutputDocAttributes.DocTypeCode), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile); // Process attributes for file properties currentDocProperties = AttributesListProcess(currentDocProperties, localFile); // Create Document from Config File Info currentDocument = myMezzoObject.DocumentCreate(currentDocProperties); // If current document is not null if (currentDocument != null) { // Transfer file Utils.MaMessage(String.Format(tsl.T("[NEWDOCCREATED]"), DateTime.Now.ToString(TimeFormat), currentDocument.Code), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile); FileTransferToFolder(localFile, currentDocument.Id); // If we are supposed to sign the document if (currentDocProperties.SignDocument) { //Check if not locked, unlock if so if (currentDocument.LockedAuthor != "") myMezzoObject.DocumentUnlock(currentDocument.Id); //Sign document if (myMezzoObject.DocumentSign(currentDocument.Id) == ExecStatus.Continue) Utils.MaMessage(String.Format(tsl.T("[NEWDOCSIGNED]"), DateTime.Now.ToString(TimeFormat), currentDocument.Code), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile); else Utils.MaMessage(String.Format(tsl.T("[NEWDOCNOTSIGNED]"), DateTime.Now.ToString(TimeFormat), currentDocument.Code), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile); } } else { Utils.MaMessage(String.Format(tsl.T("[NEWDOCNOTCREATED]"), DateTime.Now.ToString(TimeFormat)), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile); } } catch (Exception e) { Utils.MaMessage(String.Format(tsl.T("[NEWDOCERROR]"), DateTime.Now.ToString(TimeFormat), e.Message), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile); } }
private void DynamicDocumentCreate(object currentObject) { Document currentDocument; MezzoObject.moDocumentProperties currentDocProperties = new MezzoObject.moDocumentProperties(); FileInfo xmlFileInfo; FileInfo localFile; try { xmlFileInfo = FileGetFromObject(currentObject); System.Xml.Serialization.XmlSerializer docPropertiesReader = new System.Xml.Serialization.XmlSerializer(currentDocProperties.GetType()); if (xmlFileInfo.Exists) { System.IO.StreamReader xmlFile = new System.IO.StreamReader(xmlFileInfo.FullName); currentDocProperties = (MezzoObject.moDocumentProperties)docPropertiesReader.Deserialize(xmlFile); xmlFile.Close(); } else throw new Exception(tsl.T("[NEWDOCNOTFOUND]") + xmlFileInfo.FullName); Utils.MaMessage(String.Format(tsl.T("[NEWDOCCREATING]"), DateTime.Now.ToString(TimeFormat), CurrentConfig.OutputDocAttributes.DocTypeCode), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile); // Create Document from Config File Info currentDocument = myMezzoObject.DocumentCreate(currentDocProperties); // If current document is not null if (currentDocument != null) { Utils.MaMessage(String.Format(tsl.T("[NEWDOCCREATED]"), DateTime.Now.ToString(TimeFormat), currentDocument.Code), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile); // Transfer files if any foreach (MezzoObject.moFile tmpMoFile in currentDocProperties.moFileList) { localFile = new FileInfo(tmpMoFile.PathName + "\\" + tmpMoFile.FileName); if (localFile != null) { FileTransferToFolder(localFile, currentDocument.Id); } } // If we are supposed to sign the document if (currentDocProperties.SignDocument) { //Check if not locked, unlock if so if (currentDocument.LockedAuthor != "") myMezzoObject.DocumentUnlock(currentDocument.Id); //Sign document if (myMezzoObject.DocumentSign(currentDocument.Id) == ExecStatus.Continue) Utils.MaMessage(String.Format(tsl.T("[NEWDOCSIGNED]"), DateTime.Now.ToString(TimeFormat), currentDocument.Code), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile); else Utils.MaMessage(String.Format(tsl.T("[NEWDOCNOTSIGNED]"), DateTime.Now.ToString(TimeFormat), currentDocument.Code), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile); } } else { Utils.MaMessage(String.Format(tsl.T("[NEWDOCNOTCREATED]"), DateTime.Now.ToString(TimeFormat)), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile); } } catch (Exception e) { Utils.MaMessage(String.Format(tsl.T("[NEWDOCERROR]"), DateTime.Now.ToString(TimeFormat), e.Message), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile); } }