WriteEndElement() public method

public WriteEndElement ( ) : void
return void
示例#1
0
        public static void Main(String[] args)
        {
            DateTime            oScriptStart = DateTime.UtcNow;
            NameValueCollection oVipSettings = new NameValueCollection();
            NameValueCollection oXmlSettings = ConfigurationManager.GetSection("xmlWriterSettings") as NameValueCollection;

            //NameValueCollection oElectionAdminSettings = ConfigurationManager.GetSection("electionOfficial") as NameValueCollection;

            oVipSettings.Add("ScriptStart", oScriptStart.ToString("yyyy-MM-ddTHH:mm:ss"));
            oVipSettings.Add(ConfigurationManager.GetSection("vipSettings") as NameValueCollection);

            FeedWriter oFeedWriter = new FeedWriter(
                oVipSettings.Get("FilePath"),
                oVipSettings.Get("StateFIPS"),
                oXmlSettings
                );

            oFeedWriter.WriteStartElement("vip_object");

            oFeedWriter.WriteHeader(oVipSettings);

            // this may not be necessary if the election_officials are stored in the db
            //oFeedWriter.WriteElementFromConfig("election_official", oElectionAdminSettings);

            try {
                oFeedWriter.WritePollingPlaces();
                oFeedWriter.WriteStreetSegments();
                oFeedWriter.WritePrecincts();
                oFeedWriter.WritePrecinctSplits();
                oFeedWriter.WriteLocalities();
            } catch (Exception ex) {
                // TODO: Write success or failure to a text file
                Console.WriteLine(ex.Message.ToString());
            }


            oFeedWriter.WriteEndElement();
        }
示例#2
0
        public static void Main(String[] args)
        {
            DateTime oScriptStart = DateTime.UtcNow;

            /*NameValueCollection oAppSettings = ConfigurationManager.AppSettings;
             * NameValueCollection oDbSettings = ConfigurationManager.GetSection("dbSettings") as NameValueCollection;
             * NameValueCollection oVipSettings = ConfigurationManager.GetSection("vipSettings") as NameValueCollection;
             * NameValueCollection oXmlSettings = ConfigurationManager.GetSection("xmlWriterSettings") as NameValueCollection;
             * NameValueCollection oElectionAdminSettings = ConfigurationManager.GetSection("electionOfficial") as NameValueCollection;*/

            NameValueCollection oDbSettings            = new NameValueCollection();
            NameValueCollection oVipSettings           = new NameValueCollection();
            NameValueCollection oXmlSettings           = new NameValueCollection();
            NameValueCollection oElectionAdminSettings = new NameValueCollection();

            oDbSettings.Add("Host", "localhost");
            oDbSettings.Add("Port", "1521");
            oDbSettings.Add("Service", "VIPFEED");
            oDbSettings.Add("User", "DBSNMP");
            oDbSettings.Add("Pass", "P4SSW0RD");

            oVipSettings.Add("FilePath", "C:\\Users\\Jared\\Documents\\projects\\vip\\feeds\\");
            oVipSettings.Add("SchemaURL", "http://election-info-standard.googlecode.com/files/vip_spec_v2.2a.xsd");
            oVipSettings.Add("SchemaVer", "2.2");
            oVipSettings.Add("StateName", "State");
            oVipSettings.Add("ScriptStart", oScriptStart.ToString("yyyy-MM-ddTHH:mm:ss"));
            oVipSettings.Add("StateFIPS", "20");
            oVipSettings.Add("SourceName", "State of Somewhere");
            oVipSettings.Add("Description", "The Secretary of State is the chief state election official for the state. This feed provides information on registration, advance voting, and the location of polling locations for registered voters in the state.");
            oVipSettings.Add("OrganizationURL", "http://sos.gov");

            oXmlSettings.Add("Indent", "true");
            oXmlSettings.Add("IndentChars", "  ");
            oXmlSettings.Add("ConformanceLevel", "Fragment");

            DataConnection oDataConn   = new DataConnection(oDbSettings);
            FeedWriter     oFeedWriter = new FeedWriter(
                oVipSettings.Get("FilePath"),
                oVipSettings.Get("StateFIPS"),
                oXmlSettings
                );

            oFeedWriter.WriteStartElement("vip_object");

            oFeedWriter.WriteHeader(oVipSettings);

            // this may not be necessary if the election_officials are stored in the db
            //oFeedWriter.WriteElementFromConfig("election_official", oElectionAdminSettings);

            try {
                using (OracleConnection oConn = oDataConn.DbConnect()) {
                    oConn.Open();

                    OracleCommand oCmd = new OracleCommand();
                    oCmd.Connection = oConn;

                    oFeedWriter.WritePollingPlaces(oCmd);
                    oFeedWriter.WriteStreetSegments(oCmd);
                    oFeedWriter.WritePrecincts(oCmd);
                    oFeedWriter.WritePrecinctSplits(oCmd);
                    oFeedWriter.WriteLocalities(oCmd);
                }
            } catch (OracleException ex) {
                switch (ex.Number)
                {
                case 1:
                    Console.WriteLine("Error attempting to insert duplicate data.");
                    break;

                case 12545:
                    Console.WriteLine("The database is unavailable.");
                    break;

                default:
                    Console.WriteLine("Database error: " + ex.Message.ToString());
                    break;
                }
            } catch (Exception ex) {
                Console.WriteLine(ex.Message.ToString());
            }

            oFeedWriter.WriteEndElement();
        }
示例#3
0
        public static void Main(String[] args)
        {
            DateTime oScriptStart = DateTime.UtcNow;
            /*NameValueCollection oAppSettings = ConfigurationManager.AppSettings;
            NameValueCollection oDbSettings = ConfigurationManager.GetSection("dbSettings") as NameValueCollection;
            NameValueCollection oVipSettings = ConfigurationManager.GetSection("vipSettings") as NameValueCollection;
            NameValueCollection oXmlSettings = ConfigurationManager.GetSection("xmlWriterSettings") as NameValueCollection;
            NameValueCollection oElectionAdminSettings = ConfigurationManager.GetSection("electionOfficial") as NameValueCollection;*/

            NameValueCollection oDbSettings = new NameValueCollection();
            NameValueCollection oVipSettings = new NameValueCollection();
            NameValueCollection oXmlSettings = new NameValueCollection();
            NameValueCollection oElectionAdminSettings = new NameValueCollection();

            oDbSettings.Add("Host", "localhost");
            oDbSettings.Add("Port", "1521");
            oDbSettings.Add("Service", "VIPFEED");
            oDbSettings.Add("User", "DBSNMP");
            oDbSettings.Add("Pass", "P4SSW0RD");

            oVipSettings.Add("FilePath", "C:\\Users\\Jared\\Documents\\projects\\vip\\feeds\\");
            oVipSettings.Add("SchemaURL", "http://election-info-standard.googlecode.com/files/vip_spec_v2.2a.xsd");
            oVipSettings.Add("SchemaVer", "2.2");
            oVipSettings.Add("StateName", "State");
            oVipSettings.Add("ScriptStart", oScriptStart.ToString("yyyy-MM-ddTHH:mm:ss"));
            oVipSettings.Add("StateFIPS", "20");
            oVipSettings.Add("SourceName", "State of Somewhere");
            oVipSettings.Add("Description", "The Secretary of State is the chief state election official for the state. This feed provides information on registration, advance voting, and the location of polling locations for registered voters in the state.");
            oVipSettings.Add("OrganizationURL", "http://sos.gov");

            oXmlSettings.Add("Indent", "true");
            oXmlSettings.Add("IndentChars", "  ");
            oXmlSettings.Add("ConformanceLevel", "Fragment");

            DataConnection oDataConn = new DataConnection(oDbSettings);
            FeedWriter oFeedWriter = new FeedWriter(
                oVipSettings.Get("FilePath"),
                oVipSettings.Get("StateFIPS"),
                oXmlSettings
            );

            oFeedWriter.WriteStartElement("vip_object");

            oFeedWriter.WriteHeader(oVipSettings);

            // this may not be necessary if the election_officials are stored in the db
            //oFeedWriter.WriteElementFromConfig("election_official", oElectionAdminSettings);

            try {
                using (OracleConnection oConn = oDataConn.DbConnect()) {
                    oConn.Open();

                    OracleCommand oCmd = new OracleCommand();
                    oCmd.Connection = oConn;

                    oFeedWriter.WritePollingPlaces(oCmd);
                    oFeedWriter.WriteStreetSegments(oCmd);
                    oFeedWriter.WritePrecincts(oCmd);
            oFeedWriter.WritePrecinctSplits(oCmd);
                    oFeedWriter.WriteLocalities(oCmd);
                }

            } catch (OracleException ex) {
                switch (ex.Number) {
                    case 1:
                        Console.WriteLine("Error attempting to insert duplicate data.");
                        break;
                    case 12545:
                        Console.WriteLine("The database is unavailable.");
                        break;
                    default:
                        Console.WriteLine("Database error: " + ex.Message.ToString());
                        break;
                }
            } catch (Exception ex) {
                Console.WriteLine(ex.Message.ToString());
            }

            oFeedWriter.WriteEndElement();
        }