Пример #1
0
 public NovelRequestHandler(ProxyInfo proxy, DelayInfo delay)
 {
     base.LogFile = Constants.FILE_LOG;
     base.Proxy = proxy;
     base.Delay = delay;
     base.Initial();
 }
Пример #2
0
        public static DelayInfo GetDelay()
        {
            DelayInfo delay = new DelayInfo();
            delay.DelayedTime = DataConvert.GetInt32(Properties.Settings.Default.DelayedTime);
            delay.TimeOut = DataConvert.GetInt32(Properties.Settings.Default.TimeOut);
            delay.TryTimes = DataConvert.GetInt32(Properties.Settings.Default.TryTimes);

            return delay;
        }
Пример #3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtDelayedTime.Text != string.Empty && !DataValidation.IsNaturalNumber(txtDelayedTime.Text))
                {
                    MessageBox.Show("延迟时间必须为整数!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtDelayedTime.Select();
                    return;
                }

                if (DataValidation.IsNullOrEmpty(txtTimeOut.Text) || !DataValidation.IsNaturalNumber(txtTimeOut.Text))
                {
                    MessageBox.Show("超时时间不能为空且必须是整数!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtTimeOut.Select();
                    return;
                }

                if (DataValidation.IsNullOrEmpty(txtTryTimes.Text) || !DataValidation.IsNaturalNumber(txtTryTimes.Text) || DataConvert.GetInt32(txtTryTimes.Text) < 1)
                {
                    MessageBox.Show("尝试次数必须为大于1的整数!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtTryTimes.Select();
                    return;
                }

                DelayInfo delay = new DelayInfo();

                if (txtDelayedTime.Text != string.Empty)
                    delay.DelayedTime = DataConvert.GetInt32(txtDelayedTime.Text);
                else
                    delay.DelayedTime = null;

                delay.TimeOut = DataConvert.GetInt32(txtTimeOut.Text);
                delay.TryTimes = DataConvert.GetInt32(txtTryTimes.Text);

                if (!ConfigCtrl.SetDelay(delay))
                {
                    MessageBox.Show("保存失败!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                Program.ShowMessageBox("DlgDelaySetting", ex);
            }
        }
Пример #4
0
        public static bool SetDelay(DelayInfo delay)
        {
            try
            {
                XmlDocument objXmlDoc = GetMainConfigFile();
                if (objXmlDoc == null)
                    return false;

                XmlNode nodeRoot = objXmlDoc.SelectSingleNode(Constants.CONFIG_ROOT);
                XmlNode objNode = GetAppendNode(nodeRoot, objXmlDoc, Constants.CONFIG_DELAY, "");

                GetAppendNode(objNode, objXmlDoc, Constants.DELAY_DELAYEDTIME, "0").InnerText = DataConvert.GetString(delay.DelayedTime);
                GetAppendNode(objNode, objXmlDoc, Constants.DELAY_TIMEOUT, "30").InnerText = DataConvert.GetString(delay.TimeOut);
                GetAppendNode(objNode, objXmlDoc, Constants.DELAY_TRYTIMES, "3").InnerText = DataConvert.GetString(delay.TryTimes);

                return SetMainConfigFile(objXmlDoc);
            }
            catch (Exception ex)
            {
                LogHelper.Write("ConfigCtrl.SetDelay()", ex);
                return false;
            }
        }
Пример #5
0
        public static DelayInfo GetDelay()
        {
            try
            {
                XmlDocument objXmlDoc = GetMainConfigFile();
                if (objXmlDoc == null)
                    return null;

                XmlNode nodeRoot = objXmlDoc.SelectSingleNode(Constants.CONFIG_ROOT);
                XmlNode objNode = GetAppendNode(nodeRoot, objXmlDoc, Constants.CONFIG_DELAY, "");

                DelayInfo delay = new DelayInfo();
                delay.DelayedTime = DataConvert.GetInt32(GetAppendNode(objNode, objXmlDoc, Constants.DELAY_DELAYEDTIME, "0").InnerText);
                delay.TimeOut = DataConvert.GetInt32(GetAppendNode(objNode, objXmlDoc, Constants.DELAY_TIMEOUT, "30").InnerText);
                delay.TryTimes = DataConvert.GetInt32(GetAppendNode(objNode, objXmlDoc, Constants.DELAY_TRYTIMES, "3").InnerText);

                return delay;
            }
            catch (Exception ex)
            {
                LogHelper.Write("ConfigCtrl.GetDelay()", ex);
                throw;
            }
        }