예제 #1
0
        /// <summary>
        /// Default Page Load Event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");
            Server.ScriptTimeout = 50000;
            SectionTitle         = "EMail Manager";

            //Images in mailings must have Absolute URLs
            radDescription.EnableFilter(Telerik.Web.UI.EditorFilters.MakeUrlsAbsolute);

            if (AppLogic.ProductIsMLX())
            {
                Response.Redirect(AppLogic.AdminLinkUrl("restrictedfeature.aspx"));
            }

            if (!IsPostBack)
            {
                bool processing = false;

                //Check to see if we have any mailing manager jobs running
                if (AsyncDataStore.RetrieveRecord(Session.SessionID) != null)
                {
                    //The data store DOES contain records - lets see if it is completed
                    try
                    {
                        String[] Status = AsyncDataStore.RetrieveRecord(Session.SessionID).ToString().Split(',');

                        if (Status[0] != Status[1])
                        {
                            //Not completed.  Show status, and disable buttons.
                            ifrStatus.Visible           = true;
                            ifrStatus.Attributes["src"] = "asyncstatus.aspx?id=" + Session.SessionID;
                            ltError.Text = AppLogic.GetString("admin.mailingmgr.BulkMailSending", ThisCustomer.LocaleSetting);

                            btnRemoveEmail.Enabled = false;
                            btnSend.Enabled        = false;

                            processing = true;
                        }
                    }
                    catch { }
                }

                if (!processing && CommonLogic.QueryStringNativeInt("completed") == 1)
                {
                    //Page reloaded due to having completed processing a bulk send

                    ltError.Text = AppLogic.GetString("admin.asyncstatus.Complete", ThisCustomer.LocaleSetting);
                    divStatus.Attributes["class"] = "noticeMsg";
                }
            }
            else
            {
            }
        }
예제 #2
0
        internal IEnumerator <DSResource> InvokeCmdletAsync(System.Management.Automation.PowerShell powerShell, Expression expression, EventHandler <DataAddedEventArgs> dataAddedEventHandler, AsyncCallback executionCompletionCallback, bool noStreamingResponse)
        {
            Tracer tracer = new Tracer();

            this.dataStore = new AsyncDataStore <DSResource>(expression, noStreamingResponse);
            this.output    = new PSDataCollection <PSObject>();
            tracer.CommandInvocationStart(this.cmdletInfo.CmdletName);
            powerShell.Runspace = this.runspace.Item.Runspace;
            powerShell.AddCommand(this.cmdletInfo.CmdletName);
            foreach (string key in this.parameters.Keys)
            {
                if (!this.cmdletInfo.IsSwitch(key))
                {
                    powerShell.AddParameter(key, this.parameters[key]);
                }
                else
                {
                    powerShell.AddParameter(key);
                }
            }
            this.isExecutionCompleted = false;
            using (OperationTracer operationTracer = new OperationTracer(new Action <string>(TraceHelper.Current.CmdletExecutionStart), new Action <string>(TraceHelper.Current.CmdletExecutionEnd), powerShell.Commands.ToTraceMessage()))
            {
                try
                {
                    this.timer.Start();
                    powerShell.Invoke <PSObject>(null, this.output, Utils.GetPSInvocationSettings());
                }
                catch (CommandNotFoundException commandNotFoundException1)
                {
                    CommandNotFoundException commandNotFoundException = commandNotFoundException1;
                    throw new CommandInvocationFailedException(powerShell.Commands.Commands[0].CommandText, commandNotFoundException);
                }
                catch (ParameterBindingException parameterBindingException1)
                {
                    ParameterBindingException parameterBindingException = parameterBindingException1;
                    throw new CommandInvocationFailedException(powerShell.Commands.Commands[0].CommandText, parameterBindingException);
                }
                catch (CmdletInvocationException cmdletInvocationException1)
                {
                    CmdletInvocationException cmdletInvocationException = cmdletInvocationException1;
                    throw new CommandInvocationFailedException(powerShell.Commands.Commands[0].CommandText, cmdletInvocationException);
                }
            }
            return(new BlockingEnumerator <DSResource>(this.dataStore));
        }
        /// <summary>
        /// Uses the ID parameter to retrieve async process status from a static hashtable and reports the status here
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            string sessID = CommonLogic.QueryStringCanBeDangerousContent("id");

            if (AsyncDataStore.RetrieveRecord(sessID) != null)
            {
                String[] Status = AsyncDataStore.RetrieveRecord(sessID).ToString().Split(',');

                if (Status[0] == Status[1])
                {
                    ltlTimeRemaining.Text = AppLogic.GetString("admin.asyncstatus.Complete", ThisCustomer.LocaleSetting);
                    ltlNumeric.Text       = String.Empty;
                    ltlPercent.Text       = String.Empty;
                    ltlEstRemaining.Text  = String.Empty;
                }
                else
                {
                    //Not completed.  Set the page to refresh
                    Response.AddHeader("Refresh", "5");

                    decimal  sent      = Convert.ToDecimal(Status[0]);
                    decimal  total     = Convert.ToDecimal(Status[1]);
                    DateTime startTime = Convert.ToDateTime(Status[2]);

                    decimal percentComplete = Math.Round(((sent / total) * 100), 2);

                    DateTime currentTime  = DateTime.Now;
                    decimal  elapsed      = (decimal)currentTime.Subtract(startTime).TotalSeconds;
                    decimal  opsPerSecond = ((decimal)elapsed / (decimal)sent);

                    TimeSpan remaining = TimeSpan.FromSeconds((double)(opsPerSecond * (total - sent)));

                    StringBuilder displayTime = new StringBuilder();

                    if (remaining.Days > 0)
                    {
                        displayTime.Append(remaining.Days.ToString() + " " + AppLogic.GetString("admin.common.days", ThisCustomer.LocaleSetting));
                        displayTime.Append(" ");
                    }
                    if (remaining.Hours > 0)
                    {
                        displayTime.Append(remaining.Hours.ToString() + " " + AppLogic.GetString("admin.common.Hours", ThisCustomer.LocaleSetting));
                        displayTime.Append(" ");
                    }
                    if (remaining.Minutes > 0)
                    {
                        displayTime.Append(remaining.Minutes.ToString() + " " + AppLogic.GetString("admin.common.Minutes", ThisCustomer.LocaleSetting));
                        displayTime.Append(" ");
                    }
                    if (remaining.Seconds > 0)
                    {
                        displayTime.Append(remaining.Seconds.ToString() + " " + AppLogic.GetString("admin.common.Seconds", ThisCustomer.LocaleSetting));
                        displayTime.Append(" ");
                    }


                    ltlNumeric.Text       = String.Format(AppLogic.GetString("admin.asyncstatus.SendingXofY", ThisCustomer.LocaleSetting), Status[0], Status[1]);
                    ltlPercent.Text       = percentComplete.ToString() + "%";
                    ltlTimeRemaining.Text = displayTime.ToString();;
                }
            }
        }
예제 #4
0
파일: PSCommand.cs 프로젝트: nickchal/pash
		internal IEnumerator<DSResource> InvokeCmdletAsync(System.Management.Automation.PowerShell powerShell, Expression expression, EventHandler<DataAddedEventArgs> dataAddedEventHandler, AsyncCallback executionCompletionCallback, bool noStreamingResponse)
		{
			Tracer tracer = new Tracer();
			this.dataStore = new AsyncDataStore<DSResource>(expression, noStreamingResponse);
			this.output = new PSDataCollection<PSObject>();
			tracer.CommandInvocationStart(this.cmdletInfo.CmdletName);
			powerShell.Runspace = this.runspace.Item.Runspace;
			powerShell.AddCommand(this.cmdletInfo.CmdletName);
			foreach (string key in this.parameters.Keys)
			{
				if (!this.cmdletInfo.IsSwitch(key))
				{
					powerShell.AddParameter(key, this.parameters[key]);
				}
				else
				{
					powerShell.AddParameter(key);
				}
			}
			this.isExecutionCompleted = false;
			using (OperationTracer operationTracer = new OperationTracer(new Action<string>(TraceHelper.Current.CmdletExecutionStart), new Action<string>(TraceHelper.Current.CmdletExecutionEnd), powerShell.Commands.ToTraceMessage()))
			{
				try
				{
					this.timer.Start();
					powerShell.Invoke<PSObject>(null, this.output, Utils.GetPSInvocationSettings());
				}
				catch (CommandNotFoundException commandNotFoundException1)
				{
					CommandNotFoundException commandNotFoundException = commandNotFoundException1;
					throw new CommandInvocationFailedException(powerShell.Commands.Commands[0].CommandText, commandNotFoundException);
				}
				catch (ParameterBindingException parameterBindingException1)
				{
					ParameterBindingException parameterBindingException = parameterBindingException1;
					throw new CommandInvocationFailedException(powerShell.Commands.Commands[0].CommandText, parameterBindingException);
				}
				catch (CmdletInvocationException cmdletInvocationException1)
				{
					CmdletInvocationException cmdletInvocationException = cmdletInvocationException1;
					throw new CommandInvocationFailedException(powerShell.Commands.Commands[0].CommandText, cmdletInvocationException);
				}
			}
			return new BlockingEnumerator<DSResource>(this.dataStore);
		}