Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();
            (this.Content as FrameworkElement).DataContext = this;

            this.MaxWidth  = 10000;
            this.MaxHeight = 10000;
            this.Loaded   += window1Loaded;
            CollectorArgs options = CollectorArgs.ParseArgs(Environment.GetCommandLineArgs());

            try
            {
                //SetWindowPositionAndDimensions(options);
                string[] files     = options.DataFile.Split(',');
                string[] senderIds = options.SenderId.Split(',');

                int taskId = int.Parse(senderIds[0]);
                taskFile = new FileInfo(files[0]);
                int projectId = int.Parse(senderIds[1]);
                projectFile = new FileInfo(files[1]);
                this.Title  = string.Format("[{0},{1}] - {2}", taskId, projectId, this.Title);

                taskNetList           = new TodoNetList();
                taskNetList.LogEvent += taskNetList_LogEvent;
                taskNetList.CurrentItemChangedEvent += taskNetList_CurrentItemChangedEvent;
                projectNetList           = new ProjectNetList();
                projectNetList.LogEvent += projectNetList_LogEvent;
                projectNetList.CurrentItemChangedEvent += projectNetList_CurrentItemChangedEvent;
                taskNetList.Start <Todo>(options.ConnectionString, taskId, options.LogFile, taskFile);
                projectNetList.Start <Project>(options.ConnectionString, projectId, options.LogFile, projectFile);

                System.Timers.Timer autoSaveTimer = new System.Timers.Timer();
                autoSaveTimer.Elapsed += autoSaveTimer_Elapsed;
                autoSaveTimer.Interval = 5000;
                autoSaveTimer.Enabled  = true;

                System.Timers.Timer halfHourSaveTimer = new System.Timers.Timer();
                halfHourSaveTimer.Elapsed += halfHourSaveTimer_Elapsed;
                halfHourSaveTimer.Interval = 1800000;
                halfHourSaveTimer.Enabled  = true;

                if (options.Left > 0 || options.Top > 0)
                {
                    this.Left = options.Left;
                    this.Top  = options.Top;
                }
                if (options.Width > 0 || options.Height > 0)
                {
                    this.Width  = options.Width;
                    this.Height = options.Height;
                }
            }

            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(string.Format("Start Exception: {0}", ex.Message));
                Console.ForegroundColor = ConsoleColor.Green;
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            DataArgs options = DataArgs.ParseArgs(args);

            try
            {
                SetWindowPositionAndDimensions(options);
                string[] files     = options.DataFile.Split(',');
                string[] senderIds = options.SenderId.Split(',');

                int taskId = int.Parse(senderIds[0]);
                taskFile = new FileInfo(files[0]);
                int projectId = int.Parse(senderIds[1]);
                projectFile = new FileInfo(files[1]);

                taskNetList    = new TodoNetList();
                projectNetList = new ProjectNetList();
                taskNetList.Start <Todo>(options.ConnectionString, taskId, options.LogFile, taskFile);
                projectNetList.Start <Project>(options.ConnectionString, projectId, options.LogFile, projectFile);

                System.Timers.Timer autoSaveTimer = new System.Timers.Timer();
                autoSaveTimer.Elapsed += autoSaveTimer_Elapsed;
                autoSaveTimer.Interval = 5000;
                autoSaveTimer.Enabled  = true;

                System.Timers.Timer halfHourSaveTimer = new System.Timers.Timer();
                halfHourSaveTimer.Elapsed += halfHourSaveTimer_Elapsed;
                halfHourSaveTimer.Interval = 1800000;
                halfHourSaveTimer.Enabled  = true;
            }

            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(string.Format("Start Exception: {0}", ex.Message));
                Console.ForegroundColor = ConsoleColor.Green;
            }

            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("Press any key to exit.");
            ConsoleKeyInfo key = Console.ReadKey();

            if (key.Key == ConsoleKey.S)
            {
                Console.ReadKey();
            }
        }