/// <summary> /// Core method for performing EWS calls against the Exchange service. /// </summary> /// <param name="credentials">User credentials.</param> /// <param name="exchangeUrl">URL to the EWS endpoint.</param> /// <param name="param">Additional parameters that work with the specific request.</param> /// <param name="requestType">Type of the EWS request.</param> /// <param name="additionalParam">List of additional parameters needed for a request.</param> /// <returns></returns> public IExchangeResponse PerformExchangeRequest(UserCredentials credentials, string exchangeUrl, string param, ExchangeRequestType requestType, IEnumerable <string> additionalParam = null) { var postContent = string.Empty; Type type = null; var authHeaderContent = GetBasicAuthFormat(credentials); var request = (HttpWebRequest)WebRequest.Create(exchangeUrl); request.Method = WebRequestMethods.Http.Post; request.Headers.Add(HttpRequestHeader.Authorization, string.Concat("Basic ", authHeaderContent)); request.UserAgent = "Hummingbird"; request.ContentType = "text/xml"; switch (requestType) { case ExchangeRequestType.ValidateAlias: { LoggingViewModel.Instance.Logger.Write(string.Concat("ExchangeConnector:ValidateAlias ", param)); postContent = Resources.AliasValidationPOST.Replace(AppSetup.GroupIdFiller, param); type = typeof(AliasValidationEnvelope); break; } case ExchangeRequestType.CreateGroup: { LoggingViewModel.Instance.Logger.Write(string.Concat("ExchangeConnector:CreateGroup ", param)); postContent = Resources.GroupCreationPOST.Replace(AppSetup.GroupIdFiller, param); var additionalParamList = additionalParam != null?additionalParam.ToList() : null; if (additionalParamList != null && additionalParamList.Count == 1) { postContent = postContent.Replace(AppSetup.OwnerSmtpFiller, additionalParamList[0]); } type = typeof(GroupCreationEnvelope); break; } case ExchangeRequestType.GetUnifiedGroupDetails: { LoggingViewModel.Instance.Logger.Write(string.Concat("ExchangeConnector:GetGroupDetails ", param)); postContent = Resources.GetUnifiedGroupsPOST.Replace(AppSetup.GroupSmtpFiller, param); type = typeof(GetUnifiedGroupEnvelope); break; } case ExchangeRequestType.DeleteGroup: { postContent = Resources.DeleteGroupPOST; type = null; break; } case ExchangeRequestType.AddMember: { LoggingViewModel.Instance.Logger.Write(string.Concat("ExchangeConnector:AddMember ", param)); if (additionalParam != null) { using ( var addMemberEnvelopeStream = new MemoryStream(Encoding.UTF8.GetBytes(Resources.SetUnifiedGroupMembersPOST))) { using (var reader = new StreamReader(addMemberEnvelopeStream)) { var serializer = new XmlSerializer(typeof(AddMemberEnvelope)); var deserializedContent = (AddMemberEnvelope)serializer.Deserialize(reader); deserializedContent.Body.SetUnifiedGroupMembershipState.Members = new List <string>(additionalParam); deserializedContent.Body.SetUnifiedGroupMembershipState.GroupIdentity.Value = param; var ns = new XmlSerializerNamespaces(); ns.Add("s", "http://schemas.xmlsoap.org/soap/envelope/"); var xmlWriterSettings = new XmlWriterSettings { OmitXmlDeclaration = true }; using (var textWriter = new StringWriter()) { using (var writer = XmlWriter.Create(textWriter, xmlWriterSettings)) { serializer.Serialize(writer, deserializedContent, ns); postContent = textWriter.ToString(); LoggingViewModel.Instance.Logger.Write( string.Concat("ExchangeConnector:AddMemberPostContent ", postContent)); type = typeof(SetMemberEnvelope); } } } } } else { throw new ArgumentNullException("additionalParam", Resources.ExchangeRequestAddMembersWithoutMembers); } break; } } var processedPostContent = Encoding.UTF8.GetBytes(postContent); request.ContentLength = processedPostContent.Length; using (var requestStream = request.GetRequestStream()) { requestStream.Write(processedPostContent, 0, processedPostContent.Length); } try { var response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { using (var responseStream = response.GetResponseStream()) { using (var reader = new StreamReader(responseStream)) { var serializer = new XmlSerializer(type); var translatedResponse = (IExchangeResponse)serializer.Deserialize(reader); return(translatedResponse); } } } } catch (Exception exception) { LoggingViewModel.Instance.Logger.Write(string.Concat("ExchangeConnector:Error ", exception.Message, Environment.NewLine, exception.StackTrace)); } return(null); }
/// <summary> /// Core method for performing EWS calls against the Exchange service. /// </summary> /// <param name="credentials">User credentials.</param> /// <param name="exchangeUrl">URL to the EWS endpoint.</param> /// <param name="param">Additional parameters that work with the specific request.</param> /// <param name="requestType">Type of the EWS request.</param> /// <param name="additionalParam">List of additional parameters needed for a request.</param> /// <returns></returns> public IExchangeResponse PerformExchangeRequest(UserCredentials credentials, string exchangeUrl, string param, ExchangeRequestType requestType, IEnumerable<string> additionalParam = null) { var postContent = string.Empty; Type type = null; var authHeaderContent = GetBasicAuthFormat(credentials); var request = (HttpWebRequest) WebRequest.Create(exchangeUrl); request.Method = WebRequestMethods.Http.Post; request.Headers.Add(HttpRequestHeader.Authorization, string.Concat("Basic ", authHeaderContent)); request.UserAgent = "Hummingbird"; request.ContentType = "text/xml"; switch (requestType) { case ExchangeRequestType.ValidateAlias: { LoggingViewModel.Instance.Logger.Write(string.Concat("ExchangeConnector:ValidateAlias ", param)); postContent = Resources.AliasValidationPOST.Replace(AppSetup.GroupIdFiller, param); type = typeof (AliasValidationEnvelope); break; } case ExchangeRequestType.CreateGroup: { LoggingViewModel.Instance.Logger.Write(string.Concat("ExchangeConnector:CreateGroup ", param)); postContent = Resources.GroupCreationPOST.Replace(AppSetup.GroupIdFiller, param); var additionalParamList = additionalParam != null ? additionalParam.ToList() : null; if (additionalParamList != null && additionalParamList.Count == 1) { postContent = postContent.Replace(AppSetup.OwnerSmtpFiller, additionalParamList[0]); } type = typeof (GroupCreationEnvelope); break; } case ExchangeRequestType.GetUnifiedGroupDetails: { LoggingViewModel.Instance.Logger.Write(string.Concat("ExchangeConnector:GetGroupDetails ", param)); postContent = Resources.GetUnifiedGroupsPOST.Replace(AppSetup.GroupSmtpFiller, param); type = typeof (GetUnifiedGroupEnvelope); break; } case ExchangeRequestType.DeleteGroup: { postContent = Resources.DeleteGroupPOST; type = null; break; } case ExchangeRequestType.AddMember: { LoggingViewModel.Instance.Logger.Write(string.Concat("ExchangeConnector:AddMember ", param)); if (additionalParam != null) { using ( var addMemberEnvelopeStream = new MemoryStream(Encoding.UTF8.GetBytes(Resources.SetUnifiedGroupMembersPOST))) { using (var reader = new StreamReader(addMemberEnvelopeStream)) { var serializer = new XmlSerializer(typeof (AddMemberEnvelope)); var deserializedContent = (AddMemberEnvelope) serializer.Deserialize(reader); deserializedContent.Body.SetUnifiedGroupMembershipState.Members = new List<string>(additionalParam); deserializedContent.Body.SetUnifiedGroupMembershipState.GroupIdentity.Value = param; var ns = new XmlSerializerNamespaces(); ns.Add("s", "http://schemas.xmlsoap.org/soap/envelope/"); var xmlWriterSettings = new XmlWriterSettings { OmitXmlDeclaration = true }; using (var textWriter = new StringWriter()) { using (var writer = XmlWriter.Create(textWriter, xmlWriterSettings)) { serializer.Serialize(writer, deserializedContent, ns); postContent = textWriter.ToString(); LoggingViewModel.Instance.Logger.Write( string.Concat("ExchangeConnector:AddMemberPostContent ", postContent)); type = typeof (SetMemberEnvelope); } } } } } else { throw new ArgumentNullException("additionalParam", Resources.ExchangeRequestAddMembersWithoutMembers); } break; } } var processedPostContent = Encoding.UTF8.GetBytes(postContent); request.ContentLength = processedPostContent.Length; using (var requestStream = request.GetRequestStream()) { requestStream.Write(processedPostContent, 0, processedPostContent.Length); } try { var response = (HttpWebResponse) request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { using (var responseStream = response.GetResponseStream()) { using (var reader = new StreamReader(responseStream)) { var serializer = new XmlSerializer(type); var translatedResponse = (IExchangeResponse) serializer.Deserialize(reader); return translatedResponse; } } } } catch (Exception exception) { LoggingViewModel.Instance.Logger.Write(string.Concat("ExchangeConnector:Error ", exception.Message, Environment.NewLine, exception.StackTrace)); } return null; }
public ObjectList<ExchangeRequest> GetDuplicatesByOutId(ExchangeRequestType type, ExchangeStatus status) { return Mappers.ExchangeRequestMapper.GetDuplicatesByOutId(base.Id, this.OutId, type, status); }
public static ObjectList<ExchangeRequest> GetExchangeRequestsGroup(ExchangeRequestType type, ExchangeStatus status) { return Mappers.ExchangeRequestMapper.GetExchangeRequestsGroup(type, status); }
public static ObjectList<ExchangeRequest> FindBy(ExchangeRequestType type, System.DateTime DateIn) { return Mappers.ExchangeRequestMapper.FindBy(type, DateIn); }
public static ObjectList<ExchangeRequest> FindBy(ExchangeRequestType type, ExchangeStatus status) { return Mappers.ExchangeRequestMapper.FindBy(type, status); }
private void LoadExchangeRequest(System.Windows.Forms.ListBox list, ExchangeRequestType exchangeRequestType) { if (this.m_IsShowAll) { foreach (ExchangeRequest request in ExchangeRequest.FindBy(exchangeRequestType, this.dtFilter.Value)) { list.Items.Add(request); } } else { foreach (ExchangeRequest request2 in ExchangeRequest.FindBy(exchangeRequestType, ExchangeStatus.Received)) { list.Items.Add(request2); } } }