public static ExchangeService GetExchangeService(string emailAddress, string username, string password, ExchangeVersion exchangeVersion, Uri serviceUri) { var service = new ExchangeService(exchangeVersion); service.Credentials = new WebCredentials(username, password); service.EnableScpLookup = false; if (serviceUri == null) { service.AutodiscoverUrl(emailAddress, (url) => { bool result = false; var redirectionUri = new Uri(url); if (redirectionUri.Scheme == "https") { result = true; } return result; }); } else { service.Url = serviceUri; } return service; }
public EwsMailTip(EwsMailTipType mailTipType, string sender, string recipient, ExchangeVersion requestedServerVersion) { this.MailTipType = mailTipType; this.Sender = sender; this.Recipient = recipient; this.RequestedServerVersion = requestedServerVersion; }
private ExchangeCalendarFactory(string exchangeServerUrl, ExchangeVersion exchangeVersion) { _exchangeServerUrl = exchangeServerUrl; _exchangeVersion = exchangeVersion; _useDomainCredentials = true; InitializeExchangeService(); }
public static List <KeyValuePair <string, string> > ToList(ExchangeVersion exchangeVersion) { if (!typeof(T).IsClass) { throw new ArgumentException("T must be a class type"); } List <KeyValuePair <string, string> > list = new List <KeyValuePair <string, string> >(); var members = typeof(T).GetMembers(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.FlattenHierarchy); foreach (var member in members) { // Exclude fields that cause errors with value retrieval via reflection of the PropertyDefinitionBase if (member.Name != "EntityExtractionResult" && member.Name != "Equals" && member.Name != "ExtendedProperties" && member.Name != "IconIndex" && member.Name != "InternetMessageHeaders" && member.Name != "IsReminderSet" && member.Name != "ReferenceEquals" && member.Name != "ReminderDueBy" && member.Name != "ReminderMinutesBeforeStart") { if (exchangeVersion >= ExchangeVersion.Exchange2013) { list.Add(new KeyValuePair <string, string>(member.Name, member.Name)); } else { if (member.Name != "ArchiveTag" && member.Name != "Flag" && member.Name != "IconIndex" && member.Name != "InstanceKey" && member.Name != "NormalizedBody" && member.Name != "PolicyTag" && member.Name != "Preview" && member.Name != "RetentionDate" && member.Name != "TextBody") { list.Add(new KeyValuePair <string, string>(member.Name, member.Name)); } } } } return(list); }
internal static void LogExceptionsOnly(IMailboxContext userContext, string eventId, Action action) { ExchangeVersion value = ExchangeVersion.Current; try { ExchangeVersion.Current = ExchangeVersion.Latest; OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate() { action(); }); } catch (GrayException ex) { string primarySmtpAddress = SimulatedWebRequestContext.GetPrimarySmtpAddress(userContext); bool flag = false; RequestDetailsLogger requestDetailsLogger = SimulatedWebRequestContext.GetRequestDetailsLogger(eventId, userContext, primarySmtpAddress ?? "[user logged out]", out flag); SimulatedWebRequestContext.ProcessException(requestDetailsLogger, eventId, ex.InnerException); if (flag) { requestDetailsLogger.Commit(); } } finally { ExchangeVersion.Current = value; } }
/// <summary> /// Initializes a new instance of the <see cref="DateTimePropertyDefinition"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="uri">The URI.</param> /// <param name="version">The version.</param> internal DateTimePropertyDefinition( string xmlElementName, string uri, ExchangeVersion version) : base(xmlElementName, uri, version) { }
/// <summary> /// GetExchangeExchangeVersion /// </summary> /// <param name="serverInfo"></param> /// <returns></returns> private ExchangeVersion GetExchangeExchangeVersion(ExchangeServerInfo serverInfo) { ExchangeVersion version = ExchangeVersion.Exchange2013_SP1; if (serverInfo != null) { switch (serverInfo.MajorVersion) { case 15: version = ExchangeVersion.Exchange2013_SP1; break; case 14: version = ExchangeVersion.Exchange2010_SP2; break; case 8: version = ExchangeVersion.Exchange2007_SP1; break; default: break; } } return(version); }
public void SetProperty(String key, String value) { if (key == "ExchangeVersion") { switch (value) { case "Exchange2007_SP1": _version = ExchangeVersion.Exchange2007_SP1; break; case "Exchange2010": _version = ExchangeVersion.Exchange2010; break; case "Exchange2010_SP1": _version = ExchangeVersion.Exchange2010_SP1; break; case "Exchange2010_SP2": _version = ExchangeVersion.Exchange2010_SP2; break; case "Exchange2013": _version = ExchangeVersion.Exchange2013; break; case "Exchange2013_SP1": _version = ExchangeVersion.Exchange2013_SP1; break; default: break; } } }
private bool ParseParameters() { try { errorRecipients = new List <string>(); exchangeVersion = (ExchangeVersion)Enum.Parse(typeof(ExchangeVersion), Properties.Settings.Default.EXCHANGE_VERSION); password = Properties.Settings.Default.PASSWORD; useAutodiscover = Properties.Settings.Default.USE_AUTODISCOVER; useDefaultCredentials = Properties.Settings.Default.USE_DEFAULT_CREDENTIALS; useImpersonation = Properties.Settings.Default.USE_IMPERSONATION; username = Properties.Settings.Default.USERNAME; if (Properties.Settings.Default.SERVICE_URI != string.Empty) { EwsUri = new Uri(Properties.Settings.Default.SERVICE_URI); } if (textBoxFrom.Text != string.Empty && textBoxFrom.Text.Contains('@') && textBoxFrom.Text.Contains('.')) { emailAddress = textBoxFrom.Text; } else { return(false); } unresolvedToRecipients = textBoxTo.Text.Split(';'); unresolvedCCRecipients = textBoxCC.Text.Split(';'); messageSubject = textBoxSubject.Text; messageBody = textBoxBody.Text; return(true); } catch { return(false); } }
private ExchangeVersion GetExchangeVersion(string sExchangeVersion) { // Set Version ExchangeVersion oVersion = new ExchangeVersion(); oVersion = ExchangeVersion.Exchange2010_SP1; switch (sExchangeVersion) { case "Exchange2007_SP1": oVersion = ExchangeVersion.Exchange2007_SP1; break; case "Exchange2010": oVersion = ExchangeVersion.Exchange2010; break; case "Exchange2010_SP1": oVersion = ExchangeVersion.Exchange2010_SP1; break; case "Exchange2010_SP2": oVersion = ExchangeVersion.Exchange2010_SP2; break; case "Exchange2013": oVersion = ExchangeVersion.Exchange2013; break; } //_Version = oVersion; return(oVersion); }
internal static ExchangeVersion GetExchangeVersion(string ver) { ExchangeVersion outy = ExchangeVersion.Exchange2007_SP1; switch (ver.Trim().ToLower()) { case "Exchange2007_SP1": outy = ExchangeVersion.Exchange2007_SP1; break; case "Exchange2010": outy = ExchangeVersion.Exchange2010; break; case "Exchange2010_SP1": outy = ExchangeVersion.Exchange2010_SP1; break; case "Exchange2010_SP2": outy = ExchangeVersion.Exchange2010_SP2; break; case "Exchange2013": outy = ExchangeVersion.Exchange2013; break; } return(outy); }
public ExchangeConnection(ExchangeVersion version = ExchangeVersion.Exchange2013_SP1, bool useDefaultCreds = false) { ExchangeService = new ExchangeService((Microsoft.Exchange.WebServices.Data.ExchangeVersion)version) { UseDefaultCredentials = useDefaultCreds }; }
/// <summary> /// Validates list of folderIds against a specified request version. /// </summary> /// <param name="version">The version.</param> internal void Validate(ExchangeVersion version) { foreach (AbstractFolderIdWrapper folderIdWrapper in this.ids) { folderIdWrapper.Validate(version); } }
/// <summary> /// Manages Streaming Notifications for Exchange Users. Automatically assigns subscriptions to adequate CAS connections. /// </summary> /// <param name="credentials">Credentials with permission to impersonate the user mailboxes for all the subscriptions this instance will manage.</param> /// <param name="exchangeVersion">The version of the target Exchange server. Must be 2010 SP1 or higher</param> /// <param name="onNotificationEvent">The Action to invoke when Notifications arrive</param> public StreamingListener(ExchangeCredentials credentials, ExchangeVersion exchangeVersion, Action<SubscriptionNotificationEventCollection> onNotificationEvent) { _onNotificationEvent = onNotificationEvent; if ((int)exchangeVersion < 2) throw new ArgumentException("ExchangeVersion must be 2010 SP1 or higher"); _exchangeVersion = exchangeVersion; this._credentials = credentials; }
/// <summary> /// Initializes a new instance of the <see cref="PropertyDefinition"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="uri">The URI.</param> /// <param name="flags">The flags.</param> /// <param name="version">The version.</param> internal PropertyDefinition( string xmlElementName, string uri, PropertyDefinitionFlags flags, ExchangeVersion version) : this(xmlElementName, uri, version) { this.flags = flags; }
/// <summary> /// Initialize a new EwsClient using the specified username and password to connect to the specified version of EWS. An attempt is made to autodiscovered the EWS endpoint. /// </summary> /// <param name="username">A user with login rights on the specified <paramref name="domain"/>.</param> /// <param name="password">The password for the specified <paramref name="username"/>.</param> /// <param name="domain">The Exchange domain.</param> /// <param name="exchangeVersion">The version of Exchange.</param> /// <remarks> /// In order for autodiscovery of an EWS endpoint to work, there may be additional Exchange configuration required. /// See http://msdn.microsoft.com/en-us/library/office/jj900169(v=exchg.150).aspx. /// </remarks> public EwsClient(string username, string password, string domain, ExchangeVersion exchangeVersion) { exchangeService = new ExchangeService(exchangeVersion) { Credentials = new WebCredentials(username, password, domain), }; exchangeService.AutodiscoverUrl(String.Format("{0}@{1}", username, domain)); }
public static UserInfo CreateUserData(string email, string password, ExchangeVersion version) { UserInfo user = new UserInfo(); user.EmailAddress = email; user.Password = password; user.Version = version; return(user); }
/// <summary> /// Validates FolderId against a specified request version. /// </summary> /// <param name="version">The version.</param> internal void Validate(ExchangeVersion version) { // The FolderName property is a WellKnownFolderName, an enumeration type. If the property // is set, make sure that the value is valid for the request version. if (this.FolderName.HasValue) { EwsUtilities.ValidateEnumVersionValue(this.FolderName.Value, version); } }
private ExchangeCalendarFactory(string username, string password, string exchangeServerUrl, ExchangeVersion exchangeVersion) { _username = username; _password = password; _exchangeServerUrl = exchangeServerUrl; _exchangeVersion = exchangeVersion; _useDomainCredentials = false; InitializeExchangeService(); }
/// <summary> /// Initializes a new instance of the <see cref="PropertyDefinition"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="flags">The flags.</param> /// <param name="version">The version.</param> internal PropertyDefinition( string xmlElementName, PropertyDefinitionFlags flags, ExchangeVersion version) : base() { this.xmlElementName = xmlElementName; this.flags = flags; this.version = version; }
/// <summary> /// Initializes a new instance of the <see cref="PropertyDefinition"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="uri">The URI.</param> /// <param name="version">The version.</param> internal PropertyDefinition( string xmlElementName, string uri, ExchangeVersion version) : base(uri) { this.xmlElementName = xmlElementName; this.flags = PropertyDefinitionFlags.None; this.version = version; }
/// <summary> /// Initializes a new instance of the <see cref="ResponseObjectsPropertyDefinition"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="uri">The URI.</param> /// <param name="version">The version.</param> internal ResponseObjectsPropertyDefinition( string xmlElementName, string uri, ExchangeVersion version) : base( xmlElementName, uri, version) { }
/// <summary> /// Initializes a new instance of the <see cref="ComplexPropertyDefinitionBase"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="uri">The URI.</param> /// <param name="version">The version.</param> internal ComplexPropertyDefinitionBase( string xmlElementName, string uri, ExchangeVersion version) : base( xmlElementName, uri, version) { }
/// <summary> /// Initializes a new instance of the <see cref="ComplexPropertyDefinitionBase"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="flags">The flags.</param> /// <param name="version">The version.</param> internal ComplexPropertyDefinitionBase( string xmlElementName, PropertyDefinitionFlags flags, ExchangeVersion version) : base( xmlElementName, flags, version) { }
/// <summary> /// Manages Streaming Notifications for Exchange Users. Automatically assigns subscriptions to adequate CAS connections. /// </summary> /// <param name="credentials">Credentials with permission to impersonate the user mailboxes for all the subscriptions this instance will manage.</param> /// <param name="exchangeVersion">The version of the target Exchange server. Must be 2010 SP1 or higher</param> /// <param name="onNotificationEvent">The Action to invoke when Notifications arrive</param> public StreamingListener(ExchangeCredentials credentials, ExchangeVersion exchangeVersion, Action <SubscriptionNotificationEventCollection> onNotificationEvent) { _onNotificationEvent = onNotificationEvent; if ((int)exchangeVersion < 2) { throw new ArgumentException("ExchangeVersion must be 2010 SP1 or higher"); } _exchangeVersion = exchangeVersion; this._credentials = credentials; }
public ExchangeMailService(ExchangeVersion version, IExchangeFactoryItem factory, IIdentityService auth, IMailConfiguration config) { Config = config ?? ServiceFactory.Get <IConfigurationService>().Mail; Factory = factory ?? ServiceFactory.Ensure <IExchangeFactoryItem, ExchangeFactoryItem>(); Auth = auth ?? ServiceFactory.Get <IIdentityService>(); Version = version; }
public ConnectionParams( ExchangeVersion version, string autodiscoverUri, IUserData data, bool traceToFile) { this.Version = version; this.AutodiscoverUrl = autodiscoverUri; this.Data = data; this.TraceToFile = traceToFile; }
/// <summary> /// Gets the time zone property to which to scope times. /// </summary> /// <param name="version">The EWS version for which the property is to be retrieved.</param> /// <returns>The PropertyDefinition of the scoping time zone property.</returns> private PropertyDefinition GetTimeZoneProperty(ExchangeVersion version) { PropertyDefinition timeZoneProperty = this.getPropertyDefinitionCallback(version); EwsUtilities.Assert( timeZoneProperty != null, "ScopedDateTimePropertyDefinition.GetTimeZoneProperty", "timeZoneProperty is null."); return(timeZoneProperty); }
private ExchangeService getService(NetworkCredential credentials) { ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack; ExchangeVersion version = (ExchangeVersion)Enum.Parse(typeof(ExchangeVersion), Settings.ExchangeServiceVersion); ExchangeService service = new ExchangeService(version); service.Credentials = credentials; service.AutodiscoverUrl(Settings.AutodiscoverUrl, RedirectionUrlValidationCallback); return(service); }
/// <summary> /// Initializes a new instance of the <see cref="TypedPropertyDefinition"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="uri">The URI.</param> /// <param name="version">The version.</param> internal TypedPropertyDefinition( string xmlElementName, string uri, ExchangeVersion version) : base( xmlElementName, uri, version) { this.isNullable = false; }
/// <summary> /// Initializes a new instance of the <see cref="ContainedPropertyDefinition<TComplexProperty>"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="uri">The URI.</param> /// <param name="containedXmlElementName">Name of the contained XML element.</param> /// <param name="flags">The flags.</param> /// <param name="version">The version.</param> /// <param name="propertyCreationDelegate">Delegate used to create instances of ComplexProperty.</param> internal ContainedPropertyDefinition( string xmlElementName, string uri, string containedXmlElementName, PropertyDefinitionFlags flags, ExchangeVersion version, CreateComplexPropertyDelegate <TComplexProperty> propertyCreationDelegate) : base(xmlElementName, uri, flags, version, propertyCreationDelegate) { this.containedXmlElementName = containedXmlElementName; }
private UserInfo BuildUserInfo(string email, string password) { ExchangeVersion version = ExchangeVersion.Exchange2013; if (!string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password)) { return(UserInfo.CreateUserData(email, password, version)); } return(null); }
/// <summary> /// Gets the time zone property to which to scope times. /// </summary> /// <param name="version">The EWS version for which the property is to be retrieved.</param> /// <returns>The PropertyDefinition of the scoping time zone property.</returns> private PropertyDefinition GetTimeZoneProperty(ExchangeVersion version) { PropertyDefinition timeZoneProperty = this.getPropertyDefinitionCallback(version); EwsUtilities.Assert( timeZoneProperty != null, "ScopedDateTimePropertyDefinition.GetTimeZoneProperty", "timeZoneProperty is null."); return timeZoneProperty; }
/// <summary> /// Initializes a new instance of the <see cref="MeetingTimeZonePropertyDefinition"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="uri">The URI.</param> /// <param name="flags">The flags.</param> /// <param name="version">The version.</param> internal MeetingTimeZonePropertyDefinition( string xmlElementName, string uri, PropertyDefinitionFlags flags, ExchangeVersion version) : base( xmlElementName, uri, flags, version) { }
/// <summary> /// Initializes a new instance of the <see cref="ComplexPropertyDefinition<TComplexProperty>"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="uri">The URI.</param> /// <param name="version">The version.</param> /// <param name="propertyCreationDelegate">Delegate used to create instances of ComplexProperty.</param> internal ComplexPropertyDefinition( string xmlElementName, string uri, ExchangeVersion version, CreateComplexPropertyDelegate <TComplexProperty> propertyCreationDelegate) : base( xmlElementName, uri, version) { this.propertyCreationDelegate = propertyCreationDelegate; }
/// <summary> /// Initializes a new instance of the <see cref="TimeZonePropertyDefinition"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="uri">The URI.</param> /// <param name="flags">The flags.</param> /// <param name="version">The version.</param> internal TimeZonePropertyDefinition( string xmlElementName, string uri, PropertyDefinitionFlags flags, ExchangeVersion version) : base( xmlElementName, uri, flags, version) { }
/// <summary> /// Initializes a new instance of the <see cref="EffectiveRightsPropertyDefinition"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="uri">The URI.</param> /// <param name="flags">The flags.</param> /// <param name="version">The version.</param> internal EffectiveRightsPropertyDefinition( string xmlElementName, string uri, PropertyDefinitionFlags flags, ExchangeVersion version) : base( xmlElementName, uri, flags, version) { }
public ExchangeCalendarConfiguration(string userName, string password, bool useDomainCredentials, string endpoint, ExchangeVersion exchangeVersion) { UserName = userName; Password = password; UseDomainCredentials = useDomainCredentials; Endpoint = endpoint; ExchangeVersion = exchangeVersion; }
/// <summary> /// Initializes a new instance of the <see cref="RecurrencePropertyDefinition"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="uri">The URI.</param> /// <param name="flags">The flags.</param> /// <param name="version">The version.</param> internal RecurrencePropertyDefinition( string xmlElementName, string uri, PropertyDefinitionFlags flags, ExchangeVersion version) : base( xmlElementName, uri, flags, version) { }
public ExchangeClient(string userName, string password, string domain, ExchangeVersion version) { _exchange = new ExchangeService(version); _exchange.Credentials = new WebCredentials(userName, password); _exchange.AutodiscoverUrl(userName + "@" + domain); _connection = new StreamingSubscriptionConnection(_exchange, 30); CreateSubscription(); _connection.OnNotificationEvent += OnNotificationEvent; _connection.OnSubscriptionError += OnSubscriptionError; _connection.OnDisconnect += OnDisconnect; _connection.Open(); }
/// <summary> /// Initializes a new instance of the <see cref="PermissionSetPropertyDefinition"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="uri">The URI.</param> /// <param name="flags">The flags.</param> /// <param name="version">The version.</param> internal PermissionSetPropertyDefinition( string xmlElementName, string uri, PropertyDefinitionFlags flags, ExchangeVersion version) : base( xmlElementName, uri, flags, version) { }
/// <summary> /// Initializes a new instance of the <see cref="TypedPropertyDefinition"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="uri">The URI.</param> /// <param name="flags">The flags.</param> /// <param name="version">The version.</param> /// <param name="isNullable">Indicates that this property definition is for a nullable property.</param> internal TypedPropertyDefinition( string xmlElementName, string uri, PropertyDefinitionFlags flags, ExchangeVersion version, bool isNullable) : this( xmlElementName, uri, flags, version) { this.isNullable = isNullable; }
// URI like http://127.0.0.1:81/Schedule/ThisMonthItems?MailAddress=...&Password=... public ActionResult ThisMonthItems(O365AccountModel model) { // Exchange Online に接続 (今回はデモなので、Address は決めうち !) string emailAddress = model.MailAddress; string password = model.Password; ExchangeVersion ver = new ExchangeVersion(); ver = ExchangeVersion.Exchange2010_SP1; ExchangeService sv = new ExchangeService(ver, TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time")); //sv.TraceEnabled = true; // デバッグ用 sv.Credentials = new System.Net.NetworkCredential(emailAddress, password); //sv.EnableScpLookup = false; //sv.AutodiscoverUrl(emailAddress, AutodiscoverCallback); //sv.Url = new Uri(@"https://hknprd0202.outlook.com/EWS/Exchange.asmx"); sv.Url = new Uri(model.Url); // 今月の予定 (Appointment) を取得 //DateTime nowDate = DateTime.Now; DateTime nowDate = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now.ToUniversalTime(), "Tokyo Standard Time"); DateTime firstDate = new DateTime(nowDate.Year, nowDate.Month, 1); DateTime lastDate = firstDate.AddDays(DateTime.DaysInMonth(nowDate.Year, nowDate.Month) - 1); CalendarView thisMonthView = new CalendarView(firstDate, lastDate); FindItemsResults<Appointment> appointRes = sv.FindAppointments(WellKnownFolderName.Calendar, thisMonthView); // 結果 (Json 値) を作成 IList<object> resList = new List<object>(); foreach (Appointment appointItem in appointRes.Items) { // (注意 : Json では、Date は扱えない !) resList.Add(new { Subject = appointItem.Subject, StartYear = appointItem.Start.Year, StartMonth = appointItem.Start.Month, StartDate = appointItem.Start.Day, StartHour = appointItem.Start.Hour, StartMinute = appointItem.Start.Minute, StartSecond = appointItem.Start.Second }); } return new JsonResult() { Data = resList, ContentEncoding = System.Text.Encoding.UTF8, ContentType = @"application/json", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
/// <summary> /// Initializes a new instance of the <see cref="ScopedDateTimePropertyDefinition"/> class. /// </summary> /// <param name="xmlElementName">Name of the XML element.</param> /// <param name="uri">The URI.</param> /// <param name="flags">The flags.</param> /// <param name="version">The version.</param> /// <param name="getPropertyDefinitionCallback">The callback that will be used to retrieve the time zone property.</param> internal ScopedDateTimePropertyDefinition( string xmlElementName, string uri, PropertyDefinitionFlags flags, ExchangeVersion version, GetPropertyDefinitionCallback getPropertyDefinitionCallback) : base( xmlElementName, uri, flags, version) { EwsUtilities.Assert( getPropertyDefinitionCallback != null, "ScopedDateTimePropertyDefinition.ctor", "getPropertyDefinitionCallback is null."); this.getPropertyDefinitionCallback = getPropertyDefinitionCallback; }
/// <summary> /// Writes to XML. /// </summary> /// <param name="writer">The writer.</param> /// <param name="requestedServerVersion">The requested server version.</param> internal void WriteToXml(EwsServiceXmlWriter writer, ExchangeVersion requestedServerVersion) { if (string.IsNullOrEmpty(this.id)) { throw new ArgumentException(Strings.IdPropertyMustBeSet); } writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.OpenAsAdminOrSystemService); writer.WriteAttributeString(XmlElementNames.LogonType, this.logonType.ToString()); if (requestedServerVersion >= ExchangeVersion.Exchange2013 && this.budgetType.HasValue) { writer.WriteAttributeString(XmlElementNames.BudgetType, ((int)this.budgetType.Value).ToString()); } writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.ConnectingSID); writer.WriteElementValue(XmlNamespace.Types, this.idType.ToString(), this.id); writer.WriteEndElement(); // ConnectingSID writer.WriteEndElement(); // OpenAsAdminOrSystemService }
public override void OnMessage(string value) { try { // クライアントからメッセージが来た場合 JsonObject jsonValue = (JsonObject)JsonValue.Parse(value); this.EmailAddress = (string)((JsonPrimitive)jsonValue["address"]).Value; this.Password = (string)((JsonPrimitive)jsonValue["password"]).Value; // Exchange Online に接続 (今回はデモなので、Address は決めうち !) ExchangeVersion ver = new ExchangeVersion(); ver = ExchangeVersion.Exchange2010_SP1; sv = new ExchangeService(ver, TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time")); //sv.TraceEnabled = true; // デバッグ用 sv.Credentials = new System.Net.NetworkCredential( this.EmailAddress, this.Password); sv.EnableScpLookup = false; sv.AutodiscoverUrl(this.EmailAddress, AutodiscoverCallback); // Streaming Notification の開始 (今回はデモなので、15 分で終わり !) StreamingSubscription sub = sv.SubscribeToStreamingNotifications( new FolderId[] { new FolderId(WellKnownFolderName.Calendar) }, EventType.Created, EventType.Modified, EventType.Deleted); subcon = new StreamingSubscriptionConnection(sv, 15); // only 15 minutes ! subcon.AddSubscription(sub); subcon.OnNotificationEvent += new StreamingSubscriptionConnection.NotificationEventDelegate(subcon_OnNotificationEvent); subcon.Open(); // 準備完了の送信 ! JsonObject jsonObj = new JsonObject( new KeyValuePair<string, JsonValue>("MessageType", "Ready"), new KeyValuePair<string, JsonValue>("ServerUrl", sv.Url.ToString())); this.SendMessage(jsonObj.ToString()); } catch (Exception ex) { this.SendInternalError(ex); } base.OnMessage(value); }
/// <summary> /// Method for setting $EwsSession session context variable. /// </summary> /// <param name="userName">Connecting username.</param> /// <param name="password">Connecting password.</param> /// <param name="ewsUrl">Ews endpoint.</param> /// <param name="impersonateEmail">Email address of the impersonated user.</param> /// <param name="traceEnabled">Enable ews tracing.</param> /// <param name="traceFolder">Location where trace items will be saved.</param> /// <param name="traceFlags">Options what to trace.</param> internal void SetSessionVariable(string userName, SecureString password, Uri ewsUrl, string autodicoverEmail, string impersonateEmail, bool traceEnabled, string traceFolder, TraceFlags traceFlags, ExchangeVersion exchangeVersion) { this.SetSessionVariable(userName, password, ewsUrl, autodicoverEmail, exchangeVersion); this.SetSessionVariable(impersonateEmail, traceEnabled, traceFolder, traceFlags); }
/// <summary> /// Determines whether the specified flag is set. /// </summary> /// <param name="flag">The flag.</param> /// <param name="version">Requested version.</param> /// <returns> /// <c>true</c> if the specified flag is set; otherwise, <c>false</c>. /// </returns> internal override bool HasFlag(PropertyDefinitionFlags flag, ExchangeVersion? version) { if (version.HasValue && (version.Value == ExchangeVersion.Exchange2007_SP1)) { return AppointmentSchema.MeetingTimeZone.HasFlag(flag, version); } else { return base.HasFlag(flag, version); } }
private void SetSessionVariable(NetworkCredential networkCredentials, string autodiscoverEmail, Uri ewsUrl, ExchangeVersion exchangeVersion) { ExchangeService ewsService = new ExchangeService(exchangeVersion); ewsService.Credentials = networkCredentials; if (!String.IsNullOrEmpty(autodiscoverEmail)) { this.ValidateEmailAddress(autodiscoverEmail); ewsService.AutodiscoverUrl(autodiscoverEmail, this.RedirectionUrlValidationCallback); } else if (ewsUrl != null) ewsService.Url = ewsUrl; else throw new InvalidOperationException("Please specify autodiscover e-mail or Ews endpoint."); this.SessionState.PSVariable.Set("EwsSession", ewsService); }