LogError() public method

public LogError ( string file, string errorCode, string message, int line, int column ) : void
file string
errorCode string
message string
line int
column int
return void
Example #1
0
        protected sealed override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            bool flag = true;

            foreach (ValidatingCondition validatingCondition in this.ValidationTests)
            {
                ValidatingTaskResult validatingTaskResult = new ValidatingTaskResult();
                validatingTaskResult.ConditionDescription = validatingCondition.Description.ToString();
                if (flag)
                {
                    bool flag2 = false;
                    try
                    {
                        flag2 = validatingCondition.Validate();
                    }
                    catch (LocalizedException ex)
                    {
                        TaskLogger.LogError(new LocalizedException(Strings.ExceptionValidatingConditionFailed(ex.Message), ex));
                        validatingTaskResult.FailureDetails = ex;
                        flag2 = false;
                    }
                    validatingTaskResult.Result = (flag2 ? ValidatingTaskResult.ResultType.Passed : ValidatingTaskResult.ResultType.Failed);
                    if (!flag2 && validatingCondition.AbortValidationIfFailed)
                    {
                        flag = false;
                    }
                }
                base.WriteObject(validatingTaskResult);
            }
            TaskLogger.LogExit();
        }
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     CmdletProxy.ThrowExceptionIfProxyIsNeeded(base.CurrentTaskContext, this.DataObject, false, this.ConfirmationMessage, null);
     try
     {
         using (MailboxSession mailboxSession = ContactLinkingBaseCmdLet.OpenMailboxSessionAsAdmin(this.DataObject, this.UserAgent))
         {
             this.PerformanceTracker = new ContactLinkingPerformanceTracker(mailboxSession);
             if (this.OwnsPerformanceTrackerLifeCycle)
             {
                 this.PerformanceTracker.Start();
             }
             this.ContactLinkingOperation(mailboxSession);
         }
     }
     catch (Exception ex)
     {
         TaskLogger.LogError(ex);
         this.WriteError(ex, ErrorCategory.NotSpecified, this.Identity, true);
     }
     finally
     {
         if (this.OwnsPerformanceTrackerLifeCycle && this.PerformanceTracker != null)
         {
             this.PerformanceTracker.Stop();
         }
         this.WritePerformanceData();
         TaskLogger.LogExit();
     }
 }
Example #3
0
 private static bool InvokeFindDCSettingsMethod(out IConfigurable dcSettings)
 {
     dcSettings = null;
     HygieneDCSettings.BuildMethodsAndProperties();
     try
     {
         MethodBase methodBase = HygieneDCSettings.findDCSettingsMethod;
         object     obj        = HygieneDCSettings.globalConfigSession;
         object[]   array      = new object[4];
         array[2] = false;
         IConfigurable[] array2 = methodBase.Invoke(obj, array) as IConfigurable[];
         if (array2 != null)
         {
             dcSettings = array2.FirstOrDefault <IConfigurable>();
         }
         if (dcSettings == null)
         {
             TaskLogger.LogError(new Exception("Find<DataCenterSettings> method returned empty result"));
             return(false);
         }
     }
     catch (TargetInvocationException ex)
     {
         TaskLogger.LogError(ex.InnerException);
         return(false);
     }
     return(true);
 }
Example #4
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         this.OpenMailboxSession();
         DeviceIdentity deviceIdentity = new DeviceIdentity(this.Identity.DeviceId, this.Identity.DeviceType, this.Identity.ClientType);
         if (!DeviceInfo.RemoveDeviceFromMailbox(this.mailboxSession, deviceIdentity) && !this.deviceExistsinAD)
         {
             base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorObjectNotFound(this.Identity.ToString())), ErrorCategory.WriteError, null);
         }
         if (this.deviceExistsinAD)
         {
             base.InternalProcessRecord();
         }
         DeviceInfo.UpdateThrottlingData((IConfigurationSession)base.DataSession, this.activeSyncDevices);
     }
     catch (DataSourceTransientException ex)
     {
         TaskLogger.LogError(ex);
         base.WriteError(ex, ErrorCategory.ReadError, this.principal);
     }
     catch (StorageTransientException ex2)
     {
         TaskLogger.LogError(ex2);
         base.WriteError(ex2, ErrorCategory.ReadError, this.principal);
     }
     catch (DataSourceOperationException ex3)
     {
         TaskLogger.LogError(ex3);
         base.WriteError(ex3, ErrorCategory.InvalidOperation, this.principal);
     }
     catch (StoragePermanentException ex4)
     {
         TaskLogger.LogError(ex4);
         base.WriteError(ex4, ErrorCategory.InvalidOperation, this.principal);
     }
     catch (InvalidOperationException ex5)
     {
         TaskLogger.LogError(ex5);
         base.WriteError(ex5, ErrorCategory.InvalidOperation, this.principal);
     }
     finally
     {
         if (this.mailboxSession != null)
         {
             this.mailboxSession.Dispose();
             this.mailboxSession = null;
         }
     }
 }
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         base.InternalProcessRecord();
         if (!base.HasErrors)
         {
             ADUser            user         = this.DataObject as ADUser;
             ExchangePrincipal mailboxOwner = ExchangePrincipal.FromADUser(base.SessionSettings, user);
             using (MailboxSession mailboxSession = MailboxSession.OpenAsAdmin(mailboxOwner, CultureInfo.InvariantCulture, "Client=Management;Action=Disable-ServiceEmailChannel"))
             {
                 using (Folder folder = Folder.Bind(mailboxSession, DefaultFolderType.Root))
                 {
                     StoreObjectId receiveFolder = mailboxSession.GetReceiveFolder("IPM.Note.Custom.ServiceEmail");
                     mailboxSession.ClearReceiveFolder("IPM.Note.Custom.ServiceEmail");
                     StoreObjectId receiveFolder2 = mailboxSession.GetReceiveFolder("IPM.Note.Custom.ServiceEmail");
                     if (receiveFolder != null && (receiveFolder2 == null || !receiveFolder2.Equals(receiveFolder)))
                     {
                         using (Folder folder2 = Folder.Bind(folder.Session, receiveFolder))
                         {
                             if ((string)folder2[StoreObjectSchema.DisplayName] != null && (string)folder2[StoreObjectSchema.DisplayName] == "Service E-Mail")
                             {
                                 folder.DeleteObjects(DeleteItemFlags.HardDelete, new StoreId[]
                                 {
                                     receiveFolder
                                 });
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (StorageTransientException ex)
     {
         TaskLogger.LogError(ex);
         base.WriteError(ex, ErrorCategory.ReadError, this.DataObject);
     }
     catch (StoragePermanentException ex2)
     {
         TaskLogger.LogError(ex2);
         base.WriteError(ex2, ErrorCategory.InvalidOperation, this.DataObject);
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
 private void DeleteINIFile(string iniFile)
 {
     for (int i = 0; i < 3; i++)
     {
         try
         {
             File.Delete(iniFile);
             break;
         }
         catch (Exception e)
         {
             TaskLogger.LogError(e);
             Thread.Sleep(2000);
         }
     }
 }
        CategorizeSDKProjectsTask GetCategorizeProjectTask(string BuildScope, string FQBuildScopeDirPath, string projType, string projCategory)
        {
            if (string.IsNullOrEmpty(BuildScope) && string.IsNullOrEmpty(FQBuildScopeDirPath))
            {
                TaskLogger.LogError("Both BuildScope and FullyQualifiedBuildScopeDirPath properties cannot be null/empty. Need at least one property to be set in order for the task to execute.");
            }

            if (!string.IsNullOrWhiteSpace(BuildScope))
            {
            }


            if (!string.IsNullOrWhiteSpace(FQBuildScopeDirPath))
            {
            }


            return(null);
        }
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            DirectoryInfo directoryInfo = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(this.BundlePath.PathName)));

            try
            {
                EmbeddedCabWrapper.ExtractFiles(this.BundlePath.PathName, directoryInfo.FullName, this.DirToExtract);
            }
            catch (CabUtilityWrapperException e)
            {
                TaskLogger.LogError(e);
                TaskLogger.LogExit();
            }
            string sendToPipeline = directoryInfo.FullName + '\\' + this.DirToExtract;

            base.WriteObject(sendToPipeline);
            TaskLogger.LogExit();
        }
        private static ProvisioningHandler[] GetProvisioningHandlersImpl(Task task)
        {
            if (ProvisioningLayer.Disabled)
            {
                return(null);
            }
            ProvisioningBroker provisioningBroker = ExchangePropertyContainer.GetProvisioningBroker(task.SessionState);

            if (provisioningBroker.InitializationException != null && !task.CurrentTaskContext.InvocationInfo.CommandName.StartsWith("Get-"))
            {
                string commandName;
                if ((commandName = task.CurrentTaskContext.InvocationInfo.CommandName) == null || (!(commandName == "Set-CmdletExtensionAgent") && !(commandName == "Remove-CmdletExtensionAgent") && !(commandName == "Disable-CmdletExtensionAgent")))
                {
                    ProvisioningBrokerException ex = new ProvisioningBrokerException(Strings.ProvisioningBrokerInitializationFailed(provisioningBroker.InitializationException.Message), provisioningBroker.InitializationException);
                    TaskLogger.LogError(ex);
                    throw ex;
                }
                task.WriteWarning(provisioningBroker.InitializationException.Message);
            }
            return(provisioningBroker.GetProvisioningHandlers(task));
        }
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         base.InternalProcessRecord();
         if (!base.HasErrors)
         {
             ADUser            user         = this.DataObject as ADUser;
             ExchangePrincipal mailboxOwner = ExchangePrincipal.FromADUser(base.SessionSettings, user);
             using (MailboxSession mailboxSession = MailboxSession.OpenAsAdmin(mailboxOwner, CultureInfo.InvariantCulture, "Client=Management;Action=Enable-ServiceEmailChannel"))
             {
                 using (Folder folder = Folder.Create(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Root), StoreObjectType.Folder, "Service E-Mail", CreateMode.CreateNew))
                 {
                     folder.ClassName = "IPF.Note";
                     folder.Save();
                     folder.Load();
                     mailboxSession.SetReceiveFolder("IPM.Note.Custom.ServiceEmail", folder.StoreObjectId);
                 }
             }
         }
     }
     catch (StorageTransientException ex)
     {
         TaskLogger.LogError(ex);
         base.WriteError(ex, ErrorCategory.ReadError, this.DataObject);
     }
     catch (StoragePermanentException ex2)
     {
         TaskLogger.LogError(ex2);
         base.WriteError(ex2, ErrorCategory.InvalidOperation, this.DataObject);
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
Example #11
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            bool flag = false;

            this.summary = default(UpdateSafeList.SafeListSummary);
            CmdletProxy.ThrowExceptionIfProxyIsNeeded(base.CurrentTaskContext, (ADUser)this.DataObject, false, this.ConfirmationMessage, null);
            try
            {
                ADUser aduser = this.DataObject as ADUser;
                if (aduser == null || (aduser.RecipientType != RecipientType.UserMailbox && aduser.RecipientType != RecipientType.MailUser))
                {
                    base.WriteError(new RecipientTypeInvalidException(this.Identity.ToString()), ErrorCategory.InvalidData, aduser);
                }
                ExchangePrincipal mailboxOwner = ExchangePrincipal.FromADUser(base.SessionSettings, aduser);
                using (MailboxSession mailboxSession = MailboxSession.OpenAsAdmin(mailboxOwner, CultureInfo.InvariantCulture, "Client=Management;Action=Update-SafeList"))
                {
                    if (!mailboxSession.Capabilities.CanHaveJunkEmailRule)
                    {
                        base.WriteError(new MailboxNotJunkRuleCapableException(this.Identity.ToString()), ErrorCategory.InvalidData, aduser);
                    }
                    else if (this.EnsureJunkEmailRule)
                    {
                        this.CheckAndCreateJunkEmailRule(mailboxSession);
                    }
                    else
                    {
                        JunkEmailRule filteredJunkEmailRule = mailboxSession.FilteredJunkEmailRule;
                        switch (this.Type)
                        {
                        case UpdateType.SafeSenders:
                        case UpdateType.SafeRecipients:
                        case UpdateType.BlockedSenders:
                            flag = this.CheckAndUpdateHashes(filteredJunkEmailRule, this.Type);
                            break;

                        case UpdateType.Both:
                            if (this.CheckAndUpdateHashes(filteredJunkEmailRule, UpdateType.SafeRecipients))
                            {
                                flag = true;
                            }
                            if (this.CheckAndUpdateHashes(filteredJunkEmailRule, UpdateType.SafeSenders))
                            {
                                flag = true;
                            }
                            break;

                        case UpdateType.All:
                            if (this.CheckAndUpdateHashes(filteredJunkEmailRule, UpdateType.SafeRecipients))
                            {
                                flag = true;
                            }
                            if (this.CheckAndUpdateHashes(filteredJunkEmailRule, UpdateType.SafeSenders))
                            {
                                flag = true;
                            }
                            if (this.CheckAndUpdateHashes(filteredJunkEmailRule, UpdateType.BlockedSenders))
                            {
                                flag = true;
                            }
                            break;
                        }
                        if (flag)
                        {
                            base.InternalProcessRecord();
                            if ((this.Type == UpdateType.SafeSenders || this.Type == UpdateType.Both || this.Type == UpdateType.All) && (this.summary.SkippedContacts > 0 || this.summary.SkippedSafeSenderDomains > 0 || this.summary.SkippedSafeSenders > 0))
                            {
                                this.WriteWarning(Strings.SafeSendersNotUpdated(this.summary.SkippedContacts, this.summary.SkippedSafeSenders, this.summary.SkippedSafeSenderDomains, this.Identity.ToString()));
                            }
                            if ((this.Type == UpdateType.SafeRecipients || this.Type == UpdateType.Both || this.Type == UpdateType.All) && (this.summary.SkippedSafeRecipientDomains > 0 || this.summary.SkippedSafeRecipients > 0))
                            {
                                this.WriteWarning(Strings.SafeRecipientsNotUpdated(this.summary.SkippedSafeRecipients, this.summary.SkippedSafeRecipientDomains, this.Identity.ToString()));
                            }
                            if ((this.Type == UpdateType.BlockedSenders || this.Type == UpdateType.All) && (this.summary.SkippedBlockedSenderDomains > 0 || this.summary.SkippedBlockedSenders > 0))
                            {
                                this.WriteWarning(Strings.BlockedSendersNotUpdated(this.summary.SkippedBlockedSenders, this.summary.SkippedBlockedSenderDomains, this.Identity.ToString()));
                            }
                        }
                        if (flag || !filteredJunkEmailRule.AllRestrictionsLoaded)
                        {
                            filteredJunkEmailRule.Save();
                        }
                    }
                }
            }
            catch (JunkEmailValidationException ex)
            {
                TaskLogger.LogError(ex);
                base.WriteError(ex, ErrorCategory.InvalidData, this.DataObject);
            }
            catch (StorageTransientException ex2)
            {
                TaskLogger.LogError(ex2);
                base.WriteError(ex2, ErrorCategory.ReadError, this.DataObject);
            }
            catch (StoragePermanentException ex3)
            {
                TaskLogger.LogError(ex3);
                base.WriteError(ex3, ErrorCategory.InvalidOperation, this.DataObject);
            }
            finally
            {
                TaskLogger.LogExit();
            }
        }
Example #12
0
 public void LogError(Exception e)
 {
     TaskLogger.LogError(e);
 }
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            bool flag = this.principal.RecipientTypeDetails == RecipientTypeDetails.MonitoringMailbox;

            try
            {
                this.mailboxSession = MailboxSession.OpenAsAdmin(this.principal, CultureInfo.InvariantCulture, "Client=Management;Action=Get-MobileDeviceStatistics");
                List <DeviceInfo> list = new List <DeviceInfo>();
                if (base.Fields["ActiveSync"] == null && base.Fields["OWAforDevices"] == null)
                {
                    base.Fields["ActiveSync"]    = new SwitchParameter(true);
                    base.Fields["OWAforDevices"] = new SwitchParameter(true);
                }
                else if (base.Fields["ActiveSync"] == null)
                {
                    if (this.OWAforDevices == false)
                    {
                        base.Fields["ActiveSync"] = new SwitchParameter(true);
                    }
                }
                else if (base.Fields["OWAforDevices"] == null && this.ActiveSync == false)
                {
                    base.Fields["OWAforDevices"] = new SwitchParameter(true);
                }
                if (this.ActiveSync == true)
                {
                    DeviceInfo[] allDeviceInfo = DeviceInfo.GetAllDeviceInfo(this.mailboxSession, MobileClientType.EAS);
                    if (allDeviceInfo != null)
                    {
                        list.AddRange(allDeviceInfo);
                    }
                }
                if (this.OWAforDevices == true)
                {
                    DeviceInfo[] allDeviceInfo2 = DeviceInfo.GetAllDeviceInfo(this.mailboxSession, MobileClientType.MOWA);
                    if (allDeviceInfo2 != null)
                    {
                        list.AddRange(allDeviceInfo2);
                    }
                }
                if (list != null)
                {
                    List <MobileDevice> allMobileDevices = this.GetAllMobileDevices();
                    int num = 0;
                    using (List <DeviceInfo> .Enumerator enumerator = list.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            DeviceInfo deviceInfo = enumerator.Current;
                            if (deviceInfo.DeviceADObjectId != null && ADObjectId.Equals(deviceInfo.UserADObjectId, this.principal.ObjectId))
                            {
                                MobileDevice mobileDevice = allMobileDevices.Find((MobileDevice currentDevice) => currentDevice.DeviceId.Equals(deviceInfo.DeviceIdentity.DeviceId));
                                if (mobileDevice != null)
                                {
                                    num++;
                                    this.deviceConfiguration = this.CreateDeviceConfiguration(deviceInfo);
                                    if (this.Identity != null)
                                    {
                                        TIdentity identity = this.Identity;
                                        if (!identity.InternalADObjectId.Equals(this.deviceConfiguration.Identity))
                                        {
                                            continue;
                                        }
                                    }
                                    if (mobileDevice != null && this.deviceConfiguration.DeviceAccessStateReason < DeviceAccessStateReason.UserAgentsChanges && mobileDevice.ClientType == MobileClientType.EAS)
                                    {
                                        if (!flag)
                                        {
                                            DeviceAccessState       deviceAccessState       = DeviceAccessState.Unknown;
                                            DeviceAccessStateReason deviceAccessStateReason = DeviceAccessStateReason.Unknown;
                                            ADObjectId deviceAccessControlRule = null;
                                            bool       flag2 = false;
                                            if (mobileDevice.OrganizationId != OrganizationId.ForestWideOrgId && (mobileDevice.DeviceAccessStateReason != DeviceAccessStateReason.Individual || mobileDevice.DeviceAccessState != DeviceAccessState.Blocked) && mobileDevice.DeviceAccessStateReason != DeviceAccessStateReason.Policy)
                                            {
                                                Command.DetermineDeviceAccessState(this.LoadAbq(OrganizationId.ForestWideOrgId), mobileDevice.DeviceType, mobileDevice.DeviceModel, mobileDevice.DeviceUserAgent, mobileDevice.DeviceOS, out deviceAccessState, out deviceAccessStateReason, out deviceAccessControlRule);
                                                if (deviceAccessState == DeviceAccessState.Blocked)
                                                {
                                                    mobileDevice.DeviceAccessState       = deviceAccessState;
                                                    mobileDevice.DeviceAccessStateReason = deviceAccessStateReason;
                                                    mobileDevice.DeviceAccessControlRule = deviceAccessControlRule;
                                                    flag2 = true;
                                                }
                                            }
                                            if (!flag2 && mobileDevice.DeviceAccessState != DeviceAccessState.DeviceDiscovery && mobileDevice.DeviceAccessStateReason != DeviceAccessStateReason.Individual && mobileDevice.DeviceAccessStateReason != DeviceAccessStateReason.Upgrade && mobileDevice.DeviceAccessStateReason != DeviceAccessStateReason.Policy)
                                            {
                                                Command.DetermineDeviceAccessState(this.LoadAbq(mobileDevice.OrganizationId), mobileDevice.DeviceType, mobileDevice.DeviceModel, mobileDevice.DeviceUserAgent, mobileDevice.DeviceOS, out deviceAccessState, out deviceAccessStateReason, out deviceAccessControlRule);
                                                mobileDevice.DeviceAccessState       = deviceAccessState;
                                                mobileDevice.DeviceAccessStateReason = deviceAccessStateReason;
                                                mobileDevice.DeviceAccessControlRule = deviceAccessControlRule;
                                            }
                                        }
                                        this.deviceConfiguration.DeviceAccessState       = mobileDevice.DeviceAccessState;
                                        this.deviceConfiguration.DeviceAccessStateReason = mobileDevice.DeviceAccessStateReason;
                                        this.deviceConfiguration.DeviceAccessControlRule = mobileDevice.DeviceAccessControlRule;
                                    }
                                    if (this.ShowRecoveryPassword == false)
                                    {
                                        this.deviceConfiguration.RecoveryPassword = "******";
                                    }
                                    if (this.GetMailboxLog)
                                    {
                                        this.deviceConfiguration.MailboxLogReport = deviceInfo.GetOrCreateMailboxLogReport(this.mailboxSession);
                                    }
                                    base.WriteObject(this.deviceConfiguration);
                                    if (this.Identity != null)
                                    {
                                        this.ProcessMailboxLogger(new DeviceInfo[]
                                        {
                                            deviceInfo
                                        });
                                    }
                                }
                            }
                        }
                    }
                    if (this.Identity == null)
                    {
                        this.ProcessMailboxLogger(list.ToArray());
                    }
                    if (num > 0)
                    {
                        using (IBudget budget = StandardBudget.Acquire(this.mailboxSession.MailboxOwner.Sid, BudgetType.Eas, this.mailboxSession.GetADSessionSettings()))
                        {
                            if (budget != null)
                            {
                                IThrottlingPolicy throttlingPolicy = budget.ThrottlingPolicy;
                                if (throttlingPolicy != null && !throttlingPolicy.EasMaxDevices.IsUnlimited && (long)num >= (long)((ulong)throttlingPolicy.EasMaxDevices.Value))
                                {
                                    this.WriteWarning((num == 1) ? Strings.MaxDevicesReachedSingular(throttlingPolicy.EasMaxDevices.Value) : Strings.MaxDevicesReached(num, throttlingPolicy.EasMaxDevices.Value));
                                }
                            }
                        }
                    }
                }
            }
            catch (StorageTransientException ex)
            {
                TaskLogger.LogError(ex);
                base.WriteError(ex, ErrorCategory.ReadError, this.principal);
            }
            catch (StoragePermanentException ex2)
            {
                TaskLogger.LogError(ex2);
                base.WriteError(ex2, ErrorCategory.InvalidOperation, this.principal);
            }
            finally
            {
                if (this.mailboxSession != null)
                {
                    this.mailboxSession.Dispose();
                }
                TaskLogger.LogExit();
            }
        }
Example #14
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            IConfigurable configurable = base.PrepareDataObject();
            SmimeConfigurationContainer smimeConfigurationContainer = configurable as SmimeConfigurationContainer;

            if (base.Fields.Contains("SMIMECertificateIssuingCA"))
            {
                byte[] array = base.Fields["SMIMECertificateIssuingCA"] as byte[];
                if (array != null && array.Length != 0)
                {
                    if (array.Length > 70000)
                    {
                        base.WriteError(new InvalidOperationException(string.Format(Strings.SSTFileSizeExceedLimit, 70000.ToString())), ErrorCategory.LimitsExceeded, (configurable != null) ? configurable.Identity : null);
                        return(smimeConfigurationContainer);
                    }
                    smimeConfigurationContainer.SMIMECertificateIssuingCA = array;
                    X509Certificate2Collection x509Certificate2Collection = new X509Certificate2Collection();
                    try
                    {
                        x509Certificate2Collection.Import(array);
                    }
                    catch (Exception e)
                    {
                        base.WriteError(new FormatException("SMIMECertificateIssuingCA has wrong format"), ErrorCategory.InvalidData, null);
                        TaskLogger.LogError(e);
                    }
                    List <string> list     = new List <string>();
                    DateTime      dateTime = DateTime.MaxValue;
                    string        text     = string.Empty;
                    for (int i = 0; i < x509Certificate2Collection.Count; i++)
                    {
                        DateTime dateTime2;
                        if (DateTime.TryParse(x509Certificate2Collection[i].GetExpirationDateString(), out dateTime2))
                        {
                            if (dateTime2 < DateTime.UtcNow)
                            {
                                list.Add(x509Certificate2Collection[i].Thumbprint);
                            }
                            if (string.IsNullOrWhiteSpace(text) || dateTime2 < dateTime)
                            {
                                dateTime = dateTime2;
                                text     = x509Certificate2Collection[i].Thumbprint;
                            }
                        }
                        else
                        {
                            base.WriteError(new FormatException("Certificate Expiry date has wrong format"), ErrorCategory.InvalidData, null);
                        }
                    }
                    if (list.Count > 0)
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        foreach (string value in list)
                        {
                            if (stringBuilder.Length != 0)
                            {
                                stringBuilder.Append(" , ");
                            }
                            stringBuilder.Append(value);
                        }
                        base.WriteError(new InvalidOperationException(string.Format(Strings.ExpiryCertMessage, stringBuilder.ToString())), ErrorCategory.LimitsExceeded, null);
                        return(smimeConfigurationContainer);
                    }
                    if (dateTime != DateTime.MaxValue)
                    {
                        smimeConfigurationContainer.SMIMECertificatesExpiryDate       = new DateTime?(dateTime);
                        smimeConfigurationContainer.SMIMEExpiredCertificateThumbprint = text;
                    }
                }
                else
                {
                    smimeConfigurationContainer.SMIMECertificateIssuingCA         = null;
                    smimeConfigurationContainer.SMIMECertificatesExpiryDate       = null;
                    smimeConfigurationContainer.SMIMEExpiredCertificateThumbprint = string.Empty;
                }
            }
            this.ProcessSmimeRecord(smimeConfigurationContainer);
            TaskLogger.LogExit();
            return(smimeConfigurationContainer);
        }
Example #15
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     this.datetime = ((DateTime)ExDateTime.Now).ToString("yyyyMMdd-HHmmss");
     try
     {
         string value = "LOGVERBOSE=1 TARGETDIR=\"" + this.InstallPath + "\"";
         Dictionary <string, bool> dictionary  = new Dictionary <string, bool>();
         Dictionary <string, bool> dictionary2 = new Dictionary <string, bool>();
         int num = 0;
         for (int i = 0; i < this.LanguagePacksToInstall.Length; i++)
         {
             bool flag = Convert.ToBoolean(this.LPServerFlags[i]);
             dictionary.Add(this.LanguagePacksToInstall[i], flag);
             if (flag)
             {
                 num++;
             }
             flag = Convert.ToBoolean(this.LPClientFlags[i]);
             dictionary2.Add(this.LanguagePacksToInstall[i], flag);
             if (flag)
             {
                 num++;
             }
         }
         int num2 = num * 2;
         if (this.SourceIsBundle)
         {
             num2 += this.LanguagePacksToInstall.Length;
         }
         int num3 = 0;
         foreach (string text in this.LanguagePacksToInstall)
         {
             int    lcid  = CultureInfo.GetCultureInfo(text).LCID;
             string text2 = "";
             if (this.SourceIsBundle)
             {
                 TaskLogger.Log(Strings.ExtractingLang(text));
                 base.WriteProgress(this.Description, Strings.ExtractingLang(text), (int)((double)num3 * 100.0 / (double)num2 + 0.5));
                 DirectoryInfo directoryInfo = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(this.LangPackPath.PathName)));
                 string        text3         = text + "\\";
                 EmbeddedCabWrapper.ExtractFiles(this.LangPackPath.PathName, directoryInfo.FullName, text3);
                 text2 = directoryInfo.FullName + '\\' + text3;
                 num3++;
             }
             else
             {
                 text2 = Path.Combine(this.LangPackPath.PathName, text);
             }
             string text4 = Path.Combine(text2, "ClientLanguagePack.msi");
             if (dictionary2[text] && File.Exists(text4))
             {
                 TaskLogger.Log(Strings.UninstallOldMSIFor(text, "client"));
                 base.WriteProgress(this.Description, Strings.UninstallOldMSIFor(text, "client"), (int)((double)num3 * 100.0 / (double)num2 + 0.5));
                 using (MonadCommand monadCommand = new MonadCommand("Uninstall-MsiPackage", this.monadConnection))
                 {
                     string value2 = this.CreateMsilogPathname("Uninstall", "Client", text);
                     monadCommand.Parameters.AddWithValue("LogFile", value2);
                     Guid productCode = MsiUtility.GetProductCode(text4);
                     monadCommand.Parameters.AddWithValue("ProductCode", productCode);
                     monadCommand.Execute();
                 }
                 num3++;
                 TaskLogger.Log(Strings.InstallingMSIFor(text, "client"));
                 base.WriteProgress(this.Description, Strings.InstallingMSIFor(text, "client"), (int)((double)num3 * 100.0 / (double)num2 + 0.5));
                 using (MonadCommand monadCommand2 = new MonadCommand("Install-MsiPackage", this.monadConnection))
                 {
                     monadCommand2.Parameters.AddWithValue("PackagePath", text4);
                     string value3 = this.CreateMsilogPathname("Install", "Client", text);
                     monadCommand2.Parameters.AddWithValue("LogFile", value3);
                     monadCommand2.Parameters.AddWithValue("Features", new string[]
                     {
                         "AdminTools",
                         "Mailbox",
                         "ClientAccess",
                         "Gateway",
                         "Bridgehead",
                         "UnifiedMessaging",
                         "ClientLanguagePack"
                     });
                     monadCommand2.Parameters.AddWithValue("PropertyValues", value);
                     monadCommand2.Execute();
                 }
                 num3++;
             }
             text4 = Path.Combine(text2, "ServerLanguagePack.msi");
             if (dictionary[text] && File.Exists(text4))
             {
                 TaskLogger.Log(Strings.UninstallOldMSIFor(text, "server"));
                 base.WriteProgress(this.Description, Strings.UninstallOldMSIFor(text, "server"), (int)((double)num3 * 100.0 / (double)num2 + 0.5));
                 using (MonadCommand monadCommand3 = new MonadCommand("Uninstall-MsiPackage", this.monadConnection))
                 {
                     string value4 = this.CreateMsilogPathname("Uninstall", "Server", text);
                     monadCommand3.Parameters.AddWithValue("LogFile", value4);
                     Guid productCode2 = MsiUtility.GetProductCode(text4);
                     monadCommand3.Parameters.AddWithValue("ProductCode", productCode2);
                     monadCommand3.Execute();
                 }
                 num3++;
                 TaskLogger.Log(Strings.InstallingMSIFor(text, "server"));
                 base.WriteProgress(this.Description, Strings.InstallingMSIFor(text, "server"), (int)((double)num3 * 100.0 / (double)num2 + 0.5));
                 using (MonadCommand monadCommand4 = new MonadCommand("Install-MsiPackage", this.monadConnection))
                 {
                     monadCommand4.Parameters.AddWithValue("PackagePath", text4);
                     string value5 = this.CreateMsilogPathname("Install", "Server", text);
                     monadCommand4.Parameters.AddWithValue("LogFile", value5);
                     monadCommand4.Parameters.AddWithValue("Features", new string[]
                     {
                         "AdminTools",
                         "Mailbox",
                         "ClientAccess",
                         "Gateway",
                         "Bridgehead",
                         "UnifiedMessaging",
                         "ServerLanguagePack"
                     });
                     monadCommand4.Parameters.AddWithValue("PropertyValues", value);
                     monadCommand4.Execute();
                 }
                 num3++;
             }
             if (this.SourceIsBundle)
             {
                 try
                 {
                     Directory.Delete(text2, true);
                 }
                 catch (IOException e)
                 {
                     TaskLogger.LogError(e);
                 }
             }
         }
     }
     finally
     {
         base.WriteProgress(this.Description, Strings.ProgressStatusCompleted, 100);
         TaskLogger.LogExit();
     }
 }
Example #16
0
 private static void LogException(Exception ex)
 {
     TaskLogger.LogError(ex);
 }
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            MailboxSession mailboxSession = null;

            try
            {
                mailboxSession = MailboxSession.OpenAsAdmin(this.principal, CultureInfo.InvariantCulture, "Client=Management;Action=Get-ActiveSyncDeviceStatistics");
                DeviceInfo deviceInfo = MobileDeviceTaskHelper.GetDeviceInfo(mailboxSession, this.Identity);
                if (deviceInfo == null)
                {
                    base.WriteError(new MobileDeviceNotExistException(this.Identity.ToString()), ErrorCategory.InvalidOperation, this.Identity);
                }
                using (SyncStateStorage syncStateStorage = SyncStateStorage.Bind(mailboxSession, deviceInfo.DeviceIdentity, null))
                {
                    if (syncStateStorage == null)
                    {
                        base.WriteError(new MobileDeviceNotExistException(this.Identity.ToString()), ErrorCategory.InvalidOperation, this.Identity);
                    }
                    using (CustomSyncState orCreateGlobalSyncState = AirSyncUtility.GetOrCreateGlobalSyncState(syncStateStorage))
                    {
                        if (this.Cancel)
                        {
                            if (!DeviceInfo.CancelRemoteWipeFromMailbox(orCreateGlobalSyncState))
                            {
                                this.WriteWarning(Strings.CannotCancelWipe(this.Identity.ToString()));
                            }
                        }
                        else
                        {
                            DeviceInfo.StartRemoteWipeFromMailbox(syncStateStorage, orCreateGlobalSyncState, ExDateTime.UtcNow, this.validatedAddresses, this.wipeRequestorSMTP);
                        }
                        orCreateGlobalSyncState.Commit();
                    }
                }
                base.InternalProcessRecord();
            }
            catch (FolderSaveException exception)
            {
                base.WriteError(exception, ErrorCategory.WriteError, this.Identity);
            }
            catch (CorruptSyncStateException ex)
            {
                TaskLogger.LogError(ex);
                base.WriteError(ex, ErrorCategory.ReadError, this.principal);
            }
            catch (InvalidSyncStateVersionException ex2)
            {
                TaskLogger.LogError(ex2);
                base.WriteError(ex2, ErrorCategory.ReadError, this.principal);
            }
            catch (StorageTransientException ex3)
            {
                TaskLogger.LogError(ex3);
                base.WriteError(ex3, ErrorCategory.ReadError, this.principal);
            }
            catch (StoragePermanentException ex4)
            {
                TaskLogger.LogError(ex4);
                base.WriteError(ex4, ErrorCategory.InvalidOperation, this.principal);
            }
            catch (InvalidOperationException ex5)
            {
                TaskLogger.LogError(ex5);
                base.WriteError(ex5, ErrorCategory.InvalidOperation, this.principal);
            }
            finally
            {
                if (mailboxSession != null)
                {
                    mailboxSession.Dispose();
                }
                TaskLogger.LogExit();
            }
        }