Exemple #1
0
        private void ListGetListInXml(bool inJSON)
        {
            // link to web service documentation
            // http://msdn.microsoft.com/en-us/library/lists.lists.getlist%28v=office.12%29.aspx

            XmlNode data     = null;
            var     listName = _dataManager.GetPropVal("ListName");

            using (var listSvc = new WorkEngineSolutionStoreListSvc.Lists())
            {
                // TODO: write a function to get user name and password
                listSvc.Credentials = new NetworkCredential("Solution1", @"J@(Djkhldk2", "EPM");
                listSvc.Url         = CoreFunctions.getFarmSetting("WorkEngineStore") + "_vti_bin/Lists.asmx";

                try
                {
                    ServicePointManager.ServerCertificateValidationCallback =
                        ((sender, certificate, chain, sslPolicyErrors) => true);

                    data = listSvc.GetList(listName);
                }
                catch (Exception ex)
                {
                    WriteLine(ex);
                    Response.Write($"{{ error : \"{ex.Message}\" }}");
                    return;
                }
            }

            Response.Write(!inJSON
                ? HttpUtility.HtmlEncode(data.OuterXml)
                : HttpUtility.HtmlEncode(JSONUtil.ConvertXmlToJson(XmlDataSimplifier.SimplifySPGetListXml(data), string.Empty)));
        }
Exemple #2
0
        private bool TryGetListItemsInXml(out XmlNode data)
        {
            // link to web service documentation
            // http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems%28v=office.12%29.aspx

            data = null;
            var listName = _dataManager.GetPropVal("ListName");
            var viewName = _dataManager.GetPropVal("ViewName");

            var xmlDoc = new XmlDocument();

            // create query param
            const string queryNodeName = "Query";
            var          nodeQuery     = xmlDoc.CreateNode(XmlNodeType.Element, queryNodeName, string.Empty);

            nodeQuery.InnerXml = _dataManager.GetPropVal(queryNodeName);

            // create view fields param
            const string viewFieldsName = "ViewFields";
            var          nodeViewFields = xmlDoc.CreateNode(XmlNodeType.Element, viewFieldsName, string.Empty);

            nodeViewFields.InnerXml = _dataManager.GetPropVal(viewFieldsName);

            var rowLimit = _dataManager.GetPropVal("RowLimit");

            // create query options param
            const string queryOptionsName = "QueryOptions";
            var          nodeQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, queryOptionsName, string.Empty);
            var          queryOptions     = _dataManager.GetPropVal(queryOptionsName);

            queryOptions = !string.IsNullOrWhiteSpace(queryOptions) ? queryOptions.Replace(@"\\", @"\") : string.Empty;
            nodeQueryOptions.InnerXml = !string.IsNullOrWhiteSpace(queryOptions)
                ? queryOptions
                : "<Folder>Solutions/" + CoreFunctions.GetAssemblyVersion() + "</Folder>";
            var webId = _dataManager.GetPropVal("WebID");

            using (var listSvc = new WorkEngineSolutionStoreListSvc.Lists())
            {
                // TODO: write a function to get user name and password
                listSvc.Credentials = new NetworkCredential("Solution1", @"J@(Djkhldk2", "EPM");
                listSvc.Url         = CoreFunctions.getFarmSetting("WorkEngineStore") + "_vti_bin/Lists.asmx";
                try
                {
                    ServicePointManager.ServerCertificateValidationCallback =
                        ((sender, certificate, chain, sslPolicyErrors) => true);

                    data = listSvc.GetListItems(listName, null, nodeQuery, null, rowLimit, nodeQueryOptions, null);
                }
                catch (Exception ex)
                {
                    WriteLine(ex);
                    Response.Write($"{{ error : \"{ex.Message}\" }}");
                    return(false);
                }
            }

            return(true);
        }
        private void PullMoreInfoFromOnline()
        {
            System.Xml.XmlNode data = null;

            XmlDocument xDoc = new XmlDocument();

            // create query param
            XmlNode ndQuery = xDoc.CreateNode(XmlNodeType.Element, "Query", "");

            if (_solutionType.Equals("sitecollection", StringComparison.CurrentCultureIgnoreCase))
            {
                ndQuery.InnerXml = "<Where><Eq><FieldRef Name=\"SolutionType\" /><Value Type=\"Choice\">SiteCollection</Value></Eq></Where><OrderBy><FieldRef Name=\"Title\" Ascending=\"True\" /></OrderBy>";
            }
            else
            {
                if (_templateType.ToLower() == "template")
                {
                    _templateType = "project";
                }
                //ndQuery.InnerXml = "<Where><And><Eq><FieldRef Name=\"Visible\" /><Value Type=\"Boolean\">1</Value></Eq><Eq><FieldRef Name=\"SolutionType\" /><Value Type=\"Choice\">" + _solutionType + "</Value></Eq></And></Where><OrderBy><FieldRef Name=\"Title\" Ascending=\"True\" /></OrderBy>";
                ndQuery.InnerXml = "<Where><And><Eq><FieldRef Name=\"Visible\" /><Value Type=\"Boolean\">1</Value></Eq><And><Eq><FieldRef Name=\"SolutionType\" /><Value Type=\"Choice\">" + _solutionType + "</Value></Eq><Eq><FieldRef Name=\"TemplateType\" /><Value Type=\"MultiChoice\">" + _templateType + "</Value></Eq></And></And></Where><OrderBy><FieldRef Name=\"Title\" Ascending=\"True\" /></OrderBy>";
            }

            // create query options param
            XmlNode ndQueryOptions = xDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");

            //ndQueryOptions.InnerXml = "<queryOptions xmlns:SOAPSDK9=\"http://schemas.microsoft.com/sharepoint/soap/\" ><QueryOptions/></queryOptions>";
            ndQueryOptions.InnerXml = "<Folder>Solutions/" + CoreFunctions.GetAssemblyVersion() + "</Folder>";
            using (var listSvc = new WorkEngineSolutionStoreListSvc.Lists())
            {
                // TODO: write a function to get user name and password
                listSvc.Credentials = new NetworkCredential("Solution1", @"J@(Djkhldk2", "EPM");
                //listSvc.Url = EPMLiveCore.CoreFunctions.getFarmSetting("WorkEngineStore") + "/_vti_bin/Lists.asmx";
                listSvc.Url = EPMLiveCore.CoreFunctions.getFarmSetting("WorkEngineStore") + "_vti_bin/Lists.asmx";
                data        = listSvc.GetListItems("Solutions", null, ndQuery, null, "10000", ndQueryOptions, null);
            }

            XmlDocument dataXml = new XmlDocument();

            dataXml.LoadXml(data.OuterXml);

            foreach (XmlNode nd in data.FirstChild.NextSibling.ChildNodes)
            {
                if (nd.NodeType.Equals(XmlNodeType.Element) &&
                    nd.Attributes["ows_ID"] != null &&
                    Convert.ToInt32(nd.Attributes["ows_ID"].Value) == _tempId &&
                    nd.Attributes["ows_MetaInfo"] != null &&
                    !string.IsNullOrEmpty(nd.Attributes["ows_MetaInfo"].Value))
                {
                    string[] metaInfos = nd.Attributes["ows_MetaInfo"].Value.Split('\n');
                    foreach (string info in metaInfos)
                    {
                        string header = info.Split('|')[0];
                        if (header == "MoreInfo:SW")
                        {
                            pnlContent.Controls.Add(new LiteralControl(HttpUtility.HtmlDecode(info.Split('|')[1]
                                                                                              .Replace("\r", "")
                                                                                              .Replace("\n", "")
                                                                                              //.Replace("\"", "\\\"")
                                                                                              .Replace("\r\n", "")
                                                                                              .Replace("\\r\\n", "")
                                                                                              .Replace(@"/MoreInfoImages/", @"https://store.workengine.com/MoreInfoImages/")
                                                                                              )));
                            break;
                        }
                    }
                    break;
                }
            }

            //IEnumerable<XElement> temps = dataXml.Root.Descendants("
        }