public static int SeekActiveUnitsCuenca(DataTable dtzone, int qty) { System.Configuration.AppSettingsReader appSettings = new System.Configuration.AppSettingsReader(); string UNIT_ID = (string)appSettings.GetValue("GroupsChilds.UnitId", typeof(string)); string swhere = ""; CmpGroupsChildsGisDB cGroupChildsDb = new CmpGroupsChildsGisDB(); CmpGroupsDB cGroupsDb = new CmpGroupsDB(); foreach (DataRow dr in dtzone.Rows) { // If there is not a UNIT we follow deeping in the tree...(Level 2) if (dr["CGRPG_TYPE"].ToString() != UNIT_ID) { swhere = "CGRPG_ID = "+ dr["CGRPG_CHILD"].ToString(); DataTable dtsubzone = cGroupChildsDb.GetData(null, swhere, null, null); qty = SeekActiveUnits(dtsubzone, qty); } else { CmpUnitsDB udb = new CmpUnitsDB(); swhere = "UNI_ID = " + dr["CGRPG_CHILD"].ToString() + " AND UNI_IP IS NOT NULL AND UNI_DSTA_ID IN (0,1,2)"; DataTable dtUnit = udb.GetData(null, swhere, null, null); if (dtUnit.Rows.Count != 0) { qty++; } } } return(qty); }
public static int SeekUnitAlarmsQty(DataTable dtzone, int qty, int zoneId) { System.Configuration.AppSettingsReader appSettings = new System.Configuration.AppSettingsReader(); string UNIT_ID = (string)appSettings.GetValue("GroupsChilds.UnitId", typeof(string)); string swhere = ""; CmpGroupsChildsGisDB cGroupChildsDb = new CmpGroupsChildsGisDB(); CmpGroupsDB cGroupsDb = new CmpGroupsDB(); foreach (DataRow dr in dtzone.Rows) { // If there is not a UNIT we follow deeping in the tree...(Level 2) if (dr["CGRPG_TYPE"].ToString() != UNIT_ID) { swhere = "CGRPG_ID = "+ dr["CGRPG_CHILD"].ToString(); DataTable dtsubzone = cGroupChildsDb.GetData(null, swhere, null, null); qty = SeekUnitAlarmsQty(dtsubzone, qty, zoneId); } // if theres a unit let's get if he has an active alarm (or more) else { swhere = "ALA_UNI_ID = "+ dr["CGRPG_CHILD"].ToString(); DataTable dtAlarms = new CmpAlarmsDB().GetData(null, swhere, null, null); if (dtAlarms.Rows.Count > 0) { qty++; } } } return(qty); }
public static string SeekUnitsString(DataTable dtzone) { System.Configuration.AppSettingsReader appSettings = new System.Configuration.AppSettingsReader(); string UNIT_ID = (string)appSettings.GetValue("GroupsChilds.UnitId", typeof(string)); string swhere = ""; CmpGroupsChildsGisDB cGroupChildsDb = new CmpGroupsChildsGisDB(); CmpGroupsDB cGroupsDb = new CmpGroupsDB(); string strRes = ""; string strTemp = ""; foreach (DataRow dr in dtzone.Rows) { // If there is not a UNIT we follow deeping in the tree...(Level 2) if (dr["CGRPG_TYPE"].ToString() != UNIT_ID) { swhere = "CGRPG_ID = "+ dr["CGRPG_CHILD"].ToString(); DataTable dtsubzone = cGroupChildsDb.GetData(null, swhere, null, null); strTemp = SeekUnitsString(dtsubzone); if (strTemp != "") { if (strRes == "") { strRes = strTemp; } else { strRes += "," + strTemp; } } } else { if (dr["CGRPG_CHILD"].ToString() != "") { CmpUnitsDB udb = new CmpUnitsDB(); swhere = "UNI_ID = " + dr["CGRPG_CHILD"].ToString() + " AND UNI_DPUNI_ID IN (1,2) "; DataTable dtUnit = udb.GetData(null, swhere, null, null); if (dtUnit.Rows.Count != 0) { if (strRes == "") { strRes = dr["CGRPG_CHILD"].ToString(); } else { strRes += "," + dr["CGRPG_CHILD"].ToString(); } } } } } return(strRes); }
public static void SeekUnitAlarms(DataTable dtzone, DataTable dtReturn, int zoneId) { System.Configuration.AppSettingsReader appSettings = new System.Configuration.AppSettingsReader(); string UNIT_ID = (string)appSettings.GetValue("GroupsChilds.UnitId", typeof(string)); string swhere = ""; CmpGroupsChildsGisDB cGroupChildsDb = new CmpGroupsChildsGisDB(); CmpGroupsDB cGroupsDb = new CmpGroupsDB(); object[] ovalues = new object[4]; foreach (DataRow dr in dtzone.Rows) { // If there is not a UNIT we follow deeping in the tree...(Level 2) if (dr["CGRPG_TYPE"].ToString() != UNIT_ID) { swhere = "CGRPG_ID = "+ dr["CGRPG_CHILD"].ToString(); DataTable dtsubzone = cGroupChildsDb.GetData(null, swhere, null, null); SeekUnitAlarms(dtsubzone, dtReturn, zoneId); } // if theres a unit let's get if he has an active alarm (or more) else { swhere = "ALA_UNI_ID = "+ dr["CGRPG_CHILD"].ToString(); //DataTable dtAlarms = new CmpAlarmsDB().GetData(null,swhere,null,null); DataTable dtAlarmsZone = new CmpAlarmsZoneDB().GetData(null, swhere, null, null); for (int j = 0; j < dtAlarmsZone.Rows.Count; j++) { ovalues[0] = new object(); ovalues[1] = new object(); ovalues[2] = new object(); ovalues[3] = new object(); ovalues[0] = dtAlarmsZone.Rows[j]["ALA_UNI_ID"].ToString(); ovalues[1] = zoneId; ovalues[2] = dtAlarmsZone.Rows[j]["DALA_LIT_ID"].ToString(); ovalues[3] = dtAlarmsZone.Rows[j]["UNI_DESCSHORT"].ToString(); dtReturn.Rows.Add(ovalues); } } } }
/// <summary> /// Gets All Alarms for zones /// </summary> /// <returns>DataTable with info about alarms and Phisical zones</returns> /// public static DataTable GetAlarms() { // Components Used CmpAlarmsDB cAlarmsDb = new CmpAlarmsDB(); CmpGroupsChildsGisDB cGroupChildsDb = new CmpGroupsChildsGisDB(); CmpGroupsDB cGroupsDb = new CmpGroupsDB(); // STEP 1: Get the alarms DataTable dtalarms = cAlarmsDb.GetData(); // STEP 2: Recursive search of the unit to find his zone. DataTable dtReturn = new DataTable(); dtReturn.Columns.Add("UNI_ID"); dtReturn.Columns.Add("ZONE_ID"); object[] ovalues = new object[2]; foreach (DataRow dr in dtalarms.Rows) { // Use a recursive function to reach zone. We pass the unit (or group) and the functions return its sector string id = dr["ALA_UNI_ID"].ToString(); string sZone = ""; sZone = RecursiveSearchParent(id); ovalues[0] = new object(); ovalues[1] = new object(); if (String.Compare(sZone, "-1") != 0) { ovalues[0] = dr["ALA_UNI_ID"]; ovalues[1] = sZone; dtReturn.Rows.Add(ovalues); } } return(dtReturn); }