private void CarregarObjetos(Utilitarios.TipoTransacao objTipoTransacao) { switch (objTipoTransacao) { case Utilitarios.TipoTransacao.Salvar: if (gobjJCP == null) { gobjJCP = new JCP(); } if (ddlAba.Text.Equals("Ano")) { gobjJCP.Ano = txtAno.Text; gobjJCP.Periodo = ddlMes.SelectedItem.ToString(); gobjJCP.TipoProvento = txtTipoProvento.Text; gobjJCP.PosicaoAcionaria = Convert.ToDateTime(txtPosicaoAcionaria.Text); gobjJCP.DataPagamento = Convert.ToDateTime(txtDataPagamento.Text); gobjJCP.ValorAcao = txtValorAcao.Text; } else { gobjJCP.Ano = "0"; gobjJCP.Periodo = txtPeriodo.Text; gobjJCP.TipoProvento = txtTipoProvento.Text; gobjJCP.PosicaoAcionaria = Convert.ToDateTime(txtPosicaoAcionaria.Text); } break; } }
public SocketService(string Host, int SocketPort, bool socketEncryption, string socketKey) { Server = new SocketServer(); // Setup Parser Protocol = new JCP(socketEncryption, socketKey); if (socketEncryption) { Shared.Log.Message("socket", "Encryption Enabled"); } else { Shared.Log.Message("socket", "Encryption DISABLED"); } // Setup handlers Server.OnConnected += Server_OnConnected; Server.OnClosed += Server_OnClosed; Server.OnException += Server_OnException; Server.OnData += Server_OnData; // Set port Server.Host = Host; Server.Port = SocketPort; }
//#region Atualizar //public static int AtualizarJCP(JCP pobjJCP) //{ // string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; // SqlConnection objConexao = new SqlConnection(strConectionString); // SqlCommand objComando = new SqlCommand("SPE_U_JCP"); // objComando.Connection = objConexao; // objComando.CommandType = CommandType.StoredProcedure; // //Define parametros da procedure // objComando.Parameters.Add("@jcpId", SqlDbType.Int).Value = pobjJCP.IdJCP; // objComando.Parameters.Add("@titulo", SqlDbType.VarChar, 200).Value = pobjJCP.Titulo; // objComando.Parameters.Add("@descricao", SqlDbType.VarChar, 200).Value = pobjJCP.Descricao; // objComando.Parameters.Add("@arquivo", SqlDbType.VarChar, 200).Value = pobjJCP.Arquivo; // try // { // //Abre conexão com o banco de dados // objConexao.Open(); // //Declara variavel de retorno // int intRetorno = 0; // //Executa comando no banco de dados // intRetorno = objComando.ExecuteNonQuery(); // return intRetorno; // } // catch (Exception ex) // { // throw ex; // } // finally // { // //Fecha a conexao se aberta // if (objConexao.State != ConnectionState.Closed) // { // objConexao.Close(); // } // } //} //#endregion #region Listar public static List <JCP> Listar(int pintIdConteudo, int pintIdIdioma, int pintAno) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_L_JCP"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; //Define parametros da procedure objComando.Parameters.Add("@conteudoId", SqlDbType.Int).Value = pintIdConteudo; objComando.Parameters.Add("@idiomaId", SqlDbType.Int).Value = pintIdIdioma; objComando.Parameters.Add("@ano", SqlDbType.Int).Value = pintAno; try { //Abre Conexao objConexao.Open(); //Declara variavel de retorno List <JCP> objList = new List <JCP>(); JCP obj = default(JCP); IDataReader idrReader = default(IDataReader); idrReader = objComando.ExecuteReader(); while ((idrReader.Read())) { obj = new JCP(); obj.FromIDataReader(idrReader); objList.Add(obj); } return(objList); } catch (Exception ex) { throw ex; } finally { //Fecha a conexao se aberta if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }
public static int InserirJCP(JCP pobjJCP) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_I_JCP"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; //Define parametros da procedure objComando.Parameters.Add("@ano", SqlDbType.Int).Value = pobjJCP.Ano; objComando.Parameters.Add("@periodo", SqlDbType.VarChar, 50).Value = pobjJCP.Periodo; objComando.Parameters.Add("@tipoProvento", SqlDbType.VarChar, 50).Value = pobjJCP.TipoProvento; objComando.Parameters.Add("@posicaoAcionaria", SqlDbType.Date).Value = pobjJCP.PosicaoAcionaria; objComando.Parameters.Add("@dataPagamento", SqlDbType.Date).Value = pobjJCP.DataPagamento; objComando.Parameters.Add("@valorAcao", SqlDbType.VarChar, 100).Value = pobjJCP.ValorAcao; try { //Abre conexão com o banco de dados objConexao.Open(); IDataReader idrReader = objComando.ExecuteReader(); if (idrReader.Read()) { return(Convert.ToInt32(idrReader["Identity"])); } else { return(-1); } } catch (Exception ex) { throw ex; } finally { //Fecha a conexao se aberta if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }
public void Start() { // Initialize Protocol Protocol = new JCP(Encryption, EncryptionKey); if (Encryption) { Shared.Log.Message("socket", "Encryption Enabled"); } else { Shared.Log.Message("socket", "Encryption DISABLED"); } Host = Shared.Network.GetIPAddress(Host); Connection.Connect(Host, Port); Connection.Start(); }
public void Start() { // Initialize Protocol Protocol = new JCP(Settings.EncryptionUseEncryptedProtocol, Settings.EncryptionServerEncryptionKey); if (Settings.EncryptionUseEncryptedProtocol) { Shared.Log.Message("socket", "Encryption Enabled"); } else { Shared.Log.Message("socket", "Encryption DISABLED"); } Application.OnConnecting(); Connection.Connect(Settings.ServerAddress, Settings.ServerPort); Connection.Start(); }
public static JCP ObterJCP(int pintIdJCP) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_L_JCP_ID"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; objComando.Parameters.Add("@jcpId", SqlDbType.Int).Value = pintIdJCP; try { objConexao.Open(); JCP obj = new JCP(); IDataReader idrReader = default(IDataReader); idrReader = objComando.ExecuteReader(); while ((idrReader.Read())) { obj.FromIDataReader(idrReader); } return(obj); } catch (Exception ex) { throw ex; } finally { //Fecha a conexao se aberta if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }
public static void ProcessData(Sender session, List <byte> buffer, byte[] data, JCP protocol, ICommandFactory factory) { Log.Message("JCP", "Received " + data.Length + " bytes."); // We have to assume the buffer exists for the session buffer.AddRange(data); bool parsing = true; while (parsing) { if (buffer.Count >= Platform.ByteSizeOfInt) { byte[] lengthBytes = buffer.GetRange(0, Platform.ByteSizeOfInt).ToArray(); int packetLength = BitConverter.ToInt32(lengthBytes, 0); // We've got a complete packet at this point if (buffer.Count >= (packetLength + Platform.ByteSizeOfInt)) { Packet packet = new Packet(buffer.GetRange(Platform.ByteSizeOfInt, packetLength).ToArray(), protocol.EncryptionKey); // Remove processed data buffer.RemoveRange(0, Platform.ByteSizeOfInt + packetLength); // Execute packet instructions foreach (Instruction i in packet.GetInstructions()) { Log.Message("socket", "Instruction Received -> " + i.Operation.ToString() + " from " + session.RemoteEndPoint.GetHost()); // Factory Pattern ISocketCommand receivedCommand = factory.CreateCommand(i.Operation); // Execute (decide what to do though) if (receivedCommand.CanExecute(session)) { receivedCommand.Execute(session, i.Parameters); } } } else { parsing = false; } } else { parsing = false; } } }