public async Task Start() { //Дадим команду визарду обновить состояние UpdateState?.Invoke(this, EventArgs.Empty); try { Progress = "Подготовка к копированию шаблона"; var collection = new List <IDataObject>(); Progress = "Загрузка всех элементов шаблона"; await LoadCore(new[] { _creationInfo.Template.Id }, collection); Progress = "Создание корневого элемента"; await Process(collection); _cts.Token.ThrowIfCancellationRequested(); _modifier.Apply(); } catch (OperationCanceledException) { _modifier.Clear(); } catch (Exception e) { //Результат failed _creationInfo.Exception = e; _modifier.Clear(); } finally { //Дадим команду визарду перейти на следующую страницу _canGoNext = true; NavigateNext?.Invoke(this, EventArgs.Empty); } }
private void AddGraphicLayer(IDataObject dataObject, string xamlObject, Guid elementId) { var builder = _modifier.Edit(dataObject); using (var textBlocksStream = new MemoryStream()) using (var writer = new StreamWriter(textBlocksStream)) { writer.Write(xamlObject); writer.Flush(); var name = GraphicLayerElementConstants.GRAPHIC_LAYER_ELEMENT + elementId; var element = new GraphicLayerElement( elementId, Guid.NewGuid(), 0, 0, new Point(5, 5), -45, 0, 0, VerticalAlignment.Top, HorizontalAlignment.Left, GraphicLayerElementConstants.XAML, false); var serializer = new XmlSerializer(typeof(GraphicLayerElement)); using (var stream = new MemoryStream()) { serializer.Serialize(stream, element); builder.AddFile(name, stream, DateTime.Now, DateTime.Now, DateTime.Now); } builder.AddFile(GraphicLayerElementConstants.GRAPHIC_LAYER_ELEMENT_CONTENT + element.ContentId, textBlocksStream, DateTime.Now, DateTime.Now, DateTime.Now); _modifier.Apply(); } }
public async void AnnulSubtree(IEnumerable <Guid> ids) { await AnnulRecursive(ids); if (_hasAnyChanges) { _objectModifier.Apply(); } }
public async Task <IEnumerable <IFile> > AddFiles(Guid id, IEnumerable <string> filePaths) { if (filePaths == null) { return(null); } if (filePaths.Count() == 0) { return(null); } var builder = _objectModifier.EditById(id); foreach (string filePath in filePaths) { builder.AddFile(filePath); } _objectModifier.Apply(); var obj = (await _objectsRepository.GetObjectsAsync(new Guid[] { id }, o => o, System.Threading.CancellationToken.None)).FirstOrDefault(); return(obj.ActualFileSnapshot.Files); }
private void SetDocOnMenuClick() { var loader = new ObjectLoader(_objectsRepository); if (_listSpec == null) { return; } if (_listSpec.Count == 0) { return; } // для объектов спецификациий формируем pdf, для спецификаций формируем xps // формируем вторичное представление для спецификаций using (var k = new KompasConverter()) { k.KompasConvertToXps(_listSpec); foreach (var spc in _listSpec) { k.KompasConvertToPdf(spc.ListSpcObjects); } } // прикрепляем xps'ки foreach (var spc in _listSpec) { if (spc.GlobalId == Guid.Empty || spc.PreviewDocument == null) { continue; } loader.Load(spc.GlobalId, obj => { var builder = _objectModifier.Edit(obj); builder.AddFile(spc.PreviewDocument); _objectModifier.Apply(); }); foreach (var spcObject in spc.ListSpcObjects) { if (spcObject.GlobalId != Guid.Empty && spcObject.PreviewDocument != null) { loader.Load(spcObject.GlobalId, obj => { var builder = _objectModifier.Edit(obj); builder.AddFile(spcObject.PreviewDocument); _objectModifier.Apply(); }); } } } }
public void Upload(Guid objectId, Stream stream, string fileName) { var copy = new MemoryStream(); stream.Position = 0; stream.CopyTo(copy); stream.Position = 0; copy.Position = 0; _remoteStorage.Enqueue(() => { var changesetData = CreateChangesetData(objectId, copy, fileName); Logger.InfoFormat("ChangesetData was created for file with name {0}, with ObjectId {1}", fileName, objectId); var uploader = new ChangesetUploader(copy, _connector.FileArchiveApi, changesetData); uploader.Upload(); _objectModifier.Apply(changesetData); }); }