Ejemplo n.º 1
0
        //Carga Formulario XML Personalizado
        public static void LoadFromXml(string fileName, string formName)
        {
            if (ActivateFormIsOpen(formName))
            {
                return;
            }

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(fileName);
            SBOApplication.LoadBatchActions(xmlDocument.InnerXml);
        }
Ejemplo n.º 2
0
        public override void initApp()
        {
            String XlsFile;
            String s;

            base.initApp();
            String  Local;
            Boolean bCargar = false;

            try
            {
                // compilacion SQL HANA
                GlobalSettings.SBO_f   = SBOFunctions;
                GlobalSettings.SBOMeta = SBOMetaData;
                //


                //oLog.LogFile = "C:\\Visualk\\xxx.log";
                oLog.LogFile = System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\VD.log";
                SAPbobsCOM.Recordset oRecordSet;
                oRecordSet = (SAPbobsCOM.Recordset)(SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset));
                try
                {
                    if (GlobalSettings.RunningUnderSQLServer)
                    {
                        s = "SELECT SUPERUSER FROM OUSR WHERE USER_CODE = '{0}'";
                    }
                    else
                    {
                        s = @"SELECT ""SUPERUSER"" FROM ""OUSR"" WHERE ""USER_CODE"" = '{0}'";
                    }
                    s = String.Format(s, SBOCompany.UserName.Trim());
                    oRecordSet.DoQuery(s);
                    if (((System.String)oRecordSet.Fields.Item("SUPERUSER").Value).Trim() == "Y")
                    {
                        bCargar = true;
                    }
                }
                catch
                {
                    if (bCargar == false)
                    {
                        SBOApplication.MessageBox("El addon se esta iniciando por primera vez, debe inicar con un super usuario");
                    }
                }
                finally
                {
                    SBOFunctions._ReleaseCOMObject(oRecordSet);
                    oRecordSet = null;
                }


                //if (SBOCompany.UserName == "manager")
                if (bCargar)
                {
                    XlsFile = System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\Docs\\UDFFELEC.xls";
                    if (!SBOFunctions.ValidEstructSHA1(XlsFile))
                    {
                        oLog.OutLog("InitApp: Estructura de datos 1 - Facturación Electronica");
                        SBOApplication.StatusBar.SetText("Inicializando AddOn Factura Electronica(1).", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning);
                        if (!SBOMetaData.SyncTablasUdos("1.1", XlsFile))
                        {
                            SBOFunctions.DeleteSHA1FromTable("EDAG.xls");
                            oLog.OutLog("InitApp: sincronización de Estructura de datos fallo");
                            CloseSplash();
                            SBOApplication.MessageBox("Estructura de datos con problemas, consulte a soporte...", 1, "Ok", "", "");
                            Halt(0);
                        }
                    }

                    XlsFile = System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\Docs\\UDFFELECCL.xls";
                    if (!SBOFunctions.ValidEstructSHA1(XlsFile))
                    {
                        oLog.OutLog("InitApp: Estructura de datos 2 - Facturación Electronica CL");
                        SBOApplication.StatusBar.SetText("Inicializando AddOn Factura Electronica(2).", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning);
                        if (!SBOMetaData.SyncTablasUdos("1.1", XlsFile))
                        {
                            SBOFunctions.DeleteSHA1FromTable("UDFFELECCL.xls");
                            oLog.OutLog("InitApp: sincronización de Estructura de datos fallo");
                            SBOApplication.MessageBox("Estructura de datos con problemas, consulte a soporte...", 1, "Ok", "", "");
                        }
                    }


                    XlsFile = System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\Docs\\UDFSAP.xls";
                    if (!SBOFunctions.ValidEstructSHA1(XlsFile))
                    {
                        oLog.OutLog("InitApp: Estructura de datos 3 - Facturación Electronica CL");
                        SBOApplication.StatusBar.SetText("Inicializando AddOn Factura Electronica(3).", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning);
                        if (!SBOMetaData.SyncTablasUdos("1.1", XlsFile))
                        {
                            SBOFunctions.DeleteSHA1FromTable("UDFSAP.xls");
                            oLog.OutLog("InitApp: sincronización de Estructura de datos fallo");
                            SBOApplication.MessageBox("Estructura de datos con problemas, consulte a soporte...", 1, "Ok", "", "");
                        }
                    }
                }

                oLog.DebugLvl             = 20;
                MainObj[0].GlobalSettings = GlobalSettings;
                MainObj[0].SBOApplication = SBOApplication;
                MainObj[0].SBOCompany     = SBOCompany;
                MainObj[0].oLog           = oLog;
                MainObj[0].SBOFunctions   = SBOFunctions;


                //SetFiltros();


                MainObj[0].AddMenus();

                InitOK = true;
                oLog.OutLog("App SBO in C# - Init!");
                SBOApplication.StatusBar.SetText("Aplicación Inicializada.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success);


                if (1 == 1) //(SBOFunctions.AccessStr.Substring(10,1) = 'P') then
                {
                    GlobalSettings.SBO_f      = SBOFunctions;
                    MainObj[0].GlobalSettings = GlobalSettings;
                    MainObj[0].SBOApplication = SBOApplication;
                    MainObj[0].SBOCompany     = SBOCompany;
                    MainObj[0].oLog           = oLog;
                    MainObj[0].SBOFunctions   = SBOFunctions;
                }

                SetFiltros();

                if (1 == 1) // (SBOFunctions.AccessStr.Substring(10,1) = 'P') then
                {
                    //MainObj[0].AddMenus();
                    SAPbouiCOM.Menus    oMenus    = null;
                    SAPbouiCOM.MenuItem oMenuItem = null;


                    System.Xml.XmlDocument oXmlDoc = null;
                    oXmlDoc = new System.Xml.XmlDocument();

                    oXmlDoc.Load(System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\Menus\\RemoveMenu.xml");


                    string sXML = oXmlDoc.InnerXml.ToString();
                    SBOApplication.LoadBatchActions(ref sXML);

                    oXmlDoc.Load(System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\Menus\\Menu.xml");

                    sXML = oXmlDoc.InnerXml.ToString();
                    SBOApplication.LoadBatchActions(ref sXML);

                    //GlobalSettings.AddMenusRepAux(False);
                    //GlobalSettings.AddMenusRepAux(True);
                }

                InitOK = true;
                oLog.OutLog("C# - Shine your crazy diamond!");
                SBOApplication.StatusBar.SetText("Aplicación Inicializada.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success);
            }
            catch (Exception ex)
            {
                oLog.OutLog("Error iniApp, " + ex.Message + ", TRACE " + ex.StackTrace);
            }
            finally
            {
                CloseSplash();
            }
        }