Beispiel #1
0
        /// <summary>
        /// Isolates only the AQTS items that meet processing requirements
        /// </summary>
        /// <param name="allTS"></param>
        /// <returns></returns>
        private static tsInventory FilterAqTimeSeries(tsInventory allTS)
        {
            tsInventory filteredTS = new tsInventory();

            filteredTS.ResponseTime    = allTS.ResponseTime;
            filteredTS.ResponseVersion = allTS.ResponseVersion;
            filteredTS.Summary         = allTS.Summary;
            List <tsItems> filteredList = new List <tsItems>();

            foreach (var ts in allTS.TimeSeriesDescriptions)
            {
                // CHECK IF TS HAS AQ EXTENDED ATTRIBUTES AND IS A REFLECTED TS
                var hdbSyncVars = ts.ExtendedAttributes;
                if (hdbSyncVars[0].Value != null && hdbSyncVars[1].Value != null && hdbSyncVars[2].Value != null && ts.TimeSeriesType.ToLower() == "reflected")
                {
                    filteredList.Add(ts);
                }
            }
            filteredTS.TimeSeriesDescriptions = filteredList;
            return(filteredTS);
        }
Beispiel #2
0
        /// <summary>
        /// Builds the text files required by the AquAS UI
        /// </summary>
        /// <param name="tsItems"></param>
        /// <param name="t1"></param>
        /// <param name="t2"></param>
        /// <param name="sitesTags"></param>
        /// <param name="siteNum"></param>
        /// <param name="thisYear"></param>
        /// <param name="lastYear"></param>
        /// <param name="twoYear"></param>
        private static void BuildAquasOutputs(tsInventory tsItems, DateTime t1, DateTime t2, ref string sitesTags, ref int siteNum, List <string> thisYear, List <string> lastYear, List <string> twoYear)
        {
            tsItems.TimeSeriesDescriptions.Sort((x, y) => string.Compare(x.LocationIdentifier, y.LocationIdentifier));
            foreach (var ts in tsItems.TimeSeriesDescriptions)
            {
                //if (ts.Label.Contains("Published |"))
                //{
                //get approvals
                var tsApprovals = AquQuery.GetAqTimeSeriesApprovals(ts.UniqueId, t1, t2);
                Console.WriteLine("Processing " + tsApprovals.LocationIdentifier + " | " + tsApprovals.Parameter + @""",");
                //build approvals table
                var dTab = new DataTable();
                dTab.Columns.Add("startDate", typeof(DateTime));
                dTab.Columns.Add("endDate", typeof(DateTime));
                dTab.Columns.Add("loadDate", typeof(DateTime));
                dTab.Columns.Add("ApprovalLevel", typeof(string));
                dTab.Columns.Add("Comment", typeof(string));
                foreach (var item in tsApprovals.Approvals)
                {
                    var dRow = dTab.NewRow();
                    dRow["startDate"]     = item.StartTime;
                    dRow["endDate"]       = item.EndTime;
                    dRow["loadDate"]      = item.DateAppliedUtc;
                    dRow["approvalLevel"] = item.LevelDescription;
                    dRow["comment"]       = item.Comment;
                    dTab.Rows.Add(dRow);
                }
                dTab.DefaultView.Sort = "loadDate ASC";
                dTab = dTab.DefaultView.ToTable();

                //build approvals series with no approval data
                var s = new Series();
                for (DateTime t = t1; t <= t2; t = t.AddDays(1))
                {
                    s.Add(t, 0.0, "4");//no approval data
                }

                // iterate through approval levels in AQ and update series
                foreach (DataRow row in dTab.Rows)
                {
                    DateTime ithStart    = DateTime.Parse(row["startDate"].ToString()).Date;
                    DateTime ithEnd      = DateTime.Parse(row["endDate"].ToString()).Date;
                    string   ithApproval = row["approvalLevel"].ToString();

                    string approvalFlag;
                    if (ithApproval.ToLower() == "working")
                    {
                        approvalFlag = "1";
                    }
                    else if (ithApproval.ToLower() == "in review")
                    {
                        approvalFlag = "2";
                    }
                    else if (ithApproval.ToLower() == "approved")
                    {
                        approvalFlag = "3";
                    }
                    else
                    {
                        approvalFlag = "4";
                    }

                    if (ithStart < t1)
                    {
                        ithStart = t1;
                    }
                    if (ithEnd > t2)
                    {
                        ithEnd = t2;
                    }
                    var sTemp = new Series();
                    for (DateTime t = ithStart; t <= ithEnd; t = t.AddDays(1))
                    {
                        sTemp.Add(t, 0.0, approvalFlag);
                    }
                    s = Reclamation.TimeSeries.Math.Merge(sTemp, s);
                }

                //write data entries to dashboard input file

                /*
                 *************************
                 *************************sitesTags.txt - THIS IS A COMMA-DELIMITED TEXT FILE OF THE ROWS IN THE DASHBOARD MAPS TO THE SITE# FOR THE DATA FILE
                 *************************"SITE 1 | PAR 1","SITE 1 | PAR 2","SITE 2 | PAR 1","SITE 2 | PAR 2","SITE 2 | PAR 3"
                 */
                sitesTags += @"""" + tsApprovals.LocationIdentifier + " | " + tsApprovals.Parameter + @""",";
                siteNum    = siteNum + 1;

                /*
                 *************************
                 *************************thisYear.txt - THIS IS A TAB-DELIMITED FILE OF THE DAILY ROWS FOR THE DASHBOARD
                 *************************site day value
                 *************************1	1	1
                 *************************1	2	1
                 *************************1	.	2
                 *************************1	.	4
                 *************************1	.	3
                 *************************1	365	3
                 *************************
                 */
                foreach (Point pt in s)
                {
                    var yearDiff = pt.DateTime.Year - t1.Year;
                    //var jDay = pt.DateTime.DayOfYear;
                    //var val = pt.Flag;
                    var val = siteNum.ToString() + "\t" + pt.DateTime.DayOfYear.ToString() + "\t" + pt.Flag;
                    switch (yearDiff)
                    {
                    case 0:
                        twoYear.Add(val);
                        break;

                    case 1:
                        lastYear.Add(val);
                        break;

                    case 2:
                        thisYear.Add(val);
                        break;

                    default:
                        break;
                    }
                }
                //}
            }
        }