コード例 #1
0
        public async Task AddOrUpdateAsync(Document document, CancellationToken cancellationToken = default)
        {
            ValidateElasticSearchEnabled();

            var client = _clientProvider.GetClient();

            var existsResponse = await client.DocumentExistsAsync(DocumentPath <EsDocument> .Id(document.Id),
                                                                  x => x.Index(_options.IndexName), cancellationToken);

            HandleError(existsResponse);

            var esDocument = new EsDocument
            {
                Id           = document.Id,
                ProjectId    = document.ProjectId,
                Name         = document.Name,
                FileName     = document.FileName,
                Content      = document.Content,
                LanguageCode = ConvertLanguageCode(document.LanguageCode),
                Version      = ConvertVersion(document.Version)
            };

            if (!existsResponse.Exists)
            {
                HandleError(await client.IndexAsync(esDocument,
                                                    x => x.Id(document.Id).Index(_options.IndexName), cancellationToken));
            }
            else
            {
                HandleError(await client.UpdateAsync(DocumentPath <EsDocument> .Id(document.Id),
                                                     x => x.Doc(esDocument).Index(_options.IndexName), cancellationToken));
            }
        }
        public async Task <TEntity> FindAsync(Guid id)
        {
            var nestId   = (id as Guid?).Value;
            var response = await ElasticClient.GetAsync(DocumentPath <TEntity> .Id(nestId).Index(IndexName));

            return(response.Source);
        }
コード例 #3
0
        public async Task <bool> UpdateData(NewYorkUpdateDtos newYorkUpdateDtos, int id)
        {
            ISearchResponse <NewYork> searchResponse = await Exists(id);

            if (searchResponse != null)
            {
                var newYork        = searchResponse.Documents.FirstOrDefault();
                var updateResponse = await _client.UpdateAsync <NewYorkUpdateDtos>(
                    DocumentPath <NewYorkUpdateDtos> .Id(searchResponse.Hits.FirstOrDefault().Id),
                    descriptor => descriptor
                    .RetryOnConflict(3)
                    .Doc(newYorkUpdateDtos)
                    .Refresh(Refresh.True)
                    );

                if (updateResponse.IsValid)
                {
                    return(true);
                }

                return(false);
            }



            return(false);
        }
コード例 #4
0
        public async Task <bool> AddManyBulk(List <NewYorkAddDtos> newYorkList)
        {
            List <NewYorkAddDtos> tempList = new List <NewYorkAddDtos>();

            foreach (var newYork in newYorkList)
            {
                ISearchResponse <NewYork> searchResponse = await Exists(newYork.id);

                if (searchResponse != null)
                {
                    var updateResponse = await _client.UpdateAsync <NewYorkAddDtos>(
                        DocumentPath <NewYorkAddDtos> .Id(searchResponse.Hits.FirstOrDefault().Id),
                        descriptor => descriptor
                        .RetryOnConflict(3)
                        .Doc(newYork)
                        .Refresh(Refresh.True)
                        );
                }
                else
                {
                    tempList.Add(newYork);
                }
            }

            if (tempList.Count > 0)
            {
                var indexManyAsyncResponse = await _client.IndexManyAsync(tempList);

                return(indexManyAsyncResponse.IsValid);
            }
            else
            {
                return(true);
            }
        }
コード例 #5
0
        public async Task <LogModel <T> > GetByIdNest <T>(object id) where T : class, ICloneable
        {
            try
            {
                if (string.IsNullOrEmpty(collectionName))
                {
                    collectionName = typeof(T).Name.ToLower();
                }

                var p = new DocumentPath <LogModel <T> >(new Id(id));

                var response = await elasticsearchClient.SearchAsync <LogModel <T> >(s =>
                                                                                     s.Size(1)
                                                                                     .Query(q =>
                                                                                            q.Match(m => m.Field(f => f.ObjectId)
                                                                                                    .Query(id.ToString()
                                                                                                           ))
                                                                                            )
                                                                                     );

                return(response.Documents.FirstOrDefault());
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                return(null);
            }
        }
コード例 #6
0
        public long GetVersion <T>(string indexName, int id) where T : class
        {
            DocumentPath <T> path = new DocumentPath <T>(id);
            var response          = elasticClient.Get <T>(path, s => s.Index(indexName.ToLower()));

            return(response.Version);
        }
コード例 #7
0
        public async Task DeleteAsync <T>(string id)
            where T : class
        {
            await Client.DeleteAsync(DocumentPath <T> .Id(id), idx => idx.Index(PrefixIndex + "-" + typeof(T).Name.ToLower()));

            await Client.RefreshAsync(Indices.All);
        }
コード例 #8
0
        public static bool updateListUser(string ID, List <long> LstUserId, string Type)
        {
            if (EnableElasticServer.ToIntOrZero() == 1)
            {
                try
                {
                    var result = ConnectionToES.EsClient().Get <ElasticModel>(Type + "_" + ID.ToString(),
                                                                              x => x.Index(ElasticIndex).Type(ElasticModel));
                    ElasticModel tmpModel = result.Source;
                    if (LstUserId != null && LstUserId.Count > 0)
                    {
                        tmpModel.ListUser.AddRange(LstUserId);
                        var response = ConnectionToES.EsClient().Update(
                            DocumentPath <ElasticModel> .Id(Type + "_" + ID.ToString()),
                            u => u.Index(ElasticIndex).Type(ElasticModel).Doc(tmpModel)
                            );
                        return(true);
                    }
                    return(false);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }

            return(false);
        }
コード例 #9
0
        public async Task DeleteAsync(Guid id, CancellationToken cancellationToken = default)
        {
            ValidateElasticSearchEnabled();

            HandleError(await _clientProvider.GetClient()
                        .DeleteAsync(DocumentPath <Document> .Id(id), x => x.Index(_options.IndexName), cancellationToken));
        }
コード例 #10
0
        public bool Edit(MainRCJournalInfo mainRCJournalInfo)
        {
            DocumentPath <MainRCJournalInfo> deletePath = new DocumentPath <MainRCJournalInfo>(mainRCJournalInfo.ID);
            var result = _iService.EditEntityWidthScope(mainRCJournalInfo, deletePath);

            return(result);
        }
コード例 #11
0
        private async Task <Response> DeleteEntityFromPathAsync <TEntity>(DocumentPath <TEntity> documentPath)
            where TEntity : class
        {
            var result    = new Response();
            var indexName = ElasticSearchExtensions.GetIndexNameFrom <TEntity>();

            var existsResponse = await _elasticClient.Indices.ExistsAsync(indexName)
                                 .ConfigureAwait(false);

            if (!existsResponse.Exists)
            {
                throw new InvalidOperationException($"Index {indexName} does not exist");
            }

            var documentExistsResponse = await _elasticClient.DocumentExistsAsync(documentPath, d => d.Index(indexName))
                                         .ConfigureAwait(false);

            if (!documentExistsResponse.Exists)
            {
                return(result);
            }

            var deleteResponse = await _elasticClient.DeleteAsync(documentPath, d => d.Index(indexName))
                                 .ConfigureAwait(false);

            if (deleteResponse.IsValid)
            {
                return(result);
            }

            result.IsOk         = false;
            result.ErrorMessage = deleteResponse.OriginalException.Message;
            result.Exception    = deleteResponse.OriginalException;
            return(result);
        }
コード例 #12
0
        public async Task <DocumentResponse <TEntity> > GetEntityByIdAsync <TEntity>(Id id)
            where TEntity : class
        {
            var result = new DocumentResponse <TEntity>();

            var indexName = ElasticSearchExtensions.GetIndexNameFrom <TEntity>();

            var indexExistsResponse = await _elasticClient.Indices.ExistsAsync(indexName)
                                      .ConfigureAwait(false);

            if (!indexExistsResponse.Exists)
            {
                result.IsOk         = false;
                result.ErrorMessage = $"Index {indexName} does not exist";

                return(result);
            }

            var documentPath = DocumentPath <TEntity> .Id(id);

            var getResponse = await _elasticClient.GetAsync(documentPath, descriptor => descriptor.Index(indexName))
                              .ConfigureAwait(false);

            if (!getResponse.IsValid)
            {
                result.IsOk         = false;
                result.ErrorMessage = getResponse.OriginalException.Message;
                result.Exception    = getResponse.OriginalException;
                return(result);
            }

            result.DocumentResult = getResponse;

            return(result);
        }
コード例 #13
0
        public void VersionLock(string indexName)
        {
            //查询到版本号
            var result = _client.Search <TestModel2>(
                s =>
                s.Index(indexName)
                .Query(q => q.Term(tm => tm.Field(fd => fd.State).Value(1))).Size(1)
                .Version()        //结果中包含版本号
                );

            foreach (var s in result.Hits)
            {
                Console.WriteLine(s.Id + "  -  " + s.Version);
            }

            var path = new DocumentPath <TestModel2>(1);
            //更新时带上版本号 如果服务端版本号与传入的版本好相同才能更新成功
            var response = _client.Update(path, (p) => p
                                          .Index(indexName)
                                          .Type(typeof(TestModel2))
                                          .Version(2)//限制es中版本号为2时才能成功
                                          .Doc(new TestModel2()
            {
                Name = "测测测" + DateTime.Now
            })
                                          );
        }
コード例 #14
0
		//** if you have an instance of your document you can use it as well generate document paths */
		[U] public void FromObject()
		{
			var project = new Project { Name = "hello-world" };

			/** here we create a new document path based on a Project */
			IDocumentPath path = new DocumentPath<Project>(project);
			Expect("project").WhenSerializing(path.Index);
			Expect("project").WhenSerializing(path.Type);
			Expect("hello-world").WhenSerializing(path.Id);

			/** You can still override the inferred index and type name*/
			path = new DocumentPath<Project>(project).Type("project1");
			Expect("project1").WhenSerializing(path.Type);

			path = new DocumentPath<Project>(project).Index("project1");
			Expect("project1").WhenSerializing(path.Index);
			
			/** there is also a static way to describe such paths */
			path = DocumentPath<Project>.Id(project); 
			Expect("project").WhenSerializing(path.Index);
			Expect("project").WhenSerializing(path.Type);
			Expect("hello-world").WhenSerializing(path.Id);

			DocumentPath<Project> p = project;
		}
コード例 #15
0
        [U] public void Null()
        {
            var value = new DocumentPath <Project>(2);

            (value == null).Should().BeFalse();
            (null == value).Should().BeFalse();
        }
コード例 #16
0
        public virtual async Task AddOrUpdateAsync <T, TKey>(string indexName, T model) where T : ElasticEntity <TKey>
        {
            var exis = ElasticSearchClient.DocumentExists(DocumentPath <T> .Id(new Id(model)), dd => dd.Index(indexName));

            if (exis.Exists)
            {
                var result = await ElasticSearchClient.UpdateAsync(DocumentPath <T> .Id(new Id(model)),
                                                                   ss => ss.Index(indexName).Doc(model).RetryOnConflict(3));

                if (result.ServerError == null)
                {
                    return;
                }
                throw new ElasticSearchException($"Update Document failed at index{indexName} :" + result.ServerError.Error.Reason);
            }
            else
            {
                var result = await ElasticSearchClient.IndexAsync(model, ss => ss.Index(indexName));

                if (result.ServerError == null)
                {
                    return;
                }
                throw new ElasticSearchException($"Insert Document failed at index {indexName} :" + result.ServerError.Error.Reason);
            }
        }
コード例 #17
0
        public bool Delete(int id)
        {
            DocumentPath <MainRCJournalInfo> deletePath = new DocumentPath <MainRCJournalInfo>(id);
            bool result = _iService.DeleteRowById(deletePath);

            return(result);
        }
コード例 #18
0
        public ActionResult Edit(MainRCJournalInfo mainRCJournalInfo)
        {
            DocumentPath <MainRCJournalInfo> deletePath = new DocumentPath <MainRCJournalInfo>(mainRCJournalInfo.ID);
            var result = _iService.EditEntityWidthScope(mainRCJournalInfo, deletePath);

            return(Json(new { result = result }));
        }
コード例 #19
0
        public static void HowToScrollIndex(IElasticClient client)
        {
            var res = client.Search <ProductListEsIndexModelExample>(s => s
                                                                     .From(0)
                                                                     .Size(1)
                                                                     .MatchAll()
                                                                     .Scroll(new Time(TimeSpan.FromSeconds(4)))
                                                                     );

            res.ThrowIfException();
            if (!ValidateHelper.IsPlumpString(res.ScrollId))
            {
                throw new Exception("未能拿到游标地址");
            }

            while (true)
            {
                res = client.Scroll <ProductListEsIndexModelExample>("4s", res.ScrollId);
                if (!res.Documents.Any())
                {
                    break;
                }
                foreach (var doc in res.Documents)
                {
                    //do something
                    client.Delete(new DeleteRequest("index", "typename", "ukey"));
                    client.Delete(DocumentPath <ProductListEsIndexModelExample> .Id("ukey").Index("index"));
                }
            }
        }
コード例 #20
0
 public MsBuildItem(DocumentPath documentPath, string fullPath, string itemType, MsBuildProject project)
 {
     this.documentPath = documentPath;
     this.fullPath     = fullPath;
     this.itemType     = itemType;
     this.project      = project;
 }
コード例 #21
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <typeparam name="T">实体类型</typeparam>
        /// <param name="indexName">索引名</param>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public virtual async Task SaveAsync <T>(string indexName, T entity) where T : class
        {
            var client = await GetClientAsync();

            var exists =
                await client.DocumentExistsAsync(DocumentPath <T> .Id(new Id(entity)), dd => dd.Index(indexName));

            if (exists.Exists)
            {
                var result = await client.UpdateAsync(DocumentPath <T> .Id(new Id(entity)),
                                                      ss => ss.Index(indexName).Doc(entity).RetryOnConflict(3));

                if (result.ServerError == null)
                {
                    return;
                }

                throw new ElasticSearchException($"更新文档在索引 {indexName} 失败:{result.ServerError.Error.Reason}");
            }
            else
            {
                var result = await client.IndexAsync <T>(entity, ss => ss.Index(indexName));

                if (result.ServerError == null)
                {
                    return;
                }
                throw new ElasticSearchException($"插入文档在索引 {indexName} 失败:{result.ServerError.Error.Reason}");
            }
        }
コード例 #22
0
        public virtual Task UpsertDocument <TDocument>(IUpsertDocumentContext <TDocument> context) where TDocument : class
        {
            var documentType = typeof(TDocument);
            var client       = this._clientFactory.GetClient();

            var documentPath = new DocumentPath <TDocument>(context.Id)
                               .Type(documentType);

            var index            = this.GetIndex(context.IndexContext);
            var updateDescriptor = new UpdateDescriptor <TDocument, dynamic>(documentPath)
                                   .Index(index);

            if (context.Script != null)
            {
                updateDescriptor.Script(d => d.Inline(context.Script)
                                        .Params(context.ScriptParams.ToDictionary(k => k.Key, v => v.Value)));
            }
            else
            {
                updateDescriptor.Upsert(context.Document)
                .Doc(context.PartialUpdate ?? context.Document);
            }

            var updateDocResponse = client.Update <TDocument, dynamic>(updateDescriptor);

            this._responseHandler.ValdateAndHandleException(updateDocResponse, true);
            return(Task.CompletedTask);
        }
コード例 #23
0
        public SourceResponse <TDocument> Source <TDocument>(DocumentPath <TDocument> id, Action <SourceRequestDescriptor <TDocument> > configureRequest = null)
        {
            var descriptor = new SourceRequestDescriptor <TDocument>(document: id.Document, index: id?.Self?.Index ?? typeof(TDocument), id: id?.Self?.Id ?? Id.From(id.Document));

            configureRequest?.Invoke(descriptor);
            return(DoRequest <SourceRequestDescriptor <TDocument>, SourceResponse <TDocument> >(descriptor));
        }
コード例 #24
0
        public void RemoveCodeFile(DocumentPath documentPath)
        {
            MsBuildProject container    = null;
            MsBuildItem    itemToRemove = null;

            foreach (var proj in this.Solution.Projects)
            {
                if (proj.Value.Name == documentPath.ProjectName)
                {
                    foreach (var item in proj.Value.Items)
                    {
                        if (item.DocumentPath.Equals(documentPath) && this.msBuildStoreAdapters.Any(a => a.ItemSupported(item)))
                        {
                            container    = proj.Value;
                            itemToRemove = item;
                            break;
                        }
                    }
                }
            }

            if (itemToRemove != null)
            {
                container.RemoveItem(itemToRemove);
            }
        }
コード例 #25
0
ファイル: BaseEsContext.cs プロジェクト: Ljyi/eaven
        ///// <summary>
        ///// 更新部分字段
        ///// </summary>
        ///// <returns></returns>
        //public bool UpdatePart(UpdateRequest<T, object> request)
        //{
        //    var response = client.Update(request);
        //    return response.IsValid;
        //}
        ///// <summary>
        ///// 更新部分字段
        ///// </summary>
        ///// <returns></returns>
        //public bool UpdatePartAsync(UpdateRequest<T, object> request)
        //{
        //    var response = client.UpdateAsync(request);
        //    return response.Result.IsValid;
        //}
        /// <summary>
        /// 更新全部字段
        /// </summary>
        /// <returns></returns>
        public bool Update(T t)
        {
            DocumentPath <T> updatePath = new DocumentPath <T>(t.Id);
            var response = client.Update(updatePath, (p) => p.Doc(t));

            return(response.IsValid);
        }
コード例 #26
0
        public override string GetPath(TransformationData data)
        {
            if (isInternalOutput)
            {
                if (IsBookmark)
                {
                    return("index.html#" + BookmarkName);
                }
                else
                {
                    return("index.html#" + DocumentPathId(DocumentPath.ToLower()));
                }
            }

            var path =
                Path.Combine(
                    FileHelper.GetRelativePath(
                        Path.GetDirectoryName(data.Document.LocalPath), Path.GetDirectoryName(DocumentPath)),
                    "index.html");

            if (IsBookmark)
            {
                var bookmark = data.ProcessedDocumentCache.Get(DocumentPath).GetBookmark(BookmarkName);
                if (bookmark == null)
                {
                    throw new EMPathVerificationException(Language.Message("BookmarkNotFound", BookmarkName));
                }

                path += "#" + bookmark.UniqueKey;
            }

            return(Normalizer.NormalizePath(path));
        }
コード例 #27
0
        public TestModel2 Get(string indexName, int id)
        {
            DocumentPath <TestModel2> path = new DocumentPath <TestModel2>(id);
            var response = _client.Get <TestModel2>(path, s => s.Index(indexName));

            return(response.Source);
        }
コード例 #28
0
        public ActionResult Delete(int id)
        {
            DocumentPath <MainRCJournalInfo> deletePath = new DocumentPath <MainRCJournalInfo>(id);
            bool result = _iService.DeleteRowById(deletePath);

            return(Json(new { result = result }));
        }
コード例 #29
0
        public long GetVersion(string indexName, int id)
        {
            DocumentPath <TestModel2> path = new DocumentPath <TestModel2>(id);
            var response = _client.Get <TestModel2>(path, s => s.Index(indexName));

            return(response.Version);
        }
コード例 #30
0
        //** if you have an instance of your document you can use it as well generate document paths */
        [U] public void FromObject()
        {
            var project = new Project {
                Name = "hello-world"
            };

            /** here we create a new document path based on a Project */
            IDocumentPath path = new DocumentPath <Project>(project);

            Expect("project").WhenSerializing(path.Index);
            Expect("project").WhenSerializing(path.Type);
            Expect("hello-world").WhenSerializing(path.Id);

            /** You can still override the inferred index and type name*/
            path = new DocumentPath <Project>(project).Type("project1");
            Expect("project1").WhenSerializing(path.Type);

            path = new DocumentPath <Project>(project).Index("project1");
            Expect("project1").WhenSerializing(path.Index);

            /** there is also a static way to describe such paths */
            path = DocumentPath <Project> .Id(project);

            Expect("project").WhenSerializing(path.Index);
            Expect("project").WhenSerializing(path.Type);
            Expect("hello-world").WhenSerializing(path.Id);

            DocumentPath <Project> p = project;
        }
コード例 #31
0
        public Task <Response> DeleteEntityAsync <TEntity>(Id id)
            where TEntity : class
        {
            var documentPath = DocumentPath <TEntity> .Id(id);

            return(DeleteEntityFromPathAsync(documentPath));
        }
コード例 #32
0
		/** # DocumentPaths
		 * Many API's in elasticsearch describe a path to a document. In NEST besides generating a constructor that takes
		 * and Index, Type and Id seperately we also generate a constructor taking a DocumentPath that allows you to describe the path
		 * to your document more succintly 
		 */

		/** Manually newing */
		[U] public void FromId()
		{
			/** here we create a new document path based on Project with the id 1 */
			IDocumentPath path = new DocumentPath<Project>(1);
			Expect("project").WhenSerializing(path.Index);
			Expect("project").WhenSerializing(path.Type);
			Expect(1).WhenSerializing(path.Id);

			/** You can still override the inferred index and type name*/
			path = new DocumentPath<Project>(1).Type("project1");
			Expect("project1").WhenSerializing(path.Type);

			path = new DocumentPath<Project>(1).Index("project1");
			Expect("project1").WhenSerializing(path.Index);
			
			/** there is also a static way to describe such paths */
			path = DocumentPath<Project>.Id(1); 
			Expect("project").WhenSerializing(path.Index);
			Expect("project").WhenSerializing(path.Type);
			Expect(1).WhenSerializing(path.Id);
		}
コード例 #33
0
ファイル: Repository.cs プロジェクト: ELS-STLCM/test
        public static string GetDocumentPath(DocumentPath.Module documentPath, string courseId, string scenarioId, AppEnum.ApplicationRole role,
                                           string userId, string customValue)
        {
            List<string> nodeList = new List<string>();
            string currentUserRole = AppCommon.GetRoleDescription(role);
            if (documentPath == DocumentPath.Module.Masters)
            {
                nodeList.Add(GetMasterDocumentPath());
            }
            else if (documentPath == DocumentPath.Module.Attachments)
            {
                nodeList.Add(GetAttachmentDocumentPath());
            }
            else
            {
                nodeList.Add(GetBaseDocumentPath(courseId, currentUserRole));
            }
            bool isAdminUser = IsAdmin(currentUserRole);
            if (isAdminUser)
            {
            }
            else
            {
                nodeList.Add(userId);
                nodeList.Add(AssignmentNode);
                nodeList.Add(scenarioId);
            }
            switch (documentPath)
            {
                case DocumentPath.Module.PatientVisitAppointment:
                case DocumentPath.Module.BlockAppointment:
                case DocumentPath.Module.OtherAppointment:
                case DocumentPath.Module.RecurrenceGroup:
                    {
                        if (isAdminUser)
                        {

                        }
                        else
                        {

                            nodeList.Add(AppointmentNode);
                            if (documentPath == DocumentPath.Module.RecurrenceGroup)
                            {
                                nodeList.Add("Recurrence");
                                nodeList.Add("{0}");
                            }
                            else
                            {
                                nodeList.Add("Type");
                                switch (documentPath)
                                {
                                    case DocumentPath.Module.PatientVisitAppointment:
                                        {
                                            nodeList.Add("PatientVisit");

                                            break;
                                        }
                                    case DocumentPath.Module.OtherAppointment:
                                        {
                                            nodeList.Add("Other");
                                            break;
                                        }
                                    case DocumentPath.Module.BlockAppointment:
                                        {
                                            nodeList.Add("Block");
                                            break;
                                        }
                                }
                                nodeList.Add(customValue);
                                nodeList.Add("{0}");
                                switch (customValue)
                                {
                                    case AppConstants.CalendarMonthFilters:
                                        break;
                                    default:
                                        nodeList.Add("{1}");
                                        nodeList.Add("{2}");
                                        nodeList.Add("{3}");
                                        AppEnum.ProviderType providerType = (!AppCommon.CheckIfStringIsEmptyOrNull(customValue) ? (AppEnum.ProviderType)Enum.Parse(typeof(AppEnum.ProviderType), customValue) : AppEnum.ProviderType.SingleProvider);
                                        if (providerType == AppEnum.ProviderType.SingleProvider)
                                        {
                                            nodeList.Add("{4}");
                                        }
                                        break;
                                }
                            }
                        }
                        break;
                    }
                case DocumentPath.Module.LCMFolders:
                    {
                        nodeList.Add("{0}");//Based on foldertype substitute with either QuestionBank,AssignmentRepository etc.,
                        nodeList.Add("SubFolders{1}");
                        break;
                    }
                case DocumentPath.Module.Assignments:
                    {
                        if (isAdminUser)
                        {
                            switch (customValue)
                            {
                                case AppConstants.Create:
                                    {
                                        nodeList.Add(AdminAssignmentRepository + "{0}");
                                        nodeList.Add(AssignmentNode);
                                        nodeList.Add("{1}");
                                        break;
                                    }
                                default:
                                    {
                                        nodeList.Add(AdminAssignmentRepository);
                                        break;
                                    }
                            }
                        }
                        break;
                    }
                case DocumentPath.Module.Patients:
                    {

                        switch (customValue)
                        {
                            case AppConstants.Read:
                                {
                                    nodeList.Add(isAdminUser ? AdminPatientRepository : PatientsNode);
                                    break;
                                }
                            case AppConstants.Create:
                                {
                                    if (isAdminUser)
                                    {
                                        nodeList.Add(AdminPatientRepository);
                                    }
                                    nodeList.Add(PatientsNode);
                                    nodeList.Add("{0}");
                                    break;
                                }
                            default:
                                {
                                    break;
                                }
                        }

                        break;
                    }
                case DocumentPath.Module.QuestionBank:
                    {
                        if (isAdminUser)
                        {
                            switch (customValue)
                            {
                                case AppConstants.Create:
                                    {
                                        nodeList.Add(AdminQuestionBank + "{0}");
                                        nodeList.Add(QuestionItems);
                                        nodeList.Add("{1}");
                                        break;
                                    }
                                default:
                                    {
                                        nodeList.Add(AdminQuestionBank);
                                        break;
                                    }
                            }

                        }
                        break;
                    }

                case DocumentPath.Module.Attachments:
                    {
                        switch (customValue)
                        {
                            case AppConstants.TransientAttachment:
                                {
                                    nodeList.Add(AppConstants.TransientAttachment);
                                    break;
                                }
                            default:
                                {
                                    nodeList.Add(AppConstants.PersistentAttachment);
                                    break;
                                }
                        }
                        nodeList.Add("{0}");
                        break;
                    }
                case DocumentPath.Module.SkillSets:
                    {
                        if (isAdminUser)
                        {

                            switch (customValue)
                            {
                                case AppConstants.Create:
                                    nodeList.Add(AdminSkillsetRepository + "{0}");// {0} will be replaced with FOLDER text
                                    nodeList.Add(Skillsets);
                                    nodeList.Add("{1}"); // {1} will be replaces with NEW GUID value for each skillset
                                    break;
                                default:
                                    nodeList.Add(AdminSkillsetRepository);
                                    break;
                            }
                        }
                        break;
                    }
                case DocumentPath.Module.ReferralForm:
                case DocumentPath.Module.PriorAuthorizationForm:
                case DocumentPath.Module.PatientRecordsAccessForms:
                case DocumentPath.Module.MedicalRecordsReleaseDocument:
                case DocumentPath.Module.BillOfRights:
                case DocumentPath.Module.NoticeOfPrivacyPractice:
                    {
                        if (isAdminUser)
                        {
                        }
                        else
                        {

                            nodeList.Add(PatientNode);
                            nodeList.Add("{0}");//Patient Guid Value
                            switch (documentPath)
                            {
                                case DocumentPath.Module.ReferralForm:
                                    {
                                        nodeList.Add("ReferralForms");
                                        break;
                                    }
                                case DocumentPath.Module.PriorAuthorizationForm:
                                    {
                                        nodeList.Add("PriorAuthorizationRequestForms");
                                        break;
                                    }
                                case DocumentPath.Module.PatientRecordsAccessForms:
                                    {
                                        nodeList.Add("PatientRecordsAccessForms");
                                        break;
                                    }
                                case DocumentPath.Module.MedicalRecordsReleaseDocument:
                                    {
                                        nodeList.Add("MedicalRecordsReleaseDocument");
                                        break;
                                    }
                                case DocumentPath.Module.BillOfRights:
                                    {
                                        nodeList.Add("BillOfRights");
                                        break;
                                    }
                                case DocumentPath.Module.NoticeOfPrivacyPractice:
                                    {
                                        nodeList.Add("NoticeOfPrivacyPractice");
                                        break;
                                    }
                                default: { break; }
                            }
                            if (documentPath != DocumentPath.Module.BillOfRights)
                            {
                                nodeList.Add("{1}");//Form Guid
                            }
                        }
                        break;
                    }
                case DocumentPath.Module.Masters:
                    {
                        switch (customValue)
                        {
                            case AppConstants.BillofRights:
                                {
                                    nodeList.Add("Forms");
                                    nodeList.Add(AppConstants.BillofRights);
                                    break;
                                }
                            case AppConstants.NoticePrivacyPractice:
                                {
                                    nodeList.Add("Forms");
                                    nodeList.Add(AppConstants.NoticePrivacyPractice);
                                    break;
                                }
                            case AppConstants.ApplicationModule:
                                {
                                    nodeList.Add(AppConstants.ApplicationModule);
                                    break;
                                }
                            case AppConstants.Competencies:
                                {
                                    nodeList.Add(AppConstants.Competencies + "{0}{1}");
                                    break;
                                }
                            case AppConstants.CompetencySource:
                                {
                                    nodeList.Add(AppConstants.CompetencySource);
                                    nodeList.Add("{0}");
                                    break;
                                }
                            case AppConstants.QuestionType:
                                {
                                    nodeList.Add(AppConstants.QuestionType);
                                    break;
                                }
                            default: { break; }
                        }
                        break;
                    }
                default:
                    {
                        break;
                    }
            }
            return string.Join("/", nodeList);
        }
コード例 #34
0
ファイル: Repository.cs プロジェクト: ELS-STLCM/test
 public static string GetDocumentPath(DocumentPath.Module documentPath, DropBoxLink dropBox, string customValue)
 {
     return GetDocumentPath(documentPath, dropBox.Cid, dropBox.Sid, AppCommon.GetCurrentUserRole(dropBox.UserRole), dropBox.Uid, customValue);
 }