Ejemplo n.º 1
0
        }         // func RequestComAddInAutomationService

        #region -- Environment Handling -----------------------------------------------

        private PpsEnvironment FindOrCreateEnvironment(PpsEnvironmentInfo info)
        {
            var env = GetEnvironmentFromInfo(info);

            if (env == null)
            {
                env = new PpsEnvironment(lua, this, info);
                openEnvironments.Add(env);
            }
            return(env);
        }         // func FindOrCreateEnvironment
Ejemplo n.º 2
0
            }             // func GetCredentials

            /// <summary>Refresh environment list.</summary>
            /// <param name="getCurrentEnvironment"></param>
            /// <returns></returns>
            public async Task RefreshEnvironmentsAsync(Func <PpsEnvironmentInfo[], PpsEnvironmentInfo> getCurrentEnvironment)
            {
                // parse all environment
                environments = await Task.Run(() => PpsEnvironmentInfo.GetLocalEnvironments().ToArray());

                OnPropertyChanged(nameof(Environments));

                // update current environment
                if (environments.Length > 0)
                {
                    CurrentEnvironment = getCurrentEnvironment?.Invoke(environments) ?? environments[0];
                }
            }             // proc RefreshEnvironments
Ejemplo n.º 3
0
        }         // func FindEnvironment

        public void ActivateEnvironment(PpsEnvironmentInfo info)
        {
            if (info is null)
            {
                return;
            }

            var env = FindOrCreateEnvironment(info);

            if (AuthentificateEnvironment(env) != null)
            {
                SetCurrentEnvironment(env);
            }
        }         // proc ActivateEnvironment
Ejemplo n.º 4
0
        }         // proc RefreshUsername

        private void RefreshEnvironments()
        {
            // remove all instances
            loginGalery.Items.Clear();

            // readd them
            foreach (var cur in PpsEnvironmentInfo.GetLocalEnvironments().OrderBy(c => c.DisplayName))
            {
                var env          = Globals.ThisAddIn.GetEnvironmentFromInfo(cur);
                var ribbonButton = Factory.CreateRibbonDropDownItem();
                ribbonButton.Label     = cur.Name ?? cur.DisplayName;
                ribbonButton.ScreenTip = $"{ cur.Name} ({cur.DisplayName})";
                ribbonButton.SuperTip  =
                    env == null
                                                ? String.Format("Version {0}\nUri: {1}", cur.Version, cur.Uri.ToString())
                                                : String.Format("Angemeldet: {2}\nVersion {0}\nUri: {1}", cur.Version, cur.Uri.ToString(), env.UserName);

                ribbonButton.Tag   = cur;
                ribbonButton.Image = env != null && env.IsAuthentificated ? Properties.Resources.EnvironmentAuthImage : Properties.Resources.EnvironmentImage;
                loginGalery.Items.Add(ribbonButton);
            }
        }         // proc RefreshEnvironments
Ejemplo n.º 5
0
        }         // func AuthentificateEnvironment

        public PpsEnvironment FindEnvironment(string name, Uri uri)
        {
            return((PpsEnvironment)waitForm.Invoke(new Func <PpsEnvironment>(() =>
            {
                PpsEnvironment envByName = null;
                PpsEnvironmentInfo infoByName = null;
                PpsEnvironmentInfo infoByUri = null;

                foreach (var oe in openEnvironments)
                {
                    if (oe.Info.Name == name)
                    {
                        envByName = oe;
                        break;
                    }
                }

                if (envByName != null)
                {
                    return AuthentificateEnvironment(envByName);
                }

                foreach (var info in PpsEnvironmentInfo.GetLocalEnvironments())
                {
                    if (info.Name == name)
                    {
                        infoByName = info;
                        break;
                    }
                    else if (info.Uri == uri)
                    {
                        infoByUri = info;
                    }
                }

                return AuthentificateEnvironment(FindOrCreateEnvironment(infoByName ?? infoByUri)) ?? CurrentEnvironment;
            })));
        }         // func FindEnvironment
Ejemplo n.º 6
0
        }         // proc SetCurrentEnvironment

        public PpsEnvironment GetEnvironmentFromInfo(PpsEnvironmentInfo info)
        => openEnvironments.Find(c => c.Info == info);