Exemplo n.º 1
0
        //ozd, jpg 함께 저장
        private async void Save()
        {
            Login.MasterPage.Loading(true, this);

            try
            {
                //로컬에 임시로 저장
                StorageFolder folder = ApplicationData.Current.TemporaryFolder;
                string fullPath = folder.Path + "\\";
                string paramJPG = "export.format=jpg;export.mode=silent;export.path=" + fullPath + ";export.filename=" + FileName + ".jpg;export.confirmsave=false";
                ozViewer.ScriptEx("save", paramJPG, ";");
                string paramPDF = "export.format=pdf;export.mode=silent;export.path=" + fullPath + ";export.filename=" + FileName + ".pdf;export.confirmsave=false";
                ozViewer.ScriptEx("save", paramPDF, ";");
                string paramOZD = "export.format=ozd;export.mode=silent;export.path=" + fullPath + ";export.filename=" + FileName + ".ozd;export.confirmsave=false";
                ozViewer.ScriptEx("save", paramOZD, ";");

                //업로드용 bytes
                StorageFile fileJPG = await StorageFile.GetFileFromPathAsync(fullPath + FileName + ".jpg");
                byte[] bytesJPG = await WinAppLibrary.Utilities.Helper.GetImageBytesFromStorageFile(fileJPG);
                StorageFile filePDF = await StorageFile.GetFileFromPathAsync(fullPath + FileName + ".pdf");
                byte[] bytesPDF = await WinAppLibrary.Utilities.Helper.GetImageBytesFromStorageFile(filePDF);
                StorageFile fileOZD = await StorageFile.GetFileFromPathAsync(fullPath + FileName + ".ozd");
                byte[] bytesOZD = await WinAppLibrary.Utilities.Helper.GetImageBytesFromStorageFile(fileOZD);

                //fiwpdto
                List<DataLibrary.FiwpDTO> fiwpdto = new List<DataLibrary.FiwpDTO>();

                if (Lib.IWPDataSource.iwplist == null)
                {
                    Login.MasterPage.Loading(false, this);
                    return;
                }
                fiwpdto = Lib.IWPDataSource.iwplist.Where(x => x.FiwpID == Lib.IWPDataSource.selectedIWP).ToList();

                fiwpdto[0].DTOStatus = (int)DataLibrary.Utilities.RowStatus.Update;

                //upFileCollectionDTO
                DataLibrary.UpfileDTOS upFileCollection = new DataLibrary.UpfileDTOS(); ;
                upFileCollection.fileStoreDTOList = new List<DataLibrary.FileStoreDTO>();
                upFileCollection.uploadedFileDTOList = new List<DataLibrary.UploadedFileInfoDTO>();

                #region fileStoreDTO
                DataLibrary.FileStoreDTO fileStoreDTOList = new DataLibrary.FileStoreDTO();

                if (_fileStoreID > 0)
                    fileStoreDTOList.DTOStatus = (int)DataLibrary.Utilities.RowStatus.Update;
                else
                    fileStoreDTOList.DTOStatus = (int)DataLibrary.Utilities.RowStatus.New;

                fileStoreDTOList.CreatedBy = Login.UserAccount.UserName;
                fileStoreDTOList.CreatedDate = DateTime.Now.ToString("dd-MM-yyyy");
                fileStoreDTOList.FileCategory = DataLibrary.Utilities.FileCategory.REPORT;
                fileStoreDTOList.FileDescription = Login.UserAccount.CurProjectID + " " + Login.UserAccount.FIWPID + " " + FileName;    //내용 확인 필요
                fileStoreDTOList.FileStoreId = _fileStoreID;
                fileStoreDTOList.FileTitle = FileName;
                fileStoreDTOList.FileTypeCode = FileType;
                fileStoreDTOList.ProjectId = Login.UserAccount.CurProjectID;
                fileStoreDTOList.UpdatedBy = Login.UserAccount.UserName;
                fileStoreDTOList.UpdatedDate = DateTime.Now.ToString("dd-MM-yyyy");

                upFileCollection.fileStoreDTOList.Add(fileStoreDTOList);
                #endregion

                #region uploadFileDTO

                DataLibrary.UploadedFileInfoDTO uploadedFileDTOList = new DataLibrary.UploadedFileInfoDTO();
                if (_fileStoreID > 0)
                    uploadedFileDTOList.DTOStatus = (int)DataLibrary.Utilities.RowStatus.Update;
                else
                    uploadedFileDTOList.DTOStatus = (int)DataLibrary.Utilities.RowStatus.New;
                uploadedFileDTOList.byteFile = bytesJPG;
                uploadedFileDTOList.FileExtension = "jpg";
                uploadedFileDTOList.Size = bytesJPG.Length;
                uploadedFileDTOList.CreatedBy = Login.UserAccount.UserName;
                uploadedFileDTOList.CreatedDate = DateTime.Now.ToString("dd-MM-yyyy");
                uploadedFileDTOList.FileStoreId = _fileStoreID;
                uploadedFileDTOList.Name = FileName;
                uploadedFileDTOList.Path = fullPath;
                uploadedFileDTOList.UpdatedBy = Login.UserAccount.UserName;
                uploadedFileDTOList.UpdatedDate = DateTime.Now.ToString("dd-MM-yyyy");
                uploadedFileDTOList.UploadedBy = Login.UserAccount.UserName;
                uploadedFileDTOList.UploadedDate = DateTime.Now;
                //uploadedFileDTOList.Revision
                //uploadedFileDTOList.UploadedFileInfoId

                upFileCollection.uploadedFileDTOList.Add(uploadedFileDTOList);

                DataLibrary.UploadedFileInfoDTO uploadedFileDTOList2 = new DataLibrary.UploadedFileInfoDTO();
                if (_fileStoreID > 0)
                    uploadedFileDTOList2.DTOStatus = (int)DataLibrary.Utilities.RowStatus.Update;
                else
                    uploadedFileDTOList2.DTOStatus = (int)DataLibrary.Utilities.RowStatus.New;
                uploadedFileDTOList2.byteFile = bytesPDF;
                uploadedFileDTOList2.CreatedBy = Login.UserAccount.UserName;
                uploadedFileDTOList2.CreatedDate = DateTime.Now.ToString("dd-MM-yyyy");
                uploadedFileDTOList2.FileExtension = "pdf";
                uploadedFileDTOList2.FileStoreId = _fileStoreID;
                uploadedFileDTOList2.Name = FileName;
                uploadedFileDTOList2.Path = fullPath;
                //uploadedFileDTOList2.Revision
                uploadedFileDTOList2.Size = bytesPDF.Length;
                uploadedFileDTOList2.UpdatedBy = Login.UserAccount.UserName;
                uploadedFileDTOList2.UpdatedDate = DateTime.Now.ToString("dd-MM-yyyy");
                uploadedFileDTOList2.UploadedBy = Login.UserAccount.UserName;
                uploadedFileDTOList2.UploadedDate = DateTime.Now;
                //uploadedFileDTOList2.UploadedFileInfoId

                upFileCollection.uploadedFileDTOList.Add(uploadedFileDTOList2);

                DataLibrary.UploadedFileInfoDTO uploadedFileDTOList3 = new DataLibrary.UploadedFileInfoDTO();
                if (_fileStoreID > 0)
                    uploadedFileDTOList3.DTOStatus = (int)DataLibrary.Utilities.RowStatus.Update;
                else
                    uploadedFileDTOList3.DTOStatus = (int)DataLibrary.Utilities.RowStatus.New;
                uploadedFileDTOList3.byteFile = bytesOZD;
                uploadedFileDTOList3.CreatedBy = Login.UserAccount.UserName;
                uploadedFileDTOList3.CreatedDate = DateTime.Now.ToString("dd-MM-yyyy");
                uploadedFileDTOList3.FileExtension = "ozd";
                uploadedFileDTOList3.FileStoreId = _fileStoreID;
                uploadedFileDTOList3.Name = FileName;
                uploadedFileDTOList3.Path = fullPath;
                //uploadedFileDTOList3.Revision
                uploadedFileDTOList3.Size = bytesOZD.Length;
                uploadedFileDTOList3.UpdatedBy = Login.UserAccount.UserName;
                uploadedFileDTOList3.UpdatedDate = DateTime.Now.ToString("dd-MM-yyyy");
                uploadedFileDTOList3.UploadedBy = Login.UserAccount.UserName;
                uploadedFileDTOList3.UploadedDate = DateTime.Now;
                //uploadedFileDTOList3.UploadedFileInfoId

                upFileCollection.uploadedFileDTOList.Add(uploadedFileDTOList3);
                #endregion


                //결과값 사용하지 않음
                await (new Lib.ServiceModel.ProjectModel()).SaveDocumentWithOZformForAssembleIWP(fiwpdto, upFileCollection, AssembleStep, Login.UserAccount.PersonnelId);

                //현재 단계 저장
                if (!fiwpdto[0].DocEstablishedLUID.Equals(DataLibrary.Utilities.AssembleStep.APPROVER))
                    fiwpdto[0].DocEstablishedLUID = AssembleStep;

                Lib.WizardDataSource.SetTargetMenu(AssembleStep, Lib.CommonDataSource.selPackageTypeLUID, true);


                //공통 파일 - AssembleDocument나 AssembleReport로 이동 시 파라미터 추가
                if (Lib.WizardDataSource.NextMenu != null)
                {
                    //IWPSummary -> SafetyChecklist
                    if (AssembleStep == DataLibrary.Utilities.AssembleStep.SUMMARY)
                        this.Frame.Navigate(Lib.WizardDataSource.NextMenu, DataLibrary.Utilities.AssembleStep.SAFETY_CHECK);
                    //SafetyChecklist -> Safety Formlist
                    else if(AssembleStep == DataLibrary.Utilities.AssembleStep.SAFETY_CHECK)
                        this.Frame.Navigate(Lib.WizardDataSource.NextMenu, DataLibrary.Utilities.AssembleStep.SAFETY_FORM);
                    //ScaffoldChecklist -> Specs & Details
                    else if(AssembleStep == DataLibrary.Utilities.AssembleStep.SCAFFOLD_CHECK)
                        this.Frame.Navigate(Lib.WizardDataSource.NextMenu, DataLibrary.Utilities.AssembleStep.SPEC);
                    else
                        this.Frame.Navigate(Lib.WizardDataSource.NextMenu);
                }
            }
            catch (Exception ex)
            {
                (new WinAppLibrary.Utilities.Helper()).ExceptionHandler(ex, "Save " + FileName, "There is a problem saving the " + FileName + " - Please try again later", "Error");
            }
            Login.MasterPage.Loading(false, this);
        }
Exemplo n.º 2
0
        private async void SaveDrawing()
        {
            try
            {
                var writableImage = await DrawingEditor.RenderDrawing();
                if (writableImage != null)
                {
                    using (Stream stream = await (new WinAppLibrary.Utilities.Helper()).GetJpegStreamFromWriteableBitmap(writableImage))
                    {
                        //if (DrawingEditor.EditMode == DrawingEditMode.RFI)
                        //{
                        //    using (Stream webdav = await (new WinAppLibrary.Utilities.Helper()).GetJpegStreamFromWriteableBitmap(writableImage))
                        //    {
                        //        await (new WinAppLibrary.Utilities.WebDavClient_Old(this.DrawingEditor.FileUrl, Login.UserAccount.WDUser, Login.UserAccount.WDPassword, "")).
                        //            UploadImageContent(DrawingEditor.FileUrl, webdav);

                        //        //await (new WinAppLibrary.Utilities.Helper()).SaveFileStream(Windows.Storage.ApplicationData.Current.LocalFolder, DrawingEditor.FileName, webdav);
                        //    }

                        //    await (new WinAppLibrary.Utilities.FileDocument()).SaveJpegContent(Login.UserAccount.SPURL + "/" + DataLibrary.Utilities.SPCollectionName.Drawing + "/", DrawingEditor.FileName, stream);
                        //}
                        var selected = gvViewType.SelectedIndex == 0 ? gvDrawing.SelectedItem as DataItem : FlipView.SelectedItem as DataItem;

                        if (selected != null)
                        {
                            int drawingId = Convert.ToInt32(selected.UniqueId);
                            var markup = await LoadMarkupDrawing(drawingId, null);
                            if (markup ==  null)
                            {
                                markup = new DataLibrary.DocumentmarkupDTO();
                                markup.DrawingID = drawingId;
                                markup.PersonnelID = Login.UserAccount.PersonnelId;
                                markup.UpdatedBy = Login.UserAccount.UserName;
                                markup.UpdatedDate = DateTime.Now;
                                markup.DTOStatus = (int)DataLibrary.Utilities.RowStatus.New;

                                _fileStoreID = 0;
                            }
                            else
                            {
                                _fileStoreID = markup.FileStoreId;
                                markup.DTOStatus = (int)DataLibrary.Utilities.RowStatus.Update;
                            }

                            //upFileCollectionDTO
                            DataLibrary.UpfileDTOS upFileCollection = new DataLibrary.UpfileDTOS(); ;
                            upFileCollection.fileStoreDTOList = new List<DataLibrary.FileStoreDTO>();
                            upFileCollection.uploadedFileDTOList = new List<DataLibrary.UploadedFileInfoDTO>();

                            #region fileStoreDTO
                            DataLibrary.FileStoreDTO fileStoreDTOList = new DataLibrary.FileStoreDTO();

                            if (_fileStoreID > 0)
                                fileStoreDTOList.DTOStatus = (int)DataLibrary.Utilities.RowStatus.Update;
                            else
                                fileStoreDTOList.DTOStatus = (int)DataLibrary.Utilities.RowStatus.New;
                            fileStoreDTOList.CreatedBy = Login.UserAccount.UserName;
                            fileStoreDTOList.CreatedDate = DateTime.Now.ToString("dd-MM-yyyy");
                            fileStoreDTOList.FileCategory = DataLibrary.Utilities.FileCategory.REPORT;
                            fileStoreDTOList.FileDescription = selected.Title + DataLibrary.Utilities.SPCollectionName.MarkupSuffix + Login.UserAccount.PersonnelId;
                            fileStoreDTOList.FileStoreId = _fileStoreID;
                            fileStoreDTOList.FileTypeCode = DataLibrary.Utilities.FileType.DRAWING_MARKUP;
                            fileStoreDTOList.ProjectId = Login.UserAccount.CurProjectID;
                            fileStoreDTOList.UpdatedBy = Login.UserAccount.UserName;
                            fileStoreDTOList.UpdatedDate = DateTime.Now.ToString("dd-MM-yyyy");

                            upFileCollection.fileStoreDTOList.Add(fileStoreDTOList);
                            #endregion

                            #region uploadFileDTO
                            DataLibrary.UploadedFileInfoDTO uploadedFileDTOList = new DataLibrary.UploadedFileInfoDTO();

                            if (_fileStoreID > 0)
                                uploadedFileDTOList.DTOStatus = (int)DataLibrary.Utilities.RowStatus.Update;
                            else
                                uploadedFileDTOList.DTOStatus = (int)DataLibrary.Utilities.RowStatus.New;

                            var wImage = await DrawingEditor.RenderDrawing();
                            var jStream = await (new WinAppLibrary.Utilities.Helper()).GetJpegStreamFromWriteableBitmap(wImage);

                            byte[] byteArray = new byte[jStream.Length];
                            jStream.Position = 0;
                            jStream.Read(byteArray, 0, (int)jStream.Length);

                            uploadedFileDTOList.byteFile = byteArray;
                            uploadedFileDTOList.FileExtension = "jpg";
                            uploadedFileDTOList.Size = byteArray.Length;
                            uploadedFileDTOList.CreatedBy = Login.UserAccount.UserName;
                            uploadedFileDTOList.CreatedDate = DateTime.Now.ToString("dd-MM-yyyy");
                            uploadedFileDTOList.FileStoreId = _fileStoreID;
                            uploadedFileDTOList.UpdatedBy = Login.UserAccount.UserName;
                            uploadedFileDTOList.UpdatedDate = DateTime.Now.ToString("dd-MM-yyyy");
                            uploadedFileDTOList.UploadedBy = Login.UserAccount.UserName;
                            uploadedFileDTOList.UploadedDate = DateTime.Now;

                            upFileCollection.uploadedFileDTOList.Add(uploadedFileDTOList);
                            #endregion

                            markup = await (new Lib.ServiceModel.ProjectModel()).SaveDocumentmarkupWithMarkupImage(markup, upFileCollection);
                        }

                    }

                    if (this.DrawingEditor.IsNew)
                    {
                        this.DrawingEditor.Hide();
                        //Login.MasterPage.ShowTopBanner = true;
                    }
                    else
                    {
                        DrawingEditor.UpdateImage(writableImage);

                        WinAppLibrary.Utilities.Helper.SimpleMessage("Successfully Saved", "-!");
                    }
                }
                else
                    WinAppLibrary.Utilities.Helper.SimpleMessage("There is a problem loading the drawing board - Please try again later", "Caution!");
            }
            catch (Exception e)
            {
                (new WinAppLibrary.Utilities.Helper()).ExceptionHandler(e, "DawingGridView SaveDrawing", "Failed to save the modified drawing - Please try again later.", "Saving Error!");

                if (this.DrawingEditor.IsNew)
                {
                    this.DrawingEditor.Hide();
                    //Login.MasterPage.ShowTopBanner = true;
                }
            }

            Login.MasterPage.Loading(false, this);
        }