예제 #1
0
        public override async Task SetVariableAsync(string name, string value, CancellationToken cancellationToken, TimeSpan expiration = default)
        {
            var storageDocument = new StorageDocument
            {
                Type     = PlainText.MediaType,
                Document = value
            };

            if (expiration != default)
            {
                storageDocument.Expiration = DateTimeOffset.UtcNow.Add(expiration);
            }

            var key = CreateContextKey(name);

            if (!await _ownerCallerNameDocumentMap.TryAddAsync(key, storageDocument, true, cancellationToken))
            {
                throw new LimeException(ReasonCodes.COMMAND_PROCESSING_ERROR, "An unexpected error occurred while storing the document");
            }

            if (expiration != default)
            {
                await _ownerCallerNameDocumentMap.SetRelativeKeyExpirationAsync(key, expiration);
            }
        }
예제 #2
0
        private Tuple <Label, CalculationParameter, BuiltInCategory, Element> GetElementInternalData(Autodesk.Revit.DB.CodeChecking.ServiceData data, ElementId elementId)
        {
            Element              element              = data.Document.GetElement(elementId);
            BuiltInCategory      category             = Autodesk.Revit.DB.CodeChecking.Tools.GetCategoryOfElement(element);
            StorageDocument      storageDocument      = Autodesk.Revit.DB.CodeChecking.Storage.StorageService.GetStorageService().GetStorageDocument(data.Document);
            CalculationParameter calculationParameter = storageDocument.CalculationParamsManager.CalculationParams.GetEntity <CalculationParameter>(data.Document);
            Label ccLabel = storageDocument.LabelsManager.GetLabel(element);

            return(new Tuple <Label, CalculationParameter, BuiltInCategory, Element>(ccLabel, calculationParameter, category, element));
        }
        protected override void AddVariableValue(string variableName, string variableValue)
        {
            var storageDocument = new StorageDocument()
            {
                Type     = "text/plain",
                Document = variableValue
            };

            OwnerCallerNameDocumentMap.TryAddAsync(
                new OwnerCallerName()
            {
                Owner  = Application,
                Caller = User,
                Name   = variableName.ToLowerInvariant()
            },
                storageDocument)
            .Wait();
        }
예제 #4
0
        private async Task UploadDocumentAsync(byte[] document, string documentName)
        {
            if (IsBusy || document == null)
            {
                return;
            }

            IsBusy      = true;
            BusyMessage = "upoading document...";

            try
            {
                using (var memoryStream = document.AsMemoryStream())
                {
                    var uploadResult = await StorageService.UploadFileAsync(FileType.Document, memoryStream);

                    if (uploadResult.IsValid())
                    {
                        var file = new StorageDocument()
                        {
                            Name = documentName,
                            RemoteStorageFileId = uploadResult.FileId,
                            //RemoteStorageFileId = "test_id",
                            File     = document,
                            FileType = FileType.Document
                        };

                        ModelUpdatedMessageEvent <StorageDocument> .Publish(file, ModelUpdateEvent.Created);

                        await Navigation.Close();
                    }
                    else
                    {
                        await Dialog.DisplayAlertAsync("Error", uploadResult.Notification.ToString(), "close");
                    }
                }
            }
            finally
            {
                IsBusy = false;
            }
        }