Ejemplo n.º 1
0
        private void AddForecastDay(EwsContainerItem parentContainer, int dayNumber)
        {
            var containerId = string.Format(ServerHelper.ForecastDayContainerId, dayNumber);
            var parent      = EnsureContainerItem(containerId, $"Day {dayNumber}", null, EwsContainerTypeEnum.Folder, parentContainer);

            // Date
            EnsureValueItem(string.Format(ServerHelper.ForecastDayDateId, dayNumber), "Date", null, EwsValueTypeEnum.DateTime, parent, null,
                            EwsValueWriteableEnum.ReadOnly, EwsValueForceableEnum.NotForceable);

            // High Temp
            EnsureValueItem(string.Format(ServerHelper.ForecastDayHighTempId, dayNumber), "High Temp", null, EwsValueTypeEnum.Double, parent, "°C",
                            EwsValueWriteableEnum.ReadOnly, EwsValueForceableEnum.NotForceable);

            // Low Temp
            EnsureValueItem(string.Format(ServerHelper.ForecastDayLowTempId, dayNumber), "Low Temp", null, EwsValueTypeEnum.Double, parent, "°C",
                            EwsValueWriteableEnum.ReadOnly, EwsValueForceableEnum.NotForceable);

            // Pressure
            EnsureValueItem(string.Format(ServerHelper.ForecastDayPressureId, dayNumber), "Pressure", null, EwsValueTypeEnum.Double, parent, "hPa",
                            EwsValueWriteableEnum.ReadOnly, EwsValueForceableEnum.NotForceable);

            // Relative Humidity
            EnsureValueItem(string.Format(ServerHelper.ForecastDayRelativeHumidityId, dayNumber), "Humidity", null, EwsValueTypeEnum.Integer, parent, "%",
                            EwsValueWriteableEnum.ReadOnly, EwsValueForceableEnum.NotForceable);

            // Forecast Description
            EnsureValueItem(string.Format(ServerHelper.ForecastDayDescriptionId, dayNumber), "Forecast", null, EwsValueTypeEnum.String, parent, null,
                            EwsValueWriteableEnum.ReadOnly, EwsValueForceableEnum.NotForceable);
        }
Ejemplo n.º 2
0
        private EwsValueItem EnsureValueItem(string altId, string name = null, string description = null, EwsValueTypeEnum type = EwsValueTypeEnum.String, EwsContainerItem parent = null, string unit = null, EwsValueWriteableEnum writeable = EwsValueWriteableEnum.Writeable, EwsValueForceableEnum forceable = EwsValueForceableEnum.Forceable, EwsValueStateEnum defaultState = EwsValueStateEnum.Uncertain)
        {
            CheckCancellationToken();

            var vi = DataAdapter.ValueItems.FirstOrDefault(x => x.AlternateId == altId);

            if (vi == null)
            {
                return(DataAdapter.AddValueItem(altId, name ?? altId, description, type, writeable, forceable, defaultState, unit, parent));
            }
            vi = DataAdapter.ModifyValueItemName(vi, altId);
            vi = DataAdapter.ModifyValueItemDescription(vi, description);
            vi = DataAdapter.ModifyValueItemType(vi, type);
            vi = DataAdapter.ModifyValueItemWriteable(vi, writeable);
            vi = DataAdapter.ModifyValueItemForceable(vi, forceable);
            vi = DataAdapter.ModifyValueItemUnit(vi, unit);
            return(DataAdapter.ModifyValueItemParent(vi, parent));
        }
Ejemplo n.º 3
0
        private EwsHistoryItem EnsureHistoryItem(string altId, string name, string description, EwsValueItem valueItem, EwsContainerItem parent = null)
        {
            CheckCancellationToken();

            var hi = DataAdapter.HistoryItems.FirstOrDefault(x => x.AlternateId == altId);

            if (hi == null)
            {
                return(DataAdapter.AddHistoryItem(altId, name ?? altId, description, valueItem, true, parent));
            }
            hi = DataAdapter.ModifyHistoryItemName(hi, altId);
            hi = DataAdapter.ModifyHistoryItemDescription(hi, description);
            return(DataAdapter.ModifyHistoryItemParent(hi, parent));
        }
Ejemplo n.º 4
0
        private EwsContainerItem EnsureContainerItem(string altId, string name = null, string description = null, EwsContainerTypeEnum type = EwsContainerTypeEnum.Folder, EwsContainerItem parent = null)
        {
            CheckCancellationToken();

            var ci = DataAdapter.ContainerItems.FirstOrDefault(x => x.AlternateId == altId);

            if (ci == null)
            {
                return(DataAdapter.AddContainerItem(altId, name ?? altId, description, type, parent));
            }
            ci = DataAdapter.ModifyContainerItemName(ci, altId);
            ci = DataAdapter.ModifyContainerItemDescription(ci, description);
            ci = DataAdapter.ModifyContainerItemType(ci, type);
            return(DataAdapter.ModifyContainerItemParent(ci, parent));
        }