コード例 #1
0
        public int UpdateDevicePointFolder(DevicePointFolder folder)
        {
            if (folder.id == null && this.db.DevicePointFolder.Any(m => m.DeviceId == folder.DeviceId && m.Name == folder.Name && m.ParentId == folder.ParentId && m.Type == folder.Type))
            {
                throw new Exception("此文件夹已存在");
            }
            else if (folder.id == null && this.db.DevicePointFolder.Any(m => m.id != folder.id && m.DeviceId == folder.DeviceId && m.Name == folder.Name && m.ParentId == folder.ParentId && m.Type == folder.Type))
            {
                throw new Exception("此文件夹已存在");
            }

            this.db.Update(folder);
            return(folder.id.Value);
        }
コード例 #2
0
ファイル: AnalogNode.cs プロジェクト: simpleway2016/SunRiz
        void addFolderClick(object sender, RoutedEventArgs e)
        {
            var inputbox = new Dialogs.InputBox("请输入文件夹名称", "添加文件夹");

            inputbox.Owner = MainWindow.Instance;
            if (inputbox.ShowDialog() == true && !inputbox.Value.IsBlank())
            {
                SunRizServer.DevicePointFolder folder = new DevicePointFolder();
                folder.ParentId = this.FolderModel.id;
                folder.Type     = this.FolderType;
                folder.Name     = inputbox.Value.Trim();
                folder.DeviceId = GetDevice().id;

                MainWindow.Instance.Cursor = Cursors.Hand;
                Helper.Remote.Invoke <int>("UpdateDevicePointFolder", (ret, err) =>
                {
                    MainWindow.Instance.Cursor = null;
                    if (err != null)
                    {
                        MessageBox.Show(MainWindow.Instance, err);
                    }
                    else
                    {
                        folder.id = ret;
                        folder.ChangedProperties.Clear();

                        //添加node对象
                        AnalogNode newNode = null;
                        if (this.FolderType == DevicePointFolder_TypeEnum.Analog)
                        {
                            newNode = new AnalogNode(folder);
                        }
                        else
                        {
                            newNode = new DigitalNode(folder);
                        }
                        newNode.Text = folder.Name;
                        this.Nodes.Insert(0, newNode);
                        this.IsExpanded = true;
                    }
                }, folder);
            }
        }