コード例 #1
0
ファイル: Globals.cs プロジェクト: modernist/CrawlWave
 /// <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);
 }
コード例 #2
0
ファイル: Globals.cs プロジェクト: modernist/CrawlWave
 /// <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);
 }