public GoalWeightStatisticsHomepageController(ServerIP IPConfig, JsonStructure jsonStructureConfig,
                                               ChartHomepageInfo homepageChartInfo)
     : base(IPConfig, jsonStructureConfig, homepageChartInfo,
            new GoalWeightController(IPConfig, jsonStructureConfig),
            new WeightController(IPConfig, jsonStructureConfig))
 {
 }
 public GoalStepsDailyStatisticsHomepageController(ServerIP IPConfig, JsonStructure jsonStructureConfig,
                                                   ChartHomepageInfo homepageChartInfo)
     : base(IPConfig, jsonStructureConfig, homepageChartInfo,
            new GoalStepsDailyController(IPConfig, jsonStructureConfig),
            new ActivitySummaryStepsController(IPConfig, jsonStructureConfig))
 {
 }
Beispiel #3
0
 public void Save(XmlTextWriter xml)
 {
     xml.WriteStartElement("sender");
     xml.WriteAttributeString("serverIP", ServerIP.ToString());
     xml.WriteAttributeString("serverPort", ServerPort.ToString());
     xml.WriteEndElement();
 }
 public GoalCaloriesStatisticsHomepageController(ServerIP IPConfig, JsonStructure jsonStructureConfig,
                                                 ChartHomepageInfo homepageChartInfo)
     : base(IPConfig, jsonStructureConfig, homepageChartInfo,
            new GoalCaloriesOutController(IPConfig, jsonStructureConfig),
            new ActivitySummaryCaloriesController(IPConfig, jsonStructureConfig))
 {
 }
Beispiel #5
0
 public GoalStatisticsController(ServerIP IPConfig, JsonStructure jsonStructureConfig,
                                 BaseJsonReadController <TModelGoal> goalController,
                                 BaseJsonReadController <TModelRealData> realDataController)
     : base(IPConfig, jsonStructureConfig)
 {
     GoalController     = goalController;
     RealDataController = realDataController;
 }
Beispiel #6
0
 public BaseJsonController(ServerIP IPConfig, JsonStructure jsonStructureConfig, JsonData jsonDataConfig)
     : base(IPConfig)
 {
     JsonStructureConfig  = jsonStructureConfig;
     QueryParamsConfig    = jsonStructureConfig.QueryParams;
     AdditionalPathConfig = jsonStructureConfig.AdditionalPath;
     JsonDataConfig       = jsonDataConfig;
 }
 public AdminAuthenticationController(string connectionString, ServerIP IPConfig, JsonStructure jsonStructureConfig, MailData mailData)
     : base(IPConfig, jsonStructureConfig, jsonStructureConfig.Patient)
 {
     DoctorController            = new DoctorController(IPConfig, jsonStructureConfig);
     PatientCollectionController = new PatientController(IPConfig, jsonStructureConfig);
     ConnectionString            = connectionString;
     MailData = mailData;
 }
Beispiel #8
0
 public MQTTController(ServerIP IPConfig, JsonStructure jsonStructureConfig, IHubContext <MqttHub> hubContext)
     : base(IPConfig)
 {
     JsonStructureConfig   = jsonStructureConfig;
     WeightConfig          = jsonStructureConfig.Weight;
     ActivitySummaryConfig = jsonStructureConfig.ActivitySummary;
     HubContext            = hubContext;
 }
Beispiel #9
0
        //登录
        private void button1_Click(object sender, EventArgs e)
        {
            string username = textBox1.Text.Trim();
            string password = textBox2.Text.Trim();

            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                MessageBox.Show("请输入完整信息");
                return;
            }

            if (access.SearchUserID(username) < 0)
            {
                MessageBox.Show("用户不存在!");
                return;
            }

            if (password != access.GetUserPassword(username))
            {
                MessageBox.Show("密码错误!", "错误");
                return;
            }

            var userVector    = timeline.ToVector();
            var storedVectors = access.FetchKeyboardVectors(username);

            if (!Verifier.Verify(userVector, storedVectors))
            {
                MessageBox.Show("键盘特征非用户本人!", "错误");
                InitializeKeyboardVariable();
                textBox2.Clear();
                textBox2.Focus();
                return;
            }

            access.InsertKeyboardData(username, userVector);

#if KEYBOARD_DEBUG
            MessageBox.Show("OK!");
            InitializeKeyboardVariable();
            return;
#endif

            //构造登录信息
            LoginModel loginModel = new LoginModel();
            loginModel.username = username;
            loginModel.password = password;

            //发送登录信息
            MyMessage loginMsg = new MyMessage();
            loginMsg.from       = username;
            loginMsg.to         = "server";
            loginMsg.type       = "login";
            loginMsg.loginModel = loginModel;

            server.sendMsg(loginMsg, ServerIP.getServerIPEndPoint());
        }
 public GoalStatisticsHomepageAbstractController(ServerIP IPConfig, JsonStructure jsonStructureConfig,
                                                 ChartHomepageInfo homepageChartInfo,
                                                 BaseJsonReadController <TModelGoal> goalController,
                                                 BaseJsonReadController <TModelRealData> realDataController)
     : base(IPConfig, jsonStructureConfig)
 {
     GoalController     = goalController;
     RealDataController = realDataController;
     HomepageChartInfo  = homepageChartInfo.GeneralChartInfo;
 }
Beispiel #11
0
        /// <summary>
        /// update the source.
        /// </summary>
        public void BindingUpdateSource()
        {
            BindingExpression be = ServerIP.GetBindingExpression(UCTextField.ValueProperty);

            be.UpdateSource();
            be = ServerPort.GetBindingExpression(UCTextField.ValueProperty);
            be.UpdateSource();
            be = MazeRows.GetBindingExpression(UCTextField.ValueProperty);
            be.UpdateSource();
            be = MazeCols.GetBindingExpression(UCTextField.ValueProperty);
            be.UpdateSource();
        }
Beispiel #12
0
        /// <summary>
        /// Start connect to the server.
        /// </summary>
        public void StartConnectToServer()
        {
            if (ServerIP == null)
            {
                log.Warn("Client has no configured IP adress");
                log.Warn("Client cannot connect to the server. Please open the clientSocket configuration and enter the clientSocket IP");
            }

            try
            {
                // Creates one SocketPermission object for access restrictions
                SocketPermission permission = new SocketPermission(
                    NetworkAccess.Connect,    // Allowed to accept connections
                    TransportType.Tcp,        // Defines transport types
                    ServerIP.ToString(),      // The IP addresses of local host
                    SocketPermission.AllPorts // Specifies all ports
                    );

                // Ensures the code to have permission to access a Socket
                permission.Demand();

                // Remote endpoint is the server
                IPEndPoint remoteEP = new IPEndPoint(ServerIP, ServerPort);

                // Create a TCP/IP socket
                // Using IPv4 as the network protocol
                _clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                // Begin to connect to the server.
                _clientSocket.BeginConnect(remoteEP, new AsyncCallback(this.ConnectCallback), _clientSocket);

                // Wait until the connection is done
                connectDone.WaitOne();

                // Start method which checks periodically if the Socket is still connected
                new Thread(() => SocketConnected(_clientSocket))
                {
                    IsBackground = true
                }.Start();

                this.IsSocketConnected = true;

                // Begin to wait for logs request signal from the server.
                new SychronousClientFunctions(_clientSocket).WaitForSignal();
            }
            catch (Exception ex)
            {
                log.Info(ex.Message, ex);
            }
        }
Beispiel #13
0
        public void sendHeartBeatMsg()
        {
            MyMessage heartBeatMsg = new MyMessage();

            heartBeatMsg.from    = currentUsername;
            heartBeatMsg.to      = "server";
            heartBeatMsg.type    = "heart";
            heartBeatMsg.content = "heart";

            while (true)
            {
                sendMsg(heartBeatMsg, ServerIP.getServerIPEndPoint());
                Thread.Sleep(HEART_BEAT_SLEEP_TIME);
            }
        }
Beispiel #14
0
        public static string GetIp(ServerIP srv)
        {
            switch (srv)
            {
            case ServerIP.ServerUniversal:
                return("192.168.1.104");

            case ServerIP.ServerDebug:
                return("127.0.0.1");

            case ServerIP.ServerClient:
                return("35.160.15.132");

            default:
                return("");
            }
        }
Beispiel #15
0
        public void Start()
        {
            #region Чтение IP-адреса сервера

            string SettingsFileName = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + @"\serverip.txt";
            SettingsFileName = SettingsFileName.Replace("file:\\", string.Empty);

            if (!File.Exists(SettingsFileName))
            {
                MessageBox.Show(string.Format("Не найден файл настроек [{0}]\r\n\r\nПриложение будет закрыто!", SettingsFileName));
                Application.Exit();
                return;
            }

            StreamReader SettingsFile = File.OpenText(SettingsFileName);

            string ServerIP;

            while ((ServerIP = SettingsFile.ReadLine()) != null)
            {
                if (ServerIP.Trim() != string.Empty)
                {
                    break;
                }
            }
            SettingsFile.Close();

            #endregion
            //ConnectionAgent = new ServerAgent("192.168.100.254", 8609, this, MainForm.DrawConnectionStatus, MainForm.ShowPingResult);

            try
            {
                ConnectionAgent = new ServerAgent(ServerIP, 8609, this, MainForm.DrawConnectionStatus, MainForm.ShowPingResult);
            }
            catch (Exception exp)
            {
                MessageBox.Show(string.Format("Ошибка создания агента сервера. Server IP = {0}\r\nОписание ошибки:\r\n{1}\r\nПриложение будет закрыто!", ServerIP, exp.Message));
                Application.Exit();
            }
            MainForm.ServerIP = ServerIP;

            StartConnectionAgent();

            Welcome();
        }
Beispiel #16
0
    // Start is called before the first frame update
    void Awake()
    {
        instance = this;
        var options = new List <Dropdown.OptionData>();

        foreach (var one in ipList)
        {
            options.Add(new Dropdown.OptionData(one.name + "   " + one.ip + ""));
        }
        var ips = GetComponent <Dropdown>();

        ips.options = options;
        if (defaultIpIndex < 0 || defaultIpIndex >= options.Count)
        {
            defaultIpIndex = 0;
        }
        ips.value = defaultIpIndex;
    }
Beispiel #17
0
 public bool IsValid()
 {
     if (!string.IsNullOrWhiteSpace(ServerName) &&
         !string.IsNullOrWhiteSpace(ServerClient) &&
         !string.IsNullOrWhiteSpace(ServerIP) &&
         !string.IsNullOrWhiteSpace(ServerPort.ToString()) &&
         !string.IsNullOrWhiteSpace(ServerVersion) &&
         GlobalFuncs.IsClientValid(ServerClient) &&
         GlobalFuncs.IsIPValid(ServerIP) &&
         (!ServerIP.Equals("localhost") || !ServerIP.Equals("127.0.0.1")))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #18
0
        public void Save(string fileName)
        {
            using (XmlTextWriter xml = new XmlTextWriter(fileName, Encoding.UTF8))
            {
                xml.Formatting = System.Xml.Formatting.Indented;
                xml.WriteStartDocument(true);
                xml.WriteStartElement("configuration");
                xml.WriteStartElement("settings");

                xml.WriteStartElement("server");
                xml.WriteAttributeString("ip", ServerIP.ToString());
                xml.WriteAttributeString("port", ServerPort.ToString());
                xml.WriteEndElement();

                xml.WriteEndElement();
                xml.WriteEndElement();
                xml.WriteEndDocument();
            }
        }
Beispiel #19
0
        private string ValidateServerIP()
        {
            string errString = "Не задан корректный IP адрес сервера";

            if (String.IsNullOrWhiteSpace(ServerIP))
            {
                return(errString);
            }

            string[] splitValues = ServerIP.Split('.');
            if (splitValues.Length != 4)
            {
                return(errString);
            }

            byte tempForParsing;

            return(splitValues.All(r => byte.TryParse(r, out tempForParsing)) ? null : errString);
        }
Beispiel #20
0
 public PatientPersonalDataViewComponent(ServerIP IPConfig, JsonStructure jsonStructureConfig)
     : base(IPConfig, jsonStructureConfig)
 {
     //ActivitySummaryController = new ActivitySummaryController(IPConfig, jsonStructureConfig);
     WeightController = new WeightController(IPConfig, jsonStructureConfig);
 }
 public PatientActivitiesViewComponent(ServerIP IPConfig, JsonStructure jsonStructureConfig)
     : base(IPConfig, jsonStructureConfig)
 {
     ActivityController = new ActivityController(IPConfig, jsonStructureConfig);
 }
 public DietController(ServerIP IPConfig, JsonStructure jsonStructureConfig)
     : base(IPConfig, jsonStructureConfig, jsonStructureConfig.Diet)
 {
 }
Beispiel #23
0
        public void ConnectToServer()
        {
            ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            int tryCount   = 20;
            int tryCounter = 0;

            while (tryCounter < tryCount)
            {
                try
                {
                    IPEndPoint ep = new IPEndPoint(ServerIP, Port);
                    ClientSocket.Connect(ep);
                    return;
                }
                catch (SocketException e)
                {
                    tryCounter++;
                    Thread.Sleep(10000);

                    if (tryCounter == tryCount)
                    {
                        throw new Exception(string.Format(@"Failed to connect to {0}:{1}, {2}", ServerIP.ToString(), Port, e));
                    }
                }
            }
        }
        public void buildConnectionString()
        {
            // Folder with CSV
            if (DriverSel.SelectedItem.ToString() == "ODBC File (*.csv)")
            {
                Driver   = "{Microsoft Text Driver (*.txt; *.csv)}";
                ServerIP = ServerTxt.Text.ToString();
                FilePath = ServerTxt.Text.ToString();
                Database = DatabaseTxt.Text.ToString();
                Username = UsernameTxt.Text.ToString();
                Password = PasswordTxt.Text.ToString();
                conStr   = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + FilePath.ToString() + ";Extensions=asc,csv,tab,txt;";
            }
            //Excel 97/2000 File
            if (DriverSel.SelectedItem.ToString() == "ODBC Excel (*.xls)")
            {
                Driver   = "Driver={Microsoft Excel Driver (*.xls)};";
                ServerIP = ServerTxt.Text.ToString();
                FilePath = ServerTxt.Text.ToString();
                Database = DatabaseTxt.Text.ToString();
                Username = UsernameTxt.Text.ToString();
                Password = PasswordTxt.Text.ToString();
                conStr   = "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=" + FilePath.ToString() + ";";
            }
            //MySQl Server
            if (DriverSel.SelectedItem.ToString() == "ODBC MySQL (IP)")
            {
                Driver   = "{MySQL ODBC 5.1 Driver}";
                ServerIP = ServerTxt.Text.ToString();
                FilePath = ServerTxt.Text.ToString();
                Database = DatabaseTxt.Text.ToString();
                Username = UsernameTxt.Text.ToString();
                Password = PasswordTxt.Text.ToString();
                conStr   = "Driver={MySQL ODBC 5.1 Driver};Server=" + ServerIP.ToString() + ";Database=" + Database.ToString() + ";uid=" + Username.ToString() + ";pwd=" + Password.ToString() + ";";
            }
            //SQLite File
            if (DriverSel.SelectedItem.ToString() == "ODBC SQLite (*.db)")
            {
                Driver   = "Driver=SQLite3 ODBC Driver;";
                ServerIP = ServerTxt.Text.ToString();
                FilePath = ServerTxt.Text.ToString();
                Database = DatabaseTxt.Text.ToString();
                Username = UsernameTxt.Text.ToString();
                Password = PasswordTxt.Text.ToString();
                conStr   = "DRIVER=SQLite3 ODBC Driver;Database=" + FilePath.ToString() + ";LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;";
            }
            //PostgreSQL
            if (DriverSel.SelectedItem.ToString() == "ODBC PostgreSQL (IP)")
            {
                Driver   = "Driver{PostgreSQL}";
                ServerIP = ServerTxt.Text.ToString();
                FilePath = ServerTxt.Text.ToString();
                Database = DatabaseTxt.Text.ToString();
                Username = UsernameTxt.Text.ToString();
                Password = PasswordTxt.Text.ToString();
                conStr   = "Driver={PostgreSQL};Server=" + ServerIP.ToString() + ";Port=5432;Database=" + Database.ToString() + ";Uid=" + Username.ToString() + ";Pwd=" + Password.ToString() + ";";
            }

            //MySQL Server
            if (DriverSel.SelectedItem.ToString() == "ADO MySQL (IP)")
            {
                Driver   = "{MySQL ADO Driver}";
                ServerIP = ServerTxt.Text.ToString();
                FilePath = ServerTxt.Text.ToString();
                Database = DatabaseTxt.Text.ToString();
                Username = UsernameTxt.Text.ToString();
                Password = PasswordTxt.Text.ToString();
                conStr   = "SERVER=" + ServerIP.ToString() + ";DATABASE=" + Database.ToString() + ";UID=" + Username.ToString() + ";PASSWORD="******";PORT=3306;";
            }
            //Microsoft (Transakt) SQL Server (97/2000)
            if (DriverSel.SelectedItem.ToString() == "ADO Microsoft SQL (IP)")
            {
                Driver   = "{SQL Server}";
                ServerIP = ServerTxt.Text.ToString();
                FilePath = ServerTxt.Text.ToString();
                Database = DatabaseTxt.Text.ToString();
                Username = UsernameTxt.Text.ToString();
                Password = PasswordTxt.Text.ToString();
                conStr   = "Driver={SQL Server};Server=" + ServerIP.ToString() + ";Database=" + Database.ToString() + ";Uid=" + Username.ToString() + ";Pwd=" + Password.ToString() + ";";
            }
            // Provider=MSDASQL;Driver=MySQL ODBC 5.1 Driver;Server=127.0.0.1;Database=datebank_name;Uid=mein_db_user;Pwd=pa_pa_passwort
            if (DriverSel.SelectedItem.ToString() == "ADODB MSDASQL/MYSQL (IP)")
            {
                Driver   = "Provider=MSDASQL;Driver=MySQL ODBC 5.1 Driver";
                ServerIP = ServerTxt.Text.ToString();
                FilePath = ServerTxt.Text.ToString();
                Database = DatabaseTxt.Text.ToString();
                Username = UsernameTxt.Text.ToString();
                Password = PasswordTxt.Text.ToString();
                conStr   = "Provider=MSDASQL;Driver=MySQL ODBC 5.1 Driver;Server=" + ServerIP.ToString() + ";Database=" + Database.ToString() + ";Uid=" + Username.ToString() + ";Pwd=" + Password.ToString() + ";";
            }
            conStrBox.Text = conStr.ToString();
        }
Beispiel #25
0
        /// <summary>
        /// Server start to listen the client connection.
        /// </summary>
        public void StartServerListeningClientConnections()
        {
            try
            {
                // WE have to start the server delayed
                Thread.Sleep(2000);

                // Creates one SocketPermission object for access restrictions
                SocketPermission permission = new SocketPermission(
                    NetworkAccess.Accept,     // Allowed to accept connections
                    TransportType.Tcp,        // Defines transport types
                    ServerIP.ToString(),      // The IP addresses of local host
                    SocketPermission.AllPorts // Specifies all ports
                    );

                // Ensures the code to have permission to access a Socket
                permission.Demand();

                // Establish the server endpoint for the socket.
                IPEndPoint serverEndPoint = new IPEndPoint(ServerIP, ServerPort);

                // Create a TCP/IP socket
                // Using IPv4 as the network protocol
                _listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                // Bind the socket to the server endpoint and listen for incoming connections.
                _listener.Bind(serverEndPoint);
                _listener.Listen(AsynchronousServer.SOCKET_LISTENER_BACKLOG);

                log.Info("Log server is ready for client connections.");
                log.Info("");

                //Start method which checks periodically if the server is running
                new Thread(() => CheckServer())
                {
                    IsBackground = true
                }.Start();

                IsServerRunning = true;

                // Loop server listening to client connections.
                while (IsServerRunning)
                {
                    // Start an asynchronous socket to listen for connections.
                    _listener.BeginAccept(new AsyncCallback(this.AcceptCallback), _listener);

                    // Wait until a connection is made before continuing.
                    connectDone.WaitOne();
                }
            }
            catch (SocketException ex)
            {
                log.Error(ex.Message, ex);
                log.Warn("Log Server listener closed. Try to restart Server");

                // Socket is not listening --> Restart Server
                this.RestartServer();
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
            }
        }
Beispiel #26
0
 public PatientController(ServerIP IPConfig, JsonStructure jsonStructureConfig)
     : base(IPConfig, jsonStructureConfig, jsonStructureConfig.Patient)
 {
 }
Beispiel #27
0
 public DoctorController(ServerIP IPConfig, JsonStructure jsonStructure)
     : base(IPConfig, jsonStructure, jsonStructure.Doctor)
 {
 }
Beispiel #28
0
 public TrainingController(ServerIP IPConfig, JsonStructure jsonStructure)
     : base(IPConfig, jsonStructure, jsonStructure.Training)
 {
 }
Beispiel #29
0
 public ActivitySummaryController(ServerIP IPConfig, JsonStructure jsonStructureConfig)
     : base(IPConfig, jsonStructureConfig, jsonStructureConfig.ActivitySummary)
 {
 }
 public GoalWeightController(ServerIP IPConfig, JsonStructure jsonStructureConfig)
     : base(IPConfig, jsonStructureConfig, jsonStructureConfig.GoalsWeight)
 {
 }