예제 #1
0
        //将所有父组织list出来
        public string GetOrganizationServer(OrganizationTreeItemViewModel organization)
        {
            if (organization == null)
            {
                return(null);
            }

            if (organization.Parent == null)
            {
                return(organization.ServerIP);
            }

            var parent = organization.Parent;

            while (parent != null)
            {
                if (parent.Parent == null)
                {
                    break;
                }
                parent = parent.Parent;
            }

            return(parent.ServerIP);
        }
예제 #2
0
        public List <OrganizationTreeItemViewModel> GetCopyOrganizations(OrganizationTreeItemViewModel organization, OrganizationTreeItemViewModel parentorganization)
        {
            if (organization == null)
            {
                return(null);
            }
            List <OrganizationTreeItemViewModel> organizationlist = new List <OrganizationTreeItemViewModel>();

            organizationlist.Add(organization);
            if (parentorganization != null)
            {
                organization.T_Organization.CopyTemp(parentorganization.T_Organization);
            }
            else
            {
                organization.T_Organization.CopyTemp(null);
            }

            var childs = GetCopyOrganizations(organization.Children);

            if (childs != null)
            {
                organizationlist.AddRange(childs);
            }
            return(organizationlist);
        }
예제 #3
0
        //将所有父组织list出来
        public string GetOrganizationName(OrganizationTreeItemViewModel organization)
        {
            if (organization == null)
            {
                return(null);
            }

            if (organization.Parent == null)
            {
                return(organization.Name);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append(organization.Name);
            var parent = organization.Parent;

            while (parent != null)
            {
                sb.Insert(0, parent.Name + ">");
                parent = parent.Parent;
            }

            return(sb.ToString());
        }
예제 #4
0
        //将组织树中所有组织list出来
        public List <OrganizationTreeItemViewModel> GetOrganizations(OrganizationTreeItemViewModel organization)
        {
            if (organization == null)
            {
                return(null);
            }
            List <OrganizationTreeItemViewModel> organizationlist = new List <OrganizationTreeItemViewModel>();

            organizationlist.Add(organization);
            var childs = GetOrganizations(organization.Children);

            if (childs != null)
            {
                organizationlist.AddRange(childs);
            }
            return(organizationlist);
        }
예제 #5
0
        public string SameNameChecked(IList <T1_Organization> organizations, OrganizationTreeItemViewModel organization, bool IsNew = false)
        {
            string rename  = organization.Name;
            string newname = rename;
            IEnumerable <string> names;

            if (organization.T_Organization.Level == 0)
            {
                if (IsNew == false)
                {
                    names = organizations.Where(p => p.Level == 0 && p.Guid != organization.T_Organization.Guid).Select(p => p.Name);
                }
                else//特别为Copy节点准备
                {
                    names = organizations.Where(p => p.Level == 0).Select(p => p.Name);
                }
            }
            else
            {
                if (IsNew == false)
                {
                    names = organizations.Where(p => p.Parent_Guid == organization.T_Organization.Parent_Guid && p.Guid != organization.T_Organization.Guid).Select(p => p.Name);
                }
                else//特别为Copy节点准备
                {
                    names = organizations.Where(p => p.Parent_Guid == organization.T_Organization.Parent_Guid).Select(p => p.Name);
                }
            }
            while (true)
            {
                foreach (var name in names)
                {
                    if (name == rename)
                    {
                        newname = rename + "-1";
                        break;
                    }
                }
                if (newname == rename)
                {
                    return(newname);
                }
                rename = newname;
            }
        }
예제 #6
0
        //将组织树中所有设备list出来
        public List <DeviceTreeItemViewModel> GetDevices(OrganizationTreeItemViewModel organization)
        {
            if (organization == null)
            {
                return(null);
            }
            List <DeviceTreeItemViewModel> items = new List <DeviceTreeItemViewModel>();

            if (organization is DeviceTreeItemViewModel && !(organization is ItemTreeItemViewModel) && !(organization is DivFreTreeItemViewModel))
            {
                items.Add(organization as DeviceTreeItemViewModel);
            }
            var childs = GetDevices(organization.Children);

            if (childs != null)
            {
                items.AddRange(childs);
            }

            return(items);
        }
예제 #7
0
        public void GetOrganizationFromDatabase(string ip, bool isadmin)
        {
            var roots = from p in _databaseComponent.GetOrganizationData(ip) where p.Level == 0 && p.Is_Disabled == false orderby p.Sort_No select p;

            foreach (var root in roots.Distinct())//去重复
            {
                if (root.NodeType == 0 && root.Is_Disabled == false)
                {
                    T1_OrganizationPrivilege t_organization = null;
                    if (isadmin == false)
                    {
                        t_organization = (from p in T_OrganizationPrivilege[ip] where p.T_Organization_Guid == root.Guid select p).FirstOrDefault();
                    }
                    if (t_organization != null || isadmin == true)
                    {
                        OrganizationTreeItemViewModel organization = new OrganizationTreeItemViewModel(root, ip);
                        OrganizationTreeItems.Add(organization);
                        GetSubOrganization(organization, ip, isadmin);
                    }
                }
            }

            //新建回收站
            OrganizationTreeItemViewModel recyclednode = new OrganizationTreeItemViewModel("回收站", 0, ip);

            recyclednode.IsExpanded = true;
            RecycledTreeItems.Add(recyclednode);

            //回收站,有问题,htzk123,忘记是否修复了没有
            var recycles = from p in _databaseComponent.GetItemData(ip) where p.Is_Disabled == true orderby p.Modify_Time select p;

            foreach (var recycle in recycles.Distinct())//去重复
            {
                ItemTreeItemViewModel organization = new ItemTreeItemViewModel(recycle);
                recyclednode.AddChild(organization);

                ItemTreeItems.Add(organization);
            }
        }
 public void SelectedTreeChanged(object para)
 {
     if (para is DeviceTreeItemViewModel)
     {
         OrganizationNames    = _cardProcess.GetDevices(para as OrganizationTreeItemViewModel).Select(p => p.FullName).ToList();
         SelectedOrganization = para as OrganizationTreeItemViewModel;
         Refresh();
     }
     else if (para is OrganizationTreeItemViewModel)
     {
         if ((para as OrganizationTreeItemViewModel).Children != null && (para as OrganizationTreeItemViewModel).Children.Count > 0 && (para as OrganizationTreeItemViewModel).Children[0] is DeviceTreeItemViewModel)
         {
             OrganizationNames    = _cardProcess.GetDevices(para as OrganizationTreeItemViewModel).Select(p => p.FullName).ToList();
             SelectedOrganization = para as OrganizationTreeItemViewModel;
             Refresh();
         }
         else
         {
             OrganizationNames = new List <string>();
             Refresh();
         }
     }
 }
예제 #9
0
        //将所有子组织list出来
        public List <T1_Organization> GetChildOrganizations(OrganizationTreeItemViewModel organization)
        {
            if (organization == null)
            {
                return(null);
            }
            List <T1_Organization> organizationlist = new List <T1_Organization>();

            organizationlist.Add(organization.T_Organization);
            if (organization.Children == null || organization.Children.Count == 0)
            {
                return(organizationlist);
            }

            foreach (var child in organization.Children)
            {
                if (child.Children != null)
                {
                    organizationlist.AddRange(GetChildOrganizations(child));
                }
            }

            return(organizationlist);
        }
예제 #10
0
        //将所有父组织list出来
        public List <Organization> GetParentOrganizations(OrganizationTreeItemViewModel organization)
        {
            if (organization == null)
            {
                return(null);
            }
            List <Organization> organizationlist = new List <Organization>();

            organizationlist.Add(OrganizationConvert(organization.T_Organization));
            if (organization.Parent == null)
            {
                return(organizationlist);
            }

            var parent = organization.Parent;

            while (parent != null)
            {
                organizationlist.Add(OrganizationConvert(parent.T_Organization));
                parent = parent.Parent;
            }

            return(organizationlist);
        }
예제 #11
0
        private void getTree()
        {
            node1       = new OrganizationTreeItemViewModel("北京航天智控测试工厂", 0, "192.168.0.210");
            node1_1     = new OrganizationTreeItemViewModel("厂区1", 2, node1);
            node1_2     = new OrganizationTreeItemViewModel("厂区2", 1, node1);
            node1_3     = new OrganizationTreeItemViewModel("厂区3", 0, node1);
            node1_1_1   = new DeviceTreeItemViewModel("设备1", 2, node1_1);
            node1_1_2   = new DeviceTreeItemViewModel("设备2", 1, node1_1);
            node1_1_3   = new DeviceTreeItemViewModel("设备3", 0, node1_1);
            node1_1_1_1 = new ItemTreeItemViewModel("测点1", 2, node1_1_1);
            node1_1_1_2 = new ItemTreeItemViewModel("测点2", 1, node1_1_1);
            node1_1_1_3 = new ItemTreeItemViewModel("测点3", 0, node1_1_1);
            node1_1_2_1 = new ItemTreeItemViewModel("测点4", 2, node1_1_2);
            node1_1_2_2 = new ItemTreeItemViewModel("测点5", 1, node1_1_2);
            node1_1_2_3 = new ItemTreeItemViewModel("测点6", 0, node1_1_2);
            node1_1_3_1 = new ItemTreeItemViewModel("测点7", 2, node1_1_3);
            node1_1_3_2 = new ItemTreeItemViewModel("测点8", 1, node1_1_3);
            node1_1_3_3 = new ItemTreeItemViewModel("测点9", 0, node1_1_3);
            node2       = new OrganizationTreeItemViewModel("测试工厂1", 3, "");
            node3       = new OrganizationTreeItemViewModel("测试工厂2", 2, "");
            node4       = new OrganizationTreeItemViewModel("测试工厂3", 1, "");

            OrganizationTreeItems.Clear();

            List <ItemTreeItemViewModel> item1 = new List <ItemTreeItemViewModel>();

            item1.Add(node1_1_1_1);
            item1.Add(node1_1_1_2);
            item1.Add(node1_1_1_3);
            node1_1_1.AddChildRange(from p in item1 orderby p.T_Organization.Sort_No select p as OrganizationTreeItemViewModel);

            List <ItemTreeItemViewModel> item2 = new List <ItemTreeItemViewModel>();

            item2.Add(node1_1_2_1);
            item2.Add(node1_1_2_2);
            item2.Add(node1_1_2_3);
            node1_1_2.AddChildRange(from p in item2 orderby p.T_Organization.Sort_No select p as OrganizationTreeItemViewModel);

            List <ItemTreeItemViewModel> item3 = new List <ItemTreeItemViewModel>();

            item3.Add(node1_1_3_1);
            item3.Add(node1_1_3_2);
            item3.Add(node1_1_3_3);
            node1_1_3.AddChildRange(from p in item3 orderby p.T_Organization.Sort_No select p as OrganizationTreeItemViewModel);

            List <DeviceTreeItemViewModel> device = new List <DeviceTreeItemViewModel>();

            device.Add(node1_1_1);
            device.Add(node1_1_2);
            device.Add(node1_1_3);
            node1_1.AddChildRange(from p in device orderby p.T_Organization.Sort_No select p as OrganizationTreeItemViewModel);

            List <OrganizationTreeItemViewModel> organization = new List <OrganizationTreeItemViewModel>();

            organization.Add(node1_1);
            organization.Add(node1_2);
            organization.Add(node1_3);
            node1.AddChildRange(from p in organization orderby p.T_Organization.Sort_No select p as OrganizationTreeItemViewModel);

            List <OrganizationTreeItemViewModel> root = new List <OrganizationTreeItemViewModel>();

            root.Add(node1);
            root.Add(node2);
            root.Add(node3);
            root.Add(node4);
            OrganizationTreeItems.AddRange(from p in root orderby p.T_Organization.Sort_No select p);

            RecycledTreeItems.Clear();
            OrganizationTreeItemViewModel recyclednode = new OrganizationTreeItemViewModel("回收站", 0, "192.168.0.1");

            recyclednode.IsExpanded = true;
            RecycledTreeItems.Add(recyclednode);

            //SaveOrganizationToDatabase();
            //SaveItemToDatabase();
        }
예제 #12
0
        private void GetSubOrganization(OrganizationTreeItemViewModel parent_organization, string ip, bool isadmin)
        {
            if (parent_organization == null)
            {
                return;
            }
            var childs = from p in _databaseComponent.GetOrganizationData(ip) where p.Parent_Guid == parent_organization.T_Organization.Guid && p.Is_Disabled == false orderby p.Sort_No select p;

            foreach (var child in childs)
            {
                if (child.NodeType == 0 && child.Is_Disabled == false)
                {
                    T1_OrganizationPrivilege t_organization = null;
                    if (isadmin == false)
                    {
                        t_organization = (from p in T_OrganizationPrivilege[ip] where p.T_Organization_Guid == child.Guid select p).FirstOrDefault();
                    }
                    if (t_organization != null || isadmin == true)
                    {
                        OrganizationTreeItemViewModel organization = new OrganizationTreeItemViewModel(child, parent_organization);
                        //organization.T_Organization = child;
                        parent_organization.AddChild(organization);
                        GetSubOrganization(organization, ip, isadmin);
                    }
                }
                else if (child.NodeType == 1 && child.Is_Disabled == false)
                {
                    T1_OrganizationPrivilege t_organization = null;
                    if (isadmin == false)
                    {
                        t_organization = (from p in T_OrganizationPrivilege[ip] where p.T_Organization_Guid == child.Guid select p).FirstOrDefault();
                    }
                    if (t_organization != null || isadmin == true)
                    {
                        DeviceTreeItemViewModel organization = new DeviceTreeItemViewModel(child, parent_organization);
                        parent_organization.AddChild(organization);

                        GetSubOrganization(organization, ip, isadmin);
                    }
                }
                else if (child.NodeType == 2 && child.Is_Disabled == false)
                {
                    ItemTreeItemViewModel organization = new ItemTreeItemViewModel(child, parent_organization as DeviceTreeItemViewModel);
                    parent_organization.AddChild(organization);
                    //测点数据
                    var t_item = _databaseComponent.GetItemData(ip).Where(p => p.Is_Disabled == false && p.Guid == organization.T_Organization.Guid).FirstOrDefault();
                    if (t_item != null)
                    {
                        organization.RecoverBind(t_item);
                        t_item.ServerIP = parent_organization.ServerIP;//改为初始化时候填充,覆盖数据库的ServerIP。
                        //如果彻底删除此项,必须修改//服务器IP匹配20180306
                    }
                    ItemTreeItems.Add(organization);

                    GetSubOrganization(organization, ip, isadmin);
                }
                else if (child.NodeType == 3 && child.Is_Disabled == false)
                {
                    DivFreTreeItemViewModel organization = new DivFreTreeItemViewModel(child, parent_organization as ItemTreeItemViewModel);

                    //分频数据
                    var t_divfre = T_DivFreInfo[ip].Where(p => p.Guid == organization.T_Organization.Guid).FirstOrDefault();
                    if (t_divfre != null)                           //分频一定不为空
                    {
                        parent_organization.AddChild(organization); //否则丢弃无效分频数据

                        organization.T_DivFreInfo = t_divfre;
                        DivFreTreeItems.Add(organization);

                        //GetSubOrganization(organization, ip, isadmin);//分频下无节点
                    }
                }
            }
        }
예제 #13
0
 public void SelectedTreeChanged(object para)
 {
     selectedOrganization = para as OrganizationTreeItemViewModel;
 }
예제 #14
0
 public ItemTreeItemViewModel GetRecycledItem(string ip, ChannelTreeItemViewModel channeltree, OrganizationTreeItemViewModel recycledTreeItem)
 {
     if (channeltree.IChannel is WirelessVibrationChannelInfo || channeltree.IChannel is WirelessScalarChannelInfo)
     {
         var slaveIdentifier = (channeltree.Parent.Parent as TransmissionCardTreeItemViewModel).TransmissionCard.SlaveIdentifier;
         var slotNum         = (channeltree.Parent as SlotTreeItemViewModel).SlotNum;
         var chNum           = channeltree.CHNum;
         //var channelHDID = ip + "_" + slaveIdentifier + "_" + slotNum + "_" + chNum;
         var channelHDID  = slaveIdentifier.PadLeft(4, '0') + "_" + slotNum + "_" + chNum + "_0" + "@" + ip;
         var recycledItem = recycledTreeItem.Children.Where(p => (p as ItemTreeItemViewModel).T_Item.ChannelHDID == channelHDID).OrderByDescending(p => (p as ItemTreeItemViewModel).T_Item.Modify_Time).Select(p => p as ItemTreeItemViewModel).FirstOrDefault();
         return(recycledItem);
     }
     else
     {
         var cardNum = (channeltree.Parent.Parent as WireMatchingCardTreeItemViewModel).CardNum;
         var slotNum = (channeltree.Parent as SlotTreeItemViewModel).SlotNum;
         var chNum   = channeltree.CHNum;
         //var channelHDID = ip + "_" + cardNum + "_" + slotNum + "_" + chNum;
         var channelHDID  = cardNum.ToString("0000") + "_" + slotNum + "_" + chNum + "_0" + "@" + ip;
         var recycledItem = recycledTreeItem.Children.Where(p => (p as ItemTreeItemViewModel).T_Item.ChannelHDID == channelHDID).OrderByDescending(p => (p as ItemTreeItemViewModel).T_Item.Modify_Time).Select(p => p as ItemTreeItemViewModel).FirstOrDefault();
         return(recycledItem);
     }
 }
예제 #15
0
 public NewEntityRequestContainer(OrganizationTreeItemViewModel Source, EntityTypes Type)
 {
     EventSource = Source;
     EntityType  = Type;
 }