示例#1
0
        public EngineClass GetMultipleClass()
        {
            try
            {
                var className = $"{Name}Response";
                var result    = new EngineClass()
                {
                    Name = className,
                    Type = "object",
                };
                foreach (var response in Responses)
                {
                    var engineProprty = new EngineProperty()
                    {
                        Name        = response.Name,
                        Description = response.Description,
                        Type        = QlikApiUtils.GetDotNetType(response.GetRealType()),
                        Required    = response.Required,
                        Format      = response.Format,
                    };

                    var serviceType = response.GetServiceType();
                    if (serviceType != null)
                    {
                        engineProprty.Type = serviceType;
                    }
                    result.Properties.Add(engineProprty);
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception("The method \"GetMultipleClass\" was failed.", ex);
            }
        }
示例#2
0
        private string GetImplemention(EngineProperty property)
        {
            var result    = new StringBuilder();
            var arrayType = property?.Ref?.Split('/')?.LastOrDefault() ?? null;

            return($" : List<{QlikApiUtils.GetDotNetType(arrayType)}>");
        }
示例#3
0
        private void _btnOk_Click(object sender, EventArgs e)
        {
            _engineProperty = (EngineProperty)_cbEngineSelection.SelectedItem;
            _tcMain.TabPages.Remove(_tpSelectEngine);
            _tcMain.TabPages.Add(_tpStartEngine);

            DialogResult = DialogResult.None;

            _btnOk.Enabled = false;
            _btnOk.Visible = false;

            BeginInvoke(new StartEngineDelegate(StartEngine));
        }
示例#4
0
        protected override void OnLoad(EventArgs e)
        {
            if (!DesignMode)
            {
                // Check what OCR engines are installed using the registry
                var engineProperties = new List <EngineProperty>();
                engineProperties.Add(new EngineProperty
                {
                    Name            = "LEADTOOLS - LEAD OCR Engine",
                    EngineType      = OcrEngineType.LEAD,
                    RuntimePath     = @"LEADTOOLS\OcrLEADRuntime",
                    RegistryKeyName = "OCRPathLEAD20"
                });
#if !LT_CLICKONCE && !FOR_NUGET
                if (IntPtr.Size == 8)
                {
                    engineProperties.Add(new EngineProperty
                    {
                        Name            = "LEADTOOLS - OmniPage OCR Engine",
                        EngineType      = OcrEngineType.OmniPage,
                        RuntimePath     = @"LEADTOOLS\OCROmniPageRuntime64",
                        RegistryKeyName = "OCRPathOmniPage20_64"
                    });
                    engineProperties.Add(new EngineProperty
                    {
                        Name            = "LEADTOOLS - OmniPage Arabic OCR Engine",
                        EngineType      = OcrEngineType.OmniPageArabic,
                        RuntimePath     = @"LEADTOOLS\OCROmniPageArabicRuntime64",
                        RegistryKeyName = "OCRPathOmniPageArabic20_64"
                    });
                }
                else
                {
                    engineProperties.Add(new EngineProperty
                    {
                        Name            = "LEADTOOLS - OmniPage OCR Engine",
                        EngineType      = OcrEngineType.OmniPage,
                        RuntimePath     = @"LEADTOOLS\OCROmniPageRuntime",
                        RegistryKeyName = "OCRPathOmniPage20"
                    });
                    engineProperties.Add(new EngineProperty
                    {
                        Name            = "LEADTOOLS - OmniPage Arabic OCR Engine",
                        EngineType      = OcrEngineType.OmniPageArabic,
                        RuntimePath     = @"LEADTOOLS\OCROmniPageArabicRuntime",
                        RegistryKeyName = "OCRPathOmniPageArabic20"
                    });
                }
#endif // #if !LT_CLICKONCE && !FOR_NUGET

                if (_allowNoOcr && !string.IsNullOrEmpty(_allowNoOcrMessage))
                {
                    _lblAllowNoOcr.Text = _allowNoOcrMessage;
                }

                _engineFoundCount = 0;

                for (int i = 0; i < engineProperties.Count; i++)
                {
                    EngineProperty engineProperty = engineProperties[i];

                    engineProperty.Installed = IsOcrEngineInstalled(engineProperty.RuntimePath, engineProperty.RegistryKeyName);

                    engineProperties[i] = engineProperty;

                    if (engineProperty.Installed)
                    {
                        _engineFoundCount++;
                    }
                }

                if (_allowNoOcr)
                {
                    _btnCancel.Text = DemosGlobalization.GetResxString(GetType(), "Resx_Cancel");
                }

                // 1. If we do not have any OCR engines installed, the demo will not start (if AllowNoOcr is false), so show the messages
                // where the user can download the OCR engines and hide the OK button

                // 2. If we have one engine, start it up

                // 3. If we have more than one engine, show the selection combo box

                if (_engineFoundCount == 0)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine(DemosGlobalization.GetResxString(GetType(), "Resx_OCREngineNotFound"));
                    sb.AppendLine();

                    if (!_allowNoOcr)
                    {
                        sb.AppendLine(DemosGlobalization.GetResxString(GetType(), "Resx_OCRCapabilities"));
                    }

                    sb.AppendLine();
                    sb.AppendLine(DemosGlobalization.GetResxString(GetType(), "Resx_OCREngineVersion"));

                    _lblNoEnginesFound.Text = sb.ToString();

                    _tcMain.TabPages.Remove(_tpSelectEngine);
                    _tcMain.TabPages.Remove(_tpStartEngine);

                    _btnOk.Enabled = false;
                    _btnOk.Visible = false;
                }
                else if (_engineFoundCount == 1 && !_allowNoOcr)
                {
                    _tcMain.TabPages.Remove(_tpNoEnginesFound);
                    _tcMain.TabPages.Remove(_tpSelectEngine);

                    foreach (EngineProperty engineProperty in engineProperties)
                    {
                        if (engineProperty.Installed)
                        {
                            _engineProperty = engineProperty;
                        }
                    }

                    _btnOk.Enabled = false;
                    _btnOk.Visible = false;

                    BeginInvoke(new StartEngineDelegate(StartEngine));
                }
                else
                {
                    _tcMain.TabPages.Remove(_tpNoEnginesFound);
                    _tcMain.TabPages.Remove(_tpStartEngine);

                    foreach (EngineProperty engineProperty in engineProperties)
                    {
                        if (engineProperty.Installed)
                        {
                            _cbEngineSelection.Items.Add(engineProperty);

                            if (string.Compare(_selectEngineType, engineProperty.EngineType.ToString(), StringComparison.InvariantCultureIgnoreCase) == 0)
                            {
                                _cbEngineSelection.SelectedItem = engineProperty;
                            }
                        }
                    }

                    if (_cbEngineSelection.SelectedIndex == -1)
                    {
                        _cbEngineSelection.SelectedIndex = 0;
                    }
                }
            }

            base.OnLoad(e);
        }
 protected CombustionEngine(int engineId, MetaInfo metaInfo, EngineProperty engineProperty)
     : base(engineId, metaInfo, engineProperty)
 {
 }
 protected Engine(int engineId, MetaInfo metaInfo, EngineProperty engineProperty)
 {
     EngineId       = engineId;
     MetaInfo       = metaInfo;
     EngineProperty = engineProperty;
 }
示例#7
0
        private List <EngineProperty> ReadProperties(JObject jObject, string tokenName, string className)
        {
            var results = new List <EngineProperty>();

            try
            {
                var properties = GetValueFromProperty <JToken>(jObject, tokenName);
                if (properties == null)
                {
                    return(results);
                }
                foreach (var property in properties)
                {
                    var jprop = property as JProperty;
                    logger.Debug($"Property name: {jprop.Name}");
                    var     engineProperty = new EngineProperty();
                    dynamic propObject     = null;
                    if (property.First.Type == JTokenType.Object)
                    {
                        propObject              = property.First as JObject;
                        engineProperty          = propObject.ToObject <EngineProperty>();
                        engineProperty.EnumShot = (propObject as JObject)["enumShort"] as JToken ?? null;
                    }
                    engineProperty.Name = jprop.Name;
                    if (engineProperty.Description != null && engineProperty.Description.Contains("The default value is"))
                    {
                        if (!String.IsNullOrEmpty(engineProperty.Default))
                        {
                            engineProperty.DefaultValueFromDescription = engineProperty.Default;
                        }
                        else
                        {
                            logger.Warn($"The default value was not found for the property: \"{engineProperty.Name}\" class: \"{className}\"");
                        }
                    }

                    var refValue = GetValueFromProperty <string>(propObject, "$ref");
                    if (!String.IsNullOrEmpty(refValue))
                    {
                        engineProperty.Ref = refValue;
                    }

                    if (jprop.Name == "$ref")
                    {
                        var refLink = jprop?.Value?.ToObject <string>() ?? null;
                        logger.Debug($"Items Ref: {refLink}");
                        engineProperty.Ref = refLink;
                    }

                    if (engineProperty.Type == "array")
                    {
                        refValue = GetValueFromProperty <string>(propObject.items, "$ref");
                        if (String.IsNullOrEmpty(refValue))
                        {
                            refValue = propObject.items.type.ToObject <string>();
                        }
                        engineProperty.Ref = refValue;
                    }

                    if (engineProperty.Enum != null)
                    {
                        engineProperty.Type       = GenerateEnumType(engineProperty.Name);
                        engineProperty.IsEnumType = true;
                        var engineEnum = new EngineEnum()
                        {
                            Name = engineProperty.Name,
                        };
                        foreach (var enumValue in engineProperty.Enum)
                        {
                            var shotName = engineEnum.GetShotEnumName(enumValue, engineProperty.EnumShot);
                            engineEnum.Values.Add(new EngineEnumValue()
                            {
                                Name = enumValue, ShotValue = shotName
                            });
                        }
                        var enumResult = EnumExists(engineEnum);
                        if (enumResult == null)
                        {
                            EngineObjects.Add(engineEnum);
                            engineEnum.Name = engineProperty.Type;
                        }
                        else
                        {
                            engineProperty.Type = enumResult.Name;
                        }
                    }

                    results.Add(engineProperty);
                }
                return(results);
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"The method {nameof(ReadProperties)} failed.");
                return(results);
            }
        }
示例#8
0
 public GasolineEngine(int engineId, MetaInfo metaInfo, EngineProperty engineProperty)
     : base(engineId, metaInfo, engineProperty)
 {
 }