public static bool SetLicense(Page mainPage, bool silent = false) { // Need Page as parameter instead of using MainPage as this code may execute within the Page's constructor RasterSupport.Initialize(mainPage); if (RasterSupport.KernelExpired) { try { byte[] licBytes = System.Text.Encoding.UTF8.GetBytes(LicContents); RasterSupport.SetLicense(licBytes, KeyContents); } catch (Exception ex) { Debug.WriteLine(ex.Message); } } if (RasterSupport.KernelExpired && !silent) { string msg = "Your license file is missing, invalid or expired. LEADTOOLS will not function. Please contact LEAD Sales for information on obtaining a valid license."; MainThread.BeginInvokeOnMainThread(async() => await mainPage.DisplayAlert("Error", msg, "OK")); } return(!RasterSupport.KernelExpired); }
public static bool SetLicense(bool silent) { try { //不读文件,改为直接写入字符串 //var key = File.ReadAllText(Application.StartupPath+"\\full_license.key"); string key = "gcxLXptTi5bPbVDDR9E+k4CRC8BLLm0IuN383qJp6jPqoMTYamOe1yuYzHqrCmFEN5zDcumaaCTXpO9GpeGal0wjSKF8nxnu"; var lic = File.ReadAllBytes(Application.StartupPath + "\\fl.lic"); RasterSupport.SetLicense(lic, key); } catch (Exception ex) { Debug.Write(ex.Message); } if (RasterSupport.KernelExpired) { string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); /* Try the common LIC directory */ string licenseFileRelativePath = Path.Combine(dir, "..\\..\\..\\Common\\License\\LEADTOOLS.LIC"); string keyFileRelativePath = Path.Combine(dir, "..\\..\\..\\Common\\License\\LEADTOOLS.LIC.key"); if (File.Exists(licenseFileRelativePath) && File.Exists(keyFileRelativePath)) { string developerKey = File.ReadAllText(keyFileRelativePath); try { RasterSupport.SetLicense(licenseFileRelativePath, developerKey); } catch (Exception ex) { Debug.Write(ex.Message); } } } if (RasterSupport.KernelExpired) { if (silent == false) { string msg = "Your license file is missing, invalid or expired. LEADTOOLS will not function. Please contact LEAD Sales for information on obtaining a valid license."; string logmsg = string.Format("*** NOTE: {0} ***{1}", msg, Environment.NewLine); Debugger.Log(0, null, "*******************************************************************************" + Environment.NewLine); Debugger.Log(0, null, logmsg); Debugger.Log(0, null, "*******************************************************************************" + Environment.NewLine); MessageBox.Show(null, msg, "No LEADTOOLS License", MessageBoxButtons.OK, MessageBoxIcon.Stop); Process.Start("https://www.leadtools.com/downloads/evaluation-form.asp?evallicenseonly=true"); } return(false); } return(true); }
public static bool SetLicense(bool silent) { try { // TODO: Change this to use your license file and developer key */ string licenseFilePath = AppDomain.CurrentDomain.BaseDirectory + "\\full_license.lic"; string developerKey = "gcxLXptTi5bPbVDDR9E+k4CRC8BLLm0IuN383qJp6jPqoMTYamOe1yuYzHqrCmFEN5zDcumaaCTXpO9GpeGal0wjSKF8nxnu"; var lic = File.ReadAllBytes(licenseFilePath); RasterSupport.SetLicense(lic, developerKey); //RasterSupport.SetLicense(licenseFilePath, developerKey); } catch (Exception ex) { System.Diagnostics.Debug.Write(ex.Message); } if (RasterSupport.KernelExpired) { if (silent == false) { string msg = "Your license file is missing, invalid or expired. LEADTOOLS will not function. Please contact LEAD Sales for information on obtaining a valid license."; string logmsg = string.Format("*** NOTE: {0} ***{1}", msg, Environment.NewLine); System.Diagnostics.Debugger.Log(0, null, "*******************************************************************************" + Environment.NewLine); System.Diagnostics.Debugger.Log(0, null, logmsg); System.Diagnostics.Debugger.Log(0, null, "*******************************************************************************" + Environment.NewLine); MessageBox.Show(null, msg, "No LEADTOOLS License", MessageBoxButtons.OK, MessageBoxIcon.Stop); System.Diagnostics.Process.Start("https://www.leadtools.com/downloads/evaluation-form.asp?evallicenseonly=true"); } return(false); } return(true); }
private bool SetLicense() { var _files = Directory.GetFiles(Path.Combine(LibUtilities.TheEnvironmentVariablePath, TheEnvVarSubDir.License), "*.*", SearchOption.AllDirectories) .Where(file => (file.ToLower().EndsWith("lic") || file.ToLower().EndsWith("key"))) .ToArray(); if (_files.ToList().Count < 2) { return(false); } if (string.IsNullOrWhiteSpace(_files.Where(file => file.ToLower().EndsWith("lic")).ToList()[0]) || string.IsNullOrWhiteSpace(_files.Where(file => file.ToLower().EndsWith("key")).ToList()[0])) { return(false); } RasterSupport.SetLicense(_files.Where(file => file.ToLower().EndsWith("lic")).ToList()[0], File.ReadAllText(_files.Where(file => file.ToLower().EndsWith("key")).ToList()[0])); if (RasterSupport.KernelExpired) { return(false); } if (RasterSupport.IsLocked(RasterSupportType.Forms)) { return(false); } if (RasterSupport.IsLocked(RasterSupportType.OcrLEAD)) { return(false); } return(true); }
public static void Startup() { //_logFile.WriteToLog("Applying Leadtools license..."); string licenseFileName = ""; string licenseFileWithLocation = ""; string developerKey = ""; try { string currDir = System.Reflection.Assembly.GetEntryAssembly().Location; currDir = Path.GetDirectoryName(currDir); licenseFileName = Properties.Settings.Default.LeadtoolsLicenseFile; licenseFileWithLocation = currDir + @"\" + licenseFileName; developerKey = Properties.Settings.Default.LeadtoolsDeveloperKey; //_logFile.WriteToLog("Applying license at: " + licenseFileWithLocation); //_logFile.WriteToLog("Applying key: " + developerKey); RasterSupport.SetLicense(licenseFileWithLocation, developerKey); //_logFile.WriteToLog("Applied Leadtools license."); codec = new RasterCodecs(); //_logFile.WriteToLog("Lead tools Codec object is created"); } catch (Exception e) { _logFile.WriteToLog("Problem applying Leadtools license:"); _logFile.WriteToLog("LeadtoolsLicenseFile = " + licenseFileName); _logFile.WriteToLog("licenseFileWithLocation = " + licenseFileWithLocation); _logFile.WriteToLog("LeadtoolsLicenseFile = " + developerKey); _logFile.WriteToLog(e.StackTrace + "\nInner Exception: " + e.InnerException); throw e; } }
private static bool UnlockLeadtools() { const string licenseFile = @"..\..\..\common\license\leadtools.lic"; try { var developerKey = File.ReadAllText(licenseFile + ".key"); RasterSupport.SetLicense(licenseFile, developerKey); if (RasterSupport.KernelExpired) { Console.WriteLine("LEADTOOLS License has Expired!\nPress [Enter] to exit."); Console.ReadLine(); return(false); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); Console.WriteLine("\nPress [Enter] to exit."); Console.ReadLine(); return(false); } return(true); }
private bool TrySetLicense(string licensePath, string developerKey) { try { RasterSupport.SetLicense(licensePath, developerKey); //try to set license } catch (Exception ex) { // log.Error(ex, "Error while setup license"); } if (RasterSupport.KernelExpired) { // log.Error("Your license file is missing, invalid or expired. LEADTOOLS will not function. Please contact LEAD Sales for information on obtaining a valid license."); return(false); } if (RasterSupport.IsLocked(RasterSupportType.Forms)) { // log.Error("Forms support must be unlocked!"); return(false); } if (RasterSupport.IsLocked(RasterSupportType.OcrLEAD)) { // log.Error("OCR support must be unlocked!"); return(false); } // log.Info("Licnse is valid."); return(true); }
public static bool SetLicense(bool silent) { try { // TODO: Change this to use your license file and developer key */ string licenseFilePath = AppDomain.CurrentDomain.BaseDirectory + "\\full_license.lic"; string developerKey = "gcxLXptTi5bPbVDDR9E+k4CRC8BLLm0IuN383qJp6jPqoMTYamOe1yuYzHqrCmFEN5zDcumaaCTXpO9GpeGal0wjSKF8nxnu"; var lic = File.ReadAllBytes(licenseFilePath); RasterSupport.SetLicense(lic, developerKey); //RasterSupport.SetLicense(licenseFilePath, developerKey); } catch (Exception ex) { //System.Diagnostics.Debug.Write(ex.Message); ServiceLog.WriteLog("Set License Error, " + ex.Message); } if (RasterSupport.KernelExpired) { if (silent == false) { string msg = "Your license file is missing, invalid or expired. LEADTOOLS will not function. Please contact LEAD Sales for information on obtaining a valid license."; string logmsg = string.Format("*** NOTE: {0} ***{1}", msg, Environment.NewLine); ServiceLog.WriteLog("*******************************************************************************" + Environment.NewLine); ServiceLog.WriteLog(logmsg); ServiceLog.WriteLog("*******************************************************************************" + Environment.NewLine); } return(false); } return(true); }
static void Main(string[] args) { String fileToConvert = @"FILE PATH HERE"; RasterSupport.SetLicense(@"C:\LEADTOOLS 20\Common\License\LEADTOOLS.LIC", System.IO.File.ReadAllText(@"C:\LEADTOOLS 20\Common\License\LEADTOOLS.LIC.KEY")); using (RasterCodecs codecs = new RasterCodecs()) { using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false)) { ocrEngine.Startup(null, null, null, @"C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime"); using (IOcrPage ocrPage = ocrEngine.CreatePage(ocrEngine.RasterCodecsInstance.Load(fileToConvert, 1), OcrImageSharingMode.AutoDispose)) { ocrPage.AutoZone(null); ocrPage.Recognize(null); string recognizedCharacters = ocrPage.GetText(-1); BarcodeEngine engine = new BarcodeEngine(); int resolution = 300; using (RasterImage image = RasterImage.Create((int)(8.5 * resolution), (int)(11.0 * resolution), 1, resolution, RasterColor.FromKnownColor(RasterKnownColor.White))) { BarcodeWriter writer = engine.Writer; QRBarcodeData data = BarcodeData.CreateDefaultBarcodeData(BarcodeSymbology.QR) as QRBarcodeData; data.Bounds = new LeadRect(0, 0, image.ImageWidth, image.ImageHeight); QRBarcodeWriteOptions writeOptions = writer.GetDefaultOptions(data.Symbology) as QRBarcodeWriteOptions; writeOptions.XModule = 30; writeOptions.HorizontalAlignment = BarcodeAlignment.Near; writeOptions.VerticalAlignment = BarcodeAlignment.Near; data.Value = recognizedCharacters; writer.CalculateBarcodeDataBounds(new LeadRect(0, 0, image.ImageWidth, image.ImageHeight), image.XResolution, image.YResolution, data, writeOptions); Console.WriteLine("{0} by {1} pixels", data.Bounds.Width, data.Bounds.Height); writer.WriteBarcode(image, data, writeOptions); CropCommand cmd = new CropCommand(new LeadRect(0, 0, data.Bounds.Width, data.Bounds.Height)); cmd.Run(image); codecs.Save(image, "QR.tif", RasterImageFormat.CcittGroup4, 1); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { var process = new Process(); process.StartInfo = new ProcessStartInfo("QR.tif") { UseShellExecute = true }; process.Start(); } Console.WriteLine(); } } } } }
private static void UnlockSupport() { // TODO: If you need a license file, go to https://www.leadtools.com/downloads?category=main var lic = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @"Leadtools.lic"); var key = File.ReadAllText(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @"Leadtools.lic.key")); RasterSupport.SetLicense(lic, key); }
private static void UnlockSupport() { // TODO: This is using the default path; change as needed. // If you need a license file, go to https://www.leadtools.com/downloads?category=main const string lic = @"C:\leadtools 19\common\license\Leadtools.lic"; var key = File.ReadAllText(@"C:\leadtools 19\common\license\Leadtools.lic.key"); RasterSupport.SetLicense(lic, key); }
public BarcodesController() { barcodeEngineInstance = new BarcodeEngine(); // Requires a license file that unlocks 1D barcode read functionality. string MY_LICENSE_FILE = @"C:\LEADTOOLS 20\Common\License\leadtools.lic"; string MY_DEVELOPER_KEY = System.IO.File.ReadAllText(@"C:\LEADTOOLS 20\Common\License\leadtools.lic.key"); RasterSupport.SetLicense(MY_LICENSE_FILE, MY_DEVELOPER_KEY); }
static void Initialize() { RasterSupport.SetLicense(@"C:\LEADTOOLS 20\Common\License\LEADTOOLS.LIC", System.IO.File.ReadAllText(@"C:\LEADTOOLS 20\Common\License\LEADTOOLS.LIC.KEY")); codecs = new RasterCodecs(); ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false); ocrEngine.Startup(null, null, null, null); }
public static bool SetLicense(bool silent = false) { try { var developerKey = System.IO.File.ReadAllText(DeveloperKeyPath); RasterSupport.SetLicense(LicenseFilePath, developerKey); } catch (Exception ex) { System.Diagnostics.Debug.Write(ex.Message); } if (RasterSupport.KernelExpired) { var dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); /* Try the common LIC directory */ if (dir != null) { var licenseFileRelativePath = System.IO.Path.Combine(dir, Path.RelativePathToRoot, "common-files\\leadtools-license\\eval-license-files.LIC"); var keyFileRelativePath = System.IO.Path.Combine(dir, Path.RelativePathToRoot, "common-files\\leadtools-license\\eval-license-files.LIC.key"); if (System.IO.File.Exists(licenseFileRelativePath) && System.IO.File.Exists(keyFileRelativePath)) { var developerKey = System.IO.File.ReadAllText(keyFileRelativePath); try { RasterSupport.SetLicense(licenseFileRelativePath, developerKey); } catch (Exception ex) { System.Diagnostics.Debug.Write(ex.Message); } } } } if (!RasterSupport.KernelExpired) { return(true); } if (silent) { return(false); } const string msg = "Your license file is missing, invalid, or expired. LEADTOOLS will not function.\nPlease contact [email protected] for information on obtaining a valid license."; var logmsg = string.Format("*** NOTE: {0} ***{1}", msg, Environment.NewLine); System.Diagnostics.Debugger.Log(0, null, "*******************************************************************************" + Environment.NewLine); System.Diagnostics.Debugger.Log(0, null, logmsg); System.Diagnostics.Debugger.Log(0, null, "*******************************************************************************" + Environment.NewLine); Console.WriteLine(msg); Path.ShellExecute(NewEvaluationLicenseUrl); return(false); }
private void MainForm_Load(object sender, EventArgs e) { //Set our LEADTOOLS License and Developer Key RasterSupport.SetLicense(@"C:\LEADTOOLS 19\Common\License\LEADTOOLS.LIC", System.IO.File.ReadAllText(@"C:\LEADTOOLS 19\Common\License\LEADTOOLS.LIC.KEY")); //Create a RasterCodecs Instance _codecs = new RasterCodecs(); //Startup our DICOM Engine DicomEngine.Startup(); }
public SingleUseCouponsController(ApplicationDbContext context, IHostingEnvironment host) { _context = context; _host = host; barcodeEngineInstance = new BarcodeEngine(); // Requires a license file that unlocks 1D barcode read functionality. string MY_LICENSE_FILE = @"C:\LEADTOOLS 20\Common\License\leadtools.lic"; string MY_DEVELOPER_KEY = System.IO.File.ReadAllText(@"C:\LEADTOOLS 20\Common\License\leadtools.lic.key"); RasterSupport.SetLicense(MY_LICENSE_FILE, MY_DEVELOPER_KEY); }
private static void Printer_EmfEvent(object sender, EmfEventArgs e) { string licString = @"F:\LeadToolsDeveloperTrialVersion\eval-license-files_ca9205db-0588-4317-8b13-dc1fef29e86e\eval-license-files.lic"; string developerKey = "g8xOXslT1JadbVXDQNE7k4CRUMBLLjEIvt383qJptzPvoMXYamOe13OYknr9CmFEbpzAcriaPCSEpO9G9+HPl0sjQaEqn0zu"; RasterSupport.SetLicense(licString, developerKey); System.IO.File.WriteAllBytes(Path.Combine(LEAD_VARS.ImagesDir, @"LEADTOOLS_IMAGE1.emf"), e.Stream.ToArray()); Metafile metaFile = new Metafile(e.Stream); Image emfImage = metaFile.GetThumbnailImage(metaFile.Width, metaFile.Height, null, IntPtr.Zero); emfImage.Save(Path.Combine(LEAD_VARS.ImagesDir, @"LEADTOOLS_IMAGE2.emf")); }
public static void SetLicense() { string p_Lic, p_Key; //1、读取License文件 //License文件夹被我放到Debug文件夹和Release文件夹里,可以根据需要变更文件路径 System.IO.TextReader reader = System.IO.File.OpenText(@"License\full_license.key"); p_Key = reader.ReadLine(); reader = System.IO.File.OpenText(@"License\full_license.lic"); p_Lic = reader.ReadToEnd(); //下面只是注册License的其中一中方式 byte[] licenseBuffer = ASCIIEncoding.ASCII.GetBytes(p_Lic.ToCharArray()); RasterSupport.ResetLicense(); RasterSupport.SetLicense(licenseBuffer, p_Key); }
protected override void OnLoad(EventArgs e) { // Requires a license file that unlocks 1D barcode read functionality. string MY_LICENSE_FILE = @"C:\LEADTOOLS 20\Common\License\leadtools.lic"; string MY_DEVELOPER_KEY = System.IO.File.ReadAllText(@"C:\LEADTOOLS 20\Common\License\leadtools.lic.key"); RasterSupport.SetLicense(MY_LICENSE_FILE, MY_DEVELOPER_KEY); // Create the BarcodeEngine instance barcodeEngineInstance = new BarcodeEngine(); readBarcodesButton.Click += readBarcodesButton_Click; loadImageButton.Click += loadImageButton_Click; base.OnLoad(e); }
public static void SetLicense() { try { RasterSupport.SetLicense("", "Nag"); /* Uncomment this and add your license file and developer key * string licenseFilePath = "Replace this with the path to the LEADTOOLS license file"; * string developerKey = "Replace this with your developer key"; * RasterSupport.SetLicense(licenseFilePath, developerKey); */ } catch (Exception ex) { System.Diagnostics.Debug.Write(ex.Message); } }
public static void Set() { string licenseFilePath = "LeadToolsHelpers\\eval-license-files.lic"; //Your .LIC file path here string developerKey = System.IO.File.ReadAllText("LeadToolsHelpers\\eval-license-files.lic.key"); //Your .KEY file path here RasterSupport.SetLicense(licenseFilePath, developerKey); //Tests to see if license supports a particular type bool isLocked = RasterSupport.IsLocked(RasterSupportType.Document); if (isLocked) { Trace.WriteLine("Document support is locked"); } else { Trace.WriteLine("Document support is unlocked"); } }
public FrmShowPhotoLocation() { RasterSupport.SetLicense( File.ReadAllBytes(Path.Combine(_rootPath, @"Common\License\leadtools.lic")), File.ReadAllText(Path.Combine(_rootPath, @"Common\License\leadtools.lic.key"))); InitializeComponent(); webBrowser1.ScriptErrorsSuppressed = true; webBrowser1.ScrollBarsEnabled = true; RasterPaintProperties paintProperties = RasterPaintProperties.Default; paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic; paintProperties.PaintEngine = RasterPaintEngine.GdiPlus; paintProperties.UsePaintPalette = true; rasterPictureBox1.PaintProperties = paintProperties; rasterPictureBox1.SizeMode = RasterPictureBoxSizeMode.Fit; }
/// <summary> /// 初期化処理 /// </summary> private void Initialization() { RasterSupport.SetLicense(Application.StartupPath + "\\LEAD175ImgSuite.lic", "+sxwXvpT1JbgbQ7DAdF9k8WRWcBnLgwIjN2a3sVpuzOIoMTYIWPT13qYg3qhCnFE"); RasterSupport.SetLicense(Application.StartupPath + "\\LEAD175PDFRead.lic", "GL/iTglRN/ENEQvqOhAf1Z9QTPE2TPnSKBIV46X+rLrYLjpOwntMtnq5nDOWh+skhCe196Z5xK/6f/eatnC7zYlWLKBkYEdBuTw3Kd5JE66jNVn08HpvVdJjz9YAT+77V8P70s5whFv4rFKlzZ/zN3CUmyNeEpoav9oOfSTE2s4heejvh/VZ3BMI8dnR4SRdHumqwebWJSeee9zhTWmU1ubSjEjJSG/HHgfAExQHiKUc5SiwTe2MMBCDdagF3yz10sD8WhkQ/PiIAh5cD+GSUmXHdY3VgW/I6LlwY8vXQfqH/a8a9+79ite7Hye71P6Aqmw3fYX4jJgHioqMxatL2A8NJz5rPzgqPBc817V1qZ8AcaM/LIWnGPHGVqBeIgCjydQlvEjknm9i2Jny83+T3ETq2Sg5YBY1P8+3ccQcY+Xae/KdK6/L7EoYFeq3NAf6mHLN3rK5zOT7uBfHTfVNJQ=="); codecs = new RasterCodecs(); // すべてのチェックボックスにチェックする for (int i = 0; i < chkExt.Items.Count; i++) { chkExt.SetItemChecked(i, true); } // デフォルト縦 this.cmbDirection.SelectedIndex = 0; // デフォルトWhite this.cpTargetColor.Value = Color.White; // デフォルト4ピクセル this.numPixel.Value = 4; // 中止ボタン使用不可 this.btnAbort.Enabled = false; }
public static void SetLicense() { if (!RasterSupport.KernelExpired) { return; } // file path may be relative or absolute // license/dev key may be relative, absolute, or the full text string license = ReadLicense(); string licKey = ReadLicenseKey(); if (!string.IsNullOrEmpty(license) && !string.IsNullOrEmpty(licKey)) { RasterSupport.SetLicense(Encoding.ASCII.GetBytes(license), licKey); } else if (string.IsNullOrEmpty(license) && RasterSupport.KernelExpired) { Demos.Support.SetLicense(true); } }
private void Form1_Load(object sender, EventArgs e) { const string licenseFile = @"C:\LEADTOOLS 19\Common\License\Leadtools.lic"; string developerKey = File.ReadAllText(licenseFile + ".key"); RasterSupport.SetLicense(licenseFile, developerKey); // Initialize a new RasterCodecs object using (var codecs = new RasterCodecs()) { rpbOriginal.Image = codecs.Load( @"tippy test_edited.jpg", 24, CodecsLoadByteOrder.Bgr, 1, 1); } SetUpDitheringMethods(); SetUpPalettes(); SetUpColorMatchingMethods(); rpbNormalScale.UseDpi = false; nudMaxPixels.Value = 5000; }
static void Main(string[] args) { RasterSupport.SetLicense(@"C:\LEADTOOLS 19\Common\License\LEADTOOLS.LIC", File.ReadAllText(@"C:\LEADTOOLS 19\Common\License\LEADTOOLS.LIC.KEY")); Byte[] imageData = File.ReadAllBytes(@"C:\Users\Public\Documents\LEADTOOLS Images\cannon.jpg"); using (MemoryStream ms = new MemoryStream(imageData)) { // Put the pointer back to the beginning ms.Seek(0, System.IO.SeekOrigin.Begin); using (RasterCodecs codecs = new RasterCodecs()) { // Load the source image from disk using (RasterImage image = codecs.Load(ms)) // on this line I got error... { //do something with the image } } } }
public void ApplyLicense() { string licenseFilePath = System.IO.Path.GetFullPath(@"LeadToolsLicense\License.lic"); string keyFilePath = System.IO.Path.GetFullPath(@"LeadToolsLicense\License.lic.key"); if (System.IO.File.Exists(licenseFilePath) && System.IO.File.Exists(keyFilePath)) { string developerKey = System.IO.File.ReadAllText(keyFilePath); RasterSupport.SetLicense(licenseFilePath, developerKey); } else { throw new LicenseException( typeof(RasterSupport), null, $"No se han encontrado los archivos de licencia necesarios:\n{licenseFilePath}\n{keyFilePath}"); } if (RasterSupport.KernelExpired) { var exMessage = "La licencia es inválida o ha expirado. El componente de LeadTools se ha deshabilitado. Por favor, contacte con el soporte técnico de LeadTools para conseguir una licencia válida."; throw new LicenseException(typeof(RasterSupport), null, exMessage); } }
public static bool UnlockSupport() { if (RasterSupport.KernelExpired) { try { RasterSupport.SetLicense(LicensePath, DeveloperKey); } catch (Exception ex) { Debug.WriteLine("Error Setting License: " + ex.Message); } } if (RasterSupport.KernelExpired) { string msg = "Your license file is missing, invalid or expired. LEADTOOLS will not function. Please contact LEAD Sales for information on obtaining a valid license."; Debug.WriteLine($"*******************************************************************************{Environment.NewLine}"); Debug.WriteLine($"*** NOTE: {msg} ***{Environment.NewLine}"); Debug.WriteLine($"*******************************************************************************{Environment.NewLine}"); return(false); } return(true); }
/// <summary> /// Loads the LEADTools license to allow LEADTools functionality /// to be used. /// </summary> private static void SetLeadtoolsLicense() { RasterSupport.SetLicense(Constants.LeadLicense, Constants.LeadKey); }
public static void SetLicense() { if (!RasterSupport.KernelExpired) { return; } // file path may be relative or absolute // dev key may be relative, absolute, or the full text string licensePath = null; string devKey = null; // First check the config file (appSettings) var licSetting = GetSettingValue(Key_License_FilePath); if (!string.IsNullOrEmpty(licSetting)) { // If settings are wrong from here on out, we need to throw an exception licSetting = GetAbsolutePath(licSetting); if (File.Exists(licSetting)) { licensePath = licSetting; // devKey can be relative, absolute, or file contents var devKeySetting = GetSettingValue(Key_License_DeveloperKey); if (devKeySetting != null) { devKeySetting = devKeySetting.Trim(); } if (devKeySetting != null && IsAbsolutePath(devKeySetting) && File.Exists(devKeySetting)) { var devKeyFile = devKeySetting; devKey = File.ReadAllText(devKeyFile); } else if (devKeySetting != null) { // Coule be a relative path or a developer key, see if the file exist var devKeyFile = GetAbsolutePath(devKeySetting); if (File.Exists(devKeyFile)) { devKey = File.ReadAllText(devKeyFile); } else { devKey = devKeySetting; } } else { throw new InvalidOperationException("Developer key in configuration was invalid."); } } else { throw new InvalidOperationException("License file path in configuration does not exist."); } } else { // Was not found there, check the bin folder var currentContext = HttpContext.Current; if (currentContext != null && currentContext.Server != null) { string licBinPath = currentContext.Server.MapPath(@"~/bin/LEADTOOLS.LIC"); if (File.Exists(licBinPath)) { licensePath = licBinPath; // get value for devKey, process to get file contents string devKeyBinPath = currentContext.Server.MapPath(@"~/bin/LEADTOOLS.LIC.key"); if (File.Exists(devKeyBinPath)) { devKey = File.ReadAllText(devKeyBinPath); } } } } if (!string.IsNullOrEmpty(licensePath) && !string.IsNullOrEmpty(devKey)) { RasterSupport.SetLicense(licensePath, devKey); } else { // This will work for development if LEADTOOLS is installed on the machine RasterSupport.SetLicense("", "Nag"); } }