示例#1
0
        /// <summary>
        /// Crea los Menús de acuerdo al archivo XML
        /// </summary>
        public void AddMenus()
        {
            System.Xml.XmlDocument oXMLDoc = new System.Xml.XmlDocument();
            string FileName      = "MenuSAP.xml";
            string OONE_FldMenus = System.IO.Directory.GetCurrentDirectory() + "\\XMLConfig\\";

            try
            {
                if (!System.IO.File.Exists(OONE_FldMenus + FileName))
                {
                    SBO_Application.MessageBox("File Not Found: " + OONE_FldMenus + FileName);
                    salirAddon();
                }

                oForm = SBO_Application.Forms.GetFormByTypeAndCount(169, 1);
                oForm.Freeze(true);

                oXMLDoc.Load(OONE_FldMenus + FileName);
                SBO_Application.LoadBatchActions(oXMLDoc.InnerXml);
            }
            catch (Exception ex)
            {
                SBO_Application.MessageBox("Addon término de forma inesperada:" + ex.Message);
            }
            finally
            {
                oForm.Freeze(false);
                oForm.Update();
                oXMLDoc = null;
            }
        }
示例#2
0
 public void AddXML(string pathstr)
 {
     try
     {
         System.Xml.XmlDocument xmldoc       = new System.Xml.XmlDocument();
         System.IO.Stream       stream       = Assembly.GetExecutingAssembly().GetManifestResourceStream(pathstr);
         System.IO.StreamReader streamreader = new System.IO.StreamReader(stream, true);
         xmldoc.LoadXml(streamreader.ReadToEnd());
         streamreader.Close();
         oApplication.LoadBatchActions(xmldoc.InnerXml);
     }
     catch (Exception ex)
     {
         oApplication.StatusBar.SetText("Failed to Load XML,AddXMl Method Failed" + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);
     }
     finally
     {
     }
 }
示例#3
0
        /// <summary>
        /// Cargar XML para la creación del Menú.
        /// </summary>
        /// <param name="FileName">Nombre del archivo.</param>
        private void LoadFromXML(string FileName)
        {
            System.Xml.XmlDocument oXmlDoc = default(System.Xml.XmlDocument);

            oXmlDoc = new System.Xml.XmlDocument();

            string sPath = null;


            sPath = System.IO.Directory.GetCurrentDirectory() + "\\Forms";

            oXmlDoc.Load(sPath + "\\" + FileName + ".srf");

            _Application.LoadBatchActions(oXmlDoc.InnerXml);
        }
        public static void LoadFromXML(
            SAPbouiCOM.Application oApplication
            , ref string pFileName
            )
        {
            System.Xml.XmlDocument oXmlDoc = null;
            oXmlDoc = new System.Xml.XmlDocument();

            string sPath = null;

            sPath = System.Windows.Forms.Application.StartupPath;


            oXmlDoc.Load(sPath + "\\" + pFileName);

            string sXml = oXmlDoc.InnerXml.ToString();

            oApplication.LoadBatchActions(ref sXml);
        }
示例#5
0
        internal override void ProcessMenuAttribute(List <MenuAttribute> menus)
        {
            UIApplication appCommand;
            List <ApplicationMenusActionMenu> actionMenus = new List <ApplicationMenusActionMenu>();

            menus.Sort();


            foreach (var menu in menus)
            {
                if (!string.IsNullOrEmpty(menu.i18n))
                {
                    menu.String = i18NService.GetLocalizedString(menu.i18n);
                }

                if (application.Menus.Exists(menu.UniqueID) &&
                    RemoveIfNotEqual(menu))
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(menu.ValidateMethod) && menu.OriginalType != null &&
                    NotAuthorized(menu))
                {
                    continue;
                }

                var actionMenu = new ApplicationMenusActionMenu();

                Logger.Debug(String.Format(Messages.MenuProcess, menu.String, menu.UniqueID));

                actionMenu.Checked   = menu.Return(x => x.Checked, "0");
                actionMenu.Enabled   = menu.Return(x => x.Enabled, "1");
                actionMenu.FatherUID = menu.FatherUID;
                if (!string.IsNullOrWhiteSpace(menu.Image))
                {
                    actionMenu.Image = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, menu.Image);
                }
                actionMenu.String   = menu.String;
                actionMenu.Type     = ((int)menu.Type).ToString();
                actionMenu.UniqueID = menu.UniqueID;
                if (menu.Position > 0)
                {
                    actionMenu.Position = menu.Position.ToString();
                }
                actionMenus.Add(actionMenu);
            }
            appCommand = new UIApplication()
            {
                Menus = new ApplicationMenus[] {
                    new ApplicationMenus()
                    {
                        action = new ApplicationMenusAction[] {
                            new ApplicationMenusAction()
                            {
                                type = "add",
                                Menu = actionMenus.ToArray()
                            }
                        }
                    }
                }
            };

            string xml = appCommand.Serialize();

            Logger.Debug(DebugString.Format(Messages.MenuStart, xml));
            try
            {
                application.LoadBatchActions(ref xml);
            }
            catch (Exception e)
            {
                Logger.Error(String.Format(Messages.MenuError, e.Message), e);
                throw e;
            }
            ParseBatchResult(application.GetLastBatchResults());

            Logger.Debug(Messages.MenuEnd);
        }