public void Save(BasicDictionary objBasicDictionary) { string sql = null; List <DbParameter> parameterList = new List <DbParameter>(); if (objBasicDictionary.PkId == 0) { sql = " insert into tbl_basic_dictionary(DictKind, DictKey, DictValue, IsSystem) " + " values(@DictKind, @DictKey, @DictValue, @IsSystem) "; parameterList.Add(new MySqlParameter("@DictKind", objBasicDictionary.DictKind)); parameterList.Add(new MySqlParameter("@DictKey", objBasicDictionary.DictKey)); parameterList.Add(new MySqlParameter("@DictValue", objBasicDictionary.DictValue)); parameterList.Add(new MySqlParameter("@IsSystem", objBasicDictionary.IsSystem)); } else { sql = " update tbl_basic_dictionary set DictValue=@DictValue where PkId=@PkId "; parameterList.Add(new MySqlParameter("@PkId", objBasicDictionary.PkId)); parameterList.Add(new MySqlParameter("@DictValue", objBasicDictionary.DictValue)); } DbHelper.ExecuteNonQuery(sql, CommandType.Text, parameterList.ToArray()); }
public void Save(BasicDictionary objBasicDictionary) { string sql = null; List <DbParameter> parameterList = new List <DbParameter>(); if (objBasicDictionary.PkId == 0) { sql = " insert into tbl_basic_dictionary(PkId, DictKind, DictKey, DictValue, IsSystem) " + " values(TBD_PKID.NEXTVAL, :DictKind, :DictKey, :DictValue, :IsSystem) "; parameterList.Add(new OracleParameter(":DictKind", objBasicDictionary.DictKind)); parameterList.Add(new OracleParameter(":DictKey", objBasicDictionary.DictKey)); parameterList.Add(new OracleParameter(":DictValue", objBasicDictionary.DictValue)); parameterList.Add(new OracleParameter(":IsSystem", objBasicDictionary.IsSystem)); } else { sql = " update tbl_basic_dictionary set DictValue=:DictValue where PkId=:PkId "; parameterList.Add(new OracleParameter(":DictValue", objBasicDictionary.DictValue)); parameterList.Add(new OracleParameter(":PkId", objBasicDictionary.PkId)); } DbHelper.ExecuteNonQuery(sql, CommandType.Text, parameterList.ToArray()); }
static void Main(string[] args) { BD2 = new BasicDictionary(); BD = new Dict(); while (true) { Console.Write("> "); string Command = Console.ReadLine(); Console.ForegroundColor = ConsoleColor.Black; Console.BackgroundColor = ConsoleColor.White; Console.Title = "Dict.CS Test Module"; string[] separator = { " " }; string[] wordsInCmd = Command.Split(separator, StringSplitOptions.None); switch (wordsInCmd[0].ToLower()) { case "isword": bool isword = BD.IsWord(wordsInCmd[1].ToLower()); if (!isword) { BD.SuggestedWords(wordsInCmd[1]); } Console.WriteLine(isword); break; case "anagramof": var op = (BD.AnagramsOf(wordsInCmd[1].ToLower())); foreach (var p in op) { Console.Write("{0} ", p); } Console.WriteLine(); break; case "help": ShowHelp(); break; case "exit": return; case "clear": Console.Clear(); break; case "partword": var PartWordArray = BD.SuggestWord(wordsInCmd[1]); foreach (var word in PartWordArray) { Console.Write("{0} ", word); } Console.WriteLine(); break; default: Console.WriteLine("Invalid Command!"); break; } } }
public void Test_dict_toDataTable() { DBConnection db = new DBConnection(); db.connect(SERVER, PORT); BasicDictionary tb = (BasicDictionary)db.run("dict(1 2 3 4,5 6 7 8)"); DataTable dt = tb.toDataTable(); Assert.AreEqual(4, dt.Rows.Count); }
public void Test_run_return_dict() { DBConnection db = new DBConnection(); db.connect(SERVER, PORT); BasicDictionary dict = (BasicDictionary)db.run("dict(1 2 3, 2.3 3.4 5.5)"); BasicDouble v = (BasicDouble)dict.get(new BasicInt(2)); Assert.AreEqual(3.4, v.getValue()); }
public bool CheckExists(BasicDictionary objBasicDictionary) { string sql = null; List <DbParameter> parameterList = new List <DbParameter>(); sql = " select count(*) from tbl_basic_dictionary where DictKind=@DictKind and DictKey=@DictKey "; parameterList.Add(new MySqlParameter("@DictKind", objBasicDictionary.DictKind)); parameterList.Add(new MySqlParameter("@DictKey", objBasicDictionary.DictKey)); return(int.Parse(DbHelper.ExecuteScalar(sql, CommandType.Text, parameterList.ToArray()).ToString()) > 0); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public PartitionedTableAppender(String tableName, String host, int port, int threadCount) throws java.io.IOException public PartitionedTableAppender(string tableName, string host, int port, int threadCount) { this.tableName = new BasicString(tableName); DBConnection conn = new DBConnection(); BasicAnyVector locations; AbstractVector partitionSchema; BasicTable colDefs; BasicIntVector typeInts; try { conn.connect(host, port); tableInfo = (BasicDictionary)conn.run("schema(" + tableName + ")"); partitionColumnIdx = ((BasicInt)tableInfo.get(new BasicString("partitionColumnIndex"))).Int; if (partitionColumnIdx == -1) { throw new Exception("Table '" + tableName + "' is not partitioned"); } locations = (BasicAnyVector)tableInfo.get(new BasicString("partitionSites")); int partitionType = ((BasicInt)tableInfo.get(new BasicString("partitionType"))).Int; partitionSchema = (AbstractVector)tableInfo.get(new BasicString("partitionSchema")); router = TableRouterFacotry.createRouter(Enum.GetValues(typeof(Entity_PARTITION_TYPE))[partitionType], partitionSchema, locations); colDefs = ((BasicTable)tableInfo.get(new BasicString("colDefs"))); this.cols = colDefs.getColumn(0).rows(); typeInts = (BasicIntVector)colDefs.getColumn("typeInt"); this.columnCategories = new Entity_DATA_CATEGORY[this.cols]; this.columnTypes = new Entity_DATA_TYPE[this.cols]; for (int i = 0; i < cols; ++i) { this.columnTypes[i] = Enum.GetValues(typeof(Entity_DATA_TYPE))[typeInts.getInt(i)]; this.columnCategories[i] = Entity.typeToCategory(this.columnTypes[i]); } } catch (IOException e) { throw e; } finally { conn.close(); } this.threadCount = threadCount; if (this.threadCount <= 0) { this.threadCount = Math.Min(CORES, locations.rows()); } if (this.threadCount > 0) { this.threadCount--; } threadPool = Executors.newFixedThreadPool(this.threadCount); }
/// <summary> /// 加载下拉列表 /// </summary> <param name="lue">下拉控件</param> /// <param name="parentId">根节点ID</param> private void InitLookUpEdit(LookUpEdit lue, int parentId) { try { if (parentId <= 0) { return; } using (var db = SugarDao.GetInstance()) { var list_lue = db.Queryable <BasicDictionary>().Where(t => t.ParentId == parentId).ToList(); //品牌 if (list_lue.Count > 0) { BasicDictionary p = new BasicDictionary(); var l = list_lue.Select(m => new { m.Id, m.Name, m.Character }).ToList(); lue.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Id", "Id")); lue.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Name", "名称")); lue.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Character", "简写")); lue.Properties.NullText = ""; lue.Properties.ImmediatePopup = true; //当用户在输入框按任一可见字符键时立即弹出下拉窗体 lue.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard; //要使用户可以输入,这里须设为Standard lue.Properties.SearchMode = SearchMode.OnlyInPopup; //自动过滤掉不需要显示的数据,可以根据需要变化 lue.Properties.AutoSearchColumnIndex = 2; //lue.Properties.NullText = "请选择"; //lue.EditValue = "Id"; lue.Properties.ValueMember = "Id"; lue.Properties.DisplayMember = "Name"; lue.Properties.ShowHeader = true; //lue.ItemIndex = 0; //选择第一项 lue.Properties.DataSource = list_lue; //自适应宽度 lue.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; //填充列 //lue.Properties.PopulateColumns(); //lue.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Character")); lue.Properties.Columns[0].Visible = false; } else { lue.Properties.NullText = ""; } } } catch (Exception ex) { XtraMessageBox.Show("加载数据出错!" + ex.Message); } }
private void btn_save_Click(object sender, EventArgs e) { try { if (parentId <= 0) { XtraMessageBox.Show("请您先选择树形菜单!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } using (var db = SugarDao.GetInstance()) { if (string.IsNullOrWhiteSpace(txt_name.Text.Trim())) { XtraMessageBox.Show("请您输入名称!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var model = new BasicDictionary() { Id = id, ParentId = parentId, Name = txt_name.Text.Trim(), Character = txt_character.Text.Trim() }; if (Convert.ToBoolean(db.InsertOrUpdate(model))) { string msg = id > 0 ? $"【{parentName} 修改成功】 " : $"【{parentName} 新增成功】"; Log.Info(new LoggerInfo() { LogType = LogType.基础信息.ToString(), CreateUserId = UserInfo.Account, Message = msg + $" 名称:{Name},简写:{model.Character}" }); DialogResult = DialogResult.OK; this.Close(); } else { DialogResult = DialogResult.Cancel; } } } catch (Exception) { throw; } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (this.IsValid) { IBasicService service = ServiceFactory.GetService <IBasicService>(); BasicDictionary entity = null; if (this.IsInsert) { entity = new BasicDictionary() { DictKind = this.Kind.ToByte(0), DictKey = this.txtDictKey.Text.Trim().ToByte(0), DictValue = this.txtDictValue.Text.Trim(), IsSystem = 0 }; if (service.CheckExists_Dictionary(entity)) { this.JscriptMsg("字典数据键已存在", null, "Error"); return; } } else { entity = service.GetObject_Dictionary(this.PkId); if (entity != null) { entity.DictValue = this.txtDictValue.Text.Trim(); } } service.Save_Dictionary(entity); if (this.IsInsert && (sender as Button).CommandName == "SubmitContinue") { this.ReturnUrl = this.Request.Url.AbsolutePath; } this.JscriptMsg("数据保存成功", this.ReturnUrl, "Success"); } BasicConvert.ClearCache(); }
/// /// <param name="tableName"> name of the shared table </param> /// <param name="host"> host </param> /// <param name="port"> port </param> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public TableAppender(String tableName, String host, int port) throws java.io.IOException public TableAppender(string tableName, string host, int port) { this.tableName = new BasicString(tableName); this.conn = new DBConnection(); try { this.conn.connect(host, port); tableInfo = (BasicDictionary)conn.run("schema(" + tableName + ")"); int partitionColumnIdx = ((BasicInt)tableInfo.get(new BasicString("partitionColumnIndex"))).Int; if (partitionColumnIdx != -1) { throw new Exception("Table '" + tableName + "' is partitioned"); } BasicTable colDefs = ((BasicTable)tableInfo.get(new BasicString("colDefs"))); this.cols = colDefs.getColumn(0).rows(); } catch (IOException e) { throw e; } }
public autoFitTableAppender(string dbUrl, string tableName, bool asynTask, DBConnection conn) { this.dbUrl = dbUrl; this.tableName = tableName; this.asynTask = asynTask; this.conn = conn; conn.setasynTask(false); BasicDictionary tableInfo = (BasicDictionary)conn.run("schema(loadTable(\"" + dbUrl + "\", \"" + tableName + "\"))"); BasicTable colDefs; colDefs = ((BasicTable)tableInfo.get(new BasicString("colDefs"))); BasicStringVector names = (BasicStringVector)colDefs.getColumn("name"); BasicIntVector types = (BasicIntVector)colDefs.getColumn("typeInt"); int rows = names.rows(); this.schema = new Dictionary <string, DATA_TYPE>(); for (int i = 0; i < rows; ++i) { schema.Add(names.getString(i), (DATA_TYPE)types.getInt(i)); } conn.setasynTask(asynTask); }
private void BindDict() { if (!this.IsInsert) { IBasicService service = ServiceFactory.GetService <IBasicService>(); BasicDictionary entity = service.GetObject_Dictionary(this.PkId); if (entity != null) { this.txtDictKey.Text = entity.DictKey.ToString(); this.txtDictValue.Text = entity.DictValue; this.txtDictKey.ReadOnly = true; this.btnSubmitContinue.Visible = false; } else { this.JscriptMsg("数据不存在", this.ReturnUrl, "Error"); } } }
/* * return null if get DT_VOID * return table or throw exception if not DT_VOID */ public static TableResult RunScriptAndFetchResultAsDataTable(DBConnection conn, string script) { IEntity entity = RunScript(conn, script); if (entity.getDataType() == DATA_TYPE.DT_VOID) { return(null); } TableResult result = new TableResult { srcForm = entity.getDataForm(), columnSrcType = new List <DATA_TYPE>() }; if (entity.isTable()) { BasicTable basicTable = entity as BasicTable; for (int i = 0; i != basicTable.columns(); i++) { result.columnSrcType.Add(basicTable.getColumn(i).getDataType()); } result.table = basicTable.toDataTable(); return(result); } result.table = entity.toDataTable(); if (entity.isDictionary()) { BasicDictionary basicDictionary = entity as BasicDictionary; result.columnSrcType.Add(basicDictionary.KeyDataType); result.columnSrcType.Add(basicDictionary.getDataType()); return(result); } if (entity.isMatrix()) { IMatrix m = entity as IMatrix; IVector colLabels = m.getColumnLabels(); if (!(colLabels == null || colLabels.columns() == 0)) { result.matrix_ColumnLabels = new List <string>(); for (int i = 0; i != colLabels.rows(); i++) { result.matrix_ColumnLabels.Add(colLabels.get(i).getString()); } } IVector rowLabels = m.getRowLabels(); if (!(rowLabels == null || rowLabels.columns() == 0)) { result.matrix_RowLabels = new List <string>(); for (int i = 0; i != rowLabels.rows(); i++) { result.matrix_RowLabels.Add(rowLabels.get(i).getString()); } } } for (int i = 0; i != result.table.Columns.Count; i++) { result.columnSrcType.Add(entity.getDataType()); } return(result); }
public void Save_Dictionary(BasicDictionary objBasicDictionary) { var repository = ServiceFactory.GetService <IBasicDictionaryRepository>(); repository.Save(objBasicDictionary); }
public bool CheckExists_Dictionary(BasicDictionary objBasicDictionary) { var repository = ServiceFactory.GetService <IBasicDictionaryRepository>(); return(repository.CheckExists(objBasicDictionary)); }
public PartitionedTableAppender(string dbUrl, string tableName, string partitionColName, string appendFunction, IDBConnectionPool pool) { this.pool = pool; threadCount = pool.getConnectionCount(); chunkIndices = new List <List <int> >(threadCount); for (int i = 0; i < threadCount; ++i) { chunkIndices.Add(new List <int>()); } DBConnection conn = new DBConnection(); IEntity partitionSchema; BasicTable colDefs; BasicIntVector typeInts; int partitionType; DATA_TYPE partitionColType; try { IDBTask task; if (dbUrl == null || dbUrl.Length == 0) { task = new BasicDBTask("schema(" + tableName + ")"); appendScript = "tableInsert{" + tableName + "}"; } else { task = new BasicDBTask("schema(loadTable(\"" + dbUrl + "\", \"" + tableName + "\"))"); appendScript = "tableInsert{loadTable('" + dbUrl + "', '" + tableName + "')}"; } if (appendFunction != null && appendFunction.Length != 0) { appendScript = appendFunction; } pool.execute(task); if (!task.isSuccessful()) { throw new Exception(task.getErrorMsg()); } tableInfo = (BasicDictionary)task.getResults(); IEntity partColNames = tableInfo.get(new BasicString("partitionColumnName")); if (partColNames == null) { throw new Exception("Can't find specified partition column name."); } if (partColNames.isScalar()) { if (!((BasicString)partColNames).getString().Equals(partitionColName, StringComparison.OrdinalIgnoreCase)) { throw new Exception("Can't find specified partition column name."); } partitionColumnIdx = ((BasicInt)tableInfo.get(new BasicString("partitionColumnIndex"))).getValue(); partitionSchema = tableInfo.get(new BasicString("partitionSchema")); partitionType = ((BasicInt)tableInfo.get(new BasicString("partitionType"))).getValue(); // partitionColType = (DATA_TYPE)((BasicInt)tableInfo.get(new BasicString("partitionColumnType"))).getValue(); } else { BasicStringVector vec = (BasicStringVector)partColNames; int dims = vec.rows(); int index = -1; for (int i = 0; i < dims; ++i) { if (!vec.getString(i).Equals(partitionColName, StringComparison.OrdinalIgnoreCase)) { index = i; break; } } if (index < 0) { throw new Exception("Can't find specified partition column name."); } partitionColumnIdx = ((BasicIntVector)tableInfo.get(new BasicString("partitionColumnIndex"))).getInt(index); partitionSchema = ((BasicAnyVector)tableInfo.get(new BasicString("partitionSchema"))).getEntity(index); partitionType = ((BasicIntVector)tableInfo.get(new BasicString("partitionType"))).getInt(index); // partitionColType = (DATA_TYPE)((BasicIntVector)tableInfo.get(new BasicString("partitionColumnType"))).getInt(index); } colDefs = ((BasicTable)tableInfo.get(new BasicString("colDefs"))); this.cols = colDefs.getColumn(0).rows(); typeInts = (BasicIntVector)colDefs.getColumn("typeInt"); this.columnCategories = new DATA_CATEGORY[this.cols]; this.columnTypes = new DATA_TYPE[this.cols]; for (int i = 0; i < cols; ++i) { this.columnTypes[i] = (DATA_TYPE)typeInts.getInt(i); this.columnCategories[i] = Utils.typeToCategory(this.columnTypes[i]); } domain = DomainFactory.createDomain((PARTITION_TYPE)partitionType, partitionColType, partitionSchema); } catch (Exception e) { throw e; } finally { conn.close(); } }