public void Add(DepartmentNode item)
        {
            client.Cypher
            .Merge("(att:Department  {Guid:{deptGuid}})")
            .OnCreate()
            .Set("att = {deptParam}")

            .WithParams(
                new
            {
                deptGuid  = item.Guid,
                deptParam = item
            })
            .ExecuteWithoutResults();
        }
Exemplo n.º 2
0
 public static void ForShowAvatar(this DepartmentNode node, AvatarSize size)
 {
     if (node.Type == DepartmentNodeType.Member)
     {
         node.Avatar = new TethysAvatar
         {
             Id          = node.Addition.Uid,
             Name        = node.Addition.Name,
             DisplayName = node.Addition.DisplayName,
             Background  = AvatarHelper.GetColorBrush(node.Addition.DisplayName),
             Source      = AvatarHelper.GetAvatarBitmap(node.Addition.Avatar, size, FromType.User)
         };
     }
     else if (node.Type == DepartmentNodeType.Department)
     {
         foreach (var item in node.Children)
         {
             ForShowAvatar(item, size);
         }
     }
 }
        public List <DepartmentNode> GenerateOverviewTree(bool getInactive, long hospitalId, Guid SecurityToken)
        {
            var isActive        = !getInactive;
            var departments     = m_orgService.GetDepartmentListByHospitalId(hospitalId, SecurityToken);
            var departmentNodes = new List <DepartmentNode>();

            var textTemplates = m_textTemplateService.GetFullSMSTextTemplatesFor(isActive, hospitalId);

            // Global ---> Ruleset.Deptid is null AND Template.Deptid is null
            var templatesForGlobalSchedules = textTemplates.Where(t =>
                                                                  (t.DepartmentId == null && t.TemplateDepartmentId == null)).ToList();
            var globalRuleSetNodes = GroupByRSAndGetNodes(templatesForGlobalSchedules, true, hospitalId, SecurityToken);

            foreach (var department in departments)
            {
                //Department Schedules ---> Ruleset.DeptId = deptid OR Template.Deptid = deptid
                var deptTempalts = textTemplates.Where(t =>
                                                       (t.DepartmentId == department.DepartmentId || t.TemplateDepartmentId == department.DepartmentId)).ToList();
                //var scheduleNodes = new List<RuleSetNode>();
                var scheduleNodes = GroupByRSAndGetNodes(deptTempalts, false, hospitalId, SecurityToken);

                //Remove global ruleset if it has excluded the same department considering here.
                var filteredGlobalRuleSets = new List <RuleSetNode>();
                foreach (var globalRuleSet in globalRuleSetNodes)
                {
                    if (globalRuleSet.ExcludedOrgUnitNames != null && globalRuleSet.ExcludedOrgUnitNames.Any())
                    {
                        if (!globalRuleSet.ExcludedOrgUnitNames.Any(c => c == department.UnitGid))
                        {
                            filteredGlobalRuleSets.Add(globalRuleSet);
                        }
                    }
                    else
                    {
                        filteredGlobalRuleSets.Add(globalRuleSet);
                    }
                }

                //Add global schedules/templates into all the departments
                scheduleNodes.AddRange(filteredGlobalRuleSets);

                if (scheduleNodes.Count == scheduleNodes.Select(i => i.RuleSetId).Distinct().Count())
                {
                    var depNode = new DepartmentNode
                    {
                        Name      = department.DepartmentName,
                        Id        = department.DepartmentId,
                        Schedules = scheduleNodes
                    };
                    departmentNodes.Add(depNode);
                }
                else
                {
                    var depNode = new DepartmentNode
                    {
                        Name      = department.DepartmentName,
                        Id        = department.DepartmentId,
                        Schedules = GetDistinctRuleSetNode(scheduleNodes)
                    };
                    departmentNodes.Add(depNode);
                }
            }
            return(departmentNodes);
        }