public static void AddReportSpecificTables(DataSet dataSet)
        {
            try
            {
                Common common = (Common)dataSet.Tables["RunReportRequest"].Rows[0]["CommonLibrary"];

                DataTable settingsTable = dataSet.Tables["ReportSettings"];
                settingsTable.Columns.Add("ReportTitle", typeof(string));
                settingsTable.Rows[0]["ReportTitle"] = Resources.BenchmarkHistory;

                DataTable table = new DataTable("BenchmarkHistoryDataTable");
                dataSet.Tables.Add(table);

                RunFileReportRequest runReportRequest = (RunFileReportRequest)dataSet.Tables["RunReportRequest"].Rows[0]["RunReportRequest"];
                IPublishGateway      publish          = runReportRequest.Publish;
                string locationIdentifier             = (string)dataSet.Tables["LocationInput"].Rows[0]["Identifier"];

                string dllName = (string)dataSet.Tables["RunReportRequest"].Rows[0]["DllName"];
                Log.DebugFormat("{0} - Document GenerateScript input location = {1}", dllName, locationIdentifier);

                ///////////////////////////////////////////////////////////////
                DateTimeOffsetInterval reportPeriod = (DateTimeOffsetInterval)dataSet.Tables["ReportPeriods"].Rows[0]["NoGroupBy"];

                int    formatPrecision = common.GetParameterInt("FormatPrecision", 3);
                string formatType      = common.GetParameterString("FormatType", "Fixed");
                bool   formatFixed     = (formatType == "Fixed");

                int groupSizeLimit = 6;

                DataTable benchmarks = dataSet.Tables.Add("Benchmarks");

                benchmarks.Columns.Add("Name", typeof(string));
                benchmarks.Columns.Add("Elevation", typeof(string));
                benchmarks.Columns.Add("DateConstructed", typeof(string));
                benchmarks.Columns.Add("DateRemoved", typeof(string));
                benchmarks.Columns.Add("Status", typeof(string));
                benchmarks.Columns.Add("Description", typeof(string));

                DataTable groupBy = dataSet.Tables.Add("GroupBy");
                groupBy.Columns.Add("GroupNumber", typeof(int));
                for (int i = 0; i < groupSizeLimit; i++)
                {
                    groupBy.Columns.Add("Name" + (i + 1).ToString(), typeof(string));
                }

                DataTable benchmarkHistory = dataSet.Tables.Add("BenchmarkHistory");

                benchmarkHistory.Columns.Add("GroupNumber", typeof(int));
                benchmarkHistory.Columns.Add("DateTime", typeof(string));
                benchmarkHistory.Columns.Add("Party", typeof(string));
                benchmarkHistory.Columns.Add("Comments", typeof(string));
                for (int i = 0; i < groupSizeLimit; i++)
                {
                    benchmarkHistory.Columns.Add("Elevation" + (i + 1).ToString(), typeof(string));
                    benchmarkHistory.Columns.Add("Correction" + (i + 1).ToString(), typeof(string));
                }

                dataSet.Relations.Add("GroupByBenchmarkHistory", groupBy.Columns["GroupNumber"], benchmarkHistory.Columns["GroupNumber"]);

                LocationDataServiceResponse locData = common.GetLocationData(locationIdentifier);

                List <ReferencePoint> refPoints = new List <ReferencePoint>();
                foreach (ReferencePoint refPoint in locData.ReferencePoints)
                {
                    List <ReferencePointPeriod> refPointPeriods = refPoint.ReferencePointPeriods;

                    if (refPointPeriods.Count == 0)
                    {
                        continue;
                    }

                    refPointPeriods.Sort((x, y) => x.ValidFrom.CompareTo(y.ValidFrom));
                    DateTimeOffset validFrom = refPointPeriods[0].ValidFrom;

                    if (ReportSpecificFunctions.TimeRangeOverlaps(validFrom, refPoint.DecommissionedDate, reportPeriod))
                    {
                        refPoints.Add(refPoint);
                    }
                }

                if (refPoints.Count == 0)
                {
                    return;
                }

                Dictionary <Guid, List <ReferencePointPeriod> > refPointHistories = new Dictionary <Guid, List <ReferencePointPeriod> >();
                Dictionary <Guid, int> refPointNumbers = new Dictionary <Guid, int>();

                for (int i = 0; i < refPoints.Count; i++)
                {
                    ReferencePoint refPoint = refPoints[i];

                    refPointNumbers.Add(refPoint.UniqueId, i);

                    DataRow row = benchmarks.NewRow();

                    row["Name"]        = refPoint.Name;
                    row["Description"] = refPoint.Description;

                    if (refPoint.DecommissionedDate.HasValue)
                    {
                        row["DateRemoved"] = refPoint.DecommissionedDate.Value.ToString("yyyy-MM-dd");
                    }

                    string status = (refPoint.DecommissionedDate.HasValue) ? Resources.InactiveLowerCase : Resources.ActiveLowerCase;
                    status += (refPoint.PrimarySinceDate.HasValue) ? " " + Resources.PrimaryLowerCase : "";

                    row["Status"] = status;

                    DateTimeOffset?primarySince = refPoint.PrimarySinceDate;

                    List <ReferencePointPeriod> refPointPeriods = refPoint.ReferencePointPeriods;
                    refPointPeriods.Sort((x, y) => x.ValidFrom.CompareTo(y.ValidFrom));

                    DateTimeOffset validFrom = refPointPeriods[0].ValidFrom;
                    row["DateConstructed"] = validFrom.ToString("yyyy-MM-dd");

                    double elevation = refPointPeriods[refPointPeriods.Count - 1].Elevation;
                    row["Elevation"] = Common.FormatDoubleValue(elevation, formatFixed, formatPrecision, "");

                    refPointPeriods.Reverse();
                    refPointHistories[refPoint.UniqueId] = refPointPeriods;

                    benchmarks.Rows.Add(row);
                }

                int numberOfGroups = (int)Math.Ceiling((double)benchmarks.Rows.Count / groupSizeLimit);

                FieldVisitDataByLocationServiceRequest fdRequest = new FieldVisitDataByLocationServiceRequest();
                fdRequest.LocationIdentifier = locationIdentifier;
                fdRequest.Activities         = new List <ActivityType> {
                    ActivityType.LevelSurvey
                };
                FieldVisitDataByLocationServiceResponse fdResponse = publish.Get(fdRequest);
                List <FieldVisit> fieldVisitData = fdResponse.FieldVisitData;

                try
                {
                    fieldVisitData.Sort((x, y) => y.StartTime.Value.CompareTo(x.StartTime.Value));
                }
                catch { }


                for (int i = 0; i < numberOfGroups; i++)
                {
                    DataRow groupByRow = dataSet.Tables["GroupBy"].NewRow();
                    groupByRow["GroupNumber"] = i;

                    for (int j = 0; j < groupSizeLimit; j++)
                    {
                        int index = (i * groupSizeLimit) + j;
                        if (index < refPoints.Count)
                        {
                            ReferencePoint refPoint = refPoints[index];
                            groupByRow["Name" + (j + 1).ToString()] = refPoint.Name;
                        }
                    }

                    dataSet.Tables["GroupBy"].Rows.Add(groupByRow);
                }

                foreach (FieldVisit fieldVisit in fieldVisitData)
                {
                    if (!ReportSpecificFunctions.TimeRangeOverlaps(fieldVisit.StartTime.Value, fieldVisit.StartTime.Value, reportPeriod))
                    {
                        continue;
                    }

                    string dateTime = fieldVisit.StartTime.Value.ToString("yyyy-MM-dd HH:mm");
                    string comments = fieldVisit.LevelSurveyActivity.Comments;
                    string party    = fieldVisit.LevelSurveyActivity.Party;

                    int fieldVisitFirstRow = dataSet.Tables["BenchmarkHistory"].Rows.Count;

                    for (int i = 0; i < numberOfGroups; i++)
                    {
                        DataRow row = dataSet.Tables["BenchmarkHistory"].NewRow();
                        row["GroupNumber"] = i;
                        row["DateTime"]    = dateTime;
                        row["Party"]       = party;
                        row["Comments"]    = comments;
                        dataSet.Tables["BenchmarkHistory"].Rows.Add(row);
                    }

                    List <LevelSurveyMeasurement> levelMeasurements = fieldVisit.LevelSurveyActivity.LevelMeasurements;

                    foreach (LevelSurveyMeasurement lsm in levelMeasurements)
                    {
                        if (!lsm.MeasuredElevation.Numeric.HasValue)
                        {
                            continue;
                        }

                        Guid id = lsm.ReferencePointUniqueId;

                        if (!refPointNumbers.ContainsKey(id))
                        {
                            continue;
                        }

                        int number         = refPointNumbers[id];
                        int theGroupNumber = (int)Math.Floor((double)number / groupSizeLimit);
                        int thePosition    = (int)(number % groupSizeLimit);

                        double level      = lsm.MeasuredElevation.Numeric.Value;
                        double correction = ReportSpecificFunctions.calculateDifference(lsm, refPointHistories[id]);

                        DataRow row = dataSet.Tables["BenchmarkHistory"].Rows[fieldVisitFirstRow + theGroupNumber];

                        row["Elevation" + (1 + thePosition).ToString()]  = Common.FormatDoubleValue(level, formatFixed, formatPrecision, "");
                        row["Correction" + (1 + thePosition).ToString()] = Common.FormatDoubleValue(correction, formatFixed, formatPrecision, "");
                    }
                }

                List <DataRow> emptyRows = new List <DataRow>();
                for (int i = 0; i < dataSet.Tables["BenchmarkHistory"].Rows.Count; i++)
                {
                    DataRow row = dataSet.Tables["BenchmarkHistory"].Rows[i];

                    int emptyCount = 0;
                    for (int j = 0; j < groupSizeLimit; j++)
                    {
                        bool empty = string.IsNullOrEmpty(row["Elevation" + (j + 1).ToString()].ToString());
                        if (empty)
                        {
                            emptyCount++;
                        }
                    }
                    if (emptyCount == groupSizeLimit)
                    {
                        emptyRows.Add(row);
                    }
                }

                for (int i = 0; i < emptyRows.Count; i++)
                {
                    dataSet.Tables["BenchmarkHistory"].Rows.Remove(emptyRows[i]);
                }
            }
            catch (Exception exp)
            {
                Log.Error("Error creating report specific data tables ", exp);
                throw exp;
            }
        }
コード例 #2
0
        public static void AddReportSpecificTables(DataSet dataSet)
        {
            try
            {
                if (dataSet.Tables.Contains("DischargeTimeSeriesFromRatingCurve"))
                {
                    dataSet.Tables["DischargeTimeSeriesFromRatingCurve"].TableName         = "SourceData";
                    dataSet.Tables["DischargeTimeSeriesFromRatingCurveLocation"].TableName = "SourceDataLocation";
                    dataSet.Tables["DischargeTimeSeriesFromRatingCurveLocationExtendedAttributes"].TableName = "SourceDataLocationExtendedAttributes";
                }

                Common common = (Common)dataSet.Tables["RunReportRequest"].Rows[0]["CommonLibrary"];

                DataTable settingsTable = dataSet.Tables["ReportSettings"];
                settingsTable.Columns.Add("ReportTitle", typeof(string));
                settingsTable.Rows[0]["ReportTitle"] = Resources.ContinuousDataProduction;

                DataTable table = new DataTable("ContinuousDataProductionDataTable");

                dataSet.Tables.Add(table);
                RunFileReportRequest runReportRequest = (RunFileReportRequest)dataSet.Tables["RunReportRequest"].Rows[0]["RunReportRequest"];
                IPublishGateway      publish          = runReportRequest.Publish;
                Guid timeSeriesUniqueId = (Guid)dataSet.Tables["SourceData"].Rows[0]["UniqueId"];

                string dllName = (string)dataSet.Tables["RunReportRequest"].Rows[0]["DllName"];
                Log.DebugFormat("{0} - Document GenerateScript input = {1}", dllName, timeSeriesUniqueId);

                ///////////////////////////////////////////////////////////////

                string timeseriesType = (string)dataSet.Tables["SourceData"].Rows[0]["TimeSeriesType"];

                if (timeseriesType != "ProcessorDerived")
                {
                    throw (new Exception("Input is not a derived time-series. Input signal must be a rating curve derived time-series."));
                }

                Server.Services.PublishService.ServiceModel.RequestDtos.UpchainProcessorListByTimeSeriesServiceRequest upchain = new Server.Services.PublishService.ServiceModel.RequestDtos.UpchainProcessorListByTimeSeriesServiceRequest();
                upchain.TimeSeriesUniqueId = timeSeriesUniqueId;
                List <Server.Services.PublishService.ServiceModel.Dtos.Processor> processors = publish.Get(upchain).Processors;

                string ratingModelIdentifier = "";

                foreach (Server.Services.PublishService.ServiceModel.Dtos.Processor processor in processors)
                {
                    if (string.IsNullOrEmpty(processor.InputRatingModelIdentifier))
                    {
                        continue;
                    }

                    if (processor.InputTimeSeriesUniqueIds.Count == 0)
                    {
                        continue;
                    }

                    ratingModelIdentifier = processor.InputRatingModelIdentifier;
                    break;
                }

                if (string.IsNullOrEmpty(ratingModelIdentifier))
                {
                    throw (new Exception("Input is not a rating model derived time-series. Input time-series must be a derived from a rating model."));
                }

                double tableIncrement           = common.GetParameterDouble("TableIncrement", 0.1);
                int    httpRepeatCallLimit      = common.GetParameterInt("HttpRepeatCallLimit", 4);
                int    httpCallLimitSize        = common.GetParameterInt("HttpCallLimitSize", 2000);
                int    httpCallTimeoutInSeconds = common.GetParameterInt("HttpCallTimeoutInSeconds", 30);
                string httpUrlPrefix            = common.GetParameterString("HttpUrlPrefix",
                                                                            @"http://geo.weather.gc.ca/geomet/features/collections/hydrometric-daily-mean/items?f=json&STATION_NUMBER=");

                TimeSpan timezone = TimeSpan.FromHours(common.GetTimeSeriesDescription(timeSeriesUniqueId).UtcOffset);
                DateTimeOffsetInterval selectedInterval = (DateTimeOffsetInterval)dataSet.Tables["ReportData"].Rows[0]["SelectedInterval"];

                DateTimeOffset ReportTime = DateTimeOffset.Now;

                if (selectedInterval.End.HasValue)
                {
                    ReportTime = selectedInterval.End.Value.ToOffset(timezone);
                }
                else
                {
                    ReportTime = DateTimeOffset.Now.ToOffset(timezone);
                }

                string locationIdentifier = common.GetTimeSeriesDescription(timeSeriesUniqueId).LocationIdentifier;

                int numberOfHistoricalPoints = ReportSpecificFunctions.GetNumberOfHistoricalPointsAvailable(
                    httpUrlPrefix, locationIdentifier, httpRepeatCallLimit, httpCallTimeoutInSeconds);

                settingsTable.Columns.Add("NumberOfHistoricalPoints", typeof(int));
                settingsTable.Rows[0]["NumberOfHistoricalPoints"] = numberOfHistoricalPoints;
            }
            catch (Exception exp)
            {
                Log.Error("Error creating report specific data tables ", exp);
                throw exp;
            }
        }
コード例 #3
0
        public static void AddReportSpecificTables(DataSet dataSet)
        {
            try
            {
                RunFileReportRequest runReportRequest = (RunFileReportRequest)dataSet.Tables["RunReportRequest"].Rows[0]["RunReportRequest"];
                IPublishGateway      publish          = runReportRequest.Publish;
                Guid   TimeSeriesUniqueId             = (Guid)dataSet.Tables["SourceData"].Rows[0]["UniqueId"];
                string timeseriesType = (string)dataSet.Tables["SourceData"].Rows[0]["TimeSeriesType"];

                if (timeseriesType != "ProcessorDerived")
                {
                    throw (new Exception("Input is not a derived time-series. Input signal must be a daily mean derived time-series."));
                }

                Server.Services.PublishService.ServiceModel.RequestDtos.UpchainProcessorListByTimeSeriesServiceRequest upchain = new Server.Services.PublishService.ServiceModel.RequestDtos.UpchainProcessorListByTimeSeriesServiceRequest();
                upchain.TimeSeriesUniqueId = TimeSeriesUniqueId;
                List <Server.Services.PublishService.ServiceModel.Dtos.Processor> processors = publish.Get(upchain).Processors;

                foreach (Server.Services.PublishService.ServiceModel.Dtos.Processor processor in processors)
                {
                    string procType = processor.ProcessorType;
                    if (procType != "statistics")
                    {
                        throw (new Exception("Input is not a statistics derived time-series. Input signal must be a daily mean derived time-series."));
                    }
                    else
                    {
                        string requireCoverage = null;
                        string timeStep        = null;
                        string timeStepCount   = null;
                        string statType        = null;

                        string coverageAmountPercent = "";

                        Dictionary <string, string> settings = processor.Settings;
                        foreach (var item in settings)
                        {
                            string key = item.Key;
                            string val = item.Value;

                            if (key == "StatisticType")
                            {
                                statType = item.Value;
                            }
                            if (key == "RequireMinimumCoverage")
                            {
                                requireCoverage = item.Value;
                            }
                            if (key == "TimeStep")
                            {
                                timeStep = item.Value;
                            }
                            if (key == "TimeStepCount")
                            {
                                timeStepCount = item.Value;
                            }
                            if (key == "MinimumCoverageRequiredForPartialGradeAsPercent")
                            {
                                coverageAmountPercent = item.Value;
                            }
                        }
                        if (("Daily" != timeStep) || ("1" != timeStepCount) || ("Mean" != statType))
                        {
                            throw (new Exception("Input is not a daily mean derived time-series. Input signal must be a daily mean derived time-series."));
                        }

                        ReportJobParameter coverageItem = null;
                        foreach (ReportJobParameter item in runReportRequest.Parameters)
                        {
                            if (item.Name == "DataCoverageThresholdPercent")
                            {
                                coverageItem = item;
                                break;
                            }
                        }
                        if (coverageItem != null)
                        {
                            runReportRequest.Parameters.Remove(coverageItem);
                        }

                        ReportJobParameter parm = new ReportJobParameter();
                        parm.Name  = "DataCoverageThresholdPercent";
                        parm.Value = ("true" == requireCoverage) ? coverageAmountPercent : "";
                        runReportRequest.Parameters.Add(parm);

                        break;
                    }
                }

                Common common = (Common)dataSet.Tables["RunReportRequest"].Rows[0]["CommonLibrary"];

                DataTable settingsTable = dataSet.Tables["ReportSettings"];
                settingsTable.Columns.Add("ReportTitle", typeof(string));
                settingsTable.Rows[0]["ReportTitle"] = "Daily Mean Discharge";

                DataTable table = new DataTable("DailyMeanDischargeDataTable");

                dataSet.Tables.Add(table);
            }
            catch (Exception exp)
            {
                Log.Error("Error creating report specific data tables ", exp);
                throw exp;
            }
        }
コード例 #4
0
        public static void AddReportSpecificTables(DataSet dataSet)
        {
            try
            {
                Common common = (Common)dataSet.Tables["RunReportRequest"].Rows[0]["CommonLibrary"];

                DataTable settingsTable = dataSet.Tables["ReportSettings"];
                settingsTable.Columns.Add("ReportTitle", typeof(string));
                settingsTable.Rows[0]["ReportTitle"] = Resources.Instrumentation;

                DataTable table = new DataTable("InstrumentationDataTable");

                dataSet.Tables.Add(table);

                RunFileReportRequest runReportRequest = (RunFileReportRequest)dataSet.Tables["RunReportRequest"].Rows[0]["RunReportRequest"];
                IPublishGateway      publish          = runReportRequest.Publish;
                string locationIdentifier             = (string)dataSet.Tables["LocationInput"].Rows[0]["Identifier"];

                string dllName = (string)dataSet.Tables["RunReportRequest"].Rows[0]["DllName"];
                Log.DebugFormat("{0} - Document GenerateScript input location = {1}", dllName, locationIdentifier);

                ///////////////////////////////////////////////////////////////
                DateTimeOffsetInterval reportPeriod = (DateTimeOffsetInterval)dataSet.Tables["ReportPeriods"].Rows[0]["NoGroupBy"];

                string sortOrder = common.GetParameterString("SortOrder", "ReverseChronologicalOnMeasurementTime");

                DataTable table1 = dataSet.Tables.Add("Instrumentation");

                table1.Columns.Add("Date", typeof(string));
                table1.Columns.Add("Time", typeof(string));
                table1.Columns.Add("Timezone", typeof(string));
                table1.Columns.Add("ActivityType", typeof(string));
                table1.Columns.Add("Stage", typeof(string));
                table1.Columns.Add("StageUnit", typeof(string));
                table1.Columns.Add("Discharge", typeof(string));
                table1.Columns.Add("DischargeUnit", typeof(string));
                table1.Columns.Add("ControlCondition", typeof(string));
                table1.Columns.Add("ActivityRemarks", typeof(string));
                table1.Columns.Add("FieldVisitComments", typeof(string));
                table1.Columns.Add("Method", typeof(string));
                table1.Columns.Add("InstrumentType", typeof(string));
                table1.Columns.Add("Software", typeof(string));
                table1.Columns.Add("Firmware", typeof(string));
                table1.Columns.Add("SerialNumber", typeof(string));
                table1.Columns.Add("Manufacturer", typeof(string));
                table1.Columns.Add("Model", typeof(string));

                ActiveMetersAndCalibrationsServiceRequest  amcRequest  = new ActiveMetersAndCalibrationsServiceRequest();
                ActiveMetersAndCalibrationsServiceResponse amcResponse = publish.Get(amcRequest);
                List <ActiveMeterDetails> activeMeterDetailsList       = amcResponse.ActiveMeterDetails;

                FieldVisitDataByLocationServiceRequest fdRequest = new FieldVisitDataByLocationServiceRequest();
                fdRequest.LocationIdentifier = locationIdentifier;
                fdRequest.Activities         = new List <ActivityType> {
                    ActivityType.Reading, ActivityType.DischargeSummary, ActivityType.DischargePointVelocity, ActivityType.DischargeAdcp
                };
                fdRequest.ApplyRounding    = true;
                fdRequest.IncludeVerticals = true;
                FieldVisitDataByLocationServiceResponse fdResponse = publish.Get(fdRequest);
                List <FieldVisit> fieldVisitData = fdResponse.FieldVisitData;

                try
                {
                    if (sortOrder != "ReverseChronologicalOnMeasurementTime")
                    {
                        fieldVisitData.Sort((x, y) => x.StartTime.Value.CompareTo(y.StartTime.Value));
                    }
                    else
                    {
                        fieldVisitData.Sort((x, y) => y.StartTime.Value.CompareTo(x.StartTime.Value));
                    }
                }
                catch { }

                foreach (FieldVisit fieldVisit in fieldVisitData)
                {
                    if (!ReportSpecificFunctions.TimeRangeOverlaps(fieldVisit.StartTime.Value, fieldVisit.StartTime.Value, reportPeriod))
                    {
                        continue;
                    }

                    string controlCondition = (fieldVisit.ControlConditionActivity != null) ? fieldVisit.ControlConditionActivity.ControlCondition.ToString() : "";

                    var activities = fieldVisit.DischargeActivities;

                    if (activities != null)
                    {
                        if (sortOrder != "ReverseChronologicalOnMeasurementTime")
                        {
                            activities.Sort((x, y) => x.DischargeSummary.MeasurementTime.CompareTo(y.DischargeSummary.MeasurementTime));
                        }
                        else
                        {
                            activities.Sort((x, y) => y.DischargeSummary.MeasurementTime.CompareTo(x.DischargeSummary.MeasurementTime));
                        }

                        foreach (DischargeActivity dischargeActivity in activities)
                        {
                            DataRow row = table1.NewRow();
                            row["Date"]               = (fieldVisit.StartTime.HasValue) ? fieldVisit.StartTime.Value.ToString("yyyy-MM-dd") : "";
                            row["ControlCondition"]   = controlCondition;
                            row["FieldVisitComments"] = fieldVisit.Remarks;
                            row["ActivityType"]       = Resources.DischargeSummary;
                            row["Method"]             = dischargeActivity.DischargeSummary.DischargeMethod;

                            DischargeSummary dischargeSummary = dischargeActivity.DischargeSummary;
                            row["Time"]     = dischargeSummary.MeasurementTime.ToString("HH:mm");
                            row["Timezone"] = dischargeSummary.MeasurementTime.ToString("zzz");
                            string discharge     = (dischargeSummary.Discharge != null) ? dischargeSummary.Discharge.Numeric.ToString() : "";
                            string dischargeUnit = (dischargeSummary.Discharge != null) ? dischargeSummary.Discharge.Unit : "";
                            if (dischargeUnit != "m^3/s")
                            {
                                discharge += " " + dischargeUnit;
                            }
                            row["Discharge"] = discharge;

                            string stage     = (dischargeSummary.MeanGageHeight != null) ? dischargeSummary.MeanGageHeight.Numeric.ToString() : "";
                            string stageUnit = (dischargeSummary.MeanGageHeight != null) ? dischargeSummary.MeanGageHeight.Unit : "";
                            if (!string.IsNullOrEmpty(stage) && (stageUnit != "m"))
                            {
                                stage += " " + stageUnit;
                            }
                            row["Stage"]           = stage;
                            row["ActivityRemarks"] = dischargeSummary.Comments;

                            string serialNumber   = "";
                            string model          = "";
                            string manufacturer   = "";
                            string instrumentType = "";
                            string software       = "";
                            string firmware       = "";

                            if ((dischargeActivity.PointVelocityDischargeActivities != null) && (dischargeActivity.PointVelocityDischargeActivities.Count > 0))
                            {
                                PointVelocityDischargeActivity pointVelocityDischargeActivity = dischargeActivity.PointVelocityDischargeActivities[0];
                                if ((pointVelocityDischargeActivity.Verticals != null) && (pointVelocityDischargeActivity.Verticals.Count > 0))
                                {
                                    Vertical vertical = pointVelocityDischargeActivity.Verticals[0];
                                    serialNumber = vertical.CurrentMeter.SerialNumber;
                                    model        = vertical.CurrentMeter.Model;
                                    manufacturer = vertical.CurrentMeter.Manufacturer;

                                    foreach (ActiveMeterDetails activeMeterDetails in activeMeterDetailsList)
                                    {
                                        if ((activeMeterDetails.Manufacturer == manufacturer) &&
                                            (activeMeterDetails.SerialNumber == serialNumber) &&
                                            (activeMeterDetails.Model == model))
                                        {
                                            instrumentType = (activeMeterDetails.MeterType.HasValue) ? activeMeterDetails.MeterType.Value.ToString() : "";
                                            software       = activeMeterDetails.SoftwareVersion;
                                            firmware       = activeMeterDetails.FirmwareVersion;

                                            break;
                                        }
                                    }
                                }
                            }

                            if ((dischargeActivity.AdcpDischargeActivities != null) && (dischargeActivity.AdcpDischargeActivities.Count > 0))
                            {
                                AdcpDischargeActivity adcpDischargeActivity = dischargeActivity.AdcpDischargeActivities[0];

                                instrumentType = adcpDischargeActivity.AdcpDeviceType;
                                software       = adcpDischargeActivity.SoftwareVersion;
                                firmware       = adcpDischargeActivity.FirmwareVersion;
                                manufacturer   = adcpDischargeActivity.Manufacturer;
                                serialNumber   = adcpDischargeActivity.SerialNumber;
                                model          = adcpDischargeActivity.Model;

                                Log.DebugFormat("AdcpDischargeActivity: {0}, {1}, {2}", instrumentType, software, firmware);
                            }

                            row["Software"]       = software;
                            row["InstrumentType"] = instrumentType;
                            row["Firmware"]       = firmware;
                            row["Manufacturer"]   = manufacturer;
                            row["Model"]          = model;
                            row["SerialNumber"]   = serialNumber;
                            table1.Rows.Add(row);
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                Log.Error("Error creating report specific data tables ", exp);
                throw exp;
            }
        }
        public static void AddReportSpecificTables(DataSet dataSet)
        {
            try
            {
                Common common = (Common)dataSet.Tables["RunReportRequest"].Rows[0]["CommonLibrary"];

                DataTable settingsTable = dataSet.Tables["ReportSettings"];
                settingsTable.Columns.Add("ReportTitle", typeof(string));
                settingsTable.Rows[0]["ReportTitle"] = "Cross-Section Survey Plot";

                RunFileReportRequest runReportRequest = (RunFileReportRequest)dataSet.Tables["RunReportRequest"].Rows[0]["RunReportRequest"];
                IPublishGateway      publish          = runReportRequest.Publish;
                Common CommonLibrary = (Common)dataSet.Tables["RunReportRequest"].Rows[0]["CommonLibrary"];
                DateTimeOffsetInterval periodSelected = (DateTimeOffsetInterval)dataSet.Tables["ReportData"].Rows[0]["PeriodSelectedAdjustedForReport"];

                DataTable crossSectionSurveyDataTable = new DataTable("CrossSectionSurveyPlotDataTable");
                dataSet.Tables.Add(crossSectionSurveyDataTable);

                string   locIdentifier = (string)dataSet.Tables["InputLocation"].Rows[0]["LocationIdentifier"];
                TimeSpan utcOffset     = (TimeSpan)dataSet.Tables["InputLocation"].Rows[0]["UtcOffset"];

                string relativeLocationFilter = CommonLibrary.GetParameterString("RelativeLocationFilterPartialName", "");
                string channelFilter          = CommonLibrary.GetParameterString("ChannelFilterPartialName", "");
                string partyFilter            = CommonLibrary.GetParameterString("PartyFilterPartialName", "");

                string filterInformationString = Resources.RelativeLocationFilter + ": " + relativeLocationFilter;
                filterInformationString += "        " + Resources.ChannelFilter + ": " + channelFilter;
                filterInformationString += "        " + Resources.PartyFilter + ": " + partyFilter;

                crossSectionSurveyDataTable.Rows.Add(crossSectionSurveyDataTable.NewRow());

                crossSectionSurveyDataTable.Columns.Add("FilterInformationString", typeof(string));
                crossSectionSurveyDataTable.Columns.Add("RelativeLocationColumnHeader", typeof(string));
                crossSectionSurveyDataTable.Columns.Add("ChannelColumnHeader", typeof(string));
                crossSectionSurveyDataTable.Columns.Add("StartingPointColumnHeader", typeof(string));
                crossSectionSurveyDataTable.Columns.Add("StartTimeColumnHeader", typeof(string));
                crossSectionSurveyDataTable.Columns.Add("EndTimeColumnHeader", typeof(string));
                crossSectionSurveyDataTable.Columns.Add("PartyColumnHeader", typeof(string));
                crossSectionSurveyDataTable.Columns.Add("SurveyCommentColumnHeader", typeof(string));
                crossSectionSurveyDataTable.Columns.Add("TotalPointsColumnHeader", typeof(string));
                crossSectionSurveyDataTable.Columns.Add("StageColumnHeader", typeof(string));

                crossSectionSurveyDataTable.Rows[0]["FilterInformationString"] = filterInformationString;

                string sortOrder  = CommonLibrary.GetParameterString("SortOrder", "ReverseChronologicalOnStartTime");
                string dateFormat = CommonLibrary.GetParameterString("DateFormat", "yyyy-MM-dd HH:mm");

                string stageUnitSymbol = "";
                string stageUnitId     = "";

                DataTable activityTable = dataSet.Tables.Add("CrossSectionSurveyActivity");
                activityTable.Columns.Add("ActivityNumber", typeof(int));
                activityTable.Columns.Add("RelativeLocation", typeof(string));
                activityTable.Columns.Add("Channel", typeof(string));
                activityTable.Columns.Add("StartingPoint", typeof(string));
                activityTable.Columns.Add("StartTime", typeof(string));
                activityTable.Columns.Add("EndTime", typeof(string));
                activityTable.Columns.Add("Party", typeof(string));
                activityTable.Columns.Add("SurveyComment", typeof(string));
                activityTable.Columns.Add("TotalPoints", typeof(string));
                activityTable.Columns.Add("Stage", typeof(string));
                activityTable.Columns.Add("DistanceUnitSymbol", typeof(string));
                activityTable.Columns.Add("ElevationUnitSymbol", typeof(string));
                activityTable.Columns.Add("YAxisLabel", typeof(string));
                activityTable.Columns.Add("XAxisLabel", typeof(string));

                DataTable pointsTable = dataSet.Tables.Add("CrossSectionSurveyPoints");
                pointsTable.Columns.Add("ActivityNumber", typeof(int));
                pointsTable.Columns.Add("PointOrder", typeof(string));
                pointsTable.Columns.Add("Distance", typeof(string));
                pointsTable.Columns.Add("Elevation", typeof(string));
                pointsTable.Columns.Add("DistanceUnit", typeof(string));
                pointsTable.Columns.Add("ElevationUnit", typeof(string));
                pointsTable.Columns.Add("DistanceDouble", typeof(double));
                pointsTable.Columns.Add("ElevationDouble", typeof(double));
                pointsTable.Columns.Add("PointComment", typeof(string));

                dataSet.Relations.Add("ActivityPoints", activityTable.Columns["ActivityNumber"], pointsTable.Columns["ActivityNumber"]);

                FieldVisitDataByLocationServiceRequest request = new FieldVisitDataByLocationServiceRequest();
                request.LocationIdentifier = locIdentifier;
                request.ApplyRounding      = true;
                request.Activities         = new List <ActivityType> {
                    ActivityType.CrossSectionSurvey
                };
                request.IncludeCrossSectionSurveyProfile = true;
                request.IncludeInvalidActivities         = false;

                FieldVisitDataByLocationServiceResponse response = publish.Get(request);
                List <FieldVisit> visits = response.FieldVisitData;

                if (sortOrder != "ReverseChronologicalOnStartTime")
                {
                    visits.Sort((x, y) => x.StartTime.Value.CompareTo(y.StartTime.Value));
                }
                else
                {
                    visits.Sort((x, y) => y.StartTime.Value.CompareTo(x.StartTime.Value));
                }

                int activityNumber = 0;
                foreach (FieldVisit visit in visits)
                {
                    if (visit.CrossSectionSurveyActivity == null)
                    {
                        continue;
                    }

                    List <CrossSectionSurveyActivity> activities = visit.CrossSectionSurveyActivity;
                    if (sortOrder != "ReverseChronologicalOnStartTime")
                    {
                        activities.Sort((x, y) => {
                            int ret = x.StartTime.CompareTo(y.StartTime);
                            return((ret != 0) ? ret : string.Compare(x.RelativeLocation, y.RelativeLocation));
                        });
                    }
                    else
                    {
                        activities.Sort((x, y) => {
                            int ret = y.StartTime.CompareTo(x.StartTime);
                            return((ret != 0) ? ret : string.Compare(x.RelativeLocation, y.RelativeLocation));
                        });
                    }

                    foreach (CrossSectionSurveyActivity activity in activities)
                    {
                        if (periodSelected.Start.HasValue && (activity.StartTime < periodSelected.Start.Value))
                        {
                            continue;
                        }
                        if (periodSelected.End.HasValue && (activity.StartTime > periodSelected.End.Value))
                        {
                            continue;
                        }

                        if (!Common.MatchPartialNameFilter(relativeLocationFilter, activity.RelativeLocation))
                        {
                            continue;
                        }
                        if (!Common.MatchPartialNameFilter(channelFilter, activity.Channel))
                        {
                            continue;
                        }
                        if (!Common.MatchPartialNameFilter(partyFilter, activity.Party))
                        {
                            continue;
                        }

                        List <CrossSectionPoint> points = activity.CrossSectionPoints;

                        string distanceUnitId  = "";
                        string elevationUnitId = "";

                        activityNumber++;

                        DataRow activitytRow = activityTable.NewRow();
                        activitytRow["ActivityNumber"]   = activityNumber;
                        activitytRow["RelativeLocation"] = activity.RelativeLocation;
                        activitytRow["Channel"]          = activity.Channel;
                        activitytRow["StartingPoint"]    = activity.StartingPoint.ToString();
                        activitytRow["StartTime"]        = activity.StartTime.ToOffset(utcOffset).ToString(dateFormat);
                        activitytRow["EndTime"]          = activity.EndTime.ToOffset(utcOffset).ToString(dateFormat);
                        activitytRow["Party"]            = activity.Party;
                        activitytRow["SurveyComment"]    = activity.Comments;
                        activitytRow["TotalPoints"]      = (points == null)? "" : points.Count.ToString();

                        if (string.IsNullOrEmpty(stageUnitId))
                        {
                            stageUnitId = activity.Stage.Unit;
                        }
                        string stageUnit = (stageUnitId == activity.Stage.Unit) ? "" : " " + CommonLibrary.GetUnitSymbol(activity.Stage.Unit);
                        activitytRow["Stage"] = activity.Stage.Display + stageUnit;

                        activityTable.Rows.Add(activitytRow);
                        if (points == null)
                        {
                            continue;
                        }

                        points.Sort((x, y) => x.PointOrder.CompareTo(y.PointOrder));

                        for (int i = 0; i < points.Count; i++)
                        {
                            CrossSectionPoint point = points[i];

                            if (string.IsNullOrEmpty(distanceUnitId))
                            {
                                distanceUnitId = point.Distance.Unit;
                            }
                            if (string.IsNullOrEmpty(elevationUnitId))
                            {
                                elevationUnitId = point.Elevation.Unit;
                            }

                            string distanceUnit  = (distanceUnitId == point.Distance.Unit) ? "" : " " + CommonLibrary.GetUnitSymbol(point.Distance.Unit);
                            string elevationUnit = (elevationUnitId == point.Elevation.Unit) ? "" : " " + CommonLibrary.GetUnitSymbol(point.Elevation.Unit);

                            DataRow row = pointsTable.NewRow();

                            row["ActivityNumber"]  = activityNumber;
                            row["PointOrder"]      = point.PointOrder.ToString();
                            row["Distance"]        = point.Distance.Display + distanceUnit;
                            row["Elevation"]       = point.Elevation.Display + elevationUnit;
                            row["DistanceUnit"]    = distanceUnit;
                            row["ElevationUnit"]   = elevationUnit;
                            row["DistanceDouble"]  = (point.Distance.Numeric.HasValue)? point.Distance.Numeric.Value : double.NaN;
                            row["ElevationDouble"] = (point.Elevation.Numeric.HasValue)? +point.Elevation.Numeric.Value : double.NaN;
                            row["PointComment"]    = point.Comments;

                            pointsTable.Rows.Add(row);
                        }

                        string distanceUnitSymbol  = CommonLibrary.GetUnitSymbol(distanceUnitId);
                        string elevationUnitSymbol = CommonLibrary.GetUnitSymbol(elevationUnitId);

                        activitytRow["DistanceUnitSymbol"]  = distanceUnitSymbol;
                        activitytRow["ElevationUnitSymbol"] = elevationUnitSymbol;
                        activitytRow["YAxisLabel"]          = Resources.Elevation + " (" + elevationUnitSymbol + ")";
                        activitytRow["XAxisLabel"]          = Resources.Distance + " (" + distanceUnitSymbol + ")";
                    }

                    stageUnitSymbol = CommonLibrary.GetUnitSymbol(stageUnitId);

                    crossSectionSurveyDataTable.Rows[0]["RelativeLocationColumnHeader"] = Resources.RelativeLocation;
                    crossSectionSurveyDataTable.Rows[0]["ChannelColumnHeader"]          = Resources.Channel;
                    crossSectionSurveyDataTable.Rows[0]["StartingPointColumnHeader"]    = Resources.StartingPoint;
                    crossSectionSurveyDataTable.Rows[0]["StartTimeColumnHeader"]        = Resources.StartTime;
                    crossSectionSurveyDataTable.Rows[0]["EndTimeColumnHeader"]          = Resources.EndTime;
                    crossSectionSurveyDataTable.Rows[0]["PartyColumnHeader"]            = Resources.Party;
                    crossSectionSurveyDataTable.Rows[0]["SurveyCommentColumnHeader"]    = Resources.CrossSectionSurveyComment;
                    crossSectionSurveyDataTable.Rows[0]["TotalPointsColumnHeader"]      = Resources.TotalPoints;
                    crossSectionSurveyDataTable.Rows[0]["StageColumnHeader"]            = Resources.Stage + " (" + stageUnitSymbol + ")";
                }
            }
            catch (Exception exp)
            {
                Log.Error("Error creating report specific data tables ", exp);
                throw exp;
            }
        }
コード例 #6
0
        public static void AddReportSpecificTables(DataSet dataSet)
        {
            try
            {
                RunFileReportRequest runReportRequest = (RunFileReportRequest)dataSet.Tables["RunReportRequest"].Rows[0]["RunReportRequest"];
                IPublishGateway      publish          = runReportRequest.Publish;
                Guid   TimeSeriesUniqueId             = (Guid)dataSet.Tables["SourceData"].Rows[0]["UniqueId"];
                string timeseriesType = (string)dataSet.Tables["SourceData"].Rows[0]["TimeSeriesType"];

                if (timeseriesType != "ProcessorDerived")
                {
                    throw (new Exception("Input is not a derived time-series. Input signal must be a daily selected value derived time-series."));
                }

                Server.Services.PublishService.ServiceModel.RequestDtos.UpchainProcessorListByTimeSeriesServiceRequest upchain = new Server.Services.PublishService.ServiceModel.RequestDtos.UpchainProcessorListByTimeSeriesServiceRequest();
                upchain.TimeSeriesUniqueId = TimeSeriesUniqueId;
                List <Server.Services.PublishService.ServiceModel.Dtos.Processor> processors = publish.Get(upchain).Processors;

                foreach (Server.Services.PublishService.ServiceModel.Dtos.Processor processor in processors)
                {
                    string procType = processor.ProcessorType;
                    if (procType != "statistics")
                    {
                        throw (new Exception("Input is not a statistics derived time-series. Input signal must be a daily selected value derived time-series."));
                    }
                    else
                    {
                        string timeStep      = null;
                        string timeStepCount = null;
                        string statType      = null;

                        Dictionary <string, string> settings = processor.Settings;
                        foreach (var item in settings)
                        {
                            string key = item.Key;
                            string val = item.Value;

                            if (key == "StatisticType")
                            {
                                statType = item.Value;
                            }
                            if (key == "TimeStep")
                            {
                                timeStep = item.Value;
                            }
                            if (key == "TimeStepCount")
                            {
                                timeStepCount = item.Value;
                            }
                        }
                        if (("Daily" != timeStep) || ("1" != timeStepCount) || ("SelectedValue" != statType))
                        {
                            throw (new Exception("Input is not a daily selected value derived time-series. Input signal must be a daily selected value derived time-series."));
                        }

                        break;
                    }
                }

                Common common = (Common)dataSet.Tables["RunReportRequest"].Rows[0]["CommonLibrary"];

                DataTable settingsTable = dataSet.Tables["ReportSettings"];
                settingsTable.Columns.Add("ReportTitle", typeof(string));
                settingsTable.Rows[0]["ReportTitle"] = "Daily Midnight Contents";

                DataTable table = new DataTable("DailyMidnightContentsDataTable");

                dataSet.Tables.Add(table);
            }
            catch (Exception exp)
            {
                Log.Error("Error creating report specific data tables ", exp);
                throw exp;
            }
        }
コード例 #7
0
        public static void AddReportSpecificTables(DataSet dataSet)
        {
            try
            {
                Common common = (Common)dataSet.Tables["RunReportRequest"].Rows[0]["CommonLibrary"];

                DataTable settingsTable = dataSet.Tables["ReportSettings"];
                settingsTable.Columns.Add("ReportTitle", typeof(string));
                settingsTable.Rows[0]["ReportTitle"] = Resources.FieldActivity;

                DataTable table = new DataTable("FieldActivityDataTable");

                dataSet.Tables.Add(table);

                RunFileReportRequest runReportRequest = (RunFileReportRequest)dataSet.Tables["RunReportRequest"].Rows[0]["RunReportRequest"];
                IPublishGateway      publish          = runReportRequest.Publish;
                string locationIdentifier             = (string)dataSet.Tables["LocationInput"].Rows[0]["Identifier"];

                string dllName = (string)dataSet.Tables["RunReportRequest"].Rows[0]["DllName"];
                Log.DebugFormat("{0} - Document GenerateScript input location = {1}", dllName, locationIdentifier);

                ///////////////////////////////////////////////////////////////
                DateTimeOffsetInterval reportPeriod = (DateTimeOffsetInterval)dataSet.Tables["ReportPeriods"].Rows[0]["NoGroupBy"];

                string sortOrder = common.GetParameterString("SortOrder", "ReverseChronologicalOnMeasurementTime");

                DataTable table1 = dataSet.Tables.Add("FieldActivity");

                table1.Columns.Add("Date", typeof(string));
                table1.Columns.Add("Time", typeof(string));
                table1.Columns.Add("Timezone", typeof(string));
                table1.Columns.Add("ActivityType", typeof(string));
                table1.Columns.Add("Stage", typeof(string));
                table1.Columns.Add("StageUnit", typeof(string));
                table1.Columns.Add("Discharge", typeof(string));
                table1.Columns.Add("DischargeUnit", typeof(string));
                table1.Columns.Add("ControlCondition", typeof(string));
                table1.Columns.Add("ActivityRemarks", typeof(string));
                table1.Columns.Add("FieldVisitComments", typeof(string));

                FieldVisitDataByLocationServiceRequest fdRequest = new FieldVisitDataByLocationServiceRequest();
                fdRequest.LocationIdentifier = locationIdentifier;
                fdRequest.ApplyRounding      = true;
                fdRequest.Activities         = new List <ActivityType> {
                    ActivityType.Reading, ActivityType.DischargeSummary, ActivityType.ControlCondition
                };
                FieldVisitDataByLocationServiceResponse fdResponse = publish.Get(fdRequest);
                List <FieldVisit> fieldVisitData = fdResponse.FieldVisitData;

                try
                {
                    if (sortOrder != "ReverseChronologicalOnMeasurementTime")
                    {
                        fieldVisitData.Sort((x, y) => x.StartTime.Value.CompareTo(y.StartTime.Value));
                    }
                    else
                    {
                        fieldVisitData.Sort((x, y) => y.StartTime.Value.CompareTo(x.StartTime.Value));
                    }
                }
                catch { }

                foreach (FieldVisit fieldVisit in fieldVisitData)
                {
                    if (!ReportSpecificFunctions.TimeRangeOverlaps(fieldVisit.StartTime.Value, fieldVisit.StartTime.Value, reportPeriod))
                    {
                        continue;
                    }

                    if (fieldVisit.DischargeActivities != null)
                    {
                        var activities = fieldVisit.DischargeActivities;

                        if (sortOrder != "ReverseChronologicalOnMeasurementTime")
                        {
                            activities.Sort((x, y) => x.DischargeSummary.MeasurementTime.CompareTo(y.DischargeSummary.MeasurementTime));
                        }
                        else
                        {
                            activities.Sort((x, y) => y.DischargeSummary.MeasurementTime.CompareTo(x.DischargeSummary.MeasurementTime));
                        }

                        foreach (DischargeActivity dischargeActivity in activities)
                        {
                            if (dischargeActivity.DischargeSummary == null)
                            {
                                continue;
                            }

                            DataRow row = table1.NewRow();
                            row["Date"]               = (fieldVisit.StartTime.HasValue) ? fieldVisit.StartTime.Value.ToString("yyyy-MM-dd") : "";
                            row["ControlCondition"]   = (fieldVisit.ControlConditionActivity != null) ? fieldVisit.ControlConditionActivity.ControlCondition.ToString() : "";
                            row["FieldVisitComments"] = fieldVisit.Remarks;
                            row["ActivityType"]       = Resources.DischargeSummary;

                            DischargeSummary dischargeSummary = dischargeActivity.DischargeSummary;
                            row["Time"]     = dischargeSummary.MeasurementTime.ToString("HH:mm");
                            row["Timezone"] = dischargeSummary.MeasurementTime.ToString("zzz");
                            string discharge     = (dischargeSummary.Discharge != null) ? dischargeSummary.Discharge.Display : "";
                            string dischargeUnit = (dischargeSummary.Discharge != null) ? dischargeSummary.Discharge.Unit : "";
                            if (dischargeUnit != "m^3/s")
                            {
                                discharge += " " + dischargeUnit;
                            }
                            row["Discharge"] = discharge;

                            string stage     = (dischargeSummary.MeanGageHeight != null) ? dischargeSummary.MeanGageHeight.Display : "";
                            string stageUnit = (dischargeSummary.MeanGageHeight != null) ? dischargeSummary.MeanGageHeight.Unit : "";
                            if (!string.IsNullOrEmpty(stage) && (stageUnit != "m"))
                            {
                                stage += " " + stageUnit;
                            }
                            row["Stage"]           = stage;
                            row["ActivityRemarks"] = dischargeSummary.Comments;

                            table1.Rows.Add(row);
                        }
                    }
                    if ((fieldVisit.InspectionActivity != null) && (fieldVisit.InspectionActivity.Readings != null))
                    {
                        foreach (Reading reading in fieldVisit.InspectionActivity.Readings)
                        {
                            if (!reading.Publish || !reading.IsValid)
                            {
                                continue;
                            }
                            if ("Stage" != reading.Parameter)
                            {
                                continue;
                            }

                            DataRow row = table1.NewRow();
                            row["Date"]               = (fieldVisit.StartTime.HasValue) ? fieldVisit.StartTime.Value.ToString("yyyy-MM-dd") : "";
                            row["ControlCondition"]   = (fieldVisit.ControlConditionActivity != null) ? fieldVisit.ControlConditionActivity.ControlCondition.ToString() : "";
                            row["FieldVisitComments"] = fieldVisit.Remarks;
                            row["ActivityType"]       = Resources.Reading;

                            row["Time"]     = (reading.Time.HasValue) ? reading.Time.Value.ToString("HH:mm") : "";
                            row["Timezone"] = (reading.Time.HasValue) ? reading.Time.Value.ToString("zzz") : "";
                            string stage     = reading.Value.Display;
                            string stageUnit = reading.Unit;
                            if (stageUnit != "m")
                            {
                                stage += " " + stageUnit;
                            }
                            row["Stage"]           = stage;
                            row["ActivityRemarks"] = reading.Comments;

                            table1.Rows.Add(row);
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                Log.Error("Error creating report specific data tables ", exp);
                throw exp;
            }
        }