Esempio n. 1
0
        private TreeNode AddDeviceGroupNode(DeviceGroup group)
        {
            TreeNode node = new TreeNode();
            node.Tag = group;

            List<DeviceGroup> children = _Groups.Where(item => item.ParentID == group.ID).ToList();
            if (children != null && children.Count > 0)
            {
                foreach (DeviceGroup child in children)
                {
                    TreeNode dnode = AddDeviceGroupNode(child);
                    FreshNode(dnode);
                    node.Nodes.Add(dnode);
                    _AllGroupNodes.Add(dnode);
                }
            }
            if (_Devices != null && _Devices.Count > 0)
            {
                foreach (DeviceInfo device in _Devices)
                {
                    if (device.GroupID == group.ID)
                    {
                        TreeNode unode = new TreeNode(device.Name);
                        unode.Tag = device;
                        FreshNode(unode);
                        node.Nodes.Add(unode);
                        _AllDeviceNodes.Add(unode);
                    }
                }
            }
            return node;
        }
Esempio n. 2
0
 public CommandResult Delete(DeviceGroup info)
 {
     List<DeviceGroup> depts = ProviderFactory.Create<IDeviceGroupProvider>(_RepoUri).GetItems(null).QueryObjects;
     IUnitWork unitWork = ProviderFactory.Create<IUnitWork>(_RepoUri);
     foreach (DeviceGroup dept in depts.Where(item => item.ID.IndexOf(info.ID, 0) == 0))
     {
         ProviderFactory.Create<IDeviceGroupProvider>(_RepoUri).Delete(dept, unitWork);
     }
     return unitWork.Commit();
 }
Esempio n. 3
0
 public CommandResult Update(DeviceGroup info)
 {
     DeviceGroup original = ProviderFactory.Create<IDeviceGroupProvider>(_RepoUri).GetByID(info.ID).QueryObject;
     if (original != null)
     {
         return ProviderFactory.Create<IDeviceGroupProvider>(_RepoUri).Update(info, original);
     }
     else
     {
         return new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord));
     }
 }
Esempio n. 4
0
 public CommandResult Add(DeviceGroup info)
 {
     string id = ProviderFactory.Create<IStringIDCreater>(_RepoUri).CreateID("G", 3, "DeviceGroup");
     if (!string.IsNullOrEmpty(id))
     {
         info.ID = id;
         return ProviderFactory.Create<IDeviceGroupProvider>(_RepoUri).Insert(info);
     }
     else
     {
         return new CommandResult(ResultCode.Fail, "创建ID失败");
     }
 }
 protected override Object GetItemFromInput()
 {
     DeviceGroup info;
     if (UpdatingItem == null)
     {
         info = new DeviceGroup();
         info.ParentID = ParentGroup != null ? ParentGroup.ID : null;
     }
     else
     {
         info = UpdatingItem as DeviceGroup;
     }
     info.Name = txtDeptName.Text;
     info.Memo = txtMemo.Text;
     return info;
 }