Exemplo n.º 1
0
        // constructor
        public ControlsVisualHandler()
        {
            // get an instance of the MainWindow
            MWindow = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();

            // get 'Base Configuration' button
            //RadioButton btnConfigBase = (RadioButton)MWindow.FindName("btnConfigBase");

            // get settings panel
            WrapPanel wpControlLeftPane = (WrapPanel)MWindow.FindName("wpControlLeftPane");

            // get config wrappanel
            ControlWrapPanel = (WrapPanel)MWindow.FindName("ControlWrapPanel");

            // get all filter buttons from the Configs page
            List <RadioButton> _filterButtons = UIHandler.GetLogicalChildCollection <RadioButton>(wpControlLeftPane);//.Where(r => r.GroupName == "grpSettings").ToList();

            FilterButtons = _filterButtons;

            // setting grid containing right hand content
            Grid controlGrid = (Grid)MWindow.FindName("controlGrid");

            // get all right hand config panels that are dynamic
            var AllControlPanels = UIHandler.GetLogicalChildCollection <Border>(controlGrid).ToList();

            AllDynamicControlPanels = (from a in AllControlPanels
                                       where (a.Name.Length > 1 && !a.Name.Contains("NONDYNAMIC"))
                                       select a).ToList();

            GS = GlobalSettings.GetGlobals();
        }
        /// <summary>
        /// function to create window
        /// </summary>
        /// <param name="DisplayName">name of window</param>
        /// <returns>int (Window ID)</returns>
        private int CreateVerWindow(string DisplayName, string TabName)
        {
            // create new version window
            MWindow verWnd = new MWindow(GetCtx(), 0, Get_TrxName());

            verWnd.SetName(DisplayName + "_" + TabName);
            verWnd.SetDisplayName(DisplayName);
            // set window as Query Only
            verWnd.SetWindowType("Q");
            verWnd.SetDescription("Display version data");
            verWnd.SetHelp("The window allows you to view past data versioning and future updation versions (if any).");
            if (!verWnd.Save())
            {
                ValueNamePair vnp   = VLogger.RetrieveError();
                string        error = "";
                if (vnp != null)
                {
                    error = vnp.GetName();
                    if (error == "" && vnp.GetValue() != null)
                    {
                        error = vnp.GetValue();
                    }
                }
                if (error == "")
                {
                    error = "Error in creating Version Window";
                }
                log.Log(Level.SEVERE, "Version Window not Created :: " + DisplayName + " :: " + error);
                Get_TrxName().Rollback();
                return(0);
            }
            // Return Window ID
            return(verWnd.GetAD_Window_ID());
        }
Exemplo n.º 3
0
        /// <summary>
        /// After Save.
        /// </summary>
        /// <param name="newRecord">new record</param>
        /// <param name="success">success</param>
        /// <returns>true if save complete (if not overwritten true)</returns>
        protected override bool AfterSave(bool newRecord, bool success)
        {
            log.Fine("Success=" + success);
            if (success && newRecord)
            {
                //	save all nodes -- Creating new Workflow
                MWFNode[] nodes = GetNodesInOrder(0);
                for (int i = 0; i < nodes.Length; i++)
                {
                    nodes[i].Save(Get_Trx());
                }
            }

            if (newRecord)
            {
                int             AD_Role_ID = GetCtx().GetAD_Role_ID();
                MWorkflowAccess wa         = new MWorkflowAccess(this, AD_Role_ID);
                wa.Save();
            }
            //	Menu/Workflow
            else if (Is_ValueChanged("IsActive") || Is_ValueChanged("Name") ||
                     Is_ValueChanged("Description") || Is_ValueChanged("Help"))
            {
                MMenu[] menues = MMenu.Get(GetCtx(), "AD_Workflow_ID=" + GetAD_Workflow_ID());
                for (int i = 0; i < menues.Length; i++)
                {
                    menues[i].SetIsActive(IsActive());
                    menues[i].SetName(GetName());
                    menues[i].SetDescription(GetDescription());
                    menues[i].Save();
                }
                X_AD_WF_Node[] nodes = MWindow.GetWFNodes(GetCtx(), "AD_Workflow_ID=" + GetAD_Workflow_ID());
                for (int i = 0; i < nodes.Length; i++)
                {
                    bool changed = false;
                    if (nodes[i].IsActive() != IsActive())
                    {
                        nodes[i].SetIsActive(IsActive());
                        changed = true;
                    }
                    if (nodes[i].IsCentrallyMaintained())
                    {
                        nodes[i].SetName(GetName());
                        nodes[i].SetDescription(GetDescription());
                        nodes[i].SetHelp(GetHelp());
                        changed = true;
                    }
                    if (changed)
                    {
                        nodes[i].Save();
                    }
                }
            }

            return(success);
        }
Exemplo n.º 4
0
        protected override string DoIt()
        {
            MModuleWindow mWindow = new MModuleWindow(GetCtx(), GetRecord_ID(), null);

            _windowNo = mWindow.GetAD_Window_ID();

            if (_windowNo == 0)
            {
                return(Msg.GetMsg(GetCtx(), "VIS_WindowNotFound"));
            }

            MWindow window = new MWindow(GetCtx(), _windowNo, null);

            MTab[] tabs = window.GetTabs(false, null);
            if (tabs == null || tabs.Length == 0)
            {
                return(Msg.GetMsg(GetCtx(), "VIS_TabNotFound"));
            }

            string      sql = "select AD_Tab_ID,AD_ModuleTab_ID FROM AD_ModuleTab WHERE isActive='Y' AND ad_modulewindow_id=" + mWindow.GetAD_ModuleWindow_ID();
            IDataReader idr = DB.ExecuteReader(sql);
            DataTable   dt  = new DataTable();

            dt.Load(idr);
            idr.Close();

            Dictionary <int, int> existingTabs = new Dictionary <int, int>();

            foreach (DataRow dr in dt.Rows)
            {
                existingTabs[Convert.ToInt32(dr["AD_Tab_ID"])] = Convert.ToInt32(dr["AD_ModuleTab_ID"]);
            }

            for (int i = 0; i < tabs.Length; i++)
            {
                MModuleTab mTab = null;
                if (existingTabs.ContainsKey(tabs[i].GetAD_Tab_ID()))
                {
                    mTab = new MModuleTab(GetCtx(), existingTabs[tabs[i].GetAD_Tab_ID()], null);
                    InsertORUpdateFields(tabs[i].GetAD_Tab_ID(), mTab);
                }
                else
                {
                    mTab = new MModuleTab(GetCtx(), 0, null);

                    mTab.SetAD_Tab_ID(tabs[i].GetAD_Tab_ID());
                    mTab.SetAD_ModuleWindow_ID(GetRecord_ID());
                    if (mTab.Save())
                    {
                        InsertORUpdateFields(tabs[i].GetAD_Tab_ID(), mTab);
                    }
                }
            }

            return("Done");
        }
Exemplo n.º 5
0
 public Loader(MWindow mainWindow)
 {
     this.mWindow = mainWindow;
 }
Exemplo n.º 6
0
        // Constructor
        public SettingsVisualHandler()
        {
            // get an instance of the MainWindow
            MWindow = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();

            // get 'show all settings' button and click it
            RadioButton btnAllSettings = (RadioButton)MWindow.FindName("btnAllSettings");
            //btnAllSettings.IsChecked = true;

            // get settings grid
            WrapPanel wpSettingsLeftPane = (WrapPanel)MWindow.FindName("wpSettingsLeftPane");

            // get all filter buttons from the settings page
            List <RadioButton> _filterButtons = UIHandler.GetLogicalChildCollection <RadioButton>(wpSettingsLeftPane);//.Where(r => r.GroupName == "grpSettings").ToList();

            FilterButtons = _filterButtons;

            // setting grid containing right hand content
            Grid SettingGrid = (Grid)MWindow.FindName("SettingGrid");

            // get all settings panels
            //AllSettingPanels = UIHandler.GetLogicalChildCollection<Border>("SettingGrid").ToList();

            AllSettingPanels = UIHandler.GetLogicalChildCollection <Border>(SettingGrid).ToList();


            // iterate through each panel and match the border x:name to the class property name
            foreach (Border b in AllSettingPanels)
            {
                // remove any trailing numerals from the control name
                string name = StripTrailingNumerals(b.Name);

                // if the control name matches a property name in this class, add it to that list
                PropertyInfo property = typeof(SettingsVisualHandler).GetProperty(name);
                if (property == null)
                {
                    // no property matched
                    continue;
                }

                // add the border control to the correct List
                switch (property.Name)
                {
                case "MednafenPaths":
                    MednafenPaths.Add(b);
                    break;

                case "GameFolders":
                    GameFolders.Add(b);
                    break;

                case "SystemBios":
                    SystemBios.Add(b);
                    break;

                case "Netplay":
                    Netplay.Add(b);
                    break;

                case "Emulator":
                    Emulator.Add(b);
                    break;

                case "MedLaunch":
                    MedLaunch.Add(b);
                    break;

                case "Library":
                    Library.Add(b);
                    break;

                case "ScrapingSettings":
                    ScrapingSettings.Add(b);
                    break;

                default:
                    // do nothing
                    break;
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Assign/UnAssign windows from group to role
        /// </summary>
        /// <param name="AD_Group_ID"></param>
        /// <param name="AD_Role_ID"></param>
        /// <param name="grantAccess"></param>
        private void ProvideWindowAccessToRole(int AD_Group_ID, int AD_Role_ID, bool grantAccess)
        {
            string                 sql                    = "SELECT AD_Window_ID from AD_Group_Window WHERE IsActive='Y' AND AD_GroupInfo_ID=" + AD_Group_ID;
            DataSet                ds                     = DB.ExecuteDataset(sql);
            List <int>             groupWindowIDs         = new List <int>();             // will contains all windows of group
            Dictionary <int, bool> roleWindowIDsDictinary = new Dictionary <int, bool>(); // this will contain all windows access for current role...
            StringBuilder          winIDs                 = new StringBuilder();

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (ds.Tables[0].Rows[i]["AD_Window_ID"] != null && ds.Tables[0].Rows[i]["AD_Window_ID"] != DBNull.Value)
                    {
                        if (winIDs.Length > 0)
                        {
                            winIDs.Append(",");
                        }
                        winIDs.Append(ds.Tables[0].Rows[i]["AD_Window_ID"].ToString());
                        groupWindowIDs.Add(Convert.ToInt32(ds.Tables[0].Rows[i]["AD_Window_ID"]));
                    }
                }

                groupWindowIDs.Sort();

                // get windowsID from WIndow Access for current role and windows in group
                sql = "SELECT AD_Window_ID,IsReadWrite FROM AD_Window_Access WHERE AD_Role_ID=" + AD_Role_ID + " AND AD_Window_ID IN(" + winIDs.ToString() + ")";
                ds  = DB.ExecuteDataset(sql);
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        roleWindowIDsDictinary[Convert.ToInt32(ds.Tables[0].Rows[i]["AD_Window_ID"])] = ds.Tables[0].Rows[i]["IsReadWrite"].ToString() == "Y" ? true : false;
                    }
                }

                for (int i = 0; i < groupWindowIDs.Count(); i++)
                {
                    if (roleWindowIDsDictinary.ContainsKey(groupWindowIDs[i]))      // if Role window access already have current window then set window active/ inactive in window access.
                    {
                        if (roleWindowIDsDictinary[groupWindowIDs[i]] != grantAccess)
                        {
                            //wAccess.SetIsReadWrite(grantAccess);
                            //bool savenew = wAccess.Save();
                            if (grantAccess)
                            {
                                sql = "UPDATE AD_Window_Access Set IsReadWrite='Y',IsActive='Y' WHERE AD_Window_ID=" + groupWindowIDs[i] + " AND AD_Role_ID=" + AD_Role_ID;
                            }
                            else
                            {
                                sql = "UPDATE AD_Window_Access Set IsReadWrite='N',IsActive='N' WHERE AD_Window_ID=" + groupWindowIDs[i] + " AND AD_Role_ID=" + AD_Role_ID;
                            }
                            DB.ExecuteQuery(sql, null, null);
                        }
                    }
                    else                // Else create new entry....
                    {
                        MWindow       wind    = new MWindow(ctx, groupWindowIDs[i], null);
                        MWindowAccess wAccess = new MWindowAccess(wind, AD_Role_ID);
                        wAccess.SetAD_Client_ID(ctx.GetAD_Client_ID());
                        wAccess.SetAD_Org_ID(ctx.GetAD_Org_ID());
                        wAccess.SetAD_Role_ID(AD_Role_ID);
                        wAccess.SetAD_Window_ID(groupWindowIDs[i]);
                        wAccess.SetIsReadWrite(grantAccess);
                        bool savenew = wAccess.Save();
                    }
                }
            }
        }
Exemplo n.º 8
0
 public Refresher(MWindow mWindow)
 {
     this.mWindow = mWindow;
 }