예제 #1
0
 /// <summary>
 /// Sets the Client's settings and stores them.
 /// </summary>
 /// <param name="settings">The new <see cref="ClientSettings"/> to be assigned to the Cleint.</param>
 public void SetSettings(ClientSettings settings)
 {
     try
     {
         globals.Settings.ConnectionSpeed = settings.ConnectionSpeed;
         globals.Settings.Email = settings.Email;
         globals.Settings.EnableScheduler = settings.EnableScheduler;
         globals.Settings.LoadAtStartup = settings.LoadAtStartup;
         globals.Settings.MinimizeOnExit = settings.MinimizeOnExit;
         globals.Settings.MinimizeToTray = settings.MinimizeToTray;
         globals.Settings.StartTime = settings.StartTime;
         globals.Settings.StopTime = settings.StopTime;
         globals.Settings.SaveSettings();
     }
     catch(Exception e)
     {
         log.LogWarning("Failed to save the application's settings: " + e.Message);
     }
 }
예제 #2
0
 /// <summary>
 /// Constructs a new instance of the <see cref="Globals"/> class.
 /// </summary>
 private Globals()
 {
     //Initialize the variables. Interning the strings saves us some memory.
     userAgent = String.Intern("CrawlWave/1.2 (crawlwave[at]spiderwave.aueb.gr http://www.spiderwave.aueb.gr/");
     string path = GetAppPath();
     try
     {
         //If the application cannot write to its local path then it will attempt
         //to write in the personal path of the current user, under Application Data
         FileStream fs =  File.Create(path + "test.dat");
         fs.Close();
         File.Delete(path + "test.dat");
     }
     catch
     {
         path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\CrawlWave\\";
     }
     appPath = String.Intern(path);
     dataPath = String.Intern(path + "data\\");
     workPath = String.Intern(path + "work\\");
     //if the data and work directories do not exist create them
     if(!Directory.Exists(dataPath))
     {
         Directory.CreateDirectory(dataPath);
     }
     if(!Directory.Exists(workPath))
     {
         Directory.CreateDirectory(workPath);
     }
     logEventSource = String.Intern("CrawlWave");
     logFileName = String.Intern(dataPath + "CrawlWave.Client.log");
     settings = new ClientSettings(dataPath + "CrawlWave.Client.Config.xml");
     settings.LoadSettings();
     clientInfo = new ClientInfo();
     clientInfo.UserID = settings.UserID;
     clientInfo.ClientID = settings.ClientID;
     clientInfo.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
     systemLog = new SystemEventLogger(logEventSource);
     fileLog = new FileEventLogger(logFileName, true, logEventSource);
 }
예제 #3
0
 /// <summary>
 /// Loads the <see cref="ClientSettings"/> of the Client and populates the fields.
 /// </summary>
 private void LoadSettings()
 {
     settings = core.GetSettings();
     txtUsername.Text = settings.UserName;
     if(settings.UserName != String.Empty)
     {
         grpUserInformation.Enabled = false;
     }
     else
     {
         grpUserStatistics.Enabled = false;
         DisableControls();
     }
     txtEmail.Text = settings.Email;
     chkLoadAtStartup.Checked = settings.LoadAtStartup;
     chkMinimizeToSystemTray.Checked = settings.MinimizeToTray;
     chkMinimizeOnExit.Checked = settings.MinimizeOnExit;
     SelectConnectionSpeed(settings.ConnectionSpeed);
     chkEnableScheduler.Checked = settings.EnableScheduler;
     dtStartTime.Enabled = settings.EnableScheduler;
     dtStopTime.Enabled = settings.EnableScheduler;
     lblStartTime.Enabled = settings.EnableScheduler;
     lblStopTime.Enabled = settings.EnableScheduler;
     dtStartTime.Value = settings.StartTime;
     dtStopTime.Value = settings.StopTime;
     state = core.GetState();
     EnableControls(state);
 }
예제 #4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmdRegister_Click(object sender, System.EventArgs e)
 {
     try
     {
         txtUsername.Text = txtUsername.Text.Trim();
         if(txtUsername.Text == String.Empty)
         {
             MessageBox.Show("You must supply a username!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             txtUsername.Focus();
             return;
         }
         txtPassword.Text = txtPassword.Text.Trim();
         if(txtPassword.Text == String.Empty)
         {
             MessageBox.Show("You must supply a password!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             txtPassword.Focus();
             return;
         }
         EmailValidator validator = EmailValidator.Instance();
         if(!validator.Validate(txtEmail.Text))
         {
             MessageBox.Show("You must supply a valid email address!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             txtEmail.Focus();
             return;
         }
     }
     catch
     {}
     try
     {
         Cursor = Cursors.WaitCursor;
         SerializedException sx = core.RegisterUser(txtUsername.Text, txtPassword.Text, txtEmail.Text);
         if(sx!=null)
         {
             MessageBox.Show("An error occured during the registration: " + sx.Message);
             return;
         }
         else
         {
             settings = core.GetSettings();
             LoadSettings();
             EnableControls(CrawlerState.Stopped);
         }
     }
     catch(Exception ex)
     {
         ex.ToString();
     }
     finally
     {
         Cursor = Cursors.Default;
     }
 }
예제 #5
0
 /// <summary>
 /// Constructs a new instance of the <see cref="Globals"/> class.
 /// </summary>
 private Globals()
 {
     //Initialize the variables
     string path = GetAppPath();
     try
     {
         //If the application cannot write to its local path then it will attempt
         //to write in the personal path of the current user, under Application Data
         FileStream fs =  File.Create(path + "test.dat");
         fs.Close();
         File.Delete(path + "test.dat");
     }
     catch
     {
         path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\CrawlWave\\";
     }
     appPath = String.Intern(path);
     logEventSource = String.Intern("CrawlWave.ClientScheduler");
     logFileName = String.Intern(appPath + "CrawlWave.ClientScheduler.log");
     settings = new ClientSettings(appPath + "data\\CrawlWave.Client.config.xml");
     settings.LoadSettings();
     clientInfo = new ClientInfo();
     clientInfo.UserID = settings.UserID;
     clientInfo.ClientID = settings.ClientID;
     clientInfo.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
     systemLog = new SystemEventLogger(logEventSource);
     fileLog = new FileEventLogger(logFileName, true, logEventSource);
 }