public void RefreshScripts()
        {
            try
            {
                RenameScripts.Clear();

                List <VM_RenameScript> scripts = VM_ShokoServer.Instance.ShokoServices.GetAllRenameScripts()
                                                 .Cast <VM_RenameScript>()
                                                 .OrderBy(a => a.ScriptName)
                                                 .ToList();

                if (scripts.Count > 0)
                {
                    int idx = 0;
                    if (defaultScriptID.HasValue)
                    {
                        foreach (VM_RenameScript scr in scripts)
                        {
                            if (scr.RenameScriptID == defaultScriptID)
                            {
                                break;
                            }
                            idx++;
                        }
                    }

                    foreach (VM_RenameScript scr in scripts)
                    {
                        RenameScripts.Add(scr);
                    }

                    cboScript.SelectedIndex = idx;
                }
                else
                {
                    defaultScriptID = null;
                }

                ScriptProcessors.Clear();
                var scriptControllers = VM_ShokoServer.Instance.ShokoServices.GetScriptTypes();
                int idxi = 0;
                foreach (var controller in scriptControllers)
                {
                    ScriptProcessors.Add(new Controller {
                        RenamerType = controller.Key, Description = controller.Value
                    });
                    if (controller.Key == (cboScript.SelectedValue as VM_RenameScript)?.RenamerType)
                    {
                        cboController.SelectedIndex = idxi;
                    }
                    idxi++;
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Example #2
0
        public void RefreshScripts()
        {
            try
            {
                RenameScripts.Clear();

                List <RenameScriptVM> scripts = new List <RenameScriptVM>();

                foreach (JMMServerBinary.Contract_RenameScript raw in JMMServerVM.Instance.clientBinaryHTTP.GetAllRenameScripts())
                {
                    scripts.Add(new RenameScriptVM(raw));
                }

                // sort by scrit name
                List <SortPropOrFieldAndDirection> sortCriteria = new List <SortPropOrFieldAndDirection>();
                sortCriteria.Add(new SortPropOrFieldAndDirection("ScriptName", false, SortType.eString));
                scripts = Sorting.MultiSort <RenameScriptVM>(scripts, sortCriteria);

                if (scripts.Count > 0)
                {
                    int idx = 0;
                    if (defaultScriptID.HasValue)
                    {
                        foreach (RenameScriptVM scr in scripts)
                        {
                            if (scr.RenameScriptID.Value == defaultScriptID.Value)
                            {
                                break;
                            }
                            idx++;
                        }
                    }

                    foreach (RenameScriptVM scr in scripts)
                    {
                        RenameScripts.Add(scr);
                    }

                    cboScript.SelectedIndex = idx;
                }
                else
                {
                    defaultScriptID = null;
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Example #3
0
        public void RefreshScripts()
        {
            try
            {
                RenameScripts.Clear();

                List <VM_RenameScript> scripts = VM_ShokoServer.Instance.ShokoServices.GetAllRenameScripts().Cast <VM_RenameScript>().OrderBy(a => a.ScriptName).ToList();

                if (scripts.Count > 0)
                {
                    int idx = 0;
                    if (defaultScriptID.HasValue)
                    {
                        foreach (VM_RenameScript scr in scripts)
                        {
                            if (scr.RenameScriptID == defaultScriptID)
                            {
                                break;
                            }
                            idx++;
                        }
                    }

                    foreach (VM_RenameScript scr in scripts)
                    {
                        RenameScripts.Add(scr);
                    }

                    cboScript.SelectedIndex = idx;
                }
                else
                {
                    defaultScriptID = null;
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }