public static T ExecuteToEntity <T>(string commandText , RowMapper <T> rowMapper , HanaParameter parameter = null , List <HanaParameter> parameters = null , CommandType type = CommandType.StoredProcedure) where T : class { HanaConnection connection = null; HanaCommand command = null; HanaDataReader dataReader = null; T entity = null; try { connection = OpenConnection(); command = PrepareCommand(commandText, connection, type, parameter, parameters); dataReader = command.ExecuteReader(); while (dataReader.Read()) { entity = rowMapper(dataReader); } } catch (HanaException) { throw; } finally { CloseDataReader(dataReader); CloseCommand(command); CloseConnection(connection); } return(entity); }
private static void CloseDataReader(HanaDataReader dataReader) { if (dataReader != null) { dataReader.Close(); dataReader.Dispose(); } }
public CadastroPedido ConsultaUltimoPedido() { WS.ServiceLayer.ServiceLayer Service = new WS.ServiceLayer.ServiceLayer(); CadastroPedido _Retorno = new CadastroPedido(); try { using (HanaConnection conn = new HanaConnection(ConfigurationManager.ConnectionStrings["Hana"].ConnectionString)) { conn.Open(); var Schema = ConfigurationManager.AppSettings["CompanyDB"]; string Sql = string.Format(Properties.Resources.ConsultaUltimoPedido, Schema); using (HanaCommand cmd3 = new HanaCommand(Sql, conn)) { using (HanaDataReader productInfoReader3 = cmd3.ExecuteReader()) { HanaCommand cmd = new HanaCommand(Sql, conn); HanaDataReader productInfoReader = cmd.ExecuteReader(); while (productInfoReader.Read()) { var DocEntry = productInfoReader.GetString(0); var GetPedido = Service.Get($"Orders({DocEntry})"); _Retorno = JsonConvert.DeserializeObject <CadastroPedido>(GetPedido.Documento, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); //var GetJob = Service.Get($"JOB?$select=*&$filter=U_NEO_DocEntry eq '{DocEntry}'"); //var RetObjJob = Newtonsoft.Json.JsonConvert.DeserializeObject<CadastroJobs>(GetJob.Documento, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); //if (RetObjJob.value.ToList().Count > 0) //{ // _Retorno.CadastroJob = new CadastroJob[RetObjJob.value.ToList().Count]; // _Retorno.CadastroJob = RetObjJob.value; //} } } } } } catch (Exception ex) { Log.Error(ex.Message); } finally { //Service.Logout(); } return(_Retorno); }
public CadastroPN ConsultaUltimoPN() { WS.ServiceLayer.ServiceLayer Service = new WS.ServiceLayer.ServiceLayer(); CadastroPN _Retorno = new CadastroPN(); try { //var RetLogin = Service.Login(); //if (!RetLogin.Sucesso) //{ // Log.Error("Erro do Login SL"); //} using (HanaConnection conn = new HanaConnection(ConfigurationManager.ConnectionStrings["Hana"].ConnectionString)) { conn.Open(); var Schema = ConfigurationManager.AppSettings["CompanyDB"]; string Sql = string.Format(Properties.Resources.ConsultaUltimoPN, Schema); using (HanaCommand cmd3 = new HanaCommand(Sql, conn)) { using (HanaDataReader productInfoReader3 = cmd3.ExecuteReader()) { HanaCommand cmd = new HanaCommand(Sql, conn); HanaDataReader productInfoReader = cmd.ExecuteReader(); while (productInfoReader.Read()) { var CardCode = productInfoReader.GetString(0); var GetPN = Service.Get($"BusinessPartners('{CardCode}')"); _Retorno = JsonConvert.DeserializeObject <CadastroPN>(GetPN.Documento, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); } } } } } catch (Exception ex) { Log.Error(ex.Message); } finally { //Service.Logout(); } return(_Retorno); }
private DataTable GetReportData() { DataGridView gr = new DataGridView(); HanaConnection conn = new HanaConnection(string.Format("Server={0};UserID={1};Password={2}", ConfigurationManager.AppSettings["SAPServer"], ConfigurationManager.AppSettings["SAPUsername"], ConfigurationManager.AppSettings["SAPPassword"])); conn.Open(); HanaCommand selectCmd = new HanaCommand(string.Format("SELECT \"QUERY\" AS \"SqlQuery\" FROM {1}.\"@PRINTDOCUMENT\" WHERE \"Code\" LIKE '{0}'", this.oid, ConfigurationManager.AppSettings["SAPDatabase"]), conn); HanaDataReader dr = selectCmd.ExecuteReader(); gr.DataSource = dr; DataTable dt = new DataTable(); dt.Load(dr); dr.Close(); conn.Close(); if (dt == null || dt.Rows.Count == 0) { return(null); } var cmdText = System.Text.ASCIIEncoding.ASCII.GetString((byte[])dt.Rows[0]["SqlQuery"]); if (string.IsNullOrEmpty(cmdText)) { return(null); } return(Utility.hanaConnection(cmdText)); //var conn1 = DBConnection.conn; //try //{ // var obj = Utility.hanaConnection(string.Format("SELECT \"QUERY\" AS \"SqlQuery\" FROM \"@PRINTDOCUMENT\" WHERE \"Code\" LIKE '{0}'", this.oid)); // if (obj == null || obj.Rows.Count == 0) return null; // var cmdText = System.Text.ASCIIEncoding.ASCII.GetString((byte[])obj.Rows[0]["SqlQuery"]); // if (string.IsNullOrEmpty(cmdText)) return null; // return // Utility.GetObjects(cmdText, conn1); //} //catch (Exception) //{ // return null; //} }
public CadastroAtividade ConsultaUltimoAtividade() { WS.ServiceLayer.ServiceLayer Service = new WS.ServiceLayer.ServiceLayer(); CadastroAtividade _Retorno = new CadastroAtividade(); try { using (HanaConnection conn = new HanaConnection(ConfigurationManager.ConnectionStrings["Hana"].ConnectionString)) { conn.Open(); var Schema = ConfigurationManager.AppSettings["CompanyDB"]; string Sql = string.Format(Properties.Resources.ConsultaUltimoAtividade, Schema); using (HanaCommand cmd3 = new HanaCommand(Sql, conn)) { using (HanaDataReader productInfoReader3 = cmd3.ExecuteReader()) { HanaCommand cmd = new HanaCommand(Sql, conn); HanaDataReader productInfoReader = cmd.ExecuteReader(); while (productInfoReader.Read()) { var DocEntry = productInfoReader.GetString(0); var CardName = productInfoReader.GetString(1); var GetAtividade = Service.Get($"Activities({DocEntry})"); _Retorno = JsonConvert.DeserializeObject <CadastroAtividade>(GetAtividade.Documento, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); _Retorno.CardName = CardName; } } } } } catch (Exception ex) { Log.Error(ex.Message); } finally { //Service.Logout(); } return(_Retorno); }
//static void testInsertEf() //{ // using (var context = new Entities1()) // { // var tm_Master01 = new Tm_Master01(); // tm_Master01.Description = "ini di insert dari EF"; // context.Tm_Master01.Add(tm_Master01); // context.SaveChanges(); // } //} static void testKoneksiBiasa() { HanaConnection conn = new HanaConnection("Server=$userHost$:$userPort$;UserName=$userName$;Password=$userPassword$"); conn.Open(); HanaCommand cmd = new HanaCommand("select 'Hello, World' from DUMMY", conn); // Exception try { HanaDataReader reader = cmd.ExecuteReader(); reader.Read(); Console.WriteLine(reader.GetString(0)); } catch (Exception e) { String errorMsg = e.ToString(); Console.WriteLine(errorMsg); } }
public Porcentagem ConsultaPorcentagem(string etapa) { Porcentagem _Retorno = new Porcentagem(); try { using (HanaConnection conn = new HanaConnection(ConfigurationManager.ConnectionStrings["Hana"].ConnectionString)) { conn.Open(); var Schema = ConfigurationManager.AppSettings["CompanyDB"]; string Sql = string.Format(Properties.Resources.ConsultaPorcentagem, Schema, etapa); using (HanaCommand cmd3 = new HanaCommand(Sql, conn)) { using (HanaDataReader productInfoReader3 = cmd3.ExecuteReader()) { HanaCommand cmd = new HanaCommand(Sql, conn); HanaDataReader productInfoReader = cmd.ExecuteReader(); if (productInfoReader.HasRows) { productInfoReader.Read(); string valor = productInfoReader.GetString(0); _Retorno.Valor = valor; } } } } } catch (Exception ex) { Log.Error(ex.Message); } finally { } return(_Retorno); }
public string ConsultaCardCodePN(string Tipo, string Serie) { string _Retorno = string.Empty; try { using (HanaConnection conn = new HanaConnection(ConfigurationManager.ConnectionStrings["Hana"].ConnectionString)) { conn.Open(); var Schema = ConfigurationManager.AppSettings["CompanyDB"]; string Sql = string.Format(Properties.Resources.ConsultaCardCodePN, Schema, Tipo, Serie); using (HanaCommand cmd3 = new HanaCommand(Sql, conn)) { using (HanaDataReader productInfoReader3 = cmd3.ExecuteReader()) { HanaCommand cmd = new HanaCommand(Sql, conn); HanaDataReader productInfoReader = cmd.ExecuteReader(); if (productInfoReader.HasRows) { productInfoReader.Read(); string Code = productInfoReader.GetString(0); _Retorno = Code; } } } } } catch (Exception ex) { Log.Error(ex.Message); } finally { } return(_Retorno); }
private void SapToSoldev() { HanaDataAdapter dta = new HanaDataAdapter(); DataTable dt = new DataTable(); string lSql = sapSqlSolDev(); HanaCommand cmd = new HanaCommand(lSql, sapConn()); HanaDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { dgSoldev.ItemsSource = reader; //btnToSml.Visibility = Visibility.Visible; } else { MessageBox.Show("Document not found..!"); } }
public static bool canRead(this HanaDataReader reader, string tag, out int ordinal) { ordinal = -1; bool can = true; try { ordinal = reader.GetOrdinal(tag); } catch (IndexOutOfRangeException) { throw; } if (ordinal < 0) { can = false; } if (ordinal > 0) { if (reader.IsDBNull(ordinal)) { can = false; } } return(can); }
public Retorno InsereAtualizaPedido(CadastroPedido Pedido) { WS.ServiceLayer.ServiceLayer Service = new WS.ServiceLayer.ServiceLayer(); Retorno _Retorno = new Retorno(); try { if (Pedido.DocEntry == null) { #region Insere Pedido //var ObjJob = Pedido.CadastroJob; //Pedido.CadastroJob = null; var Json = JsonConvert.SerializeObject(Pedido, Newtonsoft.Json.Formatting.Indented, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); _Retorno = Service.Add("Orders", Json); #endregion #region Insere Projeto Gerencial if (_Retorno.Sucesso) { ProjetoGerencial projetoGerencial = new ProjetoGerencial(); projetoGerencial.ProjectName = Pedido.DocumentLines[0].ProjectCode; projetoGerencial.StartDate = Pedido.DocDate; projetoGerencial.DueDate = Pedido.DocDueDate; projetoGerencial.BusinessPartner = Pedido.CardCode; projetoGerencial.BusinessPartnerName = Pedido.CardName; projetoGerencial.SalesEmployee = Pedido.SalesPersonCode; projetoGerencial.FinancialProject = Pedido.DocumentLines[0].ProjectCode; Json = JsonConvert.SerializeObject(projetoGerencial, Newtonsoft.Json.Formatting.Indented, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); var _RetornoProjeto = Service.Add("ProjectManagements", Json); if (!_RetornoProjeto.Sucesso) { Log.Error("Erro ao Gerar Projeto Gerencial: " + _RetornoProjeto.Documento); } } #endregion #region Insere Pré LCM if (_Retorno.Sucesso) { Modelos.Pedido.CadastroPedido GetObjPedido = JsonConvert.DeserializeObject <Modelos.Pedido.CadastroPedido>(_Retorno.Documento, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); foreach (var item in GetObjPedido.DocumentLines) { string U_NEO_Dt_Inicio = item.U_NEO_Dt_Inicio; float? valor = item.UnitPrice; float? valorTotal = 0; string U_NEO_RecReceita = item.U_NEO_RecReceita; string ItemCode = item.ItemCode; string CardCode = GetObjPedido.CardCode; string Projeto = item.ProjectCode; int? DocNum = GetObjPedido.DocNum; string Conta = string.Empty; int? Filial = GetObjPedido.BPL_IDAssignedToInvoice; if (!string.IsNullOrEmpty(U_NEO_Dt_Inicio)) { if (!string.IsNullOrEmpty(U_NEO_RecReceita)) { using (HanaConnection conn = new HanaConnection(ConfigurationManager.ConnectionStrings["Hana"].ConnectionString)) { conn.Open(); var Schema = ConfigurationManager.AppSettings["CompanyDB"]; string Sql = string.Format(Properties.Resources.ConsultaGrupoItem, Schema, ItemCode); using (HanaCommand cmd3 = new HanaCommand(Sql, conn)) { using (HanaDataReader productInfoReader3 = cmd3.ExecuteReader()) { HanaCommand cmd = new HanaCommand(Sql, conn); HanaDataReader productInfoReader = cmd.ExecuteReader(); if (productInfoReader.HasRows) { productInfoReader.Read(); string GrupoItem = productInfoReader.GetString(0); if (GrupoItem.Equals("107")) { Conta = "3010201010098"; } else { Conta = "3010201010099"; } //3010201010098 - DIFERIMENTO - PRODUÇÃO - 107 //3010201010099 - DIFERIMENTO - MYND - 105 DateTime Data = new DateTime(); Data = DateTime.Parse(U_NEO_Dt_Inicio); int TotalDias = 0; DateTime ultimoDiaDoMes = new DateTime(); for (int i = 0; i < int.Parse(U_NEO_RecReceita); i++) { ultimoDiaDoMes = new DateTime(Data.Year, Data.Month, DateTime.DaysInMonth(Data.Year, Data.Month)); var qtddias = ultimoDiaDoMes.Day; var diaAtual = Data.Day; var restoDias = qtddias - diaAtual + 1; TotalDias = TotalDias + qtddias - diaAtual + 1; //Data = Data.AddDays(restoDias - 1); Data = Data.AddDays(restoDias); } PreLCM preLCM = new PreLCM(); preLCM.JournalVoucher = new Journalvoucher(); preLCM.JournalVoucher.JournalEntry = new Journalentry(); preLCM.JournalVoucher.JournalEntry.JournalEntryLines = new Journalentryline[int.Parse(U_NEO_RecReceita) + 1]; preLCM.JournalVoucher.JournalEntry.ReferenceDate = DateTime.Now.ToString("yyyy-MM-dd"); preLCM.JournalVoucher.JournalEntry.Memo = "Pré Lançamento gerado pelo Site Pedido: " + DocNum; Data = DateTime.Parse(U_NEO_Dt_Inicio); for (int i = 0; i < int.Parse(U_NEO_RecReceita); i++) { ultimoDiaDoMes = new DateTime(Data.Year, Data.Month, DateTime.DaysInMonth(Data.Year, Data.Month)); var qtddias = ultimoDiaDoMes.Day; var diaAtual = Data.Day; var restoDias = qtddias - diaAtual + 1; var ValorLCM = (valor / TotalDias) * restoDias; valorTotal = valorTotal + ValorLCM; preLCM.JournalVoucher.JournalEntry.DueDate = ultimoDiaDoMes.ToString("yyyy-MM-dd"); preLCM.JournalVoucher.JournalEntry.JournalEntryLines[i] = new Journalentryline(); preLCM.JournalVoucher.JournalEntry.JournalEntryLines[i].AccountCode = Conta; preLCM.JournalVoucher.JournalEntry.JournalEntryLines[i].Credit = ValorLCM; preLCM.JournalVoucher.JournalEntry.JournalEntryLines[i].Debit = 0; preLCM.JournalVoucher.JournalEntry.JournalEntryLines[i].BPLID = Filial; preLCM.JournalVoucher.JournalEntry.JournalEntryLines[i].DueDate = ultimoDiaDoMes.ToString("yyyy-MM-dd"); preLCM.JournalVoucher.JournalEntry.JournalEntryLines[i].LineMemo = "Pré Lançamento gerado pelo Site Pedido: " + DocNum; preLCM.JournalVoucher.JournalEntry.JournalEntryLines[i].ProjectCode = Projeto; Data = Data.AddDays(restoDias); } preLCM.JournalVoucher.JournalEntry.JournalEntryLines[int.Parse(U_NEO_RecReceita)] = new Journalentryline(); preLCM.JournalVoucher.JournalEntry.JournalEntryLines[int.Parse(U_NEO_RecReceita)].AccountCode = "1010201010001"; preLCM.JournalVoucher.JournalEntry.JournalEntryLines[int.Parse(U_NEO_RecReceita)].Credit = 0; preLCM.JournalVoucher.JournalEntry.JournalEntryLines[int.Parse(U_NEO_RecReceita)].Debit = valorTotal; preLCM.JournalVoucher.JournalEntry.JournalEntryLines[int.Parse(U_NEO_RecReceita)].BPLID = Filial; preLCM.JournalVoucher.JournalEntry.JournalEntryLines[int.Parse(U_NEO_RecReceita)].ShortName = CardCode; preLCM.JournalVoucher.JournalEntry.JournalEntryLines[int.Parse(U_NEO_RecReceita)].DueDate = ultimoDiaDoMes.ToString("yyyy-MM-dd"); preLCM.JournalVoucher.JournalEntry.JournalEntryLines[int.Parse(U_NEO_RecReceita)].LineMemo = "Pré Lançamento gerado pelo Site Pedido: " + DocNum; preLCM.JournalVoucher.JournalEntry.JournalEntryLines[int.Parse(U_NEO_RecReceita)].ProjectCode = Projeto; var JsonLCM = JsonConvert.SerializeObject(preLCM, Newtonsoft.Json.Formatting.Indented, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); var _RetornoLCM = Service.Add("JournalVouchersService_Add", JsonLCM); if (!_RetornoLCM.Sucesso) { Log.Error("Erro ao Gerar Pré LCM: " + _RetornoLCM.Documento); } } } } } } } } } #endregion #region Insere Job //if (_Retorno.Sucesso) //{ // foreach (var itemJobb in ObjJob) // { // var RetObjPedido = Newtonsoft.Json.JsonConvert.DeserializeObject<CadastroPedido>(_Retorno.Documento, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); // itemJobb.U_NEO_DocEntry = RetObjPedido.DocEntry.ToString(); // itemJobb.U_NEO_DocType = "17"; // var JsonJob = Newtonsoft.Json.JsonConvert.SerializeObject(itemJobb, Newtonsoft.Json.Formatting.Indented, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); // var _RetornoJob = Service.Add("JOB", JsonJob); // if (!_RetornoJob.Sucesso) // { // } // } //} #endregion } else { #region Atualiza Pedido //var ObjJob = Pedido.CadastroJob; //Pedido.CadastroJob = null; var Json = Newtonsoft.Json.JsonConvert.SerializeObject(Pedido, Newtonsoft.Json.Formatting.Indented, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); _Retorno = Service.Update($"Orders({Pedido.DocEntry})", Json); #endregion #region Insere Job //if (_Retorno.Sucesso) //{ // var GetJob = Service.Get($"JOB?$select=*&$filter=U_NEO_DocEntry eq '{Pedido.DocEntry}'"); // var RetObjJob = Newtonsoft.Json.JsonConvert.DeserializeObject<CadastroJobs>(GetJob.Documento, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); // if (RetObjJob.value.ToList().Count > 0) // { // foreach (var item in RetObjJob.value) // { // var _RetornoJob = Service.Delete($"JOB({item.DocEntry})"); // if (!_RetornoJob.Sucesso) // { // } // } // foreach (var itemJobb in ObjJob) // { // itemJobb.U_NEO_DocEntry = Pedido.DocEntry.ToString(); // itemJobb.U_NEO_DocType = "17"; // var JsonJob = Newtonsoft.Json.JsonConvert.SerializeObject(itemJobb, Newtonsoft.Json.Formatting.Indented, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); // var _RetornoJob = Service.Add("JOB", JsonJob); // if (!_RetornoJob.Sucesso) // { // } // } // } // else // { // foreach (var item in ObjJob) // { // item.U_NEO_DocEntry = Pedido.DocEntry.ToString(); // item.U_NEO_DocType = "17"; // var JsonJob = Newtonsoft.Json.JsonConvert.SerializeObject(item, Newtonsoft.Json.Formatting.Indented, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); // var _RetornoJob = Service.Add("JOB", JsonJob); // if (!_RetornoJob.Sucesso) // { // } // } // } //} #endregion } } catch (Exception ex) { Log.Error(ex.Message); } finally { //Service.Logout(); } return(_Retorno); }
public CadastroAtividades ConsultaAtividade(CadastroAtividade atividade) { WS.ServiceLayer.ServiceLayer Service = new WS.ServiceLayer.ServiceLayer(); CadastroAtividades _Retorno = new CadastroAtividades(); try { using (HanaConnection conn = new HanaConnection(ConfigurationManager.ConnectionStrings["Hana"].ConnectionString)) { conn.Open(); var Schema = ConfigurationManager.AppSettings["CompanyDB"]; string Sql = string.Format(Properties.Resources.ConsultaAtividade, Schema, atividade.CardCode, atividade.CardName, atividade.ActivityCode); using (HanaCommand cmd3 = new HanaCommand(Sql, conn)) { using (HanaDataReader productInfoReader3 = cmd3.ExecuteReader()) { HanaCommand cmd = new HanaCommand(Sql, conn); HanaDataReader productInfoReader = cmd.ExecuteReader(); if (productInfoReader.HasRows) { productInfoReader.Read(); var DocEntry = productInfoReader.GetString(0); var CardName = productInfoReader.GetString(1); var Count = productInfoReader.GetString(2); var GetPN = Service.Get($"Activities({DocEntry})"); var _RetornoAtividade = JsonConvert.DeserializeObject <CadastroAtividade>(GetPN.Documento, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); _RetornoAtividade.CardName = CardName; _Retorno.value = new CadastroAtividade[int.Parse(Count)]; _Retorno.value[0] = new CadastroAtividade(); _Retorno.value[0] = _RetornoAtividade; int i = 1; while (productInfoReader.Read()) { _Retorno.value[i] = new CadastroAtividade(); DocEntry = productInfoReader.GetString(0); CardName = productInfoReader.GetString(1); GetPN = Service.Get($"Activities({DocEntry})"); _RetornoAtividade = JsonConvert.DeserializeObject <CadastroAtividade>(GetPN.Documento, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); _RetornoAtividade.CardName = CardName; _Retorno.value[i] = _RetornoAtividade; i++; } } } } } } catch (Exception ex) { Log.Error(ex.Message); } finally { //Service.Logout(); } return(_Retorno); }
public ContasReceber ConsultaContasReceber(string NomeCliente, string DataVencimentoDe, string DataVencimentoAte, string DataPagamentoDe, string DataPagamentoAte, string Projeto, string Status) { WS.ServiceLayer.ServiceLayer Service = new WS.ServiceLayer.ServiceLayer(); ContasReceber _Retorno = new ContasReceber(); try { using (HanaConnection conn = new HanaConnection(ConfigurationManager.ConnectionStrings["Hana"].ConnectionString)) { conn.Open(); var Schema = ConfigurationManager.AppSettings["CompanyDB"]; if (string.IsNullOrEmpty(Status)) { Status = "Todos"; } string Sql = string.Format(Properties.Resources.ConsultaContasReceber, Schema, NomeCliente, DataVencimentoDe, DataVencimentoAte, DataPagamentoDe, DataPagamentoAte, Projeto, Status); using (HanaCommand cmd3 = new HanaCommand(Sql, conn)) { using (HanaDataReader productInfoReader3 = cmd3.ExecuteReader()) { HanaCommand cmd = new HanaCommand(Sql, conn); HanaDataReader productInfoReader = cmd.ExecuteReader(); if (productInfoReader.HasRows) { productInfoReader.Read(); var pNomeCliente = productInfoReader.GetString(0); var pParcela = productInfoReader.GetString(1); var pValorParcela = productInfoReader.GetString(2); var pNumeroNota = productInfoReader.GetString(3); var pDataVencimento = productInfoReader.GetString(4); var pDataPagamento = productInfoReader.GetString(5); var pProjeto = productInfoReader.GetString(6); var pStatus = productInfoReader.GetString(7); var Count = productInfoReader.GetString(8); _Retorno.value = new ContaReceber[int.Parse(Count)]; _Retorno.value[0] = new ContaReceber(); _Retorno.value[0].NomeCliente = pNomeCliente; _Retorno.value[0].Parcela = pParcela; _Retorno.value[0].ValorParcela = pValorParcela; _Retorno.value[0].NumeroNota = pNumeroNota; _Retorno.value[0].DataVencimento = pDataVencimento; _Retorno.value[0].DataPagamento = pDataPagamento; _Retorno.value[0].Projeto = pProjeto; _Retorno.value[0].Status = pStatus; int i = 1; while (productInfoReader.Read()) { _Retorno.value[i] = new ContaReceber(); pNomeCliente = productInfoReader.GetString(0); pParcela = productInfoReader.GetString(1); pValorParcela = productInfoReader.GetString(2); pNumeroNota = productInfoReader.GetString(3); pDataVencimento = productInfoReader.GetString(4); pDataPagamento = productInfoReader.GetString(5); pProjeto = productInfoReader.GetString(6); pStatus = productInfoReader.GetString(7); Count = productInfoReader.GetString(8); _Retorno.value[i].NomeCliente = pNomeCliente; _Retorno.value[i].Parcela = pParcela; _Retorno.value[i].ValorParcela = pValorParcela; _Retorno.value[i].NumeroNota = pNumeroNota; _Retorno.value[i].DataVencimento = pDataVencimento; _Retorno.value[i].DataPagamento = pDataPagamento; _Retorno.value[i].Projeto = pProjeto; _Retorno.value[i].Status = pStatus; i++; } } } } } } catch (Exception ex) { Log.Error(ex.Message); } finally { //Service.Logout(); } return(_Retorno); }
public static string getString(this HanaDataReader reader, string tag, object def) { return(reader.canRead(tag, out ordinal) ? reader.GetString(ordinal) : Convert.ToString(def)); }
public static string getString(this HanaDataReader reader, string tag) { return(reader.getString(tag, HanaDataReaderHelperDefault.STRING_DEF)); }
public static bool getBool(this HanaDataReader reader, string tag, object def) { return(reader.canRead(tag, out ordinal) ? reader.GetBoolean(ordinal) : Convert.ToBoolean(def)); }
public static int getInt32(this HanaDataReader reader, string tag) { return(reader.getInt32(tag, HanaDataReaderHelperDefault.INT_DEF)); }
public static int getInt32(this HanaDataReader reader, string tag, object def) { return(reader.canRead(tag, out ordinal) ? reader.GetInt32(ordinal) : Convert.ToInt32(def)); }
public Vendedores ConsultaVendedorPedido() { Vendedores _Retorno = new Vendedores(); try { using (HanaConnection conn = new HanaConnection(ConfigurationManager.ConnectionStrings["Hana"].ConnectionString)) { conn.Open(); var Schema = ConfigurationManager.AppSettings["CompanyDB"]; string Sql = string.Format(Properties.Resources.ConsultaVendedorPN, Schema); using (HanaCommand cmd3 = new HanaCommand(Sql, conn)) { using (HanaDataReader productInfoReader3 = cmd3.ExecuteReader()) { HanaCommand cmd = new HanaCommand(Sql, conn); HanaDataReader productInfoReader = cmd.ExecuteReader(); if (productInfoReader.HasRows) { productInfoReader.Read(); string Code = productInfoReader.GetString(0); string Name = productInfoReader.GetString(1); string Count = productInfoReader.GetString(2); _Retorno.value = new Vendedor[int.Parse(Count)]; _Retorno.value[0] = new Vendedor(); _Retorno.value[0].Code = Code; _Retorno.value[0].Name = Name; int i = 1; while (productInfoReader.Read()) { Code = productInfoReader.GetString(0); Name = productInfoReader.GetString(1); _Retorno.value[i] = new Vendedor(); _Retorno.value[i].Code = Code; _Retorno.value[i].Name = Name; i++; } } } } } } catch (Exception ex) { Log.Error(ex.Message); } finally { } return(_Retorno); }
public CadastrosPNs ConsultaPN(CadastroPN PN) { WS.ServiceLayer.ServiceLayer Service = new WS.ServiceLayer.ServiceLayer(); CadastrosPNs _Retorno = new CadastrosPNs(); try { //var RetLogin = Service.Login(); //if (!RetLogin.Sucesso) //{ // Log.Error("Erro do Login SL"); //} using (HanaConnection conn = new HanaConnection(ConfigurationManager.ConnectionStrings["Hana"].ConnectionString)) { conn.Open(); var Schema = ConfigurationManager.AppSettings["CompanyDB"]; string CNPJ = string.Empty; string CPF = string.Empty; if (PN.BPFiscalTaxIDCollection != null) { CNPJ = PN.BPFiscalTaxIDCollection[0].TaxId0; CPF = PN.BPFiscalTaxIDCollection[0].TaxId4; } string Sql = string.Format(Properties.Resources.ConsultaPN, Schema, PN.CardCode, PN.CardName, CNPJ, CPF); using (HanaCommand cmd3 = new HanaCommand(Sql, conn)) { using (HanaDataReader productInfoReader3 = cmd3.ExecuteReader()) { HanaCommand cmd = new HanaCommand(Sql, conn); HanaDataReader productInfoReader = cmd.ExecuteReader(); if (productInfoReader.HasRows) { productInfoReader.Read(); var Count = productInfoReader.GetString(1); var CardCode = productInfoReader.GetString(0); var GetPN = Service.Get($"BusinessPartners('{CardCode}')"); var _RetornoPN = JsonConvert.DeserializeObject <CadastroPN>(GetPN.Documento, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); _Retorno.value = new CadastroPN[int.Parse(Count)]; _Retorno.value[0] = new CadastroPN(); _Retorno.value[0] = _RetornoPN; int i = 1; while (productInfoReader.Read()) { _Retorno.value[i] = new CadastroPN(); CardCode = productInfoReader.GetString(0); GetPN = Service.Get($"BusinessPartners('{CardCode}')"); _RetornoPN = JsonConvert.DeserializeObject <CadastroPN>(GetPN.Documento, new Newtonsoft.Json.JsonSerializerSettings { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore }); _Retorno.value[i] = _RetornoPN; i++; } } } } } } catch (Exception ex) { Log.Error(ex.Message); } finally { //Service.Logout(); } return(_Retorno); }
public static decimal getDecimal(this HanaDataReader reader, string tag) { return(reader.getDecimal(tag, HanaDataReaderHelperDefault.DECIMAL_DEF)); }
public static DateTime getDateTime(this HanaDataReader reader, string tag, object def) { return(reader.canRead(tag, out ordinal) ? reader.GetDateTime(ordinal) : Convert.ToDateTime(def)); }
public static DateTime getDateTime(this HanaDataReader reader, string tag) { return(reader.getDateTime(tag, HanaDataReaderHelperDefault.DATETIME_DEF)); }
public static decimal getDecimal(this HanaDataReader reader, string tag, object def) { return(reader.canRead(tag, out ordinal) ? reader.GetDecimal(ordinal) : Convert.ToDecimal(def)); }
public void ExecuteQuery() { try { conn = HanaService.ConnectToDataBase(); conn.Open(); cnt = 0; string query = Queries.GetQueueOfLabels; HanaCommand command = new HanaCommand(query); command.Connection = conn; HanaDataReader dr = command.ExecuteReader(); while (dr.Read()) { cnt++; daimlerLabel = new Label(); daimlerLabel.Supplier = dr["Supplier"].ToString(); daimlerLabel.Odbiorca = dr["Odbiorca"].ToString(); daimlerLabel.PartNo = dr["Part no"].ToString(); daimlerLabel.Quantity = double.Parse(dr["U_QtyOnLabel"].ToString()); daimlerLabel.Street = dr["Street"].ToString(); daimlerLabel.Address = dr["Adres odbiorcy"].ToString(); daimlerLabel.City = dr["City"].ToString(); daimlerLabel.AdviceNote = dr["Advice note"].ToString(); daimlerLabel.Description = dr["Description"].ToString(); daimlerLabel.Gate = dr["Dock/Gate"].ToString(); daimlerLabel.LabelNo = double.Parse(dr["Serien"].ToString()); daimlerLabel.Date = dr["Date"].ToString(); daimlerLabel.SupplierPartNumber = dr["Supplier part no"].ToString(); daimlerLabel.GTL = dr["GTL"].ToString(); daimlerLabel.DocEntry = dr["DocEntry"].ToString(); daimlerLabel.Los = dr["Los"].ToString(); singleLabel = stringService.ConvertZplFile(stringService.ReadFile(), daimlerLabel); Console.WriteLine(singleLabel); ZplService.Print(singleLabel, IP.Zpl401); if (cnt == 1) { hanaService.CallUpdateProcedure(conn, int.Parse(daimlerLabel.DocEntry), 0); } return; } if (daimlerLabel != null) { hanaService.CallUpdateProcedure(conn, int.Parse(daimlerLabel.DocEntry), 2); } } catch (Exception e) { Console.WriteLine(e.Message); if (daimlerLabel != null) { hanaService.CallUpdateProcedure(conn, int.Parse(daimlerLabel.DocEntry), 3); } } finally { Console.WriteLine("Zaktualizowano"); conn.Close(); } }
public static bool getBool(this HanaDataReader reader, string tag) { return(reader.getBool(tag, HanaDataReaderHelperDefault.BOOL_DEF)); }