示例#1
0
        protected static XmlBody GetCrudBody <T>(CrudOperation <T> operation) where T : ZObject
        {
            XmlBody body = new XmlBody();

            switch (operation.OperationType)
            {
            case CrudOperations.Insert:
                body.InsertTemplate = new BasicCrudTemplate
                {
                    ZObjects = operation.Items
                };
                break;

            case CrudOperations.Update:
                body.UpdateTemplate = new BasicCrudTemplate
                {
                    ZObjects = operation.Items
                };
                break;

            case CrudOperations.Delete:
                body.DeleteTemplate = new DeleteTemplate
                {
                    ZObjects = operation.Items
                };
                break;
            }

            return(body);
        }
示例#2
0
        public static async Task <HttpResponseMessage> PutXmlAsync <T>(
            this ICateHttp cate, string uri, T data)
        {
            var body = new XmlBody(cate.Configuration.XmlSerializer.Serialize(data));

            return(await cate.SendAsync(uri, HttpMethod.Put, MimeType.Xml, body));
        }
        internal static string GenerateRequest(XmlBody body, XmlHeader header)
        {
            XmlDocument document = SerializeToDocument(new XmlRequest
            {
                Body   = body,
                Header = header
            });

            return(document.OuterXml);
        }
        public string GetRequestWithData()
        {
            string XmlBody;

            using (StreamReader reader = GetXMLFileStream())
            {
                XmlBody = reader.ReadToEnd();
            }
            int counter = 0;

            foreach (string Field in ReplaceFieldName)
            {
                if (XmlBody.Contains(Field))
                {
                    XmlBody = XmlBody.Replace(Field, ReplacementData[counter]);
                }
                counter++;
            }
            return(XmlBody);
        }
示例#5
0
        private static XmlBody GetCrudBody <T>(CrudOperation <T> operation) where T : SObject
        {
            XmlBody body = new XmlBody();

            switch (operation.OperationType)
            {
            case CrudOperations.Insert:
                body.InsertTemplate = new BasicCrudTemplate
                {
                    SObjects = GetCrudItems(operation.Items, CrudOperations.Insert)
                };
                break;

            case CrudOperations.Upsert:
                body.UpsertTemplate = new UpsertTemplate
                {
                    SObjects            = GetCrudItems(operation.Items, CrudOperations.Upsert),
                    ExternalIdFieldName = operation.ExternalIdField
                };
                break;

            case CrudOperations.Update:
                body.UpdateTemplate = new BasicCrudTemplate
                {
                    SObjects = GetCrudItems(operation.Items, CrudOperations.Update)
                };
                break;

            case CrudOperations.Delete:
                body.DeleteTemplate = new DeleteTemplate
                {
                    Ids = operation.Items.Select(i => i.Id).Distinct().ToArray()
                };
                break;
            }

            return(body);
        }
示例#6
0
        public static string CrudOperation <T>(CrudOperation <T> operation, SalesforceSession session) where T : SObject
        {
            XmlBody body = GetCrudBody(operation);

            return(XmlRequestGenerator.GenerateRequest(body, BuildXmlHeader(session)));
        }
 internal static string GenerateRequest(XmlBody body)
 {
     return(GenerateRequest(body, null));
 }