public JanelaAgente(Spartacus.Database.Generic p_database, Spartacus.Forms.Window p_pai) : base("Edição de Agente", 300, 200, p_pai) { this.v_database = p_database; this.v_id = new Spartacus.Forms.Textbox(this, "Código"); this.v_id.Disable(); this.Add(this.v_id); this.v_nome = new Spartacus.Forms.Textbox(this, "Nome"); this.Add(this.v_nome); this.v_telefone = new Spartacus.Forms.Textbox(this, "Telefone"); this.Add(this.v_telefone); this.v_buttons = new Spartacus.Forms.Buttons(this); this.v_buttons.AddButton("Salvar", this.ClickSalvar); this.v_buttons.AddButton("Cancelar", this.ClickCancelar); this.Add(this.v_buttons); this.v_insert = new Spartacus.Database.Command(); this.v_insert.v_text = "insert into agentes (nome, telefone) values (#NOME#, #TELEFONE#)"; this.v_insert.AddParameter("NOME", Spartacus.Database.Type.STRING); this.v_insert.AddParameter("TELEFONE", Spartacus.Database.Type.STRING); this.v_update = new Spartacus.Database.Command(); this.v_update.v_text = "update agentes set nome = #NOME#, telefone = #TELEFONE# where id = #ID#"; this.v_update.AddParameter("NOME", Spartacus.Database.Type.STRING); this.v_update.AddParameter("TELEFONE", Spartacus.Database.Type.STRING); this.v_update.AddParameter("ID", Spartacus.Database.Type.INTEGER); }
/// <summary> /// Popula o Grid atual com os dados obtidos a partir da execução da consulta SQL no banco de dados. /// </summary> /// <param name="p_database">Objeto de conexão com o banco de dados.</param> /// <param name="p_sql">Consulta SQL.</param> public void Populate(Spartacus.Database.Generic p_database, string p_sql) { this.v_database = p_database; this.v_sql = p_sql; this.v_gridhtml = this.v_database.QueryHtml(this.v_sql, "grid_" + this.v_id, "class='display compact'"); }
public FakeSmtp( string p_ip, int p_port, string p_realhost, int p_realport, bool p_log, bool p_logeml, bool p_redirect ) : base(p_ip, p_port) { this.v_connect.ConnectEvent += new Spartacus.Net.ConnectEventClass.ConnectEventHandler(OnConnect); this.v_mailclient = new Spartacus.Net.MailClient(); this.v_database = null; this.v_select = null; this.v_insert = null; this.v_credential = null; this.v_realhost = p_realhost; this.v_realport = p_realport; this.v_log = p_log; this.v_logeml = p_logeml; this.v_redirect = p_redirect; this.v_whitelist = false; if (this.v_log) { Console.WriteLine("Spartacus FakeSMTP {0}:{1}", this.v_ip, this.v_port); Console.WriteLine(); } }
public JanelaAgentes(Spartacus.Database.Generic p_database, Spartacus.Forms.Window p_pai) : base("Cadastro de Agentes", 600, 400, p_pai) { this.v_database = p_database; this.v_grid = new Spartacus.Forms.Grid(this, 330); this.v_grid.Populate( this.v_database, "select a.id, " + " a.nome, " + " a.telefone " + "from agentes a " + "order by a.id " ); this.Add(this.v_grid); this.v_buttons = new Spartacus.Forms.Buttons(this); this.v_buttons.AddButton("Novo", this.ClickNovo); this.v_buttons.AddButton("Editar", this.ClickEditar); this.v_buttons.AddButton("Remover", this.ClickRemover); this.Add(this.v_buttons); this.v_janelaagente = new JanelaAgente(this.v_database, this); this.v_delete = new Spartacus.Database.Command(); this.v_delete.v_text = "delete from agentes where id = #ID#"; this.v_delete.AddParameter("ID", Spartacus.Database.Type.INTEGER); }
/// <summary> /// Popula o componente Lookup com os dados obtidos a partir da execução da consulta SQL no banco de dados. /// </summary> /// <param name="p_database">Objeto de conexão com o banco de dados.</param> /// <param name="p_sql">SQl a ser executado no banco de dados.</param> public void Populate(Spartacus.Database.Generic p_database, string p_sql) { System.Data.DataTable v_table; string v_columnnames, v_columnwidths; int k; this.v_database = p_database; this.v_sql = p_sql; v_table = this.v_database.Query(this.v_sql, "LOOKUP"); v_columnnames = v_table.Columns[0].ColumnName; v_columnwidths = "50"; for (k = 1; k < v_table.Columns.Count; k++) { v_columnnames += ";" + v_table.Columns[k].ColumnName; v_columnwidths += ";120"; } this.v_lookup.ColumnNames = v_columnnames; this.v_lookup.ColumnWidths = v_columnwidths; this.v_lookup.DataSource = v_table; this.v_lookup.DisplayMember = v_table.Columns[0].ColumnName; this.v_lookup.ValueMember = v_table.Columns[1].ColumnName; this.v_lookup.SelectedIndex = -1; this.v_lookup.Text = ""; }
/// <summary> /// Popula o Grid atual com os dados obtidos a partir da execução da consulta SQL no banco de dados. /// </summary> /// <param name="p_database">Objeto de conexão com o banco de dados.</param> /// <param name="p_sql">Consulta SQL.</param> public void Populate(Spartacus.Database.Generic p_database, string p_sql) { this.v_database = p_database; this.v_sql = p_sql; this.v_grid.DataSource = this.v_database.Query(this.v_sql, "GRID"); this.v_grid.AutoResizeColumns(System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells); }
public JanelaPrincipal(Spartacus.Database.Generic p_database) : base("Finanças Pessoais", 800, 600) { this.v_database = p_database; Spartacus.Forms.Menugroup v_group, v_group2; this.v_menu = new Spartacus.Forms.Menu(this); v_group = this.v_menu.AddGroup("Cadastro"); this.v_menu.AddItem(v_group, "Agentes", this.MenuAgentes); this.Add(this.v_menu); v_group = this.v_menu.AddGroup("Relatórios"); v_group2 = this.v_menu.AddGroup(v_group, "Listagem de Agentes"); this.v_menu.AddItem(v_group2, "Excel", this.MenuAgentesExcel); this.v_menu.AddItem(v_group2, "PDF", this.MenuAgentesPDF); v_group2 = this.v_menu.AddGroup(v_group, "Listagem de Movimentação"); this.v_menu.AddItem(v_group2, "Excel", this.MenuMovimentacaoExcel); this.v_menu.AddItem(v_group2, "PDF", this.MenuMovimentacaoPDF); this.v_grid = new Spartacus.Forms.Grid(this, 480); this.v_grid.Populate( this.v_database, "select m.id, " + " m.data, " + " a.nome, " + " m.descricao, " + " m.debito, " + " m.credito, " + " m.saldo " + "from movimentos m " + "inner join agentes a " + "on a.id = m.idagente " + "order by m.id desc " ); this.Add(this.v_grid); this.v_buttons = new Spartacus.Forms.Buttons(this); this.v_buttons.AddButton("Débito", this.ClickDebito); this.v_buttons.AddButton("Crédito", this.ClickCredito); this.v_buttons.AddButton("Estorno", this.ClickEstorno); this.v_buttons.AddButton("Atualizar", this.ClickAtualizar); this.Add(this.v_buttons); this.v_janelaagentes = new JanelaAgentes(this.v_database, this); this.v_janeladebito = new JanelaDebito(this.v_database, this); this.v_janelacredito = new JanelaCredito(this.v_database, this); this.v_cmd = new Spartacus.Database.Command(); this.v_cmd.v_text = "insert into movimentos (idagente, data, debito, credito, saldo, descricao) values (#IDAGENTE#, #DATA#, #DEBITO#, #CREDITO#, #SALDO#, #DESCRICAO#)"; this.v_cmd.AddParameter("IDAGENTE", Spartacus.Database.Type.INTEGER); this.v_cmd.AddParameter("DATA", Spartacus.Database.Type.INTEGER); this.v_cmd.AddParameter("DEBITO", Spartacus.Database.Type.REAL); this.v_cmd.SetLocale("DEBITO", Spartacus.Database.Locale.EUROPEAN); this.v_cmd.AddParameter("CREDITO", Spartacus.Database.Type.REAL); this.v_cmd.SetLocale("CREDITO", Spartacus.Database.Locale.EUROPEAN); this.v_cmd.AddParameter("SALDO", Spartacus.Database.Type.REAL); this.v_cmd.SetLocale("SALDO", Spartacus.Database.Locale.EUROPEAN); this.v_cmd.AddParameter("DESCRICAO", Spartacus.Database.Type.STRING); }
/// <summary> /// Inicializa uma nova instância da classe <see cref="Spartacus.Database.Configuration"/>. /// </summary> /// <param name="p_type">Tipo.</param> /// <param name="p_provider">Provider.</param> /// <param name="p_host">Servidor.</param> /// <param name="p_port">Porta.</param> /// <param name="p_service">Serviço.</param> /// <param name="p_user">Usuário.</param> /// <param name="p_password">Senha.</param> /// <param name="p_integrated_security">Segurança integrada.</param> public Configuration( string p_type, string p_provider, string p_host, string p_port, string p_service, string p_user, string p_password, string p_integrated_security ) { this.v_database = null; switch (p_type.ToLower()) { case "firebird": this.v_database = new Spartacus.Database.Firebird(p_host, p_port, p_service, p_user, p_password); break; case "firebirdembed": this.v_database = new Spartacus.Database.FirebirdEmbed(p_service, p_user, p_password); break; case "mysql": this.v_database = new Spartacus.Database.Mysql(p_host, p_port, p_service, p_user, p_password); break; case "odbc": this.v_database = new Spartacus.Database.Odbc(p_service, p_user, p_password); break; case "oledb": this.v_database = new Spartacus.Database.Oledb(p_provider, p_host, p_port, p_service, p_user, p_password); break; case "postgresql": this.v_database = new Spartacus.Database.Postgresql(p_host, p_port, p_service, p_user, p_password); break; case "sqlite": if (p_service != null) this.v_database = new Spartacus.Database.Sqlite(p_service); else this.v_database = new Spartacus.Database.Sqlite(); break; case "oracle": this.v_database = new Spartacus.Database.Oracle(p_host, p_port, p_service, p_user, p_password); break; case "memory": this.v_database = new Spartacus.Database.Memory(); break; case "sqlserver": this.v_database = new Spartacus.Database.SqlServer(p_host, p_port, p_service, p_user, p_password, bool.Parse(p_integrated_security)); break; default: this.v_database = null; break; } }
public void Initialize() { try { if (new System.IO.FileInfo(System.Configuration.ConfigurationManager.AppSettings["database"].ToString()).Exists) { this.v_database = new Spartacus.Database.Sqlite(System.Configuration.ConfigurationManager.AppSettings["database"].ToString()); } else { this.v_database = new Spartacus.Database.Sqlite(); this.v_database.CreateDatabase(System.Configuration.ConfigurationManager.AppSettings["database"].ToString()); this.v_database.Execute("create table reports (code integer primary key autoincrement, name text, xmlfile text not null);"); } this.v_mainwindow = new Spartacus.Forms.Window( System.Configuration.ConfigurationManager.AppSettings["main.title"].ToString(), 600, 400 ); this.v_maingrid = new Spartacus.Forms.Grid(this.v_mainwindow, 300); this.v_maingrid.Populate(this.v_database, "select * from reports"); this.v_mainwindow.Add(this.v_maingrid); this.v_editable = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["editable"].ToString()); this.v_mainbuttons = new Spartacus.Forms.Buttons(this.v_mainwindow); this.v_mainbuttons.AddButton(System.Configuration.ConfigurationManager.AppSettings["main.execute"].ToString(), this.OnMainExecuteClick); this.v_mainbuttons.AddButton(System.Configuration.ConfigurationManager.AppSettings["main.insert"].ToString(), this.OnMainInsertClick, this.v_editable); this.v_mainbuttons.AddButton(System.Configuration.ConfigurationManager.AppSettings["main.update"].ToString(), this.OnMainUpdateClick, this.v_editable); this.v_mainbuttons.AddButton(System.Configuration.ConfigurationManager.AppSettings["main.delete"].ToString(), this.OnMainDeleteClick, this.v_editable); this.v_mainwindow.Add(this.v_mainbuttons); this.v_mainwindow.Run(); } catch (Spartacus.Database.Exception exc) { Spartacus.Forms.Messagebox.Show(exc.v_message, "Spartacus.Database.Exception", Spartacus.Forms.Messagebox.Icon.ERROR); System.Environment.Exit(-1); } catch (Spartacus.Forms.Exception exc) { Spartacus.Forms.Messagebox.Show(exc.v_message, "Spartacus.Forms.Exception", Spartacus.Forms.Messagebox.Icon.ERROR); System.Environment.Exit(-1); } catch (System.Exception exc) { Spartacus.Forms.Messagebox.Show(exc.Message, exc.GetType().ToString(), Spartacus.Forms.Messagebox.Icon.ERROR); System.Environment.Exit(-1); } }
/// <summary> /// Inicializa uma nova instância da classe <see cref="Spartacus.Web.Grid"/>. /// </summary> /// <param name="p_id">Identificador do Container atual.</param> /// <param name="p_parent">Container pai.</param> public Grid(string p_id, Spartacus.Web.Container p_parent) : base(p_id, p_parent) { this.v_type = Spartacus.Web.ContainerType.GRID; this.v_selected = new System.Web.UI.HtmlControls.HtmlGenericControl("input"); this.v_selected.ID = p_id; this.v_selected.Attributes.Add("runat", "server"); this.v_selected.Attributes.Add("type", "text"); this.v_selected.Attributes.Add("value", ""); this.v_selected.Style.Add("display", "none"); this.v_database = null; this.v_sql = null; }
/// <summary> /// Inicializa uma nova instância da classe <see cref="Spartacus.Forms.Lookup"/>. /// </summary> /// <param name="p_parent">Container pai.</param> /// <param name="p_label">Rótulo do componente.</param> public Lookup(Spartacus.Forms.Container p_parent, string p_label) : base(p_parent) { this.v_control = new System.Windows.Forms.Panel(); this.SetWidth(p_parent.v_width); this.SetHeight(40); this.SetLocation(0, p_parent.v_offsety); this.v_label = new System.Windows.Forms.Label(); this.v_label.Text = p_label; this.v_label.Location = new System.Drawing.Point(10, 10); this.v_label.AutoSize = true; this.v_label.Parent = this.v_control; this.v_proportion1 = 40; this.v_proportion2 = 70; this.v_textbox = new System.Windows.Forms.TextBox(); this.v_textbox.Enabled = false; this.v_textbox.Location = new System.Drawing.Point((int) (this.v_width * ((double) this.v_proportion2 / (double) 100)), 5); this.v_textbox.Width = this.v_width - 10 - this.v_textbox.Location.X; this.v_textbox.Parent = this.v_control; this.v_lookup = new ThirdParty.MultiColumnComboBox(); this.v_lookup.AutoComplete = true; this.v_lookup.AutoDropdown = true; this.v_lookup.BackColorEven = System.Drawing.Color.White; this.v_lookup.BackColorOdd = System.Drawing.Color.Silver; this.v_lookup.ColumnWidthDefault = 75; this.v_lookup.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable; this.v_lookup.FormattingEnabled = true; this.v_lookup.LinkedColumnIndex = 1; this.v_lookup.LinkedTextBox = this.v_textbox; this.v_lookup.Location = new System.Drawing.Point((int) (this.v_width * ((double) this.v_proportion1 / (double) 100)), 5); this.v_lookup.Width = this.v_textbox.Location.X - this.v_lookup.Location.X - 5; this.v_lookup.Parent = this.v_control; this.v_database = null; this.v_sql = null; }
public JanelaDebito(Spartacus.Database.Generic p_database, Spartacus.Forms.Window p_pai) : base("Novo Débito", 600, 300, p_pai) { this.v_database = p_database; this.v_agente = new Spartacus.Forms.Lookup(this, "Agente", 40, 60); this.v_agente.Populate( this.v_database, "select a.id, " + " a.nome " + "from agentes a " + "order by a.id " ); this.Add(this.v_agente); this.v_valor = new Spartacus.Forms.Textbox(this, "Valor"); this.Add(this.v_valor); this.v_descricao = new Spartacus.Forms.Memobox(this, "Descrição", 150); this.Add(this.v_descricao); this.v_buttons = new Spartacus.Forms.Buttons(this); this.v_buttons.AddButton("Salvar", this.ClickSalvar); this.v_buttons.AddButton("Cancelar", this.ClickCancelar); this.Add(this.v_buttons); this.v_cmd = new Spartacus.Database.Command(); this.v_cmd.v_text = "insert into movimentos (idagente, data, debito, credito, saldo, descricao) values (#IDAGENTE#, #DATA#, #DEBITO#, #CREDITO#, #SALDO#, #DESCRICAO#)"; this.v_cmd.AddParameter("IDAGENTE", Spartacus.Database.Type.INTEGER); this.v_cmd.AddParameter("DATA", Spartacus.Database.Type.INTEGER); this.v_cmd.AddParameter("DEBITO", Spartacus.Database.Type.REAL); this.v_cmd.SetLocale("DEBITO", Spartacus.Database.Locale.EUROPEAN); this.v_cmd.AddParameter("CREDITO", Spartacus.Database.Type.REAL); this.v_cmd.SetLocale("CREDITO", Spartacus.Database.Locale.EUROPEAN); this.v_cmd.AddParameter("SALDO", Spartacus.Database.Type.REAL); this.v_cmd.SetLocale("SALDO", Spartacus.Database.Locale.EUROPEAN); this.v_cmd.AddParameter("DESCRICAO", Spartacus.Database.Type.STRING); }
/// <summary> /// Inicializa uma nova instância da classe <see cref="Spartacus.Forms.Grid"/>. /// </summary> /// <param name="p_parent">Container pai.</param> /// <param name="p_height">Altura.</param> public Grid(Spartacus.Forms.Container p_parent, int p_height) : base(p_parent) { this.v_control = new System.Windows.Forms.Panel(); this.v_isfrozen = false; this.v_width = p_parent.v_width; this.v_control.Width = p_parent.v_width - 5; this.SetHeight(p_height); this.SetLocation(0, p_parent.v_offsety); this.v_grid = new System.Windows.Forms.DataGridView(); this.v_grid.RowHeadersVisible = false; this.v_grid.EnableHeadersVisualStyles = false; this.v_grid.ColumnHeadersHeight = 20; this.v_grid.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; this.v_grid.AutoGenerateColumns = true; this.v_grid.ReadOnly = true; this.v_grid.MultiSelect = false; this.v_grid.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.v_grid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.v_grid.DoubleBuffered(true); this.v_grid.BorderStyle = System.Windows.Forms.BorderStyle.None; this.v_grid.AllowDrop = false; this.v_grid.AllowUserToAddRows = false; this.v_grid.AllowUserToDeleteRows = false; this.v_grid.AllowUserToOrderColumns = true; this.v_grid.AllowUserToResizeColumns = true; this.v_grid.Dock = System.Windows.Forms.DockStyle.Fill; this.v_grid.Parent = this.v_control; this.v_database = null; this.v_sql = null; }
/// <summary> /// Transfere dados do banco de dados atual para um banco de dados de destino. /// Conexão com o banco de destino precisa estar aberta. /// Não pára a execução se der um problema num comando de inserção específico. /// </summary> /// <returns>Número de linhas transferidas.</returns> /// <param name="p_query">Consulta SQL para buscar os dados no banco atual.</param> /// <param name="p_insert">Comando de inserção para inserir cada linha no banco de destino.</param> /// <param name="p_destdatabase">Conexão com o banco de destino.</param> /// <param name="p_progress">Evento de progresso.</param> /// <param name="p_error">Evento de erro.</param> public override uint Transfer(string p_query, Spartacus.Database.Command p_insert, Spartacus.Database.Generic p_destdatabase, Spartacus.Utils.ProgressEventClass p_progress, Spartacus.Utils.ErrorEventClass p_error) { uint v_transfered; this.BuildCache(p_query); v_transfered = this.v_database.Transfer(p_query, p_insert, p_destdatabase, p_progress, p_error); this.DestroyCache(); return(v_transfered); }
/// <summary> /// Transfere dados do banco de dados atual para um banco de dados de destino. /// Conexão com o banco de destino precisa estar aberta. /// Não pára a execução se der um problema num comando de inserção específico. /// </summary> /// <returns>Número de linhas transferidas.</returns> /// <param name="p_query">Consulta SQL para buscar os dados no banco atual.</param> /// <param name="p_insert">Comando de inserção para inserir cada linha no banco de destino.</param> /// <param name="p_destdatabase">Conexão com o banco de destino.</param> /// <param name="p_log">Log de inserção.</param> public override uint Transfer(string p_query, Spartacus.Database.Command p_insert, Spartacus.Database.Generic p_destdatabase, out string p_log) { uint v_transfered; this.BuildCache(p_query); v_transfered = this.v_database.Transfer(p_query, p_insert, p_destdatabase, out p_log); this.DestroyCache(); return(v_transfered); }
public Tile[,] Generate( Spartacus.Database.Generic p_database, int p_map_size, int p_mapcell_size, int p_tree_chance, string p_terrain_filter, string p_object_filter ) { Tile[,] v_map; bool[,] v_skel; System.Collections.Generic.List <Terrain> v_all_terrain, v_terrain; System.Collections.Generic.List <Object> v_all_object, v_object; System.Random v_random; int k, v_tmp; int v_limit; v_random = new System.Random(); v_limit = v_random.Next(1, p_map_size / 2); v_skel = new bool[p_map_size, p_map_size]; v_map = new Tile[p_map_size, p_map_size]; v_all_terrain = p_database.QueryList <Terrain>( "select distinct id, " + " name, " + " 'terrain/' || image as image, " + " canstep " + "from terrain " + "where 1=1 " + p_terrain_filter + " " + "order by 1" ); v_all_object = p_database.QueryList <Object>( "select distinct id, " + " name, " + " 'trees/' || image as image, " + " block " + "from objects " + "where 1=1 " + p_object_filter + " " + "order by 1" ); v_terrain = new System.Collections.Generic.List <Terrain>(); v_terrain.Add(new Terrain()); do { k = v_random.Next(v_all_terrain.Count); v_terrain[0].id = v_all_terrain[k].id; v_terrain[0].name = v_all_terrain[k].name; v_terrain[0].image = v_all_terrain[k].image; v_terrain[0].canstep = v_all_terrain[k].canstep; }while (v_terrain[0].canstep == 'N'); v_tmp = v_random.Next(1, System.Math.Min(5, v_all_terrain.Count)); for (int x = 1; x <= v_tmp; x++) { k = v_random.Next(v_all_terrain.Count); v_terrain.Add(new Terrain(v_all_terrain[k].id, v_all_terrain[k].name, v_all_terrain[k].image, v_all_terrain[k].canstep)); } v_object = new System.Collections.Generic.List <Object>(); v_tmp = v_random.Next(1, System.Math.Min(5, v_all_object.Count)); for (int x = 0; x <= v_tmp; x++) { k = v_random.Next(v_all_object.Count); v_object.Add(new Object(v_all_object[k].id, v_all_object[k].name, v_all_object[k].image, v_all_object[k].block)); } for (int i = 0; i < p_map_size; i++) { for (int j = 0; j < p_map_size; j++) { v_map[i, j] = new Tile(i, j, p_mapcell_size, true, v_terrain[0].image); v_skel[i, j] = false; if (i < v_limit || i > (p_map_size - v_limit) || j < v_limit || j > (p_map_size - v_limit)) { if (i == j || (i + j) == (p_map_size - 1)) { v_skel[i, j] = true; } } else { if (i == v_limit || i == (p_map_size - v_limit) || j == v_limit || j == (p_map_size - v_limit)) { v_skel[i, j] = true; } } if (!v_skel[i, j]) { k = v_random.Next(v_terrain.Count); v_map[i, j].v_images[0] = v_terrain[k].image; v_map[i, j].v_canstep = v_terrain[k].canstep == 'Y'; if (v_random.Next(100) > (100 - p_tree_chance)) { k = v_random.Next(v_object.Count); v_map[i, j].v_images.Add(v_object[k].image); v_map[i, j].v_canstep = false; v_map[i, j].v_block = true; } } } } return(v_map); }
/// <summary> /// Inicializa uma nova instância da classe <see cref="Spartacus.Reporting.Report"/>. /// </summary> /// <param name="p_reportid">Código do Relatório.</param> /// <param name="p_filename">Nome do arquivo XML.</param> /// <param name="p_table">Tabela com os dados.</param> /// <param name="p_calculate_groups">Se o gerador de relatórios deve calcular os valores agrupados ou não.</param> public Report(int p_reportid, string p_filename, System.Data.DataTable p_table, bool p_calculate_groups) { this.v_reportid = p_reportid; this.v_header = new Spartacus.Reporting.Block(); this.v_footer = new Spartacus.Reporting.Block(); this.v_fields = new System.Collections.ArrayList(); this.v_groups = new System.Collections.ArrayList(); this.v_database = null; this.v_tabletemp = p_table; this.v_table = null; this.v_rendertable = null; this.v_calculate_groups = p_calculate_groups; this.v_progress = new Spartacus.Utils.ProgressEventClass(); this.v_progress.FireEvent("Spartacus.Reporting.Report", "ExportPDF", 0.0, "Lendo XML do relatorio " + this.v_reportid.ToString()); try { this.ReadXml(p_filename); } catch (Spartacus.Reporting.Exception e) { throw e; } }
/// <summary> /// Transfere dados do banco de dados atual para um banco de dados de destino. /// Conexão com o banco de destino precisa estar aberta. /// </summary> /// <returns>Número de linhas transferidas.</returns> /// <param name="p_query">Consulta SQL para buscar os dados no banco atual.</param> /// <param name="p_table">Nome da tabela de destino.</param> /// <param name="p_columns">Lista de colunas da tabela de destino.</param> /// <param name="p_insert">Comando de inserção para inserir cada linha no banco de destino.</param> /// <param name="p_destdatabase">Conexão com o banco de destino.</param> /// <param name="p_log">Log de inserção.</param> /// <param name='p_startrow'>Número da linha inicial.</param> /// <param name='p_endrow'>Número da linha final.</param> /// <param name='p_hasmoredata'>Indica se ainda há mais dados a serem lidos.</param> public override uint Transfer(string p_query, string p_table, string p_columns, Spartacus.Database.Command p_insert, Spartacus.Database.Generic p_destdatabase, ref string p_log, uint p_startrow, uint p_endrow, out bool p_hasmoredata) { uint v_transfered; this.BuildCache(p_query); v_transfered = this.v_database.Transfer(p_query, p_table, p_columns, p_insert, p_destdatabase, ref p_log, p_startrow, p_endrow, out p_hasmoredata); this.DestroyCache(); return(v_transfered); }
public void Initialize() { this.v_window = new Spartacus.Forms.Window("Spartacus OverLord", this.v_window_width, this.v_window_height); this.v_database = new Spartacus.Database.Sqlite("overlord.db"); MapGenerator v_generator = new MapGenerator(); this.v_tileset = v_generator.Generate( this.v_database, this.v_map_size, this.v_tile_size, this.v_tree_chance, "and name like 'jungle%'", "and name not like 'autumn%'" ); this.v_player = "green"; this.v_playercolor = System.Drawing.Color.Green; this.v_soldiers = new Soldier[4]; this.v_soldiers[0] = new Soldier( this.v_database, TeamColor.GREEN, "green_1", 2, 3 ); this.v_soldiers[1] = new Soldier( this.v_database, TeamColor.GREEN, "green_2", 2, 4 ); this.v_soldiers[2] = new Soldier( this.v_database, TeamColor.RED, "red_1", 6, 1 ); this.v_soldiers[3] = new Soldier( this.v_database, TeamColor.BLUE, "blue_1", 1, 6 ); this.v_selected = -1; this.v_action = ""; this.v_turn = TeamColor.GREEN; this.v_range = new Range(this.v_tileset, this.v_map_size, this.v_mapview_width, this.v_mapview_height); this.v_soldiersview = new Spartacus.Game.Layer(); this.v_soldiersview.MouseClick += this.OnSoldierMouseClick; this.v_soldiersview.Collision += this.OnCollision; this.v_mapview = new Spartacus.Game.Layer(); this.v_mapview.MouseClick += this.OnMapMouseClick; this.v_mapview.Collision += this.OnCollision; this.BuildMapView(); this.v_guiview = new Spartacus.Game.Layer(); this.v_guiview.MouseClick += this.OnGuiMouseClick; this.v_guiview.Collision += this.OnCollision; this.BuidGuiView(); this.v_keyboard = new Spartacus.Game.Keyboard(this.v_window); this.v_keyboard.KeyDown += this.OnKeyDown; this.v_keyboard.Start(15); this.v_level = new Spartacus.Game.Level(this.v_window); this.v_level.AddLayer(this.v_mapview); this.v_level.AddLayer(this.v_soldiersview); this.v_level.AddLayer(this.v_guiview); v_level.Time += this.OnTime; this.v_level.Start(15); this.v_window.Run(); }
/* * switch(this.v_direction) * { * case Direction.SOUTH: * break; * case Direction.SOUTHWEST: * break; * case Direction.WEST: * break; * case Direction.NORTHWEST: * break; * case Direction.NORTH: * break; * case Direction.NORTHEAST: * break; * case Direction.EAST: * break; * case Direction.SOUTHEAST: * break; * } */ public Soldier( Spartacus.Database.Generic p_database, TeamColor p_color, string p_name, int p_mapx, int p_mapy ) { Spartacus.Game.Animation v_animation; Direction[] v_directions = new Direction[] { Direction.SOUTH, Direction.SOUTHWEST, Direction.WEST, Direction.NORTHWEST, Direction.NORTH, Direction.NORTHEAST, Direction.EAST, Direction.SOUTHEAST }; int k, f; this.v_color = p_color; switch (p_color) { case TeamColor.GREEN: this.v_prefix = "soldiers/green/"; break; case TeamColor.RED: this.v_prefix = "soldiers/red/"; break; case TeamColor.BLUE: this.v_prefix = "soldiers/blue/"; break; case TeamColor.YELLOW: this.v_prefix = "soldiers/yellow/"; break; default: break; } this.v_mapx = p_mapx; this.v_mapy = p_mapy; this.v_name = p_name; this.v_health = 100; this.v_actions = 5; this.v_stamina = 100; this.v_ammo = 20; this.v_grenades = 2; this.v_object = new Spartacus.Game.Object(p_name, 0, 0, 96, 96); foreach (System.Data.DataRow r in p_database.Query("select * from animations order by id", "ANIMATIONS").Rows) { if (r["id"].ToString() == "1") { k = 0; foreach (Direction d in v_directions) { this.v_object.AddImage(this.v_prefix + r["name"].ToString() + string.Format("{0:0000}", k) + ".png", true); k++; } } else { foreach (Direction d in v_directions) { v_animation = new Spartacus.Game.Animation(r["name"].ToString(), false); k = 0; f = 2; for (int s = 0; s < int.Parse(r["steps"].ToString()); s++) { this.v_object.AddImage(this.v_prefix + r["name"].ToString() + "_" + this.DirectionToString(d) + string.Format("{0:0000}", k) + ".png", true); v_animation.AddStep(this.v_object.v_images.Count - 1, f); k++; f += 2; } switch (d) { case Direction.SOUTH: v_animation.AddStep(0, f); break; case Direction.SOUTHWEST: v_animation.AddStep(1, f); break; case Direction.WEST: v_animation.AddStep(2, f); break; case Direction.NORTHWEST: v_animation.AddStep(3, f); break; case Direction.NORTH: v_animation.AddStep(4, f); break; case Direction.NORTHEAST: v_animation.AddStep(5, f); break; case Direction.EAST: v_animation.AddStep(6, f); break; case Direction.SOUTHEAST: v_animation.AddStep(7, f); break; } this.v_object.AddAnimation(v_animation); } } } this.v_random = new System.Random(); this.v_direction = v_directions[this.v_random.Next(v_directions.Length)]; this.Start(); }
/// <summary> /// Constrói o banco de dados temporário. /// </summary> /// <param name="p_sql">Texto SQL.</param> private void BuildCache(string p_sql) { Spartacus.Utils.ProgressEventClass v_progress; Spartacus.Utils.ErrorEventClass v_error; Spartacus.Utils.Cryptor v_cryptor; System.IO.FileInfo v_info; long v_totalsize; v_totalsize = 0; foreach (string s in this.ExtractFromString(p_sql, "[", "]")) { if (!s.StartsWith(".")) { v_info = new System.IO.FileInfo(this.v_service + "/" + s); if (v_info.Exists) { if (p_sql.ToLower().Contains("drop table [" + s.ToLower() + "]")) { this.v_tabletodrop = s.ToLower(); } v_totalsize += v_info.Length; this.v_tables.Add(s); } else { if (p_sql.ToLower().Contains("create table [" + s.ToLower() + "]")) { this.v_tables.Add(s.ToLower()); } else { throw new Spartacus.Database.Exception("File '{0}' does not exist and is not going to be created.", s); } } } } if (v_totalsize > this.v_cachethreshold) { v_cryptor = new Spartacus.Utils.Cryptor("spartacus"); this.v_tempdatabase = v_cryptor.RandomString() + ".db"; this.v_database = new Spartacus.Database.Sqlite(this.v_tempdatabase); } else { this.v_tempdatabase = ""; this.v_database = new Spartacus.Database.Memory(); } this.v_database.SetTimeout(-1); this.v_database.SetExecuteSecurity(false); this.v_database.Open(); this.v_database.Execute("PRAGMA synchronous=OFF"); v_progress = new Spartacus.Utils.ProgressEventClass(); v_progress.ProgressEvent += new Spartacus.Utils.ProgressEventClass.ProgressEventHandler(OnProgress); v_error = new Spartacus.Utils.ErrorEventClass(); v_error.ErrorEvent += new Spartacus.Utils.ErrorEventClass.ErrorEventHandler(OnError); foreach (string t in this.v_tables) { v_info = new System.IO.FileInfo(this.v_service + "/" + t); if (v_info.Exists) { this.v_database.TransferFromFile(this.v_service + "/" + t, this.v_separator, this.v_delimiter, this.v_header, this.v_encoding, "[" + t + "]", v_progress, v_error); } } }