Ejemplo n.º 1
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;
        }
Ejemplo 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;
        }
Ejemplo n.º 3
0
        public SigmaResultTypeDTO SaveCrewAttendance_Rpt(int dailybrassId, string sigmauserId)
        {
            SigmaResultTypeDTO result = new SigmaResultTypeDTO();

            DataSet ds = GetCrewAttendance_Rpt(dailybrassId);
            int projectId = 0;
            List<rptDailyBrassInOutDTO> brassList = DTOHelper.DataTableToListDTO<rptDailyBrassInOutDTO>(ds, 0);
            List<rptCrewAttendanceHeader> headerList = DTOHelper.DataTableToListDTO<rptCrewAttendanceHeader>(ds, 1);

            if (brassList.Count > 0 && headerList.Count > 0)
            {
                projectId = headerList[0].ProjectId;
                List<ReportParameter> Params = new List<ReportParameter>();
                Params.Add(new ReportParameter("DailyBrassID", dailybrassId.ToString()));
                Params.Add(new ReportParameter("ProjectID", projectId.ToString()));
                //Params.Add(new ReportParameter("imgurl", @".\Resource\images\Logo.png"));

                LocalReport report = new LocalReport();
                report.ReportPath = @"..\Element.Sigma.Web.Biz\TrueTask\Resource\rdl\RPTCrewAttendance.rdl";
                report.EnableExternalImages = true;
                report.SetParameters(Params);
                report.DataSources.Clear();
                report.DataSources.Add(new ReportDataSource("dsDailyBrassSign", brassList));
                report.DataSources.Add(new ReportDataSource("dsHeader", headerList));

                byte[] bytes = report.Render("Image");
                string fileName = headerList[0].ForemanId + '_' + dailybrassId.ToString();

                #region Upload Report File & Save File Info

                string fileType = Element.Reveal.DataLibrary.Utilities.FileType.CREW_ATTENDANCE;
                int dailyBrassReportId = 0;
                int fileStoreId = 0;
                string fileExtension = "jpg";

                //Check existence
                List<ComboBoxDTO> exists = GetDailybrassreportByDailybrassFiletype_Combo(dailybrassId, fileType);
                if (exists != null && exists.Count > 0)
                {
                    dailyBrassReportId = exists[0].DataID;
                    int.TryParse(exists[0].ExtraValue3, out fileStoreId);
                    fileName = exists[0].DataName;
                    fileExtension = exists[0].ExtraValue4;
                }

                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 = sigmauserId;
                fileStore.UpdatedBy = sigmauserId;
                fileStore.FileStoreId = fileStoreId;
                fileStore.ProjectId = projectId;
                fileStoreList.Add(fileStore);
                upFileCollection.fileStoreDTOList = fileStoreList;

                UploadedFileInfoDTO uploadFile = new UploadedFileInfoDTO();
                uploadFile.Name = fileName;
                uploadFile.Size = bytes.Length;
                uploadFile.FileExtension = fileExtension;
                uploadFile.UploadedBy = sigmauserId;
                uploadFile.UploadedDate = DateTime.Now;
                uploadFile.CreatedBy = sigmauserId;
                uploadFile.UpdatedBy = sigmauserId;
                uploadFile.byteFile = bytes;
                uploadFile.UploadedFileInfoId = 0;
                uploadFile.FileStoreId = fileStoreId;
                uploadFileList.Add(uploadFile);
                upFileCollection.uploadedFileDTOList = uploadFileList;

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

                #endregion

                #region Save Report Document Info

                List<DailybrassreportDTO> reportDTOList = new List<DailybrassreportDTO>();

                DailybrassreportDTO reportDTO = new DailybrassreportDTO();
                reportDTO.DailyBrassReportId = dailyBrassReportId;
                reportDTO.DailyBrassId = dailybrassId;
                reportDTO.UploadedFileInfoId = upFileCollection.uploadedFileDTOList[0].UploadedFileInfoId;
                reportDTO.UpdatedBy = sigmauserId;
                reportDTO.DTOStatus = (int)RowStatusNo.New;
                reportDTOList.Add(reportDTO);

                reportDTOList = SaveDailyBrassReport(reportDTOList);

                #endregion

                result.IsSuccessful = true;
            }
            else
            {
                result.AffectedRow = -1;
                result.ErrorCode = "";
                result.ErrorMessage = "no data";
                result.IsSuccessful = false;
            }

            return result;
        }