public string GetUserFilesLocalFolderLocation() { string path = ""; try { m_mutexHostControllerEndpoints.WaitOne(); foreach (EndpointAddress ep in m_hostControllerEndpoints) { BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); JBCHostControllerServiceClient serviceClient = new JBCHostControllerServiceClient(binding, ep); serviceClient.Open(); path = serviceClient.GetUserFilesLocalFolderLocation(); serviceClient.Close(); } } catch (Exception ex) { LoggerModule.logger.Error(System.Reflection.MethodInfo.GetCurrentMethod().Name + ". Error: " + ex.Message); } finally { m_mutexHostControllerEndpoints.ReleaseMutex(); } return(path); }
public bool SetAvailableRemoteServerDownload(bool available) { bool bOk = false; try { m_mutexHostControllerEndpoints.WaitOne(); foreach (EndpointAddress ep in m_hostControllerEndpoints) { BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); JBCHostControllerServiceClient serviceClient = new JBCHostControllerServiceClient(binding, ep); serviceClient.Open(); bOk = serviceClient.SetAvailableRemoteServerDownload(available); serviceClient.Close(); } } catch (Exception ex) { LoggerModule.logger.Error(System.Reflection.MethodInfo.GetCurrentMethod().Name + ". Error: " + ex.Message); } finally { m_mutexHostControllerEndpoints.ReleaseMutex(); } return(bOk); }
public List <dc_FirmwareStation> GetInfoUpdateFirmware(dc_FirmwareStation infoUpdateFirmware) { List <dc_FirmwareStation> listInfoUpdateFirmware = new List <dc_FirmwareStation>(); try { m_mutexHostControllerEndpoints.WaitOne(); foreach (EndpointAddress ep in m_hostControllerEndpoints) { BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); JBCHostControllerServiceClient serviceClient = new JBCHostControllerServiceClient(binding, ep); serviceClient.Open(); listInfoUpdateFirmware.AddRange(serviceClient.GetInfoUpdateFirmware(infoUpdateFirmware)); serviceClient.Close(); } } catch (Exception ex) { LoggerModule.logger.Error(System.Reflection.MethodInfo.GetCurrentMethod().Name + ". Error: " + ex.Message); } finally { m_mutexHostControllerEndpoints.ReleaseMutex(); } return(listInfoUpdateFirmware); }
//@Brief Comprueba si existe una actualización para el RemoteManager //@Paran[in] swVersion Versión del RemoteManager //@Return Boolean True si existe una actualización public bool CheckUpdateConnectedRemoteManager(string swVersion) { bool bOk = false; try { m_mutexHostControllerEndpoints.WaitOne(); foreach (EndpointAddress ep in m_hostControllerEndpoints) { BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); JBCHostControllerServiceClient serviceClient = new JBCHostControllerServiceClient(binding, ep); serviceClient.Open(); bOk = serviceClient.CheckUpdateConnectedRemoteManager(swVersion); serviceClient.Close(); } } catch (Exception ex) { LoggerModule.logger.Error(System.Reflection.MethodInfo.GetCurrentMethod().Name + ". Error: " + ex.Message); } finally { m_mutexHostControllerEndpoints.ReleaseMutex(); } return(bOk); }
//@Brief Obtiene una porción de la actualización //@Param[in] nSequence Número de la secuencia //@Return dc_UpdateWProgram Estructura con los datos de la actualización public dc_UpdateRemoteManager GetFileUpdateRemoteManager(int nSequence) { dc_UpdateRemoteManager updateRemoteManager = new dc_UpdateRemoteManager(); updateRemoteManager.sequence = -1; updateRemoteManager.final = false; try { m_mutexHostControllerEndpoints.WaitOne(); foreach (EndpointAddress ep in m_hostControllerEndpoints) { BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); JBCHostControllerServiceClient serviceClient = new JBCHostControllerServiceClient(binding, ep); serviceClient.Open(); updateRemoteManager = serviceClient.GetFileUpdateRemoteManager(nSequence); serviceClient.Close(); } } catch (Exception ex) { LoggerModule.logger.Error(System.Reflection.MethodInfo.GetCurrentMethod().Name + ". Error: " + ex.Message); } finally { m_mutexHostControllerEndpoints.ReleaseMutex(); } return(updateRemoteManager); }
//@Brief Obtiene la información de la actualización específica //@Return dc_InfoUpdateSpecificTime Información de la actualización específica public dc_InfoUpdateSpecificTime GetUpdateSpecificTimeInfo() { dc_InfoUpdateSpecificTime infoUpdateSpecificTime = new dc_InfoUpdateSpecificTime(); infoUpdateSpecificTime.available = false; try { m_mutexHostControllerEndpoints.WaitOne(); foreach (EndpointAddress ep in m_hostControllerEndpoints) { BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); JBCHostControllerServiceClient serviceClient = new JBCHostControllerServiceClient(binding, ep); serviceClient.Open(); infoUpdateSpecificTime = serviceClient.GetUpdateSpecificTime(); serviceClient.Close(); } } catch (Exception ex) { LoggerModule.logger.Error(System.Reflection.MethodInfo.GetCurrentMethod().Name + ". Error: " + ex.Message); } finally { m_mutexHostControllerEndpoints.ReleaseMutex(); } return(infoUpdateSpecificTime); }
private void SendEventLogToController() { do { List <dc_EventLog> eventLog = m_eventLog.GetLogEvents(); try { m_mutexHostControllerEndpoints.WaitOne(); foreach (EndpointAddress ep in m_hostControllerEndpoints) { //Open connection BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); JBCHostControllerServiceClient serviceClient = new JBCHostControllerServiceClient(binding, ep); serviceClient.Open(); serviceClient.RegisterEventLog(eventLog.ToArray()); serviceClient.Close(); } //Updates the date of the last data collection My.Settings.Default.EventLogLastDataCollection = DateTime.Now; } catch (Exception ex) { LoggerModule.logger.Error(System.Reflection.MethodInfo.GetCurrentMethod().Name + ". Error: " + ex.Message); } finally { m_mutexHostControllerEndpoints.ReleaseMutex(); } Thread.Sleep(TIME_SEND_EVENT_LOG_HOST_CONTROLLER); } while (true); }
/// <summary> /// Send software version to HostController /// </summary> private void SendVersionFileToController() { // inicialmente esperamos 10 segundos para que el searcher tenga tiempo suficiente de realizar su búsqueda Thread.Sleep(10000); do { try { m_mutexHostControllerEndpoints.WaitOne(); foreach (EndpointAddress ep in m_hostControllerEndpoints) { //Open connection BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); JBCHostControllerServiceClient serviceClient = new JBCHostControllerServiceClient(binding, ep); serviceClient.Open(); serviceClient.CheckUpdateConnectedStationController(m_swVersion); serviceClient.Close(); } } catch (Exception ex) { LoggerModule.logger.Error(System.Reflection.MethodInfo.GetCurrentMethod().Name + ". Error: " + ex.Message); } finally { m_mutexHostControllerEndpoints.ReleaseMutex(); } Thread.Sleep(TIME_SEND_VERSION_HOST_CONTROLLER); } while (true); }
//@Brief Establece la comprobación periódica //@Param[in] infoCheckPeriodicTime Información de la comprobación periódica public void SetCheckPeriodicTime(dc_InfoCheckPeriodicTime infoCheckPeriodicTime) { try { m_mutexHostControllerEndpoints.WaitOne(); foreach (EndpointAddress ep in m_hostControllerEndpoints) { BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); JBCHostControllerServiceClient serviceclient = new JBCHostControllerServiceClient(binding, ep); serviceclient.Open(); bool bok = serviceclient.SetCheckPeriodicTime(infoCheckPeriodicTime); serviceclient.Close(); } } catch (Exception ex) { LoggerModule.logger.Error(System.Reflection.MethodInfo.GetCurrentMethod().Name + ". Error: " + ex.Message); } finally { m_mutexHostControllerEndpoints.ReleaseMutex(); } }
public void GetUpdateFirmware(ref System.Collections.Generic.List <CFirmwareStation> versionMicros) { List <CFirmwareStation> versionMicrosHostController = new List <CFirmwareStation>(); try { //Carpeta donde guardar la descarga string firmwareFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles), "JBC\\JBC Station Controller Service\\Firmwares"); //Crear carpeta temporal if (!(new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.DirectoryExists(firmwareFolder)) { Directory.CreateDirectory(firmwareFolder); } //Endpoint HostController EndpointAddress ep = null; m_mutexHostControllerEndpoints.WaitOne(); if (m_hostControllerEndpoints.Count > 0) { ep = m_hostControllerEndpoints.First(); } m_mutexHostControllerEndpoints.ReleaseMutex(); if (ep != null) { //Open connection BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); JBCHostControllerServiceClient serviceClient = new JBCHostControllerServiceClient(binding, ep); serviceClient.Open(); //Recorrer todos los micros for (int i = 0; i <= versionMicros.Count - 1; i++) { //Obtener información del firmware HostControllerServiceReference.dc_FirmwareStation infoUpdateFirmware = new HostControllerServiceReference.dc_FirmwareStation(); infoUpdateFirmware.model = System.Convert.ToString(versionMicros.ElementAt(i).Model); infoUpdateFirmware.hardwareVersion = System.Convert.ToString(versionMicros.ElementAt(i).HardwareVersion); List <HostControllerServiceReference.dc_FirmwareStation> listNewInfoUpdateFirmware = new List <HostControllerServiceReference.dc_FirmwareStation>(); listNewInfoUpdateFirmware.AddRange(serviceClient.GetInfoUpdateFirmware(infoUpdateFirmware)); foreach (HostControllerServiceReference.dc_FirmwareStation dc_firmware in listNewInfoUpdateFirmware) { CFirmwareStation firmware = new CFirmwareStation(); firmware.Model = dc_firmware.model; firmware.ModelVersion = dc_firmware.modelVersion; firmware.ProtocolVersion = dc_firmware.protocolVersion; firmware.HardwareVersion = dc_firmware.hardwareVersion; firmware.SoftwareVersion = dc_firmware.softwareVersion; firmware.FileName = Path.Combine(firmwareFolder, dc_firmware.fileName); versionMicrosHostController.Add(firmware); //Si no existe el archivo de firmware if (!File.Exists(firmware.FileName)) { bool bOk = false; bool bContinue = false; int nSequence = 1; //Download firmware update do { int nTries = 3; bOk = false; dc_UpdateFirmware updateFirmware = new dc_UpdateFirmware(); while (nTries > 0 && !bOk) { updateFirmware = serviceClient.GetFileUpdateFirmware(nSequence, dc_firmware.fileName); bOk = updateFirmware.sequence == nSequence; bContinue = !updateFirmware.final; nTries--; } if (!bOk) { break; } nSequence++; (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.WriteAllBytes(firmware.FileName, updateFirmware.bytes, true); } while (bContinue); } } } serviceClient.Close(); } } catch (Exception ex) { LoggerModule.logger.Error(System.Reflection.MethodInfo.GetCurrentMethod().Name + ". Error: " + ex.Message); } versionMicros = versionMicrosHostController; }