void IVocabularyWindow.DefineLexicalData(dictionary_type lexicalType)
        {
            Word[] selected = SelectedWords().OrderBy(x => x.Id).ToArray();
            if (selected.Length > 1)
            {
                using (ISession session = DataHelper.OpenSession())
                {
                    using (ITransaction transaction = session.BeginTransaction())
                    {
                        Dictionary d = null;
                        try
                        {
                            for (int i = 0; i < selected.Length; i++)
                            {
                                for (int j = i + 1; j < selected.Length; j++)
                                {
                                    d                = new Dictionary();
                                    d.Left           = selected[i];
                                    d.Right          = selected[j];
                                    d.DictionaryType = lexicalType;
                                    session.SaveOrUpdate(d);
                                }
                            }

                            transaction.Commit();
                        }
                        catch (ADOException e)
                        {
                            transaction.Rollback();
                            Trace.TraceError(ErrorHelper.Message(e));
                            PostgresException ne = e.InnerException as PostgresException;
                            if (ne != null && ne.SqlState == "23505")
                            {
                                string format = string.Empty;
                                switch (lexicalType)
                                {
                                case dictionary_type.synonym:
                                    format = Strings.SynonymsAlreadyExist;
                                    break;

                                case dictionary_type.antonym:
                                    format = Strings.AntnymsAlreadyExist;
                                    break;

                                default:
                                    break;
                                }

                                KryptonMessageBox.Show(this, string.Format(format, d.Left, d.Right), Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                ErrorHelper.ShowDbError(this, e);
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        public static Dictionary <string, string> to_dictionary(string str, string delimiter_list, string delimiter_dictionary, type split_type = type.use_any_quotes | type.ignore_trailing_spaces, dictionary_type dict_type = dictionary_type.on_error_keep_last)
        {
            var list = to_list(str, delimiter_list, split_type);

            return(new Dictionary <string, string>());
        }
示例#3
0
 public static Dictionary<string,string> to_dictionary(string str, string delimiter_list, string delimiter_dictionary, type split_type = type.use_any_quotes | type.ignore_trailing_spaces, dictionary_type dict_type = dictionary_type.on_error_keep_last) {
     var list = to_list(str, delimiter_list, split_type);
     return new Dictionary<string, string>();
 }