public TaxonomyDetail(ConversationVm conversation)
        {
            this.InitializeComponent();
            //_conversation = conversation;
            this.DataContext = this;

            this.GenerateTaxonomyTree(conversation.Conversation.FwControllerContext, conversation);
            this.OnPropertyChanged("CategoryTaxonomies");
            this.OnPropertyChanged("SelectedTaxonomyProtocol");
        }
        public void GenerateTaxonomyTree(FwControllerContext fwControllerContext, ConversationVm conversation = null)
        {
            this._taxonomies = new List <TaxonomyCategory>();


            NBAR2TaxonomyProtocol[] nbarTaxonomies;
            if (conversation == null)
            {
                var nbarDb = fwControllerContext.FwController.GetNbarProtocolPortDatabase();
                nbarTaxonomies = nbarDb.Nbar2Taxonomy.NBAR2TaxonomyProtocol;
            }
            else
            {
                nbarTaxonomies = fwControllerContext.FwController.GetNbarTaxonomiesProtocolFromAppTags(conversation.Conversation.ApplicationTags);
            }


            foreach (var nbarTaxonomy in nbarTaxonomies)
            {
                var attributes = nbarTaxonomy.attributes.FirstOrDefault();
                if (attributes != null)
                {
                    var category = this._taxonomies.FirstOrDefault(taxonomyCategory => taxonomyCategory.Name == attributes.category);

                    if (category == null)
                    {
                        category = new TaxonomyCategory
                        {
                            Name          = attributes.category,
                            Protocols     = new List <TaxonomyProtocol>(),
                            SubCategories = new List <TaxonomyCategory>()
                        };

                        this._taxonomies.Add(category);
                    }

                    var subCategory = category.SubCategories.FirstOrDefault(taxonomyCategory => taxonomyCategory.Name == attributes.subcategory);

                    if (subCategory == null)
                    {
                        subCategory = new TaxonomyCategory
                        {
                            Name          = attributes.subcategory,
                            Protocols     = new List <TaxonomyProtocol>(),
                            SubCategories = new List <TaxonomyCategory>()
                        };

                        category.SubCategories.Add(subCategory);
                    }

                    var applicationGroup = subCategory.SubCategories.FirstOrDefault(taxonomyCategory => taxonomyCategory.Name == attributes.applicationgroup);

                    if (applicationGroup == null)
                    {
                        applicationGroup = new TaxonomyCategory
                        {
                            Name          = attributes.applicationgroup,
                            Protocols     = new List <TaxonomyProtocol>(),
                            SubCategories = new List <TaxonomyCategory>()
                        };

                        subCategory.SubCategories.Add(applicationGroup);
                    }

                    var taxProto = new TaxonomyProtocol
                    {
                        Name                = nbarTaxonomy.name,
                        CommonName          = nbarTaxonomy.commonname,
                        Description         = nbarTaxonomy.helpstring,
                        Encrypted           = attributes.encrypted,
                        Tunnel              = attributes.tunnel,
                        UnderLyingProtocols = nbarTaxonomy.underlyingprotocols
                    };


                    foreach (var port in nbarTaxonomy.ports)
                    {
                        if (!string.IsNullOrEmpty(port.tcp))
                        {
                            taxProto.Ports += string.Format("TCP:{0} ", port.tcp);
                        }

                        if (!string.IsNullOrEmpty(port.udp))
                        {
                            taxProto.Ports += string.Format("UDP:{0} ", port.udp);
                        }
                    }

                    applicationGroup.Protocols.Add(taxProto);
                }
            }
        }
 public ReassembledStreamDetailVm(ConversationVm conversation)
 {
     _conversation = conversation;
     DataContext   = _conversation;
 }
Пример #4
0
        private async Task <List <ConversationVm> > GenerateConversationVmsAsync(List <Guid> input)
        {
            var currentUserId = GetUserId();

            var result = new List <ConversationVm>();

            var conversations = await _conversationCtrlAppService.GetByIdsAsync(input);

            #region generate p2p vm
            foreach (var c in conversations.Where(x => x.Type == ConversationType.P2P))
            {
                var vm   = ConversationVm.Create(c);
                var dest = c.Participants.FirstOrDefault(o => !o.Equals(currentUserId));
                var dtos = await _employeeMappingService.ByUserIdAsync(dest);

                vm.Topic = (dtos == null || !dtos.Any()) ? "未知用户" : dtos.First().Name;
                result.Add(vm);
            }
            #endregion

            #region generate customgroup vm
            var ids = new List <Guid>();
            conversations.Where(x => x.Type == ConversationType.CustomGroup).ForEach(x =>
            {
                var vm   = ConversationVm.Create(x);
                vm.Topic = "[未获取到群组名称]";
                result.Add(vm);
                ids.Add(x.Id);
            });
            if (ids.Count > 0)
            {
                var groups = await _groupAppService.GetListByIdsAsync(ids);

                groups.RemoveIfContains(null);
                foreach (var item in groups)
                {
                    var vm = result.Find(x => x.Id == item.Id);
                    vm.Topic = item.Name;
                }
            }
            #endregion

            #region generate departmentgroup vm
            ids = new List <Guid>();
            conversations.Where(x => x.Type == ConversationType.DepartmentGroup).ForEach(x =>
            {
                var vm   = ConversationVm.Create(x);
                vm.Topic = "[未获取到群组名称]";
                result.Add(vm);
                ids.Add(x.Id);
            });
            if (ids.Count > 0)
            {
                var departments = await _departmentAppService.GetListByIdsAsync(ids);

                departments.RemoveIfContains(null);
                foreach (var item in departments)
                {
                    var vm = result.Find(x => x.Id == item.Id);
                    vm.Topic = item.Name;
                }
            }
            #endregion

            return(result);
        }