示例#1
0
        private IEnumerable <WebDavResource> Convert(IEnumerable <SystemFile> files, Uri baseUri)
        {
            var convertResult = new List <WebDavResource>();

            var credentials = new NetworkCredential(ScpContext.User.Login,
                                                    _cryptography.Decrypt(ScpContext.User.EncryptedPassword),
                                                    WebDavAppConfigManager.Instance.UserDomain);

            foreach (var file in files)
            {
                var webDavitem = new WebDavResource();

                webDavitem.SetCredentials(credentials);

                webDavitem.SetHref(baseUri.Append(ScpContext.User.OrganizationId).Append(file.RelativeUrl.Replace("\\", "/")));

                webDavitem.SetItemType(file.IsDirectory? ItemType.Folder : ItemType.Resource);
                webDavitem.SetLastModified(file.Changed);
                webDavitem.ContentLength  = file.Size;
                webDavitem.AllocatedSpace = file.FRSMQuotaMB;
                webDavitem.Summary        = file.Summary;

                convertResult.Add(webDavitem);
            }

            return(convertResult);
        }
示例#2
0
            /// <summary>
            ///     Processes the response from the server.
            /// </summary>
            /// <param name="response">The raw response from the server.</param>
            private void ProcessResponse(string response)
            {
                try
                {
                    var XmlDoc = new XmlDocument();
                    XmlDoc.LoadXml(response);
                    XmlNodeList XmlResponseList = XmlDoc.GetElementsByTagName("D:response");
                    if (XmlResponseList.Count == 0)
                    {
                        XmlResponseList = XmlDoc.GetElementsByTagName("d:response");
                    }
                    var children = new WebDavResource[XmlResponseList.Count];
                    int counter = 0;
                    foreach (XmlNode XmlCurrentResponse in XmlResponseList)
                    {
                        var item = new WebDavResource();
                        item.SetCredentials(_credentials);

                        foreach (XmlNode XmlCurrentNode in XmlCurrentResponse.ChildNodes)
                        {
                            switch (XmlCurrentNode.LocalName)
                            {
                                case "href":
                                    string href = XmlCurrentNode.InnerText;
                                    if (!Regex.Match(href, "^https?:\\/\\/").Success)
                                    {
                                        href = _path.Scheme + "://" + _path.Host + href;
                                    }
                                    item.SetHref(href, _path);
                                    break;

                                case "propstat":
                                    foreach (XmlNode XmlCurrentPropStatNode in XmlCurrentNode)
                                    {
                                        switch (XmlCurrentPropStatNode.LocalName)
                                        {
                                            case "prop":
                                                foreach (XmlNode XmlCurrentPropNode in XmlCurrentPropStatNode)
                                                {
                                                    switch (XmlCurrentPropNode.LocalName)
                                                    {
                                                        case "creationdate":
                                                            item.SetCreationDate(XmlCurrentPropNode.InnerText);
                                                            break;

                                                        case "getcontentlanguage":
                                                            item.SetProperty(
                                                                new Property(
                                                                    new PropertyName("getcontentlanguage",
                                                                        XmlCurrentPropNode.NamespaceURI),
                                                                    XmlCurrentPropNode.InnerText));
                                                            break;

                                                        case "getcontentlength":
                                                            item.SetProperty(
                                                                new Property(
                                                                    new PropertyName("getcontentlength",
                                                                        XmlCurrentPropNode.NamespaceURI),
                                                                    XmlCurrentPropNode.InnerText));
                                                            break;
                                                        case "getcontenttype":
                                                            item.SetProperty(
                                                                new Property(
                                                                    new PropertyName("getcontenttype",
                                                                        XmlCurrentPropNode.NamespaceURI),
                                                                    XmlCurrentPropNode.InnerText));
                                                            break;

                                                        case "getlastmodified":
                                                            item.SetLastModified(XmlCurrentPropNode.InnerText);
                                                            break;

                                                        case "resourcetype":
                                                            item.SetProperty(
                                                                new Property(
                                                                    new PropertyName("resourcetype",
                                                                        XmlCurrentPropNode.NamespaceURI),
                                                                    XmlCurrentPropNode.InnerXml));
                                                            break;
                                                        //case "lockdiscovery":
                                                        //{
                                                        //    if (XmlCurrentPropNode.HasChildNodes == false)
                                                        //    {
                                                        //        break;
                                                        //    }

                                                        //    foreach (XmlNode activeLockNode in XmlCurrentPropNode.FirstChild)
                                                        //    {
                                                        //        switch (activeLockNode.LocalName)
                                                        //        {
                                                        //            case "owner":
                                                        //                item.SetProperty(
                                                        //                    new Property(
                                                        //                        new PropertyName("owner",
                                                        //                            activeLockNode.NamespaceURI),
                                                        //                        activeLockNode.InnerXml));
                                                        //                break;
                                                        //            case "locktoken":
                                                        //                var lockTokenNode = activeLockNode.FirstChild;
                                                        //                item.SetProperty(
                                                        //                    new Property(
                                                        //                        new PropertyName("locktoken",
                                                        //                            lockTokenNode.NamespaceURI),
                                                        //                        lockTokenNode.InnerXml));
                                                        //                break;
                                                        //        }
                                                        //    }
                                                        //    break;
                                                        //}
                                                    }
                                                }
                                                break;

                                            case "status":
                                                break;
                                        }
                                    }
                                    break;
                            }
                        }

                        if (item.DisplayName != String.Empty)
                        {
                            children[counter] = item;
                            counter++;
                        }
                        else
                        {
                            SetItemType(ItemType.Folder);
                            SetHref(item.Href.AbsoluteUri, item.Href);
                            SetCreationDate(item.CreationDate);
                            SetComment(item.Comment);
                            SetCreatorDisplayName(item.CreatorDisplayName);
                            SetLastModified(item.LastModified);

                            foreach (Property property in item.Properties)
                            {
                                SetProperty(property);
                            }
                        }
                    }

                    int childrenCount = 0;
                    foreach (IHierarchyItem item in children)
                    {
                        if (item != null)
                        {
                            childrenCount++;
                        }
                    }
                    _children = new IHierarchyItem[childrenCount];

                    counter = 0;
                    foreach (IHierarchyItem item in children)
                    {
                        if (item != null)
                        {
                            _children[counter] = item;
                            counter++;
                        }
                    }
                }
                catch (XmlException e)
                {
                }
            }
示例#3
0
        private IEnumerable<WebDavResource> Convert(IEnumerable<SystemFile> files, Uri baseUri)
        {
            var convertResult = new List<WebDavResource>();

            var credentials = new NetworkCredential(WspContext.User.Login,
                _cryptography.Decrypt(WspContext.User.EncryptedPassword),
                WebDavAppConfigManager.Instance.UserDomain);

            foreach (var file in files)
            {
                 var webDavitem = new WebDavResource();

                webDavitem.SetCredentials(credentials);

                webDavitem.SetHref(baseUri.Append(WspContext.User.OrganizationId).Append(file.RelativeUrl.Replace("\\","/")));

                webDavitem.SetItemType(file.IsDirectory? ItemType.Folder : ItemType.Resource);
                webDavitem.SetLastModified(file.Changed);
                webDavitem.ContentLength = file.Size;
                webDavitem.AllocatedSpace = file.FRSMQuotaMB;
                webDavitem.Summary = file.Summary;

                convertResult.Add(webDavitem);
            }

            return convertResult;
        }
示例#4
0
            /// <summary>
            ///     Processes the response from the server.
            /// </summary>
            /// <param name="response">The raw response from the server.</param>
            private void ProcessResponse(string response)
            {
                try
                {
                    var XmlDoc = new XmlDocument();
                    XmlDoc.LoadXml(response);
                    XmlNodeList XmlResponseList = XmlDoc.GetElementsByTagName("D:response");
                    if (XmlResponseList.Count == 0)
                    {
                        XmlResponseList = XmlDoc.GetElementsByTagName("d:response");
                    }
                    var children = new WebDavResource[XmlResponseList.Count];
                    int counter  = 0;
                    foreach (XmlNode XmlCurrentResponse in XmlResponseList)
                    {
                        var item = new WebDavResource();
                        item.SetCredentials(_credentials);

                        foreach (XmlNode XmlCurrentNode in XmlCurrentResponse.ChildNodes)
                        {
                            switch (XmlCurrentNode.LocalName)
                            {
                            case "href":
                                string href = XmlCurrentNode.InnerText;
                                if (!Regex.Match(href, "^https?:\\/\\/").Success)
                                {
                                    href = _path.Scheme + "://" + _path.Host + href;
                                }
                                item.SetHref(href, _path);
                                break;

                            case "propstat":
                                foreach (XmlNode XmlCurrentPropStatNode in XmlCurrentNode)
                                {
                                    switch (XmlCurrentPropStatNode.LocalName)
                                    {
                                    case "prop":
                                        foreach (XmlNode XmlCurrentPropNode in XmlCurrentPropStatNode)
                                        {
                                            switch (XmlCurrentPropNode.LocalName)
                                            {
                                            case "creationdate":
                                                item.SetCreationDate(XmlCurrentPropNode.InnerText);
                                                break;

                                            case "getcontentlanguage":
                                                item.SetProperty(
                                                    new Property(
                                                        new PropertyName("getcontentlanguage",
                                                                         XmlCurrentPropNode.NamespaceURI),
                                                        XmlCurrentPropNode.InnerText));
                                                break;

                                            case "getcontentlength":
                                                item.SetProperty(
                                                    new Property(
                                                        new PropertyName("getcontentlength",
                                                                         XmlCurrentPropNode.NamespaceURI),
                                                        XmlCurrentPropNode.InnerText));
                                                break;

                                            case "getcontenttype":
                                                item.SetProperty(
                                                    new Property(
                                                        new PropertyName("getcontenttype",
                                                                         XmlCurrentPropNode.NamespaceURI),
                                                        XmlCurrentPropNode.InnerText));
                                                break;

                                            case "getlastmodified":
                                                item.SetLastModified(XmlCurrentPropNode.InnerText);
                                                break;

                                            case "resourcetype":
                                                item.SetProperty(
                                                    new Property(
                                                        new PropertyName("resourcetype",
                                                                         XmlCurrentPropNode.NamespaceURI),
                                                        XmlCurrentPropNode.InnerXml));
                                                break;
                                                //case "lockdiscovery":
                                                //{
                                                //    if (XmlCurrentPropNode.HasChildNodes == false)
                                                //    {
                                                //        break;
                                                //    }

                                                //    foreach (XmlNode activeLockNode in XmlCurrentPropNode.FirstChild)
                                                //    {
                                                //        switch (activeLockNode.LocalName)
                                                //        {
                                                //            case "owner":
                                                //                item.SetProperty(
                                                //                    new Property(
                                                //                        new PropertyName("owner",
                                                //                            activeLockNode.NamespaceURI),
                                                //                        activeLockNode.InnerXml));
                                                //                break;
                                                //            case "locktoken":
                                                //                var lockTokenNode = activeLockNode.FirstChild;
                                                //                item.SetProperty(
                                                //                    new Property(
                                                //                        new PropertyName("locktoken",
                                                //                            lockTokenNode.NamespaceURI),
                                                //                        lockTokenNode.InnerXml));
                                                //                break;
                                                //        }
                                                //    }
                                                //    break;
                                                //}
                                            }
                                        }
                                        break;

                                    case "status":
                                        break;
                                    }
                                }
                                break;
                            }
                        }

                        if (item.DisplayName != String.Empty)
                        {
                            children[counter] = item;
                            counter++;
                        }
                        else
                        {
                            SetItemType(ItemType.Folder);
                            SetHref(item.Href.AbsoluteUri, item.Href);
                            SetCreationDate(item.CreationDate);
                            SetComment(item.Comment);
                            SetCreatorDisplayName(item.CreatorDisplayName);
                            SetLastModified(item.LastModified);

                            foreach (Property property in item.Properties)
                            {
                                SetProperty(property);
                            }
                        }
                    }

                    int childrenCount = 0;
                    foreach (IHierarchyItem item in children)
                    {
                        if (item != null)
                        {
                            childrenCount++;
                        }
                    }
                    _children = new IHierarchyItem[childrenCount];

                    counter = 0;
                    foreach (IHierarchyItem item in children)
                    {
                        if (item != null)
                        {
                            _children[counter] = item;
                            counter++;
                        }
                    }
                }
                catch (XmlException e)
                {
                }
            }