public String getContactCFE_byRUP(string strRPU) { clsZone oClsZone = new clsZone(); clsContactCFE oClsContactoCFE = new clsContactCFE(); DataTable dtZone; StringBuilder strHTMLGroup = new StringBuilder(); dtZone = oClsContactoCFE.getByRUP(strRPU); if (dtZone == null) { return("Error al recuperar los datos"); } else { if (dtZone.Rows.Count > 0) { strHTMLGroup = oClsContactoCFE.ReturnHTMLRup(dtZone); return(strHTMLGroup.ToString()); //return "<div class='table-responsive'><table class='table table-hover table-bordred table-striped table-bordered'><thead><tr class='filters'><th class='text-center'>CFE</th></tr></thead><tbody><tr><td>Juna Pérez <p>Av. 5 de Mayo No. 1390 Col. Napoles </p><p><a href='mailto:[email protected]'>[email protected]</a> </p></td></tr></tbody></table></div>: "; } else { return("No hay datos para mostrar"); } } }
public List <NameContract> ListZonesContact() { Event.WriteVerbose("WebService", "ListZonesContact"); List <NameContract> names = new List <NameContract>(); for (ushort i = 1; i < WebService.HAC.Zones.Count; i++) { clsZone zone = WebService.HAC.Zones[i]; if ((zone.ZoneType == enuZoneType.EntryExit || zone.ZoneType == enuZoneType.X2EntryDelay || zone.ZoneType == enuZoneType.X4EntryDelay || zone.ZoneType == enuZoneType.Perimeter || zone.ZoneType == enuZoneType.Tamper || zone.ZoneType == enuZoneType.Auxiliary) && zone.DefaultProperties == false) { names.Add(new NameContract() { id = i, name = zone.Name }); } } return(names); }
public static string ToState(this clsZone zone) { if (zone.Status.IsBitSet(5)) { return("bypassed"); } else if (zone.Status.IsBitSet(2)) { return("tripped"); } else if (zone.Status.IsBitSet(4)) { return("armed"); } else if (zone.Status.IsBitSet(1)) { return("trouble"); } else if (zone.Status.IsBitSet(0)) { return("not_ready"); } else { return("secure"); } }
public List <NameContract> ListZonesContact() { log.Debug("ListZonesContact"); List <NameContract> names = new List <NameContract>(); for (ushort i = 1; i < WebServiceModule.OmniLink.Controller.Zones.Count; i++) { clsZone zone = WebServiceModule.OmniLink.Controller.Zones[i]; if ((zone.ZoneType == enuZoneType.EntryExit || zone.ZoneType == enuZoneType.X2EntryDelay || zone.ZoneType == enuZoneType.X4EntryDelay || zone.ZoneType == enuZoneType.Perimeter || zone.ZoneType == enuZoneType.Tamper || zone.ZoneType == enuZoneType.Auxiliary) && zone.DefaultProperties == false) { names.Add(new NameContract() { id = i, name = zone.Name }); } } return(names); }
private void ProcessZoneReceived(clsZone zone, Topic command, string payload) { if (command == Topic.command && Enum.TryParse(payload, true, out ZoneCommands cmd)) { log.Debug("SetZone: {id} to {value}", zone.Number, payload); OmniLink.SendCommand(ZoneMapping[cmd], 0, (ushort)zone.Number); } }
public void Buscar() { clsZone oClsZone = new clsZone(); DataTable dtZone; StringBuilder strHTMLGroup = new StringBuilder(); try { msgErrNew.InnerText = ""; msgErrNew.Style.Add("display", "none"); string strDivision = cmbDivision.Items[cmbDivision.SelectedIndex].Value; string strZone = string.Empty; if (cmbZone.SelectedIndex != -1) { strZone = cmbZone.Items[cmbZone.SelectedIndex].Value; } if (strDivision == "0") { strDivision = ""; } dtZone = oClsZone.ValidateFilters(strDivision, strZone); if (dtZone == null) { //msgErrNew.InnerText = ""; //msgErrNew.Style.Add("display", "inline"); //msgErrNew.InnerText = "Error al recuperar los datos"; ScriptManager.RegisterStartupScript(this, GetType(), "muestraError", "swal('','Error al recuperar los datos','warning');", true); } else { if (dtZone.Rows.Count > 0) { strHTMLGroup = oClsZone.ReturnHTMLDivision(dtZone); DBDataPlaceHolder.Controls.Add(new Literal { Text = strHTMLGroup.ToString() }); } else { //msgErrNew.InnerText = ""; //msgErrNew.Style.Add("display", "inline"); //msgErrNew.InnerText = "No hay datos para mostrar"; ScriptManager.RegisterStartupScript(this, GetType(), "muestraError", "swal('','No hay datos para mostrar','warning');", true); } } } catch (Exception ex) { clsError.logMessage = ex.ToString(); clsError.logModule = "btnSearch_Click"; clsError.LogWrite(); msgErrNew.InnerText = ""; msgErrNew.Style.Add("display", "inline"); msgErrNew.InnerHtml = ex.ToString(); } }
public void Select() { clsZone clsBussinesZone = new clsZone(); try { if (IsPostBack) { string s = cmbDivision.Items[cmbDivision.SelectedIndex].Value; if (!string.IsNullOrEmpty(s)) { if (s == "-- TODOS --") { cmbZone.Items.Clear(); //btnSearch_Click(sender, e); } else { DataTable dtZBD; cmbZone.Items.Clear(); dtZBD = clsBussinesZone.dtGetZoneByDivision(s); if (dtZBD == null) { //msgErrNew.InnerHtml = ""; //msgErrNew.Style.Add("display", "none"); //msgErrNew.InnerHtml = "Error al recuperar los datos"; ScriptManager.RegisterStartupScript(this, GetType(), "muestraError", "swal('','Error al recuperar los datos','warning');", true); } else { if (dtZBD.Rows.Count > 0) { dtZBD.Rows.Add(-1, "-- TODOS --", 0); DataSet ds = new DataSet(); ds.Tables.Add(dtZBD.Copy()); cmbZone.DataSource = ds; cmbZone.DataTextField = "Zona"; cmbZone.DataValueField = "Id"; cmbZone.DataBind(); //cmbZone.Items.Add(""); //cmbZone.SelectedValue = ""; msgErrNew.InnerHtml = ""; } } } } } } catch (Exception ex) { clsError.logMessage = ex.ToString(); clsError.logModule = "itemSelected"; clsError.LogWrite(); msgErrNew.InnerHtml = ""; msgErrNew.Style.Add("display", "none"); msgErrNew.InnerHtml = ex.ToString(); } }
public static Sensor ToConfigHumidity(this clsZone zone) { Sensor ret = new Sensor(); ret.name = $"{Global.mqtt_discovery_name_prefix}{zone.Name} Humidity"; ret.device_class = Sensor.DeviceClass.humidity; ret.state_topic = zone.ToTopic(Topic.current_humidity); ret.unit_of_measurement = "%"; return(ret); }
public static Sensor ToConfigTemp(this clsZone zone) { Sensor ret = new Sensor(); ret.name = $"{Global.mqtt_discovery_name_prefix}{zone.Name} Temp"; ret.device_class = Sensor.DeviceClass.temperature; ret.state_topic = zone.ToTopic(Topic.current_temperature); ret.unit_of_measurement = "°F"; return(ret); }
protected void itemSelectedSearch(object sender, EventArgs e) { clsZone clsBussinesZone = new clsZone(); try { if (IsPostBack) { string s = cmbSearchDivision.Items[cmbSearchDivision.SelectedIndex].Value; if (!string.IsNullOrEmpty(s)) { if (s == "-- TODOS --" || string.IsNullOrEmpty(s)) { cmbSearchZone.Items.Clear(); btnSearch_Click(sender, e); } else { DataTable dtZBD; cmbSearchZone.Items.Clear(); dtZBD = clsBussinesZone.dtGetZoneByDivision(s); if (dtZBD == null) { msgErrorSearch.InnerHtml = ""; msgErrorSearch.Style.Add("display", "none"); msgErrorSearch.InnerHtml = "Error al recuperar los datos"; } else { if (dtZBD.Rows.Count > 0) { dtZBD.Rows.Add(0, "-- TODOS --", 0); DataSet ds = new DataSet(); ds.Tables.Add(dtZBD.Copy()); cmbSearchZone.DataSource = ds; cmbSearchZone.DataTextField = "Zona"; cmbSearchZone.DataValueField = "Id"; cmbSearchZone.DataBind(); cmbSearchZone.Items.Add(""); cmbSearchZone.SelectedValue = ""; } } } } } } catch (Exception ex) { clsError.logMessage = ex.ToString(); clsError.logModule = "itemSelected"; clsError.LogWrite(); msgErrorSearch.InnerHtml = ""; msgErrorSearch.Style.Add("display", "none"); msgErrorSearch.InnerHtml = ex.ToString(); } }
public static Sensor ToConfigTemp(this clsZone zone, enuTempFormat format) { Sensor ret = new Sensor(); ret.unique_id = $"{Global.mqtt_prefix}zone{zone.Number.ToString()}temp"; ret.name = $"{Global.mqtt_discovery_name_prefix}{zone.Name} Temp"; ret.device_class = Sensor.DeviceClass.temperature; ret.state_topic = zone.ToTopic(Topic.current_temperature); ret.unit_of_measurement = (format == enuTempFormat.Fahrenheit ? "°F" : "°C"); return(ret); }
public static ZoneContract ToContract(this clsZone zone) { ZoneContract ret = new ZoneContract(); ret.id = (ushort)zone.Number; ret.zonetype = zone.ZoneType; ret.name = zone.Name; ret.status = zone.StatusText(); ret.temp = zone.TempText(); return(ret); }
public static BinarySensor ToConfig(this clsZone zone) { BinarySensor ret = new BinarySensor(); ret.unique_id = $"{Global.mqtt_prefix}zone{zone.Number.ToString()}binary"; ret.name = Global.mqtt_discovery_name_prefix + zone.Name; Global.mqtt_discovery_override_zone.TryGetValue(zone.Number, out OverrideZone override_zone); if (override_zone != null) { ret.device_class = override_zone.device_class; } else { switch (zone.ZoneType) { case enuZoneType.EntryExit: case enuZoneType.X2EntryDelay: case enuZoneType.X4EntryDelay: ret.device_class = BinarySensor.DeviceClass.door; break; case enuZoneType.Perimeter: ret.device_class = BinarySensor.DeviceClass.window; break; case enuZoneType.Tamper: ret.device_class = BinarySensor.DeviceClass.problem; break; case enuZoneType.AwayInt: case enuZoneType.NightInt: ret.device_class = BinarySensor.DeviceClass.motion; break; case enuZoneType.Water: ret.device_class = BinarySensor.DeviceClass.moisture; break; case enuZoneType.Fire: ret.device_class = BinarySensor.DeviceClass.smoke; break; case enuZoneType.Gas: ret.device_class = BinarySensor.DeviceClass.gas; break; } } ret.state_topic = zone.ToTopic(Topic.basic_state); return(ret); }
public static ZoneContract ConvertZone(ushort id, clsZone zone) { ZoneContract ret = new ZoneContract(); ret.id = id; ret.zonetype = zone.ZoneType; ret.name = zone.Name; ret.status = zone.StatusText(); ret.temp = zone.TempText(); return(ret); }
private void Buscar() { clsZone oClsZone = new clsZone(); clsContactCFE oClsContactoCFE = new clsContactCFE(); DataTable dtZone; StringBuilder strHTMLGroup = new StringBuilder(); try { msgErrorSearch.InnerText = ""; msgErrorSearch.Style.Add("display", "none"); string strDivision = cmbSearchDivision.Items[cmbSearchDivision.SelectedIndex].Value; string strZone = string.Empty; if (cmbSearchZone.SelectedIndex != -1) { strZone = cmbSearchZone.Items[cmbSearchZone.SelectedIndex].Value; } dtZone = oClsContactoCFE.ValidateFilters(strDivision, strZone); if (dtZone == null) { msgErrorSearch.InnerText = ""; msgErrorSearch.Style.Add("display", "inline"); msgErrorSearch.InnerText = "Error al recuperar los datos"; } else { if (dtZone.Rows.Count > 0) { strHTMLGroup = oClsContactoCFE.ReturnHTMLDivision(dtZone); DBDataPlaceHolder.Controls.Add(new Literal { Text = strHTMLGroup.ToString() }); } else { msgErrorSearch.InnerText = ""; msgErrorSearch.Style.Add("display", "inline"); msgErrorSearch.InnerText = "No hay datos para mostrar"; } } } catch (Exception ex) { clsError.logMessage = ex.ToString(); clsError.logModule = "btnSearch_Click"; clsError.LogWrite(); msgErrorSearch.InnerText = ""; msgErrorSearch.Style.Add("display", "inline"); msgErrorSearch.InnerHtml = ex.ToString(); } }
private void Omnilink_OnConnect(object sender, EventArgs e) { if (Global.verbose_area) { for (ushort i = 1; i <= omnilink.Controller.Areas.Count; i++) { clsArea area = omnilink.Controller.Areas[i]; if (i > 1 && area.DefaultProperties == true) { continue; } string status = area.ModeText(); if (area.ExitTimer > 0) { status = "ARMING " + status; } if (area.EntryTimer > 0) { status = "TRIPPED " + status; } log.Verbose("Initial AreaStatus {id} {name}, Status: {status}, Alarms: {alarms}", i, area.Name, status, area.AreaAlarms); } } if (Global.verbose_zone) { for (ushort i = 1; i <= omnilink.Controller.Zones.Count; i++) { clsZone zone = omnilink.Controller.Zones[i]; if (zone.DefaultProperties == true) { continue; } if (zone.IsTemperatureZone()) { log.Verbose("Initial ZoneStatus {id} {name}, Temp: {temp}", i, zone.Name, zone.TempText()); } else { log.Verbose("Initial ZoneStatus {id} {name}, Status: {status}", i, zone.Name, zone.StatusText()); } } } }
private void PublishZoneState(clsZone zone) { MqttClient.PublishAsync(zone.ToTopic(Topic.state), zone.ToState(), MqttQualityOfServiceLevel.AtMostOnce, true); MqttClient.PublishAsync(zone.ToTopic(Topic.basic_state), zone.ToBasicState(), MqttQualityOfServiceLevel.AtMostOnce, true); if (zone.IsTemperatureZone()) { MqttClient.PublishAsync(zone.ToTopic(Topic.current_temperature), zone.TempText(), MqttQualityOfServiceLevel.AtMostOnce, true); } else if (zone.IsHumidityZone()) { MqttClient.PublishAsync(zone.ToTopic(Topic.current_humidity), zone.TempText(), MqttQualityOfServiceLevel.AtMostOnce, true); } }
private void PublishZoneState(clsZone zone) { PublishAsync(zone.ToTopic(Topic.state), zone.ToState()); PublishAsync(zone.ToTopic(Topic.basic_state), zone.ToBasicState()); if (zone.IsTemperatureZone()) { PublishAsync(zone.ToTopic(Topic.current_temperature), zone.TempText()); } else if (zone.IsHumidityZone()) { PublishAsync(zone.ToTopic(Topic.current_humidity), zone.TempText()); } }
public ZoneContract GetZone(ushort id) { Event.WriteVerbose("WebService", "GetZone: " + id); WebOperationContext ctx = WebOperationContext.Current; if (WebService.HAC.Zones[id].IsTemperatureZone()) { ctx.OutgoingResponse.Headers.Add("type", "temp"); } else { switch (WebService.HAC.Zones[id].ZoneType) { case enuZoneType.EntryExit: case enuZoneType.X2EntryDelay: case enuZoneType.X4EntryDelay: case enuZoneType.Perimeter: case enuZoneType.Tamper: case enuZoneType.Auxiliary: ctx.OutgoingResponse.Headers.Add("type", "contact"); break; case enuZoneType.AwayInt: case enuZoneType.NightInt: ctx.OutgoingResponse.Headers.Add("type", "motion"); break; case enuZoneType.Water: ctx.OutgoingResponse.Headers.Add("type", "water"); break; case enuZoneType.Fire: ctx.OutgoingResponse.Headers.Add("type", "smoke"); break; case enuZoneType.Gas: ctx.OutgoingResponse.Headers.Add("type", "co"); break; default: ctx.OutgoingResponse.Headers.Add("type", "unknown"); break; } } clsZone unit = WebService.HAC.Zones[id]; return(Helper.ConvertZone(id, unit)); }
private void Omnilink_OnAreaStatus(object sender, AreaStatusEventArgs e) { PublishAreaState(e.Area); // Since the controller doesn't fire zone status change on area status change // request update so armed, tripped, and secure statuses are correct for (ushort i = 1; i < OmniLink.Controller.Zones.Count; i++) { clsZone zone = OmniLink.Controller.Zones[i]; if (zone.DefaultProperties == false && zone.Area == e.Area.Number) { OmniLink.Controller.Connection.Send(new clsOL2MsgRequestExtendedStatus(OmniLink.Controller.Connection, enuObjectType.Zone, i, i), HandleRequestZoneStatus); } } }
private void HandleRequestZoneStatus(clsOmniLinkMessageQueueItem M, byte[] B, bool Timeout) { if (Timeout) { return; } clsOL2MsgExtendedStatus MSG = new clsOL2MsgExtendedStatus(OmniLink.Controller.Connection, B); for (byte i = 0; i < MSG.ZoneStatusCount(); i++) { clsZone zone = OmniLink.Controller.Zones[MSG.ObjectNumber(i)]; zone.CopyExtendedStatus(MSG, i); MqttClient.PublishAsync(zone.ToTopic(Topic.state), zone.ToState(), MqttQualityOfServiceLevel.AtMostOnce, true); } }
private void ProcessZoneReceived(clsZone zone, string command, string payload) { if (string.Compare(command, Topic.command.ToString()) == 0) { if (string.Compare(payload, "bypass", true) == 0) { log.Debug("SetZone: " + zone.Number + " to " + payload); OmniLink.Controller.SendCommand(enuUnitCommand.Bypass, 0, (ushort)zone.Number); } else if (string.Compare(payload, "restore", true) == 0) { log.Debug("SetZone: " + zone.Number + " to " + payload); OmniLink.Controller.SendCommand(enuUnitCommand.Restore, 0, (ushort)zone.Number); } } }
private void PublishZones() { log.Debug("Publishing {type}", "zones"); for (ushort i = 1; i <= OmniLink.Controller.Zones.Count; i++) { clsZone zone = OmniLink.Controller.Zones[i]; if (zone.DefaultProperties == true) { PublishAsync(zone.ToTopic(Topic.name), null); } else { PublishZoneState(zone); PublishAsync(zone.ToTopic(Topic.name), zone.Name); } if (zone.DefaultProperties == true || Global.mqtt_discovery_ignore_zones.Contains(zone.Number)) { PublishAsync($"{Global.mqtt_discovery_prefix}/binary_sensor/{Global.mqtt_prefix}/zone{i}/config", null); PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}/config", null); PublishAsync($"{Global.mqtt_discovery_prefix}/switch/{Global.mqtt_prefix}/zone{i}/config", null); PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}temp/config", null); PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}humidity/config", null); continue; } PublishAsync($"{Global.mqtt_discovery_prefix}/binary_sensor/{Global.mqtt_prefix}/zone{i}/config", JsonConvert.SerializeObject(zone.ToConfig())); PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}/config", JsonConvert.SerializeObject(zone.ToConfigSensor())); PublishAsync($"{Global.mqtt_discovery_prefix}/switch/{Global.mqtt_prefix}/zone{i}/config", JsonConvert.SerializeObject(zone.ToConfigSwitch())); if (zone.IsTemperatureZone()) { PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}temp/config", JsonConvert.SerializeObject(zone.ToConfigTemp(OmniLink.Controller.TempFormat))); } else if (zone.IsHumidityZone()) { PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}humidity/config", JsonConvert.SerializeObject(zone.ToConfigHumidity())); } } }
public static Sensor ToConfigSensor(this clsZone zone) { Sensor ret = new Sensor(); ret.unique_id = $"{Global.mqtt_prefix}zone{zone.Number.ToString()}"; ret.name = Global.mqtt_discovery_name_prefix + zone.Name; switch (zone.ZoneType) { case enuZoneType.EntryExit: case enuZoneType.X2EntryDelay: case enuZoneType.X4EntryDelay: ret.icon = "mdi:door"; break; case enuZoneType.Perimeter: ret.icon = "mdi:window-closed"; break; case enuZoneType.Tamper: ret.icon = "mdi:shield"; break; case enuZoneType.AwayInt: case enuZoneType.NightInt: ret.icon = "mdi:walk"; break; case enuZoneType.Water: ret.icon = "mdi:water"; break; case enuZoneType.Fire: ret.icon = "mdi:fire"; break; case enuZoneType.Gas: ret.icon = "mdi:gas-cylinder"; break; } ret.value_template = @"{{ value|replace(""_"", "" "")|title }}"; ret.state_topic = zone.ToTopic(Topic.state); return(ret); }
public String EditZone(string strDivision, string strIdZone, string strCveZone, string strZone, string strObservations) { Boolean msg = true; string sResp = ""; clsZone oclsZone = new clsZone(); //if (string.IsNullOrEmpty(strDivision)) { return "Falta agregar la Division"; } //if (string.IsNullOrEmpty(strIdZone)) { return "Falta agregar el Id de la zona"; } //if (string.IsNullOrEmpty(strCveZone)) { return "Falta agregar la clave de la zona"; } //if (string.IsNullOrEmpty(strZone)) { return "Falta agregar la descripción de la zona"; } sResp = oclsZone.UpdateZone(strDivision, strIdZone, strCveZone, strZone, strObservations); //if (msg) { return "La Zona se ha actualizado en la base de datos"; } //else { return "Error al actualizar los datos"; } return(sResp); }
private void ProcessZoneReceived(clsZone zone, Topic command, string payload) { int code; (payload, code) = payload.ToCommandCode(); if (command == Topic.command && Enum.TryParse(payload, true, out ZoneCommands cmd) && !(zone.Number == 0 && cmd == ZoneCommands.bypass)) { if (zone.Number == 0) { log.Debug("SetZone: 0 implies all zones will be restored"); } log.Debug("SetZone: {id} to {value}", zone.Number, payload); OmniLink.SendCommand(ZoneMapping[cmd], (byte)code, (ushort)zone.Number); } }
public List <NameContract> ListZonesTemp() { log.Debug("ListZonesTemp"); List <NameContract> names = new List <NameContract>(); for (ushort i = 1; i < WebServiceModule.OmniLink.Controller.Zones.Count; i++) { clsZone zone = WebServiceModule.OmniLink.Controller.Zones[i]; if (zone.IsTemperatureZone() && zone.DefaultProperties == false) { names.Add(new NameContract() { id = i, name = zone.Name }); } } return(names); }
public List <NameContract> ListZonesWater() { log.Debug("ListZonesWater"); List <NameContract> names = new List <NameContract>(); for (ushort i = 1; i <= WebServiceModule.OmniLink.Controller.Zones.Count; i++) { clsZone zone = WebServiceModule.OmniLink.Controller.Zones[i]; if (zone.DefaultProperties == false && zone.ToDeviceType() == DeviceType.water) { names.Add(new NameContract() { id = i, name = zone.Name }); } } return(names); }
public String DeleteZone(string strDivision, string strZone) { clsZone oclsZone = new clsZone(); Boolean msg = true; if (string.IsNullOrEmpty(strDivision) && string.IsNullOrEmpty(strZone)) { return("Falta agregar la división y la zona"); } msg = oclsZone.DeleteZone(strDivision, strZone); if (msg) { return("La Zona se ha eliminado de la base de datos"); } else { return("Error al eliminar la Zona de la base de datos"); } }
public static ZoneContract ToContract(this clsZone zone) { ZoneContract ret = new ZoneContract(); ret.id = (ushort)zone.Number; ret.zonetype = zone.ZoneType; ret.name = zone.Name; ret.status = zone.StatusText(); if (zone.IsTemperatureZone()) { ret.temp = zone.TempText(); } else if (zone.IsHumidityZone()) { ret.temp = zone.TempText(); } return(ret); }