/// <summary> /// Cria documento com apenas 1 linha por documento. /// </summary> /// <param name="type"></param> /// <returns></returns> public static List <ROBO.Transacoes.Entidade.Documents> GetDadosSL(TransEnum type) { var oDocEntitys = new List <Transacoes.Entidade.Documents>(); using (var conn = new MyRecordSet()) { principal.GravaAudit(Properties.Querys.Transacoes_1); principal.GravaAudit(type.ToString()); conn.DoQuery(Properties.Querys.Transacoes_1, ((int)type)); while (conn.HasNext()) { var oDocEntity = new Transacoes.Entidade.Documents(); try { oDocEntity = new Transacoes.Entidade.Documents(); oDocEntity.MyValues["Id"] = conn.GetFieldValue(0); oDocEntity.BplId = conn.GetFieldValue("BplId").ToInt(); oDocEntity.MyValues["ReadBySAP"] = conn.GetFieldValue("ReadBySAP"); oDocEntity.Comments = conn.GetFieldValue("Comments").ToString(); oDocEntity.DocDate = conn.GetFieldValue("DocDate").ToDate(); oDocEntity.GroupNum = conn.GetFieldValue("GroupNum").ToInt(); oDocEntity.TaxDate = conn.GetFieldValue("TaxDate").ToDate(); // Linhas var oDocentryLine = new Transacoes.Entidade.DocumentsEntityLine(); oDocentryLine.UserFields["U_Lot"] = conn.GetFieldValue("U_Lot").ToString(); oDocentryLine.UserFields["U_Quality"] = conn.GetFieldValue("U_Quality").ToString(); oDocentryLine.WhsCode = conn.GetFieldValue("WareHouse").ToString(); oDocentryLine.Quantity = conn.GetFieldValue("Quantity").ToDouble(); oDocentryLine.ItemCode = Functions.Find.Item(conn.GetFieldValue("OITM_CodeBars").ToString()); oDocEntity.Lines.Add(oDocentryLine); // Adicionando na lista if ((Program.contador % 2) == 0) { if (oDocEntity.MyValues["ReadBySAP"].ToChar() != 'E') { oDocEntitys.Add(oDocEntity); } } else { oDocEntitys.Add(oDocEntity); } } catch (Exception ex) { UpdateStatus(oDocEntity, 'E', String.Format(Properties.LogMessage.TRANS_0030_2L , oDocEntity.MyValues["Id"] , ex.Message)); } } } return(oDocEntitys); }
/// <summary> /// Informa se há transação em aberto /// </summary> /// <param name="type">Tipo de transação</param> /// <returns></returns> public static bool TransactionOpen(TransEnum type) { using (var rs = new MyRecordSet()) { rs.DoQuery("SELECT COUNT(*) FROM sage_TRANSACOES WITH (NOLOCK) WHERE ReadBySAP <> 'Y' AND CAST(TransactionType AS INT) = '{0}'", (int)type); if (rs.HasNext()) { return(rs.GetFieldValue(0).ToInt() > 0); } else { return(false); } } }
/// <summary> /// Informe o número da transação. /// </summary> /// <param name="transtype">Transação ID</param> public Processar(TransEnum type) { this.transType = type; }
/// <summary> /// Retorna as entidades de transações não lida pelo SAP. /// </summary> /// <param name="type">Tipo de transação</param> /// <returns></returns> public static List <Transacoes.Entidade.Documents> GetDados(TransEnum type) { var oDocEntitys = new List <Transacoes.Entidade.Documents>(); var conn = new MyLibs.v2.local.DataBase.ConnSqlServer(); conn.DoQuery(Properties.Querys.Transacoes_1, (int)type); var oDocEntity = new Transacoes.Entidade.Documents(); int bplId = -1; try { while (conn.HasNext()) { var error = false; try { if (bplId != conn.GetFieldValue("BplId").ToInt()) { bplId = conn.GetFieldValue("BplId").ToInt(); oDocEntity.BplId = bplId; oDocEntity.MyValues["Id"] = conn.GetFieldValue("Id"); oDocEntity.Comments = conn.GetFieldValue("Comments").ToString(); oDocEntity.DocDate = conn.GetFieldValue("DocDate").ToDate(); oDocEntity.GroupNum = conn.GetFieldValue("GroupNum").ToInt(); oDocEntity.TaxDate = conn.GetFieldValue("TaxDate").ToDate(); var oDocentryLine = new Transacoes.Entidade.DocumentsEntityLine(); oDocentryLine.Quantity = conn.GetFieldValue("Quantity").ToDouble(); var codebars = conn.GetFieldValue("OITM_CodeBars").ToString(); try { oDocentryLine.ItemCode = MyQuery.GetValue("OITM", codebars, "CodeBars", "ItemCode").ToString(); } catch { error = true; principal.GravaAudit("Transação " + type.ToString() + " " + Properties.LogMessage.ERRO_TRANS_28_2.ToString() + " " + codebars.ToString()); UpdateStatus(oDocEntity, 'E', String.Format(Properties.LogMessage.ERRO_TRANS_28_2 , codebars , oDocEntity.MyValues["Id"])); oDocentryLine.ItemCode = null; } oDocentryLine.UserFields["U_Lot"] = conn.GetFieldValue("U_Lot").ToString(); oDocentryLine.UserFields["U_Quality"] = conn.GetFieldValue("U_Quality").ToString(); oDocentryLine.WhsCode = conn.GetFieldValue("WareHouse").ToString(); oDocentryLine.MyValues["Id"] = conn.GetFieldValue("Id"); oDocEntity.Lines.Add(oDocentryLine); } else { var oDocentryLine = new Transacoes.Entidade.DocumentsEntityLine(); oDocentryLine.MyValues["Id"] = conn.GetFieldValue("Id"); oDocentryLine.Quantity = conn.GetFieldValue("Quantity").ToDouble(); var codebars = conn.GetFieldValue("OITM_CodeBars").ToString(); try { oDocentryLine.ItemCode = MyQuery.GetValue("OITM", codebars, "CodeBars", "ItemCode").ToString(); } catch { error = true; principal.GravaAudit("Transação " + type.ToString() + " " + Properties.LogMessage.ERRO_TRANS_28_2.ToString() + " " + codebars.ToString()); UpdateStatus(oDocEntity, 'E', String.Format(Properties.LogMessage.ERRO_TRANS_28_2 , codebars , oDocEntity.MyValues["Id"].ToInt())); oDocentryLine.ItemCode = null; } oDocentryLine.UserFields["U_Lot"] = conn.GetFieldValue("U_Lot").ToString(); oDocentryLine.UserFields["U_Quality"] = conn.GetFieldValue("U_Quality").ToString(); oDocentryLine.WhsCode = conn.GetFieldValue("WareHouse").ToString(); oDocEntity.Lines.Add(oDocentryLine); } }catch (Exception ex) { error = true; UpdateStatus(oDocEntity, 'E', ex.Message); } if (!error) { oDocEntitys.Add(oDocEntity); } oDocEntity = new Transacoes.Entidade.Documents(); } } catch (Exception ex) { principal.GravaAudit("Transação " + type.ToString() + " " + ex.Message.ToString()); } return(oDocEntitys); }