private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            scanstarttext = ScanIPStarttextBox_1.Text + "." + ScanIPStarttextBox_2.Text + "." + ScanIPStarttextBox_3.Text + "." + ScanIPStarttextBox_4.Text;
            scanendtext   = ScanIPEndtextBox_1.Text + "." + ScanIPEndtextBox_2.Text + "." + ScanIPEndtextBox_3.Text + "." + ScanIPEndtextBox_4.Text;
            IPAddress ip;

            if (IPAddress.TryParse(scanstarttext, out ip) && IPAddress.TryParse(scanendtext, out ip))
            {
                if ((Convert.ToInt16(ScanIPStarttextBox_1.Text) == Convert.ToInt16(ScanIPEndtextBox_1.Text)) && (Convert.ToInt16(ScanIPStarttextBox_2.Text) == Convert.ToInt16(ScanIPEndtextBox_2.Text)) && (Convert.ToInt16(ScanIPStarttextBox_3.Text) == Convert.ToInt16(ScanIPEndtextBox_3.Text)) && (Convert.ToInt16(ScanIPStarttextBox_4.Text) <= Convert.ToInt16(ScanIPEndtextBox_4.Text)))
                {
                    //将设备扫描范围存入配置文件
                    XmlSerializationHelper configContext = new XmlSerializationHelper("Config");
                    GlobalConfig           globalconfig  = configContext.Get <GlobalConfig>();
                    string Awarry = globalconfig.ScanIPConfig[0].scanip;
                    globalconfig.ScanIPConfig[0].scanip = Awarry + "+" + scanstarttext + "-" + scanendtext;
                    configContext.Save(globalconfig);
                    StaticGlobal.ScanIP = globalconfig.ScanIPConfig[0].scanip;
                    this.Close();
                }
                else
                {
                    UserMessageBox.Show("提示", "请输入正确的范围!");
                }
            }
            else
            {
                UserMessageBox.Show("提示", "请输入正确的IP!");
            }
        }
示例#2
0
        /// <summary>
        /// 查询短信余额
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsmiSmsBalance_Click(object sender, EventArgs e)
        {
            int res = SMSHelper.Instance.GetSMSBalance();

            if (res < 0)
            {
                if (res == -1)
                {
                    UserMessageBox.MessageError("错误,账户为空");
                }

                if (res == -2)
                {
                    UserMessageBox.MessageError("错误,密码为空");
                }

                if (res == -3)
                {
                    UserMessageBox.MessageError("错误,企业ID为空");
                }
                else
                {
                    UserMessageBox.MessageError("错误,查询失败!\r\n返回码未知:" + res);
                }
            }
            else
            {
                UserMessageBox.MessageInfo(string.Format("短信剩余{0}条", res));
            }
        }
示例#3
0
 private void UserMessageBox_Click(object sender, EventArgs e)
 {
     if (UserMessageBox.Text.Equals("Enter your message . . ."))
     {
         UserMessageBox.Clear();
     }
 }
示例#4
0
        void btnOK_Click(object sender, EventArgs e)
        {
            if (!CheckInput())
            {
                return;
            }
            ConfigHelper.UpdateConfig("IPAddress", combIP.SelectedItem.ToString(), true);
            ConfigHelper.UpdateConfig("Port", txtPort.Text, true);
            ConfigHelper.UpdateConfig("DataType", combDBType.Text, true);
            ConfigHelper.UpdateConfig("DataIP", txtDataIp.Text, true);
            ConfigHelper.UpdateConfig("DataName", txtDataName.Text, true);
            ConfigHelper.UpdateConfig("DName", txtDName.Text, true);
            ConfigHelper.UpdateConfig("DPwd", txtPwd.Text, true);
            ConfigHelper.UpdateConfig("DataPort", txtDataPort.Text, true);

            bool suc = TmoConfigManager.Instance.CheckConnection();

            if (suc)
            {
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                DialogResult dr = UserMessageBox.MessageInfo("无法测试数据库连接字符串是否正确!");
                if (dr == System.Windows.Forms.DialogResult.OK)
                {
                    this.DialogResult = DialogResult.OK;
                }
            }
        }
示例#5
0
        /// <summary>
        /// 关闭服务器点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsmiExit_Click(object sender, EventArgs e)
        {
            DialogResult dgr = UserMessageBox.MessageQuestion("确定要关闭服务器吗?\r\n关闭后所有客户端将无法使用");

            if (dgr == System.Windows.Forms.DialogResult.OK)
            {
                exitApp = true;
                StopServices(false); //停止服务(不能用异步)
                this.Close();
            }
        }
示例#6
0
        private void SendMessageBtn_Click(object sender, EventArgs e)
        {
            string message = UserMessageBox.Text.Trim(' ', '\n');

            if (message.Contains('\n'))
            {
                message = "\n" + message;
            }
            Client.WriteMessage(Client.Name + ": " + message);
            UserMessageBox.Clear();
        }
示例#7
0
        public static void Main(string[] args)
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                Application.ThreadException += Application_ThreadException;

                DevExpress.Skins.SkinManager.EnableFormSkins();
                TmoSkin.TSCommon.SetSkin("Office 2013");

                bool createNew;//只允许一个实例运行
                using (Mutex mutex = new Mutex(true, Application.ProductName, out createNew))
                {
                    if (createNew)
                    {
                        if (args.Length == 0)
                        {
                            string upresult = ReflectHelper.InvokeStaticMethod("Update.exe", "Common", "CheckUpdate", null).ToString();
                            if (upresult.StartsWith("err_"))
                            {
                                UserMessageBox.MessageError("检查更新失败!\n" + upresult);
                            }
                            else
                            {
                                if (upresult.ToLower() != "noupdate")
                                {
                                    ProcessStartInfo ps = new ProcessStartInfo();
                                    ps.UseShellExecute = false;
                                    ps.FileName        = "Update.exe";
                                    ps.Arguments       = upresult;
                                    Process.Start(ps);
                                    return;
                                }
                            }
                        }
                        Application.Run(new FormMain());
                    }
                    else
                    {
                        MessageBox.Show("别着急,移动设备数据同步工具已经打开 … ", "^_^", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Thread.Sleep(1000);
                        Environment.Exit(1);
                    }
                }
            }
            catch (Exception ex)
            {
                UserMessageBox.MessageError("启动程序出错\n" + ex.Message);
            }
        }
示例#8
0
        void btnClearCache_Click(object sender, EventArgs e)
        {
            //MemoryCacheHelper.GetCacheItem<string>("test", () => "testdata", DateTime.Now.AddHours(1));
            bool suc = MemoryCacheHelper.ClearCache();

            if (suc)
            {
                UserMessageBox.MessageInfo("缓存清理成功");
            }
            else
            {
                UserMessageBox.MessageError("缓存清理失败");
            }
        }
示例#9
0
        private void UserMessageBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (UserMessageBox.Text.Equals("!clear"))
                {
                    MessageArea.Clear();
                }
                else
                {
                    Network.Send(UserMessageBox.Text);
                }

                UserMessageBox.Clear();
            }
        }
示例#10
0
        //AB - Method used upon creation and first run of the form.
        private void ChatroomForm_Shown(object sender, EventArgs e)
        {
            //AB - Inputs a first message to the chat bot telling it the Users name.
            string  FirstMessageToBot = "my name is " + Program.UserName;
            Request r   = new Request(FirstMessageToBot, Program.myUser, Program.myBot);
            Result  res = Program.myBot.Chat(r);

            //AB - Causes chatbot to wait briefly before sending the first message.
            isTyping(res.Output);

            //AB - Outputs the first sentence from the chatbot.
            ConversationBox.Items.Add("Marvin: " + res.Output);

            //AB & ABo - Cursor starts in the text box.
            UserMessageBox.SelectionStart = UserMessageBox.Text.Length;
            UserMessageBox.Focus();
        }
示例#11
0
        /// <summary>
        /// 发送消息 到指定的客户端
        /// </summary>
        private void btnSend_Click(object sender, EventArgs e)
        {
            TCPServerClient client = lbClientList.SelectedItem as TCPServerClient;

            if (client != null)
            {
                string        data  = txtCmdTxt.Text.Trim();
                List <string> datas = StringPlus.GetStrArray(data, ";");
                if (datas.Count < 2)
                {
                    if (string.IsNullOrWhiteSpace(datas[0]))
                    {
                        UserMessageBox.MessageError("发送内容不能为空!");
                        return;
                    }

                    bool suc = client.SendString(datas[0]);
                    if (!suc)
                    {
                        UserMessageBox.MessageError("发送失败");
                    }
                }
                else
                {
                    if (!TmoShare.IsNumricForInt(datas[0]))
                    {
                        UserMessageBox.MessageError("命令ID必须为整数");
                        return;
                    }

                    bool suc = client.SendCommand(int.Parse(datas[0]), datas[1]);
                    if (!suc)
                    {
                        UserMessageBox.MessageError("发送失败");
                    }
                }
            }
            else
            {
                UserMessageBox.MessageInfo("请选择要发送的客户端");
            }
        }
示例#12
0
 private bool CheckInput()
 {
     try
     {
         string IpCheck = @"^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$";
         if (Convert.ToInt32(txtPort.Text) > 65535 || Convert.ToInt32(txtPort.Text) < 0)
         {
             TmoCommon.UserMessageBox.MessageInfo("请正确添写端口号(范围:0-65535)");
             return(false);
         }
         if (txtDataIp.Text.ToLower() != "localhost" && !Regex.IsMatch(txtDataIp.Text.Trim(), IpCheck))
         {
             UserMessageBox.MessageInfo("数据库连接IP地址格式错误!");
             txtDataIp.Focus();
             return(false);
         }
         return(true);
     }
     catch (Exception ex)
     {
         UserMessageBox.MessageInfo(ex.Message);
         return(false);
     }
 }
示例#13
0
        /// <summary>
        /// 启动服务
        /// </summary>
        /// <returns></returns>
        public bool StartServices()
        {
            if (start)
            {
                return(true); //阻止重复启动
            }
            isTcp = false;    //ConfigHelper.GetConfigBool("ServiceMode", false, true);

            #region 注册前先关闭通道

            try
            {
                if (_serviceHost != null)
                {
                    _serviceHost.CloseAsync().Wait();
                    _serviceHost.Dispose();
                }
            }
            catch
            {
            }

            #endregion

            try
            {
                string port = ConfigHelper.GetConfigString("Port");
                string ip   = ConfigHelper.GetConfigString("IPAddress");
                lblServerAddr.Text = ip + ":" + port;
                Uri baseAddress = new Uri($"http://{ip}:{port}");
                var config      = new HttpSelfHostConfiguration(baseAddress);
                config.Routes.MapHttpRoute("API Default", ServicePath + "/{controller}/{action}/{id}", new { id = RouteParameter.Optional });
                config.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
                config.Formatters.JsonFormatter.MediaTypeMappings.Add(new QueryStringMapping("datatype", "json", "application/json"));
                config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new DefaultContractResolver()
                {
                    IgnoreSerializableAttribute = true
                };
                config.MaxReceivedMessageSize = 20480000;

                _serviceHost = new HttpSelfHostServer(config);
                _serviceHost.OpenAsync().Wait();

                start = true; //标记已启动

                lblStatus.Text      = "已启动...";
                lblStatus.ForeColor = Color.Green;
                return(true);
            }
            catch (System.Runtime.InteropServices.ExternalException ex)
            {
                if (ex.ErrorCode == 10048)
                {
                    UserMessageBox.MessageInfo("服务器端口已被占用,无法启动程序!");
                }
                if (ex.ErrorCode == 10049)
                {
                    UserMessageBox.MessageInfo("本机IP地址配置错误,无法启动程序!");
                }

                LogHelper.Log.Error(ex);
            }
            catch (Exception ex)
            {
                LogHelper.Log.Error($"启动{ServiceName}失败", ex);
            }

            return(false);
        }