Пример #1
0
        protected bool TryGetDocumentContent <TDocument>(
            DbDocument document,
            DocumentTypeMapping <TDocument> mapping,
            out TDocument result,
            out DocumentReadFailureDetails failure)
        {
            try
            {
                result = document.GetPropertyValue <TDocument>(CreateContentKey(mapping));
            }
            catch (JsonSerializationException e)
            {
                result  = default(TDocument);
                failure = new DocumentReadFailureDetails("Failed to deserialise document", e.Message);
                return(false);
            }

            if (result == null)
            {
                failure = new DocumentReadFailureDetails("Failed to deserialise document", "Missing document content body");
                return(false);
            }

            failure = null;
            return(true);
        }
        private async Task UpsertDocumentAsync(DbDocument dbRecord)
        {
            var requestOptions = new RequestOptions {
                PartitionKey = new PartitionKey(dbRecord.PartitionKey)
            };

            await MakeClientCall(
                async() => await DbClient.UpsertDocumentAsync(CollectionUri, dbRecord, requestOptions),
                "Failed to upsert document");
        }
Пример #3
0
        /// <inheritdoc/>
        public string GetImagePath(DbDocument document)
        {
            var str = string.Empty;

            if (!string.IsNullOrEmpty(document.Image))
            {
                str = $@"pack://application:,,,/mpOther;component/Resources/Images/{document.Image}.png";
            }
            return(str);
        }
        private async Task PurgeDocumentAsync(DbDocument existingDbRecord)
        {
            var requestOptions = new RequestOptions
            {
                PartitionKey = new PartitionKey(existingDbRecord.PartitionKey)
            };

            await MakeClientCall(
                async() => await DbClient.DeleteDocumentAsync(existingDbRecord.SelfLink, requestOptions),
                "Failed to purge document");
        }
Пример #5
0
 protected void SetDocumentContent <TDocument>(DbDocument dbDocument, TDocument content, DocumentTypeMapping <TDocument> mapping)
 {
     try
     {
         dbDocument.SetPropertyValue(CreateContentKey(mapping), content);
     }
     catch (JsonException e)
     {
         throw new NebulaStoreException("Failed to serialise document content", e);
     }
 }
Пример #6
0
 private void OnBtnClick(object sender, RoutedEventArgs e)
 {
     if ((sender as Button).DataContext.GetType() == typeof(DbDocument))
     {
         PickedDocument = (sender as Button).DataContext as DbDocument;
     }
     if ((sender as Button).DataContext.GetType() == typeof(DbProject))
     {
         PickedProject = (sender as Button).DataContext as DbProject;
     }
     Close();
 }
Пример #7
0
        public int Insert(string docId, string sentence)
        {
            var docStore = _liteDatabase.GetCollection <DbDocument>("sentence");

            var doc = new DbDocument()
            {
                Sentence   = sentence,
                DocumentId = docId
            };
            var id = docStore.Insert(doc);

            return(id);
        }
        private async Task UpdateDocumentAsync(DbDocument dbRecord, DbDocument existingDbRecord)
        {
            var requestOptions = new RequestOptions
            {
                AccessCondition = new AccessCondition
                {
                    Type      = AccessConditionType.IfMatch,
                    Condition = existingDbRecord.ETag
                },
                PartitionKey = new PartitionKey(dbRecord.PartitionKey)
            };

            await MakeClientCall(
                async() => await DbClient.UpsertDocumentAsync(CollectionUri, dbRecord, requestOptions),
                "Failed to update document");
        }
Пример #9
0
        public Picker(List <DbDocument> documents)
        {
#if Revit2020
            Owner = ModuleData.RevitWindow;
#endif
#if Revit2018
            WindowInteropHelper helper = new WindowInteropHelper(this);
            helper.Owner = ModuleData.MainWindowHandle;
#endif
            PickedProject  = null;
            PickedDocument = null;
            InitializeComponent();
            this.Projects.ItemsSource = documents;
            tbHeader.Text             = "Документы:";
            Title = "KPLN: Выбрать документ";
        }
Пример #10
0
        protected void SetDocumentContentFromExisting <TDocument>(
            DbDocument dbDocument,
            DbDocument existingDocument,
            DocumentTypeMapping <TDocument> mapping)
        {
            var contentKey   = CreateContentKey(mapping);
            var contentValue = existingDocument.GetPropertyValue <object>(contentKey);

            try
            {
                dbDocument.SetPropertyValue(contentKey, contentValue);
            }
            catch (JsonException e)
            {
                throw new NebulaStoreException("Failed to serialise document content", e);
            }
        }
Пример #11
0
 private void CheckDocument(Document doc, DbDocument dbDoc)
 {
     try
     {
         DbRowData rowData = new DbRowData();
         rowData.Errors.Add(new DbError("Ошибка привязки к уровню", CheckTools.CheckLevels(doc)));
         rowData.Errors.Add(new DbError("Зеркальные элементы", CheckTools.CheckMirrored(doc)));
         rowData.Errors.Add(new DbError("Ошибка мониторинга осей", CheckTools.CheckMonitorGrids(doc)));
         rowData.Errors.Add(new DbError("Ошибка мониторинга уровней", CheckTools.CheckMonitorLevels(doc)));
         rowData.Errors.Add(new DbError("Дубликаты имен", CheckTools.CheckNames(doc)));
         rowData.Errors.Add(new DbError("Ошибки подгруженных связей", CheckTools.CheckSharedLocations(doc) + CheckTools.CheckLinkWorkSets(doc)));
         rowData.Errors.Add(new DbError("Предупреждения Revit", CheckTools.CheckErrors(doc)));
         rowData.Errors.Add(new DbError("Размер файла", CheckTools.CheckFileSize(dbDoc.Path)));
         DbController.WriteValue(dbDoc.Id.ToString(), rowData.ToString());
         //BotActions.SendRegularMessage(string.Format("👌 @{0}_{1} завершил проверку документа #{3} #{2}", NormalizeString(KPLN_Loader.Preferences.User.Family), NormalizeString(KPLN_Loader.Preferences.User.Name), NormalizeString(dbDoc.Project.Name), NormalizeString(dbDoc.Name)), Bot.Target.Process);
     }
     catch (Exception) { }
 }
 private void Update()
 {
     try
     {
         btnStart.IsEnabled = false;
         ObservableCollection <UIWPFElement> collection = this.lbDocuments.ItemsSource as ObservableCollection <UIWPFElement>;
         if (collection.Count != 0)
         {
             foreach (UIWPFElement e in collection.ToList())
             {
                 DbDocument d = e.Element as DbDocument;
                 if (!ProjectIsChecked(d) || !DepartmentIsChecked(d))
                 {
                     collection.Remove(e);
                 }
             }
         }
         foreach (DbDocument d in DbDocuments)
         {
             if (ProjectIsChecked(d) && DepartmentIsChecked(d))
             {
                 if (!ElementInCollection(collection, d))
                 {
                     collection.Add(new UIWPFElement(d));
                 }
             }
         }
         if (collection.Count != 0)
         {
             foreach (UIWPFElement e in collection.ToList())
             {
                 if (e.IsChecked)
                 {
                     btnStart.IsEnabled = true;
                     break;
                 }
             }
         }
     }
     catch (Exception e)
     {
         PrintError(e);
     }
 }
 private bool ProjectIsChecked(DbDocument doc)
 {
     if (doc.Project == null)
     {
         return(false);
     }
     foreach (UIWPFElement e in this.lbProjects.ItemsSource as ObservableCollection <UIWPFElement> )
     {
         DbProject project = e.Element as DbProject;
         if (project.Id == doc.Project.Id)
         {
             if (e.IsChecked)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     return(false);
 }
 private bool DepartmentIsChecked(DbDocument doc)
 {
     if (doc.Department == null)
     {
         return(false);
     }
     foreach (UIWPFElement e in this.lbSubDepartments.ItemsSource as ObservableCollection <UIWPFElement> )
     {
         DbSubDepartment department = e.Element as DbSubDepartment;
         if (department.Id == doc.Department.Id)
         {
             if (e.IsChecked)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     return(false);
 }
Пример #15
0
        protected async Task CreateDocumentAsync(DbDocument dbRecord)
        {
            var client = GetClient();

            await MakeClientCall(async() => await client.CreateDocumentAsync(_collectionUri, dbRecord), "Failed to write document");
        }
Пример #16
0
        //数据库文档-Project
        private void menuDoc_Click(object sender, EventArgs e)
        {
            DbDocument doc = new DbDocument();

            doc.ShowDialog();
        }
 private bool ElementInCollection(ObservableCollection <UIWPFElement> collection, DbDocument doc)
 {
     foreach (UIWPFElement e in collection)
     {
         if ((e.Element as DbDocument).Id == doc.Id)
         {
             return(true);
         }
     }
     return(false);
 }