Esempio n. 1
0
        public List<DocumentDTO> SaveDocumentWithOZformForAssembleIWP(List<FiwpDTO> fiwps, UpfileDTOS upFileCollection, string curStepCode, string userId)
        {
            //TransactionScope scope = null;
            //byte[] bytes = null;
            string fileType = string.Empty;

            //Check FileType
            switch (curStepCode)
            {
                case Element.Reveal.DataLibrary.Utilities.AssembleStep.SUMMARY:
                    fileType = Element.Reveal.DataLibrary.Utilities.FileType.SUMMARY;
                    break;
                case Element.Reveal.DataLibrary.Utilities.AssembleStep.SAFETY_CHECK:
                    fileType = Element.Reveal.DataLibrary.Utilities.FileType.SAFETY_CHECK;
                    break;
                case Element.Reveal.DataLibrary.Utilities.AssembleStep.SCAFFOLD_CHECK:
                    fileType = Element.Reveal.DataLibrary.Utilities.FileType.SCAFFOLD_CHECK;
                    break;
            }

            int iwpDocumentId = 0;
            int fileStoreId = 0;
            //string fileExtension = "jpg";
            string fileName = fiwps[0].FiwpName + "_" + fileType;

            //Get Default Info
            rptProjectCwaIwpDTO rptInfo = GetProjectCwaIwpByIwp(fiwps[0].FiwpID);

            //Check existence
            List<ComboBoxDTO> exists = GetIwpDocumentByIwpProjectFileType_Combo(fiwps[0].FiwpID, fiwps[0].ProjectID, fileType, "Y");
            if (exists != null && exists.Count > 0)
            {
                iwpDocumentId = exists[0].DataID;
                int.TryParse(exists[0].ExtraValue3, out fileStoreId);
                fileName = exists[0].DataName;
                //fileExtension = exists[0].ExtraValue4;
            }

            //using (scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            //{

            #region Upload Report File & Save File Info

            if (upFileCollection.fileStoreDTOList == null || upFileCollection.fileStoreDTOList.Count <= 0)
            {
                List<FileStoreDTO> fileStoreList = new List<FileStoreDTO>();
                //List<UploadedFileInfoDTO> uploadFileList = new List<UploadedFileInfoDTO>();

                FileStoreDTO fileStore = new FileStoreDTO();
                fileStore.FileTitle = fileName;
                fileStore.FileDescription = DateTime.Now.ToString();
                fileStore.FileCategory = Element.Reveal.DataLibrary.Utilities.FileCategory.REPORT;
                fileStore.FileTypeCode = fileType;
                fileStore.CreatedBy = string.IsNullOrEmpty(fiwps[0].UpdatedBy) ? userId : fiwps[0].UpdatedBy;
                fileStore.UpdatedBy = string.IsNullOrEmpty(fiwps[0].UpdatedBy) ? userId : fiwps[0].UpdatedBy;
                fileStore.FileStoreId = fileStoreId;
                fileStore.ProjectId = fiwps[0].ProjectID;

                fileStoreList.Add(fileStore);
                upFileCollection.fileStoreDTOList = fileStoreList;
            }
            //UploadedFileInfoDTO uploadFile = new UploadedFileInfoDTO();
            //uploadFile.Name = fileName;
            //uploadFile.Size = bytes.Length;
            //uploadFile.FileExtension = fileExtension;
            //uploadFile.UploadedBy = fiwps[0].UpdatedBy;
            //uploadFile.UploadedDate = DateTime.Now;
            //uploadFile.CreatedBy = fiwps[0].UpdatedBy;
            //uploadFile.UpdatedBy = fiwps[0].UpdatedBy;
            ////uploadFile.byteFile = bytes;
            //uploadFile.UploadedFileInfoId = 0;
            //uploadFile.FileStoreId = fileStoreId;

            //uploadFileList.Add(uploadFile);
            //upFileCollection.uploadedFileDTOList = uploadFileList;

            upFileCollection = (new TrueTask.Common()).SaveMultiUploadFile(upFileCollection, userId, fileName);

            #endregion

            #region Save Report Document Info

            List<DocumentDTO> documents = new List<DocumentDTO>();
            #region "old code _ uploadedFileInfo"
            //foreach (UploadedFileInfoDTO uploadFile in upFileCollection.uploadedFileDTOList)
            //{
            //    DocumentDTO iwpDocument = new DocumentDTO();
            //    //iwpDocument.DocumentID = iwpDocumentId;
            //    iwpDocument.FIWPID = fiwps[0].FiwpID;
            //    iwpDocument.SPCollectionID = uploadFile.UploadedFileInfoId;
            //    iwpDocument.UpdatedBy = fiwps[0].UpdatedBy;

            //    if (uploadFile.FileExtension.ToLower() == "jpg")
            //        iwpDocument.IsDisplayable = "Y";
            //    else
            //        iwpDocument.IsDisplayable = "N";

            //    //if (iwpDocument.DocumentID > 0)
            //    //  iwpDocument.DTOStatus = (int)RowStatusNo.Update;
            //    //else
            //    iwpDocument.DTOStatus = (int)RowStatusNo.New;

            //    documents.Add(iwpDocument);
            //}
            #endregion

            DocumentDTO iwpDocument = new DocumentDTO();
            iwpDocument.DocumentID = iwpDocumentId;
            iwpDocument.FIWPID = fiwps[0].FiwpID;
            iwpDocument.FileStoreId = upFileCollection.uploadedFileDTOList[0].FileStoreId;
            iwpDocument.UpdatedBy = string.IsNullOrEmpty(fiwps[0].UpdatedBy) ? userId : fiwps[0].UpdatedBy;
            iwpDocument.IsDisplayable = "Y";
            if (iwpDocument.DocumentID > 0)
                iwpDocument.DTOStatus = (int)RowStatusNo.Update;
            else
            iwpDocument.DTOStatus = (int)RowStatusNo.New;

            documents.Add(iwpDocument);

            documents = SaveDocument(documents);

            #endregion

            //Update Assemble Step
            if (fiwps[0].DocEstablishedLUID != Element.Reveal.DataLibrary.Utilities.AssembleStep.APPROVER)
                fiwps = (new TrueTask.Build()).SaveIwp(fiwps);

            //    scope.Complete();
            //}

            return documents;
        }
Esempio n. 2
0
        /// <summary>
        /// SaveFiwpMaterialForAssembleIWP
        /// </summary>
        /// <param name="fiwpmaterials"></param>
        /// <param name="fiwps"></param>
        /// <param name="documents"></param>
        /// <returns></returns>
        public List<FiwpmaterialDTO> SaveFiwpMaterialForAssembleIWP(List<FiwpmaterialDTO> fiwpmaterials, List<FiwpDTO> fiwps, string userId)
        {
            //TransactionScope scope = null;
            byte[] bytes = null;
            string fileType = Element.Reveal.DataLibrary.Utilities.FileType.CONSUMABLE;

            int iwpDocumentId = 0;
            int fileStoreId = 0;
            string fileExtension = "jpg";
            string fileName = fiwps[0].FiwpName + "_" + fileType;

            //Get Default Info
            rptProjectCwaIwpDTO rptInfo = GetProjectCwaIwpByIwp(fiwps[0].FiwpID);

            //Check existence
            List<ComboBoxDTO> exists = GetIwpDocumentByIwpProjectFileType_Combo(fiwps[0].FiwpID, fiwps[0].ProjectID, fileType, "Y");
            if (exists != null && exists.Count > 0)
            {
                iwpDocumentId = exists[0].DataID;
                int.TryParse(exists[0].ExtraValue3, out fileStoreId);
                fileName = exists[0].DataName;
                fileExtension = exists[0].ExtraValue4;
            }

            //using (scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            //{

            //Save user manipulated data
            if (fiwpmaterials != null && fiwpmaterials.Count > 0)
                fiwpmaterials = SaveFiwpMaterial(fiwpmaterials);
            //Get Latest Data
            fiwpmaterials = (new TrueTask.Build()).GetFiwpMaterialByFIWP(fiwps[0].FiwpID, fiwps[0].ProjectID, "");
            //Generate Report
            bytes = GenerateReportForMaterial(fiwpmaterials, rptInfo);

            #region Upload Report File & Save File Info

            UpfileDTOS upFileCollection = new UpfileDTOS();
            List<FileStoreDTO> fileStoreList = new List<FileStoreDTO>();
            List<UploadedFileInfoDTO> uploadFileList = new List<UploadedFileInfoDTO>();

            FileStoreDTO fileStore = new FileStoreDTO();
            fileStore.FileTitle = fileName;
            fileStore.FileDescription = DateTime.Now.ToString();
            fileStore.FileCategory = Element.Reveal.DataLibrary.Utilities.FileCategory.REPORT;
            fileStore.FileTypeCode = fileType;
            fileStore.CreatedBy = string.IsNullOrEmpty(fiwps[0].UpdatedBy) ? userId : fiwps[0].UpdatedBy;
            fileStore.UpdatedBy = string.IsNullOrEmpty(fiwps[0].UpdatedBy) ? userId : fiwps[0].UpdatedBy;
            fileStore.FileStoreId = fileStoreId;
            fileStore.ProjectId = fiwps[0].ProjectID;

            fileStoreList.Add(fileStore);
            upFileCollection.fileStoreDTOList = fileStoreList;

            UploadedFileInfoDTO uploadFile = new UploadedFileInfoDTO();
            uploadFile.Name = fileName;
            uploadFile.Size = bytes.Length;
            uploadFile.FileExtension = fileExtension;
            uploadFile.UploadedBy = string.IsNullOrEmpty(fiwps[0].UpdatedBy) ? userId : fiwps[0].UpdatedBy;
            uploadFile.UploadedDate = DateTime.Now;
            uploadFile.CreatedBy = string.IsNullOrEmpty(fiwps[0].UpdatedBy) ? userId : fiwps[0].UpdatedBy;
            uploadFile.UpdatedBy = string.IsNullOrEmpty(fiwps[0].UpdatedBy) ? userId : fiwps[0].UpdatedBy;
            uploadFile.byteFile = bytes;
            uploadFile.UploadedFileInfoId = 0;
            uploadFile.FileStoreId = fileStoreId;

            uploadFileList.Add(uploadFile);
            upFileCollection.uploadedFileDTOList = uploadFileList;

            upFileCollection = (new TrueTask.Common()).SaveSingleUploadFile(upFileCollection, userId);

            #endregion

            #region Save Report Document Info

            List<DocumentDTO> documents = new List<DocumentDTO>();

            DocumentDTO iwpDocument = new DocumentDTO();
            iwpDocument.DocumentID = iwpDocumentId;
            iwpDocument.FIWPID = fiwps[0].FiwpID;
            //iwpDocument.SPCollectionID = upFileCollection.uploadedFileDTOList[0].UploadedFileInfoId;
            iwpDocument.FileStoreId = upFileCollection.uploadedFileDTOList[0].FileStoreId;
            iwpDocument.UpdatedBy = string.IsNullOrEmpty(fiwps[0].UpdatedBy) ? userId : fiwps[0].UpdatedBy;
            iwpDocument.IsDisplayable = "Y";
            if (iwpDocument.DocumentID > 0)
                iwpDocument.DTOStatus = (int)RowStatusNo.Update;
            else
                iwpDocument.DTOStatus = (int)RowStatusNo.New;

            documents.Add(iwpDocument);

            documents = SaveDocument(documents);

            #endregion

            //Update Assemble Step
            if (fiwps[0].DocEstablishedLUID != Element.Reveal.DataLibrary.Utilities.AssembleStep.APPROVER)
                fiwps = (new TrueTask.Build()).SaveIwp(fiwps);

            //    scope.Complete();
            //}

            return fiwpmaterials;
        }
Esempio n. 3
0
        /// <summary>
        /// SaveDocumentForAssembleIWP
        /// </summary>
        /// <param name="documents"></param>
        /// <param name="fiwps"></param>
        /// <returns></returns>
        public List<DocumentDTO> SaveDocumentForAssembleIWP(List<FiwpDTO> fiwps, List<DocumentDTO> documents, string curStepCode, string userId, string webPath)
        {
            //TransactionScope scope = null;
            byte[] bytes = null;
            string fileType = string.Empty;

            //Check FileType
            switch (curStepCode)
            {
                case Element.Reveal.DataLibrary.Utilities.AssembleStep.COVER:
                    fileType = Element.Reveal.DataLibrary.Utilities.FileType.COVER;
                    break;
                case Element.Reveal.DataLibrary.Utilities.AssembleStep.SAFETY_FORM:
                    fileType = Element.Reveal.DataLibrary.Utilities.FileType.SAFETY_FORM;
                    break;
                case Element.Reveal.DataLibrary.Utilities.AssembleStep.ITR:
                    fileType = Element.Reveal.DataLibrary.Utilities.FileType.ITR;
                    break;
                case Element.Reveal.DataLibrary.Utilities.AssembleStep.SPEC:
                    fileType = Element.Reveal.DataLibrary.Utilities.FileType.SPEC;
                    break;
                case Element.Reveal.DataLibrary.Utilities.AssembleStep.MOC:
                    fileType = Element.Reveal.DataLibrary.Utilities.FileType.MOC;
                    break;
            }

            int iwpDocumentId = 0;
            int fileStoreId = 0;
            string fileExtension = "jpg";
            string fileName = fiwps[0].FiwpName + "_" + fileType;
            string coverImageUrl = string.Empty;

            //Get Default Info
            rptProjectCwaIwpDTO rptInfo = GetProjectCwaIwpByIwp(fiwps[0].FiwpID);

            //Check existence
            List<ComboBoxDTO> exists = GetIwpDocumentByIwpProjectFileType_Combo(fiwps[0].FiwpID, fiwps[0].ProjectID, fileType, "Y");
            if (exists != null && exists.Count > 0)
            {
                iwpDocumentId = exists[0].DataID;
                int.TryParse(exists[0].ExtraValue3, out fileStoreId);
                fileName = exists[0].DataName;
                fileExtension = exists[0].ExtraValue4;
            }

            //using (scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            //{

            //Save user manipulated data
            if (documents != null && documents.Count > 0)
            {
                coverImageUrl = string.IsNullOrEmpty(documents[0].LocationURL) ? "" : HttpContext.Current.Server.MapPath(documents[0].LocationURL.Replace(webPath, ""));
                documents[0].IsDisplayable = "N";
                documents = SaveDocument(documents);
            }

            //Generate Report
            if (curStepCode == Element.Reveal.DataLibrary.Utilities.AssembleStep.COVER)
                bytes = GenerateReportForCover(coverImageUrl, rptInfo);
            else
            {
                string listTitle = "List";
                List<ComboBoxDTO> combos = GetIwpDocumentByIwpProjectFileType_Combo(fiwps[0].FiwpID, fiwps[0].ProjectID, fileType, "N");
                List<ComboCodeBoxDTO> type = (new TrueTask.Common()).GetSigmaCodeByCodeCategory_Code_Combo(null, fileType);
                if (type != null && type.Count > 0)
                    listTitle = type[0].DataName;

                bytes = GenerateReportForCombo(combos, rptInfo, listTitle);
            }

            #region Upload Report File & Save File Info

            UpfileDTOS upFileCollection = new UpfileDTOS();
            List<FileStoreDTO> fileStoreList = new List<FileStoreDTO>();
            List<UploadedFileInfoDTO> uploadFileList = new List<UploadedFileInfoDTO>();

            FileStoreDTO fileStore = new FileStoreDTO();
            fileStore.FileTitle = fileName;
            fileStore.FileDescription = DateTime.Now.ToString();
            fileStore.FileCategory = Element.Reveal.DataLibrary.Utilities.FileCategory.REPORT;
            fileStore.FileTypeCode = fileType;
            fileStore.CreatedBy = string.IsNullOrEmpty(fiwps[0].UpdatedBy) ? userId : fiwps[0].UpdatedBy;
            fileStore.UpdatedBy = string.IsNullOrEmpty(fiwps[0].UpdatedBy) ? userId : fiwps[0].UpdatedBy;
            fileStore.FileStoreId = fileStoreId;
            fileStore.ProjectId = fiwps[0].ProjectID;

            fileStoreList.Add(fileStore);
            upFileCollection.fileStoreDTOList = fileStoreList;

            UploadedFileInfoDTO uploadFile = new UploadedFileInfoDTO();
            uploadFile.Name = fileName;
            uploadFile.Size = bytes.Length;
            uploadFile.FileExtension = fileExtension;
            uploadFile.UploadedBy = string.IsNullOrEmpty(fiwps[0].UpdatedBy) ? userId : fiwps[0].UpdatedBy;
            uploadFile.UploadedDate = DateTime.Now;
            uploadFile.CreatedBy = string.IsNullOrEmpty(fiwps[0].UpdatedBy) ? userId : fiwps[0].UpdatedBy;
            uploadFile.UpdatedBy = string.IsNullOrEmpty(fiwps[0].UpdatedBy) ? userId : fiwps[0].UpdatedBy;
            uploadFile.byteFile = bytes;
            uploadFile.UploadedFileInfoId = 0;
            uploadFile.FileStoreId = fileStoreId;

            uploadFileList.Add(uploadFile);
            upFileCollection.uploadedFileDTOList = uploadFileList;

            upFileCollection = (new TrueTask.Common()).SaveSingleUploadFile(upFileCollection, userId);

            #endregion

            #region Save Report Document Info

            DocumentDTO iwpDocument = new DocumentDTO();
            iwpDocument.DocumentID = iwpDocumentId;
            iwpDocument.FIWPID = fiwps[0].FiwpID;
            //iwpDocument.SPCollectionID = upFileCollection.uploadedFileDTOList[0].UploadedFileInfoId;
            iwpDocument.FileStoreId = upFileCollection.uploadedFileDTOList[0].FileStoreId;
            iwpDocument.UpdatedBy = string.IsNullOrEmpty(fiwps[0].UpdatedBy) ? userId : fiwps[0].UpdatedBy;
            iwpDocument.IsDisplayable = "Y";
            if (iwpDocument.DocumentID > 0)
                iwpDocument.DTOStatus = (int)RowStatusNo.Update;
            else
                iwpDocument.DTOStatus = (int)RowStatusNo.New;

            documents.Clear();
            documents.Add(iwpDocument);

            documents = SaveDocument(documents);

            #endregion

            //Update Assemble Step
            if (fiwps[0].DocEstablishedLUID != Element.Reveal.DataLibrary.Utilities.AssembleStep.APPROVER)
                fiwps = (new TrueTask.Build()).SaveIwp(fiwps);

            //    scope.Complete();
            //}

            return documents;
        }