Exemplo n.º 1
0
        private void Step5_ShowStep(object sender, TSWizards.ShowStepEventArgs e)
        {
            Step2 step2 = Wizard.GetStep("Step2") as Step2;

            System.Collections.Specialized.StringCollection order = step2.GetOrder();

            itemsPrepared.Items.Clear();

            foreach (string str in order)
            {
                itemsPrepared.Items.Add(str);
            }
        }
Exemplo n.º 2
0
        private void onShowStep(object sender, TSWizards.ShowStepEventArgs e)
        {
            Step2 step2 = Wizard.GetStep("Step2") as Step2;

            step2.SetProgressBar(0);
            step2.SetMaximumProgressBar(m_hosts.Count);
            _progress = new Progress <string>(data => step2.IncrementProgressBar(0));

            onDoWorkAsync();
            //if (backgroundWorker1.IsBusy != true)
            //{
            //    backgroundWorker1.RunWorkerAsync();
            //}

            //int nofExistingDirectories = 0;
            //Step2 step2 = Wizard.GetStep("Step2") as Step2;

            //// TODO: Add parallel for loop calculation
            //for (int i = 0; i < m_hosts.Count; i++)
            //{
            //    if (CheckNetworkDrive(m_hosts[i]))
            //    {
            //        nofExistingDirectories++;

            //        float percent = (float)i / (float)m_hosts.Count * 100.0f;
            //        step2.SetProgressBar((int)percent);
            //        step2.SetResult(nofExistingDirectories);
            //    }
            //}


            //Parallel.For(0, m_hosts.Count,
            //    index =>
            //    {
            //        if (CheckNetworkDrive(m_hosts[index]))
            //        {
            //            nofExistingDirectories++;

            //            float percent = (float)index / (float)m_hosts.Count * 100.0f;
            //            step2.SetProgressBar((int)percent);
            //            step2.SetResult(nofExistingDirectories);
            //        }
            //    });
        }
Exemplo n.º 3
0
        private void Step3_ShowStep(object sender, TSWizards.ShowStepEventArgs e)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            Step2 step2 = Wizard.GetStep("Step2") as Step2;

            if (step2 == null)
            {
                throw new ApplicationException("Step2 of the wizard wasn't really step2");
            }

            StringCollection order = step2.GetOrder();

            foreach (string item in order)
            {
                sb.AppendFormat("{0},\r\n", item);
            }

            orderConfirm.Text = sb.ToString();
        }
Exemplo n.º 4
0
		private void DoWork()
		{
			Step2 step2 = Wizard.GetStep("Step2") as Step2;

			if( step2 == null )
			{
				throw new ApplicationException("Step2 of the wizard wasn't really step2");
			}

			StringCollection order = step2.GetOrder();

			if( order.Count > 0 )
			{
				BeginPreparingOrder(order.Count);

				foreach(string item in order)
				{
					Preparing(item);
					Thread.Sleep(1000);
					Prepared();
				}
			}
		}
Exemplo n.º 5
0
        // Replace with call to private me
        //private void onDoWork(object sender, DoWorkEventArgs e)
        //{
        //    Task _ = onDoWorkAsync(e);
        //}
        private async Task onDoWorkAsync()
        {
            int   nofExistingDirectories = 0;
            Step2 step2 = Wizard.GetStep("Step2") as Step2;

            var tasks = m_hosts.Select(h => CheckNetworkDrive(h, TimeSpan.FromSeconds(300)));

            bool[] results = await Task.WhenAll(tasks);

            /*
             * Task entireTask = Task.WhenAll(tasks);
             * int i = 0;
             * int foundRemoteDirs = 0;
             * bool res;
             * while (res = await Task.WhenAny(entireTask, Task.Delay(6000)) != entireTask)
             * {
             *  var progressReporter = new ProgressReporter();
             *  float percent = (float)i / (float)m_hosts.Count * 100.0f;
             *  step2.SetProgressBar((int)percent);
             *  i++;
             *
             *  if (res)
             *  {
             *      step2.SetResult(foundRemoteDirs);
             *      foundRemoteDirs++;
             *  }
             * }
             */

            //step2.SetProgressBar(100);
            //bool[] results = await Task.WhenAll(tasks);
            //Trace.WriteLine(results.Count(m => m));
            ////TODO: Add parallel for loop calculation
            //for (int i = 0; i < m_hosts.Count; i++)
            //{
            //    Trace.Write(string.Format("{0}: Checking {1} ....", i, m_hosts[i]));
            //    bool res = await CheckNetworkDrive(m_hosts[i], TimeSpan.FromSeconds(5));
            //    Trace.WriteLine(res.ToString());
            //    //if (res)
            //    //{
            //    //    nofExistingDirectories++;
            //    //    step2.SetResult(nofExistingDirectories);
            //    //}

            //    //float percent = (float)i / (float)m_hosts.Count * 100.0f;
            //    //step2.SetProgressBar((int)percent);
            //}

            //Parallel.For(0, m_hosts.Count,
            //    async index =>
            //    {
            //        bool res = await CheckNetworkDrive(m_hosts[index], TimeSpan.FromSeconds(1));
            //        if (res)
            //        {
            //            nofExistingDirectories++;
            //            step2.SetResult(nofExistingDirectories);
            //        }

            //        float percent = (float)index / (float)m_hosts.Count * 100.0f;
            //        step2.SetProgressBar((int)percent);
            //    });
        }