public static void Convert(DataRow dataRow) { foreach (object obj in dataRow.Table.Columns) { DataColumn dataColumn = (DataColumn)obj; Type type = dataColumn.ExtendedProperties["ExpectedType"] as Type; string text = dataRow[dataColumn] as string; if (type != null && dataRow[dataColumn].GetType() != type && text != null) { if (type == typeof(Unlimited <int>)) { dataRow[dataColumn] = Unlimited <int> .Parse(text); } else if (type == typeof(Unlimited <EnhancedTimeSpan>)) { dataRow[dataColumn] = Unlimited <EnhancedTimeSpan> .Parse(text); } else if (type == typeof(EmailAddressPolicyPriority)) { dataRow[dataColumn] = EmailAddressPolicyPriority.Parse(text); } else if (type == typeof(SmtpDomainWithSubdomains)) { dataRow[dataColumn] = SmtpDomainWithSubdomains.Parse(text); } else if (type == typeof(SmtpAddress)) { dataRow[dataColumn] = SmtpAddress.Parse(text); } else if (type == typeof(ProxyAddress)) { dataRow[dataColumn] = ProxyAddress.Parse(text); } else if (type == typeof(MailboxId)) { dataRow[dataColumn] = MailboxId.Parse(text); } else if (type == typeof(UMLanguage)) { dataRow[dataColumn] = UMLanguage.Parse(text); } else { if (!(type == typeof(ExchangeObjectVersion))) { throw new ArgumentException(string.Format("Type {0} is not supported convert from string yet", type)); } Regex regex = new Regex("^(?<Major>\\d+)\\.(?<Minor>\\d+) \\((?<buildMajor>\\d+)\\.(?<buildMinor>\\d+)\\.(?<buildVersion>\\d+)\\.(?<buildRevison>\\d+)\\)$"); Match match = regex.Match(text); if (!match.Success) { throw new ArgumentException(string.Format("{0} is not a valid ExchangeObjectVersion", text)); } dataRow[dataColumn] = new ExchangeObjectVersion(byte.Parse(match.Result("${Major}")), byte.Parse(match.Result("${Minor}")), byte.Parse(match.Result("${buildMajor}")), byte.Parse(match.Result("${buildMinor}")), ushort.Parse(match.Result("${buildVersion}")), ushort.Parse(match.Result("${buildRevison}"))); } } } }
protected override string GetValueText(object objectValue) { string result = string.Empty; UMLanguage umlanguage = objectValue as UMLanguage; if (umlanguage != null) { result = umlanguage.DisplayName; } return(result); }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (!base.HasErrors) { UMDialPlan dialPlan = this.DataObject.GetDialPlan(); if (dialPlan == null) { base.WriteError(new DialPlanNotFoundException(this.DataObject.UMDialPlan.Name), ErrorCategory.NotSpecified, null); } int numberOfDigitsInExtension = dialPlan.NumberOfDigitsInExtension; MultiValuedProperty <string> multiValuedProperty = null; multiValuedProperty = this.DataObject.PilotIdentifierList; if (this.DataObject.IsChanged(UMAutoAttendantSchema.PilotIdentifierList) && multiValuedProperty != null) { LocalizedException ex = ValidationHelper.ValidateDialedNumbers(this.DataObject.PilotIdentifierList, dialPlan); if (ex != null) { base.WriteError(ex, ErrorCategory.NotSpecified, this.DataObject); } foreach (string text in this.DataObject.PilotIdentifierList) { UMAutoAttendant umautoAttendant = UMAutoAttendant.FindAutoAttendantByPilotIdentifierAndDialPlan(text, this.DataObject.UMDialPlan); if (umautoAttendant != null && !umautoAttendant.Guid.Equals(this.DataObject.Guid)) { base.WriteError(new AutoAttendantExistsException(text, this.DataObject.UMDialPlan.Name), ErrorCategory.NotSpecified, null); } } if (dialPlan.URIType == UMUriType.SipName) { Utility.CheckForPilotIdentifierDuplicates(this.DataObject, this.ConfigurationSession, multiValuedProperty, new Task.TaskErrorLoggingDelegate(base.WriteError)); } } string timeZone = this.DataObject.TimeZone; if (this.DataObject.IsChanged(UMAutoAttendantSchema.BusinessHourFeatures)) { ValidationHelper.ValidateTimeZone(timeZone); } string property; try { property = UMAutoAttendantSchema.BusinessHoursKeyMapping.ToString(); MultiValuedProperty <CustomMenuKeyMapping> multiValuedProperty2 = this.DataObject.BusinessHoursKeyMapping; if (multiValuedProperty2 != null && multiValuedProperty2.Count > 0) { bool flag; ValidationHelper.ValidateCustomMenu(Strings.BusinessHoursSettings, this.ConfigurationSession, property, multiValuedProperty2, numberOfDigitsInExtension, this.DataObject, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ADRecipient>), out flag); if (flag) { this.DataObject.BusinessHoursKeyMapping = multiValuedProperty2; } } property = UMAutoAttendantSchema.AfterHoursKeyMapping.ToString(); multiValuedProperty2 = this.DataObject.AfterHoursKeyMapping; if (multiValuedProperty2 != null && multiValuedProperty2.Count > 0) { bool flag2; ValidationHelper.ValidateCustomMenu(Strings.AfterHoursSettings, this.ConfigurationSession, property, multiValuedProperty2, numberOfDigitsInExtension, this.DataObject, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ADRecipient>), out flag2); if (flag2) { this.DataObject.AfterHoursKeyMapping = multiValuedProperty2; } } } catch (LocalizedException exception) { base.WriteError(exception, ErrorCategory.NotSpecified, null); } bool speechEnabled = this.DataObject.SpeechEnabled; StatusEnum status = this.DataObject.Status; property = UMAutoAttendantSchema.DTMFFallbackAutoAttendant.ToString(); if (this.fallbackAA != null) { ValidationHelper.ValidateDtmfFallbackAA(this.DataObject, dialPlan, this.fallbackAA); } ADObjectId adobjectId = null; property = UMAutoAttendantSchema.AutomaticSpeechRecognitionEnabled.ToString(); if (this.DataObject.IsChanged(UMAutoAttendantSchema.AutomaticSpeechRecognitionEnabled) && speechEnabled && ValidationHelper.IsFallbackAAInDialPlan(this.ConfigurationSession, this.DataObject, out adobjectId)) { base.WriteError(new InvalidDtmfFallbackAutoAttendantException(Strings.InvalidSpeechEnabledAutoAttendant(adobjectId.ToString())), ErrorCategory.NotSpecified, null); } property = UMAutoAttendantSchema.Language.ToString(); if (this.DataObject.IsChanged(UMAutoAttendantSchema.Language)) { UMLanguage language = this.DataObject.Language; if (!Utility.IsUMLanguageAvailable(language)) { base.WriteError(new InvalidLanguageIdException(language.ToString()), ErrorCategory.NotSpecified, null); } } bool flag3 = this.IsBusinessHours(); if (!this.DataObject.NameLookupEnabled && !this.DataObject.CallSomeoneEnabled && ((flag3 && !this.DataObject.BusinessHoursTransferToOperatorEnabled && !this.DataObject.BusinessHoursKeyMappingEnabled) || (!flag3 && !this.DataObject.AfterHoursTransferToOperatorEnabled && !this.DataObject.AfterHoursKeyMappingEnabled))) { base.WriteError(new InvalidAutoAttendantException(Strings.InvalidMethodToDisableAA), ErrorCategory.NotSpecified, null); } LocalizedString empty = LocalizedString.Empty; if (!DialGroupEntry.ValidateGroup(dialPlan.ConfiguredInCountryOrRegionGroups, this.DataObject.AllowedInCountryOrRegionGroups, true, out empty)) { base.WriteError(new Exception(empty), ErrorCategory.WriteError, this.DataObject); } if (!DialGroupEntry.ValidateGroup(dialPlan.ConfiguredInternationalGroups, this.DataObject.AllowedInternationalGroups, false, out empty)) { base.WriteError(new Exception(empty), ErrorCategory.WriteError, this.DataObject); } if (this.DataObject.ForwardCallsToDefaultMailbox && string.IsNullOrEmpty(this.DataObject.DefaultMailboxLegacyDN)) { base.WriteError(new InvalidParameterException(Strings.DefaultMailboxRequiredWhenForwardTrue), ErrorCategory.NotSpecified, null); } if (this.DataObject.IsModified(UMAutoAttendantSchema.ContactScope) && this.DataObject.ContactScope == DialScopeEnum.DialPlan && dialPlan.SubscriberType == UMSubscriberType.Consumer) { base.WriteError(new InvalidParameterException(Strings.InvalidAutoAttendantScopeSetting), (ErrorCategory)1000, null); } } TaskLogger.LogExit(); }
protected static object GetSingleProperty(object prop, Type type) { if (prop == null) { return(null); } object obj = null; if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>)) { obj = MockObjectCreator.GetSingleProperty(prop, type.GetGenericArguments()[0]); } else if (type == typeof(ADObjectId) && prop is PSObject) { obj = new ADObjectId(((PSObject)prop).Members["DistinguishedName"].Value.ToString(), new Guid(((PSObject)prop).Members["ObjectGuid"].Value.ToString())); } else if (type == typeof(EnhancedTimeSpan)) { obj = EnhancedTimeSpan.Parse(prop.ToString()); } else if (type == typeof(Unlimited <EnhancedTimeSpan>)) { obj = Unlimited <EnhancedTimeSpan> .Parse(prop.ToString()); } else if (type == typeof(ByteQuantifiedSize)) { obj = ByteQuantifiedSize.Parse(prop.ToString()); } else if (type == typeof(Unlimited <ByteQuantifiedSize>)) { obj = Unlimited <ByteQuantifiedSize> .Parse(prop.ToString()); } else if (type == typeof(Unlimited <int>)) { obj = Unlimited <int> .Parse(prop.ToString()); } else if (type == typeof(ProxyAddress)) { obj = ProxyAddress.Parse(prop.ToString()); } else if (type == typeof(SmtpAddress)) { obj = new SmtpAddress(prop.ToString()); } else if (type == typeof(SmtpDomain)) { obj = SmtpDomain.Parse(prop.ToString()); } else if (type == typeof(CountryInfo)) { obj = CountryInfo.Parse(prop.ToString()); } else if (type == typeof(SharingPolicyDomain)) { obj = SharingPolicyDomain.Parse(prop.ToString()); } else if (type == typeof(ApprovedApplication)) { obj = ApprovedApplication.Parse(prop.ToString()); } else if (type == typeof(SmtpDomainWithSubdomains)) { obj = SmtpDomainWithSubdomains.Parse(prop.ToString()); } else if (type == typeof(UMLanguage)) { obj = UMLanguage.Parse(prop.ToString()); } else if (type == typeof(UMSmartHost)) { obj = UMSmartHost.Parse(prop.ToString()); } else if (type == typeof(ScheduleInterval)) { obj = ScheduleInterval.Parse(prop.ToString()); } else if (type == typeof(NumberFormat)) { obj = NumberFormat.Parse(prop.ToString()); } else if (type == typeof(DialGroupEntry)) { obj = DialGroupEntry.Parse(prop.ToString()); } else if (type == typeof(CustomMenuKeyMapping)) { obj = CustomMenuKeyMapping.Parse(prop.ToString()); } else if (type == typeof(HolidaySchedule)) { obj = HolidaySchedule.Parse(prop.ToString()); } else if (type == typeof(UMTimeZone)) { obj = UMTimeZone.Parse(prop.ToString()); } else if (type == typeof(ServerVersion)) { obj = ServerVersion.ParseFromSerialNumber(prop.ToString()); } else if (type == typeof(X509Certificate2)) { obj = new X509Certificate2(((PSObject)prop).Members["RawData"].Value as byte[]); } else if (type == typeof(LocalizedString)) { obj = new LocalizedString(prop.ToString()); } else if (type == typeof(ExchangeObjectVersion)) { obj = ExchangeObjectVersion.Parse(prop.ToString()); } else if (type == typeof(bool)) { obj = bool.Parse(prop.ToString()); } else if (type == typeof(SecurityPrincipalIdParameter)) { obj = new SecurityPrincipalIdParameter(prop.ToString()); } else if (type == typeof(ActiveDirectoryAccessRule)) { obj = (prop as ActiveDirectoryAccessRule); } else if (type == typeof(ObjectId)) { string text = prop.ToString(); if (!ADObjectId.IsValidDistinguishedName(text) && text.Contains("/")) { text = MockObjectCreator.ConvertDNFromTreeStructure(text); } obj = new ADObjectId(text); } else if (type.IsEnum) { try { obj = Enum.Parse(type, prop.ToString()); } catch (ArgumentException) { obj = Enum.GetValues(type).GetValue(0); } } return(obj ?? prop); }
public static bool IsUMLanguageAvailable(UMLanguage language) { MultiValuedProperty <UMLanguage> multiValuedProperty = Utils.ComputeUnionOfUmServerLanguages(); return(multiValuedProperty != null && multiValuedProperty.Contains(language)); }