private void CreateFolderRequest(XmlWriter writer, ZimbraFolder folder, int requestId) { writer.WriteStartElement("CreateFolderRequest", "urn:zimbraMail"); if (requestId != -1) writer.WriteAttributeString("requestId", requestId.ToString()); writer.WriteStartElement("folder"); writer.WriteAttributeString("name", folder.name); writer.WriteAttributeString("l", folder.parent); writer.WriteAttributeString("fie", "1"); // return the existing ID instead of an error if (folder.view.Length > 0) writer.WriteAttributeString("view", folder.view); if (folder.color.Length > 0) writer.WriteAttributeString("color", folder.color); if (folder.flags.Length > 0) writer.WriteAttributeString("f", folder.flags); writer.WriteEndElement(); // folder writer.WriteEndElement(); // CreateFolderRequest }
private int DoCreateFolder(ZimbraFolder folder, out string folderID) { folderID = ""; lastError = ""; int retval = 0; WebServiceClient client = new WebServiceClient { Url = ZimbraValues.GetZimbraValues().Url, WSServiceType = WebServiceClient.ServiceType.Traditional }; StringBuilder sb = new StringBuilder(); XmlWriterSettings settings = new XmlWriterSettings(); settings.OmitXmlDeclaration = true; using (XmlWriter writer = XmlWriter.Create(sb, settings)) { writer.WriteStartDocument(); writer.WriteStartElement("soap", "Envelope", "http://www.w3.org/2003/05/soap-envelope"); WriteHeader(writer, true, true, true); writer.WriteStartElement("Body", "http://www.w3.org/2003/05/soap-envelope"); CreateFolderRequest(writer, folder, -1); writer.WriteEndElement(); // soap body writer.WriteEndElement(); // soap envelope writer.WriteEndDocument(); } string rsp = ""; WriteSoapLog(sb.ToString(),true); client.InvokeService(sb.ToString(), out rsp); WriteSoapLog(rsp.ToString(),false); retval = client.status; if (client.status == 0) { ParseCreateFolder(rsp, out folderID); // get the id } else { string soapReason = ParseSoapFault(client.errResponseMessage); if (soapReason.Length > 0) lastError = soapReason; else lastError = client.exceptionMessage; } return retval; }
private void CreateFolderRequest(XmlWriter writer, ZimbraFolder folder, int requestId) { writer.WriteStartElement("CreateFolderRequest", "urn:zimbraMail"); if (requestId != -1) writer.WriteAttributeString("requestId", requestId.ToString()); writer.WriteStartElement("folder"); // specialCharacters.Any(s => s.Equals(folder.name)); int indSpecialC = folder.name.IndexOfAny(specialCharacters); if ( indSpecialC != -1) { StringBuilder sb = new StringBuilder(folder.name); if (ReplaceSlash == null) { ReplaceSlash = "_"; } sb[indSpecialC] = ReplaceSlash.ToCharArray().ElementAt(0)/*'_'*/; string newS = sb.ToString(); writer.WriteAttributeString("name", newS); } else writer.WriteAttributeString("name", folder.name); writer.WriteAttributeString("l", folder.parent); writer.WriteAttributeString("fie", "1"); // return the existing ID instead of an error if (folder.view.Length > 0) writer.WriteAttributeString("view", folder.view); if (folder.color.Length > 0) writer.WriteAttributeString("color", folder.color); if (folder.flags.Length > 0) writer.WriteAttributeString("f", folder.flags); writer.WriteEndElement(); // folder writer.WriteEndElement(); // CreateFolderRequest }