Esempio n. 1
0
        static WaterML10.TimeSeriesResponseType LoadDataValueInfo(string siteCode, string varCode,
                                                                  WaterML10.WaterOneFlowClient WofClient,
                                                                  DateTime beginDateTime, DateTime endDateTime,
                                                                  ref string queryParam, ref string errMsg)
        {
            string beginDT = string.Format("{0:s}", beginDateTime);
            string endDT   = string.Format("{0:s}", endDateTime);

            errMsg     = "";
            queryParam = String.Format(" <{0}--{1}> ", beginDT, endDT);
            Console.WriteLine("......Getting values from <{0}> to <{1}>.", beginDT, endDT);

            WaterML10.TimeSeriesResponseType tsRt = null;
            try
            {
                tsRt = WofClient.GetValuesObject(siteCode, varCode, beginDT, endDT, "");
            }
            catch (Exception e)
            {
                errMsg = "Exception@LoadData: " + e.Message;
                Console.WriteLine(errMsg);
            }

            return(tsRt);
        }
Esempio n. 2
0
        static WaterML10.seriesCatalogType[] LoadOnesiteInfo(WaterML10.WaterOneFlowClient WofClient,
                                                             string url, string siteCode, ref string errMsg)
        {
            WaterML10.SiteInfoResponseType rt     = null;
            WaterML10.seriesCatalogType[]  sctAll = null;
            try
            {
                rt     = WofClient.GetSiteInfoObject(siteCode, "");
                sctAll = rt.site[0].seriesCatalog;
            }
            catch (Exception e)
            {
                errMsg = "Exception@LoadOneSite: " + e.Message;
                Console.WriteLine(errMsg);
            }

            return(sctAll);
        }
Esempio n. 3
0
        // Get DataValueInfo for 3 time periods: begin, middle, end.
        // As corresponding to the first, mid, and last 30 data values
        static WaterML10.TimeSeriesResponseType[] LoadDataValueInfoSplit(string siteCode, string varCode,
                                                                         WaterML10.WaterOneFlowClient WofClient,
                                                                         int valuecount, DateTime beginDateTime, DateTime endDateTime,
                                                                         ref string queryParam, ref string errMsg)
        {
            queryParam = "";
            errMsg     = "";

            WaterML10.TimeSeriesResponseType[] tsRtAll = new WaterML10.TimeSeriesResponseType[3];

            string beginDT = string.Format("{0:s}", beginDateTime);
            string endDT   = string.Format("{0:s}", endDateTime);

            Console.WriteLine("......Getting values from <{0}> to <{1}>.", beginDT, endDT);
            DateTime[] fromDateTime = new DateTime[3];
            DateTime[] toDateTime = new DateTime[3];
            string     fromDT, toDT;

            int[] count = new int[3] {
                0, 0, 0
            };

            // Timespan between beginDT and endDT
            TimeSpan delta = endDateTime - beginDateTime;
            double   step0 = delta.TotalSeconds * Program.CompareRecordCount * 2 / valuecount;

            // The first 30 records
            fromDateTime[0] = beginDateTime;
            toDateTime[0]   = beginDateTime.AddSeconds(step0);

            // The middle 30 records
            fromDateTime[1] = beginDateTime.AddSeconds(delta.TotalSeconds / 2);
            toDateTime[1]   = fromDateTime[1].AddSeconds(step0);

            // The last 30 records
            fromDateTime[2] = endDateTime.AddSeconds(-step0);
            toDateTime[2]   = endDateTime;

            for (int i = 0; i < 3; i++)
            {
                bool lastTry = false;
                tsRtAll[i] = null;
                double step = step0;
                while (!lastTry)
                {
                    if ((i < 2) && (DateTime.Compare(toDateTime[i], endDateTime) >= 0))
                    {
                        toDateTime[i] = endDateTime;
                        lastTry       = true;
                    }
                    else if ((i == 2) && (DateTime.Compare(fromDateTime[i], beginDateTime) <= 0))
                    {
                        fromDateTime[i] = beginDateTime;
                        lastTry         = true;
                    }

                    fromDT = string.Format("{0:s}", fromDateTime[i]);
                    toDT   = string.Format("{0:s}", toDateTime[i]);

                    Console.WriteLine("......Getting values, Segment <{0}>: from <{1}> to <{2}>.",
                                      i + 1, fromDT, toDT);
                    try
                    {
                        tsRtAll[i] = WofClient.GetValuesObject(siteCode, varCode, fromDT, toDT, "");
                    }
                    catch (Exception e)
                    {
                        errMsg = "Exception@LoadDataSplit: " + e.Message;
                        Console.WriteLine(errMsg);
                        return(null);
                    }

                    // Where WaterML1.0 and WaterML1.1 differ
                    if (tsRtAll[i].timeSeries.values != null)
                    {
                        count[i] = Convert.ToInt32(tsRtAll[i].timeSeries.values.count);
                    }
                    if (count[i] >= Program.CompareRecordCount)
                    {
                        queryParam += String.Format(" <{0}--{1}> ", fromDT, toDT);
                        break;
                    }
                    else
                    {
                        step *= 2;
                        if (i < 2)
                        {
                            toDateTime[i] = toDateTime[i].AddSeconds(step);
                        }
                        else
                        {
                            fromDateTime[i] = fromDateTime[i].AddSeconds(-step);
                        }
                    }
                }
            }

            return(tsRtAll);
        }