protected override void DumpConfigs()
        {
            try
            {
                var allTypes = DataTypeDefinition.GetAll();
                System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();

                var di = new DirectoryInfo(storageFolder);
                di.GetFiles().ToList().ForEach(x =>
                {
                    File.Delete(x.FullName);
                });

                foreach (var dt in allTypes)
                {
                    var doc = new XmlDocument();
                    doc.LoadXml(dt.ToXml(xmlDoc).OuterXml);
                    var xml = doc.ToString(4);

                    var fileName = dt.Text.ToAlias() + ".config";
                    var file = Path.Combine(storageFolder, fileName);
                    using (var fs = File.CreateText(file))
                    {
                        fs.Write(xml);
                    }
                }
            }
            catch { }
        }
Пример #2
0
        public static void GameTest()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load("../../../Schema/DoorDemo.xml");
            Console.Write(doc.ToString());

            XmlReader r = XmlReader.Create("../../../Schema/DoorDemo.xml");
            string xmlcontents = doc.InnerXml;

            Console.Write(xmlcontents);
            Console.ReadLine();
        }
Пример #3
0
        public Nota(String arquivoNotaXml)
        {
            if (!File.Exists(arquivoNotaXml))
            {
                throw new Exception("O arquivo de nota para envio não existe: " + arquivoNotaXml);
            }

            var xmlDoc = new XmlDocument();
            xmlDoc.Load(arquivoNotaXml);

            CaminhoFisico = arquivoNotaXml;
            ConteudoXml = xmlDoc.ToString();
        }
Пример #4
0
 public static XmlDocument getXML(string fileName)
 {
     XmlDocument xml;
     if (map[fileName] is XmlDocument)
     {
         return map[fileName] as XmlDocument;
     } else {
         ByteArray byteArr = map[fileName] as ByteArray;
         xml = new XmlDocument();
         xml.Load(byteArr.MemoryStream);
         map[fileName] = xml;
         Debug.Log(xml.ToString());
     }
     return map[fileName] as XmlDocument;
 }
Пример #5
0
        public void updateDatabase()
        {
            String method = "GET";
            String url = "https://www.mkmapi.eu/ws/v1.1/expansion/1/";
            HttpWebRequest request = WebRequest.CreateHttp(url) as HttpWebRequest;
            OAuthHeader header = new OAuthHeader();
            request.Headers.Add(HttpRequestHeader.Authorization, header.getAuthorizationHeader(method, url));
            request.Method = method;

            HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            XmlDocument doc = new XmlDocument();
            doc.Load(response.GetResponseStream());

            // Tratamos la lista de expansiones
            Console.WriteLine(doc.ToString());
        }
Пример #6
0
        public void LoadTemplateURL(string templates_navi_url)
        {
            XmlDocument xml = new XmlDocument();
            xml.Load(System.AppDomain.CurrentDomain.BaseDirectory + templates_navi_url);

            string x = xml.ToString();

            XmlNodeList nList = xml.SelectNodes("//Docments/Document");

            foreach (XmlNode node in nList)
            {
                TemplateRule rule = new TemplateRule();
                rule.ID = node.Attributes["id"].InnerXml;
                rule.TemplateURL = node.Attributes["Template"].InnerXml;
                rule.TargetURL = node.Attributes["TargetURL"].InnerXml;

                tempRules.Add(rule);
            }
        }
Пример #7
0
		public void TestWithDocPath()
		{
			var parameters = new CompilerParameters();
			CommandLineParser.ParseInto(parameters,
				new string[] { "/doc:TestDoc.xml", "/target:library", "/o:TestDoc.dll", "TestDoc.boo" });
			var compiler = new BooCompiler(parameters);
			var context=compiler.Run();
			if (context.Errors.Count > 0)
			{
				Console.WriteLine(context.Errors);
				throw new AssertionException(context.Errors[0].ToString());
			}
			
			var reference = new XmlDocument();
			reference.Load("TestDocReference.xml");
			var result = new XmlDocument();
			result.Load("TestDoc.xml");
			
			Assert.AreEqual(reference.ToString(), result.ToString());
		}
Пример #8
0
        public List<Recording> GetDownloadableRecordings()
        {
            var retval = new List<Recording>();
            var urlRecordings = String.Format(UrlRecordings, Umgebung.Web.User, Umgebung.Web.Password);

            var docRecordings = new XmlDocument();
            docRecordings.Load(urlRecordings);

            Umgebung.Log.Dump("Bong recordings.xml Ergebnisdokument:\n{0}", docRecordings.ToString());

            var root = docRecordings.DocumentElement;
            if (root != null)
            {
                var nodes = root.SelectNodes("/recordings/recording");

                if (nodes != null)
                    foreach (XmlNode node in nodes)
                    {
                        var docRecording = new XmlDocument();

                        try
                        {
                            docRecording.InnerXml = node.OuterXml;
                            var xmlDecl = docRecording.CreateXmlDeclaration("1.0", "UTF-8", null);
                            var rootRecording = docRecording.DocumentElement;
                            docRecording.InsertBefore(xmlDecl, rootRecording);

                            Umgebung.Log.Dump("Neues XML-Dokument erstellt:\n{0}", docRecording.ToString());

                            var rec = new Recording()
                                          {
                                              // Id wird erst später nachgetragen
                                              BongId = GetNodeText(docRecording, "/recording/id"),
                                              Title = GetNodeText(docRecording, "/recording/title"),
                                              Subtitle = GetNodeText(docRecording, "/recording/subtitle"),
                                              Description = GetNodeText(docRecording, "/recording/description"),
                                              Channel = GetNodeText(docRecording, "/recording/channel"),
                                              Start = DateTime.Parse(GetNodeText(docRecording, "/recording/start"), new CultureInfo("de-DE"), DateTimeStyles.None),
                                              Duration = TimeSpan.Parse(GetNodeText(docRecording, "/recording/duration"), new CultureInfo("de-DE")),
                                              Genre = GetNodeText(docRecording, "/recording/genre"),
                                              SeriesSeason = GetNodeText(docRecording, "/recording/series_season"),
                                              SeriesNumber = GetNodeText(docRecording, "/recording/series_number"),
                                              SeriesCount = GetNodeText(docRecording, "/recording/series_count"),
                                              ImageUrl = GetNodeText(docRecording, "/recording/image"),
                                              DownloadUrlHD = GetNodeText(docRecording, "/recording/files/file[type='download' and quality='HD']/url"),
                                              DownloadUrlHQ = GetNodeText(docRecording, "/recording/files/file[type='download' and quality='HQ']/url"),
                                              DownloadUrlNQ = GetNodeText(docRecording, "/recording/files/file[type='download' and quality='NQ']/url")
                                          };

                            rec.Dump("Recording-Instanz aus Bong-XML erstellt");

                            retval.Add(rec);
                        }
                        catch (Exception ex)
                        {
                            Umgebung.Log.Error("Initialisieren von Recording aus der XML-Struktur schlug fehl: {0}\n{1}", ex.Message, docRecording.ToString());
                        }
                    }
            }

            return retval;
        }
Пример #9
0
        public static XmlDocument TransformIncludes(this XmlDocument dom)
        {
            foreach (XmlNode item in dom.DocumentElement.SelectNodes("include"))
            {
                var d = new XmlDocument();
                d.Load(item.Attributes?["src"]?.Value);

                switch (item.Attributes?["type"]?.Value)
                {
                    case "text/xml":
                        var n = dom.ImportNode(d.DocumentElement, true);

                        dom.DocumentElement.ReplaceChild(n, item);

                        break;
                    case "text/component+xml":
                        dom.CreateComponent(d.ToString());

                        dom.DocumentElement.RemoveChild(item);

                        break;
                    default:
                        dom.CreateComponent(d.ToString());

                        dom.DocumentElement.RemoveChild(item);

                        break;
                }
            }

            return dom;
        }
Пример #10
0
        public static XmlDocument LoadFile(string path)
        {
            FileStream fs = null;
            try
            {
                FileInfo info = new FileInfo(path);
                if (!info.Exists)
                {
                    return null;
                }
                fs = info.Open(FileMode.Open);
                XmlDocument xml = new XmlDocument();
                xml.Load(fs);
                return xml;
            }
            catch (XmlException xml)
            {
                Console.WriteLine(xml.ToString());
                return null;
            }
            finally
            {
                if (fs != null)
                {
                    try { fs.Close(); }
                    catch (Exception) { }
                }
            }

        }
Пример #11
0
        public void TCM_UpdateTabResultsManager()
        {
            this.tabControl1.Controls.Add(this.AddIssue);
            this.TabResultsManager.Controls.Add(this.PanelResultsManagerTiltle);
            this.TabResultsManager.Controls.Add(this.TabControlIssues);
            this.PictureBoxMaximizeResultTab.Visible = false ;
            this.PictureBoxMinResultsTab.Visible = true;
            this.TabControlIssues.Visible = true ;

            if (_TCM_CountForControlsChange == 0)
            {
                _TCM_UpdateCount++;
                FileInfo file = new FileInfo(projectApp.ProjectFileName);
                string projectStructureFile = Path.Combine(file.DirectoryName, Path.GetFileNameWithoutExtension(projectApp.ProjectFileName) + ".xml");
                //string projectStructureFile = Path.GetFileNameWithoutExtension(projectApp.ProjectFileName) + ".xml";
                string finalHtmlFile = projectStructureFile.ToLower().Replace(".xml", ".html");
                try
                {
                    ProjectXmlFile(projectStructureFile);
                    string tempFile1 = Path.GetFileNameWithoutExtension(projectApp.ProjectFileName) + "1.xml";
                    string tempFile2 = Path.GetFileNameWithoutExtension(projectApp.ProjectFileName) + "2.xml";
                    string tempFile3 = Path.GetFileNameWithoutExtension(projectApp.ProjectFileName) + "3.xml";
                    if (!_MainForm.ToolBarFilterResults.Pushed)
                    {
                        if(projectApp.Sessions.Count != 0)
                        {
                            Convert(Path.GetFileName(projectStructureFile), tempFile1, "createsum.xsl");
                            Convert(tempFile1,tempFile2,"sortontype.xsl");
                            Convert(tempFile2,tempFile3, "sortonmes.xsl");
                            Convert(tempFile3,  finalHtmlFile, "viewonmes.xsl");
                        }
                    }
                    else
                    {
                        FileInfo fileInfo = new FileInfo(resultProjectXml);
                        if (fileInfo.Exists)
                        {
                            XmlDocument xmldoc= null;
                            try
                            {
                                xmldoc = new XmlDocument();
                                xmldoc.Load(fileInfo.FullName);
                            }
                            catch(Exception e)
                            {
                                MessageBox.Show(e.Message+ "-----"+ xmldoc.ToString());
                                CreateXmlTemplate();
                            }
                        }
                        if ( !fileInfo.Exists)
                        {
                            CreateXmlTemplate();
                        }
                        ProjectXmlFile(projectStructureFile);
                        if(projectApp.Sessions.Count != 0)
                        {
                            Convert(Path.GetFileName(projectStructureFile), tempFile1, "createsum.xsl");
                            Convert(tempFile1,tempFile2,"sortontype.xsl");
                            Convert(tempFile2,tempFile3, "sortonmes.xsl");
                            Convert(tempFile3,  finalHtmlFile, "viewonmesfiltered.xsl");
                        }
                    }
                    webBrowserResultMgr.Navigate(finalHtmlFile);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }

                _TCM_UpdateCount--;
            }
        }
Пример #12
0
        public async Task WhenGetXmlIsCalled_ResponseContentIsDeserialized()
        {
            var expectedString = "<root><foo>Foo</foo><bar>Bar</bar></root>";
            var expected = new XmlDocument();
            expected.LoadXml(expectedString);

            var stubHandler = new FakeHttpMessageHandler(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(expectedString)
            });
            var http = new HttpWrapper("http://foo.com/",
                new TestLogger(),
                new Envelope(new TextMessage(CreateTestUser(), "test", "id")),
                stubHandler);

            var actual = await http.GetXml();

            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Пример #13
0
        public long SaveData(
            XmlDocument xmlDoc)
        {
            SqlConnection conn = null;
            SqlCommand cmd = null;
            StringBuilder sql = new StringBuilder();
            StringBuilder fields = new StringBuilder();
            StringBuilder values = new StringBuilder();
            string cmdName = null;
            long retVal = 0;

            try {
                conn = GetConnection();
                conn.Open();

                XmlNode cmdNode = xmlDoc.DocumentElement;

                        // Set table name
                tableName = cmdNode.Attributes["table"].Value;
                aliases.Add(tableName, string.Format("{0}", "0"));
                cmdName = cmdNode.Name.ToLower();

                        // If this is an insert request ...
                if (cmdName == "insert") {
                    cmd = new SqlCommand();
                    cmd.Connection = conn;

                    XmlNodeList rowNodes = cmdNode.SelectNodes("Row");

                            // If set indentity is true, turn on the set indentity_insert
                    if (SetIdentity) {
                        sql.Append(string.Format("if IDENT_CURRENT('{0}') IS NOT NULL\nBEGIN\nset identity_insert {0} on;", tableName));
                    }

                            // For each row ...
                    foreach (XmlNode row in rowNodes) {
                        sql.Append(string.Format("insert into {0} ", tableName));
                        fields.Append("(");
                        values.Append("values (");

            //					XmlNode fieldsNode = row.SelectSingleNode("//Fields");
                        Set fieldSet = GetFields(row.SelectSingleNode("//Fields"), cmd);

                                // For each field returned: append field name and value
                        foreach (string field in fieldSet) {
                            fields.Append(string.Format("{0}, ", field));
                            values.Append(string.Format("@{0}, ", field));
            //						cmd.Parameters["@" + field].Value =
            //  !! need to add the param here
                        }

                                // Remove the extra comma and space
                        fields.Remove(fields.Length - 2, 2);
                        fields.Append(") ");
                        values.Remove(values.Length - 2, 2);
                        values.Append(") ");

                                // Append the fields and values clauses
                        sql.Append(fields + values.ToString() + ";select IDENT_CURRENT('" + tableName + "')");

                                // Turn off the set indentity_insert
                        if (SetIdentity) {
                            sql.Append(string.Format("set identity_insert {0} off\nEND ", tableName));
                        }

                                // Set commandtext and execute command
                        cmd.CommandText = sql.ToString();
                        object ident = cmd.ExecuteScalar();

                                //  if there is an identity field the identity of the new record should be returned,
                                //  but if there is no identity field we need to return something other than 0 which
                                //  indicates an error occurred
                        if (ident is Decimal) {
                            retVal = (long)((Decimal)ident);
                        } else {
                            retVal = -1;
                        }
                    }
                } else if (cmdName == "update") {
                    StringBuilder update = new StringBuilder();
                    StringBuilder where = new StringBuilder();
                    Set fieldSet = null;

                    cmd = new SqlCommand();
                    cmd.Connection = conn;
                    fieldSet = GetFields(cmdNode.SelectSingleNode("Fields"), cmd);
                    update.Append("SET ");

                            // For each field returned: append field name and value
                    foreach (string field in fieldSet) {
                        update.Append(string.Format("{0} = @{0}, ", field));
                    }

                            // Remove the extra comma
                    update.Remove(update.Length - 2, 2);

                            // Add where conditions
                    if (cmdNode.SelectSingleNode("Where").ChildNodes.Count > 0) {
                        where.Append(" WHERE ");
                        where.Append(BuildConditions(cmdNode.SelectSingleNode("Where"), cmd, null));
                    }

                            // Formulate the sql
                    sql.Append(string.Format("UPDATE {0} ", cmdNode.Attributes["table"].Value));
                    sql.Append(update);
                    sql.Append(where);
                    sql.Append(";");

                    cmd.CommandText = sql.ToString();
                    cmd.ExecuteNonQuery();
                }
            } catch (Exception ex) {
                string data = null;
                try {
                    data = xmlDoc.ToString();
                } catch { }
                        // Log error
                LogManager.GetCurrentClassLogger().Error(
                        errorMessage => errorMessage(string.Format("MsGenericDao.SaveData: data= {0}", data)), ex);
            } finally {
                DbUtilities.Close(conn, null, null);
            }

            return retVal;
        }
Пример #14
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            // setup variables for response time
            DateTime responseReceived = new DateTime();
            DateTime requestStarted = new DateTime();

            try
            {
                Cursor = Cursors.WaitCursor;
                ClearResponseTree();

                // get the request url and request method
                string graphRequest = tbRequestUrl.Text;
                HttpMethod HttpRequestMethod;

                switch (cmbHttpMethod.Text)
                {
                    case "GET":
                        HttpRequestMethod = HttpMethod.Get;
                        break;
                    case "POST":
                        HttpRequestMethod = HttpMethod.Post;
                        break;
                    case "PUT":
                        HttpRequestMethod = HttpMethod.Put;
                        break;
                    case "HEAD":
                        HttpRequestMethod = HttpMethod.Head;
                        break;
                    case "OPTIONS":
                        HttpRequestMethod = HttpMethod.Options;
                        break;
                    default:
                        HttpRequestMethod = HttpMethod.Delete;
                        break;
                }

                // create the http request and add the access token in the header
                HttpRequestMessage request = new HttpRequestMessage(HttpRequestMethod, graphRequest);
                request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken);

                // check for diagnostics flag
                if (Properties.Settings.Default.OutlookDiagnostics == "On")
                {
                    AddRequestHeader("Prefer", "outlook.diagnostics");
                }

                // add headers to the request
                foreach (DataGridViewRow row in dgRequestHeaders.Rows)
                {
                    request.Headers.Add(row.Cells[0].Value.ToString(), row.Cells[1].Value.ToString());
                }

                // check for a request body
                if (tbRequestBody.Text != "")
                {
                    request.Content = new StringContent(tbRequestBody.Text, System.Text.Encoding.UTF8, "application/json");
                }

                logger.Log("REQUEST HEADER:");
                logger.Log(request.Headers.ToString());
                logger.Log("REQUEST:");
                logger.Log(request.ToString());

                // get the current time for response time calculation
                requestStarted = DateTime.Now;

                // start processing the response
                HttpResponseMessage response = httpClient.SendAsync(request).Result;

                // get the current time again to figure out the response time
                responseReceived = DateTime.Now;

                // calculate the number of milliseconds that the request took to complete
                TimeSpan milliseconds = responseReceived.Subtract(requestStarted);
                logger.Log("RESPONSE TIME = " + milliseconds);

                // handle non-successful requests
                if (!response.IsSuccessStatusCode)
                {
                    string errorJsonContent = response.Content.ReadAsStringAsync().Result;

                    JObject jResult = JObject.Parse(errorJsonContent);

                    // check for odata error
                    if (jResult["odata.error"] != null)
                    {
                        throw new Exception((string)jResult["odata.error"]["message"]["value"]);
                    }

                    // check for null result
                    if (jResult[""] != null)
                    {
                        logger.Log("## null response ##");
                    }

                    // log non-odata errors
                    logger.Log("RESPONSE JSON CONTENT:");
                    logger.Log(jResult.ToString());

                    // display error details in the UI
                    TreeNode errorParent = TreeViewHelper.Json2Tree(jResult);
                    errorParent.Text = "Request failed.";
                    treeViewResult = errorParent.ToString();
                    tvw.Nodes.Add(errorParent);

                    // finally throw the exception to prevent further processing of the request
                    throw new WebException(response.StatusCode.ToString() + ": " + response.ReasonPhrase);
                }

                // process successful request
                string content = response.Content.ReadAsStringAsync().Result;

                logger.Log("RESPONSE HEADER:");
                logger.Log(response.Headers.ToString());
                logger.Log("RESPONSE:");

                if (response.StatusCode == HttpStatusCode.Accepted || response.StatusCode == HttpStatusCode.Created)
                {
                    // POST responses that are successful return 202 Accepted or 201 Created,
                    // there is no response body so let the user know it was successful
                    tvw.Nodes.Add(new TreeNode("Message created/sent succesfully."));
                    logger.Log("StatusCode = " + response.StatusCode.ToString());
                }
                else if (response.StatusCode == HttpStatusCode.OK)
                {
                    // GET responses should have a return type of xml or json
                    if (content[0] == '<')
                    {
                        // check for an xml response and populate the tree
                        // this is mainly for the metadata query
                        XmlDocument dom = new XmlDocument();
                        dom.LoadXml(content);

                        tvw.Nodes.Clear();
                        tvw.Nodes.Add(new TreeNode(dom.DocumentElement.Name));
                        TreeNode tNode = new TreeNode();
                        tNode = tvw.Nodes[0];

                        TreeViewHelper.AddNode(dom.DocumentElement, tNode);
                        treeViewResult = dom.ToString();
                        logger.Log(dom.ToString());
                    }
                    else
                    {
                        // if it isn't xml it should be json, populate the tree
                        JObject jResult = JObject.Parse(content);

                        if (jResult["odata.error"] != null)
                        {
                            throw new Exception((string)jResult["odata.error"]["message"]["value"]);
                        }

                        if (jResult[""] != null)
                        {

                            logger.Log("");
                        }

                        tvw.Nodes.Clear();
                        TreeNode parent = TreeViewHelper.Json2Tree(jResult);
                        parent.Text = "Root Object";
                        tvw.Nodes.Add(parent);
                        logger.Log(jResult.ToString());
                        treeViewResult = jResult.ToString();
                    }
                }
                else
                {
                    // log anything that is not an OK or Accepted response, but also not an error
                    logger.Log(response.StatusCode.ToString());
                }
            }
            catch (Exception ex)
            {
                logger.Log("Exception: " + ex.Message);
            }
            finally
            {
                // clear the headers
                dgRequestHeaders.Rows.Clear();
                Cursor = Cursors.Default;
            }
        }