private void FixQueryResult(Hubble.SQLClient.QueryResult result) { List <Hubble.Framework.Data.DataColumn> invaildColList = new List <Hubble.Framework.Data.DataColumn>(); if (result.DataSet != null) { if (result.DataSet.Tables != null) { foreach (Hubble.Framework.Data.DataColumn col in result.DataSet.Tables[0].Columns) { try { Hubble.SQLClient.QueryResultSerialization.GetDataType(col.DataType); } catch { invaildColList.Add(col); } } //result.DataSet.Tables[0].Constraints.Clear(); foreach (Hubble.Framework.Data.DataColumn col in invaildColList) { Global.Report.WriteErrorLog(string.Format("Invalid data type = {0} in column:{1}", col.DataType.ToString(), col.ColumnName)); result.DataSet.Tables[0].Columns.Remove(col); } } } }
private void ParseSQLToDict(string sql) { if (_NotInDict == null) { _NotInDict = new Dictionary <int, int>(); } SFQLParse sfqlParse = new SFQLParse(); Hubble.SQLClient.QueryResult qResult = sfqlParse.Query(sql); if (qResult.DataSet != null) { if (qResult.DataSet.Tables != null) { if (qResult.DataSet.Tables.Count > 0) { foreach (Hubble.Framework.Data.DataRow row in qResult.DataSet.Tables[0].Rows) { int docid = int.Parse(row["docid"].ToString()); if (!_NotInDict.ContainsKey(docid)) { _NotInDict.Add(docid, 0); } } } } } }
private MemoryStream Serialize(Hubble.SQLClient.QueryResult result, bool compress) { MemoryStream m = new MemoryStream(); //Hubble.SQLClient.QueryResultSerialization.Serialize(m, result, compress); m.Position = 0; return(m); }
public void Do(FormCreateTable frmCreateTable) { if (frmCreateTable.radioButtonCreateTableFromExistTable.Checked) { Hubble.SQLClient.QueryResult qResult = GlobalSetting.DataAccess.Excute( "exec SP_GetTableSchema {0}, {1}, {2}", frmCreateTable.comboBoxDBAdapter.Text, frmCreateTable.textBoxConnectionString.Text, frmCreateTable.textBoxDBTableName.Text); frmCreateTable.ClearAllTableFields(); bool hasDocIdField = false; foreach (DataColumn col in qResult.DataSet.Tables[0].Columns) { if (col.ColumnName.Equals("DocId", StringComparison.CurrentCultureIgnoreCase)) { hasDocIdField = true; if (!frmCreateTable.radioButtonAll.Checked) { continue; } } frmCreateTable.AddTableField(col); } if (frmCreateTable.radioButtonAppendOnly.Checked) { if (!hasDocIdField) { frmCreateTable.ClearAllTableFields(); throw new Exception("Append only mode must have a int data type field named docid!"); } } else { if (hasDocIdField) { frmCreateTable.ClearAllTableFields(); throw new Exception("This mode can't have field named docid!"); } } frmCreateTable.ShowTableField(); } }
private void button1_Click(object sender, EventArgs e) { try { QueryPerfCounter qp = new QueryPerfCounter(); SFQLParse sfqlParse = new SFQLParse(); string sql = textBoxSql.Text; if (!string.IsNullOrEmpty(textBoxSql.SelectedText)) { sql = textBoxSql.SelectedText; } Hubble.SQLClient.QueryResult result = DataAccess.Excute(sql); qp.Start(); for (int i = 0; i < numericUpDownIteration.Value; i++) { //MemoryStream s = Serialize(result, true); //Hubble.SQLClient.QueryResult r = // Hubble.SQLClient.QueryResultSerialization.Deserialize(s, true); //if (result.DataSet.Tables.Count == r.DataSet.Tables.Count) //{ // MessageBox.Show("OK"); //} //len = s.Length; //MemoryStream s = Hubble.Framework.Serialization.XmlSerialization<Hubble.SQLClient.QueryResult>.Serialize(result, Encoding.UTF8); //MemoryStream s = new MemoryStream(); //IFormatter formatter = new BinaryFormatter(); //formatter.Serialize(s, result); //s.Position = 0; //len = s.Length; //MemoryStream cs = Compress(s); //cs.Position = 0; //cs = DeCompress(cs); //cs.Position = 0; //formatter = new BinaryFormatter(); //formatter.Deserialize(s); //Hubble.Framework.Serialization.XmlSerialization<Hubble.SQLClient.QueryResult>.Deserialize(cs); } qp.Stop(); double ns = qp.Duration(1); StringBuilder report = new StringBuilder(); report.AppendFormat("{0} ", (ns / (1000 * 1000 * (int)numericUpDownIteration.Value)).ToString("0.00") + " ms"); labelDuration.Text = report.ToString(); } catch (Hubble.Core.SFQL.LexicalAnalysis.LexicalException lexicalEx) { ShowErrorMessage(lexicalEx.ToString()); } catch (Hubble.Core.SFQL.SyntaxAnalysis.SyntaxException syntaxEx) { ShowErrorMessage(syntaxEx.ToString()); } catch (Exception e1) { ShowErrorMessage(e1.Message + "\r\n" + e1.StackTrace); } finally { } }