public void RefreshUI(OneConfigJsonVO vo)
 {
     GrpConfig.Text     = vo.Remark;
     LblServerPath.Text = vo.GetServerUploadFolderPath();
     if (string.IsNullOrEmpty(vo.LocalFolderPath) == false)
     {
         TxtLocalFolderPath.Text = vo.LocalFolderPath;
     }
 }
        public ViewConfigUserControl(MainForm parentForm, OneConfigJsonVO vo)
        {
            _ParentForm          = parentForm;
            _CurrentConfigJsonVO = vo;

            InitializeComponent();
            TxtLocalFolderPath.DragEnter += new DragEventHandler(Utils.TextBoxDragEnter);
            TxtLocalFolderPath.DragDrop  += new DragEventHandler(Utils.TextBoxOneDirDragDrop);

            RefreshUI(vo);
        }
 public void RefreshUI(OneConfigJsonVO vo)
 {
     TxtRemark.Text = vo.Remark;
     if (string.IsNullOrEmpty(vo.Host))
     {
         _SetHostTips(true);
     }
     else
     {
         TxtHost.Text = vo.Host;
         _SetHostTips(false);
     }
     TxtUsername.Text         = vo.Username;
     TxtPassword.Text         = vo.Password;
     TxtServerFolderPath.Text = vo.ServerFolderPath;
     if (string.IsNullOrEmpty(vo.LocalFolderPath) == false)
     {
         TxtLocalFolderPath.Text = vo.LocalFolderPath;
     }
 }
예제 #4
0
 static Test()
 {
     _TestConfigList = new List <OneConfigJsonVO>();
     {
         OneConfigJsonVO vo = new OneConfigJsonVO();
         vo.Host             = "127.0.0.1";
         vo.Remark           = "test1";
         vo.LocalFolderPath  = null;
         vo.ServerFolderPath = "/res/";
         vo.Username         = "******";
         vo.Password         = "******";
         _TestConfigList.Add(vo);
     }
     {
         OneConfigJsonVO vo = new OneConfigJsonVO();
         vo.Host             = "127.0.0.1";
         vo.Remark           = "test2";
         vo.LocalFolderPath  = @"D:\zhangqi\";
         vo.ServerFolderPath = "/res_temp/";
         vo.Username         = "******";
         vo.Password         = "******";
         _TestConfigList.Add(vo);
     }
 }
        private ConfigFileVO _CheckAndGetConfigs(out string errorInfo)
        {
            ConfigFileVO vo = new ConfigFileVO();

            if (_EditConfigUserControlList.Count < 1)
            {
                errorInfo = "当前没有任何配置";
                return(null);
            }

            /**
             * 使用者密码
             */
            string inputViewPassword = TxtViewPassword.Text.Trim();

            if (string.IsNullOrEmpty(inputViewPassword))
            {
                errorInfo = "未输入使用者密码";
                return(null);
            }
            vo.ViewPassword = inputViewPassword;

            /**
             * 编辑密码
             */
            string inputEditPassword = TxtEditPassword.Text.Trim();

            if (string.IsNullOrEmpty(inputEditPassword))
            {
                errorInfo = "未输入管理员密码";
                return(null);
            }
            vo.EditPassword = inputEditPassword;
            if (inputViewPassword.Equals(inputEditPassword))
            {
                errorInfo = "管理员密码不能与使用者密码相同";
                return(null);
            }

            /**
             * 检查每一个配置项
             */
            bool          isAllConfigCheckOk = true;
            StringBuilder errorStringBuilder = new StringBuilder();

            for (int i = 0; i < _EditConfigUserControlList.Count; i++)
            {
                string          oneConfigErrorInfo = null;
                OneConfigJsonVO oneConfigVO        = _EditConfigUserControlList[i].CheckAndGetConfig(out oneConfigErrorInfo);
                if (oneConfigVO == null)
                {
                    isAllConfigCheckOk = false;
                    errorStringBuilder.AppendLine($"第{i + 1}个配置项存在错误:{oneConfigErrorInfo}");
                }
                vo.AllConfigs.Add(oneConfigVO);
            }
            if (isAllConfigCheckOk == false)
            {
                errorInfo = errorStringBuilder.ToString();
                return(null);
            }

            errorInfo = null;
            return(vo);
        }
        public OneConfigJsonVO CheckAndGetConfig(out string errorInfo)
        {
            OneConfigJsonVO vo          = new OneConfigJsonVO();
            string          inputRemark = TxtRemark.Text.Trim();

            if (string.IsNullOrEmpty(inputRemark))
            {
                errorInfo = "未输入备注名称";
                return(null);
            }
            vo.Remark = inputRemark;
            string inputHost = TxtHost.Text.Replace(_HOST_TIPS, string.Empty).Trim();

            if (string.IsNullOrEmpty(inputHost))
            {
                errorInfo = "未输入Host";
                return(null);
            }
            vo.Host = inputHost;
            string inputUsername = TxtUsername.Text.Trim();

            if (string.IsNullOrEmpty(inputUsername))
            {
                errorInfo = "未输入用户名";
                return(null);
            }
            vo.Username = inputUsername;
            string inputPassword = TxtPassword.Text.Trim();

            if (string.IsNullOrEmpty(inputPassword))
            {
                errorInfo = "未输入密码";
                return(null);
            }
            vo.Password = inputPassword;
            string inputServerFolderPath = TxtServerFolderPath.Text.Trim();

            if (string.IsNullOrEmpty(inputServerFolderPath))
            {
                errorInfo = "未输入服务器上传目录的路径";
                return(null);
            }
            vo.ServerFolderPath = inputServerFolderPath;
            // 本地路径中的“/”换成“\”,并在最后加上“\”
            vo.LocalFolderPath = TxtLocalFolderPath.Text.Trim().Replace("/", "\\");
            if (string.IsNullOrEmpty(vo.LocalFolderPath) == false && vo.LocalFolderPath.EndsWith("\\") == false)
            {
                vo.LocalFolderPath += "\\";
            }

            // 把所有的“\”换成“/”
            vo.Host             = vo.Host.Replace("\\", "/");
            vo.ServerFolderPath = vo.ServerFolderPath.Replace("\\", "/");

            // 将Host后面的“/”去掉
            while (vo.Host[vo.Host.Length - 1] == '/')
            {
                vo.Host = vo.Host.Substring(0, vo.Host.Length - 1);
            }
            // ServerFolderPath前后都加上“/”
            if (vo.ServerFolderPath.StartsWith("/") == false)
            {
                vo.ServerFolderPath = "/" + vo.ServerFolderPath;
            }
            // ServerFolderPath后面加上“/”
            if (vo.ServerFolderPath.EndsWith("/") == false)
            {
                vo.ServerFolderPath += "/";
            }

            errorInfo = null;
            return(vo);
        }
 public EditConfigUserControl(ConfigFileEditorForm parentForm, OneConfigJsonVO vo) : this(parentForm)
 {
     RefreshUI(vo);
 }