Esempio n. 1
0
        private void SetupMockIAP()
        {
            MockIAP.Init();

            MockIAP.RunInMockMode(true);
            MockIAP.SetListingInformation(1, "en-us", "2D Platformer", "$0.00", "2D Platformer");

            var mockupLicenseInfo = App.GetResourceStream(new Uri("Assets\\Xmls\\MockupLicenseInfo.xml", UriKind.Relative));

            System.Xml.Linq.XDocument doc = System.Xml.Linq.XDocument.Load(mockupLicenseInfo.Stream);
            string xml = doc.ToString();

            MockIAP.PopulateIAPItemsFromXml(xml);

            GetListingInfo();

            // Add some more items manually.
            //ProductListing p = new ProductListing
            //{
            //    Name = "img.2",
            //    ImageUri = new Uri("/Res/Image/2.jpg", UriKind.Relative),
            //    ProductId = "img.2",
            //    ProductType = Windows.ApplicationModel.Store.ProductType.Durable,
            //    Keywords = new string[] { "image" },
            //    Description = "An image",
            //    FormattedPrice = "1.0",
            //    Tag = string.Empty
            //};
            //MockIAP.AddProductListing("img.2", p);
        }
Esempio n. 2
0
        /// <summary>
        /// Make an actual web call to load products.
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public AffiliateProductDto CallProductSearch(string url)
        {
            if (string.IsNullOrEmpty(url) || string.IsNullOrWhiteSpace(url))
            {
                throw new Exception("AmazonProductService CallProductSearch function is called with empty url.");
            }

            using (var client = new HttpClient(new HttpClientHandler {
                AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
            }))
            {
                var task = client.GetAsync(new Uri(url));
                task.Wait();
                HttpResponseMessage response = task.Result;
                // response.EnsureSuccessStatusCode();
                var readTask = response.Content.ReadAsStringAsync();
                readTask.Wait();
                string result = readTask.Result;
                // try loading result into xml
                var reader = new StringReader(result);
                var xmlDoc = new XmlDocument();
                xmlDoc.Load(reader);
                System.Xml.Linq.XDocument doc = System.Xml.Linq.XDocument.Parse(result);
                System.Diagnostics.Debug.WriteLine(doc.ToString());
                return(ReadXml(xmlDoc));
            }
        }
        private void cmbCR_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (TibcoGPEntities model = new TibcoGPEntities())
            {
                model.Database.CommandTimeout = 200;

                var xml = model.Compte_rendu.Where(x => x.cr_id == ((V_Compte_Rendu)cmbCR.SelectedValue).cr_id).Select(x => x.cr_rapport).FirstOrDefault();
                if (!string.IsNullOrEmpty(xml))
                {
                    System.Xml.Linq.XDocument xDocument = System.Xml.Linq.XDocument.Parse(xml);
                    txtXML.Text = xDocument.ToString();

                    System.Xml.Linq.XDocument xXslt = System.Xml.Linq.XDocument.Parse(Properties.Resources.Defaultss);

                    System.Xml.Xsl.XslCompiledTransform xTrans = new System.Xml.Xsl.XslCompiledTransform();
                    xTrans.Load(xXslt.CreateReader());
                    ms = new System.IO.MemoryStream();
                    xTrans.Transform(xDocument.CreateReader(), null, ms);
                    ms.Position = 0;
                    webBrowserXML.DocumentStream = ms;
                }
                else
                {
                    txtXML.Clear();
                    txtXML.Text = "VIDE";
                    webBrowserXML.DocumentText = string.Empty;
                }
            }
        }
Esempio n. 4
0
        public XmlViewForm(System.Xml.Linq.XDocument xDoc)
        {
            InitializeComponent();

            xmlEditor.Text = xDoc.ToString();
            xmlEditor.AllowXmlFormatting = true;
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            //링크 주소 만들기 - love를 검색하고 검색 된 20개의 아이템을 xml로 받고 1페이지를 싶을때
            String requestUrl = "http://apis.daum.net/search/blog";

            requestUrl += "?apikey=" + "DAUM_SEARCH_DEMO_APIKEY"; //발급된 키
            requestUrl += "&q=" + "love";                         //검색어
            requestUrl += "&result=" + "20";                      //출력될 결과수w
            requestUrl += "&pageno=" + "1";                       //페이지 번호
            requestUrl += "&output=" + "xml";

            //최종 url = http://apis.daum.net/search/blog?apikey=DAUM_SEARCH_DEMO_APIKEY&q=love&&result=20&&pageno=1&output=xml

            //웹요청 객체를 만든다.
            System.Net.WebRequest wr = System.Net.WebRequest.Create(requestUrl);

            //웹요청을 실행하고 그에 대한 응답객체를 만든다.
            System.Net.WebResponse wrp = wr.GetResponse();

            //응답은 XML이므로 XML문서로 구조화한다.
            System.Xml.Linq.XDocument xd = System.Xml.Linq.XDocument.Load(wrp.GetResponseStream());

            //응답을 보여준다.
            System.Console.WriteLine(xd.ToString());
        }
Esempio n. 6
0
        /// <summary>
        /// Return a checklist raw string based on the SCAP XML file results of an existing checklist file.
        /// </summary>
        /// <param name="results">The results list of pass and fail information rules from the SCAP scan</param>
        /// <param name="checklistString">The raw XML of the checklist</param>
        /// <param name="newChecklist">True/False on a new checklist (template). If true, add pass and fail items.</param>
        /// <returns>A checklist raw XML string, if found</returns>
        public static string UpdateChecklistData(SCAPRuleResultSet results, string checklistString, bool newChecklist)
        {
            // process the raw checklist into the CHECKLIST structure
            CHECKLIST      chk = ChecklistLoader.LoadChecklist(checklistString);
            STIG_DATA      data;
            SCAPRuleResult result;

            if (chk != null)
            {
                // if we read in the hostname, then use it in the Checklist data
                if (!string.IsNullOrEmpty(results.hostname))
                {
                    chk.ASSET.HOST_NAME = results.hostname;
                }
                // if we have the IP Address, use that as well
                if (!string.IsNullOrEmpty(results.ipaddress))
                {
                    chk.ASSET.HOST_IP = results.ipaddress;
                }
                // for each VULN see if there is a rule matching the rule in the
                foreach (VULN v in chk.STIGS.iSTIG.VULN)
                {
                    data = v.STIG_DATA.Where(y => y.VULN_ATTRIBUTE == "Rule_ID").FirstOrDefault();
                    if (data != null)
                    {
                        // find if there is a matching rule
                        result = results.ruleResults.Where(z => z.ruleId.ToLower() == data.ATTRIBUTE_DATA.ToLower()).FirstOrDefault();
                        if (result != null)
                        {
                            // set the status
                            // only mark fails IF this is a new one, otherwise leave alone
                            if (result.result.ToLower() == "fail")
                            {
                                v.STATUS = "Open";
                            }
                            // mark the pass on any checklist item we find that passed
                            else if (result.result.ToLower() == "pass")
                            {
                                v.STATUS = "NotAFinding";
                            }
                        }
                    }
                }
            }
            // serialize into a string again
            System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(chk.GetType());
            using (StringWriter textWriter = new StringWriter())
            {
                xmlSerializer.Serialize(textWriter, chk);
                checklistString = textWriter.ToString();
            }
            // strip out all the extra formatting crap and clean up the XML to be as simple as possible
            System.Xml.Linq.XDocument xDoc = System.Xml.Linq.XDocument.Parse(checklistString, System.Xml.Linq.LoadOptions.None);
            checklistString = xDoc.ToString(System.Xml.Linq.SaveOptions.DisableFormatting);
            return(checklistString);
        }
Esempio n. 7
0
 public static string toXML(string inputStr)
 {
     System.Xml.Linq.XDocument xml = null; //JsonConvert.DeserializeXNode("{\"Data\":" + inputStr + "}", "root");
     if (!string.IsNullOrEmpty(inputStr))
     {
         xml = JsonConvert.DeserializeXNode("{\"Data\":" + inputStr + "}", "root");
         return(xml.ToString());
     }
     return(string.Empty);
 }
Esempio n. 8
0
 public static string Prettify(string xml)
 {
     try
     {
         System.Xml.Linq.XDocument better = System.Xml.Linq.XDocument.Parse(xml);
         return(better.ToString());
     }
     catch
     {
         return(xml);
     }
 }
Esempio n. 9
0
        public override string ToString()
        {
            string value  = $"{Value}";
            var    result = new System.Xml.Linq.XDocument(new System.Xml.Linq.XElement("tree", new System.Xml.Linq.XAttribute("value", value)));

            this.Aggregate(result, (whole, next) =>
            {
                var subtree = new System.Xml.Linq.XElement("tree", new System.Xml.Linq.XAttribute("key", next.Key));
                subtree.Add(System.Xml.Linq.XElement.Parse(next.Value.ToString()));
                whole.Root.Add(subtree);
                return(whole);
            });
            return(result.ToString());
        }
Esempio n. 10
0
        private void UpdatePrimaryTile()
        {
            System.Xml.Linq.XDocument xdoc = System.Xml.Linq.XDocument.Load("tiles.xml");

            var updator = TileUpdateManager.CreateTileUpdaterForApplication();

            updator.EnableNotificationQueueForSquare150x150(true);
            updator.EnableNotificationQueueForSquare310x310(true);
            updator.EnableNotificationQueueForWide310x150(true);
            updator.EnableNotificationQueue(true);
            updator.Clear();
            var n     = helpItemViewModel.HelpItemSize();
            var index = 0;

            if (n >= 5)
            {
                index = n - 5;
            }
            else
            {
                index = 0;
            }
            for (var i = n - 1; i >= index; i--)
            {
                XmlDocument tilexml = new XmlDocument();
                tilexml.LoadXml(xdoc.ToString());
                XmlNodeList titles = tilexml.GetElementsByTagName("text");
                titles[0].InnerText = helpItemViewModel.AllItems[i].type;
                titles[1].InnerText = helpItemViewModel.AllItems[i].type;
                titles[3].InnerText = helpItemViewModel.AllItems[i].type;
                titles[6].InnerText = helpItemViewModel.AllItems[i].type;
                titles[2].InnerText = helpItemViewModel.AllItems[i].details;
                titles[4].InnerText = helpItemViewModel.AllItems[i].details;
                titles[7].InnerText = helpItemViewModel.AllItems[i].details;
                titles[5].InnerText = helpItemViewModel.AllItems[i].dateTime.ToString();
                titles[8].InnerText = helpItemViewModel.AllItems[i].dateTime.ToString();

                /*BitmapImage b = (BitmapImage)touxiang.ImageSource;
                 * var images = tilexml.GetElementsByTagName("image");
                 * if (images != null)
                 * {
                 *  var image = images[0] as XmlElement; if (b != null) image.SetAttribute("src", b.UriSource.ToString());
                 *  image = images[1] as XmlElement; if (b != null) image.SetAttribute("src", b.UriSource.ToString());
                 *  image = images[2] as XmlElement; if (b != null) image.SetAttribute("src", b.UriSource.ToString());
                 *  image = images[3] as XmlElement; if (b != null) image.SetAttribute("src", b.UriSource.ToString());
                 * }*/
                TileNotification notification = new TileNotification(tilexml);
                updator.Update(notification);
            }
        }
Esempio n. 11
0
        private void btnCustomWay_Click(object sender, EventArgs e)
        {
            btn_CallService.Enabled = false;
            richTextBox1.Text       = "";
            var a = SendRequestToMPAPI(txtRequest.Text,
                                       "https://managepath8.com/Services/Implementations/DollarGeneral/VendorTicketService.asmx");


            System.Xml.Linq.XDocument xDocument = System.Xml.Linq.XDocument.Parse(a);


            richTextBox1.Text = xDocument.ToString();

            btn_CallService.Enabled = true;
        }
Esempio n. 12
0
        public override string ToString()
        {
            string value  = $"{Value}";
            var    result = new System.Xml.Linq.XDocument(new System.Xml.Linq.XElement("tree", new System.Xml.Linq.XAttribute("value", value)));

            this.Aggregate(result, (whole, next) =>
            {
                var xml = next?.ToString();
                if (!string.IsNullOrWhiteSpace(xml))
                {
                    whole.Root.Add(System.Xml.Linq.XElement.Parse(xml));
                }
                return(whole);
            });
            return(result.ToString());
        }
Esempio n. 13
0
        public FormRDLViewer(System.Xml.Linq.XDocument rdlxml)
        {
            InitializeComponent();

            this.xml     = rdlxml;
            this.RDLText = xml.ToString();


            var md = SSRSCommon.RDLMetaData.Load(this.RDLXML);

            this.labelXmlNamespace.Text = md.Namespace.ToString();

            this.labelPageSettings.Text = string.Format("{0} x {1} ( {2}, {3}, {4}, {5} )", md.PageSize.Width,
                                                        md.PageSize.Height, md.MarginTop, md.MarginBottom, md.MarginLeft,
                                                        md.MarginRight);
        }
Esempio n. 14
0
        public string ToString(bool format)
        {
            JsonSerializerSettings val = new JsonSerializerSettings();

            val.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
            val.DateFormatString  = "MM/dd/yyyy HH:mm";

            string str = JsonConvert.SerializeObject((object)this, val);

            System.Xml.Linq.XDocument   doc     = JsonConvert.DeserializeXNode(str, "DeviceInfo");
            System.Xml.Linq.SaveOptions options = System.Xml.Linq.SaveOptions.DisableFormatting;
            if (format)
            {
                options = System.Xml.Linq.SaveOptions.None;
            }
            return(doc.ToString(options));
        }
Esempio n. 15
0
        public FormRDLViewer(System.Xml.Linq.XDocument rdlxml)
        {
            InitializeComponent();

            this.xml = rdlxml;
            this.RDLText = xml.ToString();


            var md = SSRSCommon.RDLMetaData.Load(this.RDLXML);

            this.labelXmlNamespace.Text = md.Namespace.ToString();

            this.labelPageSettings.Text = string.Format("{0} x {1} ( {2}, {3}, {4}, {5} )", md.PageSize.Width,
                                                        md.PageSize.Height, md.MarginTop, md.MarginBottom, md.MarginLeft,
                                                        md.MarginRight);


        }
Esempio n. 16
0
        public IActionResult Index()
        {
            BookSpider spider = new BookSpider();

            spider.StrCookie = GetbookcookieAsync().Result;
            System.Xml.Linq.XDocument message = new System.Xml.Linq.XDocument();
            spider.Run();
            foreach (IPipeline item in spider.Pipelines)
            {
                message = item.ResponseMessage;
            }
            if (message == null)
            {
                return(Redirect(Url.Action("Error", "Home")));
            }
            Response.ContentType = "application/xml";
            return(Content(message.ToString()));
        }
Esempio n. 17
0
        private void Browser_Loaded(object sender, RoutedEventArgs e)
        {
            // Load IAP Listing Information

#if DEBUG
            //Use Mock API instead of real store
            MockIAP.Init();
            MockIAP.RunInMockMode(true);
            MockIAP.SetListingInformation(1, "en-us", "Your App Description", "$1.99", "Your App Name");

            // initialize to empty product list in case debug IAP functionality is not needed
            string xml = @"<ProductListings></ProductListings>";

            var sri = App.GetResourceStream(new Uri("WindowsStoreProxy.xml", UriKind.Relative));
            if (sri != null)
            {
                System.Xml.Linq.XDocument doc = System.Xml.Linq.XDocument.Load(sri.Stream);
                xml = doc.ToString();
            }

            MockIAP.PopulateIAPItemsFromXml(xml);
#endif
        }
Esempio n. 18
0
        private string GenerateExport()
        {
            string             templateExport    = TemplateExporter.GenerateXMLExport(this.tdb, this.templates, this.igSettings, true, this.categories);
            LantanaXmlResolver resolver          = new LantanaXmlResolver();
            string             stylesheetContent = string.Empty;

            using (StreamReader stylesheetReader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(StylesheetResource)))
            {
                stylesheetContent = stylesheetReader.ReadToEnd();
            }

            var export = TransformFactory.Transform(templateExport, stylesheetContent, StylesheetUri, resolver);

            if (includeVocabulary)
            {
                // Export the vocabulary for the implementation guide in SVS format
                VocabularyService vocService = new VocabularyService(tdb, false);
                string            vocXml     = vocService.GetImplementationGuideVocabulary(igSettings.ImplementationGuideId, 1000, 4, "utf-8");

                // Merge the two ATOM exports together
                XmlDocument exportDoc = new XmlDocument();
                exportDoc.LoadXml(export);

                // Remove extra xmlns attributes from vocabulary xml
                System.Xml.Linq.XDocument doc = System.Xml.Linq.XDocument.Parse(vocXml);
                foreach (var descendant in doc.Root.Descendants())
                {
                    var namespaceDeclarations = descendant.Attributes().Where(y => y.IsNamespaceDeclaration && y.Name.LocalName == "atom");
                    foreach (var namespaceDeclaration in namespaceDeclarations)
                    {
                        namespaceDeclaration.Remove();
                    }
                }
                vocXml = doc.ToString();

                XmlDocument vocDoc = new XmlDocument();
                vocDoc.LoadXml(vocXml);

                XmlNamespaceManager vocNsManager = new XmlNamespaceManager(vocDoc.NameTable);
                vocNsManager.AddNamespace("atom", "http://www.w3.org/2005/Atom");

                XmlNodeList vocEntryNodes = vocDoc.SelectNodes("/atom:feed/atom:entry", vocNsManager);

                foreach (XmlNode vocEntryNode in vocEntryNodes)
                {
                    XmlNode clonedVocEntryNode = exportDoc.ImportNode(vocEntryNode, true);
                    exportDoc.DocumentElement.AppendChild(clonedVocEntryNode);
                }

                // Format the XmlDocument and save it as a string
                using (StringWriter sw = new StringWriter())
                {
                    XmlTextWriter xtw = new XmlTextWriter(sw);
                    xtw.Formatting = Formatting.Indented;

                    exportDoc.WriteContentTo(xtw);
                    export = sw.ToString();
                }
            }

            return(export);
        }
Esempio n. 19
0
        public DDLJson LoadDDLs([FromBody] DDLFilterList filterList)
        {
            //Guid organizationId = new Guid("3EC0CBCE-7D8B-40E8-B6B7-7AB0FC48666A");

            //if (HttpContext.Current.User.Identity.IsAuthenticated) {
            //    var user = GetCurrentUser();
            //    organizationId = user.OrganizationId;
            //}
            var json = JsonConvert.SerializeObject(filterList.FilterList);

            System.Xml.Linq.XDocument xml = JsonConvert.DeserializeXNode("{\"Data\":" + json + "}", "root");

            return(_codeGenService.GetDDLItemsList(pageName: filterList.PageName, ddlListXML: xml.ToString()));
        }