Esempio n. 1
0
        public ChunkAnalyzer()
        {
            InitializeComponent();

            RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("SOFTWARE");
            if (Array.Exists(softwareKey.GetSubKeyNames(), delegate(string s) { return s.CompareTo("Maxis") == 0; }))
            {
                RegistryKey maxisKey = softwareKey.OpenSubKey("Maxis");
                if (Array.Exists(maxisKey.GetSubKeyNames(), delegate(string s) { return s.CompareTo("The Sims Online") == 0; }))
                {
                    RegistryKey tsoKey = maxisKey.OpenSubKey("The Sims Online");
                    string installDir = (string)tsoKey.GetValue("InstallDir");
                    installDir += "\\TSOClient\\";
                    m_TSOPath = installDir;
                    LblTSOPath.Text = "TSO path: " + m_TSOPath;
                }
                else
                {
                    LblTSOPath.Text = "TSO was not found, please specify path: ";
                    TxtTSOPath.Visible = true;
                }
            }
            else
                LblTSOPath.Text = "TSO path: " + m_TSOPath;

            m_OnUpdateStatus = new UpdateStatusDelegate(UpdateStatus);
            m_OnFoundChunk = new FoundChunkDelegate(FoundChunk);
        }
 public void DownloadRTSP(string rtspURL, string outFile, UpdateStatusDelegate update)
 {
     var f = new DirectoryInfo(outFile);
     // Without -nocache it creates two processes, one being used for caching
     var args = string.Format("\"{0}\" -ao pcm -ao pcm:file=\"{1}\" -vc dummy -vo null", rtspURL, f.Name);
     bigWavFile = outFile;
     RunAndUpdatePercentage(mplayer, args, f.Parent.FullName, true, ExtractPercentageMPlayer, update, "Si è verificato un errore durante lo scaricamento della puntata.", !mplayerEndsWithError);
 }
Esempio n. 3
0
		public AsynchronousClient(String host, 
							int port,
							UpdateStatusDelegate updateStatus,
			bool debug) {
			this.host = host;
			this.port = port;
			this.updateStatus = updateStatus;
			this.debug = debug;
		}
        public void ConvertToMP3(string inFile, string outFile, UpdateStatusDelegate update)
        {
            if(!File.Exists(inFile))
            {
                throw new FileNotFoundException("impossibile trovare " + inFile);
            }

            var args = string.Format("\"{0}\" \"{1}\"", inFile, outFile);
            RunAndUpdatePercentage(lame, args, ".", false, ExtractPercentageLame, update, "Si è verificato un errore durante la creazione del file MP3.", true);
        }
Esempio n. 5
0
 public void UpdateStatus(string data)
 {
     if (this.textBox2.InvokeRequired)
     {
         UpdateStatusDelegate d = new UpdateStatusDelegate(UpdateStatus);
         this.Invoke(d, new object[] { data });
     }
     else
     {
         this.textBox2.Text = data;
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Cyclic main thread task
 /// </summary>
 private void CheckOPCStatus()
 {
     while (theStopFlag == false)
     {
         Thread.Sleep(theCycleTime);
         if (tbOpcSrvMonitoringStatus.InvokeRequired)
         {
             UpdateStatusDelegate theDelegate = new UpdateStatusDelegate(UpdateStatus);
             Invoke(theDelegate, new object[] { theOPCMonitorStatus });
         }
     }
     theThreadMonitor.Abort();
 }
Esempio n. 7
0
        private void Connect()
        {
            //if (clientSocket != null)
            //{
            //    // Get packet as byte array
            //    byte[] byteData = Encoding.ASCII.GetBytes("GoodBye");

            //    // Send packet to the server
            //    clientSocket.SendTo(byteData, 0, byteData.Length, SocketFlags.None, epServer);

            //    // Close the socket
            //    clientSocket.Close();
            //}

            try
            {
                // Initialise the delegate which updates the status
                updateStatusDelegate = new UpdateStatusDelegate(UpdateStatus);

                // Initialise the socket
                serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

                // Initialise the IPEndPoint and listen on port 8888
                IPEndPoint server = new IPEndPoint(IPAddress.Any, 8888);

                //IP address and port of AgOpenServer
                IPAddress zeroIP = IPAddress.Parse("192.168.1.255");
                epAgOpenServer = new IPEndPoint(zeroIP, 9999);

                // Associate the socket with this IP address and port
                serverSocket.Bind(server);

                // Initialise the IPEndPoint for the client
                EndPoint client = new IPEndPoint(IPAddress.Any, 0);

                // Start listening for incoming data
                serverSocket.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None,
                                              ref client, new AsyncCallback(ReceiveData), serverSocket);

                lblStatus.Text = "Listening";

                //start allowing nmea to be sent
                isConnected = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Connection Error: " + ex.Message, "UDP Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 8
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            _coinGuiLines = new List <CoinGuiLine>();
            _coinConfigs  = new List <CoinConfig>();
            _coinNames    = new List <string>();
            _resetTime    = DateTime.Now;
            _refreshTime  = DateTime.Now;
            _loadGuiLines = true;

            //Attempt to load portfolio on startup
            if (File.Exists("Portfolio1"))
            {
                _coinConfigs       = JsonConvert.DeserializeObject <List <CoinConfig> >(File.ReadAllText("Portfolio1") ?? string.Empty);
                _selectedPortfolio = "Portfolio1";
            }
            else if (File.Exists("Portfolio2"))
            {
                _coinConfigs       = JsonConvert.DeserializeObject <List <CoinConfig> >(File.ReadAllText("Portfolio2") ?? string.Empty);
                _selectedPortfolio = "Portfolio2";
            }
            else if (File.Exists("Portfolio3"))
            {
                _coinConfigs       = JsonConvert.DeserializeObject <List <CoinConfig> >(File.ReadAllText("Portfolio3") ?? string.Empty);
                _selectedPortfolio = "Portfolio3";
            }

            //Update status
            UpdateStatusDelegate updateStatus = new UpdateStatusDelegate(UpdateStatus);

            BeginInvoke(updateStatus, "Loading");

            //Start main thread
            Thread mainThread = new Thread(() => DownloadData());

            mainThread.IsBackground = true;
            mainThread.Start();

            //Start time thread
            Thread timeThread = new Thread(() => Timer());

            timeThread.IsBackground = true;
            timeThread.Start();

            //Start check update thread
            Thread checkUpdateThread = new Thread(() => CheckUpdate());

            checkUpdateThread.IsBackground = true;
            checkUpdateThread.Start();
        }
Esempio n. 9
0
        private void Server_Load(object sender, EventArgs e)
        {
            nud0.Value = Properties.Settings.Default.nud0;
            nud1.Value = Properties.Settings.Default.nud1;
            nud2.Value = Properties.Settings.Default.nud2;
            nud3.Value = Properties.Settings.Default.nud3;
            nud4.Value = Properties.Settings.Default.nud4;
            nud5.Value = Properties.Settings.Default.nud5;
            nud6.Value = Properties.Settings.Default.nud6;
            nud7.Value = Properties.Settings.Default.nud7;
            nud8.Value = Properties.Settings.Default.nud8;
            nud9.Value = Properties.Settings.Default.nud9;

            nudTimer.Value = Properties.Settings.Default.nudTimer;

            timer1.Interval = (int)(1.0 / (double)nudTimer.Value * 1000.0);

            try
            {
                // Initialise the delegate which updates the status
                updateStatusDelegate = new UpdateStatusDelegate(UpdateStatus);

                // Initialise the socket
                serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                serverSocket.EnableBroadcast = true;

                // Initialise the IPEndPoint and listen on port 8888
                IPEndPoint server = new IPEndPoint(IPAddress.Any, Properties.Settings.Default.setIP_thisPort);

                // Associate the socket with this IP address and port
                serverSocket.Bind(server);

                //IP address and port of AgOpenServer  port 9999
                IPAddress zeroIP = IPAddress.Parse(Properties.Settings.Default.setIP_autoSteerIP);
                epAgOpen = new IPEndPoint(zeroIP, Properties.Settings.Default.setIP_autoSteerPort);

                // Initialise the IPEndPoint for the client
                EndPoint client = new IPEndPoint(IPAddress.Any, 0);

                // Start listening for incoming data
                serverSocket.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None,
                                              ref client, new AsyncCallback(ReceiveData), serverSocket);
            }
            catch (Exception)
            {
                MessageBox.Show("UDP Network Not Connected - No Ethernet", "Serious Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                serverSocket.Close();
            }
        }
Esempio n. 10
0
        /// <summary>
        /// prepare for running worker threads
        /// </summary>
        private void Prepare(UpdateStatusDelegate update_status)
        {
            _StatusCallback = update_status;

            _Browsers = new List <BrowserSession.BrowserSession>();

#if kill
            _OutputStream = new StreamWriter(OUTPUT_FILENAME);
            _OutputJson   = new JsonTextWriter(_OutputStream)
            {
                Formatting = Formatting.None
            };
            _OutputJson.WriteStartArray();
#endif // kill
        }
Esempio n. 11
0
 private void btnConnect_Click(object sender, System.EventArgs e)
 {
     try
     {
         Connect_to_ComPort(comboPort.Text);
         this.updateStatusDelegate = new UpdateStatusDelegate(this.UpdateStatus);
         this.workerThread         = new Thread(new ThreadStart(this.Morserino_Receive));
         btnCheck.Visible          = false;
         btnConnect.Visible        = false;
         btnDisConnect.Visible     = true;
         workerThread.Start();
         labelText.Visible = true;
     }
     catch { }
 }
Esempio n. 12
0
        private bool install(UpdateStatusDelegate updateStatus)
        {
            updateStatus(this, SetupStatus.InProgress, "Extracting files...");
            extractProgramFiles();

            updateStatus(this, SetupStatus.InProgress, "Registering application...");
            registerApplication();

            updateStatus(this, SetupStatus.InProgress, "Installing C++ runtime...");
            installCppRuntime();

            updateStatus(this, SetupStatus.InProgress, "Creating service account...");
            createServiceAccount();

            updateStatus(this, SetupStatus.InProgress, "Registering application...");
            initializeSecurity();

            updateStatus(this, SetupStatus.InProgress, "Initializing configuration...");
            initializeConfig();

            updateStatus(this, SetupStatus.InProgress, "Creating service...");
            int createServiceErrorCode;

            if (!createService(out createServiceErrorCode))
            {
                updateStatus(
                    this, SetupStatus.Failure,
                    "Could not create service (Error code: " + createServiceErrorCode + ")");
                return(false);
            }

            updateStatus(this, SetupStatus.InProgress, "Starting service...");
            if (!startService())
            {
                updateStatus(this, SetupStatus.Failure, "Could not start service");
                return(false);
            }

            if (!IsInstalled())
            {
                updateStatus(this, SetupStatus.Failure, "Installation failed");
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 13
0
        //-------------------------------CTOR
        public NetworkExamService(Exam examEmptyCopy, string examKey,
                                  ref Logger logger, UpdateStatusDelegate method, ExaminationStudentsFilter firewall)
        {
            OriginalExamWithNoStdDetails = examEmptyCopy;

            ExamKey = examKey;

            ExamSubmissionZippedStringList = new List <ExamStatusUpdate>();

            aLogger      = logger;
            UpdateMethod = method;

            submittedFiles = new SortedList <string, string>();

            Firewall = firewall;
        }
Esempio n. 14
0
        public MainWindow()
        {
            InitializeComponent();

            vertices = GetVertices(GetRawVertices());
            tsp      = new TSP(vertices, 0, 1000, 10, 0.3);

            vertexBrush = new SolidBrush(Color.White);
            pathPen     = new Pen(Color.Gray);
            bgColor     = canvasBox.BackColor;

            working  = false;
            editMode = false;

            updateStatusDelegate += UpdateStatus;
        }
Esempio n. 15
0
        //private string InstructorPassword { get; set; }
        //public Logger aLogger { get; set; }


        //-------------------------------CTOR
        public NetworkExamServicePerformanceTesting(SortedList <int, Exam> examEmptyCopies, string examKey,
                                                    UpdateStatusDelegate method, SortedList <int, ExaminationStudentsFilter> firewalls)
        {
            OriginalExamWithNoStdDetails = examEmptyCopies;

            ExamKey = examKey;

            ExamSubmissionZippedStringList = new List <ExamStatusUpdate>();

            //   aLogger = logger;
            UpdateMethod = method;

            submittedFiles = new SortedList <string, string>();

            Firewalls = firewalls;
        }
        private void OnMenuHIBP(object sender, EventArgs e)
        {
            MainForm mainForm = HIBPOfflineCheckExt.Host.MainWindow;

            PwEntry[] selectedEntries = mainForm.GetSelectedEntries();

            foreach (PwEntry pwEntry in selectedEntries)
            {
                PasswordEntry = pwEntry;

                UpdateStatusDelegate updateStatusDel = new UpdateStatusDelegate(GetPasswordStatus);
                IAsyncResult         asyncRes        = updateStatusDel.BeginInvoke(null, null);
                updateStatusDel.EndInvoke(asyncRes);

                UpdateStatus();
            }
        }
        public static async Task <bool> CheckUpdate(UpdateStatusDelegate onUpdateStatus)
        {
            try
            {
                onUpdateStatus.Invoke(UpdateStatus.Checking, Properties.Resources.CheckingForUpdate);

                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

                using (var updateManager = await UpdateManager.GitHubUpdateManager(App.UpdateUrl))
                {
                    var updates = await updateManager.CheckForUpdate();

                    var lastVersion = updates?.ReleasesToApply?.OrderBy(releaseEntry => releaseEntry.Version).LastOrDefault();

                    if (lastVersion == null)
                    {
                        onUpdateStatus.Invoke(UpdateStatus.None, Properties.Resources.NoUpdate);
                        return(false);
                    }

                    onUpdateStatus.Invoke(UpdateStatus.Downloading, Properties.Resources.DownloadingUpdate);

                    Common.Settings.Extensions.BackupSettings();

                    await updateManager.DownloadReleases(new[] { lastVersion });

                    onUpdateStatus.Invoke(UpdateStatus.Installing, Properties.Resources.InstallingUpdate);

                    await updateManager.ApplyReleases(updates);

                    await updateManager.UpdateApp();
                }

                onUpdateStatus.Invoke(UpdateStatus.Restarting, Properties.Resources.RestartingAfterUpdate);

                UpdateManager.RestartApp();

                return(true);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);

                return(false);
            }
        }
Esempio n. 18
0
 private void UpdateStatus(string newStatus)
 {
     if (lblStatus.InvokeRequired)
     {
         try
         {
             UpdateStatusDelegate del = new UpdateStatusDelegate(UpdateStatus);
             lblStatus.Invoke(del, new object[] { newStatus });
         }
         catch (Exception ex)
         {
         }
     }
     else
     {
         lblStatus.Text = newStatus;
     }
 }
Esempio n. 19
0
        private void ExecutingQueries(Object i_MethodInvoker)
        {
            ReplyData ReplyDataObj;

            try
            {
                ClientInfo cInfo = new ClientInfo(m_TmpClientIP, m_TmpClientName, Consts.ClientStatus.Unknown);
                ReplyDataObj = m_StatusBL.ExecuteQuery(m_AppDef.CurrCenter.IP, m_AppDef.m_Port, cInfo);
            }
            catch (Exception)
            {
                ReplyDataObj = null;
            }

            UpdateStatusDelegate UpdateStatus = new UpdateStatusDelegate(UpdateClientStatus);

            UpdateStatus(ReplyDataObj);
        }
Esempio n. 20
0
 /// <summary>
 /// 初始化委托
 /// </summary>
 private void initDelegates()
 {
     setOnlineDelegate             = new EnableDelegate(onLog);
     enableSendDelegate            = new EnableDelegate(onEnableSend);
     sendRtfDelegate               = new SendRtfDelegate(onSendRtfDelegate);
     sendFileDelegate              = new SendFileDelegate(SendFile);
     receiveRTFDelegate            = new ReceiveRTFDelegate(onReceiveRTF);
     removeClientDelegate          = new RemoveClientDelegate(onRemoveClient);
     askedForReceivingFileDelegate =
         new AskedForReceivingFileDelegate(onAskedForReceivingFile);
     stopSendingOrReceivingFileDelegate =
         new StopSendingOrReceivingFileDelegate(onStopSendingOrReceivingFile);
     showMessageDelegate  = new ShowMessageDelegate(onShowMessage);
     setProgressDelegate  = new SetProgressDelegate(onSetProgress);
     showProgressDelegate = new ShowProgressDelegate(onShowProgress);
     updateStatusDelegate = new UpdateStatusDelegate(onUpdateStatus);
     startTimingDelegate  = new StartTimingDelegate(onStartTiming);
 }
Esempio n. 21
0
        private void Server_Load(object sender, EventArgs e)
        {
            try
            {
                #region MySql Connection

                MysqlFirstTimeSetup();

                string mySqlServer   = "localhost";
                string mySqlUser     = "******";
                string mySqlPassword = "******";
                string mySqlDatabase = "chatterbox";
                string connectionString;
                connectionString = "SERVER=" + mySqlServer + ";" + "DATABASE=" +
                                   mySqlDatabase + ";" + "UID=" + mySqlUser + ";" + "PASSWORD="******";";

                mySqlConnection = new MySqlConnection(connectionString);

                ConnectToMySqlServer(mySqlConnection);

                #endregion



                #region Server Connection

                clientList           = new ArrayList();
                updateStatusDelegate = new UpdateStatusDelegate(UpdateStatus);
                serverSocket         = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                IPEndPoint server = new IPEndPoint(IPAddress.Any, 30000);
                serverSocket.Bind(server);
                IPEndPoint clients  = new IPEndPoint(IPAddress.Any, 0);
                EndPoint   epSender = (EndPoint)clients;
                serverSocket.BeginReceiveFrom(serverDataStream, 0, serverDataStream.Length, SocketFlags.None, ref epSender, new AsyncCallback(ReceiveData), epSender);
                statusLabel.Text = "Status : Listening";

                #endregion
            }
            catch (Exception ex)
            {
                statusLabel.Text = "Error";
                MessageBox.Show("Load Error: " + ex.Message, "UDP Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 22
0
        /// <summary>
        /// scrape
        /// </summary>
        /// <param name="update_status">callback function for working status</param>
        public void Run(bool periodic, UpdateStatusDelegate update_status)
        {
            Prepare(update_status);

            while (true)
            {
                RunWorkerThreads();

                if (!periodic)
                {
                    break;
                }

                _StatusCallback("continue after 3 hours");
                Task.Delay(TimeSpan.FromHours(3)).Wait();
            }

            CleanUp();
        }
        //private bool isInstalled()
        //{
        //    return GetUninstallRegistryKey().GetSubKeyNames().Count(n => n == registryKeyName) != 0;
        //}

        public override bool ProcessOption(UpdateStatusDelegate updateStatus)
        {
            if (!base.ProcessOption(updateStatus))
            {
                return(false);
            }

            if (IsInstalled())
            {
                updateStatus(this, SetupStatus.InProgress, "Uninstalling...");
                Process u1 = Process.Start(GetUninstallPath(false));
                u1.WaitForExit();

                // Allow 2nd process to start.
                System.Threading.Thread.Sleep(1000);

                Process u2 = getUninstallQuery().First();
                u2.WaitForExit();

                if (IsInstalled())
                {
                    updateStatus(this, SetupStatus.Failure, "Uninstallation failed");
                    return(false);
                }
            }

            updateStatus(this, SetupStatus.InProgress, "Installing...");
            Process.Start(GetInstallPath(SetupWizard.SetupPath));
            Process install = getInstallQuery().First();

            install.WaitForExit();

            // Allow 2nd process to start.
            System.Threading.Thread.Sleep(1000);

            if (!IsInstalled())
            {
                updateStatus(this, SetupStatus.Failure, "Installation failed");
                return(false);
            }

            return(true);
        }
Esempio n. 24
0
        private void fmImport_Load(object sender, EventArgs e)
        {
//            fb_Path.SelectedPath = Application.StartupPath;
            if (Globals.PathsToImport.Count > 0)
            {
                //currently do nothing.  basically this is for silent import
                //will have to thing stuff a bit more
            }
            else
            {
                this.cbPath.Text = sqlnexus.Properties.Settings.Default.ImportPath;
            }

            this.Left -= 100;

            updateProgress = new UpdateProgressDelegate(this.UpdateProgress);
            updateStatus   = new UpdateStatusDelegate(this.UpdateStatus);
            EnumImporters();
        }
Esempio n. 25
0
        private void UpdateStatus(long readBytesPerSecond = -1, long writeBytesPerSecond = -1)
        {
            if (ActivityLogTextBox.InvokeRequired)
            {
                UpdateStatusDelegate d = new UpdateStatusDelegate(UpdateStatus);
                this.Invoke(d, new object[] { readBytesPerSecond, writeBytesPerSecond });
                return;
            }

            UpdateSpeedAverage(readBytesPerSecond, writeBytesPerSecond);

            if (_mediaTester != null)
            {
                WrittenBytesLabel.Text  = (_mediaTester?.TotalBytesWritten.ToString("#,##0") ?? PALCEHOLDER_VALUE) + BYTES;
                VerifiedBytesLabel.Text = (_mediaTester?.TotalBytesVerified.ToString("#,##0") ?? PALCEHOLDER_VALUE) + BYTES;
                FailedBytesLabel.Text   = (_mediaTester?.TotalBytesFailed.ToString("#,##0") ?? PALCEHOLDER_VALUE) + BYTES;
            }

            ProgressBar.Value = _mediaTester == null ? 0 : (int)(10M * _mediaTester.ProgressPercent);
        }
        private void SoftwareFrame_Load(object sender, EventArgs eventArgs)
        {
            _currentActionDescription = "OPC-QuickClient load";
            _currentActionErrorCount  = 0;
            _isActionRunning          = false;
            SelectedMachineName       = "";
            SelectedServerId          = "";

            _updateServerListDelegate = UpdateServerListFunc;
            _updateTabListDelegate    = UpdateTabListFunc;
            _updateReportDelegate     = UpdateReportFunc;
            _updateStatusDelegate     = UpdateStatusFunc;

            m_LocalSearchCheckBox.Checked  = true;
            m_RemoteSearchCheckBox.Checked = false;

            m_RemoteMachineText.Text    = "";
            m_RemoteMachineText.Enabled = false;

            DisplayMessageInActionStatus(_currentActionDescription + " finished");
            DisplayMessageInStateStatus(Convert.ToString(_currentActionErrorCount) + " error(s)");
        }
Esempio n. 27
0
        /// <summary>
        /// clean up
        /// </summary>
        private void CleanUp()
        {
            foreach (var browser in _Browsers)
            {
                browser.Dispose();
            }

#if kill
            _OutputJson.Close();
            _OutputJson = null;
            _OutputStream.Dispose();
            _OutputStream = null;
#endif // kill

            _FinishedScrapers = null;
            _WorkerThreads    = null;
            _Browsers         = null;
            _WorkingScrapers  = null;
            _Scrapers         = null;
            _Items            = null;
            _StatusCallback   = null;
        }
Esempio n. 28
0
        private void InitializeServerConnection()
        {
            try
            {
                // Initialise the ArrayList of connected clients
                this.clientList = new ArrayList();

                // Initialise the delegate which updates the Rooms
                this.updateRoomsDelegate = new UpdateRoomsDelegate(this.UpdateRooms);

                // Initialise the delegate which updates the Server Status
                this.updateStatusDelegate = new UpdateStatusDelegate(this.UpdateStatus);

                // Initialise the socket
                serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

                // Initialise the IPEndPoint for the server and listen on port 30000
                IPEndPoint server = new IPEndPoint(IPAddress.Any, 30000);

                // Associate the socket with this IP address and port
                serverSocket.Bind(server);

                // Initialise the IPEndPoint for the clients
                IPEndPoint clientEP = new IPEndPoint(IPAddress.Any, 0);

                // Initialise the EndPoint for the clients
                EndPoint epSender = (EndPoint)clientEP;

                // Start listening for incoming data
                serverSocket.BeginReceiveFrom(this.dataStream, 0, this.dataStream.Length, SocketFlags.None, ref epSender, new AsyncCallback(ReceiveData), epSender);

                ServerComTextBox.Text = "Listening for Clients..." + "\n";
            }
            catch (Exception ex)
            {
                ServerComTextBox.Text = "Error" + "\n";
                MessageBox.Show("Load Error: " + ex.Message, "Time4aChat Server Command Center Error");
            }
        }
Esempio n. 29
0
        public override bool ProcessOption(UpdateStatusDelegate updateStatus)
        {
            if (!base.ProcessOption(updateStatus))
            {
                return(false);
            }

            updateStatus(this, SetupStatus.InProgress, "Starting service...");
            ServiceController sc = new ServiceController("Rensoft.Hosting.Server");
            bool started         = sc.Start(TimeSpan.FromSeconds(10));

            if (!started)
            {
                updateStatus(this, SetupStatus.Failure, "Service start failed");
                return(false);
            }

            updateStatus(this, SetupStatus.InProgress, "Configuring...");

            ServerConfigAdapter adapter = LocalContext.Default.CreateAdapter <ServerConfigAdapter>();

            adapter.EnableLegacyMode       = EnableLegacyMode;
            adapter.LegacyConnectionString = LegacyConnectionString;
            adapter.WindowsServerName      = WindowsServerName;
            adapter.AvailableIisSiteIPs    = AvailableIisIPs.Split(',');
            adapter.AvailableDnsServers    = DnsSuggestServers.Split(',');
            adapter.AvailableDnsIPs        = DnsSuggestAIPs.Split(',');
            adapter.FirstDnsNameServer     = DnsSoaPrimaryServer;
            adapter.DnsHostmasterName      = DnsSoaHostmaster;
            adapter.WebsiteDirectory       = new DirectoryInfo(WebsiteDirectory);

            if (EncryptorSecretChange)
            {
                // Only change if forced (could mean loosing passwords).
                adapter.EncryptorSecret = EncryptionSecret;
            }

            return(true);
        }
Esempio n. 30
0
        public override bool ProcessOption(UpdateStatusDelegate updateStatus)
        {
            if (!base.ProcessOption(updateStatus))
            {
                return(false);
            }

            if (IsInstalled())
            {
                Process uninstallProcess = GetUninstallProcess();

                // Uninstall in case application is already installed.
                updateStatus(this, SetupStatus.InProgress, "Uninstalling...");
                uninstallProcess.Start();
                uninstallProcess.WaitForExit();

                if (uninstallProcess.ExitCode != 0)
                {
                    updateStatusUninstallFailed(uninstallProcess, updateStatus);
                    return(false);
                }
            }

            Process installProcess = GetInstallProcess(SetupWizard.SetupPath);

            // Now run the installation quietly with no interface.
            updateStatus(this, SetupStatus.InProgress, "Installing...");
            installProcess.Start();
            installProcess.WaitForExit();

            if (installProcess.ExitCode != 0)
            {
                updateStatusUninstallFailed(installProcess, updateStatus);
                return(false);
            }

            return(true);
        }
Esempio n. 31
0
        private void ExecutingQueries(Object cInfo1)
        {
            if (cInfo1 == null)
            {
                throw new ArgumentNullException("cInfo1");
            }
            ReplyData ReplyDataObj;
            var       CliInfoS = cInfo1 as BaseClass.ClientInfo;

            try
            {
                // var cInfo = new BaseClass.ClientInfo(m_TmpClientIP, m_TmpClientName, Consts.ClientStatus.Unknown,Consts.NetStatus.Offline);
                ReplyDataObj = m_StatusBL.ExecuteQuery(CliInfoS.IP, SCUtility.m_AppDef.m_Port, CliInfoS);
            }
            catch (Exception)
            {
                ReplyDataObj = null;
            }

            UpdateStatusDelegate UpdateStatus = new UpdateStatusDelegate(UpdateClientStatus);

            this.Invoke(UpdateStatus, new object[] { ReplyDataObj, cInfo1 });
        }
Esempio n. 32
0
        public void Scrape(BrowserSession.BrowserSession browser, UpdateStatusDelegate update_status, TimeSpan timeout)
        {
            AutoResetEvent ev = new AutoResetEvent(false);

            var thread = new Thread(new ThreadStart(() =>
            {
                try
                {
                    this.ScrapeCore(browser, update_status);
                }
                catch (ThreadAbortException) { }

                ev.Set();
            }));

            thread.Start();

            if (!ev.WaitOne(timeout))
            {
                thread.Abort();
                throw new TimeoutException();
            }
        }
Esempio n. 33
0
        private void Server_Load(object sender, EventArgs e)
        {
            try
            {
                // Initialise the ArrayList of connected clients
                this.clientList = new ArrayList();

                this.updateStatusDelegate = new UpdateStatusDelegate(this.UpdateStatus);

                serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

                Address = ValidateNetwork.GetIPAddress();
                Port    = ValidateNetwork.GetOpenPort(10000);

                IPEndPoint server = new IPEndPoint(Address, Port);

                serverSocket.Bind(server);

                // Initialise the IPEndPoint for the clients
                IPEndPoint clients = new IPEndPoint(IPAddress.Any, 0);

                // Initialise the EndPoint for the clients
                EndPoint epSender = (EndPoint)clients;

                // Start listening for incoming data
                serverSocket.BeginReceiveFrom(this.dataStream, 0, this.dataStream.Length, SocketFlags.None, ref epSender, new AsyncCallback(ReceiveData), epSender);

                lblStatus.Text      = "Listening IP: " + Address + " Port: " + Port;
                lblStatus.ForeColor = Color.Green;
            }
            catch (Exception ex)
            {
                lblStatus.Text      = "Error";
                lblStatus.ForeColor = Color.Red;
                MessageBox.Show("Load Error: " + ex.Message, "UDP Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 34
0
        private void DownloadData()
        {
            //Update status
            UpdateStatusDelegate updateStatus = new UpdateStatusDelegate(UpdateStatus);

            BeginInvoke(updateStatus, "Refreshing");

            try
            {
                using (var webClient = new WebClient())
                {
                    //Set api
                    _api = mnuCoinMarketCap.Checked ? API_COIN_MARKET_CAP : API_COIN_CAP;

                    //Download coin data from API
                    string response = webClient.DownloadString(_api);

                    //Update coins
                    UpdateCoinDelegates updateCoins = new UpdateCoinDelegates(UpdateCoins);
                    BeginInvoke(updateCoins, response);

                    //Update status
                    updateStatus = new UpdateStatusDelegate(UpdateStatus);
                    BeginInvoke(updateStatus, "Sleeping");
                }
            }
            catch (WebException)
            {
                //Update status
                updateStatus = new UpdateStatusDelegate(UpdateStatus);
                BeginInvoke(updateStatus, "No internet connection");
            }

            //Sleep and refresh
            Thread.Sleep(5000);
            DownloadData();
        }
Esempio n. 35
0
        private void Server_Load(object sender, EventArgs e)
        {
            try
            {
                // Initialise the ArrayList of connected clients
                this.clientList = new ArrayList();

                // Initialise the delegate which updates the status
                this.updateStatusDelegate = new UpdateStatusDelegate(this.UpdateStatus);

                // Initialise the socket
                serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

                // Initialise the IPEndPoint for the server and listen on port 30000
                IPEndPoint server = new IPEndPoint(IPAddress.Any, 30000);

                // Associate the socket with this IP address and port
                serverSocket.Bind(server);

                // Initialise the IPEndPoint for the clients
                IPEndPoint clients = new IPEndPoint(IPAddress.Any, 0);

                // Initialise the EndPoint for the clients
                EndPoint epSender = (EndPoint)clients;

                // Start listening for incoming data
                serverSocket.BeginReceiveFrom(this.dataStream, 0, this.dataStream.Length, SocketFlags.None, ref epSender, new AsyncCallback(ReceiveData), epSender);

                lblStatus.Text = "Listening";
            }
            catch (Exception ex)
            {
                lblStatus.Text = "Error";
                MessageBox.Show("Load Error: " + ex.Message, "UDP Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        protected void UpdateStatus(GlobalMessageEventArgs e)
        {
            if (this.InvokeRequired)
            {
                UpdateStatusDelegate dlg = new
                    UpdateStatusDelegate(this.UpdateStatus);
                this.Invoke(dlg, new object[] { e });
                return;
            }

            //do something with the GUI control here
            if (e.IsError)
            {
                ShowError(lblInformation, e.Message);
            }
            else
            {
                ShowMessage(lblInformation, e.Message);
            }
        }
Esempio n. 37
0
        /// <summary>
        /// Control that draws the map and updates the tiles.
        /// </summary>
        public MapDisplay(int x, int y, int width, int height, LoadingThread thr)
        {
            this.Location = new Point(x, y);
            this.Width = width;
            this.Height = height;
            this.bounds = new BBox(5.16130, 52.06070, 5.19430, 52.09410);
            this.DoubleBuffered = true;

            this.updateStatusDelegate = new UpdateStatusDelegate(UpdateStatus);
            this.updateRouteStatsDelegate = new UpdateRouteStatsDelegate(UpdateRouteStats);
            this.startLogoDelegate = new StartLogoDelegate(StartLoadingLogo);
            this.stopLogoDelegate = new StopLogoDelegate(StopLoadingLogo);

            this.updateThread = new Thread(new ThreadStart(this.UpdateTiles));
            this.MouseClick += (object o, MouseEventArgs mea) => { OnClick(o, new MouseMapDragEventArgs(null, mea.Button, mea.Clicks,
                                                                                                        mea.X, mea.Y, mea.Delta)); };
            this.MouseDoubleClick += OnDoubleClick;
            this.Paint += OnPaint;
            this.Resize += OnResize;
            this.MouseDown += OnMouseDown;
            this.MouseUp += OnMouseUp;
            this.MouseMove += OnMouseMove;
            this.Disposed += (object o, EventArgs ea) => { updateThread.Abort(); };

            // Thread that loads the graph.
            loadingThread = thr;

            // Checks whether the graph is loaded so the mapdisplay can start loading tiles.
            loadingTimer = new System.Windows.Forms.Timer();
            loadingTimer.Interval = 100;
            loadingTimer.Tick += (object o, EventArgs ea) => { DoUpdate(); };
            loadingTimer.Start();

            logo = new AllstarsLogo(true);
            logo.Location = Point.Empty;
            logo.Width = this.Width;
            logo.Height = this.Height;
            this.Controls.Add(logo);
            logo.Start();

            LinkLabel creditLabel = new LinkLabel();
            creditLabel.Text = "© OpenStreetMap contributors";
            creditLabel.LinkArea = new LinkArea(2, 13);
            creditLabel.LinkClicked += (object o, LinkLabelLinkClickedEventArgs ea) => { System.Diagnostics.Process.Start("http://www.openstreetmap.org/copyright/en"); };
            creditLabel.Anchor = (AnchorStyles.Right | AnchorStyles.Bottom);
            creditLabel.Size = creditLabel.PreferredSize;
            creditLabel.Location = new Point(this.Width - creditLabel.Width - 1, this.Height - creditLabel.Height - 1);
            this.Controls.Add(creditLabel);

            statLabel = new Label();
            statLabel.AutoSize = true;
            statLabel.Resize += (object o, EventArgs ea) => { statLabel.Location = new Point(this.Width - 1 - statLabel.Size.Width, 1); };
            statLabel.Anchor = (AnchorStyles.Right | AnchorStyles.Top);
            statLabel.Font = new Font("Microsoft Sans Serif", 11);
            this.Controls.Add(statLabel);

            myVehicles = new List<MyVehicle>();
            icons = new List<MapIcon>();
            streetSelection = new List<Curve>();

            tiles = new List<List<Bitmap>>();
            tileCorners = new List<List<Point>>();
            tiles.Add(new List<Bitmap>());
            tileCorners.Add(new List<Point>());
            tileIndex = 0;

            tileIndexes = new List<SortedList<int, SortedList<int, int>>>();
            tileIndexes.Add(new SortedList<int, SortedList<int, int>>());

            zoomWidth = new List<double>();
            zoomHeight = new List<double>();

            this.Disposed += (sender, e) =>
            {
                logo.StillLoading = false;
            };

            // Set linecaps for the pens.
            footPen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
            bikePen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
            carPen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
            busPen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
            otherPen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
        }
Esempio n. 38
0
        /// <summary>
        /// prepares Background Worker but does not start it yet.
        /// </summary>
        void PrepareBackgroundWorker()
        {
            // get our dispatcher
            System.Windows.Threading.Dispatcher dispatcher = this.Dispatcher;

            // create our background worker and support cancellation
            worker = new BackgroundWorker();
            worker.WorkerSupportsCancellation = true;

            worker.DoWork += delegate(object s, DoWorkEventArgs args)
            {
                Debug.WriteLine("IP: RunWorker started");

                try
                {
                    isWorkerRunning = true;
                    // open currentPort
                    lidarLiteProcessor = new LidarLiteProcessor();
                    lidarLiteProcessor.Open(new string[] { currentPort });
                    lidarLiteProcessor.DataReceivedEvent += lidarLiteProcessor_DataReceived;

                    Dispatcher.Invoke(new Action<object>(EnableOpenCloseButton), "");

                    while (true)
                    {
                        lidarLiteProcessor.StartedLoop();   // helps keeping 20ms cycle steady

                        if (worker.CancellationPending)
                        {
                            Debug.WriteLine("IP: RunWorker Cancellation Pending, closing serial port");

                            lidarLiteProcessor.Close();

                            args.Cancel = true;

                            Debug.WriteLine("OK: RunWorker Cancellation sequence completed");

                            isWorkerRunning = false;

                            return;
                        }

                        lidarLiteProcessor.Process();

                        DisplayAll();

                        lidarLiteProcessor.WaitInLoop();  // we won't wait here longer than lidarLiteProcessor.desiredLoopTimeMs - about 20ms-<already elapsed time>
                    }
                }
                catch (Exception exc)
                {
                    Debug.WriteLine("Error: RunWorker: " + exc);

                    // create a new delegate for updating our status text
                    UpdateStatusDelegate update = new UpdateStatusDelegate(UpdateStatusText);

                    // invoke the dispatcher and pass the error data:
                    Dispatcher.BeginInvoke(update, "Error: RunWorker: " + exc.Message);

                    lidarLiteProcessor.Close();     // close communication to the serial port

                    Dispatcher.Invoke(new Action<object>(ResetOpenCloseButton), "");
                }
            };

            worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
            {
                isWorkerRunning = false;

                Dispatcher.Invoke(new Action<object>(EnableOpenCloseButton), "");

                Debug.WriteLine("OK: RunWorker Completed");
            };
        }
Esempio n. 39
0
 public void showProgressBar()
 {
     if (this.InvokeRequired)
     {
         UpdateStatusDelegate dlg = new
             UpdateStatusDelegate(this.showProgressBar);
         this.Invoke(dlg, new object[] { });
         return;
     }
     toolStripStatusLabel.Text = " Processing ";
     timerProgress.Start();
 }
        private void RunAndUpdatePercentage(string program, string args, string workingDirectory, bool stdout, ExtractPercentageDelegate getPercentage, UpdateStatusDelegate update, string errorMessage, bool stopOnErrors)
        {
            var info = new ProcessStartInfo();
            info.FileName = program;
            info.Arguments = args;
            info.WorkingDirectory = workingDirectory;
            info.UseShellExecute = false;
            info.RedirectStandardOutput = true;
            info.RedirectStandardError = true;
            info.CreateNoWindow = true;

            using(process = Process.Start(info))
            {
                using(var output = stdout ? process.StandardOutput : process.StandardError)
                {
                    update(0);
                    var line = "";
                    while(!process.HasExited)
                    {
                        if((line = output.ReadLine()) != null)
                        {
                            var perc = getPercentage(line);
                            if(perc > 0)
                            {
                                update(perc);
                            }
                        }
                    }

                    update(100);

                    if(stopOnErrors && process.ExitCode != 0)
                    {
                        throw new Exception(errorMessage);
                    }
                }
            }
            process = null;
        }
Esempio n. 41
0
 public void stopProgressBar()
 {
     if (this.InvokeRequired)
     {
         UpdateStatusDelegate dlg = new
             UpdateStatusDelegate(this.stopProgressBar);
         this.Invoke(dlg, new object[] { });
         return;
     }
     toolStripStatusLabel.Text = " Ready ";
     timerProgress.Stop();
     toolStripProgressBar.Value = 0;
 }