/// <summary> /// Update or Create document /// </summary> /// <param name="documentSaveRequest"></param> /// <returns></returns> public static DocumentSaveResponse DocumentSave(DocumentSaveRequest documentSaveRequest) { var repDocSaveResp = RepDocument.Save( documentSaveRequest.headerInfo, documentSaveRequest.inDocument, documentSaveRequest.saveType); var documentSaveResponse = new DocumentSaveResponse(); documentSaveResponse.document = documentSaveRequest.inDocument; documentSaveResponse.document.UID = repDocSaveResp; if (repDocSaveResp == 0) { documentSaveResponse.response = new ResponseStatus(MessageType.Error); documentSaveResponse.response.Message = "Error Saving Document."; documentSaveResponse.response.Successful = false; documentSaveResponse.response.ReturnCode = -0010; } else { documentSaveResponse.response = new ResponseStatus(MessageType.Informational); } return(documentSaveResponse); }
// --------------------------------------- // Save sequence number and parent // --------------------------------------- private void SaveSequenceParent(HeaderInfo headerInfo, Document document) { // document.Save(headerInfo, FCMConstant.SaveType.UPDATE); //RepDocument.Save(headerInfo, document, FCMConstant.SaveType.UPDATE); var documentSaveRequest = new DocumentSaveRequest(); documentSaveRequest.inDocument = document; documentSaveRequest.headerInfo = HeaderInfo.Instance; documentSaveRequest.saveType = FCMConstant.SaveType.UPDATE; var resp = BUSDocument.DocumentSave(documentSaveRequest); document.UID = resp.document.UID; }
private void fixDocumentLocation(TreeNode tn) { if (tn.Tag == null) { return; } Document document = (Document)tn.Tag; if (document.RecordType == "FOLDER") { foreach (TreeNode node in tn.Nodes) { fixDocumentLocation(node); } } var drr = new DocumentReadRequest(); drr.UID = document.UID; var docread = BUSDocument.DocumentRead(drr); var documentSaveRequest = new DocumentSaveRequest(); documentSaveRequest.inDocument = docread.document; documentSaveRequest.inDocument.Name = UIHelper.ClientDocumentUIHelper.SetDocumentName( documentSaveRequest.inDocument.SimpleFileName, documentSaveRequest.inDocument.IssueNumber.ToString(), documentSaveRequest.inDocument.CUID, documentSaveRequest.inDocument.RecordType, documentSaveRequest.inDocument.FileName); documentSaveRequest.headerInfo = HeaderInfo.Instance; documentSaveRequest.saveType = FCMConstant.SaveType.UPDATE; var resp = BUSDocument.DocumentSave(documentSaveRequest); tn.Tag = resp.document; }
private void btnFixLocation_Click(object sender, EventArgs e) { int documentUID = Convert.ToInt32(txtUID.Text); var drr = new DocumentReadRequest(); drr.UID = documentUID; var docread = BUSDocument.DocumentRead(drr); if (docread.document.RecordType == "FOLDER") { return; } var documentSaveRequest = new DocumentSaveRequest(); documentSaveRequest.inDocument = docread.document; documentSaveRequest.inDocument.Name = UIHelper.ClientDocumentUIHelper.SetDocumentName( documentSaveRequest.inDocument.SimpleFileName, documentSaveRequest.inDocument.IssueNumber.ToString(), documentSaveRequest.inDocument.CUID, documentSaveRequest.inDocument.RecordType, documentSaveRequest.inDocument.FileName); documentSaveRequest.headerInfo = HeaderInfo.Instance; documentSaveRequest.saveType = FCMConstant.SaveType.UPDATE; var resp = BUSDocument.DocumentSave(documentSaveRequest); txtLocation.Text = resp.document.Location; txtName.Text = resp.document.Name; TreeNode tndocSelected = tvFileList.SelectedNode; if (tndocSelected != null) { if (tndocSelected.Tag.GetType().Name == "Document") { tndocSelected.Tag = resp.document; } } }
private void btnSave_Click(object sender, EventArgs e) { //Document docSave = new Document(); if (string.IsNullOrEmpty(cbxSourceCode.Text)) { MessageBox.Show("Source code must be set."); return; } if (string.IsNullOrEmpty(cbxDocumentType.Text)) { MessageBox.Show("Document Type must be set."); return; } if (string.IsNullOrEmpty(txtUID.Text)) { docSave.UID = 0; } else { docSave.UID = Convert.ToInt32(txtUID.Text); } if (checkProjectPlan.Checked) { docSave.IsProjectPlan = "N"; } else { docSave.IsProjectPlan = "N"; } docSave.CUID = txtCUID.Text; docSave.Comments = txtComments.Text; docSave.Location = txtLocation.Text; docSave.Status = "ACTIVE"; if (string.IsNullOrEmpty(txtIssueNumber.Text)) { docSave.IssueNumber = 0; } else { docSave.IssueNumber = Convert.ToInt32(txtIssueNumber.Text); } docSave.Name = txtName.Text; docSave.DisplayName = txtDisplayName.Text; docSave.RecordType = cbxRecordType.Text; docSave.SimpleFileName = txtSimpleFileName.Text; if (cbxRecordType.Text == FCMConstant.RecordType.FOLDER) { cbxDocumentType.Text = MackkadoITFramework.Helper.Utils.DocumentType.FOLDER; } docSave.DocumentType = cbxDocumentType.Text; if (string.IsNullOrEmpty(cbxRecordType.Text)) { MessageBox.Show("Record Type is mandatory."); return; } if (string.IsNullOrEmpty(cbxDocumentType.Text)) { MessageBox.Show("Document Type is mandatory."); return; } // Parent UID is sourced from document tree // if (string.IsNullOrEmpty(txtParentUID.Text)) { docSave.ParentUID = 0; } else { docSave.ParentUID = Convert.ToInt32(txtParentUID.Text); } if (string.IsNullOrEmpty(txtSeqNum.Text)) { docSave.SequenceNumber = 0; } else { docSave.SequenceNumber = Convert.ToInt32(txtSeqNum.Text); } docSave.Comments = txtComments.Text; docSave.FileName = txtFileName.Text; docSave.FileExtension = MKITHelper.Utils.GetFileExtensionString(txtFileName.Text); docSave.SourceCode = cbxSourceCode.Text; if (string.IsNullOrEmpty(txtClientUID.Text)) { docSave.FKClientUID = 0; } else { docSave.FKClientUID = Convert.ToInt32(txtClientUID.Text); } if (docSave.SourceCode == "CLIENT" && docSave.FKClientUID == 0) { MessageBox.Show("Client ID is mandatory if source type is CLIENT"); return; } // docSave.Save(HeaderInfo.Instance, FCMConstant.SaveType.UPDATE); // RepDocument.Save(HeaderInfo.Instance, docSave, FCMConstant.SaveType.UPDATE); var documentSaveRequest = new DocumentSaveRequest(); documentSaveRequest.inDocument = docSave; documentSaveRequest.headerInfo = HeaderInfo.Instance; documentSaveRequest.saveType = FCMConstant.SaveType.UPDATE; var resp = BUSDocument.DocumentSave(documentSaveRequest); docSave.UID = resp.document.UID; if (uidl != null) { uidl.Refresh(); } txtLocation.Text = resp.document.Location; MessageBox.Show(resp.response.Message); txtCUID.Enabled = false; txtCUID.ReadOnly = true; //txtDirectory.Focus(); documentSavedSuccessfully = true; if (treeNode == null) { // There is no need to set the treenode unless it is passed in. } else { treeNode.Tag = docSave; treeNode.Name = docSave.FileName; } }
/// <summary> /// Update or Create document /// </summary> /// <returns></returns> public static Document DocumentCreate(HeaderInfo headerInfo, string filename, string filelocation, int parentUID, string recordtype = "DOCUMENT") { string documenttype = "WORD"; // Just setting as initial value Document document = new Document(); document.ParentUID = parentUID; document.CUID = filename.Substring(0, 6); document.Location = filelocation; document.Location = Utils.getReferenceFilePathName(filelocation); document.DisplayName = filename.Substring(10); // Starts after HRM-01-01 HERExxxxxxxx document.SimpleFileName = filename.Substring(10); // Starts after HRM-01-01 HERExxxxxxxx document.Name = filename; var filesplit = filename.Split('.'); document.FileExtension = String.Concat("." + filesplit[1]); document.FileName = filename; document.RecordType = recordtype; string wordExtensions = ".doc .docx .dotx"; string excelExtensions = ".xls .xlsx"; string pdfExtensions = ".pdf"; // Not every extension will be loaded // if (wordExtensions.Contains(document.FileExtension)) { documenttype = "WORD"; } if (excelExtensions.Contains(document.FileExtension)) { documenttype = "EXCEL"; } if (pdfExtensions.Contains(document.FileExtension)) { documenttype = "PDF"; } document.DocumentType = documenttype; document.SequenceNumber = 1; document.IssueNumber = 1; document.SourceCode = "FCM"; document.Status = "ACTIVE"; document.Skip = "N"; document.IsVoid = "N"; document.IsProjectPlan = "N"; document.FKClientUID = 0; document.Comments = "Web Upload"; var documentSaveRequest = new DocumentSaveRequest(); documentSaveRequest.inDocument = document; documentSaveRequest.headerInfo = headerInfo; var docresp = BUSDocument.DocumentSave(documentSaveRequest); if (docresp.response.ReturnCode <= 0) { LogFile.WriteToTodaysLogFile(docresp.response.Message); } document = docresp.document; return(document); }