Ejemplo n.º 1
0
 /// <summary>
 /// The constructor is private so that only the class itself can create an instance.
 /// </summary>
 private ServerSettings()
 {
     appName = "CrawlWave.Server";
     log = new SystemEventLogger(appName);
     logLevel = CWLogLevel.LogError; // by default assume only errors must be logged
     dbLogOptions = CWClientActions.LogNothing; //by default assume it's a production rel.
     dataFilesPath = String.Empty;
     connectionString = String.Empty;
     LoadSettings();
     robots = RobotsCache.Instance();
     robots.DBConnectionString = ProvideConnectionString();
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
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);
 }