Esempio n. 1
0
        private void sendLastReport(Socket socket)
        {
            string lastReport = PeriodicReporting.getReportString();

            Console.WriteLine("last reort is: " + lastReport);
            SendData(socket, "check connection before send last report\r");
            SendData(socket, "last report\r" + lastReport);
        }
Esempio n. 2
0
        // sara
        private void removeClient()
        {
            // ShowErrorDialog("removeeeeeeeeeeee");

            // turn off all theards
            manageMonitor.stopAllTriggers();

            // stop timer
            PeriodicReporting.stopTimer();

            // db
            DBclient DBInstance = DBclient.Instance;

            DBInstance.deleteDB();

            // restart - delete key
            RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            rkApp.DeleteValue("ClientSide.exe", false);

            System.Environment.Exit(0);
        }
Esempio n. 3
0
        //public void sendDataByParts(Socket clientSocket, string data)
        //{
        //    string subject = data.Split(new[] { '\r'}, 2)[0];
        //    string testData = data.Split(new[] { '\r' }, 2).Last();
        //    var sendData = Encoding.UTF8.GetBytes("start send data by parts\r" + subject + "\r");
        //    clientSocket.BeginSend(sendData, 0, sendData.Length, SocketFlags.None, SendCallback, clientSocket);


        //    string subData = "";
        //    string subEncrypt = "";
        //    int index = 0;
        //    int length = 20;

        //    bool lastPart = false;
        //    while (!lastPart)
        //    {

        //        if ((index + length) > testData.Length)
        //        {
        //            length = testData.Length;
        //            subData += testData.Substring(index, length);
        //            lastPart = true;
        //        }
        //        else
        //        {
        //            subData += testData.Substring(index, index + length);
        //        }


        //        Byte[] subStringByte = Encoding.UTF8.GetBytes(testData);

        //        subEncrypt = Crypto.Encryption(subData);
        //        if (subEncrypt != string.Empty)
        //        {
        //            DBclient DBInstance = DBclient.Instance;
        //            string id = DBInstance.getGeneralDetailsTable("id");

        //            sendData = Encoding.UTF8.GetBytes("sub encrypt data\r" + id + "\r" + subEncrypt);
        //            clientSocket.BeginSend(sendData, 0, sendData.Length, SocketFlags.None, SendCallback, clientSocket);
        //            index += length;
        //            length += 20;
        //        }



        //    }


        //    sendData = Encoding.UTF8.GetBytes("stop send data by parts\r" + id + "\r");
        //    clientSocket.BeginSend(sendData, 0, sendData.Length, SocketFlags.None, SendCallback, clientSocket);


        //}



        public void reConnect()
        {
            try
            {
                if (checkSocketConnections())
                {
                    return;
                }
                // Create new socket
                clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                buffer       = new byte[clientSocket.ReceiveBufferSize];

                //ShowErrorDialog("reConnect in socket: " + clientSocket.RemoteEndPoint);
                // Connect To Server
                IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(ip), 3333);
                // The function ConnectCallback set callback to receive and send
                clientSocket.BeginConnect(endPoint, ConnectCallback, clientSocket);

                // send to server alert who missing
                DBclient DBInstance      = DBclient.Instance;
                string   immadiateAlerts = DBInstance.getReportImmediateTable();
                if (immadiateAlerts.Length > 0)
                {
                    PeriodicReporting.sendMissingReportsToMail(immadiateAlerts);
                }
            }
            catch (SocketException ex)
            {
                ShowErrorDialog("reConnect send SocketException\r\n" + ex.Message + " \n\n" + ex);
            }
            catch (ObjectDisposedException ex)
            {
                ShowErrorDialog("reConnect send ObjectDisposedException \r\n" + ex.Message + " \n\n" + ex);
            }
            catch (InvalidOperationException ex) {
                ShowErrorDialog("reConnect send InvalidOperationException \r\n" + ex.Message + " \n\n" + ex);
            }
        }
Esempio n. 4
0
        // set setting and here will play all triggers;
        private void playAllTrigers()
        {
            Console.WriteLine("PLAY ALL TRIGGERRS");

            // Play all monitors
            if (manageMonitor == null)
            {
                manageMonitor = new ManageMonitor();
            }
            Setting settingInstance = Setting.Instance;

            settingInstance.setAllSetting();


            manageMonitor.stopAllTriggers();

            manageMonitor.playAllTriggers();

            // Set Periodic Report
            PeriodicReporting.setReportPeriodic();

            // set daiely report
            PeriodicReporting.setDailyReport();
        }