private void AddStrongToolTip(StrongCode code)
        {
            if (code.IsNotNull())
            {
                var strongToolTip = new DevExpress.Utils.SuperToolTip()
                {
                    AllowHtmlText = DevExpress.Utils.DefaultBoolean.True
                };
                strongToolTip.Items.Add(new DevExpress.Utils.ToolTipTitleItem()
                {
                    AllowHtmlText = DevExpress.Utils.DefaultBoolean.True,
                    Text          = code.ShortDefinition
                });
                strongToolTip.Items.Add(new DevExpress.Utils.ToolTipSeparatorItem());
                strongToolTip.Items.Add(new DevExpress.Utils.ToolTipItem()
                {
                    AllowHtmlText = DevExpress.Utils.DefaultBoolean.True,
                    Text          = code.Definition
                });


                lblStrong.SuperTip = strongToolTip;
            }
        }
Beispiel #2
0
        private async Task _Import(string zipFilePath, UnitOfWork uow)
        {
            if (File.Exists(zipFilePath))
            {
                var controller = new TranslatorController();
                var fileName   = ExtractAndGetFirstArchiveItemFilePath(zipFilePath);
                try {
                    using (var conn = new SqliteConnection($"DataSource=\"{fileName}\"")) {
                        SQLitePCL.Batteries.Init();
                        conn.Open();

                        var command = conn.CreateCommand();
                        var sql     = @"SELECT topic, lexeme, transliteration, pronunciation, short_definition, definition FROM dictionary WHERE CAST(substr(topic,2) as INTEGER) > 4031 AND topic like ""G%""";
                        command.CommandText = sql; //@"SELECT topic, lexeme, transliteration, pronunciation, short_definition, definition FROM dictionary";

                        using (var reader = command.ExecuteReader()) {
                            while (reader.Read())
                            {
                                var topic           = reader.GetString(0);
                                var lexeme          = reader.GetString(1);
                                var transliteration = reader.GetString(2);
                                var pronunciacion   = reader.GetString(3);
                                var shortDefinition = reader.GetString(4);
                                var definition      = reader.GetString(5);

                                var lang  = topic.StartsWith("H") ? Language.Hebrew : Language.Greek;
                                var _code = topic.Substring(1);
                                var code  = Convert.ToInt32(_code);

                                var short_definition_translation = await GetTranslation(controller, shortDefinition);

                                var definition_translation = await GetTranslation(controller, definition);

                                var item = new XPQuery <StrongCode>(uow).Where(x => x.Lang == lang && x.Code == code).FirstOrDefault();
                                if (item.IsNull())
                                {
                                    item = new StrongCode(uow)
                                    {
                                        Code            = code,
                                        Definition      = definition_translation,
                                        Lang            = lang,
                                        Pronunciation   = pronunciacion,
                                        ShortDefinition = short_definition_translation,
                                        SourceWord      = lexeme,
                                        Transliteration = transliteration
                                    };
                                }
                                else
                                {
                                    item.Definition      = definition_translation;
                                    item.Pronunciation   = pronunciacion;
                                    item.ShortDefinition = short_definition_translation;
                                    item.SourceWord      = lexeme;
                                    item.Transliteration = transliteration;
                                }

                                item.Save();
                            }
                        }

                        conn.Close();
                    }
                }
                finally {
                    try { File.Delete(fileName); } catch { }
                }
            }
        }