Exemplo n.º 1
0
        /// <summary>
        /// Auxillary function that starts a process with additional options.
        /// </summary>
        /// <param name="cmd">Command to execute.</param>
        /// <param name="args">Arguments to pass to command.</param>
        /// <param name="show">Whether or not the process should be visible.</param>
        /// <param name="waitForExit">Whether or not the process should wait for termination.</param>
        /// <param name="redirectIO">What I/O should be redirected.</param>
        /// <returns>Handle to the newly created process.</returns>
        public static Process RunProcess(string cmd, string args, bool show, bool waitForExit, Redirector r)
        {
            if (!File.Exists(cmd))
            {
                MessageBox.Show("The database executable file could not be found. Please reinstall eFlash.",
                    "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(2);
                return null;
            }
            else
            {
                ProcessStartInfo psi = new ProcessStartInfo(cmd, args);
                Process p = new Process();

                if (!show) // run silently...
                {
                    psi.CreateNoWindow = true;
                    psi.UseShellExecute = false;
                }
                if (r == Redirector.i || r == Redirector.ie || r == Redirector.io || r == Redirector.all) psi.RedirectStandardInput = true;
                if (r == Redirector.o || r == Redirector.oe || r == Redirector.io || r == Redirector.all) psi.RedirectStandardOutput = true;
                if (r == Redirector.e || r == Redirector.ie || r == Redirector.oe || r == Redirector.all) psi.RedirectStandardError = true;

                p.StartInfo = psi;
                p.Start();

                if (waitForExit) p.WaitForExit();

                return p;
            }
        }
Exemplo n.º 2
0
        //public static Dictionary<string, bool> timerStarteds = new Dictionary<string, bool>();
        public Testing()
        {
            room = OrbIt.game.room;

            Redirector.PopulateDelegatesAll();
            redirector = new Redirector();

            //obints.CollectionChanged += (s, e) => { };
        }
Exemplo n.º 3
0
        private static async Task <ProcessOutputResult> RunGenerateContextScript(Redirector redirector, string interpreterPath, string templateFolderPath, string userConfigFilePath)
        {
            var scriptPath = PythonToolsInstallPath.GetFile("cookiecutter_load.py");

            return(await RunPythonScript(redirector, interpreterPath, scriptPath, "\"{0}\" \"{1}\"".FormatInvariant(templateFolderPath, userConfigFilePath)));
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                string         username    = tbxUsername.Text.Trim();
                UserRepository ar          = new UserRepository();
                enter          currentUser = ar.FindByUserName(Int64.Parse(username));


                if (currentUser == null)
                {
                    HadafTools.ShowMessage(lblmessage, "نام کاربری یافت نشد", Color.Red);

                    return;
                }

                if (Int64.Parse(tbxPassword.Text) != currentUser.Pass)
                {
                    HadafTools.ShowMessage(lblmessage, "رمز عبور اشتباه است", Color.Red);
                    return;
                }


                //if (DropDownList1.SelectedItem.Value == "1")
                //{
                //    string status = currentUser.Status.ToString();
                //    Session["value"] = "1";
                //    if (status == "0")
                //    {
                //      //  Session["reshte"]="1";
                //    string aa = tbxUsername.Text;
                //    Session["stdid"]=aa;
                //    Redirector.Goto(Redirector.PageName.COMNP);
                //    }
                //    else
                //    {
                //        if (status == "1")
                //        {
                //            string stdid = tbxUsername.Text;
                //            Session["studentid"] = stdid;
                //            Redirector.Goto(Redirector.PageName.StdUnit);
                //        }
                //    }


                //}



                string value = DropDownList1.SelectedItem.Value;
                switch (value)
                {
                case "1":
                {
                    Session["value"] = "1";
                }
                break;

                case "2":
                {
                    Session["value"] = "2";
                }
                break;

                case "3":
                {
                    Session["value"] = "3";
                }
                break;

                case "4":
                {
                    Session["value"] = "4";
                }
                break;

                case "5":
                {
                    Session["value"] = "5";
                }
                break;

                case "6":
                {
                    Session["value"] = "6";
                }
                break;

                case "7":
                {
                    Session["value"] = "7";
                }
                break;

                case "8":
                {
                    Session["value"] = "8";
                }
                break;

                case "9":
                {
                    Session["value"] = "9";
                }
                break;

                case "10":
                {
                    Session["value"] = "10";
                }
                break;

                case "11":
                {
                    Session["value"] = "11";
                }
                break;

                case "12":
                {
                    Session["value"] = "12";
                }
                break;

                case "13":
                {
                    Session["value"] = "13";
                }
                break;

                case "14":
                {
                    Session["value"] = "14";
                }
                break;

                case "15":
                {
                    Session["value"] = "15";
                }
                break;
                }


                string status = currentUser.Status.ToString();

                if (status == "0")
                {
                    //  Session["reshte"]="1";
                    string aa = tbxUsername.Text;
                    Session["stdid"] = aa;
                    Redirector.Goto(Redirector.PageName.register);
                }
                else
                {
                    if (status == "1")
                    {
                        string stdid = tbxUsername.Text;
                        Session["studentid"] = stdid;
                        Redirector.Goto(Redirector.PageName.studentunit);
                    }
                }
            }
            catch
            {
                HadafTools.ShowMessage(lblmessage, "اطلاعات شما نادرست است", Color.Red);
            }
        }    //ذفد
        protected override void OnCreate()
        {
            base.OnCreate();

            _site = (IServiceProvider)this;

            _pyService = _site.GetPythonToolsService();

            // TODO: Get PYEnvironment added to image list
            BitmapImageMoniker = KnownMonikers.DockPanel;
            Caption            = Strings.Environments;

            _outputWindow = OutputWindowRedirector.GetGeneral(_site);
            Debug.Assert(_outputWindow != null);
            _statusBar = _site.GetService(typeof(SVsStatusbar)) as IVsStatusbar;

            var list = new ToolWindow();

            list.Site = _site;
            try {
                list.TelemetryLogger = _site.GetPythonToolsService().Logger;
            } catch (Exception ex) {
                Debug.Fail(ex.ToUnhandledExceptionMessage(GetType()));
            }
            list.ViewCreated += List_ViewCreated;

            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentView.OpenInteractiveWindow,
                                         OpenInteractiveWindow_Executed,
                                         OpenInteractiveWindow_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentView.OpenInteractiveScripts,
                                         OpenInteractiveScripts_Executed,
                                         OpenInteractiveScripts_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentPathsExtension.StartInterpreter,
                                         StartInterpreter_Executed,
                                         StartInterpreter_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentPathsExtension.StartWindowsInterpreter,
                                         StartInterpreter_Executed,
                                         StartInterpreter_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         ApplicationCommands.Help,
                                         OnlineHelp_Executed,
                                         OnlineHelp_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         ToolWindow.UnhandledException,
                                         UnhandledException_Executed,
                                         UnhandledException_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentView.OpenInPowerShell,
                                         OpenInPowerShell_Executed,
                                         OpenInPowerShell_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentView.OpenInCommandPrompt,
                                         OpenInCommandPrompt_Executed,
                                         OpenInCommandPrompt_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentView.EnableIPythonInteractive,
                                         EnableIPythonInteractive_Executed,
                                         EnableIPythonInteractive_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentView.DisableIPythonInteractive,
                                         DisableIPythonInteractive_Executed,
                                         DisableIPythonInteractive_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentPathsExtension.OpenInBrowser,
                                         OpenInBrowser_Executed,
                                         OpenInBrowser_CanExecute
                                         ));

            Content = list;
        }
Exemplo n.º 6
0
        public void OnDestroy()
        {
            Redirector <NetInfoDetour> .Revert();

            anarchy = false;
        }
Exemplo n.º 7
0
        internal EnvironmentView(
            IInterpreterOptionsService service,
            IInterpreterRegistryService registry,
            IPythonInterpreterFactory factory,
            Redirector redirector
            )
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }
            if (factory.Configuration == null)
            {
                throw new ArgumentException("factory must include a configuration");
            }

            _service                 = service;
            _registry                = registry;
            Factory                  = factory;
            Configuration            = Factory.Configuration;
            LocalizedDisplayName     = Configuration.Description;
            IsBroken                 = !Configuration.IsRunnable();
            BrokenEnvironmentHelpUrl = "https://go.microsoft.com/fwlink/?linkid=863373";

            _withDb = factory as IPythonInterpreterFactoryWithDatabase;
            if (_withDb != null)
            {
                _withDb.IsCurrentChanged += Factory_IsCurrentChanged;
                IsCheckingDatabase        = _withDb.IsCheckingDatabase;
                IsCurrent = _withDb.IsCurrent;
            }


            if (_service.IsConfigurable(Factory.Configuration.Id))
            {
                IsConfigurable = true;
            }

            Description = Factory.Configuration.Description;
            IsDefault   = (_service != null && _service.DefaultInterpreterId == Configuration.Id);

            PrefixPath             = Factory.Configuration.PrefixPath;
            InterpreterPath        = Factory.Configuration.InterpreterPath;
            WindowsInterpreterPath = Factory.Configuration.WindowsInterpreterPath;

            Extensions = new ObservableCollection <object>();
            Extensions.Add(new EnvironmentPathsExtensionProvider());
            if (IsConfigurable)
            {
                Extensions.Add(new ConfigurationExtensionProvider(_service, alwaysCreateNew: false));
            }

            CanBeDefault = Factory.CanBeDefault();

            Company    = _registry.GetProperty(Factory.Configuration.Id, CompanyKey) as string ?? "";
            SupportUrl = _registry.GetProperty(Factory.Configuration.Id, SupportUrlKey) as string ?? "";

            LocalizedHelpText = Company;
        }
Exemplo n.º 8
0
        public override void OnLevelLoaded(LoadMode mode)
        {
            base.OnLevelLoaded(mode);
            if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame && mode != LoadMode.NewGameFromScenario)
            {
                return;
            }
            inGame = true;
            try
            {
                Utils.Log((object)$"Begin init version: {version}");
                this.ReleaseUnusedCitizenUnits();
                UIView objectOfType = UnityEngine.Object.FindObjectOfType <UIView>();
                if ((UnityEngine.Object)objectOfType != (UnityEngine.Object)null)
                {
                    this._iptGameObject = new GameObject("IptGameObject");
                    this._iptGameObject.transform.parent = objectOfType.transform;
                    this._iptGameObject.AddComponent <SimHelper>();
                    this._iptGameObject.AddComponent <LineWatcher>();
                    this._worldInfoPanel = new GameObject("PublicTransportStopWorldInfoPanel");
                    this._worldInfoPanel.transform.parent = objectOfType.transform;
                    this._worldInfoPanel.AddComponent <PublicTransportStopWorldInfoPanel>();
                    NetManagerMod.Init();
                    VehicleManagerMod.Init();
                    Redirector <BusAIDetour> .Deploy();

                    Redirector <PassengerTrainAIDetour> .Deploy();

                    Redirector <PassengerShipAIDetour> .Deploy();

                    Redirector <PassengerPlaneAIDetour> .Deploy();

                    Redirector <PassengerFerryAIDetour> .Deploy();

                    Redirector <PassengerBlimpAIDetour> .Deploy();

                    Redirector <TramAIDetour> .Deploy();

                    Redirector <CommonBuildingAIReverseDetour> .Deploy();

                    Redirector <PublicTransportStopButtonDetour> .Deploy();

                    Redirector <PublicTransportVehicleButtonDetour> .Deploy();

                    Redirector <PublicTransportWorldInfoPanelDetour> .Deploy();

                    BuildingExtension.Init();
                    LineWatcher.instance.Init();
                    TransportLineMod.Init();
                    VehiclePrefabs.Init();
                    SerializableDataExtension.instance.Loaded = true;
                    LocaleModifier.Init();
                    this._iptGameObject.AddComponent <VehicleEditor>();
                    this._iptGameObject.AddComponent <PanelExtenderLine>();
                    this._iptGameObject.AddComponent <PanelExtenderVehicle>();
                    this._iptGameObject.AddComponent <PanelExtenderCityService>();
                    Utils.Log((object)"Loading done!");
                }
                else
                {
                    Utils.LogError((object)"UIView not found, aborting!");
                }
            }
            catch (Exception ex)
            {
                Utils.LogError((object)("Error during initialization, IPT disables itself." + System.Environment.NewLine + "Please try again without any other mod." + System.Environment.NewLine + "Please upload your log file and post the link here if that didn't help:" + System.Environment.NewLine + "http://steamcommunity.com/workshop/filedetails/discussion/424106600/615086038663282271/" + System.Environment.NewLine + ex.Message + System.Environment.NewLine + (object)ex.InnerException + System.Environment.NewLine + ex.StackTrace));
                this.Deinit();
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a virtual environment. If virtualenv is not installed, the
        /// task will succeed but error text will be passed to the redirector.
        /// </summary>
        public static Task Create(IServiceProvider provider, IPythonInterpreterFactory factory, string path, Redirector output = null)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            factory.ThrowIfNotRunnable(nameof(factory));
            return(ContinueCreate(provider, factory, path, false, output));
        }
Exemplo n.º 10
0
        private static async Task ContinueCreate(IServiceProvider provider, IPythonInterpreterFactory factory, string path, bool useVEnv, Redirector output)
        {
            path = PathUtils.TrimEndSeparator(path);
            var name = Path.GetFileName(path);
            var dir  = Path.GetDirectoryName(path);

            if (output != null)
            {
                output.WriteLine(Strings.VirtualEnvCreating.FormatUI(path));
                if (provider.GetPythonToolsService().GeneralOptions.ShowOutputWindowForVirtualEnvCreate)
                {
                    output.ShowAndActivate();
                }
                else
                {
                    output.Show();
                }
            }

            var workspaceFactoryProvider = provider.GetComponentModel().GetService <WorkspaceInterpreterFactoryProvider>();

            using (workspaceFactoryProvider?.SuppressDiscoverFactories(forceDiscoveryOnDispose: true)) {
                // Ensure the target directory exists.
                Directory.CreateDirectory(dir);

                using (var proc = ProcessOutput.Run(
                           factory.Configuration.InterpreterPath,
                           new[] { "-m", useVEnv ? "venv" : "virtualenv", name },
                           dir,
                           UnbufferedEnv,
                           false,
                           output
                           )) {
                    var exitCode = await proc;

                    if (output != null)
                    {
                        if (exitCode == 0)
                        {
                            output.WriteLine(Strings.VirtualEnvCreationSucceeded.FormatUI(path));
                        }
                        else
                        {
                            output.WriteLine(Strings.VirtualEnvCreationFailedExitCode.FormatUI(path, exitCode));
                        }
                        if (provider.GetPythonToolsService().GeneralOptions.ShowOutputWindowForVirtualEnvCreate)
                        {
                            output.ShowAndActivate();
                        }
                        else
                        {
                            output.Show();
                        }
                    }

                    if (exitCode != 0 || !Directory.Exists(path))
                    {
                        throw new InvalidOperationException(Strings.VirtualEnvCreationFailed.FormatUI(path));
                    }
                }
            }
        }
Exemplo n.º 11
0
        private static async Task <bool> CompileAsync(string arguments, string workingDir, Redirector redirector)
        {
            Debug.Assert(!string.IsNullOrEmpty(arguments), $"{nameof(arguments)} should not be empty.");

            var pathToTsc = Path.Combine(TypeScriptCompilerLocator.GetDefaultVersion(), CompilerExe);

            redirector?.WriteLine($"=== {Resources.TscBuildStarted}: {pathToTsc} {arguments} ===");

            using (var process = ProcessOutput.Run(
                       pathToTsc,
                       new[] { arguments },
                       workingDir,
                       env: null,
                       visible: false,
                       redirector: redirector,
                       quoteArgs: false,
                       outputEncoding: Encoding.UTF8))
            {
                var whnd = process.WaitHandle;
                if (whnd == null)
                {
                    // Process failed to start, and any exception message has
                    // already been sent through the redirector
                    redirector.WriteErrorLine(string.Format(Resources.TscBuildError, pathToTsc));
                    return(false);
                }
                else
                {
                    var finished = await Task.Run(() => whnd.WaitOne());

                    if (finished)
                    {
                        Debug.Assert(process.ExitCode.HasValue, "tsc.exe process has not really exited");
                        // there seems to be a case when we're signalled as completed, but the
                        // process hasn't actually exited
                        process.Wait();

                        redirector.WriteErrorLine($"==== {Resources.TscBuildCompleted} ====");

                        return(process.ExitCode == 0);
                    }
                    else
                    {
                        process.Kill();
                        redirector.WriteErrorLine($"==== {Resources.TscBuildCanceled} ====");

                        return(false);
                    }
                }
            }
        }
Exemplo n.º 12
0
        // TODO: This is duplicated from Npm project
        // We should consider using InternalsVisibleTo to avoid code duplication
        internal static async Task <IEnumerable <string> > ExecuteNpmCommandAsync(
            Redirector redirector,
            string pathToNpm,
            string executionDirectory,
            string[] arguments,
            ManualResetEvent cancellationResetEvent)
        {
            IEnumerable <string> standardOutputLines = null;

            using (var process = ProcessOutput.Run(
                       pathToNpm,
                       arguments,
                       executionDirectory,
                       null,
                       false,
                       redirector,
                       quoteArgs: false,
                       outputEncoding: Encoding.UTF8 // npm uses UTF-8 regardless of locale if its output is redirected
                       ))
            {
                var whnd = process.WaitHandle;
                if (whnd == null)
                {
                    // Process failed to start, and any exception message has
                    // already been sent through the redirector
                    if (redirector != null)
                    {
                        redirector.WriteErrorLine("Error - cannot start npm");
                    }
                }
                else
                {
                    var handles = cancellationResetEvent != null ? new[] { whnd, cancellationResetEvent } : new[] { whnd };
                    var i       = await Task.Run(() => WaitHandle.WaitAny(handles));

                    if (i == 0)
                    {
                        Debug.Assert(process.ExitCode.HasValue, "npm process has not really exited");
                        process.Wait();
                        if (process.StandardOutputLines != null)
                        {
                            standardOutputLines = process.StandardOutputLines.ToList();
                        }
                    }
                    else
                    {
                        process.Kill();
                        if (redirector != null)
                        {
                            redirector.WriteErrorLine(string.Format(CultureInfo.CurrentCulture,
                                                                    "\r\n===={0}====\r\n\r\n",
                                                                    "npm command cancelled"));
                        }

                        if (cancellationResetEvent != null)
                        {
                            cancellationResetEvent.Reset();
                        }

                        throw new OperationCanceledException();
                    }
                }
            }
            return(standardOutputLines);
        }
Exemplo n.º 13
0
        public static async Task InstallPip(IServiceProvider provider, IPythonInterpreterFactory factory, bool elevate, Redirector output = null)
        {
            factory.ThrowIfNotRunnable("factory");

            var pipDownloaderPath = PythonToolsInstallPath.GetFile("pip_downloader.py");

            if (output != null)
            {
                output.WriteLine(Strings.PipInstalling);
                if (provider.GetPythonToolsService().GeneralOptions.ShowOutputWindowForPackageInstallation)
                {
                    output.ShowAndActivate();
                }
                else
                {
                    output.Show();
                }
            }
            using (var proc = ProcessOutput.Run(
                       factory.Configuration.InterpreterPath,
                       new[] { pipDownloaderPath },
                       factory.Configuration.PrefixPath,
                       null,
                       false,
                       output,
                       elevate: elevate
                       )) {
                var exitCode = await proc;
                if (output != null)
                {
                    if (exitCode == 0)
                    {
                        output.WriteLine(Strings.PipInstallSucceeded);
                    }
                    else
                    {
                        output.WriteLine(Strings.PipInstallFailedExitCode.FormatUI(exitCode));
                    }
                    if (provider.GetPythonToolsService().GeneralOptions.ShowOutputWindowForPackageInstallation)
                    {
                        output.ShowAndActivate();
                    }
                    else
                    {
                        output.Show();
                    }
                }
            }
        }
Exemplo n.º 14
0
        public static async Task <bool> Install(
            IServiceProvider provider,
            IPythonInterpreterFactory factory,
            string package,
            IServiceProvider site,
            bool elevate,
            Redirector output = null
            )
        {
            factory.ThrowIfNotRunnable("factory");

            if (!(await factory.FindModulesAsync("pip")).Any())
            {
                if (site != null)
                {
                    try {
                        await QueryInstallPip(factory, site, Strings.InstallPip, elevate, output);
                    } catch (OperationCanceledException) {
                        return(false);
                    }
                }
                else
                {
                    await InstallPip(provider, factory, elevate, output);
                }
            }

            if (output != null)
            {
                output.WriteLine(Strings.PackageInstalling.FormatUI(package));
                if (provider.GetPythonToolsService().GeneralOptions.ShowOutputWindowForPackageInstallation)
                {
                    output.ShowAndActivate();
                }
                else
                {
                    output.Show();
                }
            }

            using (var proc = Run(factory, output, elevate, "install", GetInsecureArg(factory, output), package)) {
                var exitCode = await proc;

                if (output != null)
                {
                    if (exitCode == 0)
                    {
                        output.WriteLine(Strings.PackageInstallSucceeded.FormatUI(package));
                    }
                    else
                    {
                        output.WriteLine(Strings.PackageInstallFailedExitCode.FormatUI(package, exitCode));
                    }
                    if (provider.GetPythonToolsService().GeneralOptions.ShowOutputWindowForPackageInstallation)
                    {
                        output.ShowAndActivate();
                    }
                    else
                    {
                        output.Show();
                    }
                }
                return(exitCode == 0);
            }
        }
Exemplo n.º 15
0
        private static async Task <ProcessOutputResult> RunRunScript(Redirector redirector, string interpreterPath, string templateFolderPath, string userConfigFilePath, string outputFolderPath, string contextPath)
        {
            var scriptPath = PythonToolsInstallPath.GetFile("cookiecutter_run.py");

            return(await RunPythonScript(redirector, interpreterPath, scriptPath, GetRunArguments(templateFolderPath, userConfigFilePath, outputFolderPath, contextPath)));
        }
Exemplo n.º 16
0
 public static Redirector Bind(this Redirector r1, Redirector r2)
 {
     return (path, query) => r1(path, query) ?? r2(path, query);
 }
Exemplo n.º 17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ds.PrepareScreen();

        PXGenericInqGrph genGraph = (PXGenericInqGrph)ds.DataGraph;

        if (genGraph.Design != null)
        {
            // Check access rights - they are handled by SiteMapProvider by URL
            // but GI can be opened by using different URLs (by ID and by Name)
            if (!PXGraph.ProxyIsActive && !PXGraph.GeneratorIsActive && this.Context != null)
            {
                string nodeUrl = PXUrl.IgnoreSystemParameters(PXUrl.ToRelativeUrl(this.Request.Url.ToString()));
                var    node    = PXSiteMap.Provider.FindSiteMapNodeUnsecure(nodeUrl);

                if (node == null || !node.IsAccessibleToUser(this.Context))
                {
                    // If there is no access to the GI itself or it is not in site map,
                    // consider it as a "Preview" mode in the GI designer and check access rights for the GI designer itself
                    var designerNode = PXSiteMap.Provider.FindSiteMapNodeByGraphType(typeof(PX.Data.Maintenance.GI.GenericInquiryDesigner).FullName);

                    if (designerNode == null)
                    {
                        Redirector.SmartRedirect(HttpContext.Current, PXUrl.MainPagePath);
                        return;
                    }
                }
            }

            if (genGraph.Design.PrimaryScreenID != null && PXList.Provider.IsList(genGraph.Design.PrimaryScreenID))
            {
                PXContext.Session.SetString(LastEntryScreenSessionKey, genGraph.Design.PrimaryScreenID);
            }

            // Clear saved searches in case if parameters changed
            if (genGraph.Design.DesignID != null && PXGenericInqGrph.ParametersChanged[genGraph.Design.DesignID.Value])
            {
                ds.SavedSearchesClear(true);
                PXGenericInqGrph.ParametersChanged[genGraph.Design.DesignID.Value] = false;
            }
        }
        else         // GI configuration with defined ID/Name does not exist in this company (for example, when changing company)
        {
            string screenID = PXContext.Session[LastEntryScreenSessionKey] as string;
            PXContext.Session.SetString("LastUrl", null);             // clear last url to prevent loading GI page again (Main page loads LastUrl when there is no ScreenID)
            string redirectUrl = PXUrl.MainPagePath;
            if (!String.IsNullOrEmpty(screenID))
            {
                redirectUrl += "?ScreenID=" + screenID;
            }
            Redirector.SmartRedirect(HttpContext.Current, redirectUrl);
        }
        PXContext.SetSlot <Guid?>("__GEN_INQ_DESIGN_ID__", genGraph.Design.DesignID);
        var phF = this.FindControl("cont2");

        if (!form.Visible)
        {
            //grid.GridStyles.ToolsCell.CssClass += " transparent";
            form.Parent.Parent.Visible = false;
        }
    }
Exemplo n.º 18
0
        protected override void OnCreate()
        {
            base.OnCreate();

            _pyService = _site.GetPythonToolsService();
            _uiThread  = _site.GetUIThread();

            _pyService.InteractiveOptions.Changed += InteractiveOptions_Changed;

            // TODO: Get PYEnvironment added to image list
            BitmapImageMoniker = KnownMonikers.DockPanel;
            Caption            = Strings.Environments;

            _outputWindow = OutputWindowRedirector.GetGeneral(_site);
            Debug.Assert(_outputWindow != null);
            _statusBar = _site.GetService(typeof(SVsStatusbar)) as IVsStatusbar;

            var list = new ToolWindow();

            list.ViewCreated  += List_ViewCreated;
            list.ViewSelected += List_ViewSelected;
            list.Site          = _site;
            try {
                list.TelemetryLogger = _pyService.Logger;
            } catch (Exception ex) {
                Debug.Fail(ex.ToUnhandledExceptionMessage(GetType()));
            }

            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentView.OpenInteractiveWindow,
                                         OpenInteractiveWindow_Executed,
                                         OpenInteractiveWindow_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentView.OpenInteractiveScripts,
                                         OpenInteractiveScripts_Executed,
                                         OpenInteractiveScripts_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentPathsExtension.StartInterpreter,
                                         StartInterpreter_Executed,
                                         StartInterpreter_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentPathsExtension.StartWindowsInterpreter,
                                         StartInterpreter_Executed,
                                         StartInterpreter_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         ApplicationCommands.Help,
                                         OnlineHelp_Executed,
                                         OnlineHelp_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         ToolWindow.UnhandledException,
                                         UnhandledException_Executed,
                                         UnhandledException_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentView.OpenInPowerShell,
                                         OpenInPowerShell_Executed,
                                         OpenInPowerShell_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentView.OpenInCommandPrompt,
                                         OpenInCommandPrompt_Executed,
                                         OpenInCommandPrompt_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentPathsExtension.OpenInBrowser,
                                         OpenInBrowser_Executed,
                                         OpenInBrowser_CanExecute
                                         ));
            list.CommandBindings.Add(new CommandBinding(
                                         EnvironmentView.Delete,
                                         DeleteEnvironment_Executed,
                                         DeleteEnvironment_CanExecute
                                         ));

            RegisterCommands(
                CommandAsyncToOleMenuCommandShimFactory.CreateCommand(GuidList.guidPythonToolsCmdSet, (int)PkgCmdIDList.cmdidAddEnvironment, new AddEnvironmentCommand(this))
                );

            Content = list;
        }
Exemplo n.º 19
0
 protected void btnOk_Click(object sender, EventArgs e)
 {
     Redirector.Redirect("~/Accounting/Debit-CreditMemoPanel.aspx");
 }
Exemplo n.º 20
0
 protected void btnOk_Click(object sender, EventArgs e)
 {
     Redirector.Redirect("~/Accounting/BookAdjustmentPanel.aspx");
 }
Exemplo n.º 21
0
        public static async Task <bool> Install(
            IServiceProvider provider,
            IPythonInterpreterFactory factory,
            IInterpreterOptionsService service,
            string package,
            Redirector output = null
            )
        {
            factory.ThrowIfNotRunnable("factory");

            var condaFactory = await TryGetCondaFactoryAsync(factory, service);;

            if (condaFactory == null)
            {
                throw new InvalidOperationException("Cannot find conda");
            }
            condaFactory.ThrowIfNotRunnable();

            if (output != null)
            {
                output.WriteLine(SR.GetString(SR.PackageInstalling, package));
                if (provider.GetPythonToolsService().GeneralOptions.ShowOutputWindowForPackageInstallation)
                {
                    output.ShowAndActivate();
                }
                else
                {
                    output.Show();
                }
            }

            using (var proc = ProcessOutput.Run(
                       condaFactory.Configuration.InterpreterPath,
                       new[] { "-m", "conda", "install", "--yes", "-n", factory.Configuration.PrefixPath, package },
                       factory.Configuration.PrefixPath,
                       UnbufferedEnv,
                       false,
                       output
                       )) {
                var exitCode = await proc;
                if (output != null)
                {
                    if (exitCode == 0)
                    {
                        output.WriteLine(SR.GetString(SR.PackageInstallSucceeded, package));
                    }
                    else
                    {
                        output.WriteLine(SR.GetString(SR.PackageInstallFailedExitCode, package, exitCode));
                    }
                    if (provider.GetPythonToolsService().GeneralOptions.ShowOutputWindowForPackageInstallation)
                    {
                        output.ShowAndActivate();
                    }
                    else
                    {
                        output.Show();
                    }
                }
                return(exitCode == 0);
            }
        }
 public CondaUI(ITaskHandler taskHandler, Redirector outputWindow, bool showAndActiveOutputWindow)
 {
     _taskHandler  = taskHandler;
     _outputWindow = outputWindow ?? throw new ArgumentNullException(nameof(outputWindow));
     _showAndActiveOutputWindow = showAndActiveOutputWindow;
 }
Exemplo n.º 23
0
 public VsPackageManagerUI(IServiceProvider provider, bool alwaysElevate = false)
 {
     _outputWindow  = OutputWindowRedirector.GetGeneral(provider);
     _options       = provider.GetPythonToolsService().GeneralOptions;
     _alwaysElevate = alwaysElevate;
 }
Exemplo n.º 24
0
        public void Start()
        {
            try
            {
                m_netTool = GameObject.FindObjectOfType <NetTool>();
                if (m_netTool == null)
                {
                    DebugUtils.Log("Net Tool not found");
                    enabled = false;
                    return;
                }

                bendingPrefabs.Clear();

                int count = PrefabCollection <NetInfo> .PrefabCount();

                for (uint i = 0; i < count; i++)
                {
                    NetInfo prefab = PrefabCollection <NetInfo> .GetPrefab(i);

                    if (prefab != null)
                    {
                        if (prefab.m_enableBendingSegments)
                        {
                            bendingPrefabs.Add(prefab);
                        }
                    }
                }

                Redirector <NetInfoDetour> .Deploy();

                collision = (ToolManager.instance.m_properties.m_mode & ItemClass.Availability.AssetEditor) == ItemClass.Availability.None;

                if (chirperAtlasAnarchy == null)
                {
                    LoadChirperAtlas();
                }

                chirperButton = UIView.GetAView().FindUIComponent <UIButton>("Zone");

                if (m_panel == null)
                {
                    m_tries = 0;
                    m_panel = UIView.GetAView().AddUIComponent(typeof(OptionsPanel)) as OptionsPanel;
                }
                else
                {
                    m_panel.m_anarchy.isChecked   = false;
                    m_panel.m_bending.isChecked   = true;
                    m_panel.m_snapping.isChecked  = true;
                    m_panel.m_collision.isChecked = collision;
                }

                DebugUtils.Log("Initialized");
            }
            catch (Exception e)
            {
                DebugUtils.Log("Start failed");
                DebugUtils.LogException(e);
                enabled = false;
            }
        }
Exemplo n.º 25
0
        public CookiecutterViewModel(ICookiecutterClient cutter, IGitHubClient githubClient, IGitClient gitClient, ICookiecutterTelemetry telemetry, Redirector outputWindow, ILocalTemplateSource installedTemplateSource, ITemplateSource feedTemplateSource, ITemplateSource gitHubTemplateSource, Action <string> openFolder)
        {
            _cutterClient      = cutter;
            _githubClient      = githubClient;
            _gitClient         = gitClient;
            _telemetry         = telemetry;
            _outputWindow      = outputWindow;
            _recommendedSource = feedTemplateSource;
            _installedSource   = installedTemplateSource;
            _githubSource      = gitHubTemplateSource;
            _openFolder        = openFolder;

            Installed   = new CategorizedViewModel(Strings.TemplateCategoryInstalled);
            Recommended = new CategorizedViewModel(Strings.TemplateCategoryRecommended);
            GitHub      = new CategorizedViewModel(Strings.TemplateCategoryGitHub);
            Custom      = new CategorizedViewModel(Strings.TemplateCategoryCustom);
        }
Exemplo n.º 26
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     Redirector.Goto(Redirector.PageName.AddEmployee);
 }
Exemplo n.º 27
0
        private async Task <bool> DownloadTypingsForPackages(IEnumerable <string> packages, Redirector redirector)
        {
            var typingsToAquire = GetNewTypingsToAcquire(packages);

            if (!typingsToAquire.Any())
            {
                return(true);
            }

            var success = await ExecuteTypingsTool(GetTypingsToolInstallArguments(packages), redirector);

            if (success)
            {
                _acquiredTypingsPackageNames.Value.UnionWith(typingsToAquire);
            }
            return(success);
        }
Exemplo n.º 28
0
        public CookiecutterClient(IServiceProvider provider, CookiecutterPythonInterpreter interpreter, Redirector redirector)
        {
            _provider    = provider;
            _interpreter = interpreter;
            var localAppDataFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

            _envFolderPath      = Path.Combine(localAppDataFolderPath, "Microsoft", "CookiecutterTools", "env");
            _envInterpreterPath = Path.Combine(_envFolderPath, "scripts", "python.exe");
            _redirector         = redirector;
        }
Exemplo n.º 29
0
 /// <summary>
 /// Creates a virtual environment using venv. If venv is not available,
 /// the task will succeed but error text will be passed to the
 /// redirector.
 /// </summary>
 public static Task CreateWithVEnv(IServiceProvider provider, IPythonInterpreterFactory factory, string path, Redirector output = null)
 {
     factory.ThrowIfNotRunnable();
     return(ContinueCreate(provider, factory, path, true, output));
 }
Exemplo n.º 30
0
        private static async Task <ProcessOutputResult> RunRenderContextScript(Redirector redirector, string interpreterPath, string templateFolderPath, string userConfigFilePath, string outputFolderPath, string contextPath)
        {
            var scriptPath = PythonToolsInstallPath.GetFile("cookiecutter_render.py");

            return(await RunPythonScript(redirector, interpreterPath, scriptPath, "\"{0}\" \"{1}\" \"{2}\" \"{3}\"".FormatInvariant(templateFolderPath, userConfigFilePath, PathUtils.TrimEndSeparator(outputFolderPath), contextPath)));
        }
Exemplo n.º 31
0
        /// <summary>
        /// Installs virtualenv. If pip is not installed, the returned task will
        /// succeed but error text will be passed to the redirector.
        /// </summary>
        public static Task <bool> Install(IServiceProvider provider, IPythonInterpreterFactory factory, Redirector output = null)
        {
            bool elevate = provider.GetPythonToolsService().GeneralOptions.ElevatePip;

            if (factory.Configuration.Version < new Version(2, 5))
            {
                if (output != null)
                {
                    output.WriteErrorLine("Python versions earlier than 2.5 are not supported by PTVS.");
                }
                throw new OperationCanceledException();
            }
            else if (factory.Configuration.Version == new Version(2, 5))
            {
                return(Pip.Install(provider, factory, "https://go.microsoft.com/fwlink/?LinkID=317970", elevate, output));
            }
            else
            {
                return(Pip.Install(provider, factory, "https://go.microsoft.com/fwlink/?LinkID=317969", elevate, output));
            }
        }
Exemplo n.º 32
0
        private static DateTime? TryGetLastWriteTimeUtc(string path, Redirector output = null) {
            try {
                return File.GetLastWriteTimeUtc(path);
            } catch (UnauthorizedAccessException ex) {
                if (output != null) {
                    output.WriteErrorLine(string.Format("Failed to access {0}: {1}", path, ex.Message));
#if DEBUG
                    output.WriteErrorLine(ex.ToString());
#endif
                }
            } catch (ArgumentException ex) {
                if (output != null) {
                    output.WriteErrorLine(string.Format("Failed to access {0}: {1}", path, ex.Message));
#if DEBUG
                    output.WriteErrorLine(ex.ToString());
#endif
                }
            } catch (PathTooLongException ex) {
                if (output != null) {
                    output.WriteErrorLine(string.Format("Failed to access {0}: {1}", path, ex.Message));
#if DEBUG
                    output.WriteErrorLine(ex.ToString());
#endif
                }
            } catch (NotSupportedException ex) {
                if (output != null) {
                    output.WriteErrorLine(string.Format("Failed to access {0}: {1}", path, ex.Message));
#if DEBUG
                    output.WriteErrorLine(ex.ToString());
#endif
                }
            }
            return null;
        }
Exemplo n.º 33
0
        private static async Task ContinueCreate(IServiceProvider provider, IPythonInterpreterFactory factory, string path, bool useVEnv, Redirector output)
        {
            path = CommonUtils.TrimEndSeparator(path);
            var name = Path.GetFileName(path);
            var dir  = Path.GetDirectoryName(path);

            if (output != null)
            {
                output.WriteLine(SR.GetString(SR.VirtualEnvCreating, path));
                if (provider.GetPythonToolsService().GeneralOptions.ShowOutputWindowForVirtualEnvCreate)
                {
                    output.ShowAndActivate();
                }
                else
                {
                    output.Show();
                }
            }

            // Ensure the target directory exists.
            Directory.CreateDirectory(dir);

            using (var proc = ProcessOutput.Run(
                       factory.Configuration.InterpreterPath,
                       new[] { "-m", useVEnv ? "venv" : "virtualenv", name },
                       dir,
                       UnbufferedEnv,
                       false,
                       output
                       )) {
                var exitCode = await proc;

                if (output != null)
                {
                    if (exitCode == 0)
                    {
                        output.WriteLine(SR.GetString(SR.VirtualEnvCreationSucceeded, path));
                    }
                    else
                    {
                        output.WriteLine(SR.GetString(SR.VirtualEnvCreationFailedExitCode, path, exitCode));
                    }
                    if (provider.GetPythonToolsService().GeneralOptions.ShowOutputWindowForVirtualEnvCreate)
                    {
                        output.ShowAndActivate();
                    }
                    else
                    {
                        output.Show();
                    }
                }

                if (exitCode != 0 || !Directory.Exists(path))
                {
                    throw new InvalidOperationException(SR.GetString(SR.VirtualEnvCreationFailed, path));
                }
            }
        }
Exemplo n.º 34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Redirectors"/> class.
 /// </summary>
 /// <param name="site">The site.</param>
 public Redirectors(Site site)
 {
     using(SqlConnection cn = Site.CreateConnection(true, true)) {
         cn.Open();
         SqlCommand cmd = new SqlCommand(@"select redirectorId, urlMatchPattern, urlToRedirectToMatch, errorMatch,
     case when [contentType] is null then '' else [contentType] end,
     case when [type] is null then '' else [type] end,
     case when [listOrder] is null then 0 else [listOrder] end,
     case when [enabled] is null then cast(0 as bit) else [enabled] end
     from redirector with (nolock)", cn);
         using(SqlDataReader r = cmd.ExecuteReader()) {
             while(r.Read()) {
                 Redirector d = new Redirector(r.GetGuid(0), r.GetString(1),
                 r.GetString(2), r.GetString(3), r.GetString(4), r.GetString(5),
                 r.GetInt32(6), r.GetBoolean(7));
                 List.Add(d);
             }
         }
         /* order the list */
         List.Sort(delegate(Redirector rdr1, Redirector rdr2) {
             return rdr2.Order.CompareTo(rdr1.Order);
         });
     }
 }
Exemplo n.º 35
0
 public CondaEnvironmentManagerUI(Redirector window)
 {
     _window = window;
 }