예제 #1
0
        /// <summary>
        /// Adds the method to batch for SharePoint
        /// </summary>
        /// <param name="batch">The batch.</param>
        /// <param name="command">The command.</param>
        /// <param name="sharePointId">The share point id.</param>
        /// <param name="fields">The fields.</param>
        /// <returns></returns>
        private static void AddMethodToBatch(this XContainer batch, SharePointMethodCommand command, string sharePointId, Dictionary <string, object> fields)
        {
            string Id = "New";

            if (!string.IsNullOrEmpty(sharePointId))
            {
                Id = sharePointId;
            }

            XElement methodElement = new XElement("Method",
                                                  new XAttribute("ID", batch.Descendants().Count() + 1),
                                                  new XAttribute("Cmd", command.ToSharePointString()),
                                                  new XElement("Field",
                                                               new XAttribute("Name", "ID"),
                                                               Id));

            if (fields != null)
            {
                if (fields.Count == 0)
                {
                    return;
                }

                foreach (KeyValuePair <string, object> field in fields)
                {
                    methodElement.Add(new XElement("Field",
                                                   new XAttribute("Name", field.Key),
                                                   field.Value));
                }
            }

            batch.Add(methodElement);
        }
예제 #2
0
        /// <summary>
        /// Converts the SharePointMethodCommand into a valid string for use in SharePoint
        /// </summary>
        /// <param name="command">The command.</param>
        /// <returns></returns>
        internal static string ToSharePointString(this SharePointMethodCommand command)
        {
            string commandText = string.Empty;

            switch (command)
            {
            case SharePointMethodCommand.New:
            {
                commandText = "New";
                break;
            }

            case SharePointMethodCommand.Update:
            {
                commandText = "Update";
                break;
            }

            case SharePointMethodCommand.Delete:
            {
                commandText = "Delete";
                break;
            }
            }

            return(commandText);
        }