private void BuildResponseWithStatus(string statusCode, XmlNode responseNode) { XmlNode xmlNode = responseNode.OwnerDocument.CreateElement("Move", "ItemOperations:"); XmlNode xmlNode2 = responseNode.OwnerDocument.CreateElement("Status", "ItemOperations:"); xmlNode2.InnerText = statusCode; xmlNode.AppendChild(xmlNode2); AirSyncBlobXmlNode airSyncBlobXmlNode = new AirSyncBlobXmlNode(null, "ConversationId", "ItemOperations:", responseNode.OwnerDocument); if (this.conversationId != null) { airSyncBlobXmlNode.ByteArray = this.conversationId.GetBytes(); } else { AirSyncBlobXmlNode airSyncBlobXmlNode2 = (AirSyncBlobXmlNode)this.conversationIdNode; if (airSyncBlobXmlNode2 != null && airSyncBlobXmlNode2.Stream != null && airSyncBlobXmlNode2.Stream.CanSeek && airSyncBlobXmlNode2.Stream.CanRead) { airSyncBlobXmlNode.ByteArray = new byte[airSyncBlobXmlNode2.Stream.Length]; airSyncBlobXmlNode2.Stream.Seek(0L, SeekOrigin.Begin); airSyncBlobXmlNode2.Stream.Read(airSyncBlobXmlNode.ByteArray, 0, (int)airSyncBlobXmlNode2.Stream.Length); } } xmlNode.AppendChild(airSyncBlobXmlNode); responseNode.AppendChild(xmlNode); }
protected void CreateAirSyncNode(string airSyncTagName, byte[] data) { AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.AirSyncTracer, this, "Creating Node={0}", airSyncTagName); AirSyncBlobXmlNode airSyncBlobXmlNode = new AirSyncBlobXmlNode(null, airSyncTagName, this.xmlNodeNamespace, this.xmlParentNode.OwnerDocument); airSyncBlobXmlNode.ByteArray = data; this.xmlParentNode.AppendChild(airSyncBlobXmlNode); }
private int GetHashCode(XmlNode xmlNode) { AirSyncBlobXmlNode airSyncBlobXmlNode = xmlNode as AirSyncBlobXmlNode; if (airSyncBlobXmlNode != null && airSyncBlobXmlNode.Stream != null) { return(airSyncBlobXmlNode.GetHashCode()); } return(xmlNode.InnerText.GetHashCode()); }
protected void CreateAirSyncNode(string airSyncTagName, Stream mimeData, long mimeSize, XmlNodeType originalNodeType) { AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.AirSyncTracer, this, "Creating Node={0}", airSyncTagName); AirSyncBlobXmlNode airSyncBlobXmlNode = new AirSyncBlobXmlNode(null, airSyncTagName, this.xmlNodeNamespace, this.xmlParentNode.OwnerDocument); airSyncBlobXmlNode.Stream = mimeData; airSyncBlobXmlNode.StreamDataSize = mimeSize; airSyncBlobXmlNode.OriginalNodeType = originalNodeType; this.xmlParentNode.AppendChild(airSyncBlobXmlNode); }
protected XmlNode AppendChildNode(XmlNode parentNode, string elementName, Stream streamData, long dataSize, XmlNodeType orginalNodeType) { AirSyncDiagnostics.TraceInfo <string, string>(ExTraceGlobals.AirSyncTracer, this, "Appending Node={0} to {1}", elementName, parentNode.Name); AirSyncBlobXmlNode airSyncBlobXmlNode = new AirSyncBlobXmlNode(null, elementName, this.xmlNodeNamespace, this.xmlParentNode.OwnerDocument); airSyncBlobXmlNode.Stream = streamData; airSyncBlobXmlNode.StreamDataSize = dataSize; airSyncBlobXmlNode.OriginalNodeType = orginalNodeType; parentNode.AppendChild(airSyncBlobXmlNode); return(airSyncBlobXmlNode); }
public void BuildResponse(XmlNode responseNode) { XmlNode xmlNode = responseNode.OwnerDocument.CreateElement("Fetch", "ItemOperations:"); XmlNode xmlNode2 = responseNode.OwnerDocument.CreateElement("Status", "ItemOperations:"); XmlNode xmlNode3 = responseNode.OwnerDocument.CreateElement("FileReference", "AirSyncBase:"); XmlNode xmlNode4 = responseNode.OwnerDocument.CreateElement("Properties", "ItemOperations:"); XmlNode xmlNode5 = responseNode.OwnerDocument.CreateElement("ContentType", "AirSyncBase:"); if (this.RangeSpecified) { XmlNode xmlNode6 = responseNode.OwnerDocument.CreateElement("Range", "ItemOperations:"); xmlNode6.InnerText = string.Format(CultureInfo.InvariantCulture, "{0}-{1}", new object[] { this.MinRange, (long)this.MinRange + this.OutStream.Length - 1L }); xmlNode4.AppendChild(xmlNode6); XmlNode xmlNode7 = responseNode.OwnerDocument.CreateElement("Total", "ItemOperations:"); xmlNode7.InnerText = this.Total.ToString(CultureInfo.InvariantCulture); xmlNode4.AppendChild(xmlNode7); } xmlNode5.InnerText = this.ContentType; xmlNode4.AppendChild(xmlNode5); if (this.MultiPartResponse) { XmlNode xmlNode8 = responseNode.OwnerDocument.CreateElement("Part", "ItemOperations:"); xmlNode8.InnerText = this.PartNumber.ToString(CultureInfo.InvariantCulture); xmlNode4.AppendChild(xmlNode8); } else { this.OutStream.DoBase64Conversion = true; AirSyncBlobXmlNode airSyncBlobXmlNode = new AirSyncBlobXmlNode(null, "Data", "ItemOperations:", responseNode.OwnerDocument); airSyncBlobXmlNode.Stream = this.GetResponseStream(); airSyncBlobXmlNode.StreamDataSize = airSyncBlobXmlNode.Stream.Length; airSyncBlobXmlNode.OriginalNodeType = XmlNodeType.Text; xmlNode4.AppendChild(airSyncBlobXmlNode); } xmlNode2.InnerText = 1.ToString(CultureInfo.InvariantCulture); xmlNode.AppendChild(xmlNode2); xmlNode3.InnerText = this.FileReference; xmlNode.AppendChild(xmlNode3); xmlNode.AppendChild(xmlNode4); responseNode.AppendChild(xmlNode); }
// Token: 0x06000C40 RID: 3136 RVA: 0x000404C0 File Offset: 0x0003E6C0 public void BuildResponse(XmlNode responseNode) { XmlNode xmlNode = responseNode.OwnerDocument.CreateElement("Fetch", "ItemOperations:"); XmlNode xmlNode2 = responseNode.OwnerDocument.CreateElement("Status", "ItemOperations:"); XmlNode xmlNode3 = responseNode.OwnerDocument.CreateElement("Class", "AirSync:"); XmlNode xmlNode4 = responseNode.OwnerDocument.CreateElement("Properties", "ItemOperations:"); XmlNode xmlNode5 = responseNode.OwnerDocument.CreateElement("ServerId", "AirSync:"); XmlNode xmlNode6 = responseNode.OwnerDocument.CreateElement("CollectionId", "AirSync:"); XmlNode xmlNode7 = responseNode.OwnerDocument.CreateElement("LongId", "Search:"); FlexibleSchemaStrategy missingPropertyStrategy = new FlexibleSchemaStrategy(this.schemaTags); this.schemaConverterOptions["BodyPreference"] = this.bodyPreferences; this.schemaConverterOptions["BodyPartPreference"] = this.bodyPartPreferences; this.schemaConverterOptions["MIMESupport"] = this.mimeSupport; bool flag = false; try { using (Item item = Item.Bind(this.mailboxSession, this.storeObjectId)) { if (this.removeRightsManagementProtection) { this.IrmRemoveRestriction(item); } if (this.bodyPartPreferences != null && this.bodyPartPreferences.Count > 0) { ConversationId valueOrDefault = item.GetValueOrDefault <ConversationId>(ItemSchema.ConversationId, null); if (valueOrDefault != null) { Conversation conversation; Command.CurrentCommand.GetOrCreateConversation(valueOrDefault, true, out conversation); conversation.LoadItemParts(new List <StoreObjectId> { item.StoreObjectId }); } } foreach (KeyValuePair <string, AirSyncSchemaState> keyValuePair in this.schemaStates) { AirSyncSchemaState value = keyValuePair.Value; AirSyncXsoSchemaState airSyncXsoSchemaState = value as AirSyncXsoSchemaState; AirSyncEntitySchemaState airSyncEntitySchemaState = value as AirSyncEntitySchemaState; IServerDataObject serverDataObject; if (airSyncXsoSchemaState != null) { serverDataObject = airSyncXsoSchemaState.GetXsoDataObject(); } else { if (airSyncEntitySchemaState == null) { throw new NotImplementedException(string.Format("Schema state for \"{0}\" is not implemented yet.", keyValuePair.Key)); } serverDataObject = airSyncEntitySchemaState.GetEntityDataObject(); } if (serverDataObject.CanConvertItemClassUsingCurrentSchema(item.ClassName)) { AirSyncDataObject airSyncDataObject = value.GetAirSyncDataObject(this.schemaConverterOptions, missingPropertyStrategy); if (this.rightsManagementSupport) { Command.CurrentCommand.DecodeIrmMessage(item, true); } item.Load(serverDataObject.GetPrefetchProperties()); try { serverDataObject.Bind(item); airSyncDataObject.Bind(xmlNode4); airSyncDataObject.CopyFrom(serverDataObject); } finally { airSyncDataObject.Unbind(); serverDataObject.Unbind(); } if (this.rightsManagementSupport) { Command.CurrentCommand.SaveLicense(item); } xmlNode3.InnerText = keyValuePair.Key; flag = true; break; } } } } catch (ObjectNotFoundException innerException) { throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, innerException, false) { ErrorStringForProtocolLogger = "NotFoundInMbxFetch" }; } catch (AirSyncPermanentException) { throw; } catch (Exception ex) { if (!SyncCommand.IsItemSyncTolerableException(ex)) { throw; } AirSyncDiagnostics.TraceError <Exception>(ExTraceGlobals.ConversionTracer, this, "Sync-tolerable Item conversion Exception was thrown. Location BuildResponse(). {0}", ex); } if (!flag) { throw new AirSyncPermanentException(StatusCode.Sync_InvalidWaitTime, false) { ErrorStringForProtocolLogger = "ConvertErrorInMbxFetch" }; } xmlNode2.InnerText = 1.ToString(CultureInfo.InvariantCulture); xmlNode.AppendChild(xmlNode2); if (this.longId != null) { xmlNode7.InnerText = this.longId; xmlNode.AppendChild(xmlNode7); } else { xmlNode6.InnerText = this.collectionId; xmlNode.AppendChild(xmlNode6); xmlNode5.InnerText = this.serverId; xmlNode.AppendChild(xmlNode5); } xmlNode.AppendChild(xmlNode3); xmlNode.AppendChild(xmlNode4); if (this.multiPartResponse) { XmlNode xmlNode8 = xmlNode4["Body"]; if (xmlNode8 != null) { XmlNode xmlNode9 = xmlNode8["Data"]; AirSyncBlobXmlNode airSyncBlobXmlNode = xmlNode9 as AirSyncBlobXmlNode; if (xmlNode9 != null && (!string.IsNullOrEmpty(xmlNode9.InnerText) || (airSyncBlobXmlNode != null && airSyncBlobXmlNode.Stream != null))) { XmlNode xmlNode10 = responseNode.OwnerDocument.CreateElement("Part", "ItemOperations:"); xmlNode10.InnerText = this.partNumber.ToString(CultureInfo.InvariantCulture); xmlNode8.ReplaceChild(xmlNode10, xmlNode9); if (airSyncBlobXmlNode != null && airSyncBlobXmlNode.Stream != null) { this.outStream = airSyncBlobXmlNode.Stream; if (airSyncBlobXmlNode.Stream is AirSyncStream) { this.delayStreamDispose = true; } AirSyncDiagnostics.TraceError <Type>(ExTraceGlobals.ConversionTracer, this, "blobNode.Stream is of {0} type.", airSyncBlobXmlNode.Stream.GetType()); } else { UTF8Encoding utf8Encoding = new UTF8Encoding(); this.outStream = new MemoryStream(utf8Encoding.GetBytes(xmlNode9.InnerText)); } } } } responseNode.AppendChild(xmlNode); }
// Token: 0x06001560 RID: 5472 RVA: 0x0007D5CC File Offset: 0x0007B7CC protected void ParseMimeToMessage(MessageItem message) { if (message == null) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ItemCreationFailed"); throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.MailSubmissionFailed, null, false); } Stream stream; if (base.Version < 140) { stream = base.InputStream; } else { AirSyncBlobXmlNode airSyncBlobXmlNode = base.Request.CommandXml["Mime"] as AirSyncBlobXmlNode; stream = airSyncBlobXmlNode.Stream; stream.Seek(0L, SeekOrigin.Begin); } InboundConversionOptions inboundConversionOptions = AirSyncUtility.GetInboundConversionOptions(); inboundConversionOptions.ClearCategories = false; try { ItemConversion.ConvertAnyMimeToItem(message, stream, inboundConversionOptions); } catch (ExchangeDataException innerException) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidCharSetError"); throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidMIME, innerException, false); } catch (ConversionFailedException innerException2) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "SendMailMimeError"); throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidMIME, innerException2, false); } message.From = null; IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(Command.CurrentOrganizationId), 854, "ParseMimeToMessage", "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\SendMailBase.cs"); TransportConfigContainer transportConfigContainer = tenantOrTopologyConfigurationSession.FindSingletonConfigurationObject <TransportConfigContainer>(); base.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, tenantOrTopologyConfigurationSession.LastUsedDc); bool flag = transportConfigContainer == null || !transportConfigContainer.OpenDomainRoutingEnabled; if (flag && SendMailBase.DefaultDomain != null) { IList <Recipient> list = new List <Recipient>(); foreach (Recipient recipient in message.Recipients) { if (recipient.Participant.RoutingType == null || (recipient.Participant.RoutingType == "SMTP" && recipient.Participant.EmailAddress.IndexOf('@') == -1)) { list.Add(recipient); } } foreach (Recipient recipient2 in list) { Participant participant = this.ResolveUnresolvedParticipant(recipient2.Participant); message.Recipients.Remove(recipient2); message.Recipients.Add(participant, recipient2.RecipientItemType); } IList <Participant> list2 = new List <Participant>(); foreach (Participant participant2 in message.ReplyTo) { if (participant2.RoutingType == null || (participant2.RoutingType == "SMTP" && participant2.EmailAddress.IndexOf('@') == -1)) { list2.Add(participant2); } } foreach (Participant participant3 in list2) { Participant item = this.ResolveUnresolvedParticipant(participant3); message.ReplyTo.Remove(participant3); message.ReplyTo.Add(item); } } if (message.Recipients.Count == 0) { base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MessageHasNoRecipient"); throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.MessageHasNoRecipient, null, false); } }
// Token: 0x06000F4E RID: 3918 RVA: 0x0005793C File Offset: 0x00055B3C private Attachment16Data ParseAttachmentsData(XmlNode parentNode, AttachmentAction action) { Attachment16Data attachment16Data = new Attachment16Data(action); foreach (object obj in parentNode) { XmlNode xmlNode = (XmlNode)obj; string name; switch (name = xmlNode.Name) { case "FileReference": attachment16Data.FileReference = HttpUtility.UrlDecode(xmlNode.InnerText); continue; case "ContentId": attachment16Data.ContentId = xmlNode.InnerText; continue; case "ContentLocation": attachment16Data.ContentLocation = xmlNode.InnerText; continue; case "Method": attachment16Data.Method = Convert.ToByte(xmlNode.InnerText); continue; case "DisplayName": attachment16Data.DisplayName = xmlNode.InnerText; continue; case "IsInline": if (string.IsNullOrEmpty(xmlNode.InnerText)) { attachment16Data.IsInline = true; continue; } if (xmlNode.InnerText.Equals("1")) { attachment16Data.IsInline = true; continue; } if (xmlNode.InnerText.Equals("0")) { attachment16Data.IsInline = false; continue; } throw new ConversionException("Airsync16AttachmentProperty:ParseAttachmentsData. Invalid value passed in 'IsInline' Node."); case "Content": { AirSyncBlobXmlNode airSyncBlobXmlNode = xmlNode as AirSyncBlobXmlNode; if (airSyncBlobXmlNode == null) { continue; } if (airSyncBlobXmlNode.ByteArray != null) { attachment16Data.Content = airSyncBlobXmlNode.ByteArray; continue; } if (airSyncBlobXmlNode.Stream != null && airSyncBlobXmlNode.Stream.CanSeek && airSyncBlobXmlNode.Stream.CanRead) { attachment16Data.Content = new byte[airSyncBlobXmlNode.Stream.Length]; airSyncBlobXmlNode.Stream.Seek(0L, SeekOrigin.Begin); airSyncBlobXmlNode.Stream.Read(attachment16Data.Content, 0, (int)airSyncBlobXmlNode.Stream.Length); continue; } throw new ConversionException("Airsync16AttachmentProperty:ParseAttachmentsData. Invalid value passed in 'Data' Node."); } case "ContentType": attachment16Data.ContentType = xmlNode.InnerText; continue; case "ClientId": attachment16Data.ClientId = xmlNode.InnerText; continue; } throw new ConversionException(string.Format("Airsync16AttachmentProperty:ParseAttachmentsData. invalid node {0}.", xmlNode.Name)); } return(attachment16Data); }