private int InserirPedidoVenda(SAPbobsCOM.Company oCompany, OrderPluggto pedidoPluggto)
        {
            try
            {
                if (oCompany.Connected)
                {
                    OrdersDAL orderDAL     = new OrdersDAL(oCompany);
                    string    messageError = "";
                    int       oOrderNum    = 0;
                    Boolean   inserir      = true;

                    foreach (Item item in pedidoPluggto.Order.items)
                    {
                        if (string.IsNullOrEmpty(item.sku) && inserir)
                        {
                            this.log.WriteLogTable(oCompany, EnumTipoIntegracao.PedidoVenda, pedidoPluggto.Order.id, "", EnumStatusIntegracao.Erro, "Um ou mais item(s) do pedido está com o código de referência inválido.");
                            this.log.WriteLogPedido("Um ou mais item(s) do pedido está com o código de referência inválido.");
                            inserir = false;
                        }
                    }

                    if (inserir)
                    {
                        oOrderNum = orderDAL.InsertOrder(pedidoPluggto.Order, out messageError);
                    }
                }

                return(0);
            }
            catch (Exception e)
            {
                this.log.WriteLogPedido("Exception InserirPedidoVenda " + e.Message);
                throw;
            }
        }
Ejemplo n.º 2
0
        public clsConectionSAP(string serverName, string dbName, string SAPpassword, string SAPuser)
        {
            int    RetCode = -1;
            string ConnStatus;

            try
            {
                oCompany              = new SAPbobsCOM.Company();
                oCompany.Server       = serverName;
                oCompany.CompanyDB    = dbName;
                oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008;
                oCompany.UserName     = SAPuser;
                oCompany.Password     = SAPpassword;
                oCompany.UseTrusted   = true;

                RetCode = oCompany.Connect();

                if (RetCode != 0)
                {
                    ConnStatus = oCompany.GetLastErrorDescription();
                }
                else
                {
                    ConnStatus = "Conectando a Compania - " + oCompany.CompanyName;
                    //button1.BackColor = Color.Green;
                }
                //MessageBox.Show(strMsg);
            }
            catch (Exception ex)
            {
                ConnStatus = ex.Message;
            }
        }
Ejemplo n.º 3
0
        public static void ConnectViaUISingleSignOn()
        {
            try
            {
                // 1. Connect via UI
                ConnectViaUI();
                // 2. Create a DI Company and get connect cookie
                oCompany = new SAPbobsCOM.Company();
                String sCookie = oCompany.GetContextCookie();
                // 3. Get Connection Info from UI Application for DI Company
                String connContext = oApplication.Company.GetConnectionContext(sCookie);
                // 4. Set the connection info for DI Company
                oCompany.SetSboLoginContext(connContext);
                IRetCode = oCompany.Connect();

                // 5. Error Handling
                if (IRetCode != 0)
                {
                    MsgBoxWrapper(oCompany.GetLastErrorDescription());
                }
            }
            catch (Exception ex)
            {
                MsgBoxWrapper(ex.Message + " " + ex.StackTrace);
            }
        }
Ejemplo n.º 4
0
        public IHttpActionResult UpdateItem(Authorizations authorizations)
        {
            //Inicializo mi conexión a SAP
            SAPConnection conncetion = new SAPConnection();

            SAPbobsCOM.Company company = conncetion.OpenConnection();

            SAPbobsCOM.CompanyService          oCompanyService = company.GetCompanyService();
            SAPbobsCOM.ApprovalRequestsService approvalSrv     = oCompanyService.GetBusinessService(SAPbobsCOM.ServiceTypes.ApprovalRequestsService);
            ApprovalRequestParams oParams = approvalSrv.GetDataInterface(ApprovalRequestsServiceDataInterfaces.arsApprovalRequestParams) as ApprovalRequestParams;

            oParams.Code = authorizations.WddCode;
            ApprovalRequest oData = approvalSrv.GetApprovalRequest(oParams);

            //Agregar una autorización
            oData.ApprovalRequestDecisions.Add();
            oData.ApprovalRequestDecisions.Item(0).ApproverUserName = "******";
            oData.ApprovalRequestDecisions.Item(0).ApproverPassword = "******";
            oData.ApprovalRequestDecisions.Item(0).Status           = BoApprovalRequestDecisionEnum.ardApproved;
            oData.ApprovalRequestDecisions.Item(0).Remarks          = authorizations.Remarks;

            //Actualizar la autorización
            approvalSrv.UpdateRequest(oData);
            return(Ok(responseCall));
        }
Ejemplo n.º 5
0
        public IHttpActionResult UpdateItems([FromBody] Authorizations authorizations)
        {
            //Inicializo mi conexión a SAP
            SAPConnection conncetion = new SAPConnection();

            SAPbobsCOM.Company company = conncetion.OpenConnection(authorizations.dbname, authorizations.userSap, authorizations.userSapPass);

            SAPbobsCOM.CompanyService          oCompanyService = company.GetCompanyService();
            SAPbobsCOM.ApprovalRequestsService approvalSrv     = oCompanyService.GetBusinessService(SAPbobsCOM.ServiceTypes.ApprovalRequestsService);
            ApprovalRequestParams oParams = approvalSrv.GetDataInterface(ApprovalRequestsServiceDataInterfaces.arsApprovalRequestParams) as ApprovalRequestParams;

            oParams.Code = authorizations.WddCode;
            ApprovalRequest oData = approvalSrv.GetApprovalRequest(oParams);

            //Agregar una autorización
            oData.ApprovalRequestDecisions.Add();
            oData.ApprovalRequestDecisions.Item(0).ApproverUserName = authorizations.userSap;
            oData.ApprovalRequestDecisions.Item(0).ApproverPassword = authorizations.userSapPass;
            //Autorizar
            if (authorizations.Status == "Y")
            {
                oData.ApprovalRequestDecisions.Item(0).Status = BoApprovalRequestDecisionEnum.ardApproved;
            }
            else
            if (authorizations.Status == "N")
            {
                oData.ApprovalRequestDecisions.Item(0).Status = BoApprovalRequestDecisionEnum.ardNotApproved;
            }
            oData.ApprovalRequestDecisions.Item(0).Remarks = authorizations.Remarks;

            //Actualizar la autorización
            approvalSrv.UpdateRequest(oData);
            return(Ok(authorizations));
        }
Ejemplo n.º 6
0
        public void InstallAndRestartDover()
        {
            BusinessOneDAO b1dao = app.Resolve <BusinessOneDAO>();

            Assert.AreEqual(b1dao.ExecuteSqlForObject <int>("select count(*) from \"@DOVER_MODULES\""), 11);
            Assert.IsTrue(b1dao.ExecuteSqlForObject <int>("select count(*) from \"@DOVER_MODULES_BIN\"") > 0);
            Assert.IsTrue(b1dao.ExecuteSqlForObject <int>("select count(*) from \"@DOVER_MODULES_DEP\"") > 0);
            Assert.AreEqual(b1dao.ExecuteSqlForObject <int>("select count(*) from \"@DOVER_MODULES_USER\""), 0);
            Assert.AreEqual(b1dao.ExecuteSqlForObject <int>("select count(*) from \"@DOVER_LOGS\""), 0);
            Assert.AreEqual(b1dao.ExecuteSqlForObject <int>("select count(*) from \"@DOVER_LICENSE\""), 0);
            Assert.AreEqual(b1dao.ExecuteSqlForObject <int>("select count(*) from \"@DOVER_LICENSE_BIN\""), 0);

            DoverSetup.shutdownDover();
            DoverSetup.bootDover(app);
            b1Company = app.Resolve <SAPbobsCOM.Company>();
            b1App     = app.Resolve <SAPbouiCOM.Application>();
            b1dao     = app.Resolve <BusinessOneDAO>();
            Assert.AreEqual(b1dao.ExecuteSqlForObject <int>("select count(*) from \"@DOVER_MODULES\""), 11);
            Assert.IsTrue(b1dao.ExecuteSqlForObject <int>("select count(*) from \"@DOVER_MODULES_BIN\"") > 0);
            Assert.IsTrue(b1dao.ExecuteSqlForObject <int>("select count(*) from \"@DOVER_MODULES_DEP\"") > 0);
            Assert.AreEqual(b1dao.ExecuteSqlForObject <int>("select count(*) from \"@DOVER_MODULES_USER\""), 0);
            Assert.AreEqual(b1dao.ExecuteSqlForObject <int>("select count(*) from \"@DOVER_LOGS\""), 0);
            Assert.AreEqual(b1dao.ExecuteSqlForObject <int>("select count(*) from \"@DOVER_LICENSE\""), 0);
            Assert.AreEqual(b1dao.ExecuteSqlForObject <int>("select count(*) from \"@DOVER_LICENSE_BIN\""), 0);
        }
        private int InserirPedidoVenda(SAPbobsCOM.Company oCompany, Order pedidoMl)
        {
            try
            {
                if (oCompany.Connected)
                {
                    OrdersDAL orderDAL     = new OrdersDAL(oCompany);
                    string    messageError = "";
                    int       oOrderNum    = 0;
                    Boolean   inserir      = true;

                    foreach (Order_Items item in pedidoMl.order_items)
                    {
                        if (item.item.seller_custom_field == null && inserir)
                        {
                            this.log.WriteLogTable(oCompany, EnumTipoIntegracao.PedidoVenda, pedidoMl.id.ToString(), "", EnumStatusIntegracao.Erro, "Um ou mais item(s) do pedido está com o código de referência inválido.");
                            //throw new ArgumentException("Não foi possível criar o Pedido de Venda para o pedido "+pedidoVtex.orderId+" pois um ou mais item(s) do pedido está com o código de referência inválido.");
                            inserir = false;
                        }
                    }

                    if (inserir)
                    {
                        oOrderNum = orderDAL.InsertOrder(pedidoMl, out messageError);
                    }
                }

                return(0);
            }
            catch (Exception e)
            {
                this.log.WriteLogPedido("Exception InserirPedidoVenda " + e.Message);
                throw;
            }
        }
Ejemplo n.º 8
0
        public static List <GetListStock> GetData(SAPbobsCOM.Company oCompany, string ItemGroup, DateTime UpdateFrom, DateTime UpdateTo)
        {
            Utils     control = new Utils();
            XDocument xDoc    = new XDocument();
            string    sql     = "SELECT T1.WhsCode,T2.ItmsGrpNam as 'ItemGroup',T0.ItemCode as 'ItemNo',T0.ItemName as 'ItemDescription', " +
                                "T0.INUoMEntry as 'UOM',T1.OnHand as 'InStock',T1.IsCommited as 'Commited',T1.OnOrder as 'Ordered', " +
                                "(T1.OnHand + T1.OnOrder - T1.IsCommited) as 'Available',  T1.AvgPrice as 'ItemPrice',((T1.OnHand + T1.OnOrder - T1.IsCommited) * isnull(T1.AvgPrice,0)) as 'Total' " +
                                " FROM  OITM T0" +
                                " LEFT JOIN OITW T1 on T1.ItemCode = T0.ItemCode" +
                                " LEFT JOIN OITB T2 on T2.ItmsGrpCod = T2.ItmsGrpCod " +
                                " Where T2.ItmsGrpNam = '" + ItemGroup + "' and T0.UpdateDate between '" + UpdateFrom + "' and '" + UpdateTo + "'";
            Recordset rs = control._IDU_Recordset(oCompany, sql);

            xDoc = XDocument.Parse(rs.GetAsXML());

            List <GetListStock> List = (from data in xDoc.Element("BOM").Element("BO").Element("OITM").Elements("row")
                                        select new GetListStock
            {
                WhsCode = data.Element("WhsCode").Value,
                ItemGroup = data.Element("ItemGroup").Value,
                ItemNo = data.Element("ItemNo").Value,
                ItemDescription = data.Element("ItemDescription").Value,
                UOM = data.Element("UOM").Value,
                InStock = Convert.ToDecimal(data.Element("InStock").Value),
                Commited = Convert.ToDecimal(data.Element("Commited").Value),
                Ordered = Convert.ToDecimal(data.Element("Ordered").Value),
                Available = Convert.ToDecimal(data.Element("Available").Value),
                ItemPrice = Convert.ToDecimal(data.Element("ItemPrice").Value),
                Total = Convert.ToDecimal(data.Element("Total").Value)
            }).ToList();

            return(List);
        }
Ejemplo n.º 9
0
        public static string AddData(SAPbobsCOM.Company oCompany, EXR model)
        {
            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";

            SAPbobsCOM.SBObob    oSBob = null;
            SAPbobsCOM.Recordset rs    = null;
            try
            {
                oCompany.StartTransaction();

                oSBob = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);
                rs    = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                rs    = oSBob.GetLocalCurrency();
                rs    = oSBob.GetSystemCurrency();

                oSBob.SetCurrencyRate(model.Currency, model.DateRate, model.Rate, true);
                oCompany.EndTransaction(BoWfTransOpt.wf_Commit);

                strResult = "OK";
            }
            catch (Exception e)
            {
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(BoWfTransOpt.wf_RollBack);
                }
                ;
                throw;
            }
            return(strResult);
        }
Ejemplo n.º 10
0
        public IHttpActionResult CreateItem(ItemDetails itemDetails)
        {
            //Inicializo mi conexión a SAP
            SAPConnection conncetion = new SAPConnection();

            SAPbobsCOM.Company company = conncetion.OpenConnection();

            SAPbobsCOM.Items oItems;
            oItems          = company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems);
            oItems.ItemCode = itemDetails.ItemCode;
            oItems.ItemName = itemDetails.ItemName;
            int status = oItems.Add();

            //Compruebo si el guardado se ha realizado correctamente
            if (status == 0)
            {
                responseCall.RespCode    = "00";
                responseCall.Description = "Guardado correctamente";
            }
            else
            {
                responseCall.RespCode    = "99";
                responseCall.Description = company.GetLastErrorDescription().ToString();
            }
            return(Ok(responseCall));
        }
Ejemplo n.º 11
0
        public static int ConnectToCompany(Company customCompany)
        {
            Translator = new TranslatorTool();
            Company    = customCompany;

            return(Company.Connect());
        }
Ejemplo n.º 12
0
        private void UpdateSBOSAP(ref SAPbobsCOM.Company oCompany, DateTime FecActSBO, Double USDObs, ref SAPbobsCOM.SBObob oSBObob, string moneda)
        {
            try
            {
                //if (SBO_VID_Currency.Properties.Settings.Default.TipoCambio == 1)
                //{
                //    cambioIndirecto = true;
                //    if (SBO_VID_Currency.Properties.Settings.Default.MonedaBaseIndirecta == "E")
                //        MonedaBase = EU;
                //    else
                //        MonedaBase = USDObs;
                //}
                //string s;

                try
                {
                    //s = SBO_VID_Currency.Properties.Settings.Default.Dolar;
                    if ((moneda != "") && (moneda != null))
                    {
                        oSBObob.SetCurrencyRate(moneda, FecActSBO, USDObs, false);
                        oLog.LogMsg("Valor a cargar Moneda: " + moneda + " Fecha:" + FecActSBO + " Valor: " + USDObs, "A", "I");
                    }
                }
                catch (Exception e)
                {
                    oLog.LogMsg("Tipo de cambio  " + moneda + " ya se encuentra ingresado en la sociedad " + e.Message, "A", "D");
                }
            }
            catch (Exception e)
            {
                oLog.LogMsg("Error al actualizar tasa de cambio en SBO - " + e.Message, "A", "E");
            }
        }
Ejemplo n.º 13
0
        public string connectCompay(SAPbobsCOM.Company cmp)
        {
            string outResult = "OK";

            oDiCompany = cmp;
            return(outResult);
        }
Ejemplo n.º 14
0
Archivo: Conn.cs Proyecto: bagundes/sdi
        public static void Connect(int serverType, string server, string database, string user, string passwd, string dbuser, string dbpasswd)
        {
            try
            {
                DI = new SAPbobsCOM.Company();
                DI.DbServerType = (BoDataServerTypes)serverType;
                DI.Server       = server;
                DI.language     = SAPbobsCOM.BoSuppLangs.ln_English;
                DI.CompanyDB    = database;
                DI.UserName     = user;
                DI.Password     = passwd;
                DI.DbUserName   = dbuser;
                DI.DbPassword   = dbpasswd;
                klib.Shell.WriteLine(R.Project.ID, LOG, $"SDI: Trying to connect {DI.Server} server");
                var res = DI.Connect();

                if (res != 0)
                {
                    Fail = true;
                    var error = DI.GetLastErrorDescription();
                    klib.Shell.WriteLine(R.Project.ID, LOG, $"SDI: Error {error}");
                    throw new SDIException(1, $"{DI.GetLastErrorCode()} - {error}");
                }
                else
                {
                    Fail = false;
                }

                klib.Shell.WriteLine(R.Project.ID, LOG, $"SDI: Connected with {DI.UserName} user");
            }
            finally
            {
            }
        }
Ejemplo n.º 15
0
        public static List <BP> GetData(SAPbobsCOM.Company oCompany)
        {
            Utils control = new Utils();

            string sql = "select CardCode, CardName ,Currency,Address,DebPayAcct,CardType, " +
                         " (CASE WHEN CardType = 'C' Then 'Customer' " +
                         " WHEN CardType = 'S' Then 'Supplier' " +
                         " else 'Lead' " +
                         " end) as 'TypeName' " +
                         " from ocrd";

            Recordset rs = control._IDU_Recordset(oCompany, sql);

            XDocument xDoc = new XDocument();

            xDoc = XDocument.Parse(rs.GetAsXML());

            List <BP> list = (from data in xDoc.Element("BOM").Element("BO").Element("ocrd").Elements("row")
                              select new BP
            {
                CardCode = data.Element("CardCode").Value,
                CardName = data.Element("CardName").Value,
                Address = data.Element("Address").Value,
                Currency = data.Element("Currency").Value,
                BPType = data.Element("TypeName").Value,
                DebtPayAccount = data.Element("DebPayAcct").Value
            }).ToList();

            return(list);
        }
Ejemplo n.º 16
0
        public static BP GetData(SAPbobsCOM.Company oCompany, string id)
        {
            Utils control = new Utils();

            string sql = " select CardCode, CardName,Currency,Address,DebPayAcct,CardType, " +
                         " (CASE WHEN CardType = 'C' Then 'Customer' " +
                         " WHEN CardType = 'S' Then 'Supplier' " +
                         " else 'Lead' " +
                         " end) as 'TypeName' " +
                         " from ocrd where CardCode = '" + id + "'";

            Recordset rs = control._IDU_Recordset(oCompany, sql);

            XDocument xDoc = new XDocument();

            xDoc = XDocument.Parse(rs.GetAsXML());
            XElement xEle = xDoc.Element("BOM").Element("BO").Element("ocrd").Element("row");

            BP model = new BP()
            {
                CardCode       = xEle.Element("CardCode").Value,
                CardName       = xEle.Element("CardName").Value,
                Address        = xEle.Element("Address").Value,
                Currency       = xEle.Element("Currency").Value,
                BPType         = xEle.Element("TypeName").Value,
                DebtPayAccount = xEle.Element("DebPayAcct").Value
            };

            return(model);
        }
Ejemplo n.º 17
0
        static SAPbobsCOM.Company CompanyConnection(string RegionID)
        {
            int    lErrCode = 0;
            int    lRetCode;
            string sErrMsg = "";

            if (RegionID == "1")
            {
                strSAPDBName = SGCompany;
            }


            SAPbobsCOM.Company oCompany       = new SAPbobsCOM.Company();
            string             strLicenseName = strSAPServer + ":30000";

            oCompany.Server        = strSAPServer;
            oCompany.DbServerType  = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2016;
            oCompany.CompanyDB     = strSAPDBName;
            oCompany.UserName      = strSAPUsername;
            oCompany.Password      = strSAPPwd;
            oCompany.DbUserName    = strSAPSQLUsername;
            oCompany.DbPassword    = strSAPSQLPwd;
            oCompany.UseTrusted    = false;
            oCompany.LicenseServer = strLicenseName;
            //Try to connect
            lRetCode = oCompany.Connect();
            if (lRetCode != 0) // if the connection failed
            {
                int    temp_int    = lErrCode;
                string temp_string = sErrMsg;
                oCompany.GetLastError(out temp_int, out temp_string);
            }
            return(oCompany);
        }
Ejemplo n.º 18
0
 static void Main(string[] args)
 {
     try
     {
         Application oApp = null;
         if (args.Length < 1)
         {
             oApp = new Application();
         }
         else
         {
             oApp = new Application(args[0]);
         }
         Menu MyMenu = new Menu();
         MyMenu.AddMenuItems();
         oApp.RegisterMenuEventHandler(MyMenu.SBO_Application_MenuEvent);
         Application.SBO_Application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent);
         // events handled by SBO_Application_MenuEvent
         Application.SBO_Application.MenuEvent += new SAPbouiCOM._IApplicationEvents_MenuEventEventHandler(SBO_Application_MenuEvent);
         // events handled by SBO_Application_ItemEvent
         Application.SBO_Application.ItemEvent += new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(SBO_Application_ItemEvent);
         // events handled by SBO_Application_FormDataEvent
         Application.SBO_Application.FormDataEvent   += new SAPbouiCOM._IApplicationEvents_FormDataEventEventHandler(SBO_Application_FormDataEvent);
         Application.SBO_Application.RightClickEvent += new SAPbouiCOM._IApplicationEvents_RightClickEventEventHandler(SBO_Application_RightClickEvent);
         Conexion.Conectar_Aplicacion();
         oCompany = Conexion.oCompany;
         Funciones.AgregarUDF_Salida_Inventario();
         NVerificaAgregaUDO.VerificarCrearUDO();
         oApp.Run();
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(ex.Message);
     }
 }
        public void IniciarIntegracaoCancelamentoPedido(SAPbobsCOM.Company oCompany)
        {
            try
            {
                //var test = Convert.ToDouble(testIn);
                Repositorio   repositorioCancelPedido = new Repositorio();
                OrderFiltered orders = new OrderFiltered();

                Task <HttpResponseMessage> responseOrderFiltered = repositorioCancelPedido.PedidosACancelar();

                if (responseOrderFiltered.Result.IsSuccessStatusCode)
                {
                    var jsonListOrderFiltered = responseOrderFiltered.Result.Content.ReadAsStringAsync().Result;

                    orders = JsonConvert.DeserializeObject <OrderFiltered>(jsonListOrderFiltered);

                    if (orders.list.Length > 0)
                    {
                        foreach (List item in orders.list)
                        {
                            if (item.currencyCode.Equals("BRL") && item.status.Equals("payment-pending"))
                            {
                                //string idFormaPagmt = pedido.paymentData.transactions.ElementAt<Transaction>(0).payments.ElementAt<Payment>(0).paymentSystem;

                                TimeSpan date = DateTime.Now - item.creationDate;

                                int qtdDias = date.Days;

                                if (qtdDias > System.Convert.ToInt32(ConfigurationManager.AppSettings["qtdDiasCancelemtno"]))
                                {
                                    //cancelar pedido com mais de 3 dias
                                    Task <HttpResponseMessage> responseCacelPedido = repositorioCancelPedido.CancelarPedido(item.orderId);

                                    if (responseCacelPedido.Result.IsSuccessStatusCode)
                                    {
                                        //pedido cancelado
                                        this.log.WriteLogPedido("Pedido " + item.orderId + " cancelado com sucesso." + responseCacelPedido.Result.ReasonPhrase);
                                        this.log.WriteLogTable(oCompany, EnumTipoIntegracao.Cancel, item.orderId, "", EnumStatusIntegracao.Sucesso, "Pedido " + item.orderId + " cancelado com sucesso.");
                                    }
                                    else
                                    {
                                        this.log.WriteLogPedido("Não foi possível cancelar pedido " + item.orderId + "." + responseCacelPedido.Result.ReasonPhrase);
                                        this.log.WriteLogTable(oCompany, EnumTipoIntegracao.Cancel, item.orderId, "", EnumStatusIntegracao.Erro, "Não foi possível cancelar pedido " + item.orderId + "." + responseCacelPedido.Result.ReasonPhrase);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    log.WriteLogPedido("Nenhum Pedido pendente a ser cancelado.");
                }
            }
            catch (Exception e)
            {
                this.log.WriteLogPedido("Exception IntegracaoCancelamentoPedido " + e.Message);
                throw;
            }
        }
Ejemplo n.º 20
0
        public static List <GRPO_HEADER> GetDataList(SAPbobsCOM.Company oCompany, DateTime FromDate, DateTime ToDate)
        {
            Utils control = new Utils();
            List <GRPO_DETAIL> details    = new List <GRPO_DETAIL>();
            XDocument          xDoc       = new XDocument();
            XDocument          xDocDetail = new XDocument();

            string sql = "select T0.DocEntry ,T0.DocNum as 'NumberForm',T0.DocDate as 'PostingDate',T0.DocDueDate as 'DueDate',T0.TaxDate as 'DocumentDate'" +
                         ",T0.CardCode as 'VendorCode',T0.CardName as 'VendorName',T0.DocStatus as 'Status',T0.Comments as 'Remarks'" +
                         " FROM OPDN T0 where DocDate between '" + FromDate + "' and '" + ToDate + "'";
            Recordset rs = control._IDU_Recordset(oCompany, sql);

            xDoc = XDocument.Parse(rs.GetAsXML());


            List <GRPO_HEADER> model = (from data in xDoc.Element("BOM").Element("BO").Element("OPDN").Elements("row")
                                        select new GRPO_HEADER
            {
                DocEntry = data.Element("DocEntry").Value,
                NumberForm = data.Element("NumberForm").Value,
                VendorCode = data.Element("VendorCode").Value,
                VendorName = data.Element("VendorName").Value,
                Status = data.Element("Status").Value,
                Remarks = data.Element("Remarks").Value,
                PostingDate = DateTime.ParseExact(data.Element("PostingDate").Value, "yyyyMMdd",
                                                  CultureInfo.InvariantCulture, DateTimeStyles.None),
                DueDate = DateTime.ParseExact(data.Element("DueDate").Value, "yyyyMMdd",
                                              CultureInfo.InvariantCulture, DateTimeStyles.None),
                DocumentDate = DateTime.ParseExact(data.Element("DocumentDate").Value, "yyyyMMdd",
                                                   CultureInfo.InvariantCulture, DateTimeStyles.None)
            }
                                        ).ToList();

            return(model);
        }
        public static string DeleteRecord(string UDO_Name, string CodigoObj)
        {
            SAPbobsCOM.GeneralService    oGeneralService = null;
            SAPbobsCOM.GeneralData       oGeneralData    = null;
            SAPbobsCOM.GeneralDataParams oGeneralParams  = null;
            SAPbobsCOM.CompanyService    sCmp            = null;
            SAPbobsCOM.Company           SBO_Company     = Conexion.oCompany;

            sCmp = SBO_Company.GetCompanyService();
            string rpta = "N";

            try
            {
                // Get a handle to the SM_MOR UDO
                oGeneralService = sCmp.GetGeneralService(UDO_Name);

                // Delete UDO record
                oGeneralParams = ((SAPbobsCOM.GeneralDataParams)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)));
                oGeneralParams.SetProperty("Code", CodigoObj);
                oGeneralData = oGeneralService.GetByParams(oGeneralParams);
                oGeneralService.Delete(oGeneralParams);
            }
            catch (Exception) {}
            return(rpta);
        }
        public static bool CheckUDOExists(string UDOName)
        {
            SAPbobsCOM.Company SBO_Company = Conexion.oCompany;

            SAPbobsCOM.UserObjectsMD oUdtMD = null /* TODO Change to default(_) if this is not a reference type */;
            bool ret = false;

            try
            {
                oUdtMD = (SAPbobsCOM.UserObjectsMD)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD);

                if (oUdtMD.GetByKey(UDOName))
                {
                    ret = true;
                }
                else
                {
                    ret = false;
                }
            }
            catch (Exception)
            {
                ret = false;
            }
            finally
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oUdtMD);
                oUdtMD = null /* TODO Change to default(_) if this is not a reference type */;
                GC.Collect();
            }

            return(ret);
        }
Ejemplo n.º 23
0
        private static void ButtonRefresh(string formUID, ref ItemEvent oItemEvent, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent, string sessionId)
        {
            bBubbleEvent = true;

            if (oItemEvent.BeforeAction)
            {
            }

            if (!oItemEvent.BeforeAction)
            {
                var oForm = sbo_application.Forms.Item(formUID);
                if (oItemEvent.EventType == BoEventTypes.et_ITEM_PRESSED)
                {
                    DBDataSource det = oForm.DataSources.DBDataSources.Item(pluginForm.dbDetalle);

                    for (int i = 0; i < det.Size; i++)
                    {
                    }

                    ((Matrix)oForm.Items.Item(pluginForm.MtxOV.Uid).Specific).LoadFromDataSourceEx();
                    ((Matrix)oForm.Items.Item(pluginForm.MtxOV.Uid).Specific).AutoResizeColumns();
                }

                //if (oForm.Mode == BoFormMode.fm_OK_MODE) oForm.Mode = BoFormMode.fm_UPDATE_MODE;
            }
        }
Ejemplo n.º 24
0
        public static void Release(string Servername, string Dbuser, string Dbpassword, string SAPDBName, string SAPUser, string SAPUserPassword, string SAPLicense)
        {
            try
            {
                SAPbobsCOM.Company oCompany = new SAPbobsCOM.Company();

                oCompany.DbServerType  = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2014;
                oCompany.Server        = Servername;
                oCompany.DbUserName    = Dbuser;
                oCompany.DbPassword    = Dbpassword;
                oCompany.CompanyDB     = SAPDBName;
                oCompany.UserName      = SAPUser;
                oCompany.Password      = SAPUserPassword;
                oCompany.LicenseServer = SAPLicense;

                if (oCompany.Connected)
                {
                    oCompany.Disconnect();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 25
0
        public static List <COA> GetData(SAPbobsCOM.Company oCompany, string id)
        {
            Utils control = new Utils();

            string sql = "AcctCode, AcctName,ActCurr,Postable,FatherNum,Levels,ActType, " +
                         "(CASE WHEN ActType = 'N' then 'Other' " +
                         " WHEN ActType = 'I' then 'Sales' " +
                         " WHEN ActType = 'E' then 'Expenditure'" +
                         " ELSE 'Not Defined'" +
                         "   end) 'TypeName'" +
                         "from OACT where AcctCode = '" + id + "'";

            Recordset rs = control._IDU_Recordset(oCompany, sql);

            XDocument xDoc = new XDocument();

            xDoc = XDocument.Parse(rs.GetAsXML());
            List <COA> list = (from data in xDoc.Element("BOM").Element("BO").Element("OACT").Elements("row")
                               select new COA
            {
                AccountCode = data.Element("AcctCode").Value,
                AccountName = data.Element("AcctName").Value,
                AccountCurrency = data.Element("ActCurr").Value,
                PostAble = data.Element("PostAble").Value,
                FatherAccount = data.Element("FatherNum").Value,
                AccountType = data.Element("TypeName").Value
            }).ToList();

            return(list);
        }
Ejemplo n.º 26
0
        private static void B1Connect(String version)
        {
            company     = (SAPbobsCOM.Company)AppDomain.CurrentDomain.GetData("SAPCompany");
            application = (SAPbouiCOM.Application)AppDomain.CurrentDomain.GetData("SAPApplication");

            try
            {
                // inception!
                if (application != null && company != null)
                {
                    applicationSponsor = new Sponsor <SAPbouiCOM.Application>(application);
                    companySponsor     = new Sponsor <SAPbobsCOM.Company>(company);
                    return;
                }
                SetApplication();
                company = (SAPbobsCOM.Company)application.Company.GetDICompany();
            }
            catch (Exception er)
            {
                Logger.Fatal(String.Format(Messages.ConnectionError, er.Message), er);
            }
            finally
            {
                if (company != null)
                {
                    b1Connected = company.Connected;
                }
            }
        }
Ejemplo n.º 27
0
        private static void updateLandedCost()
        {
            SAPbobsCOM.Company        oCompany        = Application.SBO_Application.Company.GetDICompany() as SAPbobsCOM.Company;
            SAPbobsCOM.CompanyService oCompanyService = oCompany.GetCompanyService() as SAPbobsCOM.CompanyService;
            LandedCostsService        LandedService   = oCompanyService.GetBusinessService(ServiceTypes.LandedCostsService) as LandedCostsService;

            LandedCostParams oLandedCostUpdateParams = LandedService.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCostParams) as LandedCostParams;
            LandedCost       oLandedCostUpdate       = LandedService.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCost) as LandedCost;

            oLandedCostUpdateParams.LandedCostNumber = 10;
            //LandedService.CancelLandedCost(oLandedCostUpdateParams);
            oLandedCostUpdate = LandedService.GetLandedCost(oLandedCostUpdateParams);

            // oLandedCostUpdate.LandedCost_ItemLines.Remove(0);
            // LandedCost_ItemLine oLandedCost_ItemLine;
            //oLandedCost_ItemLine = oLandedCostUpdate.LandedCost_ItemLines.Add();
            //oLandedCost_ItemLine.BaseDocumentType = LandedCostBaseDocumentTypeEnum.asGoodsReceiptPO;
            //oLandedCost_ItemLine.BaseEntry = 521;
            //oLandedCost_ItemLine.BaseLine = 1;


            ////LandedCost_CostLine oLandedCostUpdate_CostLine = oLandedCostUpdate.LandedCost_CostLines.Add();
            ////oLandedCostUpdate_CostLine.LandedCostCode = "CM";
            ////oLandedCostUpdate_CostLine.amount = 11;
            //LandedService.UpdateLandedCost(oLandedCostUpdate);
        }
Ejemplo n.º 28
0
        private static void AddLandedCostXML()
        {
            SAPbobsCOM.Company        oCompany        = Application.SBO_Application.Company.GetDICompany() as SAPbobsCOM.Company;
            SAPbobsCOM.CompanyService oCompanyService = oCompany.GetCompanyService() as SAPbobsCOM.CompanyService;
            LandedCostsService        LandedService   = oCompanyService.GetBusinessService(ServiceTypes.LandedCostsService) as LandedCostsService;
            LandedCost       oLandedCost     = LandedService.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCost) as LandedCost;
            LandedCostParams oCopiedLCParams = LandedService.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCostParams) as LandedCostParams;

            oCopiedLCParams.LandedCostNumber = 17;
            LandedCost oCopiedLC = LandedService.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCost) as LandedCost;

            oCopiedLC = LandedService.GetLandedCost(oCopiedLCParams);

            string k = XMLCleaner(oCopiedLC.ToXMLString(), oCopiedLC.LandedCostNumber + "", oCopiedLC.DocEntry + "");

            oLandedCost.FromXMLString(k);
            //Adding Costs
            LandedCost_CostLine oLandedCost_CostLine = oLandedCost.LandedCost_CostLines.Add();

            oLandedCost_CostLine.LandedCostCode = "TI";
            oLandedCost_CostLine.amount         = 10;


            LandedService.AddLandedCost(oLandedCost);
        }
Ejemplo n.º 29
0
        private static void FormClose(string formUID, ref ItemEvent oItemEvent, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent, string sessionId)
        {
            bBubbleEvent = true;
            if (oItemEvent.BeforeAction)
            {
                var HasChanges = false;
                var oForm      = sbo_application.Forms.Item(oItemEvent.FormUID);

                if (string.IsNullOrEmpty(oForm.DataSources.UserDataSources.Item(pluginForm.UDLotes).ValueEx.Trim()))
                {
                    for (int i = 0; i < oForm.DataSources.DataTables.Count; i++)
                    {
                        if (!HasChanges)
                        {
                            var dt = oForm.DataSources.DataTables.Item(i);
                            if (dt.Rows.Count > 0)
                            {
                                HasChanges = true;
                            }
                        }
                    }
                    if (HasChanges)
                    {
                        if (sbo_application.MessageBox("No ha asignado lotes al registro, ¿Está seguro que desea salir?", 2, "Si", "No") == 2)
                        {
                            bBubbleEvent = false;
                            return;
                        }
                    }
                }
            }
        }
Ejemplo n.º 30
0
        private static void Porcentajes(string formUID, ref ItemEvent oItemEvent, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent, string sessionId)
        {
            bBubbleEvent = true;
            if (oItemEvent.BeforeAction)
            {
            }

            if (!oItemEvent.BeforeAction)
            {
                var oForm = sbo_application.Forms.Item(formUID);
                if (oItemEvent.EventType == BoEventTypes.et_LOST_FOCUS)
                {
                    if (Regex.Match(oItemEvent.ColUID, @"\(([^)]*)\)").Groups[1].Value.Trim() != "%" || oItemEvent.ColUID.ToUpper().Contains("HUM"))
                    {
                        return;
                    }

                    var label    = ((StaticText)oForm.Items.Item($"st{oItemEvent.ItemUID.Replace("gr", "")}").Specific).Caption;
                    var _muestra = Regex.Replace(Regex.Match(label, @"\(([^)]*)\)").Groups[1].Value.Trim(), @"[^\d]", "");

                    var dt     = ((Grid)oForm.Items.Item(oItemEvent.ItemUID).Specific).DataTable;
                    var _value = dt.GetValue(oItemEvent.ColUID, oItemEvent.Row).ToString();

                    if (!string.IsNullOrEmpty(_muestra) && !string.IsNullOrEmpty(_value))
                    {
                        var _result = (_value.GetDoubleFromString(",") / _muestra.GetDoubleFromString(",")) * 100;
                        dt.SetValue(oItemEvent.ColUID, oItemEvent.Row, _result.GetStringFromDouble(2));
                    }
                }
            }
        }
Ejemplo n.º 31
0
        private static void B1Connect(String version)
        {
            company = (SAPbobsCOM.Company)AppDomain.CurrentDomain.GetData("SAPCompany");
            application = (SAPbouiCOM.Application)AppDomain.CurrentDomain.GetData("SAPApplication");

            try
            {
                // inception!
                if (application != null && company != null)
                {
                    applicationSponsor = new Sponsor<SAPbouiCOM.Application>(application);
                    companySponsor = new Sponsor<SAPbobsCOM.Company>(company);
                    return;
                }
                SetApplication();
                company = (SAPbobsCOM.Company)application.Company.GetDICompany();
            }
            catch (Exception er)
            {
                Logger.Fatal(String.Format(Messages.ConnectionError, er.Message), er);
            }
            finally
            {
                if (company != null)
                    b1Connected = company.Connected;
            }
        }
Ejemplo n.º 32
0
 internal static void LogOff()
 {
     if (b1Connected)
     {
         company.Disconnect();
         if (company != null)
         {
             System.Runtime.InteropServices.Marshal.ReleaseComObject(company);
             company = null;
         }
         if (application != null)
         {
             System.Runtime.InteropServices.Marshal.ReleaseComObject(application);
             application = null;
         }
         b1Connected = false;
     }
 }
Ejemplo n.º 33
0
 public static int ConnectToCompany(Company customCompany)
 {
     Translator = new TranslatorTool();
     Company = customCompany;
     
     return Company.Connect();
 }
Ejemplo n.º 34
0
        public int SetConnectionContext()
        {
            int setConnectionContextReturn = 0;
            string sCookie = null;
            string sConnectionContext = null;

            oCompany = new SAPbobsCOM.Company();
            sCookie = oCompany.GetContextCookie();
            sConnectionContext = SBO_Application.Company.GetConnectionContext(sCookie);

            if (oCompany.Connected == true)
            {
                oCompany.Disconnect();
            }
            setConnectionContextReturn = oCompany.SetSboLoginContext(sConnectionContext);

            return setConnectionContextReturn;
        }