コード例 #1
0
ファイル: Metadata.cs プロジェクト: emtees/old-code
	public void DumpArrayToXml ()
	{
		string metadata_filename = dir + Path.DirectorySeparatorChar + "album-data.xml";

		XmlTextWriter writer = new XmlTextWriter (metadata_filename, Encoding.UTF8);

		writer.WriteStartDocument (true);
		writer.WriteStartElement ("album", "www.ximian.com");
		writer.WriteAttributeString ("name", album_name);
	        writer.WriteAttributeString ("count", picture_count.ToString ());

		for (int i = 0; i < picture_count; ++i) {
			writer.WriteStartElement ("picture", "www.ximian.com");

			writer.WriteElementString ("location", "www.ximian.com", picture_data [i].Location);
			writer.WriteElementString ("title", "www.ximian.com", picture_data [i].Title);
			writer.WriteElementString ("date", "www.ximian.com", picture_data [i].Date);
			writer.WriteElementString ("keywords", "www.ximian.com", picture_data [i].Keywords);
			writer.WriteElementString ("comments", "www.ximian.com", picture_data [i].Comments);
			writer.WriteElementString ("index", "www.ximian.com", picture_data [i].Index.ToString ());
			
			writer.WriteEndElement ();
		}

		writer.WriteEndElement ();
		writer.WriteEndDocument ();
		writer.Close ();
	}
コード例 #2
0
ファイル: RunTagger.cs プロジェクト: ufal/morphodita
    public static int Main(string[] args)
    {
        if (args.Length < 1) {
            Console.Error.WriteLine("Usage: RunMorphoCli tagger_file");
            return 1;
        }

        Console.Error.Write("Loading tagger: ");
        Tagger tagger = Tagger.load(args[0]);
        if (tagger == null) {
            Console.Error.WriteLine("Cannot load tagger from file '{0}'", args[0]);
            return 1;
        }
        Console.Error.WriteLine("done");

        Forms forms = new Forms();
        TaggedLemmas lemmas = new TaggedLemmas();
        TokenRanges tokens = new TokenRanges();
        Tokenizer tokenizer = tagger.newTokenizer();
        if (tokenizer == null) {
            Console.Error.WriteLine("No tokenizer is defined for the supplied model!");
            return 1;
        }

        XmlTextWriter xmlOut = new XmlTextWriter(Console.Out);
        for (bool not_eof = true; not_eof; ) {
            string line;
            StringBuilder textBuilder = new StringBuilder();

            // Read block
            while ((not_eof = (line = Console.In.ReadLine()) != null) && line.Length > 0) {
                textBuilder.Append(line).Append('\n');
            }
            if (not_eof) textBuilder.Append('\n');

            // Tokenize and tag
            string text = textBuilder.ToString();
            tokenizer.setText(text);
            int t = 0;
            while (tokenizer.nextSentence(forms, tokens)) {
                tagger.tag(forms, lemmas);

                for (int i = 0; i < lemmas.Count; i++) {
                    TaggedLemma lemma = lemmas[i];
                    int token_start = (int)tokens[i].start, token_length = (int)tokens[i].length;
                    xmlOut.WriteString(text.Substring(t, token_start - t));
                    if (i == 0) xmlOut.WriteStartElement("sentence");
                    xmlOut.WriteStartElement("token");
                    xmlOut.WriteAttributeString("lemma", lemma.lemma);
                    xmlOut.WriteAttributeString("tag", lemma.tag);
                    xmlOut.WriteString(text.Substring(token_start, token_length));
                    xmlOut.WriteEndElement();
                    if (i + 1 == lemmas.Count) xmlOut.WriteEndElement();
                    t = token_start + token_length;
                }
            }
            xmlOut.WriteString(text.Substring(t));
        }
        return 0;
    }
コード例 #3
0
ファイル: GoogleSiteMap.aspx.cs プロジェクト: suizhikuo/KYCMS
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetNoStore();
        Response.ContentType = "application/xml";
        DataTable dt = CreateBll.GetInfo(TABLE_NAME, 1, 100);

        MemoryStream ms = new MemoryStream();
        XmlTextWriter xmlTW = new XmlTextWriter(ms, Encoding.UTF8);
        xmlTW.Formatting = Formatting.Indented;
        xmlTW.WriteStartDocument();
        xmlTW.WriteStartElement("urlset");
        xmlTW.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");
        xmlTW.WriteAttributeString("xmlns:news", "http://www.google.com/schemas/sitemap-news/0.9");

        foreach (DataRow dr in dt.Rows)
        {
            xmlTW.WriteStartElement("url");
            string infoUrl = CreateBll.GetInfoUrl(dr,1).ToLower();
            if(!infoUrl.StartsWith("http://")&&!infoUrl.StartsWith("https://")&&!infoUrl.StartsWith("ftp://"))
            {
                if(Param.ApplicationRootPath==string.Empty)
                {
                    infoUrl = CreateBll.SiteModel.Domain+infoUrl;
                }
                else
                {
                    infoUrl = infoUrl.Replace(Param.ApplicationRootPath.ToLower(),string.Empty);
                    infoUrl = CreateBll.SiteModel.Domain+infoUrl;
                }
            }
            xmlTW.WriteElementString("loc", infoUrl);

            xmlTW.WriteStartElement("news:news");
            xmlTW.WriteElementString("news:publication_date", dr["addtime"].ToString());
             string keywords = dr["tagnamestr"].ToString();
            if (keywords.StartsWith("|") && keywords.EndsWith("|"))
            {
                keywords = keywords.Substring(0, keywords.Length - 1);
                keywords = keywords.Substring(1, keywords.Length - 1);
                keywords = keywords.Replace("|",",");
            }
            xmlTW.WriteElementString("news:keywords", keywords);
            xmlTW.WriteEndElement();
            xmlTW.WriteEndElement();
        }
        xmlTW.WriteEndDocument();
        xmlTW.Flush();
        byte[] buffer = ms.ToArray();
        Response.Write(Encoding.UTF8.GetString(buffer));
        Response.End();
        xmlTW.Close();
        ms.Close();
        ms.Dispose();
    }
コード例 #4
0
ファイル: SiteMap.aspx.cs プロジェクト: ivladyka/Ekran
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();
        Response.ContentType = "text/xml";
        XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
        writer.WriteStartDocument();
        writer.WriteStartElement("urlset");
        writer.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");

        string siteUrl = Request.Url.Scheme + Uri.SchemeDelimiter + System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
        if (!Request.Url.IsDefaultPort)
        {
            siteUrl += ":" + Request.Url.Port;
        }
        Menu menu = new Menu();
        Utils.InitMenu(menu, false, false, false);
        foreach (MenuItem item in menu.Items)
        {
            writer.WriteStartElement("url");
            writer.WriteElementString("loc", siteUrl + item.NavigateUrl);
            writer.WriteEndElement();
            foreach (MenuItem childItem in item.ChildItems)
            {
                writer.WriteStartElement("url");
                writer.WriteElementString("loc", siteUrl + childItem.NavigateUrl);
                writer.WriteEndElement();
            }
        }
        writer.WriteEndElement();
        writer.WriteEndDocument();
        writer.Flush();
        Response.End();
    }
コード例 #5
0
    private void GetRssFeedContens(AspxCommonInfo aspxCommonObj, string pageURL, int count)
    {
        try
        {
            string[] path = pageURL.Split('?');
            string pagepath = path[0];
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ContentType = "text/xml";
            XmlTextWriter rssXml = new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8);

            rssXml.WriteStartDocument();

            rssXml.WriteStartElement("rss");
            rssXml.WriteAttributeString("version", "2.0");
            rssXml.WriteStartElement("channel");
            rssXml.WriteElementString("link", pagepath);
            rssXml.WriteElementString("title", getLocale("AspxCommerce Services"));
            GetItemRssFeedContents(aspxCommonObj, rssXml, pageURL,count);
            rssXml.WriteEndElement();
            rssXml.WriteEndElement();
            rssXml.WriteEndDocument();
            rssXml.Flush();
            rssXml.Close();
            HttpContext.Current.Response.End();

        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
コード例 #6
0
    static void Main()
    {
        using (var writer = new XmlTextWriter(filePath, encoding))
        {
            writer.Formatting = Formatting.Indented;
            writer.IndentChar = '\t';
            writer.Indentation = 1;

            writer.WriteStartDocument();
            writer.WriteStartElement("catalogue");
            writer.WriteAttributeString("name", "Awesome Mix Vol. 1");

            WriteAlbum(writer, "Hooked on a Feeling", "Blue Swede", 1968, "Scepter Records", 20);

            WriteAlbum(writer, "Record World", "Raspberries", 1972, "Capitol Records", 18.50m,
                new List<string>() { "Don't Want to Say Goodbye", "Go All the Way", "I Wanna Be with You" });

            WriteAlbum(writer, "Starting Over", "Raspberries", 1974, "Capitol", 17.50m);

            WriteAlbum(writer, "Wovoka", "Redbone", 1974, "Lolly Vegas", 11,
                new List<string>() { "Come and Get Your Love", "When You Got Trouble" });

            WriteAlbum(writer, "The 5th Dimension", "Blue Swede", 1974, "Warner Bros.", 9.99m);

            writer.WriteEndDocument();
        }

        Console.WriteLine("Document saved to {0}", filePath);
    }
コード例 #7
0
ファイル: rss.aspx.cs プロジェクト: yschulmann/Anglodeals
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();
        Response.ContentType = "text/xml";
        XmlTextWriter objX = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
        objX.WriteStartDocument();
        objX.WriteStartElement("rss");
        objX.WriteAttributeString("version", "2.0");
        objX.WriteStartElement("channel");
        objX.WriteElementString("title", drvvv.Plugins.GetTextToSite("Anglodeals", "francodeals", "zebradeals"));
        objX.WriteElementString("link", "http://anglodeals.co.il/rss.aspx");
        objX.WriteElementString("description", "At  Deals we compile the best coupons from both English and Hebrew anf franch websites daily, translate what is needed and put them up on one user-friendly website.");
        objX.WriteElementString("copyright", "(c) 2012, anglodeals. All rights reserved.");
        //objX.WriteElementString("ttl", "5");

        foreach (var x in drvvv.drvvvSettings.GetDataContextInstance().Coupons.Where(x => x.Active && x.EndDate >= DateTime.Now && x.TitleEn != null).OrderByDescending(x => x.ID).Take(30))
        {
            objX.WriteStartElement("item");
            objX.WriteElementString("guid", x.ID.ToString());
            objX.WriteElementString("title", drvvv.Plugins.GetTextToSite(x.TitleEn, x.TitleFr, x.TitleDefault));
            objX.WriteElementString("image", (drvvv.Plugins.ReturnImgAddress(x.ImgName)).Replace("~/", drvvv.Plugins.GetTextToSite("http://anglodeals.co.il/", "http://francodeals.co.il/", "http://zebradeals.co.il/")));
            objX.WriteElementString("description", drvvv.Plugins.GetTextToSite(x.SubjectEn, x.SubjectFr, x.SubjectDefault));
            objX.WriteElementString("link", string.Format("http://{2}/CouponAddress.aspx?couponID={0}&SiteID={1}", x.ID, 6, drvvv.Plugins.GetTextToSite("anglodeals.co.il", "francodeals.co.il", "zebradeals.co.il")));
            objX.WriteElementString("pubDate", string.Format("{0:R}", x.EndDate));
            objX.WriteEndElement();
        }

        objX.WriteEndElement();
        objX.WriteEndElement();
        objX.WriteEndDocument();
        objX.Flush();
        objX.Close();
        Response.End();

    }
コード例 #8
0
    public static void WriteXmlReport(IEnumerable<XmlReport> reports)
    {

        string fileName = "../../../Sales-by-Vendors-report.xml";
        Encoding encoding = Encoding.GetEncoding("windows-1251");
        using (XmlTextWriter writer = new XmlTextWriter(fileName, encoding))
        {
            writer.Formatting = Formatting.Indented;
            writer.IndentChar = '\t';
            writer.Indentation = 1;

            writer.WriteStartDocument();
            writer.WriteStartElement("sales");

            string vendorName = "";
            bool isFirst = true;
            foreach (var report in reports)
            {
                if (report.VendorName !=vendorName && isFirst == true)
                {
                    writer.WriteStartElement("sale");
                    writer.WriteAttributeString("vendor", report.VendorName);

                    writer.WriteStartElement("summary");
                    writer.WriteAttributeString("date", string.Format("{0:d}", report.FromDate));
                    writer.WriteAttributeString("total-sum", report.Sum.ToString());
                    writer.WriteEndElement();

                    vendorName = report.VendorName;
                    isFirst = false;
                }
                else if (report.VendorName !=vendorName && isFirst == false)
                {
                    writer.WriteEndElement();
                    writer.WriteStartElement("sale");
                    writer.WriteAttributeString("vendor", report.VendorName);

                    writer.WriteStartElement("summary");
                    writer.WriteAttributeString("date", string.Format("{0:d}", report.FromDate));
                    writer.WriteAttributeString("total-sum", report.Sum.ToString());
                    writer.WriteEndElement();

                    vendorName = report.VendorName;
                }
                else
                {
                    writer.WriteStartElement("summary");
                    writer.WriteAttributeString("date", string.Format("{0:d}", report.FromDate));
                    writer.WriteAttributeString("total-sum", report.Sum.ToString());
                    writer.WriteEndElement();
                }
            }
            writer.WriteEndElement();

            writer.WriteEndDocument();
        }
    }
コード例 #9
0
    private static void collapseAll(XmlTextWriter writer, string directory)
    {
        foreach (var dir in Directory.GetDirectories(directory))
        {
            writer.WriteStartElement("dir");
            writer.WriteAttributeString("path", directory.TrimStart('.', '\\'));
            collapseAll(writer, dir);     // using recursion to expand and search in all subfolders
            writer.WriteEndElement();
        }

        foreach (var file in Directory.GetFiles(directory))
        {
            writer.WriteStartElement("file");
            writer.WriteAttributeString("name", file.Substring(file.LastIndexOf('\\') + 1)); //using the Substring() method
            writer.WriteEndElement();                                                        //to remove the file path and
                                                                                             //write only the name of the file
        }
    }
コード例 #10
0
ファイル: Podcast.aspx.cs プロジェクト: weavver/weavver
 public XmlTextWriter AddRSSItem(XmlTextWriter writer, string sItemTitle, string sItemLink, string sItemDescription, string datetime)
 {
     string itemname = System.IO.Path.GetFileName(sItemLink);
       writer.WriteStartElement("item");
            writer.WriteElementString("title",       sItemTitle);
            writer.WriteElementString("link",        "http://www.weavver.com/?redirect=" + itemname);
            writer.WriteElementString("description", "");
            writer.WriteElementString("author",      "Jane Doe");
            writer.WriteElementString("contact",     "tel://17148531212");
            writer.WriteElementString("pubDate",     datetime);
            writer.WriteElementString("tags",        "Unheard,Work");
            writer.WriteStartElement("enclosure");
                 writer.WriteAttributeString("url",                 "http://www.weavver.com/messages/" + itemname);
                 writer.WriteAttributeString("length",              "572345");
                 writer.WriteAttributeString("type",                "audio/wav");
                 writer.WriteStartElement("transcription");
                      writer.WriteAttributeString("confidence", "1.0");
                      writer.WriteValue("THIS IS THE TRANSCRIPTION.");
                 writer.WriteEndElement();
            writer.WriteEndElement();
       writer.WriteEndElement();
       return writer;
 }
コード例 #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Instantiate Action Stored Procedure object
        Blogic FetchData = new Blogic();

        int i = 0;

        //Note: You need to change the domain name "myasp-net.com and ex-designz.net" to your site domain
        Response.Clear();
        Response.ContentType = "text/xml";
        XmlTextWriter objX = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
        objX.WriteStartDocument();
        objX.WriteStartElement("rss");
        objX.WriteAttributeString("version", "2.0");
        objX.WriteStartElement("channel");
        objX.WriteElementString("title", "Ex-designz.net Most Popular Recipe RSS Feed");
        objX.WriteElementString("link", "http://www.myasp-net.com");
        objX.WriteElementString("description", "Recipe database from around the world");
        objX.WriteElementString("copyright", "(c) 2005, Myasp-net.com and Ex-designz.net. All rights reserved.");
        objX.WriteElementString("ttl", "10");

        //Get datatable
        IDataReader dr = FetchData.GetRSSMostPopularRecipe;

        //loop through all record, and write XML for each item.
        for (i = 0; i <= 20 - 1; i++)
        {
            dr.Read();
            objX.WriteStartElement("item");
            objX.WriteElementString("title", dr["Name"].ToString());
            objX.WriteElementString("link", "http://www.ex-designz.net/recipedisplay.asp?rid=" + (int)dr["ID"]);
            objX.WriteElementString("pubDate", Convert.ToDateTime(dr["Date"]).ToShortDateString());
            objX.WriteEndElement();
        }

        dr.Close();

        //End of XML file
        objX.WriteEndElement();
        objX.WriteEndElement();
        objX.WriteEndDocument();

        //Close the XmlTextWriter object
        objX.Flush();
        objX.Close();
        Response.End();

        FetchData = null;
    }
コード例 #12
0
ファイル: Podcast.aspx.cs プロジェクト: weavver/weavver
 public XmlTextWriter WriteRSSPrologue(XmlTextWriter writer)
 {
     writer.WriteStartDocument();
       writer.WriteStartElement("rss");
       writer.WriteAttributeString("version",           "2.0");
       //writer.WriteAttributeString("xmlns:atom",        "xmlns:blogChannel", "http://feeds.weavver.com");
       writer.WriteStartElement("channel");
       writer.WriteElementString("title",               "John Doe's Weavver Feed");
       writer.WriteElementString("link",                "http://my.weavver.com");
       writer.WriteElementString("language",            "en-us");
       writer.WriteElementString("description",         "");
       writer.WriteElementString("copyright",           "Copyright 2002-2003 Feed");
       writer.WriteElementString("generator",           "Weavver Syndication");
       return writer;
 }
コード例 #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int i = 0;

        //Note: You need to change the domain name "myasp-net.com and ex-designz.net" to your site domain
        Response.Clear();
        Response.ContentType = "text/xml";
        XmlTextWriter objX = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
        objX.WriteStartDocument();
        objX.WriteStartElement("rss");
        objX.WriteAttributeString("version", "2.0");
        objX.WriteStartElement("channel");
        objX.WriteElementString("title", "VGuitar.net những bài hát yêu thích nhất RRS");
        objX.WriteElementString("link", "http://thlb.biz");
        objX.WriteElementString("description", "Lyric database from around the world");
        objX.WriteElementString("copyright", "(c) 2009, thlb.biz");
        objX.WriteElementString("ttl", "10");

        //Get datatable
        IDataReader dr = Blogic.ActionProcedureDataProvider.GetRSSMostPopularLyric;

        //loop through all record, and write XML for each item.
        for (i = 0; i <= 20 - 1; i++)
        {
            dr.Read();
            objX.WriteStartElement("item");
            objX.WriteElementString("title", dr["Name"].ToString());
            objX.WriteElementString("link", "http://thlb.biz?rid=" + (int)dr["ID"]);
            objX.WriteElementString("pubDate", Convert.ToDateTime(dr["Date"]).ToShortDateString());
            objX.WriteEndElement();
        }

        dr.Close();

        //End of XML file
        objX.WriteEndElement();
        objX.WriteEndElement();
        objX.WriteEndDocument();

        //Close the XmlTextWriter object
        objX.Flush();
        objX.Close();
        Response.End();
    }
コード例 #14
0
    public void GetRssFeedContens(AspxCommonInfo aspxCommonObj, string pageURL, string rssOption, int count)
    {
        try
        {
            string[] path = pageURL.Split('?');
            string pagepath = path[0];
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ContentType = "text/xml";
            XmlTextWriter rssXml = new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8);

            rssXml.WriteStartDocument();
                      
            rssXml.WriteStartElement("rss");
            rssXml.WriteAttributeString("version", "2.0");
            rssXml.WriteStartElement("channel");
            rssXml.WriteElementString("link", pagepath);
            switch (rssOption)
            {
                case "populartags":
                    rssXml.WriteElementString("title", getLocale("AspxCommerce Popular Tags"));
                    GetPopularTagRssFeedContent(aspxCommonObj, rssXml, pageURL, rssOption, count);
                    break;

                case "newtags":
                    rssXml.WriteElementString("title", getLocale("AspxCommerce New Tag"));
                    GetNewItemTagRssFeedContent(aspxCommonObj, rssXml, pageURL, rssOption, count);
                    break;

                default:
                    break;
            }
            rssXml.WriteEndElement();
            rssXml.WriteEndElement();
            rssXml.WriteEndDocument();
            rssXml.Flush();
            rssXml.Close();
            HttpContext.Current.Response.End();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
コード例 #15
0
ファイル: newrssxml.aspx.cs プロジェクト: ranukhandelwal/EC
    protected void Page_Load(object sender, EventArgs e)
    {
        int i = 0;

        //Note: You need to change the domain name "myasp-net.com and ex-designz.net" to your site domain
        Response.Clear();
        Response.ContentType = "text/xml";
        XmlTextWriter objX = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
        objX.WriteStartDocument();
        objX.WriteStartElement("rss");
        objX.WriteAttributeString("version", "2.0");
        objX.WriteStartElement("channel");
        objX.WriteElementString("title", "ExamCrazy.com Newest RSS Feed");
        objX.WriteElementString("link", "http://www.examcrazy.com");
        objX.WriteElementString("description", "ExamCrazy.Com RSS");
        objX.WriteElementString("copyright", "(c) 2005, ExamCrazy.Com. All rights reserved.");
        objX.WriteElementString("ttl", "10");

        //Get data
        IDataReader dr = Blogic.ActionProcedureDataProvider.GetRssNewFeed;

        //loop through all record, and write XML for each item.
        for (i = 0; (i <= 20 - 1) && (dr.Read() == true); i++)
        {
            objX.WriteStartElement("item");
            objX.WriteElementString("title", dr["Title"].ToString());
            objX.WriteElementString("link", dr["Title"].ToString());
            objX.WriteElementString("pubDate", Convert.ToDateTime(dr["DatePublished"]).ToShortDateString());
            objX.WriteEndElement();
        }

        dr.Close();

        //End of XML file
        objX.WriteEndElement();
        objX.WriteEndElement();
        objX.WriteEndDocument();

        //Close the XmlTextWriter object
        objX.Flush();
        objX.Close();
        Response.End();
    }
コード例 #16
0
ファイル: SiteMap.aspx.cs プロジェクト: ivladyka/OurTravels
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();
        Response.ContentType = "text/xml";
        XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
        writer.WriteStartDocument();
        writer.WriteStartElement("urlset");
        writer.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");

        VikkiSoft_BLL.Country cont = new VikkiSoft_BLL.Country();
        if (cont.LoadSiteMap())
        {
            string siteUrl = Request.Url.Scheme + Uri.SchemeDelimiter + System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
            if (!Request.Url.IsDefaultPort)
            {
                siteUrl += ":" + Request.Url.Port;
            }
            siteUrl += "/";
            AddURL(writer, siteUrl, "Default.aspx", cont.DateUpdate);
            AddURL(writer, siteUrl, "Blogs.aspx", cont.DateUpdate);
            do
            {
                string url = "";
                if (cont.GetColumn("BlogPageID").ToString() != "0")
                {
                    url = Utils.GenerateFriendlyURL("page", new string[] { cont.GetColumn("BlogPageID").ToString(), cont.GetColumn("BlogPageName_en").ToString() }, false);
                }
                else if(cont.GetColumn("CityName").ToString() == "")
                {
                    url = Utils.GenerateFriendlyURL("country", new string[] { cont.GetColumn("CountryName").ToString() }, false);
                }
                else{
                    url = Utils.GenerateFriendlyURL("city", new string[] { cont.GetColumn("CountryName").ToString(), cont.GetColumn("CityName").ToString() }, false);
                }
                AddURL(writer, siteUrl, url, cont.DateUpdate);
            } while (cont.MoveNext());
        }

        writer.WriteEndElement();
        writer.WriteEndDocument();
        writer.Flush();
        Response.End();
    }
コード例 #17
0
    static void Main()
    {
        string path = "../../../xml/directory-tree-xmlwriter.xml";
        Encoding encoding = Encoding.GetEncoding("utf-8");   

        string rootPath = "C:\\Program Files\\Microsoft Office";
        DirectoryInfo root = new DirectoryInfo(rootPath);
        
        using (xtw = new XmlTextWriter(path, encoding))
        {
            xtw.WriteStartDocument();
            xtw.WriteStartElement("root-path");
            xtw.WriteAttributeString("dir", rootPath);

            TraverseDir(root);

            xtw.WriteEndElement();
            xtw.WriteEndDocument();
        }       
    }
コード例 #18
0
ファイル: Program.cs プロジェクト: krumov/telerik
    static void Main()
    {
        string fileName = @"..\..\..\8. album.xml";
        Encoding encoding = Encoding.GetEncoding("windows-1251");

        // reading the catalog
        using (XmlReader reader = XmlReader.Create(@"..\..\..\01.Catalog.xml"))
        {
            using (XmlTextWriter writer = new XmlTextWriter(fileName, encoding))
            {
                writer.Formatting = Formatting.Indented;
                writer.IndentChar = '\t';
                writer.Indentation = 1;

                writer.WriteStartDocument();
                writer.WriteStartElement("AlbumsCatalogSimplified");
                writer.WriteAttributeString("name", "Albums catalog");

                while (reader.Read())
                {

                    if ((reader.NodeType == XmlNodeType.Element))
                    {
                        if (reader.Name == "name")
                        {
                            writer.WriteStartElement("album"); // opening tag <album>
                            writer.WriteElementString("name", reader.ReadElementString()); //<name>...</name>
                        }
                        if (reader.Name == "artist")
                        {
                            writer.WriteElementString("artist", reader.ReadElementString()); //<artist>...</artist>
                            writer.WriteEndElement(); //closing tab </album>
                        }
                    }
                }
            }
        }

        Console.WriteLine("album.xml created!");
    }
コード例 #19
0
 public static void Main()
 {
     string fileName = "../../books.xml";
     Encoding encoding = Encoding.GetEncoding("windows-1251");
     using (XmlTextWriter writer = new XmlTextWriter(fileName, encoding))
     {
         writer.Formatting = Formatting.Indented;
         writer.IndentChar = '\t';
         writer.Indentation = 1;
     
         writer.WriteStartDocument();
         writer.WriteStartElement("library");
         writer.WriteAttributeString("name", "My Library");
         WriteBook(writer, "Code Complete",
             "Steve McConnell", "155-615-484-4");
         WriteBook(writer, "Въведение в програмирането със C#",
             "Светлин Наков и колектив", "954-775-305-3");
         WriteBook(writer, "Writing Solid Code",
             "Steve Maguire", "155-615-551-4");
         writer.WriteEndDocument();
     }
     Console.WriteLine("Document {0} created.", fileName);
 }
コード例 #20
0
    public static void CreateXMLForDirectory(string sourceDirectory, XmlTextWriter writer)
    {
        try
        {

            FileInfo fileInfoSource = new FileInfo(sourceDirectory);

            writer.WriteStartElement("directory");
            writer.WriteAttributeString("name", fileInfoSource.Name);

            var files = Directory.EnumerateFiles(sourceDirectory);
            foreach (var file in files)
            {
                FileInfo fileInfo = new FileInfo(file);
                writer.WriteStartElement("file");
                writer.WriteElementString("name", fileInfo.Name);
                writer.WriteElementString("type", fileInfo.Extension);
                writer.WriteEndElement();
            }

            var directories = Directory.EnumerateDirectories(sourceDirectory);
            foreach (var directory in directories)
            {

                CreateXMLForDirectory(directory, writer);

            }

            writer.WriteEndElement();
        }
        catch (Exception e)
        {

            throw new ArgumentException("Error" + e.Message);
        }
    }
コード例 #21
0
 public override void Save(XmlTextWriter writer)
 {
     base.Save(writer);
     writer.WriteAttributeString("id", _skill.Index.ToString());
 }
コード例 #22
0
        /// <summary>
        /// Serialize Alert header (everything except results)
        /// </summary>
        /// <returns></returns>

        private string SerializeHeader()
        {
            XmlMemoryStreamTextWriter mstw = new XmlMemoryStreamTextWriter();
            XmlTextWriter             tw   = mstw.Writer;

            tw.Formatting = Formatting.Indented;
            tw.WriteStartElement("Alert");

            tw.WriteAttributeString("Owner", Owner);
            tw.WriteAttributeString("QueryObjId", QueryObjId.ToString());
            tw.WriteAttributeString("Interval", Interval.ToString());
            tw.WriteAttributeString("MailTo", MailTo);
            tw.WriteAttributeString("LastCheck", LastCheck.ToString());
            tw.WriteAttributeString("LastCheckElapsedTime", LastCheckExecutionTime.ToString());
            tw.WriteAttributeString("NewCompounds", NewCompounds.ToString());
            tw.WriteAttributeString("ChangedCompounds", ChangedCompounds.ToString());
            tw.WriteAttributeString("NewRows", NewRows.ToString());
            tw.WriteAttributeString("TotalRows", TotalRows.ToString());
            tw.WriteAttributeString("TotalCompounds", TotalCompounds.ToString());
            tw.WriteAttributeString("CheckTablesWithCriteriaOnly", CheckTablesWithCriteriaOnly.ToString());
            tw.WriteAttributeString("LastNewData", LastNewData.ToString());
            tw.WriteAttributeString("HighlightChangedCompounds", HighlightChangedCompounds.ToString());
            tw.WriteAttributeString("RunImmediately", RunImmediately.ToString());
            tw.WriteAttributeString("Pattern", Pattern);
            tw.WriteAttributeString("StartTime", GetEasternStandardFromLocalTime(StartTime).ToShortTimeString());
            if (!String.IsNullOrEmpty(Days))
            {
                tw.WriteAttributeString("Days", Days);
            }
            if (DayInterval > 0)
            {
                tw.WriteAttributeString("DayInterval", DayInterval.ToString());
            }

            if (ExportParms != null)
            {
                ExportParms.QueryId = QueryObjId;
                string ext = System.IO.Path.GetExtension(ExportParms.OutputFileName);
                ExportParms.OutputFileName2 = Id + ext;                 // save under alert Id if not saving to a share
                ExportParms.Serialize(tw);
            }

            tw.WriteEndElement();             // end of Alert

            string xml = mstw.GetXmlAndClose();

            return(xml);
        }
コード例 #23
0
ファイル: timelineUserXML.aspx.cs プロジェクト: sedogo/Sedogo
    //===============================================================
    // Function: CreateXMLContent
    //===============================================================
    private void CreateXMLContent(XmlTextWriter writer, int userID)
    {
        SedogoUser user = new SedogoUser(Session["loggedInUserFullName"].ToString(), userID);

        SqlConnection conn = new SqlConnection((string)Application["connectionString"]);
        try
        {
            conn.Open();

            SqlCommand cmd = new SqlCommand("", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "spSelectFullEventListByCategory";
            cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = userID;
            cmd.Parameters.Add("@ShowPrivate", SqlDbType.Bit).Value = false;

            DbDataReader rdr = cmd.ExecuteReader();
            while (rdr.Read())
            {
                int categoryID = 1;
                string dateType = "D";
                DateTime startDate = DateTime.MinValue;
                DateTime rangeStartDate = DateTime.MinValue;
                DateTime rangeEndDate = DateTime.MinValue;
                int beforeBirthday = -1;
                Boolean privateEvent = false;
                Boolean eventAchieved = false;

                DateTime timelineStartDate = DateTime.MinValue;
                DateTime timelineEndDate = DateTime.MinValue;

                //*New
                string eventPicThumbnail = "";
                //

                int eventID = int.Parse(rdr["EventID"].ToString());
                string eventName = (string)rdr["EventName"];
                if (!rdr.IsDBNull(rdr.GetOrdinal("DateType")))
                {
                    dateType = (string)rdr["DateType"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("StartDate")))
                {
                    startDate = (DateTime)rdr["StartDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("RangeStartDate")))
                {
                    rangeStartDate = (DateTime)rdr["RangeStartDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("RangeEndDate")))
                {
                    rangeEndDate = (DateTime)rdr["RangeEndDate"];
                }
                eventAchieved = (Boolean)rdr["EventAchieved"];
                if (!rdr.IsDBNull(rdr.GetOrdinal("CategoryID")))
                {
                    categoryID = int.Parse(rdr["CategoryID"].ToString());
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("BeforeBirthday")))
                {
                    beforeBirthday = int.Parse(rdr["BeforeBirthday"].ToString());
                }
                privateEvent = (Boolean)rdr["PrivateEvent"];

                //*New
                if (!rdr.IsDBNull(rdr.GetOrdinal("EventPicThumbnail")))
                {
                    eventPicThumbnail = (string)rdr["EventPicThumbnail"];
                }

                string EUserName = string.Empty;
                if (!rdr.IsDBNull(rdr.GetOrdinal("CreatedByFullName")))
                {
                    EUserName = (string)rdr["CreatedByFullName"];
                }
                //

                if (dateType == "D")
                {
                    // Event occurs on a specific date

                    timelineStartDate = startDate;
                    timelineEndDate = startDate.AddDays(28);        // Add 28 days so it shows up
                }
                if (dateType == "R")
                {
                    // Event occurs in a date range - use the start date

                    timelineStartDate = rangeStartDate;
                    timelineEndDate = rangeEndDate;

                    TimeSpan ts = timelineEndDate - timelineStartDate;
                    if (ts.Days < 28)
                    {
                        timelineEndDate = startDate.AddDays(28);        // Add 28 days so it shows up
                    }

                    startDate = rangeStartDate;
                }
                if (dateType == "A")
                {
                    // Event occurs before birthday

                    timelineStartDate = DateTime.Now;
                    if (user.birthday > DateTime.MinValue)
                    {
                        timelineEndDate = user.birthday.AddYears(beforeBirthday);

                        TimeSpan ts = timelineEndDate - DateTime.Now;   // timelineStartDate.AddYears(beforeBirthday);
                        if (ts.Days < 0)
                        {
                            // Birthday was in the past
                            timelineStartDate = DateTime.Now;
                            timelineEndDate = timelineStartDate.AddDays(28);        // Add 28 days so it shows up

                            // Set start date so event is correctly placed below
                            startDate = DateTime.Now.AddDays(ts.Days);
                        }
                        else if (ts.Days >= 0 && ts.Days < 28)
                        {
                            // Birthday is within 28 days - extend the timeline a bit
                            timelineEndDate = timelineStartDate.AddDays(28);        // Add 28 days so it shows up

                            startDate = timelineStartDate;
                        }
                        else
                        {
                            startDate = timelineStartDate;
                        }
                    }
                    else
                    {
                        timelineEndDate = DateTime.Now.AddDays(28);
                    }
                }

                string timelineColour = "#cd3301";
                string category = "";
                switch (categoryID)
                {
                    case 1:
                        timelineColour = "#cd3301";
                        category = "Personal";
                        break;
                    case 2:
                        timelineColour = "#ff0b0b";
                        category = "Travel";
                        break;
                    case 3:
                        timelineColour = "#ff6801";
                        category = "Friends";
                        break;
                    case 4:
                        timelineColour = "#ff8500";
                        category = "Family";
                        break;
                    case 5:
                        timelineColour = "#d5b21a";
                        category = "General";
                        break;
                    case 6:
                        timelineColour = "#8dc406";
                        category = "Health";
                        break;
                    case 7:
                        timelineColour = "#5b980c";
                        category = "Money";
                        break;
                    case 8:
                        timelineColour = "#079abc";
                        category = "Education";
                        break;
                    case 9:
                        timelineColour = "#5ab6cd";
                        category = "Hobbies";
                        break;
                    case 10:
                        timelineColour = "#8A67C1";
                        category = "Work";
                        break;
                    case 11:
                        timelineColour = "#E54ECF";
                        category = "Culture";
                        break;
                    case 12:
                        timelineColour = "#A5369C";
                        category = "Charity";
                        break;
                    case 13:
                        timelineColour = "#A32672";
                        category = "Green";
                        break;
                    case 14:
                        timelineColour = "#669";
                        category = "Misc";
                        break;
                }

                int messageCount = SedogoEvent.GetCommentCount(eventID);
                int trackingUserCount = SedogoEvent.GetTrackingUserCount(eventID);
                int memberUserCount = SedogoEvent.GetMemberUserCount(eventID);

                //string linkURL = "&lt;a href=\"viewEvent.aspx?EID=" + eventID.ToString() + "\" class=\"modal\" title=\"\"&gt;Full details&lt;/a&gt;";
                //string linkURL = trackingUserCount.ToString() + " following this goal<br/>";
                //linkURL = linkURL + memberUserCount.ToString() + " members<br/>";
                //linkURL = linkURL + messageCount.ToString() + " comments<br/>";
                //linkURL = linkURL + "&lt;a href=\"javascript:openEvent(" + eventID.ToString() + ")\" title=\"\"&gt;Full details&lt;/a&gt;";

                //* New
                string linkURL = timelineStartDate.ToString("ddd dd MMM yyyy") + "<br/><br/>";
                linkURL = linkURL + trackingUserCount.ToString() + " Followers<br/>";
                linkURL = linkURL + memberUserCount.ToString() + " Members<br/>";
                linkURL = linkURL + messageCount.ToString() + " Comments<br/>";
                linkURL = linkURL + "&lt;a style=\"text-decoration:underline;\" href=\"javascript:openEvent(" + eventID.ToString() + ")\" title=\"\"&gt;Goal details&lt;/a&gt;";
                linkURL = linkURL + "  &lt;a style=\"text-decoration:underline;\" href=\"javascript:viewProfile(" + userID.ToString() + ")\" title=\"\"&gt;Profile&lt;/a&gt;";

                string ImgLink = "|" + EUserName + " &lt;a href=\"javascript:doSendMessage(" + userID.ToString() + ")\"&gt;&lt;img src=\"images/ico_messages.gif\" title=\"Send Message\" alt=\"Send Message\" /&gt;&lt;/a&gt;";
                //string ImgLink = "|" + EUserName;
                //*

                writer.WriteStartElement("event");      // Time format: Feb 27 2009 09:00:00 GMT
                writer.WriteAttributeString("start", timelineStartDate.ToString("MMM dd yyyy HH:mm:ss 'GMT'"));
                writer.WriteAttributeString("end", timelineEndDate.ToString("MMM dd yyyy HH:mm:ss 'GMT'"));
                writer.WriteAttributeString("isDuration", "true");
                writer.WriteAttributeString("title", eventName);

                //* New
                if (eventPicThumbnail == "")
                {
                    writer.WriteAttributeString("image", "./images/eventThumbnailBlank.png");
                }
                else
                {
                    writer.WriteAttributeString("image", "./assets/eventPics/" + eventPicThumbnail);
                }
                //writer.WriteAttributeString("image", "http://simile.mit.edu/images/csail-logo.gif");
                //*

                writer.WriteAttributeString("color", timelineColour);
                writer.WriteAttributeString("category", category);
                writer.WriteString(linkURL + " &lt;br /&gt;" + ImgLink);
                writer.WriteEndElement();
            }
            rdr.Close();
        }
        catch (Exception ex)
        {
            ErrorLog errorLog = new ErrorLog();
            errorLog.WriteLog("timelineUserXML", "Page_Load", ex.Message, logMessageLevel.errorMessage);
            //throw ex;
        }
        finally
        {
            conn.Close();
        }
    }
コード例 #24
0
    /// <summary>
    /// Saves the space.
    /// </summary>
    public static void SaveSpace()
    {
        bool directoryExists = Directory.Exists(directory);
        bool fileExists = File.Exists(directory + "CreatedWorlds.xml");

        if(directoryExists && fileExists)
        {
            List<WorldSpecs> existingSpecs = GetCreatedWorlds();
            bool skipSaving = false;
            foreach(WorldSpecs obj in existingSpecs)
            {
                if(obj.spaceName == worldspec.spaceName)
                {
                    skipSaving = true;
                }
            }
            if(!skipSaving)
            {
                existingSpecs.Add(worldspec);
                XmlTextWriter writer = new XmlTextWriter( directory + "CreatedWorlds.xml" , System.Text.Encoding.UTF8);
                writer.WriteStartDocument();
                writer.WriteStartElement("Root");
                writer.WriteWhitespace("\n");
                foreach(WorldSpecs obj in existingSpecs)
                {
                    writer.WriteWhitespace("\t");
                    writer.WriteStartElement("WorldSpec");
                    writer.WriteAttributeString("name", obj.spaceName);
                    writer.WriteAttributeString("area", obj.spaceArea.ToString());
                    writer.WriteAttributeString("spaceLength", obj.mapLength.ToString());
                    writer.WriteAttributeString("cellLength", obj.cellLength.ToString());
                    writer.WriteAttributeString("start-x", obj.start.x.ToString());
                    writer.WriteAttributeString("start-y",obj.start.y.ToString());
                    writer.WriteAttributeString("degreeJump", obj.degreeJumpStep.ToString());
                    writer.WriteAttributeString("subdivisions", obj.subdivisions.ToString());
                    writer.WriteAttributeString("numOfCells", obj.totalNumberOfCells.ToString());
                    writer.WriteAttributeString("Seed", obj.seed.ToString());
                    if(obj.planetPositions.Length > 0)
                    {
                        for(int i = 0; i < obj.planetPositions.Length; i++)
                        {
                            writer.WriteAttributeString("pPos-x" + i,obj.planetPositions[i].x.ToString());
                            writer.WriteAttributeString("pPos-y" + i,obj.planetPositions[i].y.ToString());
                        }
                    }
                    writer.WriteEndElement();
                    writer.WriteWhitespace("\n");
                }
                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Close();

            }
            //read the entire xml data populate it into a list and several data fields to resave
        }
        else if(directoryExists && !fileExists)
        {
            XmlTextWriter writer = new XmlTextWriter( directory + "CreatedWorlds.xml" , System.Text.Encoding.UTF8);

            writer.WriteStartDocument();
            writer.WriteStartElement("Root");
            writer.WriteWhitespace("\n\t");
            writer.WriteStartElement("WorldSpec");
            writer.WriteAttributeString("name", worldspec.spaceName.ToString());
            writer.WriteAttributeString("area", worldspec.spaceArea.ToString());
            writer.WriteAttributeString("spaceLength", worldspec.mapLength.ToString());
            writer.WriteAttributeString("cellLength", worldspec.cellLength.ToString());
            writer.WriteAttributeString("start-x", worldspec.start.x.ToString());
            writer.WriteAttributeString("start-y",worldspec.start.y.ToString());
            writer.WriteAttributeString("degreeJump", worldspec.degreeJumpStep.ToString());
            writer.WriteAttributeString("subdivisions", worldspec.subdivisions.ToString());
            writer.WriteAttributeString("numOfCells", worldspec.totalNumberOfCells.ToString());
            writer.WriteAttributeString("Seed", worldspec.seed.ToString());
            if(worldspec.planetPositions.Length > 0)
            {
                for(int i = 0; i < worldspec.planetPositions.Length; i++)
                {
                    writer.WriteAttributeString("pPos-x" + i,worldspec.planetPositions[i].x.ToString());
                    writer.WriteAttributeString("pPos-y" + i,worldspec.planetPositions[i].y.ToString());
                }
            }
            writer.WriteEndElement();
            writer.WriteWhitespace("\n");
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
            //create just the new file with the new world
        }
        else if(!directoryExists && !fileExists)
        {
            Directory.CreateDirectory(directory);

            XmlTextWriter writer = new XmlTextWriter( directory + "CreatedWorlds.xml" , System.Text.Encoding.UTF8);

            writer.WriteStartDocument();

            writer.WriteStartElement("Root");
            writer.WriteWhitespace("\n\t");
            writer.WriteStartElement("WorldSpec");
            writer.WriteAttributeString("name", worldspec.spaceName);
            writer.WriteAttributeString("area", worldspec.spaceArea.ToString());
            writer.WriteAttributeString("spaceLength", worldspec.mapLength.ToString());
            writer.WriteAttributeString("cellLength", worldspec.cellLength.ToString());
            writer.WriteAttributeString("start-x", worldspec.start.x.ToString());
            writer.WriteAttributeString("start-y",worldspec.start.y.ToString());
            writer.WriteAttributeString("degreeJump", worldspec.degreeJumpStep.ToString());
            writer.WriteAttributeString("subdivisions", worldspec.subdivisions.ToString());
            writer.WriteAttributeString("numOfCells", worldspec.totalNumberOfCells.ToString());
            writer.WriteAttributeString("Seed", worldspec.seed.ToString());
            if(worldspec.planetPositions.Length > 0)
            {
                for(int i = 0; i < worldspec.planetPositions.Length; i++)
                {
                    writer.WriteAttributeString("pPos-x" + i, worldspec.planetPositions[i].x.ToString());
                    writer.WriteAttributeString("pPos-y" + i, worldspec.planetPositions[i].y.ToString());
                }
            }
            writer.WriteEndElement();
            writer.WriteWhitespace("\n");
            writer.WriteEndElement();

            writer.WriteEndDocument();
            writer.Close();
            //create both the director and the file
        }
    }
コード例 #25
0
ファイル: ConnectionManager.cs プロジェクト: tonycody/Library
        public void Connect()
        {
            if (_disposed)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            using (DeadlockMonitor.Lock(this.ThisLock))
            {
                try
                {
                    TimeSpan timeout = new TimeSpan(0, 30, 0);

                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();

                    using (BufferStream stream = new BufferStream(_bufferManager))
                        using (XmlTextWriter writer = new XmlTextWriter(stream, new UTF8Encoding(false)))
                        {
                            writer.WriteStartDocument();

                            writer.WriteStartElement("Configuration");

                            if (_myProtocolVersion == ProtocolVersion.Version1)
                            {
                                writer.WriteStartElement("Protocol");
                                writer.WriteAttributeString("Version", "1");

                                writer.WriteEndElement(); //Protocol
                            }

                            writer.WriteEndElement(); //Configuration

                            writer.WriteEndDocument();
                            writer.Flush();
                            stream.Flush();

                            stream.Seek(0, SeekOrigin.Begin);
                            _connection.Send(stream, timeout - stopwatch.Elapsed);
                        }

                    using (Stream stream = _connection.Receive(timeout - stopwatch.Elapsed))
                        using (XmlTextReader reader = new XmlTextReader(stream))
                        {
                            while (reader.Read())
                            {
                                if (reader.NodeType == XmlNodeType.Element)
                                {
                                    if (reader.LocalName == "Protocol")
                                    {
                                        var version = reader.GetAttribute("Version");

                                        if (version == "1")
                                        {
                                            _otherProtocolVersion |= ProtocolVersion.Version1;
                                        }
                                    }
                                }
                            }
                        }

                    _protocolVersion = _myProtocolVersion & _otherProtocolVersion;

                    if (_protocolVersion == ProtocolVersion.Version1)
                    {
                        _lastSendTime = DateTime.UtcNow;

                        ThreadPool.QueueUserWorkItem(new WaitCallback(this.Pull));
                    }
                    else
                    {
                        throw new ConnectionManagerException();
                    }
                }
                catch (Exception ex)
                {
                    throw new ConnectionManagerException(ex.Message, ex);
                }
            }
        }
コード例 #26
0
ファイル: CBWProcessor.cs プロジェクト: schani/bwprocessor
    public override void Save(string filename)
    {
        XmlTextWriter tw = new XmlTextWriter (filename, null);

        tw.Formatting = Formatting.Indented;

        tw.WriteStartDocument ();
        tw.WriteStartElement ("bw");

        tw.WriteElementString ("load", imageFilename);

        tw.WriteStartElement ("mixer");
        tw.WriteAttributeString ("red", Red.ToString ());
        tw.WriteAttributeString ("green", Red.ToString ());
        tw.WriteAttributeString ("blue", Red.ToString ());
        tw.WriteEndElement ();

        tw.WriteStartElement ("contrast");
        tw.WriteStartElement ("curve");
        for (uint i = 0; i < contrastCurve.NumPoints (); ++i) {
            float x, y;
            contrastCurve.GetPoint (i, out x, out y);
            tw.WriteStartElement ("point");
            tw.WriteAttributeString ("x", x.ToString ());
            tw.WriteAttributeString ("y", y.ToString ());
            tw.WriteEndElement ();
        }
        tw.WriteEndElement ();
        tw.WriteEndElement ();

        tw.WriteStartElement ("tint");
        tw.WriteAttributeString ("hue", TintHue.ToString ());
        tw.WriteAttributeString ("amount", TintAmount.ToString ());
        tw.WriteEndElement ();

        tw.WriteEndElement ();
        tw.Flush ();
        tw.Close ();
    }
コード例 #27
0
        public void marshal(Svx svx, MemoryStream stream)
        {
            //XmlWriter writer = new XmlTextWriter(ExportUtils.getExecutableDir() + ExportConstants.DEBUG_FILENAME, null); // For debugging

            XmlWriter writer = new XmlTextWriter(stream, null);

            writer.WriteStartDocument();

            writer.WriteStartElement("svx");
            writer.WriteAttributeString("xmlns", ExportConstants.XMLNS);
            writer.WriteAttributeString("xmlns:xsi", ExportConstants.XSI);
            writer.WriteAttributeString("xsi:schemaLocation", ExportConstants.XSI_LOCATION);

            // Event

            Event event_ = svx.Event;

            writer.WriteStartElement("event");
            writer.WriteAttributeString("date", event_.Date);
            writer.WriteAttributeString("location", event_.Location);
            writer.WriteAttributeString("homeTeam", event_.HomeTeam);
            writer.WriteAttributeString("awayTeam", event_.AwayTeam);
            writer.WriteEndElement();

            // Clips

            writer.WriteStartElement("clips");

            foreach (Clip clip in svx.Clips)
            {
                writer.WriteStartElement("clip");
                writer.WriteAttributeString("start", Convert.ToString(clip.Start));
                writer.WriteAttributeString("team", clip.Team);
                writer.WriteAttributeString("filename", clip.Filename);

                if (clip.Categories != null && clip.Categories.Count > 0)
                {
                    writer.WriteStartElement("categories");
                    foreach (string category in clip.Categories)
                    {
                        writer.WriteStartElement("category");
                        writer.WriteString(category);
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                }

                if (clip.Persons != null && clip.Persons.Count > 0)
                {
                    writer.WriteStartElement("persons");
                    foreach (string person in clip.Persons)
                    {
                        writer.WriteStartElement("person");
                        writer.WriteString(person);
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
            }

            writer.WriteEndElement();

            writer.WriteEndElement();

            writer.WriteEndDocument();
            writer.Close();
        }
コード例 #28
0
ファイル: Log4JXmlEvent.cs プロジェクト: NecroSharper/WCell
        /// <summary>
        /// Renders the XML logging event and appends it to the specified <see cref="StringBuilder" />.
        /// </summary>
        /// <param name="builder">The <see cref="StringBuilder"/> to append the rendered data to.</param>
        /// <param name="logEvent">Logging event.</param>
        protected internal override void Append(StringBuilder builder, LogEventInfo logEvent)
        {
            StringWriter  sw  = new StringWriter(builder);
            XmlTextWriter xtw = new XmlTextWriter(sw);

            if (IndentXml)
            {
                xtw.Formatting = Formatting.Indented;
            }

            xtw.WriteStartElement("log4j:event");
            xtw.WriteAttributeString("logger", logEvent.LoggerName);
            xtw.WriteAttributeString("level", logEvent.Level.Name.ToUpper());
            xtw.WriteAttributeString("timestamp", Convert.ToString((long)(logEvent.TimeStamp.ToUniversalTime() - _log4jDateBase).TotalMilliseconds));
#if !NETCF
            xtw.WriteAttributeString("thread", NLog.Internal.ThreadIDHelper.Instance.CurrentThreadID.ToString());
#else
            xtw.WriteElementString("thread", "");
#endif

            xtw.WriteElementString("log4j:message", logEvent.FormattedMessage);
            if (IncludeNDC)
            {
                xtw.WriteElementString("log4j:NDC", NDC.GetAllMessages(" "));
            }
#if !NETCF
            if (IncludeCallSite || IncludeSourceInfo)
            {
                System.Diagnostics.StackFrame frame = logEvent.UserStackFrame;
                MethodBase methodBase = frame.GetMethod();
                Type       type       = methodBase.DeclaringType;

                xtw.WriteStartElement("log4j:locationinfo");
                xtw.WriteAttributeString("class", type.FullName);
                xtw.WriteAttributeString("method", methodBase.ToString());
                if (IncludeSourceInfo)
                {
                    xtw.WriteAttributeString("file", frame.GetFileName());
                    xtw.WriteAttributeString("line", frame.GetFileLineNumber().ToString());
                }
                xtw.WriteEndElement();

                if (IncludeNLogData)
                {
                    xtw.WriteElementString("nlog:eventSequenceNumber", logEvent.SequenceID.ToString());
                    xtw.WriteStartElement("nlog:locationinfo");
                    xtw.WriteAttributeString("assembly", type.Assembly.FullName);
                    xtw.WriteEndElement();
                }
            }
#endif
            xtw.WriteStartElement("log4j:properties");
            if (IncludeMDC)
            {
                foreach (KeyValuePair <string, string> entry in MDC.GetThreadDictionary())
                {
                    xtw.WriteStartElement("log4j:data");
                    xtw.WriteAttributeString("name", entry.Key);
                    xtw.WriteAttributeString("value", entry.Value);
                    xtw.WriteEndElement();
                }
            }

            foreach (NLogViewerParameterInfo parameter in Parameters)
            {
                xtw.WriteStartElement("log4j:data");
                xtw.WriteAttributeString("name", parameter.Name);
                xtw.WriteAttributeString("value", parameter.CompiledLayout.GetFormattedMessage(logEvent));
                xtw.WriteEndElement();
            }

            xtw.WriteStartElement("log4j:data");
            xtw.WriteAttributeString("name", "log4japp");
            xtw.WriteAttributeString("value", AppInfo);
            xtw.WriteEndElement();

            xtw.WriteStartElement("log4j:data");
            xtw.WriteAttributeString("name", "log4jmachinename");
#if NETCF
            xtw.WriteAttributeString("value", "netcf");
#else
            xtw.WriteAttributeString("value", NLog.LayoutRenderers.MachineNameLayoutRenderer.MachineName);
#endif
            xtw.WriteEndElement();
            xtw.WriteEndElement();

            xtw.WriteEndElement();
            xtw.Flush();
        }
コード例 #29
0
ファイル: SitemapManager.cs プロジェクト: hunii/a-blogsite
    /// <summary>
    /// Create the sitemap for a domain
    /// </summary>
    /// <param name="domain">A reference to the domain</param>
    /// <param name="priorityCategories">The priority for categories</param>
    /// <param name="priorityPosts">The priority for posts</param>
    /// <param name="changeFrequency">The change frequency</param>
    public static void CreateSitemap(Domain domain, string priorityCategories, string priorityPosts, string changeFrequency)
    {
        // Create the directory path
        string directoryPath = HttpContext.Current.Server.MapPath("/Content/domains/" + domain.id.ToString() + "/sitemaps/");

        // Check if the directory exists
        if (System.IO.Directory.Exists(directoryPath) == false)
        {
            // Create the directory
            System.IO.Directory.CreateDirectory(directoryPath);
        }

        // Create the file
        string filepath = directoryPath + "Sitemap.xml.gz";

        // Get categories, products and static pages
        List<Category> categories = Category.GetAll(domain.front_end_language, "title", "ASC");
        List<Post> posts = Post.GetAll(domain.front_end_language, "title", "ASC");

        // Create variables
        GZipStream gzipStream = null;
        XmlTextWriter xmlTextWriter = null;

        try
        {
            // Create a gzip stream
            gzipStream = new GZipStream(new FileStream(filepath, FileMode.Create), CompressionMode.Compress);

            // Create a xml text writer
            xmlTextWriter = new XmlTextWriter(gzipStream, new UTF8Encoding(true));

            // Write the start of the document
            xmlTextWriter.WriteStartDocument();

            // Write the url set for the xml document <urlset>
            xmlTextWriter.WriteStartElement("urlset");
            xmlTextWriter.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");
            xmlTextWriter.WriteAttributeString("xmlns:image", "http://www.google.com/schemas/sitemap-image/1.1");
            xmlTextWriter.WriteAttributeString("xmlns:video", "http://www.google.com/schemas/sitemap-video/1.1");

            // Create the start string
            string baseUrl = domain.web_address;

            // Add the baseurl
            CreateUrlPost(xmlTextWriter, baseUrl, "1.0", changeFrequency, DateTime.UtcNow);

            // Loop categories
            for (int i = 0; i < categories.Count; i++)
            {
                // Create the url post
                CreateUrlPost(xmlTextWriter, baseUrl + "/home/category/" + categories[i].page_name, priorityCategories, changeFrequency, DateTime.UtcNow);
            }

            // Loop posts
            for (int i = 0; i < posts.Count; i++)
            {
                // Create the url post
                CreateUrlPost(xmlTextWriter, baseUrl + "/home/post/" + posts[i].page_name, priorityPosts, changeFrequency, DateTime.UtcNow);
            }

            // Write the end tag for the xml document </urlset>
            xmlTextWriter.WriteEndDocument();
        }
        catch (Exception e)
        {
            throw e;
        }
        finally
        {
            // Close streams
            if (xmlTextWriter != null)
            {
                // Close the XmlTextWriter
                xmlTextWriter.Close();
            }
            if (gzipStream != null)
            {
                // Close the gzip stream
                gzipStream.Close();
            }
        }

    } // End of the CreateSitemap method
コード例 #30
0
ファイル: XmlCollada.cs プロジェクト: Gamieon/Cycles3D
 public void Save(XmlTextWriter writer)
 {
     writer.WriteStartElement(root);
     if (null != _id) { writer.WriteAttributeString(id, _id); }
     if (null != _name) { writer.WriteAttributeString(name, _name); }
     if (null != _mesh) { _mesh.Save(writer); }
     writer.WriteEndElement();
 }
コード例 #31
0
ファイル: XmlCollada.cs プロジェクト: Gamieon/Cycles3D
 public void Save(XmlTextWriter writer)
 {
     writer.WriteStartElement(root);
     if (null != _id) { writer.WriteAttributeString(id, _id); }
     writer.WriteAttributeString(count, _count.ToString());
     string valueString = "";
     for (int i = 0; i < _values.Length; i++)
     {
         valueString += _values[i] + " ";
     }
     valueString = valueString.TrimEnd();
     writer.WriteString(valueString);
     writer.WriteEndElement();
 }
コード例 #32
0
ファイル: XmlCollada.cs プロジェクト: Gamieon/Cycles3D
 public void Save(XmlTextWriter writer)
 {
     writer.WriteStartElement(root);
     if (_id != null) { writer.WriteAttributeString(id, _id); }
     if (_name != null) { writer.WriteAttributeString(name, _name); }
     if (_profileCommon != null) { _profileCommon.Save(writer); }
     writer.WriteEndElement();
 }
コード例 #33
0
ファイル: XmlCollada.cs プロジェクト: Gamieon/Cycles3D
 public void Save(XmlTextWriter writer)
 {
     writer.WriteStartElement(root);
     writer.WriteAttributeString(count, _count.ToString());
     if (null != _material) { writer.WriteAttributeString(material, _material); }
     for (int i = 0; i < _inputs.Count; i++)
     {
         Input input = (Input)_inputs.GetAt(i);
         input.Save(writer);
     }
     if (null != _vcount)
     {
         string vcountString = "";
         for (int i = 0; i < _vcount.Length; i++)
         {
             vcountString += _vcount[i].ToString() + " ";
         }
         vcountString = vcountString.TrimEnd();
         writer.WriteElementString(vcount, vcountString);
     }
     if (null != p)
     {
         string pString = "";
         for (int i = 0; i < _p.Length; i++)
         {
             pString += _p[i].ToString() + " ";
         }
         pString = pString.TrimEnd();
         writer.WriteElementString(p, pString);
     }
     writer.WriteEndElement();
 }
コード例 #34
0
ファイル: XmlCollada.cs プロジェクト: Gamieon/Cycles3D
 public void Save(XmlTextWriter writer)
 {
     writer.WriteStartElement(root);
     writer.WriteAttributeString(xmlns, "http://www.collada.org/2005/11/COLLADASchema");
     writer.WriteAttributeString(version, "1.4.1");
     if (null != _asset) { _asset.Save(writer); }
     if (null != _images) { _images.Save(writer); }
     if (null != _materials) { _materials.Save(writer); }
     if (null != _effects) { _effects.Save(writer); }
     if (null != _geometries) { _geometries.Save(writer); }
     if (null != _visualScenes) { _visualScenes.Save(writer); }
     if (null != _scene) { _scene.Save(writer); }
     writer.WriteEndElement();
 }
コード例 #35
0
ファイル: XmlCollada.cs プロジェクト: Gamieon/Cycles3D
 public void Save(XmlTextWriter writer)
 {
     writer.WriteStartElement(root);
     if (null != _id) { writer.WriteAttributeString(id, _id); }
     if (null != _name) { writer.WriteAttributeString(name, _name); }
     for (int i = 0; i < _nodes.Count; i++)
     {
         Node node = (Node)_nodes.GetAt(i);
         node.Save(writer);
     }
     writer.WriteEndElement();
 }