public License ConvertToLicense() { License license = new License(); license.id = this.LicenseId; license.tenantId = this.TenantId; license.installationKey = ResourceProtector.GenerateHash(ResourceProtector.GetHardwareId()); license.installationDate = DateTime.Now; license.computerName = Environment.MachineName; return(license); }
/// <summary> /// Obtem os parâmetros de execução a partir do XML /// </summary> public static NameValueCollection GetTaskParams() { NameValueCollection taskParams = new NameValueCollection(); try { String baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location.ToString()); String xmlLocation = PathFormat.Adjust(baseDir) + "JobRouting.xml"; XmlTextReader xmlReader = new XmlTextReader(xmlLocation); xmlReader.ReadStartElement("jobrouting"); taskParams.Add("url", xmlReader.ReadElementString("url")); taskParams.Add("tenantId", xmlReader.ReadElementString("tenantid")); taskParams.Add("interval", xmlReader.ReadElementString("interval")); taskParams.Add("logDirectories", xmlReader.ReadElementString("logdirectories")); taskParams.Add("copyLogDir", xmlReader.ReadElementString("copylogdir")); taskParams.Add("installationKey", xmlReader.ReadElementString("installationkey")); taskParams.Add("xmlHash", xmlReader.ReadElementString("xmlhash")); xmlReader.ReadEndElement(); xmlReader.Close(); } catch { return(null); } String installationKey = ResourceProtector.GetHardwareId(); installationKey = ResourceProtector.GenerateHash(installationKey); String xmlHash = taskParams["url"] + taskParams["tenantId"] + taskParams["interval"] + taskParams["logDirectories"]; xmlHash = ResourceProtector.GenerateHash(xmlHash); // Verifica se os parâmetros estão corretos (batem com os configurados durante a instalação) if (installationKey != taskParams["installationkey"]) { return(null); } if (xmlHash != taskParams["xmlhash"]) { return(null); } return(taskParams); }