Exemplo n.º 1
0
        /// <summary>
        /// Modify a multi-valued free busy property from a WebDAV resource
        /// </summary>
        /// <param name="destination">The URL of the resource</param>
        /// <param name="property">Property to modify</param>
        /// <param name="propertyValues">The new Property values</param>
        /// <returns>void</returns>
        public void UpdateFreeBusyProperty(
            string destination,
            FreeBusyProperty property,
            List <string> propertyValues)
        {
            string body = BuildFreeBusyMultiValuedPropertyQuery(property.Name, property.NameSpace, property.Type, propertyValues);

            IssueRequestIgnoreResponse(destination, Method.PROPPATCH, body);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Add a multivalued free busy property to the query to be updated to the given values.
 /// </summary>
 /// <param name="property">Property to add</param>
 /// <param name="propertyValues">The list of value for the property</param>
 public void AddUpdateProperty(
     FreeBusyProperty property,
     List <string> propertyValues)
 {
     AddUpdateProperty(property.Name,
                       property.NameSpace,
                       property.Type,
                       propertyValues);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Add a free busy property to the query to be updated to the given value.
 /// </summary>
 /// <param name="property">Property to add</param>
 /// <param name="propertyValue">The value for the property</param>
 public void AddUpdateProperty(
     FreeBusyProperty property,
     string propertyValue)
 {
     AddUpdateProperty(property.Name,
                       property.NameSpace,
                       property.Type,
                       propertyValue);
 }
Exemplo n.º 4
0
        private static bool CheckMultiValueProperty(
            FreeBusyProperty property)
        {
            string propertyName      = property.Name;
            string propertyNamespace = property.NameSpace;
            string propertyType      = property.Type;

            if (propertyType.Substring(0, 3) != "mv.")
            {
                // The property is supposed to be multi-valued, thus the type must start with "mv."
                return(false);
            }

            if (propertyNamespace != "http://schemas.microsoft.com/mapi/proptag/")
            {
                return(true);
            }

            if (propertyName[0] != 'x' && propertyName[0] != 'X')
            {
                return(true);
            }

            int propTag = 0;

            try
            {
                propTag = Convert.ToInt32("0" + propertyName, 16);
            }
            catch (FormatException)
            {
                return(false);
            }
            catch (OverflowException)
            {
                return(false);
            }

            if ((propTag & 0x1000) == 0)
            {
                return(false);
            }

            switch (propTag & 0xfff)
            {
            case 3:
                return(propertyType == "mv.int");

            case 0x102:
                return(propertyType == "mv.bin.base64");

            default:
                return(false);
            }
        }
Exemplo n.º 5
0
        public void TestRemove()
        {
            string             body         = null;
            WebDavQueryBuilder queryBuilder = new WebDavQueryBuilder();
            Property           del2         = new Property("del2", "NS2");
            FreeBusyProperty   del3         = new FreeBusyProperty("del3", "FB", "type2");
            string             expectedBody =
                "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<a:propertyupdate " +
                "xmlns:a=\"DAV:\" " +
                "xmlns:b=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\" " +
                "xmlns:c=\"xml:\" " +
                "xmlns:d=\"NS1\" " +
                "xmlns:e=\"NS2\" " +
                "xmlns:f=\"FB\">" +
                "<a:remove>" +
                "<a:prop>" +
                "<d:del1/>" +
                "<e:del2/>" +
                "<f:del3/>" +
                "</a:prop>" +
                "</a:remove>" +
                "</a:propertyupdate>";

            VerifyWellFormedXml(expectedBody);

            for (int i = 0; i < 2; i++)
            {
                bool exceptionCaught = false;
                try
                {
                    body = queryBuilder.BuildQueryBody();
                }
                catch (Exception)
                {
                    exceptionCaught = true;
                }
                Assert.IsTrue(exceptionCaught);

                queryBuilder.AddRemoveProperty("del1", "NS1");
                queryBuilder.AddRemoveProperty(del2);
                queryBuilder.AddRemoveProperty(del3);

                body = queryBuilder.BuildQueryBody();
                VerifyWellFormedXml(body);
                Assert.IsTrue(CompareXml(body, expectedBody));
                queryBuilder.Reset();
            }
        }
        public void TestUpdate()
        {
            string body = null;
            WebDavQueryBuilder queryBuilder = new WebDavQueryBuilder();
            Property up2 = new Property("up2", "NS1");
            FreeBusyProperty up3 = new FreeBusyProperty("up3", "FB", "type1");
            FreeBusyProperty up4 = new FreeBusyProperty("up4", "MV", "mv.type2");
            FreeBusyProperty up5 = new FreeBusyProperty("up5", "MV", "mv.type5");
            List<string> emptyList = new List<string>();
            List<string> up4Values = new List<string>();
            List<string> up5Values = new List<string>();
            string expectedBody =
                "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<a:propertyupdate " +
                "xmlns:a=\"DAV:\" " +
                "xmlns:b=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\" " +
                "xmlns:c=\"xml:\" " +
                "xmlns:d=\"NS1\" " +
                "xmlns:e=\"FB\" " +
                "xmlns:f=\"MV\">" +
                "<a:set>" +
                "<a:prop>" +
                "<a:up1>" +
                "1" +
                "</a:up1>" +
                "<d:up2>" +
                "2" +
                "</d:up2>" +
                "<e:up3 b:dt=\"type1\">" +
                "3" +
                "</e:up3>" +
                "<f:up4 b:dt=\"mv.type2\">" +
                "<c:v>" +
                "one" +
                "</c:v>" +
                "</f:up4>" +
                "<f:up5 b:dt=\"mv.type5\">" +
                "<c:v>" +
                "0x1234" +
                "</c:v>" +
                "<c:v>" +
                "0xabcd" +
                "</c:v>" +
                "</f:up5>" +
                "</a:prop>" +
                "</a:set>" +
                "</a:propertyupdate>";

            up4Values.Add("one");

            up5Values.Add("0x1234");
            up5Values.Add("0xabcd");

            VerifyWellFormedXml(expectedBody);

            for (int i = 0; i < 2; i++)
            {
                bool exceptionCaught = false;
                try
                {
                    body = queryBuilder.BuildQueryBody();
                }
                catch (Exception)
                {
                    exceptionCaught = true;
                }
                Assert.IsTrue(exceptionCaught);

                queryBuilder.AddUpdateProperty("up1", "DAV:", "1");
                queryBuilder.AddUpdateProperty(up2, "2");
                queryBuilder.AddUpdateProperty(up3, "3");

                try
                {
                    queryBuilder.AddUpdateProperty(up4, emptyList);
                }
                catch (Exception)
                {
                    exceptionCaught = true;
                }
                Assert.IsTrue(exceptionCaught);

                queryBuilder.AddUpdateProperty(up4, up4Values);
                queryBuilder.AddUpdateProperty(up5, up5Values);

                body = queryBuilder.BuildQueryBody();
                VerifyWellFormedXml(body);
                Assert.IsTrue(CompareXml(body, expectedBody));
                queryBuilder.Reset();
            }
        }
        private static bool CheckSingleValueProperty(
            FreeBusyProperty property)
        {
            string propertyName = property.Name;
            string propertyNamespace = property.NameSpace;
            string propertyType = property.Type;

            if (propertyType.Substring(0, 3) == "mv.")
            {
                // The property is supposed to be sinlge-valued, thus the type must not start with "mv."
                return false;
            }

            if (propertyNamespace != "http://schemas.microsoft.com/mapi/proptag/")
            {
                return true;
            }

            if (propertyName[0] != 'x' && propertyName[0] != 'X')
            {
                return true;
            }

            int propTag = 0;

            try
            {
                propTag = Convert.ToInt32("0" + propertyName, 16);
            }
            catch (FormatException)
            {
                return false;
            }
            catch (OverflowException)
            {
                return false;
            }

            if ((propTag & 0x1000) != 0)
            {
                return false;
            }

            switch (propTag & 0xfff)
            {
                case 3:
                    return propertyType == "int";

                case 0xb:
                    return propertyType == "boolean";

                case 0x40:
                    return propertyType == "dateTime.tz";

                case 0x102:
                    return propertyType == "bin.base64";

                default:
                    return false;
            }
        }
        public void TestUpdateAndRemove()
        {
            string body = null;
            WebDavQueryBuilder queryBuilder = new WebDavQueryBuilder();
            Property up2 = new Property("up2", "NS1");
            FreeBusyProperty up3 = new FreeBusyProperty("up3", "FB", "type1");
            Property del2 = new Property("del2", "NS2");
            FreeBusyProperty del3 = new FreeBusyProperty("del3", "FB", "type2");
            string expectedBody =
                "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<a:propertyupdate " +
                "xmlns:a=\"DAV:\" " +
                "xmlns:b=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\" " +
                "xmlns:c=\"xml:\" " +
                "xmlns:d=\"NS1\" " +
                "xmlns:e=\"FB\" " +
                "xmlns:f=\"NS2\">" +
                "<a:set>" +
                "<a:prop>" +
                "<a:up1>" +
                "1" +
                "</a:up1>" +
                "<d:up2>" +
                "2" +
                "</d:up2>" +
                "<e:up3 b:dt=\"type1\">" +
                "3" +
                "</e:up3>" +
                "</a:prop>" +
                "</a:set>" +
                "<a:remove>" +
                "<a:prop>" +
                "<d:del1/>" +
                "<f:del2/>" +
                "<e:del3/>" +
                "</a:prop>" +
                "</a:remove>" +
                "</a:propertyupdate>";

            VerifyWellFormedXml(expectedBody);

            for (int i = 0; i < 2; i++)
            {
                bool exceptionCaught = false;
                try
                {
                    body = queryBuilder.BuildQueryBody();
                }
                catch (Exception)
                {
                    exceptionCaught = true;
                }
                Assert.IsTrue(exceptionCaught);

                queryBuilder.AddUpdateProperty("up1", "DAV:", "1");
                queryBuilder.AddUpdateProperty(up2, "2");
                queryBuilder.AddUpdateProperty(up3, "3");

                queryBuilder.AddRemoveProperty("del1", "NS1");
                queryBuilder.AddRemoveProperty(del2);
                queryBuilder.AddRemoveProperty(del3);

                body = queryBuilder.BuildQueryBody();
                VerifyWellFormedXml(body);
                Assert.IsTrue(CompareXml(body, expectedBody));
                queryBuilder.Reset();
            }
        }
Exemplo n.º 9
0
        public void TestUpdate()
        {
            string             body         = null;
            WebDavQueryBuilder queryBuilder = new WebDavQueryBuilder();
            Property           up2          = new Property("up2", "NS1");
            FreeBusyProperty   up3          = new FreeBusyProperty("up3", "FB", "type1");
            FreeBusyProperty   up4          = new FreeBusyProperty("up4", "MV", "mv.type2");
            FreeBusyProperty   up5          = new FreeBusyProperty("up5", "MV", "mv.type5");
            List <string>      emptyList    = new List <string>();
            List <string>      up4Values    = new List <string>();
            List <string>      up5Values    = new List <string>();
            string             expectedBody =
                "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<a:propertyupdate " +
                "xmlns:a=\"DAV:\" " +
                "xmlns:b=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\" " +
                "xmlns:c=\"xml:\" " +
                "xmlns:d=\"NS1\" " +
                "xmlns:e=\"FB\" " +
                "xmlns:f=\"MV\">" +
                "<a:set>" +
                "<a:prop>" +
                "<a:up1>" +
                "1" +
                "</a:up1>" +
                "<d:up2>" +
                "2" +
                "</d:up2>" +
                "<e:up3 b:dt=\"type1\">" +
                "3" +
                "</e:up3>" +
                "<f:up4 b:dt=\"mv.type2\">" +
                "<c:v>" +
                "one" +
                "</c:v>" +
                "</f:up4>" +
                "<f:up5 b:dt=\"mv.type5\">" +
                "<c:v>" +
                "0x1234" +
                "</c:v>" +
                "<c:v>" +
                "0xabcd" +
                "</c:v>" +
                "</f:up5>" +
                "</a:prop>" +
                "</a:set>" +
                "</a:propertyupdate>";

            up4Values.Add("one");

            up5Values.Add("0x1234");
            up5Values.Add("0xabcd");

            VerifyWellFormedXml(expectedBody);

            for (int i = 0; i < 2; i++)
            {
                bool exceptionCaught = false;
                try
                {
                    body = queryBuilder.BuildQueryBody();
                }
                catch (Exception)
                {
                    exceptionCaught = true;
                }
                Assert.IsTrue(exceptionCaught);

                queryBuilder.AddUpdateProperty("up1", "DAV:", "1");
                queryBuilder.AddUpdateProperty(up2, "2");
                queryBuilder.AddUpdateProperty(up3, "3");

                try
                {
                    queryBuilder.AddUpdateProperty(up4, emptyList);
                }
                catch (Exception)
                {
                    exceptionCaught = true;
                }
                Assert.IsTrue(exceptionCaught);

                queryBuilder.AddUpdateProperty(up4, up4Values);
                queryBuilder.AddUpdateProperty(up5, up5Values);

                body = queryBuilder.BuildQueryBody();
                VerifyWellFormedXml(body);
                Assert.IsTrue(CompareXml(body, expectedBody));
                queryBuilder.Reset();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Modify a multi-valued free busy property from a WebDAV resource
        /// </summary>
        /// <param name="destination">The URL of the resource</param>
        /// <param name="property">Property to modify</param>
        /// <param name="propertyValues">The new Property values</param>
        /// <returns>void</returns>
        public void UpdateFreeBusyProperty(
            string destination,
            FreeBusyProperty property,
            List<string> propertyValues )
        {
            string body = BuildFreeBusyMultiValuedPropertyQuery( property.Name, property.NameSpace, property.Type, propertyValues );

            IssueRequestIgnoreResponse(destination, Method.PROPPATCH, body);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Add a multivalued free busy property to the query to be updated to the given values.
 /// </summary>
 /// <param name="property">Property to add</param>
 /// <param name="propertyValues">The list of value for the property</param>
 public void AddUpdateProperty(
     FreeBusyProperty property,
     List<string> propertyValues)
 {
     AddUpdateProperty(property.Name,
                       property.NameSpace,
                       property.Type,
                       propertyValues);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Add a free busy property to the query to be updated to the given value.
 /// </summary>
 /// <param name="property">Property to add</param>
 /// <param name="propertyValue">The value for the property</param>
 public void AddUpdateProperty(
     FreeBusyProperty property,
     string propertyValue)
 {
     AddUpdateProperty(property.Name,
                       property.NameSpace,
                       property.Type,
                       propertyValue);
 }