Esempio n. 1
0
        private void LoadMenuFromXML(string FileName, string iconPath)
        {
            try
            {
                string sPath = null;
                System.Reflection.Assembly thisExe = null;
                thisExe = System.Reflection.Assembly.GetExecutingAssembly();
                System.IO.Stream file = thisExe.GetManifestResourceStream(FileName);
                string           xml  = null;

                // Using
                System.IO.StreamReader sr = new System.IO.StreamReader(file);

                try
                {
                    xml = sr.ReadToEnd();
                }
                catch (Exception EX)
                {
                }
                finally
                {
                    ((IDisposable)sr).Dispose();
                }

                sPath = System.Windows.Forms.Application.StartupPath + "\\";
                xml   = xml.Replace("Payroll.bmp", sPath + "Payroll.bmp");
                //'// load the form to the SBO application in one batch
                oApplication.LoadBatchActions(xml);
                sPath = oApplication.GetLastBatchResults();
            }
            catch (Exception ex)
            {
                oApplication.MessageBox(ex.Message + " " + FileName);
            }
        }
Esempio n. 2
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);
        }