/// <summary> /// Returns the station latest firmware version given a station model and a hardware version /// </summary> /// <param name="requestInfoUpdateFirmware">Station model and hardware version information</param> /// <returns>Station firmware information</returns> public List <dc_FirmwareStation> GetInfoUpdateFirmware(dc_FirmwareStation requestInfoUpdateFirmware) { //Descargar el archivo de versiones del remote server string sFilePath = m_systemFilesManager.DownloadFile(System.Convert.ToString(My.Settings.Default.VersionFirmwareFileName)); Hashtable htInfoUpdateFirmware = new Hashtable(); //Language -> dc_FirmwareVersion Hashtable htLatestFirmwareDate = new Hashtable(); //Language -> Date if (File.Exists(sFilePath)) { bool bFoundModel = false; bool bFoundHw = false; //Decrypt byte[] fileReader = File.ReadAllBytes(sFilePath); byte[] Key = JBC_encryption.JBC_ENCRYPTION_KEY; byte[] IV = JBC_encryption.JBC_ENCRYPTION_IV; string decrypted = System.Convert.ToString(RoutinesLibrary.Security.AES.DecryptStringFromBytes_AES(fileReader, Key, IV)); //Carriage Return (0x0D AKA Char 13) and Line Feed (0x0A AKA Char 10) string[] sTextLines = decrypted.Replace("\r", "").Split('\n'); //Leemos el documento line by line foreach (string sTextLine in sTextLines) { //Buscar modelo if (!bFoundModel) { //Es una línea de modelo if (sTextLine.IndexOf(MODEL_MARK) == 0) { string[] lineArray = Strings.Split(sTextLine, SEPARATOR, MODEL_LINE_ARGS); //Comprobar el numero de campos de una linea if (lineArray.Length == MODEL_LINE_ARGS) { //Modelo encontrado if (lineArray[1].Trim() == requestInfoUpdateFirmware.model) { bFoundModel = true; } } } //Buscar hardware } else if (bFoundModel && !bFoundHw) { //Es una línea de hardware if (sTextLine.IndexOf(HARDWARE_MARK) == 0) { string[] lineArray = Strings.Split(sTextLine, SEPARATOR, HARDWARE_LINE_ARGS); //Comprobar el numero de campos de una linea if (lineArray.Length == HARDWARE_LINE_ARGS) { //Hardware encontrado if (lineArray[1].Trim() == requestInfoUpdateFirmware.hardwareVersion || lineArray[1].Trim() == HARDWARE_ALL_VERSION) { bFoundModel = true; bFoundHw = true; } } //Si es una línea de modelo salir } else if (sTextLine.IndexOf(MODEL_MARK) == 0) { break; } //Buscar software } else if (bFoundModel && bFoundHw) { //Es una línea de software if (sTextLine.IndexOf(SOFTWARE_MARK) == 0) { string[] lineArray = Strings.Split(sTextLine, SEPARATOR, SOFTWARE_LINE_ARGS); //Comprobar el numero de campos de una linea if (lineArray.Length >= SOFTWARE_LINE_ARGS_NO_LANG) { //Si es una estación multidioma seleccionamos el idioma string language = SOFTWARE_DEFAULT_LANGUAGE; if (lineArray.Length == SOFTWARE_LINE_ARGS) { language = lineArray[6].Trim(); } //Elemento nuevo if (!htInfoUpdateFirmware.Contains(language)) { dc_FirmwareStation newInfoUpdateFirmware = new dc_FirmwareStation(); newInfoUpdateFirmware.stationUUID = requestInfoUpdateFirmware.stationUUID; newInfoUpdateFirmware.model = requestInfoUpdateFirmware.model; newInfoUpdateFirmware.hardwareVersion = requestInfoUpdateFirmware.hardwareVersion; newInfoUpdateFirmware.softwareVersion = lineArray[1].Trim(); newInfoUpdateFirmware.modelVersion = lineArray[2].Trim(); newInfoUpdateFirmware.protocolVersion = lineArray[3].Trim(); newInfoUpdateFirmware.fileName = lineArray[4].Trim(); newInfoUpdateFirmware.language = language; htInfoUpdateFirmware.Add(language, newInfoUpdateFirmware); htLatestFirmwareDate.Add(language, lineArray[5].Trim()); //Elemento existente. Comprobar si la fecha es mas reciente } else if (Convert.ToDateTime((htLatestFirmwareDate[language]).ToString()) < Convert.ToDateTime(lineArray[5].Trim())) { dc_FirmwareStation newInfoUpdateFirmware = (dc_FirmwareStation)(htInfoUpdateFirmware[language]); newInfoUpdateFirmware.softwareVersion = lineArray[1].Trim(); newInfoUpdateFirmware.modelVersion = lineArray[2].Trim(); newInfoUpdateFirmware.protocolVersion = lineArray[3].Trim(); newInfoUpdateFirmware.fileName = lineArray[4].Trim(); htInfoUpdateFirmware[language] = newInfoUpdateFirmware; htLatestFirmwareDate[language] = lineArray[5].Trim(); } } //No es una línea de software, salir } else { break; } } } } //Valores a retornar. Convertir de hashtable a list List <dc_FirmwareStation> retInfoUpdateFirmware = new List <dc_FirmwareStation>(); foreach (DictionaryEntry infoUpdateFirmwareEntry in htInfoUpdateFirmware) { retInfoUpdateFirmware.Add((dc_FirmwareStation)infoUpdateFirmwareEntry.Value); } return(retInfoUpdateFirmware); }
/// <summary> /// Checks if exists an update form JBC's server /// </summary> /// <returns>Update information</returns> public stSwVersion GetInfoNewUpdate() { stSwVersion infoUpdateSw = new stSwVersion(); //descargar el archivo de versiones del remote server m_systemFilesManager.DownloadFile(System.Convert.ToString(My.Settings.Default.VersionFileName)); //obtener la información del archivo de versiones stSwVersion remoteSwVersion = m_versionFileParser.GetInfoLastSwVersion(); //obtener la información de las versiones instaladas en la red local stSwVersion currentSwVersion = m_localData.GetSwInfo(); //obtiene la fecha de la última actualización infoUpdateSw.lastUpdateDate = m_localData.GetLastUpdateDate(); //Comprobar si hay actualizacion software del StationController if (remoteSwVersion.stationControllerSwDate > currentSwVersion.stationControllerSwDate) { infoUpdateSw.stationControllerSwAvailable = true; infoUpdateSw.stationControllerSwDate = remoteSwVersion.stationControllerSwDate; infoUpdateSw.stationControllerSwVersion = remoteSwVersion.stationControllerSwVersion; infoUpdateSw.stationControllerSwUrl = remoteSwVersion.stationControllerSwUrl; } else { infoUpdateSw.stationControllerSwAvailable = false; } //Comprobar si hay actualizacion software del RemoteManager if (remoteSwVersion.remoteManagerSwDate > currentSwVersion.remoteManagerSwDate) { infoUpdateSw.remoteManagerSwAvailable = true; infoUpdateSw.remoteManagerSwDate = remoteSwVersion.remoteManagerSwDate; infoUpdateSw.remoteManagerSwVersion = remoteSwVersion.remoteManagerSwVersion; infoUpdateSw.remoteManagerSwUrl = remoteSwVersion.remoteManagerSwUrl; } else { infoUpdateSw.remoteManagerSwAvailable = false; } //Comprobar si hay actualizacion software del HostController if (remoteSwVersion.hostControllerSwDate > currentSwVersion.hostControllerSwDate) { infoUpdateSw.hostControllerSwAvailable = true; infoUpdateSw.hostControllerSwDate = remoteSwVersion.hostControllerSwDate; infoUpdateSw.hostControllerSwVersion = remoteSwVersion.hostControllerSwVersion; infoUpdateSw.hostControllerSwUrl = remoteSwVersion.hostControllerSwUrl; } else { infoUpdateSw.hostControllerSwAvailable = false; } //Comprobar si hay actualizacion software del WebManager if (remoteSwVersion.webManagerSwDate > currentSwVersion.webManagerSwDate) { infoUpdateSw.webManagerSwAvailable = true; infoUpdateSw.webManagerSwDate = remoteSwVersion.webManagerSwDate; infoUpdateSw.webManagerSwVersion = remoteSwVersion.webManagerSwVersion; infoUpdateSw.webManagerSwUrl = remoteSwVersion.webManagerSwUrl; } else { infoUpdateSw.webManagerSwAvailable = false; } return(infoUpdateSw); }