Exemplo n.º 1
0
 protected void OnComplete(bool succeeded, Exception exception)
 {
     if (!succeeded)
     {
         int num = LocalizedException.GenerateErrorCode(exception);
         this.workUnit.Errors.Add(new ErrorRecord(exception, num.ToString("X"), ErrorCategory.OperationStopped, null));
     }
     this.workUnit.Status = (succeeded ? WorkUnitStatus.Completed : WorkUnitStatus.Failed);
 }
 public static void LogPeriodicFailure(this ExEventLog.EventTuple tuple, string userName, string requestUrl, Exception exception, string featureInfo)
 {
     if (tuple.IsEnabled())
     {
         using (new ThreadCultureSwitch())
         {
             HttpContext httpContext = HttpContext.Current;
             if (string.IsNullOrEmpty(userName))
             {
                 userName = ((httpContext != null && httpContext.User != null && httpContext.User.Identity != null) ? httpContext.User.Identity.GetSafeName(true) : string.Empty);
             }
             string periodicKey = requestUrl + LocalizedException.GenerateErrorCode(exception) + userName;
             tuple.LogPeriodicEvent(periodicKey, new object[]
             {
                 userName,
                 requestUrl,
                 exception.GetTraceFormatter().ToString(),
                 featureInfo
             });
         }
     }
 }
Exemplo n.º 3
0
        // Token: 0x060010C7 RID: 4295 RVA: 0x000337D4 File Offset: 0x000319D4
        private Collection <PSObject> ClosePipeline(MonadAsyncResult asyncResult)
        {
            ExTraceGlobals.IntegrationTracer.Information((long)this.GetHashCode(), "-->MonadCommand.ClosePipeline()");
            if (base.PowerShell == null)
            {
                throw new InvalidOperationException("The command is not currently executing.");
            }
            Exception             ex     = null;
            Collection <PSObject> result = new Collection <PSObject>();

            ExTraceGlobals.VerboseTracer.Information((long)this.GetHashCode(), "\tWaiting for the pipeline to finish.");
            try
            {
                base.PowerShell.EndInvoke(asyncResult.PowerShellIAsyncResult);
            }
            catch (Exception)
            {
                ExTraceGlobals.IntegrationTracer.Information((long)this.GetHashCode(), "\tPipeline End Invoke Fired an Exception.");
                if (base.PowerShell.InvocationStateInfo.Reason == null)
                {
                    throw;
                }
            }
            ExTraceGlobals.IntegrationTracer.Information((long)this.GetHashCode(), "\tPipeline finished.");
            if (base.PowerShell.InvocationStateInfo.State == PSInvocationState.Completed && base.PowerShell.Streams.Error.Count == 0)
            {
                result = asyncResult.Output.ReadAll();
            }
            else if (base.PowerShell.InvocationStateInfo.State == PSInvocationState.Stopped || base.PowerShell.InvocationStateInfo.State == PSInvocationState.Failed || base.PowerShell.Streams.Error.Count > 0)
            {
                ex = MonadCommand.DeserializeException(base.PowerShell.InvocationStateInfo.Reason);
                if (ex != null && (this.IsHandledException(ex) || base.PowerShell.InvocationStateInfo.State == PSInvocationState.Stopped))
                {
                    ThrowTerminatingErrorException ex2 = ex as ThrowTerminatingErrorException;
                    ErrorRecord errorRecord;
                    if (ex2 != null)
                    {
                        errorRecord = ex2.ErrorRecord;
                    }
                    else
                    {
                        errorRecord = new ErrorRecord(ex, LocalizedException.GenerateErrorCode(ex).ToString("X"), ErrorCategory.InvalidOperation, null);
                    }
                    if (base.WorkUnits != null)
                    {
                        for (int i = 0; i < base.WorkUnits.Length; i++)
                        {
                            if (base.WorkUnits[i].CurrentStatus == 2)
                            {
                                if (base.PowerShell.InvocationStateInfo.State != PSInvocationState.Stopped)
                                {
                                    this.lastUnhandledError = errorRecord;
                                    break;
                                }
                            }
                            else
                            {
                                base.ReportError(errorRecord, i);
                                base.WorkUnits[i].CurrentStatus = 3;
                            }
                        }
                    }
                    else
                    {
                        base.ReportError(errorRecord, -1);
                    }
                    ex = null;
                }
                if (ex == null)
                {
                    result = asyncResult.Output.ReadAll();
                    base.DrainErrorStream(-1);
                }
                asyncResult.Output.Complete();
                base.PowerShell.Streams.Error.Complete();
            }
            this.pipelineStateAtClose = base.PowerShell.InvocationStateInfo.State;
            if (ex != null && !(ex is PipelineStoppedException))
            {
                ExTraceGlobals.IntegrationTracer.Information((long)this.GetHashCode(), ex.ToString());
                if (!(ex is CmdletInvocationException))
                {
                    int innerErrorCode = LocalizedException.GenerateErrorCode(ex);
                    ex = new CommandExecutionException(innerErrorCode, this.Command.ToString(), ex);
                }
                this.InteractionHandler.ReportException(ex);
                throw ex;
            }
            if (this.LastUnhandledError != null)
            {
                throw new MonadDataAdapterInvocationException(this.LastUnhandledError, this.Command.ToString());
            }
            ExTraceGlobals.IntegrationTracer.Information((long)this.GetHashCode(), "<--MonadCommand.ClosePipeline()");
            return(result);
        }
Exemplo n.º 4
0
        private void CheckClusterStateForDagServerRemoval()
        {
            this.m_output.AppendLogMessage("CheckClusterStateForDagServerRemoval entered. m_removeNode={0}, m_destroyCluster={1}", new object[]
            {
                this.m_removeNode,
                this.m_destroyCluster
            });
            try
            {
                this.m_clusDag = AmCluster.OpenDagClus(this.m_dag);
            }
            catch (AmClusterException ex)
            {
                this.m_output.AppendLogMessage("Trying to open the cluster on the servers in the DAG '{0}' failed with exception {1}", new object[]
                {
                    this.m_dagName,
                    ex
                });
                this.m_output.WriteErrorSimple(new DagTaskRemoveDagServerMustHaveQuorumException(this.m_dagName));
            }
            using (DumpClusterTopology dumpClusterTopology = new DumpClusterTopology(this.m_clusDag, this.m_output))
            {
                dumpClusterTopology.Dump();
            }
            this.m_output.AppendLogMessage("Trying to open the node on the cluster.", new object[0]);
            IAmClusterNode amClusterNode = null;

            try
            {
                amClusterNode = this.m_clusDag.OpenNode(this.m_mailboxAmServerName);
            }
            catch (ClusterException ex2)
            {
                this.m_output.AppendLogMessage("OpenNode threw an exception. It's probably because the server is no longer clustered. Proceeding with -configurationonly.", new object[0]);
                this.m_output.AppendLogMessage("For the records, the exception was {0}.", new object[]
                {
                    ex2
                });
                this.m_configurationOnly   = true;
                this.m_mailboxServerIsDown = true;
                return;
            }
            using (amClusterNode)
            {
                AmNodeState state = amClusterNode.GetState(false);
                this.m_output.AppendLogMessage("Node.GetState( {0} ) reports that it is {1}.", new object[]
                {
                    this.m_mailboxAmServerName,
                    state
                });
                if (!AmClusterNode.IsNodeUp(state))
                {
                    this.m_mailboxServerIsDown = true;
                }
            }
            if (!this.m_skipDagValidation)
            {
                try
                {
                    DagTaskHelper.ValidateDagClusterMembership(this.m_output, this.m_dag, this.m_clusDag, this.m_mailboxAmServerName);
                }
                catch (ClusterException ex3)
                {
                    this.DagTrace("ValidateDagClusterMembership() for the mailbox server failed possibly with error {0}, ex = {1}. This is OK.", new object[]
                    {
                        LocalizedException.GenerateErrorCode(ex3.InnerException).ToString(),
                        ex3.Message
                    });
                }
            }
            int num = this.m_clusDag.EnumerateNodeNames().Count <AmServerName>();

            this.DagTrace(string.Format("There are {0} nodes in the cluster.", num), new object[0]);
            if (num == 1)
            {
                this.m_destroyCluster = true;
            }
            else
            {
                this.m_removeNode = true;
            }
            bool destroyCluster = this.m_destroyCluster;

            this.ReopenClusterIfNecessary();
            if ((this.m_removeNode || this.m_destroyCluster) && this.m_dag.DatacenterActivationMode != DatacenterActivationModeOption.Off)
            {
                DagTaskHelper.CheckDagCanBeActivatedInDatacenter(this.m_output, this.m_dag, (ADObjectId)this.m_mailboxServer.Identity, (ITopologyConfigurationSession)base.DataSession);
            }
            this.DagTrace("CheckClusterStateForDagServerRemoval left. m_removeNode={0}, m_destroyCluster={1}.", new object[]
            {
                this.m_removeNode,
                this.m_destroyCluster
            });
        }
Exemplo n.º 5
0
        public ToolboxNode(bool isEdgeServerRoleOnly) : base(true)
        {
            ToolboxNode < > 4__this = this;
            base.DisplayName        = Strings.Toolbox;
            base.Icon      = Icons.Toolbox;
            base.HelpTopic = HelpId.ToolboxNode.ToString();
            base.ViewDescriptions.Add(ExchangeFormView.CreateViewDescription(typeof(ToolboxResultPane)));
            RefreshableComponent refreshableComponent = new RefreshableComponent();

            base.DataSource = refreshableComponent;
            refreshableComponent.DoRefreshWork += delegate(object sender, RefreshRequestEventArgs e)
            {
                DataList <Tool> dataList     = new DataList <Tool>();
                DataProvider    dataProvider = new RegistryDataProvider(Registry.LocalMachine, "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\AdminTools\\Toolbox", ConfigurationContext.Setup.InstallPath);
                dataProvider.Query();
                for (int i = 0; i < dataProvider.Tools.Count; i++)
                {
                    Tool tool = dataProvider.Tools[i];
                    if (tool.Name != string.Empty && Tool.IsToolDuplicate(dataList, tool))
                    {
                        tool.ValidTool = false;
                        tool.AddErrorMessage(Strings.DuplicateTool(tool.DataSource));
                    }
                    else if (!isEdgeServerRoleOnly || !tool.NonEdgeTool)
                    {
                        dataList.Add(tool);
                    }
                }
                e.Result = dataList;
            };
            refreshableComponent.RefreshCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
            {
                if (e.Cancelled)
                {
                    return;
                }
                DataList <Tool> dataList = (DataList <Tool>)e.Result;
                this.ValidTools.Clear();
                DataList <Tool> dataList2 = new DataList <Tool>();
                for (int i = 0; i < dataList.Count; i++)
                {
                    if (dataList[i].ValidTool)
                    {
                        this.ValidTools.Add(dataList[i]);
                    }
                    else
                    {
                        dataList2.Add(dataList[i]);
                    }
                }
                if (dataList2.Count > 0)
                {
                    List <WorkUnit> list = new List <WorkUnit>();
                    for (int j = 0; j < dataList2.Count; j++)
                    {
                        WorkUnit workUnit = new WorkUnit();
                        workUnit.Text = dataList2[j].DataSource;
                        Exception ex = new Exception(dataList2[j].ErrorMessage);
                        workUnit.Errors.Add(new ErrorRecord(ex, LocalizedException.GenerateErrorCode(ex).ToString("X"), ErrorCategory.InvalidOperation, null));
                        workUnit.Status = WorkUnitStatus.Failed;
                        list.Add(workUnit);
                    }
                    UIService.ShowError(Strings.ErrorDialogMessage, string.Empty, list.ToArray(), base.ShellUI);
                }
            };
        }