Пример #1
0
        //Constructor MUST be called on UI thread (we capture the UI synchronization context for use later)
        public JobStore()
        {
            IsLocalExecution         = true;
            CurrentExecutionPoolText = "Local Execution";
            PhysicalCoreCount        = LocalPool.GetNumberOfPhysicalCores();
            SelectedThreadCount      = Properties.Settings.Default.SelectedThreadCount; //TODO: load setting from a previous session?
            if (SelectedThreadCount == 0)
            {
                SelectedThreadCount = PhysicalCoreCount;
            }
            ThreadOptionsList = Enumerable.Range(1, USER_THREAD_COUNT_MAX).ToList();
            if (PhysicalCoreCount > USER_THREAD_COUNT_MAX)
            {
                ThreadOptionsList.Add(PhysicalCoreCount);
            }

            UiTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext();

            TrackedJobs             = new List <JobViewModel>();
            Manager                 = new JobManagerFramework.JobManager(SelectedThreadCount);
            Manager.Server.IsRemote = false;
            Manager.LoadSavedJobs();

            Manager.JobAdded           += Manager_JobAdded;
            Manager.JobCollectionAdded += JobCollectionAddedHandler;

            this.TrackedJobsChanged += (sender, args) =>
            {
                PropertyChanged.Notify(() => HasNoRunningJobs);
            };
        }
Пример #2
0
        public void StartJobManager()
        {
            Manager = new JobManagerFramework.JobManager(localConcurrentThreads: 1);
            Manager.Server.IsRemote = false;
            Manager.LoadSavedJobs();
            Manager.JobAdded           += Manager_JobAdded;
            Manager.JobCollectionAdded += JobCollectionAddedHandler;
            Manager.SwitchToRemotePool(remoteServerUri, username, password);

            // Manager.ReRunJobs(new [] {j });
            // Manager.AbortJobs(new [] {j });
            // Manager.SwitchToLocalPool(SelectedThreadCount);
        }
Пример #3
0
        public Configuration(JobManagerFramework.JobManager manager, string password = null)
        {
            this.manager = manager;
            InitializeComponent();
            AcceptButton = btnSave;
            chbRemoteExec.CheckedChanged += new EventHandler(delegate(object o, EventArgs args)
            {
                panelRemote.Enabled = chbRemoteExec.Checked;
            });
            panelRemote.Enabled = chbRemoteExec.Checked;


            this.txtUsername.Text = Properties.Settings.Default.UserID;

            if (string.IsNullOrEmpty(password) == false)
            {
                // auto-configure
                this.mtbPassword.Text = password;
                Properties.Settings.Default.RemoteExecution = true;
            }

            comboVehicleForgeURL.Items.Add("https://gamma.vehicleforge.org");
            comboVehicleForgeURL.Items.Add("https://beta.vehicleforge.org");
        }
Пример #4
0
        public JobManagerForm(Func <JobManagerFramework.JobManager> getJobManager, Dictionary <string, string> settings = null)
        {
            Func <string> getHeader       = () => META.Logger.Header();
            var           getHeaderResult = getHeader.BeginInvoke(null, null);

            InitializeComponent();

            InitJobQueue();

            this.toolStripStatusLabel      = new SpringLabel();
            this.toolStripStatusLabel.Text = "Loading";
            this.statusStrip1.Items.Add(this.toolStripStatusLabel);
            this.lvJobQueue.DoubleClick += showInExplorerToolStripMenuItem_Click;

            this.remoteServiceStatusForm = new RemoteServiceStatusForm();

            if (settings != null)
            {
                string value = string.Empty;
                if (settings.TryGetValue("-u", out value))
                {
                    Properties.Settings.Default.UserID = value;
                }
                if (settings.TryGetValue("-p", out value))
                {
                    password = value;
                }
                if (settings.TryGetValue("-U", out value))
                {
                    Properties.Settings.Default.VehicleForgeUri = value;
                }
            }

            //this.TempDir = Path.Combine(System.IO.Path.GetTempPath(), "META_JobManager");

            this.TempDir = Path.Combine(
                System.IO.Path.GetTempPath(),
                Path.Combine("META", "JobManager"));


            if (Directory.Exists(this.TempDir) == false)
            {
                Directory.CreateDirectory(this.TempDir);
            }

            this.TraceFileName = Path.Combine(this.TempDir, string.Format("JobManagerLog.trace.{0}.txt", Process.GetCurrentProcess().Id));

            this.logToolStripMenuItem.ToolTipText += string.Format(" ({0})", Path.GetFullPath(this.TraceFileName));

            var           fs     = new FileStream(this.TraceFileName, FileMode.Create);
            TraceListener fileTL = new TextWriterTraceListener(fs)
            {
                TraceOutputOptions = TraceOptions.DateTime
            };

            // use TraceXXX to get timestamp per http://stackoverflow.com/questions/863394/add-timestamp-to-trace-writeline

            Trace.AutoFlush = true;
            Trace.Listeners.Add(fileTL);

            Trace.TraceInformation(getHeader.EndInvoke(getHeaderResult));

            manager           = getJobManager();
            this.FormClosing += (sender, args) =>
            {
                if (manager.HasIncompleteSots)
                {
                    DialogResult dr = MessageBox.Show(this, "Some jobs have not been posted and will be lost. Do you want to exit anyways?", "JobManager", MessageBoxButtons.YesNo);
                    if (dr == DialogResult.No)
                    {
                        args.Cancel = true;
                        return;
                    }
                }
                if (manager.IsRemote == false)
                {
                    int unfinished = manager.UnfinishedJobCount;
                    if (unfinished > 0)
                    {
                        DialogResult dr = MessageBox.Show(this, unfinished + " jobs have not completed. Do you want to exit and terminate running processes?", "JobManager", MessageBoxButtons.YesNo);
                        if (dr == DialogResult.No)
                        {
                            args.Cancel = true;
                            return;
                        }
                    }
                }
                Trace.TraceInformation("JobManager is closing");
                manager.Dispose();
                manager = null;
            };
            this.Resize       += new EventHandler(JobManager_Resize);
            NotifyIcon         = new NotifyIcon();
            NotifyIcon.Icon    = Icon;
            NotifyIcon.Visible = false;
            NotifyIcon.Click  += new EventHandler(NotifyIcon_Click);
            this.exitToolStripMenuItem.Click += new EventHandler((o, ev) =>
            {
                this.Close();
            });

            manager.JobAdded += Manager_JobAdded;
            manager.SotAdded += Manager_SotAdded;
            //pool.JobStatusChanged += JobStatusChanged;

            if (settings.ContainsKey("-i"))
            {
                this.toolStripStatusLabel.Text             = "Configured for local execution.";
                this.remoteStatusToolStripMenuItem.Enabled = false;
                this.remoteStatusToolStripMenuItem.Visible = false;
                return;
            }
            Shown += new EventHandler(delegate(object o, EventArgs args)
            {
                if (this.Configure() == DialogResult.OK)
                {
                    lock (this)
                    {
                        //TODO: determine if set for remote execution and show in status bar
                        if (manager.IsRemote)
                        {
                            this.toolStripStatusLabel.Text             = "Configured for remote execution.";
                            this.remoteStatusToolStripMenuItem.Enabled = true;
                            this.remoteStatusToolStripMenuItem.Visible = true;
                        }
                        else
                        {
                            this.toolStripStatusLabel.Text             = "Configured for local execution.";
                            this.remoteStatusToolStripMenuItem.Enabled = false;
                            this.remoteStatusToolStripMenuItem.Visible = false;
                        }

                        manager.ServiceStatusUpdated += UpdateServiceStatus;
                        manager.LoadSavedJobs();
                    }
                }
                else
                {
                    this.toolStripStatusLabel.Text = "Closing";
                    this.Close();
                }
            });

            Trace.TraceInformation("Application started.");
        }