Ejemplo n.º 1
0
            // create period of record
            private static seriesCatalogType[] CreateSeriesCatalogRecord(int?siteID)
            {
                // need the siteID for the DB sites, and the siteCode for retrival from the service

                if (siteID.HasValue)
                {
                    seriesCatalogDataSet seriesDataset = ODSeriesCatalog.GetSeriesCatalogDataSet(siteID.Value);
                    if (seriesDataset != null && seriesDataset.SeriesCatalog.Rows.Count > 0)
                    {
                        if (seriesDataset.SeriesCatalog.Rows.Count > 0)
                        {
                            seriesCatalogType[] seriesFromDB =
                                ODSeriesCatalog.dataSet2SeriesCatalog(seriesDataset, variablesDs, vocabulariesDs);
                            if (seriesFromDB != null && seriesFromDB.Length > 0)
                            {
                                return(seriesFromDB);
                            }
                        }
                    }
                }


                // send back empty catalog
                List <seriesCatalogType> seriesList = new List <seriesCatalogType>();

                seriesList.Add(new seriesCatalogType());
                return(seriesList.ToArray());
            }
Ejemplo n.º 2
0
        private static ValuesDataSet getDataValues(ValuesDataSet ds, DateTime startDate, DateTime endDate)
        {
            //requestData = string.Empty;
            seriesCatalogDataSet sc = new seriesCatalogDataSet();

            scAdapater.FillBySiteVariable(sc.SeriesCatalog, ds.Sites[0].SiteID, ds.Variables[0].VariableID);

            Thread newThread = new Thread(ODValues.generateURL);

            newThread.Start(new reqData(ds, startDate, endDate));//URLSiteName(site), URLVariableCode(variable, site), selectStartDate(startDate, SeriesID), selectEndDate(endDate, SeriesID));
            try
            {
                // mutex.WaitOne();
                //int SeriesID = db.seriesID(site, variable);
                ds = newTable(ds.Variables[0].VariableID.ToString(), sc.SeriesCatalog[0].SeriesID, requestData);
                //return newTable(variable, SeriesID, requestData);
                return(ds);
            }
            finally
            { //mutex.ReleaseMutex();
            }

            //return new DataTable();
            //return newDataTable;
        }
Ejemplo n.º 3
0
        /*
         * newTable
         * creates the Data Table required by rest of program to create the XML form
         */
        private ValuesDataSet newTable(string variable, int SID, string Data)
        {
            SeriesCatalogTableAdapter scAdapater = new SeriesCatalogTableAdapter();

            scAdapater.Connection.ConnectionString = odws.Config.ODDB();
            ValuesDataSet ds            = basicValuesDataSet();
            DataTable     variableTable = ds.Tables[0];
            int           ValueID       = 0;

            foreach (string entry in Data.Split('\n'))
            {
                string[] row = entry.Split(',');
                if (row[0] != "" && row[0] != null)
                {
                    ValueID++;

                    seriesCatalogDataSet scTable = new seriesCatalogDataSet();
                    scAdapater.FillBySeriesID(scTable.SeriesCatalog, SID);
                    seriesCatalogDataSet.SeriesCatalogRow sc = scTable.SeriesCatalog[0];
                    TimeSpan utcOffset = sc.BeginDateTime.Subtract(sc.BeginDateTimeUTC);
                    variableTable.Rows.Add(ValueID, sc.SiteID, sc.VariableID, 0, 0, "nc", 0, sc.MethodID, sc.SourceID, 0, 0, sc.QualityControlLevelID, (row[0] == string.Empty) || row[1] == string.Empty ? -999999 : Convert.ToDouble(row[1]), 0, Convert.ToDateTime(row[0]), Convert.ToDateTime(row[0]).ToUniversalTime(), utcOffset.Hours);
                    /*"ValueID","SiteID","VariableID",offsetvalue, offset type id, "CensorCode","QualifierID","MethodID","SourceID","SampleID","DerivedFromID","QualityControlLevelID", "Value", "AccuracyStdDev", "DateTime","DateTimeUTC", "UTCOffset"*/
                }
            }

            return(ds);
        }
Ejemplo n.º 4
0
        public static ValuesDataSet getDataValues(int SiteID, int VariableID, DateTime StartDate, DateTime EndDate)
        {
            seriesCatalogDataSet      scDS = new seriesCatalogDataSet();
            SeriesCatalogTableAdapter seriesTableAdapter = new SeriesCatalogTableAdapter();

            seriesTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

            seriesTableAdapter.FillBySiteIDVariableID(scDS.SeriesCatalog, SiteID, VariableID);
            DataSet oDS = new DataSet();

            try
            {
                //   oDS = getValuesWork(scDS.SeriesCatalog, StartDate, EndDate);

                Thread thread = new Thread(delegate()
                {
                    oDS = getValuesWork(scDS.SeriesCatalog, StartDate, EndDate);
                });
                thread.Start();
                while (thread.IsAlive)
                {
                    Thread.Sleep(150);
                }
                return(newTable(scDS.SeriesCatalog, ref oDS));
            }
            catch (Exception e)
            {
                log.Fatal("Cannot retrieve information from database: " + e.Message); //+ valuesTableAdapter.Connection.DataSource
            }
            return(basicValuesDataSet());
        }
        private static seriesCatalogType createSeriesCatalog(
            seriesCatalogDataSet ds,
            VariablesDataset vds)
        {
            if (ds.SeriesCatalog.Count > 0)
            {
                Boolean useOD;

                String siteServiceURL;
                String siteServiceName;
                try
                {
                    useOD = Boolean.Parse(ConfigurationManager.AppSettings["UseODForValues"]);

                    if (!useOD)
                    {
                        siteServiceURL  = ConfigurationManager.AppSettings["externalGetValuesService"];
                        siteServiceName = ConfigurationManager.AppSettings["externalGetValuesName"];
                    }
                    else
                    {
                        siteServiceURL  = "http://localhost/";
                        siteServiceName = "OD Web Services";
                    }
                }
                catch
                {
                    useOD = true; // should be caught earlier


                    siteServiceURL  = "http://locahost/";
                    siteServiceName = "Fix UseODForValues, externalGetValuesService, externalGetValuesName";
                }
                seriesCatalogType catalog = CuahsiBuilder.CreateSeriesCatalog(
                    ds.SeriesCatalog.Count,
                    siteServiceName, // menu name (aka OD name
                    siteServiceURL   // web service location
                    );
                List <seriesCatalogTypeSeries> seriesRecords = new List <seriesCatalogTypeSeries>();
                foreach (seriesCatalogDataSet.SeriesCatalogRow row in ds.SeriesCatalog.Rows)
                {
                    seriesCatalogTypeSeries aRecord = row2SeriesCatalogElement(
                        row, ds, vds);

                    seriesRecords.Add(aRecord);
                }
                catalog.series = seriesRecords.ToArray();
                return(catalog);
            }
            else
            {
                seriesCatalogType catalog = CuahsiBuilder.CreateSeriesCatalog(0,
                                                                              null,        // menu name (aka OD name
                                                                              String.Empty // web service location
                                                                              );
                return(catalog);
            }
        }
Ejemplo n.º 6
0
            private static seriesCatalogType createSeriesCatalog(seriesCatalogDataSet ds, VariablesDataset vds, ControlledVocabularyDataset vocabularyDataset)
            {
                if (ds.SeriesCatalog.Count > 0)
                {
                    Boolean useOD;

                    String siteServiceURL;
                    String siteServiceName;
                    try
                    {
                        useOD = Boolean.Parse(ConfigurationManager.AppSettings["UseODForValues"]);

                        if (!useOD)
                        {
                            siteServiceURL = ConfigurationManager.AppSettings["externalGetValuesService"];
                            siteServiceName = ConfigurationManager.AppSettings["externalGetValuesName"];
                        }
                        else
                        {
                            siteServiceURL = "http://localhost/";
                            siteServiceName = "OD Web Services";
                        }
                    }
                    catch
                    {
                        useOD = true; // should be caught earlier

                        siteServiceURL = "http://locahost/";
                        siteServiceName = "Fix UseODForValues, externalGetValuesService, externalGetValuesName";

                    }
                    seriesCatalogType catalog = CuahsiBuilder.CreateSeriesCatalog(ds.SeriesCatalog.Count,
                                                                        siteServiceName, // menu name (aka OD name
                                                                        siteServiceURL // web service location
                            );
                    List<seriesCatalogTypeSeries> seriesRecords = new List<seriesCatalogTypeSeries>();
                    foreach (seriesCatalogDataSet.SeriesCatalogRow row in ds.SeriesCatalog.Rows)
                    {
                        seriesCatalogTypeSeries aRecord = row2SeriesCatalogElement(
                            row, ds, vds, vocabularyDataset);
                        seriesRecords.Add(aRecord);

                    }
                    catalog.series = seriesRecords.ToArray();
                    return catalog;
                }
                else
                {
                    seriesCatalogType catalog = CuahsiBuilder.CreateSeriesCatalog(0,
                                                                    null, // menu name (aka OD name
                                                                    "http://locahost/" // web service location
                        );
                    return catalog;
                }
            }
Ejemplo n.º 7
0
        private static void generateURL(object r)
        {
            reqData rData           = (reqData)r;
            seriesCatalogDataSet sc = new seriesCatalogDataSet();

            scAdapater.FillBySiteVariable(sc.SeriesCatalog, rData.DS.Sites[0].SiteID, rData.DS.Variables[0].VariableID);

            requestData = generateURL(URLSiteName(rData.DS.Sites), URLVariableCode(rData.DS.Variables, rData.DS.Sites), selectStartDate(rData.StartDate, sc.SeriesCatalog[0].SeriesID), selectEndDate(rData.EndDate, sc.SeriesCatalog[0].SeriesID));
            //newDataTable = newTable(rData.DS.Variables[0].VariableID.ToString(), sc.SeriesCatalog[0].SeriesID, requestData);


            //int SeriesID = db.seriesID(rData.Site, rData.Variable);
            //string requestData = generateURL(URLSiteName(rData.Site), URLVariableCode(rData.Variable, rData.Site), selectStartDate(rData.StartDate, SeriesID), selectEndDate(rData.EndDate, SeriesID));
            //newDataTable= newTable(rData.Variable, SeriesID, requestData);
        }
Ejemplo n.º 8
0
            public static seriesCatalogType[] dataSet2SeriesCatalog(seriesCatalogDataSet ds, VariablesDataset vds, ControlledVocabularyDataset vocabularyDataset)
            {
                /* logic
                  *   for each sourceID that is associated with the site
                  *
                  *
                  */

                List<seriesCatalogType> catalogs = new List<seriesCatalogType>();

                seriesCatalogType catalog = createSeriesCatalog(ds, vds, vocabularyDataset);
                if (catalog != null) catalogs.Add(catalog);

                return catalogs.ToArray();
            }
Ejemplo n.º 9
0
        private static DateTime selectEndDate(DateTime end, int sID)
        {
            seriesCatalogDataSet sc = new seriesCatalogDataSet();

            scAdapater.FillBySeriesID(sc.SeriesCatalog, sID);

            DateTime dbEnd = sc.SeriesCatalog[0].BeginDateTime;

            if (end < dbEnd)
            {
                return(end);
            }
            else
            {
                return(dbEnd);
            }
        }
Ejemplo n.º 10
0
        private static DateTime selectStartDate(DateTime start, int sID)
        {
            seriesCatalogDataSet sc = new seriesCatalogDataSet();

            scAdapater.FillBySeriesID(sc.SeriesCatalog, sID);

            DateTime dbStart = sc.SeriesCatalog[0].BeginDateTime;

            if (start > dbStart)
            {
                return(start);
            }
            else
            {
                return(dbStart);
            }
        }
            public static seriesCatalogType[] dataSet2SeriesCatalog(seriesCatalogDataSet ds, VariablesDataset vds, ControlledVocabularyDataset vocabularyDataset)
            {
                /* logic
                 *   for each sourceID that is associated with the site
                 *
                 *
                 */

                List <seriesCatalogType> catalogs = new List <seriesCatalogType>();

                seriesCatalogType catalog = createSeriesCatalog(ds, vds, vocabularyDataset);

                if (catalog != null)
                {
                    catalogs.Add(catalog);
                }

                return(catalogs.ToArray());
            }
Ejemplo n.º 12
0
        private DateTime selectStartDate(DateTime start, int sID)
        {
            SeriesCatalogTableAdapter scAdapater = new SeriesCatalogTableAdapter();

            scAdapater.Connection.ConnectionString = odws.Config.ODDB();
            seriesCatalogDataSet sc = new seriesCatalogDataSet();

            scAdapater.FillBySeriesID(sc.SeriesCatalog, sID);
            DateTime dbStart = sc.SeriesCatalog[0].BeginDateTime;

            if (start > dbStart)
            {
                return(start);
            }
            else
            {
                return(dbStart);
            }
        }
Ejemplo n.º 13
0
        private DateTime selectEndDate(DateTime end, int seriesID)
        {
            SeriesCatalogTableAdapter scAdapater = new SeriesCatalogTableAdapter();

            scAdapater.Connection.ConnectionString = odws.Config.ODDB();
            seriesCatalogDataSet sc = new seriesCatalogDataSet();

            scAdapater.FillBySeriesID(sc.SeriesCatalog, seriesID);
            DateTime dbEnd = sc.SeriesCatalog[0].EndDateTime;

            if (end < dbEnd)
            {
                return(end);
            }
            else
            {
                return(dbEnd);
            }
        }
Ejemplo n.º 14
0
            /// <summary>
            /// get a series catalog for a site.
            /// 
            /// </summary>
            /// <param name="siteID"></param>
            /// <returns></returns>
            public static seriesCatalogDataSet GetSeriesCatalogDataSet(int siteID)
            {
                seriesCatalogDataSet sDS = new seriesCatalogDataSet();

                SeriesCatalogTableAdapter seriesTableAdapter =
                    new SeriesCatalogTableAdapter();
                seriesTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

                try
                {
                    seriesTableAdapter.FillBySiteID(sDS.SeriesCatalog, siteID);
                }
                catch (Exception e)
                {
                    log.Fatal("Cannot retrieve information from database: " + e.Message); // + seriesTableAdapter.Connection.DataSource
                }

                return sDS;
            }
            /// <summary>
            /// get a series catalog for a site.
            ///
            /// </summary>
            /// <param name="siteID"></param>
            /// <returns></returns>
            public static seriesCatalogDataSet GetSeriesCatalogDataSet(int siteID)
            {
                seriesCatalogDataSet sDS = new seriesCatalogDataSet();

                SeriesCatalogTableAdapter seriesTableAdapter =
                    new SeriesCatalogTableAdapter();

                seriesTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

                try
                {
                    seriesTableAdapter.FillBySiteID(sDS.SeriesCatalog, siteID);
                }
                catch (Exception e)
                {
                    log.Fatal("Cannot retrieve information from database: " + e.Message); // + seriesTableAdapter.Connection.DataSource
                }

                return(sDS);
            }
Ejemplo n.º 16
0
        public ValuesDataSet getDataValues(ValuesDataSet ds, DateTime startDate, DateTime endDate)
        {
            SeriesCatalogTableAdapter scAdapater = new SeriesCatalogTableAdapter();

            scAdapater.Connection.ConnectionString = odws.Config.ODDB();
            seriesCatalogDataSet sc = new seriesCatalogDataSet();

            scAdapater.FillBySiteVariable(sc.SeriesCatalog, ds.Sites[0].SiteID, ds.Variables[0].VariableID);

            string requestData = "";

            try
            {
                requestData = generateURL(URLSiteName(ds.Sites), URLVariableCode(ds.Variables, ds.Sites), selectStartDate(startDate, sc.SeriesCatalog[0].SeriesID), selectEndDate(endDate, sc.SeriesCatalog[0].SeriesID));
                return(newTable(ds.Variables[0].VariableID.ToString(), sc.SeriesCatalog[0].SeriesID, requestData));
            }
            catch (Exception ex)
            {
                return(new ValuesDataSet());
            }
        }
Ejemplo n.º 17
0
        public ValuesDataSet getDataValues(int SiteID, int VariableID, DateTime StartDate, DateTime EndDate)
        {
            seriesCatalogDataSet      scDS = new seriesCatalogDataSet();
            SeriesCatalogTableAdapter seriesTableAdapter = new SeriesCatalogTableAdapter();

            seriesTableAdapter.Connection.ConnectionString = odws.Config.ODDB();

            seriesTableAdapter.FillBySiteIDVariableID(scDS.SeriesCatalog, SiteID, VariableID);
            DataSet oDS = new DataSet();

            try
            {
                oDS = getValuesWork(scDS.SeriesCatalog, StartDate, EndDate);
            }
            catch (Exception ex)
            {
                return(emptyValues(ex.Message));
            }

            return(newTable(scDS.SeriesCatalog, ref oDS));
        }
 public virtual int Update(seriesCatalogDataSet.SeriesCatalogDataTable dataTable) {
     return this.Adapter.Update(dataTable);
 }
 public virtual int Update(seriesCatalogDataSet dataSet) {
     return this.Adapter.Update(dataSet, "SeriesCatalog");
 }
Ejemplo n.º 20
0
            public static seriesCatalogTypeSeries row2SeriesCatalogElement(seriesCatalogDataSet.SeriesCatalogRow row, seriesCatalogDataSet ds, VariablesDataset vds, ControlledVocabularyDataset vocabularyDataset)
            {
                int variableID = row.VariableID;
                VariableInfoType variable = ODvariables.GetVariableByID(variableID, vds);
                Nullable<W3CDateTime> beginDateTime = null;
                if (!row.IsBeginDateTimeNull())
                {

                    TimeSpan timeSpan = row.BeginDateTime.Subtract(row.BeginDateTimeUTC);
                    beginDateTime = new W3CDateTime(row.BeginDateTime, timeSpan);

                }

                Nullable<W3CDateTime> endDateTime = null;
                if (!row.IsEndDateTimeNull())
                {
                    TimeSpan timeSpan = row.EndDateTime.Subtract(row.EndDateTimeUTC);
                    endDateTime = new W3CDateTime(row.EndDateTime, timeSpan);
                }

                Nullable<int> valueCount = null;
                if (!row.IsValueCountNull()) valueCount = row.ValueCount;

                string qualityControlLevelTerm = null;
                int? QualityControlLevelid = null;
                if (!row.IsQualityControlLevelIDNull())
                {
                    QualityControlLevelid = row.QualityControlLevelID;
                    ControlledVocabularyDataset.QualityControlLevelsRow qcRow =
                        vocabularyDataset.QualityControlLevels.FindByQualityControlLevelID(QualityControlLevelid.Value);
                    if (qcRow != null )
                    {
                        qualityControlLevelTerm = qcRow.Definition;
                    }
                }

                int? MethodID = null;
                if (!row.IsMethodIDNull()) MethodID = row.MethodID;

                int? SourceID = null;
                if (!row.IsSourceIDNull()) SourceID = row.SourceID;

                Nullable<Boolean> valueCountIsEstimated = false;

                /* public static seriesCatalogTypeSeries createSeriesCatalogRecord(
                        VariableInfoType variable,
                        string sampleMedium,
                        Nullable<W3CDateTime> beginDateTime,
                        Nullable<W3CDateTime> endDateTime,
                        Nullable<int> valueCount,
                         Nullable<Boolean> valueCountIsEstimated,
                        string dataType,
                        string valueType,
                        string generalCategory
                       )
                    */
                seriesCatalogTypeSeries record = CuahsiBuilder.CreateSeriesRecord(
                    variable,
                    variable.sampleMedium.ToString(),
                    beginDateTime,
                    endDateTime,
                    valueCount,
                    valueCountIsEstimated,
                    null,
                    null,
                    null,
                    false, // real time
                    null, // string if real time
                    row.QualityControlLevelCode,
                    QualityControlLevelid,
                    row.MethodDescription,
                    MethodID, row.Organization,
                    row.SourceDescription,
                    SourceID,
                    row.Citation,
                    true, // include UTC Time
                    qualityControlLevelTerm
                    );

                return record;
            }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     seriesCatalogDataSet ds = new seriesCatalogDataSet();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
 public virtual int FillBySiteID(seriesCatalogDataSet.SeriesCatalogDataTable dataTable, global::System.Nullable<int> siteID) {
     this.Adapter.SelectCommand = this.CommandCollection[1];
     if ((siteID.HasValue == true)) {
         this.Adapter.SelectCommand.Parameters[0].Value = ((int)(siteID.Value));
     }
     else {
         this.Adapter.SelectCommand.Parameters[0].Value = global::System.DBNull.Value;
     }
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }
        public static seriesCatalogTypeSeries row2SeriesCatalogElement(
            seriesCatalogDataSet.SeriesCatalogRow row,
            seriesCatalogDataSet ds, VariablesDataset vds)
        {
            int variableID = row.VariableID;
            VariableInfoType       variable      = ODvariables.GetVariableByID(variableID, vds);
            Nullable <W3CDateTime> beginDateTime = null;

            if (!row.IsBeginDateTimeNull())
            {
                beginDateTime = new W3CDateTime(row.BeginDateTime);
            }

            Nullable <W3CDateTime> endDateTime = null;

            if (!row.IsEndDateTimeNull())
            {
                endDateTime = new W3CDateTime(row.EndDateTime);
            }

            Nullable <int> valueCount = null;

            if (!row.IsValueCountNull())
            {
                valueCount = row.ValueCount;
            }

            int?QualityControlLevelid = null;

            if (!row.IsQualityControlLevelIDNull())
            {
                QualityControlLevelid = row.QualityControlLevelID;
            }

            int?MethodID = null;

            if (!row.IsMethodIDNull())
            {
                MethodID = row.MethodID;
            }

            int?SourceID = null;

            if (!row.IsSourceIDNull())
            {
                SourceID = row.SourceID;
            }


            Nullable <Boolean> valueCountIsEstimated = false;

            seriesCatalogTypeSeries record = CuahsiBuilder.CreateSeriesRecord(
                variable,
                variable.sampleMedium.ToString(),
                beginDateTime,
                endDateTime,
                valueCount,
                valueCountIsEstimated,
                null,
                null,
                null,
                false, // real time
                null,  // string if real time
                null,
                QualityControlLevelid,
                row.MethodDescription, MethodID,
                row.Organization, row.SourceDescription,
                SourceID,
                row.Citation);

            return(record);
        }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     seriesCatalogDataSet ds = new seriesCatalogDataSet();
     global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "SeriesCatalogDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
            public static seriesCatalogTypeSeries row2SeriesCatalogElement(seriesCatalogDataSet.SeriesCatalogRow row, seriesCatalogDataSet ds, VariablesDataset vds, ControlledVocabularyDataset vocabularyDataset)
            {
                int variableID = row.VariableID;
                VariableInfoType       variable      = ODvariables.GetVariableByID(variableID, vds);
                Nullable <W3CDateTime> beginDateTime = null;

                if (!row.IsBeginDateTimeNull())
                {
                    TimeSpan timeSpan = row.BeginDateTime.Subtract(row.BeginDateTimeUTC);
                    beginDateTime = new W3CDateTime(row.BeginDateTime, timeSpan);
                }

                Nullable <W3CDateTime> endDateTime = null;

                if (!row.IsEndDateTimeNull())
                {
                    TimeSpan timeSpan = row.EndDateTime.Subtract(row.EndDateTimeUTC);
                    endDateTime = new W3CDateTime(row.EndDateTime, timeSpan);
                }

                Nullable <int> valueCount = null;

                if (!row.IsValueCountNull())
                {
                    valueCount = row.ValueCount;
                }

                string qualityControlLevelTerm = null;
                int?   QualityControlLevelid   = null;

                if (!row.IsQualityControlLevelIDNull())
                {
                    QualityControlLevelid = row.QualityControlLevelID;
                    ControlledVocabularyDataset.QualityControlLevelsRow qcRow =
                        vocabularyDataset.QualityControlLevels.FindByQualityControlLevelID(QualityControlLevelid.Value);
                    if (qcRow != null)
                    {
                        qualityControlLevelTerm = qcRow.Definition;
                    }
                }

                int?MethodID = null;

                if (!row.IsMethodIDNull())
                {
                    MethodID = row.MethodID;
                }

                int?SourceID = null;

                if (!row.IsSourceIDNull())
                {
                    SourceID = row.SourceID;
                }

                Nullable <Boolean> valueCountIsEstimated = false;

                /* public static seriesCatalogTypeSeries createSeriesCatalogRecord(
                 *      VariableInfoType variable,
                 *      string sampleMedium,
                 *      Nullable<W3CDateTime> beginDateTime,
                 *      Nullable<W3CDateTime> endDateTime,
                 *      Nullable<int> valueCount,
                 *       Nullable<Boolean> valueCountIsEstimated,
                 *      string dataType,
                 *      string valueType,
                 *      string generalCategory
                 *     )
                 */
                seriesCatalogTypeSeries record = CuahsiBuilder.CreateSeriesRecord(
                    variable,
                    variable.sampleMedium.ToString(),
                    beginDateTime,
                    endDateTime,
                    valueCount,
                    valueCountIsEstimated,
                    null,
                    null,
                    null,
                    false, // real time
                    null,  // string if real time
                    row.QualityControlLevelCode,
                    QualityControlLevelid,
                    row.MethodDescription,
                    MethodID, row.Organization,
                    row.SourceDescription,
                    SourceID,
                    row.Citation,
                    true, // include UTC Time
                    qualityControlLevelTerm
                    );

                return(record);
            }
 public virtual int Fill(seriesCatalogDataSet.SeriesCatalogDataTable dataTable) {
     this.Adapter.SelectCommand = this.CommandCollection[0];
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }