ITableStructure GetStructure(CsvReader cr) { TableStructure res = new TableStructure(); if (m_hasHeaders) { try { foreach (string col in cr.GetFieldHeaders()) { res.AddColumn(col, new DbTypeString(DefaultStringLength)); } } catch (CsvDuplicateColumnName err) { throw new InvalidInputError(Texts.Get("s_duplicate_column_name_try_change_config$column", "column", err.Column)); } } else { for (int i = 1; i <= cr.FieldCount; i++) { res.AddColumn(String.Format("#{0}", i), new DbTypeString(DefaultStringLength)); } } return(res); }
private InMemoryTable ChartDataToTable(ChartData data) { var ts = new TableStructure(); ts.AddColumn(Texts.Get("s_label"), new DbTypeString()); foreach (var item in data.ValueDefs) { ts.AddColumn(item.Label, new DbTypeFloat { Bytes = 8 }); } var res = new InMemoryTable(ts); foreach (var item in data.Items) { var rec = new ArrayDataRecord(ts); rec.SeekValue(0); rec.SetString(item.Label); for (int i = 0; i < data.ValueDefs.Length; i++) { rec.SeekValue(i + 1); rec.SetDouble(item.Values[i]); } res.Rows.Add(rec); } return(res); }
private void wpprovider_CloseFromNext(object sender, Gui.Wizard.PageEventArgs e) { try { if (cbxProvider.SelectedIndex >= 0) { m_factoryName = cbxProvider.SelectedItem.ToString(); m_driverName = null; } if (cbxDriver.SelectedIndex >= 0) { m_driverName = ((DbDriverDefinition)cbxDriver.SelectedItem).InvariantName; m_factoryName = null; } if (m_factoryName != null) { m_factory = DbProviderFactories.GetFactory(m_factoryName); } if (m_driverName != null) { m_factory = DbDriverManager.Instance.CreateFactory(m_driverName); } } catch (Exception err) { StdDialog.ShowError(String.Format( "{0}:\n{1}", Texts.Get("s_cannot_create_provider"), err.Message)); e.Page = wpprovider; return; } }
public MapTransitionText(Action OnContinue, Action OnMenu, Action OnQuitDesktop, Dictionary <string, SoundEffect> sounds) { this.sounds = sounds; this.OnContinue = OnContinue; this.OnMenu = OnMenu; GetStandardSprite(true); SetAnchor(AnchorX.Middle, AnchorY.Middle); childAllignX = AnchorX.Middle; overwriteChildLayout = false; SetFixedSize(500, 500); Padding = new Microsoft.Xna.Framework.Point(10, 10); Margin = 10; textField = new Text(Texts.Get("level0Intro")); textField.wrapText = true; textField.SetFixedSize(400, 300); buttonMenu = new Button("backMenu"); buttonMenu.SetFixedWidth(200); buttonMenu.OnMouseClick = OnMenu + StopSound; Button buttonDesktop = new Button("quit"); buttonDesktop.SetFixedWidth(200); buttonDesktop.OnMouseClick = OnQuitDesktop + StopSound; buttonContinue = new Button("continue"); buttonContinue.SetFixedWidth(200); buttonContinue.OnMouseClick = OnContinue + StopSound; AddChild(textField, buttonContinue, buttonMenu, buttonDesktop); }
private void codeEditorQuery_Leave(object sender, EventArgs e) { try { SaveSource(false); } catch (Exception err) { CurCache.TargetChanged = false; CurCache.SourceModel = null; StdDialog.ShowError(Errors.ExtractImportantException(err).Message); } if (CurCache.SourceModel != null) { var cols = new HashSetEx <string>(); foreach (var col in CurCache.SourceModel.Columns) { if (cols.Contains(col.ColumnName)) { CurCache.TargetChanged = false; CurCache.SourceModel = null; StdDialog.ShowError(Texts.Get("s_datasynerr_duplicate$column", "column", col.ColumnName)); break; } cols.Add(col.ColumnName); } } }
public void CheckConfiguration() { if (String.IsNullOrEmpty(OutputDirectory) || !Directory.Exists(OutputDirectory)) { throw new CheckConfigError("DAE-00376 " + Texts.Get("s_output_directory_does_not_exist")); } }
private static string FormatCount(string s, int count) { if (count > 0) { return(String.Format("{0} ({1})", Texts.Get(s), count)); } return(Texts.Get(s)); }
private void btnClearHistory_Click(object sender, EventArgs e) { if (MessageBox.Show(Texts.Get("s_really_clear_whole_query_history"), VersionInfo.ProgramTitle, MessageBoxButtons.YesNo) == DialogResult.Yes) { m_conn.ExecuteNonQuery("delete from QueryExecute"); m_conn.ExecuteNonQuery("delete from QueryText"); ReloadData(); } }
public override void GetToolbarItems(string toolbarName, List <ToolStripItem> items) { if (toolbarName == "main" && LicenseTool.FeatureAllowed(VersionedDbFeature.Test)) { var btn = new ToolStripButton(Texts.Get("s_version_db"), CoreIcons.versiondb); btn.Click += new EventHandler(btn_Click); items.Add(btn); } }
public override void GetToolbarItems(string toolbarName, List <ToolStripItem> items) { if (toolbarName == "main" && LicenseTool.FeatureAllowed(DataSynchronizationFeature.Test)) { var btn = new ToolStripButton(Texts.Get("s_data_synchronization"), DataSynIcons.sync); btn.Click += new EventHandler(btn_Click); items.Add(btn); } }
protected override void RunBulkCopy(IDataQueue queue) { int okRowCount = 0, failRowCount = 0; List <string> insertErrors = new List <string>(); ITableStructure dst = queue.GetRowFormat; var conn = (NpgsqlConnection)Connection.SystemConnection; NpgsqlCommand command = new NpgsqlCommand(Connection.Dialect.GenerateScript(d => d.Put("^copy %f (%,i) ^from ^stdin", DestinationTable.FullName, from c in dst.Columns select c.ColumnName)), conn); NpgsqlCopyIn cin = new NpgsqlCopyIn(command, conn); try { cin.Start(); var fw = new BinaryWriter(cin.CopyStream); while (!queue.IsEof) { IBedRecord rec = queue.GetRecord(); for (int i = 0; i < rec.FieldCount; i++) { if (i > 0) { fw.Write((byte)'\t'); } rec.ReadValue(i); WriteField(rec, fw); } fw.Write((byte)'\r'); fw.Write((byte)'\n'); okRowCount++; } fw.Flush(); cin.End(); } catch (Exception err) { cin.Cancel("canceled"); ProgressInfo.LogMessageDetail( "INSERT", DatAdmin.LogLevel.Error, String.Format("{0}", Texts.Get("s_error_inserting_into_table$table", "table", DestinationTable.FullName)), err.ToString()); throw; } if (failRowCount > 0) { ProgressInfo.LogMessageDetail( "INSERT", DatAdmin.LogLevel.Error, String.Format("{0}, OK:{1}, FAIL:{2}", Texts.Get("s_error_inserting_into_table$table", "table", DestinationTable.FullName), okRowCount, failRowCount), insertErrors.CreateDelimitedText("\r\n") ); } else { ProgressInfo.LogMessage("INSERT", DatAdmin.LogLevel.Info, Texts.Get("s_inserted_into_table$table$rows", "table", DestinationTable.FullName, "rows", okRowCount)); } }
public override void GetToolbarItems(string toolbarName, List <ToolStripItem> items) { if (toolbarName == "query" && LicenseTool.FeatureAllowed(QueryHistoryFeature.Test)) { var btn = new ToolStripButton(Texts.Get("s_query_history"), CoreIcons.history); btn.Click += new EventHandler(btn_Click); btn.DisplayStyle = ToolStripItemDisplayStyle.Image; items.Add(btn); } }
public static PostgreSqlStoredConnection CheckPostgreSource(IDatabaseSource source) { PostgreSqlStoredConnection sconn = source.Connection.StoredConnection as PostgreSqlStoredConnection; if (sconn == null) { throw new InvalidInputError("DAE-00349 " + Texts.Get("s_connection_required$engine", "engine", "PostgreSQL")); } return(sconn); }
public override bool DoDelete() { if (MessageBox.Show(Texts.Get("s_really_delete$version", "version", m_version.Name), VersionInfo.ProgramTitle, MessageBoxButtons.YesNo) == DialogResult.Yes) { m_version.DeleteVersion(); Parent.CompleteRefresh(); return(true); } return(false); }
private int CompareCols(string a, string b) { int res = m_colWeights.Get(a, 0) - m_colWeights.Get(b, 0); if (res != 0) { return(res); } return(String.Compare(Texts.Get(a), Texts.Get(b), true)); }
public override bool DoDelete() { if (MessageBox.Show(Texts.Get("s_really_drop$node", "node", Title), VersionInfo.ProgramTitle, MessageBoxButtons.YesNo) == DialogResult.Yes) { var parent = m_parent as AppTreeTplNode; parent.m_children.Remove(this); Parent.CompleteRefresh(); return(true); } return(false); }
private void btnRemoveAll_Click(object sender, EventArgs e) { if (MessageBox.Show(Texts.Get("s_really_remove_all_tables"), VersionInfo.ProgramTitle, MessageBoxButtons.YesNo) == DialogResult.Yes) { foreach (NameWithSchema table in lbxUsed.Items) { m_frame.RemoveTable(table); } RefreshTables(); } }
public void CompareVersions() { var ed = new SynchronizeExtData(); var dbs = new List <string>(); dbs.Add(Texts.Get("s_none")); dbs.AddRange(from v in m_vdb.Versions select v.Name); ed.Dbs = dbs.ToArray(); ed.GetDb = FindDb; SynchronizeStructureForm.Run(null, null, ed); }
private void UpdateState() { labModified.Text = objectGridView1.Modified ? Texts.Get("s_modified") : ""; if (IsLoadingIcon) { labRowCount.Text = Texts.Get("s_loading"); } else { labRowCount.Text = Texts.Get("s_loaded$objects", "objects", objectGridView1.DataSource.Count); } }
public DependencyBrowserFrame(IDatabaseSource conn) { InitializeComponent(); m_conn = conn; m_conn.Connection.Owner = this; cbxDepTypes.Items.Add(Texts.Get("s_detected_dependencies")); cbxDepTypes.Items.Add(Texts.Get("s_native_dependencies")); cbxDepTypes.SelectedIndex = 0; Async.SafeOpen(m_conn.Connection); UpdateHistoryEnabling(); ReloadStructure(); }
private void btnRemovePage_Click(object sender, EventArgs e) { if (SelectedNode != null) { AppPage page = SelectedNode.Pages[tabControl1.SelectedIndex]; if (MessageBox.Show(Texts.Get("s_really_remove$page", "page", page.Title), VersionInfo.ProgramTitle, MessageBoxButtons.YesNo) == DialogResult.Yes) { SelectedNode.Pages.RemoveAt(tabControl1.SelectedIndex); ReloadPages(); } } }
public virtual void ReloadTexts() { using (DisposableTimer.TraceDuration <TextManager>("Start ReloadTexts", "End ReloadTexts")) { var oldCache = _textCache; var newTexts = Texts.Get(); TextHash = HashToString(ComputeHash(newTexts)); var newCache = newTexts .Where(text => text.Quality != TextQuality.PlaceHolder) .Fold((text) => text, (text) => new LocalizedTextCacheEntry { Text = text }); if (oldCache != null) { //Not too pretty... Find text entries in the old cache that equals those in the new and reuse them foreach (var ns in oldCache) { Dictionary <string, Dictionary <string, LocalizedTextCacheEntry> > newNs; if (newCache.TryGetValue(ns.Key, out newNs)) { foreach (var key in ns.Value) { Dictionary <string, LocalizedTextCacheEntry> newKey; if (newNs.TryGetValue(key.Key, out newKey)) { foreach (var lang in key.Value) { LocalizedTextCacheEntry newEntry; if (newKey.TryGetValue(lang.Key, out newEntry)) { var oldEntry = lang.Value; if (oldEntry.Text.Equals(newEntry.Text)) { //Reuse newKey[lang.Key] = lang.Value; } } } } } } } } _textCache = newCache; } }
public string ToString(string format, IFormatProvider formatProvider) { switch (format) { case "L": case "M": return(m_file ?? Texts.Get("s_structure")); case "S": default: return(System.IO.Path.GetFileName(m_file)); } }
public MimeMessage CreateNativeMessage(InternetMailTextProcessing processText = InternetMailTextProcessing.Process) { if (processText == InternetMailTextProcessing.Process) { ProcessTexts(); } var messageToSend = new MimeMessage(); if (Sender.DataType == DataType.String) { messageToSend.From.Add(new MailboxAddress("", Sender.AsString())); } else if (Sender is InternetMailAddress) { messageToSend.From.Add((Sender as InternetMailAddress).GetInternalObject()); } else { throw new RuntimeException("Неверный тип отправителя!"); } foreach (var recipient in To) { messageToSend.To.Add(recipient.GetInternalObject()); } foreach (var replyTo in ReplyTo) { messageToSend.ReplyTo.Add(replyTo.GetInternalObject()); } messageToSend.Subject = Theme; if (Texts.Count() == 1) { messageToSend.Body = Texts.Get(0).CreateTextPart(); } else { var body = new Multipart(); foreach (var text in Texts) { var part = text.CreateTextPart(); body.Add(part); } messageToSend.Body = body; } return(messageToSend); }
internal string GetToolPath(string tool) { if (PostgrePath == null) { throw new BadSettingsError("DAE-00347 " + Texts.Get("s_postgre_path_not_configured"), "Postgre SQL/s_client_settings"); } string path = Path.Combine(PostgrePath, tool + Core.ExeSuffix); if (!File.Exists(path)) { throw new BadSettingsError("DAE-00348 " + Texts.Get("s_postgre_tool_missing$path", "path", path), "Postgre SQL/s_client_settings"); } return(path); }
public IAsyncResult BeginGetRowFormat(AsyncCallback callback) { var ts = new TableStructure(); ts._Columns.Add(new ColumnStructure { ColumnName = Texts.Get("s_filename"), DataType = new DbTypeString { Length = 250 } }); ts._Columns.Add(new ColumnStructure { ColumnName = Texts.Get("s_data"), DataType = new DbTypeBlob() }); return(new ValueAsyncResult(ts, null)); }
public void SetAskedValue() { string def = ""; if (objectGridView1.CurrentCell != null) { def = (objectGridView1.CurrentCell.Value ?? "").ToString(); } string value = InputBox.Run(Texts.Get("s_type_cell_value"), def); if (value != null) { objectGridView1.FillCellSelection(value); } }
private void DoLoadFootprint(IDatabaseSource conn, SynSourceInfo info, string cacheFile) { // HACK: external sorting must be implemented using (var fw = new FileStream(cacheFile, FileMode.Create)) { var fts = new List <SynFootprint>(); using (var bw = new BinaryWriter(fw)) { var sada = conn.Dialect.CreateDataSynAdapter(); if (sada == null) { throw new ExpectedError("DAE-00365 " + Texts.Get("s_dialect_doesnt_support_sync$dialect", "dialect", conn.Dialect.DisplayName)); } var qbuf = new StringWriter(); var dmp = conn.Dialect.CreateDumper(qbuf); var qtype = m_options.Update == true ? SynQueryType.SelectKeyMd5 : SynQueryType.SelectKeyNull; info.Query.GenerateSql(dmp, sada, info, qtype, d2 => { if (!info.SqlCondition.IsEmpty()) { d2.Put(" ^where "); d2.WriteRaw(info.SqlCondition); } }); using (var cmd = conn.Connection.SystemConnection.CreateCommand()) { cmd.CommandText = qbuf.ToString(); using (IBedReader reader = conn.GetAnyDDA().AdaptReader(cmd.ExecuteReader())) { while (reader.Read()) { var ft = SynFootprint.FromReader(reader, info.KeyCols.Length, m_holder, m_conv, sada); fts.Add(ft); } } } fts.Sort(); foreach (var ft in fts) { bw.Write((byte)0); ft.SaveToStream(bw); } bw.Write((byte)1); } } }
protected override void RunBulkCopy(IDataQueue queue) { ITableStructure ts = queue.GetRowFormat; if (ts.Columns.Count == 1) { // SqlBulkCopy has problems when running on tables with one column RunInserts(queue); return; } using (SqlBulkCopy bcp = new SqlBulkCopy((SqlConnection)Connection.SystemConnection, SqlBulkCopyOptions.KeepIdentity | SqlBulkCopyOptions.KeepNulls, null)) { bcp.DestinationTableName = Connection.Dialect.QuoteFullName(DestinationTable.FullName); ITableStructure dst_ts = DestinationTable; if (ts.Columns.Count < dst_ts.Columns.Count) { int srcindex = 0; foreach (var src in ts.Columns) { SqlBulkCopyColumnMapping map = new SqlBulkCopyColumnMapping(srcindex, dst_ts.Columns.IndexOfIf(col => col.ColumnName == src.ColumnName)); bcp.ColumnMappings.Add(map); srcindex++; } } DataQueueReaderAdapter reader = new DataQueueReaderAdapter(queue); try { bcp.BulkCopyTimeout = 0; bcp.WriteToServer(reader); ProgressInfo.LogMessage("INSERT", LogLevel.Info, Texts.Get("s_inserted_into_table$table$rows", "table", DestinationTable.FullName, "rows", reader.ReadedRows)); } catch (Exception err) { ILogger logger = ProgressInfo; if (err is QueueClosedError) { logger = Logging.Root; } logger.LogMessageDetail( "INSERT", LogLevel.Error, String.Format("{0}", Texts.Get("s_error_inserting_into_table$table", "table", DestinationTable.FullName)), err.ToString()); throw; } finally { reader.Close(); } } }
public void CheckConfigured() { if (OciLibraryAvailable()) { // OK, oci.dll is in system path return; } if (OraclePath.IsEmpty()) { throw new BadSettingsError("DAE-00343 " + Texts.Get("s_oracle_path_not_configured"), "Oracle/s_client_settings"); } if (!File.Exists(Path.Combine(OraclePath, "oci.dll"))) { throw new BadSettingsError("DAE-00344 " + Texts.Get("s_oracle_client_oci_dll_not_found"), "Oracle/s_client_settings"); } }