public static PublishedApplication[] GetPublishedApplications(System.Security.Principal.WindowsIdentity user) { //Todo get published application from web service WebServiceAPI service = new WebServiceAPI(); WindowsIdentity usr = service.GetUser(user); // orig source // PublishedApplication[] apps = service.GetApplicationsByCredentials(usr, usr.UserName, "", new string[] { "defaults" }, new string[] { "all" }, new string[] { "all" }); PublishedApplication[] apps = null; try { apps = service.GetApplicationsByCredentials(usr, usr.UserName, "", new string[] { "defaults" }, new string[] { "all" }, new string[] { "all" }); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("Extentrix", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, ex.Message, ex.StackTrace); Logger.Default.Error("An error occured during getting published applications", ex); } /*XmlDocument xmlDoc = new XmlDocument(); * xmlDoc.Load(SPContext.Current.Web.Url + "/_layouts/Images/ExtentrixWebIntrface/Applications.xml"); * string xml = xmlDoc.InnerXml; * List<PublishedApplication> appsList = Util.GetPublishedApplications(); * PublishedApplication[] apps = appsList.ToArray();*/ return(apps); }
// Devuelve: latitud,longitud,fechahora,HHID private string getLastPositionDateTime() { string res = ""; try { string errDesc = ""; int errCode = -1; string encodedGPS = WebServiceAPI.GetInstance().GetPosition(DEVICEID, ORGID.ToString(), out errDesc, out errCode); Match matchRespuesta = Pos_Data.Match(encodedGPS); // Si no hay match es porque se devolvio NO_LOCATION. Seguir de largo. if (matchRespuesta.Success) { string latitud = getMatchData(matchRespuesta, 1); string longitud = getMatchData(matchRespuesta, 2); string dateTime = getMatchData(matchRespuesta, 3); string HHID = getMatchData(matchRespuesta, 4); res = latitud + "," + longitud + "," + dateTime + "," + HHID; } } catch (Exception ex) { Tools.GetInstance().DoLog("Excepcion en getLastPositionDateTime: " + ex.Message); } return(res); }
private string pollForNew(int v_deviceID, int v_orgID, DateTime v_lastReceived) { string res = ""; try { string errDesc = ""; int errCode = -1; string mensaje = WebServiceAPI.GetInstance().GetNewMessages(v_deviceID.ToString(), v_orgID.ToString(), v_lastReceived.ToString("yyyy-MM-dd HH:mm:ss"), out errDesc, out errCode); Match headerResp = msgReg.Match(mensaje); if (headerResp.Success) { res = getMatchData(headerResp, 1); string fecha = getMatchData(headerResp, 2); g_lastReceived = Convert.ToDateTime(fecha); // Actualiza la variable global con la fecha del mensaje recibido } } catch (Exception ex) { Tools.GetInstance().DoLog("Excepcion en PollForNew(): " + ex.Message); } return(res); }
private void updateLinkedUserView() { string errDesc = ""; int errCode = (int)StatusCode.OK; datosEmpleado = WebServiceAPI.GetInstance().GetLinkedEmployee(DEVICEID, ORGANIZATIONID, out errDesc, out errCode); if ((datosEmpleado.Key == null) || (datosEmpleado.Value == null)) { Tools.GetInstance().DoLog("GetLinkedEmployee devolvio null. errDesc=" + errDesc + " errCode=" + errCode); } else { lblFirstName.Text = datosEmpleado.Key.Nombre; lblLastName.Text = datosEmpleado.Key.Apellido; lblSSNO.Text = datosEmpleado.Key.NumeroDocumento; lblBadge.Text = datosEmpleado.Value.tarjeta; // Le carga los accessLevels de lenel ya que el addEmployee final, que lo va a mandar a AlutelMobility espera accesslevels de Lenel datosEmpleado.Value.accessLevels = WebServiceAPI.GetInstance().GetAccessLevelsLenel(datosEmpleado.Value.tarjeta, ORGANIZATIONID.ToString(), out errDesc, out errCode); linkedBadge = datosEmpleado.Value.tarjeta; Tools.GetInstance().DoLog("En updateLinkedUser(). Name=" + datosEmpleado.Key.Nombre + " Apellido=" + datosEmpleado.Key.Apellido + " tarjeta=" + datosEmpleado.Value.tarjeta + " AccessLevels=" + datosEmpleado.Value.accessLevels); if (datosEmpleado.Key.imageDataBytes != null) { picLinkedEmp.Image = Tools.GetInstance().ByteToImage(datosEmpleado.Key.imageDataBytes, datosEmpleado.Key.imageDataBytes.Length); } } }
private void btnSend_Click_1(object sender, EventArgs e) { string textToSend = txtToSend.Text.Replace("\r\n", "").Replace("\n", ""); if (!String.IsNullOrEmpty(textToSend.Trim())) { System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); try { // string comando = "TYPE:LNL_MSG,DEVICEID:" + DEVICEID + ",ORGANIZATION:" + ORGANIZATIONID + ",MSG:" + textToSend.Trim(); string errDesc = ""; int errCode = -1; WebServiceAPI.GetInstance().SendMSG(DEVICEID.ToString(), ORGANIZATIONID.ToString(), textToSend.Trim(), out errDesc, out errCode); addTextoToView(textToSend, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), true); } catch (Exception ex) { Tools.GetInstance().DoLog("Excepcion en boton Send: " + ex.Message); } } txtToSend.Text = ""; }
/// <summary> /// Carga la Zona y actualiza las variables globales ZonaName y triggerMode, pasadas por parametro. /// espera la info y muestra la zona en el mapa. /// </summary> /// <param name="v_PanelID"></param> public void cargarDatosUnaZona(ref string zName, ref string zonaDef, ref int triggerMode, string v_PanelID, int orgID) { try { int errCode = -1; string errDesc = ""; DoLog("Va a cargar la zona " + zName); zonaDef = WebServiceAPI.GetInstance().GetOnlyZone(v_PanelID, orgID.ToString(), out errDesc, out errCode); DoLog("Zona Cargada. Datos: " + zonaDef); triggerMode = int.Parse(zonaDef.Substring(0, 1)); // El primer dato es el TriggerMode. // Le saco el triggerMode a los datos geometricos de la zona if (zonaDef.Length >= 2) { zonaDef = zonaDef.Substring(2, zonaDef.Length - 2); } else { zonaDef = ""; } } catch (Exception ex) { DoLog("EXCEPCION en cargarDatosUnaZona(): " + ex.Message); } }
protected void OnValidateCredentials(object source, ServerValidateEventArgs args) { try { var service = new WebServiceAPI(); var credentials = new WindowsCredentials() { WinUserName = txtUserName.Text, UserName = txtUserName.Text, Password = txtPassword.Text, WinDomain = txtDomain.Text, Domain = txtDomain.Text }; args.IsValid = service.IsCredentialsValid(credentials); if (args.IsValid) { SecureStoreManager.SetExtentrixWindowsCredentials(LogLocation, SPContext.Current.Web.CurrentUser, credentials); SecureStoreManager.SetCredentialsLiveTime(CredentialLiveTime); Credentials = credentials; } } catch (Exception ex) { Logger.Default.Error(LogLocation, "User - " + Page.Request.LogonUserIdentity.Name + " ; Error = " + ex.Message, ex); AppMultiView.ActiveViewIndex = 5; } }
public PanelType getDeviceType(int v_devid) { PanelType res = PanelType.NODEFINIDO; System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); try { string errDesc = ""; int errCode = -1; res = WebServiceAPI.GetInstance().GetDeviceType(v_devid.ToString(), Tools.GetInstance().MainOrgID.ToString(), out errDesc, out errCode); if (errCode != (int)StatusCode.OK) { Tools.GetInstance().DoLog("Error en GetDeviceType(): " + errDesc); } } catch (Exception ex) { Tools.GetInstance().DoLog("Excepcion en GetDeviceType: " + ex.Message); } return(res); }
public void cargarPropiedadesDevice(string v_DeviceID, string v_OrgID, ref string v_deviceName, ref string v_deviceType, ref string v_mode, ref string v_speedLimit, ref string v_gpsUpdateTime) { try { Regex datosProperties = new Regex(@"NAME:(.*),TYPE:(.*),UPDATETIME:(.*),SPEEDLIMIT:(.*),MODE:(.*),DEVICES:(.*)"); int errCode = -1; string errDesc = ""; string datosProp = WebServiceAPI.GetInstance().GetProperties(v_DeviceID, v_OrgID, out errDesc, out errCode); //Tools.GetInstance().DoLog("datosProp: " + datosProp); Match matchHeader = datosProperties.Match(datosProp); if (matchHeader.Success) { v_deviceName = getMatchData(matchHeader, 1); v_deviceType = getMatchData(matchHeader, 2); v_gpsUpdateTime = getMatchData(matchHeader, 3); v_speedLimit = getMatchData(matchHeader, 4); v_mode = getMatchData(matchHeader, 5); //v_listaDevices = getMatchData(matchHeader, 6); // No se usa mas.- //v_IMEI = getMatchData(matchHeader, 7); // No se usa mas.- } } catch (Exception ex) { Tools.GetInstance().DoLog("EXCEPCION en cargarPropiedadesDevice(): " + ex.Message); } }
/// <summary> /// Devuelve una lista de HH,HH,HH;movilID,GPSName,movilID,GPSName /// o sea: los IDs de los HH(que son iguales a sus nombres) y los movilID,GPSName de los GPSs /// </summary> /// <param name="v_OrgID"></param> /// <returns></returns> public string cargarHHGPS(string v_OrgID) { string res = ""; try { int errCode = -1; string errDesc = ""; string datosGPS = WebServiceAPI.GetInstance().GetHHGPS(v_OrgID, out errDesc, out errCode); Regex datosDevices = new Regex(@"HH:(.*);GPS:(.*)"); Match matchHeader = datosDevices.Match(datosGPS); if (matchHeader.Success) { string HH = getMatchData(matchHeader, 1); string GPS = getMatchData(matchHeader, 2); res = HH + ";" + GPS; } } catch (Exception ex) { DoLog("EXCEPCION en cargarHHGPS(): " + ex.Message); res = ""; } return(res); }
private void btnGeoCodeSearch_click(object sender, EventArgs e) { string latitud = ""; string longitud = ""; string errDesc = ""; int errCode = 1; string posDesc = txtPosition.Text; if (!String.IsNullOrEmpty(posDesc.Trim())) { WebServiceAPI.GetInstance().obtenerPosicion(posDesc, out latitud, out longitud, out errDesc, out errCode); if (!String.IsNullOrEmpty(latitud) && !String.IsNullOrEmpty(longitud)) { string jsArray = latitud + "," + longitud + ",15"; // Posicion y Zoom por defecto object[] args2 = { jsArray }; webBrowser.Document.InvokeScript("setPos", args2); } else { MessageBox.Show("Could not get the coordinates of " + posDesc); } } else { MessageBox.Show("You have to describe a place using the following syntax: City, Country"); } }
private void btnForceLogout_Click(object sender, EventArgs e) { try { string res = ""; DialogResult ans = MessageBox.Show("This will log out the device: " + deviceName + ". Are you sure?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (ans == DialogResult.Yes) { string errDesc = ""; int errCode = (int)StatusCode.NOT_IMPLEMENTED; var respuesta = WebServiceAPI.GetInstance().UpdateLogInStatus(DEVICEID.ToString(), false, "7", out errDesc, out errCode); if (respuesta == 200) { MessageBox.Show("Successfully logged out."); } else { MessageBox.Show("Can´t log out the current device."); } } } catch (Exception ex) { Tools.GetInstance().DoLog("Excepcion en btnForceLogout_Click: " + ex.Message); } }
// Borrar todos los cardformats de la organizacion public void enviarBorrarCF(int panel_id) { string organizationID = Helpers.GetInstance().MainOrgID.ToString(); System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); try { //Helpers.GetInstance().mutexTCP_ACCESS.WaitOne(); try { string errDesc = ""; int errCode = -1; WebServiceAPI.GetInstance().DeleteCardFormats(organizationID, panel_id.ToString(), out errDesc, out errCode); } catch (Exception ex) { Helpers.GetInstance().DoLog("EXCEPCION en enviarBorrarCF: " + ex.Message); } } catch (Exception ex) { Helpers.GetInstance().DoLog("EXCEPCION en enviarBorrarCFMUTEX: " + ex.Message); } //finally //{ // Helpers.GetInstance().mutexTCP_ACCESS.ReleaseMutex(); //} }
void actualizarConnStatus() { Helpers.GetInstance().DoLog("Comienza Task de actualizacion de ConnStatus..."); while (!finalizarPoolStatus.WaitOne(5000)) { try { Dictionary <int, bool> listaStatus = WebServiceAPI.GetInstance().GetConnStatusMobileGeneral(); if (listaStatus != null) { lock (statusDevices) { foreach (KeyValuePair <int, bool> par in listaStatus) { setConnStatus(par.Key, par.Value); } } } } catch (Exception ex) { Helpers.GetInstance().DoLog("EXCEPCION en actualizarConnStatus:" + ex.Message); } } Helpers.GetInstance().DoLog("Finaliza Thread de actualizacion de ConnStatus."); }
/// <summary> /// Mensaje para notificar la dada de baja de un Reader correspondiente a un Panel /// </summary> /// <param name="PanelID"></param> /// <param name="v_ReaderID"></param> public void deleteReader(int PanelID, int v_ReaderID) { //staticDatamanager.updateConfigurationVariables(); System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); string readerID = v_ReaderID.ToString(); string orgID = Helpers.GetInstance().MainOrgID.ToString(); // El configurado en el registro try { //Helpers.GetInstance().mutexTCP_ACCESS.WaitOne(); try { string errDesc = ""; int errCode = -1; WebServiceAPI.GetInstance().DeleteReader(PanelID.ToString(), readerID, orgID, out errDesc, out errCode); } catch (Exception ex) { Helpers.GetInstance().DoLog("EXCEPCION en deleteReader: " + ex.Message); } } catch (Exception ex) { Helpers.GetInstance().DoLog("EXCEPCION en deleteReader-MUTEX: " + ex.Message); } //finally //{ // Helpers.GetInstance().mutexTCP_ACCESS.ReleaseMutex(); //} }
private void cargarDatosZonas() { try { foreach (KeyValuePair <long, string> zona in listaZonas) { int cantEmp = WebServiceAPI.GetInstance().ObtenerCantidadEmpleadosEnZona(zona.Value); Tools.GetInstance().DoLog("Cantidad empleados en la " + zona.Value + " " + cantEmp.ToString()); if (cantEmp >= 0) { Tools.GetInstance().DoLog("1"); if (!CantEmpZonas.ContainsKey(zona.Value)) { CantEmpZonas.Add(zona.Value, cantEmp); } else { CantEmpZonas[zona.Value] = cantEmp; } blinkLoading(); } Tools.GetInstance().DoLog("loop"); } actualizarListView(); Tools.GetInstance().DoLog("Fin"); updateLoadingVisible(false); } catch (Exception ex) { Tools.GetInstance().DoLog("Excepcion en cargarDatosZonas():" + ex.Message); } }
internal void startActualizarListaDeviceUsers() { try { Tools.GetInstance().DoLog("Entro a StartActualizarListaDeviceUsers"); listaDeviceUsers = WebServiceAPI.GetInstance().CargarListaDeviceUsers(); if (listaDeviceUsers != null) { EmpInfoComparer comparer = new EmpInfoComparer(); listaDeviceUsers.Sort(comparer); actualizarListaDeviceUsers(listaDeviceUsers); } else { MessageBox.Show("Server not available. Retry in a few seconds."); Invoke((MethodInvoker) delegate { this.Close(); }); } } catch (Exception ex) { Tools.GetInstance().DoLog("Excepcion en StartActualizarListaDeviceUsers. Ex: " + ex.ToString()); } }
// Se llama en el destructor del Panel de la zona. public void deleteZone(int PanelID) { PoolGetConnStatus.GetInstance().subRefCount(); //PoolGetAlarm.GetInstance().subRefCount(); PoolGetAcceso.GetInstance().subRefCount(); System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); string orgID = Helpers.GetInstance().MainOrgID.ToString(); // El configurado en el registro try { //Helpers.GetInstance().mutexTCP.WaitOne(); try { string errDesc = ""; int errCode = (int)StatusCode.NOT_IMPLEMENTED; if (!WebServiceAPI.GetInstance().ExistePanelEnOnGuard(PanelID.ToString(), out errDesc, out errCode)) { WebServiceAPI.GetInstance().DeleteZone(PanelID.ToString(), orgID, out errDesc, out errCode); } } catch (Exception) { } } catch (Exception) { } }
/// <summary> /// Devuelve la lista de AccessLevelID asociado a un PanelID /// </summary> /// <param name="v_panelID"></param> /// <returns></returns> public List <int> obtenerAccessLevelPanel(int v_panelID) { int errCode = -1; string errDesc = ""; List <int> res = WebServiceAPI.GetInstance().ObtenerAccessLevelsDeUnPanel(v_panelID, out errDesc, out errCode); return(res); }
private void btnDelete_Click(object sender, EventArgs e) { string errDesc = ""; int errCode = -1; if (listViewDeviceUsers.SelectedIndices.Count == 0) { MessageBox.Show("Please select one user", "Warning"); return; } int cantSelected = listViewDeviceUsers.SelectedIndices.Count; bool okDelete = false; if (cantSelected == 1) { DialogResult res = MessageBox.Show("Delete Device User " + listViewDeviceUsers.SelectedItems[0].Text + "?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (res == DialogResult.Yes) { okDelete = true; } } else { DialogResult res = MessageBox.Show("Do you really want to delete " + cantSelected + " items?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (res == DialogResult.Yes) { okDelete = true; } } if (okDelete) { //somethingChanged = true; List <ListViewItem> listaItems = new List <ListViewItem>(); for (int i = 0; i < listViewDeviceUsers.SelectedIndices.Count; i++) { ListViewItem item = listViewDeviceUsers.Items[listViewDeviceUsers.SelectedIndices[i]]; listaItems.Add(item); } foreach (ListViewItem i in listaItems) { listViewDeviceUsers.Items.Remove(i); var respuesta = WebServiceAPI.GetInstance().DeleteDeviceUser(i.Text, out errDesc, out errCode); } listaDeviceUsers = WebServiceAPI.GetInstance().CargarListaDeviceUsers(); actualizarListaDeviceUsers(listaDeviceUsers); clearSelected(); } }
public List <string> obtenerBadgesAlutelMobility(string orgID) { int errCode = -1; string errDesc = ""; List <string> res = WebServiceAPI.GetInstance().ObtenerBadgesAlutelmobility(orgID, out errDesc, out errCode); return(res); }
public bool updateIMEI() { try { return(WebServiceAPI.GetInstance().UpdateListaIMEI(listaIMEI, Tools.GetInstance().MainOrgID)); } catch (Exception) { return(false); } }
void actualizarConnStatus() { Helpers.GetInstance().DoLog("Comienza Thread de actualizacion de ConnStatus..."); while (!finalizarPoolStatus.WaitOne(5000)) { ConnStatusReturned = WebServiceAPI.GetInstance().GetConnStatusZoneGeneral(); // Si hay conectividad es TRUE para todas las zonas si no es FALSE para todas. } Helpers.GetInstance().DoLog("Finaliza Thread de actualizacion de ConnStatus."); }
private void updateDevices() { cmbDevice.Items.Clear(); string[] listaDevTypes = listaDevices.Split(';'); // Dos grupos : HH y GPS. Los carga antes de invocar a esta ventana string listaHH = listaDevTypes[0]; string listaGPS = listaDevTypes[1]; lstHH = new List <string>(listaHH.Split(',')); lstHH.Sort(); // Lista de nombres de devices ordenada. string[] arrGPS = listaGPS.Split(','); lstGPS = new List <string>(); if (arrGPS.Length >= 2) { for (int i = 0; i < arrGPS.Length; i = i + 2) { lstGPS.Add(arrGPS[i + 1] + "," + arrGPS[i]); // En cada elemento queda: NombreGPS,idMovil. En ese orden } } lstGPS.Sort(); // Lista de Nombre,idMovil ordenada por nombre. foreach (string s in lstHH) { if (!String.IsNullOrEmpty(s)) { cmbDevice.Items.Add(s); } } foreach (string s in lstGPS) { if (!String.IsNullOrEmpty(s)) { cmbDevice.Items.Add(s.Split(',')[0]); } } string errDesc = ""; int errCode = 0; if (!String.IsNullOrEmpty(DEVICEID)) { string deviceSeleccionado = WebServiceAPI.GetInstance().ObtenerNombrePanelID(int.Parse(DEVICEID), out errDesc, out errCode); if (!String.IsNullOrEmpty(deviceSeleccionado)) { cmbDevice.Text = deviceSeleccionado; } } }
/// <summary> /// Envia LNL_ERASEEMPLOYEE al server para que se envie directamente al HH /// </summary> private void enviarEraseEmployee(string v_badge, int v_panelID, string v_newAccesslevels, string v_fechaActivacion, string v_fechaDesactivacion) { try { int errCode = (int)StatusCode.NOT_IMPLEMENTED; string errDesc = ""; WebServiceAPI.GetInstance().EraseEmployee(v_badge, v_panelID.ToString(), Helpers.GetInstance().MainOrgID.ToString(), v_newAccesslevels, v_fechaActivacion, v_fechaDesactivacion, out errDesc, out errCode); } catch (Exception) { } }
// Envio de definicion de un cardFormat al Server. public void addCardFormat(int FormatID, int m_PanelID, int BitSize, int FC, int Offset, int BitsFC, int PositionStartFC, int BitsCardNum, int PositionStartCN, int BitsIssueCode, int PositionStartIC, int m_IsDownloadInProgress) { System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); string orgID = Helpers.GetInstance().MainOrgID.ToString(); //string nomCF = obtenerNombreCardFormat(FormatID); if (BitsFC == 0) { BitsFC++; } if (BitsCardNum == 0) { BitsCardNum++; } if (BitsIssueCode == 0) { BitsIssueCode++; } //Helpers.GetInstance().mutexTCP_ACCESS.WaitOne(); try { int errCode = -1; string errDesc = ""; string nombreCardformat = WebServiceAPI.GetInstance().ObtenerNombreCardformat(FormatID.ToString(), out errDesc, out errCode); if (String.IsNullOrEmpty(nombreCardformat)) { Helpers.GetInstance().DoLog("ERROR en addCardFormat: No pudo obtener el Nombre del Cardformat " + FormatID.ToString()); } errCode = -1; errDesc = ""; WebServiceAPI.GetInstance().AddCardFormat(m_PanelID.ToString(), orgID, FormatID.ToString(), nombreCardformat, FC.ToString(), Offset.ToString(), BitSize.ToString(), PositionStartFC.ToString(), (PositionStartFC + BitsFC - 1).ToString(), PositionStartCN.ToString(), (PositionStartCN + BitsCardNum - 1).ToString(), PositionStartIC.ToString(), (PositionStartIC + BitsIssueCode - 1).ToString(), out errDesc, out errCode); } catch (Exception ex) { Helpers.GetInstance().DoLog("EXCEPCION en addCardFormat: " + ex.Message); } //finally //{ // Helpers.GetInstance().mutexTCP_ACCESS.ReleaseMutex(); //} }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { _service = new WebServiceAPI(); var queryString = Request.QueryString; try { string action = queryString[ActionKey]; switch (action) { case "New": string appName = queryString[DocumentAppKey]; var app = FileTypesUtility.GetApplicationByName(appName); LaunchApplication(Page.Request.LogonUserIdentity, GetCurrentHost(), app); break; case "Edit": string fileType = queryString[FileTypeKey]; app = FileTypesUtility.GetApplicationByFileType(fileType); string fileUrl = queryString[FileUrlKey]; LaunchApplicationWithParameter(Page.Request.LogonUserIdentity, GetCurrentHost(), app, fileUrl); break; case "EditThrough": appName = queryString[DocumentAppKey]; string farmName = queryString[DocumentFarmKey]; app = new RedirectionApplication() { InternalName = appName, FarmName = farmName }; fileUrl = queryString[FileUrlKey]; LaunchApplicationWithParameter(Page.Request.LogonUserIdentity, GetCurrentHost(), app, fileUrl); break; } } catch (ThreadAbortException) { //Do nothing } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("Extentrix", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, ex.Message, ex.StackTrace); PageLogger.Error("An error occured during contetent redirection", ex); } } }
/// <summary> /// Mensaje para notificar la dada de baja de Panel. /// Solo se envia deletePanel si realmente se dio de baja y no existe en Lenel- /// Ademas usa DC para eliminar el usuario asociado al panel. /// </summary> public void deletePanel(int PanelID, string panelName) { PoolGetConnStatus.GetInstance().subRefCount(); // Para detener el thread y liberar memoria en caso de ser el ultimo panel que se da de baja. PoolGetAlarm.GetInstance().subRefCount(); PoolGetAcceso.GetInstance().subRefCount(); PoolSetAlarma.GetInstance().subRefCount(); PoolSetAcceso.GetInstance().subRefCount(); System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); string orgID = Helpers.GetInstance().MainOrgID.ToString(); // El configurado en el registro try { //Helpers.GetInstance().mutexTCP_ACCESS.WaitOne(); try { string errDesc = ""; int errCode = -1; if (!WebServiceAPI.GetInstance().ExistePanelEnOnGuard(PanelID.ToString(), out errDesc, out errCode)) { WebServiceAPI.GetInstance().DeleteDevice(PanelID.ToString(), orgID, out errDesc, out errCode); if (errCode == (int)StatusCode.OK) { Employee emp = WebServiceAPI.GetInstance().ObtenerEmpleadoAsociadoAHH(panelName, out errDesc, out errCode); if (emp != null) { Helpers.GetInstance().DoLog("Va a borrar el empleado " + emp.Nombre + " " + emp.Apellido + " con personid: " + emp.PersonID.ToString() + " asociado al panelID: " + PanelID.ToString() + " llamado:" + panelName); WebServiceAPI.GetInstance().EliminarEmpleado(emp.PersonID, out errDesc, out errCode); } else { Helpers.GetInstance().DoLog("emp es NULL en deletePanel. NO borró el empleado asociado al panel " + PanelID.ToString()); } } } } catch (Exception ex) { Helpers.GetInstance().DoLog("EXCEPCION en deletePanel: " + ex.Message); } } catch (Exception ex) { Helpers.GetInstance().DoLog("EXCEPCION en deletePanelMUTEX: " + ex.Message); } //finally //{ // Helpers.GetInstance().mutexTCP_ACCESS.ReleaseMutex(); //} }
private string enviarAddEmployee(string v_badge, int v_panelID, string v_newAccesslevels, string v_fechaActivacion, string v_fechaDesactivacion, string v_PIN, int m_IsDownloadInProgress) { string res = "FAIL"; int errCode = (int)StatusCode.NOT_IMPLEMENTED; try { string errDesc = ""; KeyValuePair <Employee, Tarjeta> t = WebServiceAPI.GetInstance().ObtenerDatosEmpleadoYTarjeta(v_badge, out errDesc, out errCode); if (errCode != (int)StatusCode.OK) { Helpers.GetInstance().DoLog("ObtenerDatosEmpleadoYTarjeta devolvio el error: " + errDesc); } if ((t.Key != null) && (t.Value != null)) { t.Value.accessLevels = v_newAccesslevels; t.Value.PIN = v_PIN; //Helpers.GetInstance().DoLog("Va a llamar a AddEmployee con tarjeta=" + t.Value.tarjeta + " badgekey=" + t.Value.lnlbadgekey); WebServiceAPI.GetInstance().AddEmployee(t.Key, t.Value, v_panelID, out errDesc, out errCode); if (errCode != (int)StatusCode.OK) { Helpers.GetInstance().DoLog("ERROR en enviarAddEmployee: " + errDesc); } else { res = "OK"; } if (t.Key.isVisitor) { sendScheduledVisit(t.Key.PersonID.ToString(), t.Key.Nombre, t.Key.Apellido, t.Key.NumeroDocumento, v_badge, Helpers.GetInstance().MainOrgID.ToString()); } } else { Helpers.GetInstance().DoLog("No envia addEmployee por ser Empleado o tarjeta NULL" + errDesc); } } catch (Exception ex) { Helpers.GetInstance().DoLog("Excepcion en enviarAddEmployee: " + ex.Message); res = "FAIL"; } return(res); }
private void sendZoneToServer() { string listaPuntos = ""; foreach (KeyValuePair <string, Zone.GeoCoord> pair in markerPoints) { listaPuntos = listaPuntos + pair.Value.latitude + "," + pair.Value.longitude + ","; } string modeStr = chkTrigger.Checked ? "1" : "0"; int errCode = -1; string errDesc = ""; WebServiceAPI.GetInstance().DefineZone(DEVICEID, modeStr, listaPuntos, ORGANIZATIONID.ToString(), out errDesc, out errCode); }
public static int Main (string[] args) { Log.Register (new ConsoleOutEventLog (80)); Log.Information ("Initializing application..."); HttpSocketClient.RegisterHttpProxyUse (false, false); // Don't look for proxies. DB.BackupConnectionString = "Data Source=actuator.db;Version=3;"; DB.BackupProviderName = "Clayster.Library.Data.Providers.SQLiteServer.SQLiteServerProvider"; db = DB.GetDatabaseProxy ("TheActuator"); Console.CancelKeyPress += (object sender, ConsoleCancelEventArgs e) => { e.Cancel = true; executionLed.Low (); }; // HTTP Interface HttpServer HttpServer = new HttpServer (80, 10, true, true, 1); int i; Log.Information ("HTTP Server receiving requests on port " + HttpServer.Port.ToString ()); HttpServer.RegisterAuthenticationMethod (new DigestAuthentication ("The Actuator Realm", GetDigestUserPasswordHash)); HttpServer.RegisterAuthenticationMethod (new SessionAuthentication ()); credentials = LoginCredentials.LoadCredentials (); if (credentials == null) { credentials = new LoginCredentials (); credentials.UserName = "******"; credentials.PasswordHash = CalcHash ("Admin", "Password"); credentials.SaveNew (); } state = State.LoadState (); if (state == null) { state = new State (); state.SaveNew (); } else { for (i = 0; i < 8; i++) digitalOutputs [i].Value = state.GetDO (i + 1); if (state.Alarm) AlarmOn (); else AlarmOff (); } WebServiceAPI wsApi; HttpServer.Register ("/", HttpGetRoot, HttpPostRoot, false); // Synchronous, no authentication HttpServer.Register ("/credentials", HttpGetCredentials, HttpPostCredentials, false); // Synchronous, no authentication HttpServer.Register ("/set", HttpGetSet, HttpPostSet, true); // Synchronous, http authentication HttpServer.Register ("/xml", HttpGetXml, true); // Synchronous, http authentication HttpServer.Register ("/json", HttpGetJson, true); // Synchronous, http authentication HttpServer.Register ("/turtle", HttpGetTurtle, true); // Synchronous, http authentication HttpServer.Register ("/rdf", HttpGetRdf, true); // Synchronous, http authentication HttpServer.Register (wsApi = new WebServiceAPI (), true); // HTTPS interface // Certificate must be a valid P12 (PFX) certificate file containing a private key. // X509Certificate2 Certificate = new X509Certificate2 ("Certificate.pfx", "PASSWORD"); // HttpServer HttpsServer = new HttpServer (443, 10, true, true, 1, true, false, Certificate); // // HttpsServer.RegisterAuthenticationMethod (new DigestAuthentication ("The Actuator Realm", GetDigestUserPasswordHash)); // // foreach (IHttpServerResource Resource in HttpServer.GetResources()) // HttpsServer.Register (Resource); // // Log.Information ("HTTPS Server receiving requests on port " + HttpsServer.Port.ToString ()); // CoAP Interface CoapEndpoint CoapEndpoint = new CoapEndpoint (); Log.Information ("CoAP endpoint receiving requests on port " + CoapEndpoint.Port.ToString ()); //CoapEndpoint.RegisterLineListener (new ConsoleOutLineListenerSink (BinaryFormat.Hexadecimal, true)); for (i = 1; i <= 8; i++) { CoapEndpoint.RegisterResource ("do" + i.ToString () + "/txt", "Digital Output " + i.ToString () + ", as text.", CoapBlockSize.BlockLimit_64Bytes, false, 30, false, CoapGetDigitalOutputTxt, CoapSetDigitalOutputTxt); } CoapEndpoint.RegisterResource ("do/txt", "Digital Outputs, as a number 0-255 as text.", CoapBlockSize.BlockLimit_64Bytes, false, 30, false, CoapGetDigitalOutputsTxt, CoapSetDigitalOutputsTxt); CoapEndpoint.RegisterResource ("alarm/txt", "Alarm Output " + i.ToString () + ", as text.", CoapBlockSize.BlockLimit_64Bytes, false, 30, false, CoapGetAlarmOutputTxt, CoapSetAlarmOutputTxt); foreach (CoapBlockSize BlockSize in Enum.GetValues(typeof(CoapBlockSize))) { if (BlockSize == CoapBlockSize.BlockLimit_Datagram) continue; string Bytes = (1 << (4 + (int)BlockSize)).ToString (); CoapEndpoint.RegisterResource ("xml/" + Bytes, "Complete sensor readout, in XML. Control content using query parmeters. Block size=" + Bytes + " bytes.", BlockSize, false, 30, false, CoapGetXml); CoapEndpoint.RegisterResource ("json/" + Bytes, "Complete sensor readout, in JSON. Control content using query parmeters. Block size=" + Bytes + " bytes.", BlockSize, false, 30, false, CoapGetJson); CoapEndpoint.RegisterResource ("turtle/" + Bytes, "Complete sensor readout, in TURTLE. Control content using query parmeters. Block size=" + Bytes + " bytes.", BlockSize, false, 30, false, CoapGetTurtle); CoapEndpoint.RegisterResource ("rdf/" + Bytes, "Complete sensor readout, in RDF. Control content using query parmeters. Block size=" + Bytes + " bytes.", BlockSize, false, 30, false, CoapGetRdf); } // MQTT MqttClient MqttClient = new MqttClient ("iot.eclipse.org", MqttClient.DefaultPort, "LearningIoTActuator", string.Empty, false); //MqttClient.RegisterLineListener (new ConsoleOutLineListenerSink (BinaryFormat.Hexadecimal)); MqttClient.Open (); MqttClient.CONNECT (20, true); MqttClient.PUBLISH ("Clayster/LearningIoT/Actuator/ao", state.Alarm ? "1" : "0", MqttQoS.QoS1_Acknowledged, true); MqttClient.PUBLISH ("Clayster/LearningIoT/Actuator/do", wsApi.GetDigitalOutputs ().ToString (), MqttQoS.QoS1_Acknowledged, true); for (i = 1; i <= 8; i++) MqttClient.PUBLISH ("Clayster/LearningIoT/Actuator/do" + i.ToString (), wsApi.GetDigitalOutput (i) ? "1" : "0", MqttQoS.QoS1_Acknowledged, true); MqttClient.SUBSCRIBE (new KeyValuePair<string, MqttQoS> ("Clayster/LearningIoT/Actuator/#", MqttQoS.QoS1_Acknowledged)); MqttClient.OnDataPublished += OnMqttDataPublished; Log.Information ("Receiving commands via MQTT from Clayster/LearningIoT/Actuator @ ", EventLevel.Minor, MqttClient.Host + ":" + MqttClient.PortNumber.ToString ()); // Main loop Log.Information ("Initialization complete. Application started..."); try { while (executionLed.Value) { System.Threading.Thread.Sleep (1000); RemoveOldSessions (); } } catch (Exception ex) { Log.Exception (ex); executionLed.Low (); } finally { Log.Information ("Terminating application."); Log.Flush (); Log.Terminate (); HttpServer.Dispose (); //HttpsServer.Dispose (); if (MqttClient != null) MqttClient.Dispose (); executionLed.Dispose (); foreach (DigitalOutput Output in digitalOutputs) Output.Dispose (); if (alarmThread != null) { alarmThread.Abort (); alarmThread = null; } } return 0; }