public SetupSplash() { InitializeComponent(); this.DescriptionLabel.Size = new System.Drawing.Size(0, 83); String descriptionText = "Welcome! This application will consolidate consolidating your pictures into a single location! \n"; descriptionText += "You'll no longer have to wonder where any pictures are and backups will be a snap!\n"; descriptionText += "\nBefore we begin, we'll need:\n"; descriptionText += " A place to store the pictures - this needs to be a computer with a lot of hard drive space \n"; descriptionText += " and the directory needs to be \'shared\' for everyone (sorry, no password is supported yet)\n"; descriptionText += " to learn how to share, visit: \n"; descriptionText += " http://windows.microsoft.com/en-US/windows7/Share-files-with-someone\n"; descriptionText += "\n The directories where you normally keep your pictures. This is a location where you have access and \n"; descriptionText += " don\'t have to give administrator rights. It's normally \'My Pictures\' or on your Desktop\n"; descriptionText += "\nWhen you're ready, click the Start button below!"; this.DescriptionLabel.Text = descriptionText; try { PixDBInterface pixDb = new PixDBInterface(); if (!pixDb.CheckIfDbSetup()) { pixDb.CreateDatabase(); pixDb.SetupTables(); } } catch (Exception e) { } }
static void Main(string[] args) { Logger log = new Logger("Program::main"); if (args.Length > 0) { string cmd = args[0]; if (cmd.CompareTo("shutdown") == 0) { PixDBInterface db = new PixDBInterface(); if (db.CheckIfDbSetup()) { try { // just in case we crashed and the process id in the db is bad string procId = db.ReadConfigValue("ServiceProcessId"); int nProcessID = Convert.ToInt32(procId); Process otherProc = Process.GetProcessById(nProcessID); otherProc.Kill(); } catch (Exception) { } } return; } } try { Mutex.OpenExisting("PersonalPictureManagerService"); log.WriteMessage("Opened the existing mutex"); return; } catch (WaitHandleCannotBeOpenedException) { bool createdNew; m_lockingMutex = new Mutex(true, "PersonalPictureManagerService", out createdNew); log.WriteMessage("created the mutex"); } try { PixDBInterface dbConn = new PixDBInterface(); if (!dbConn.CheckIfDbSetup()) { log.WriteMessage("setting up database"); dbConn.CreateDatabase(); dbConn.SetupTables(); } int nProcessID = Process.GetCurrentProcess().Id; dbConn.UpdateConfigValue("ServiceProcessId", Convert.ToString(nProcessID)); String runningVer = Assembly.GetExecutingAssembly().GetName().Version.ToString(); dbConn.UpdateConfigValue("ServiceProcessVersion", runningVer); log.WriteMessage("starting"); string runningFile = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; string newFile = ConfigManager.GetDataStoreDir() + ConfigManager.AppName; log.WriteMessage("newFile: " + newFile); if ((File.Exists(newFile)) && (runningFile.CompareTo(newFile) != 0)) { log.WriteMessage("running: " + newFile); Process.Start(newFile); System.Environment.Exit(0); } OnConfigTimedEvent(null, null); string server = dbConn.ReadConfigValue("ServerName"); string serverUser = dbConn.ReadConfigValue("ServerLogin"); string serverPass = dbConn.ReadConfigValue("ServerPass"); dirList = dbConn.ReadDirsToWatch(0); m_fileHelper = new PixFileHelper(server, serverUser, serverPass); m_fileHelper.WatchDirs(dirList); // update config timer aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); // Set the Interval to 5 min aTimer.Interval = 300000; aTimer.Enabled = true; // check website for new rev timer configTimer.Elapsed += new ElapsedEventHandler(OnConfigTimedEvent); // Set the Interval to 30 min configTimer.Interval = 1800000; configTimer.Enabled = true; // check if anything in the queue queueTimer.Elapsed += new ElapsedEventHandler(OnQueueTimedEvent); // Set the Interval to 30 min queueTimer.Interval = 1800000; //queueTimer.Interval = 1000; queueTimer.Enabled = true; while (true) Thread.Sleep(Timeout.Infinite); } catch (Exception e) { System.IO.File.WriteAllText(@"error_log.txt", e.Message); System.IO.File.WriteAllText(@"error_log.txt", e.StackTrace); } }