예제 #1
0
        public async Task<bool> SaveDrawing(int projectId, int moduleId, string enTag, string title, string sortoption)
        {
            bool retValue = false;
            WinAppLibrary.Utilities.Helper helper = new WinAppLibrary.Utilities.Helper();

            try
            {
                Stream xmlstream;
                var drawingpagetotal = await (new Lib.ServiceModel.ProjectModel()).GetDrawingForDrawingViewer(projectId,
                                _grouplist[Lib.HashKey.Key_CWP].Where(x => x.ParentID > 0).Select(x => x.DataID).ToList(),
                                _grouplist[Lib.HashKey.Key_FIWP].Where(x => x.ParentID > 0).Select(x => x.DataID).ToList(),
                                _grouplist[Lib.HashKey.Key_DrawingType].Where(x => x.ParentID > 0).Select(x => x.DataID).ToList(),
                                enTag, title, sortoption, 1);

                if (drawingpagetotal != null && drawingpagetotal.drawing != null && drawingpagetotal.drawing.Count > 0)
                {
                    foreach (var d in drawingpagetotal.drawing)
                    {
                        var stream = await helper.GetImageStreamFromUri(new Uri(d.DrawingFilePath + d.DrawingFileURL));
                        if (stream == null)
                            stream = await helper.GetImageStreamFromUri(new Uri(WinAppLibrary.Utilities.Helper.BaseUri + ContentPath.DefaultDrawing));

                        await helper.SaveFileStream(ContentPath.OffModeFolder, d.DrawingFileURL, stream);
                        d.DrawingFilePath = ContentPath.OffModeFolder.Path + "\\";
                    }
                }

                xmlstream = helper.EncryptSerializeTo<RevealProjectSvc.DrawingPageTotal>(drawingpagetotal);
                await helper.SaveFileStream(ContentPath.OffModeFolder, ContentPath.DrawingSource, xmlstream);

                await SaveDrawingOption(_grouplist, _documentnote, enTag, title, sortoption);
                retValue = true;
            }
            catch (Exception e)
            {
                helper.ExceptionHandler(e, "SaveDrawing");
                throw e;
            }

            return retValue;
        }