Ejemplo n.º 1
0
 private void OnOutputRecieved(OpenVPNConfiguration pCon, OutputLine pLine)
 {
     if (OutputRecieved != null)
     {
         OutputRecieved(pCon, pLine);
     }
 }
Ejemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            Assert.CanRunApplication("PowerShell/PowerShell Console");
            base.OnLoad(e);
            Settings = ApplicationSettings.GetInstance(ApplicationNames.Context, false);
            HttpContext.Current.Response.AddHeader("X-UA-Compatible", "IE=edge");
            var settings = ApplicationSettings.GetInstance(ApplicationNames.AjaxConsole, false);

            if (!Context.ClientPage.IsEvent)
            {
                var db       = Factory.GetDatabase(ApplicationSettings.ScriptLibraryDb);
                var fonts    = db.GetItem(ApplicationSettings.FontNamesPath);
                var font     = string.IsNullOrEmpty(settings.FontFamily) ? "monospace" : settings.FontFamily;
                var fontItem = fonts.Children[font];
                font = fontItem != null
                    ? fontItem["Phrase"]
                    : "Monaco, Menlo, \"Ubuntu Mono\", Consolas, source-code-pro, monospace";

                Options.Text = @"<script type='text/javascript'>" +
                               @"$ise(function() { cognifide.powershell.setOptions({ initialPoll: " +
                               WebServiceSettings.InitialPollMillis + @", maxPoll: " +
                               WebServiceSettings.MaxmimumPollMillis + @", fontSize: " +
                               settings.FontSize + $", fontFamily: '{font}' }});}});</script>" +
                               @"<style>#terminal {" +
                               $"color: {OutputLine.ProcessHtmlColor(settings.ForegroundColor)};" +
                               $"background-color: {OutputLine.ProcessHtmlColor(settings.BackgroundColor)};" +
                               $"font-family: inherit;" + "}</style>";
            }
            SheerResponse.SetDialogValue("ok");
        }
Ejemplo n.º 3
0
        public void OnDeleteFinished(object sender, EventArgs e)
        {
            OutputLine line = sender as OutputLine;

            StoreFactory.HalProxy.MakeToast(ShopNavi.Resources.TextResource.DeletingLine);
            line.DeleteCmd.Execute(sender);
        }
Ejemplo n.º 4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var          sid      = WebUtil.GetQueryString("sid");
            var          settings = ApplicationSettings.GetInstance(ApplicationNames.Context, false);
            ConsoleColor fc;
            ConsoleColor bc;

            if (!Enum.TryParse(WebUtil.GetQueryString("fc"), true, out fc))
            {
                fc = settings.ForegroundColor;
            }
            if (!Enum.TryParse(WebUtil.GetQueryString("bc"), true, out bc))
            {
                bc = settings.BackgroundColor;
            }
            var foregroundColor = OutputLine.ProcessHtmlColor(fc);
            var backgroundColor = OutputLine.ProcessHtmlColor(bc);

            Result.Style.Add("color", foregroundColor);
            Result.Style.Add("background-color", backgroundColor);
            Result.Style.Add("font-family", settings.FontFamilyStyle);
            Result.Style.Add("font-size", $"{settings.FontSize}px");
            Result.InnerHtml = HttpContext.Current.Session[sid] as string ?? string.Empty;
            All.Style.Add("color", foregroundColor);
            All.Style.Add("background-color", backgroundColor);
            Promo.Style.Add("background-color", backgroundColor);
            HttpContext.Current.Session.Remove(sid);
        }
        private OutputLine GetOutputLines(string outputLines)
        {
            OutputLine result = OutputLine.None;

            if (outputLines.Equals(string.Empty))
            {
                return(OutputLine.None);
            }

            switch (outputLines.ToLower())
            {
            case "none":
                result = OutputLine.None;
                break;

            case "straight":
                result = OutputLine.Straight;
                break;

            case "true shape":
                result = OutputLine.TrueShape;
                break;

            default:
                break;
            }
            return(result);
        }
Ejemplo n.º 6
0
        private Task Consume()
        {
            return(Task.Run(() =>
            {
                while (!_outputLines.IsCompleted)
                {
                    OutputLine line = null;

                    try
                    {
                        line = _outputLines.Take();
                    }
                    catch (InvalidOperationException) { }

                    if (line != null)
                    {
                        _sortedOutputLines.Add(line.LineNumber, line.Line);
                        var firstIndex = _sortedOutputLines.Keys.First();
                        var lastIndex = _sortedOutputLines.Keys.Last();

                        if ((lastIndex - firstIndex == _sortedOutputLines.Count - 1) &&
                            firstIndex == _lastFlushedIndex + 1)
                        {
                            _lastFlushedIndex = lastIndex;
                            FlushLinesToOutput();
                        }
                    }
                }
            }));
        }
Ejemplo n.º 7
0
        private static void SetStandardColors(OutputLine Line)
        {
            Console.BackgroundColor = ConsoleColor.Black;
            if (Line.Entry.Status == "X")
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
            }
            else if (Line.Entry.Status == "✓")
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
            }
            else if (Line.Entry.Status == "█")
            {
                Console.ForegroundColor = ConsoleColor.Red;
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.DarkGreen;
            }

            if (!Line.Hilite)
            {
                Console.ForegroundColor = ConsoleColor.DarkGray;
            }
        }
Ejemplo n.º 8
0
        protected override void OnLoad(EventArgs e)
        {
            if (!SecurityHelper.CanRunApplication("PowerShell/PowerShell Console") ||
                ServiceAuthorizationManager.TerminateUnauthorizedRequest(WebServiceSettings.ServiceClient,
                                                                         Context.User?.Name))
            {
                PowerShellLog.Error($"User {Context.User?.Name} attempt to access PowerShell Console - denied.");
                return;
            }
            base.OnLoad(e);

            UpdateWarning();

            Settings = ApplicationSettings.GetInstance(ApplicationNames.Context, false);
            HttpContext.Current.Response.AddHeader("X-UA-Compatible", "IE=edge");
            var settings = ApplicationSettings.GetInstance(ApplicationNames.Console, false);

            if (!Context.ClientPage.IsEvent)
            {
                Options.Text = @"<script type='text/javascript'>" +
                               @"$ise(function() { cognifide.powershell.setOptions({ initialPoll: " +
                               WebServiceSettings.InitialPollMillis + @", maxPoll: " +
                               WebServiceSettings.MaxmimumPollMillis + @", fontSize: " +
                               settings.FontSize + $", fontFamily: '{settings.FontFamilyStyle}' }});}});</script>" +
                               @"<style>#terminal {" +
                               $"color: {OutputLine.ProcessHtmlColor(settings.ForegroundColor)};" +
                               $"background-color: {OutputLine.ProcessHtmlColor(settings.BackgroundColor)};" +
                               $"font-family: inherit;" + "}</style>";
            }
            SheerResponse.SetDialogValue("ok");
        }
Ejemplo n.º 9
0
 public override void Start()
 {
     productionState = 2;
     IsWorking       = true;
     alertMessage    = String.Format("La centrale {0} a été démarrée", GetName);
     OutputLine.SetPriorityLevel(GetPriorityLevel);
 }
Ejemplo n.º 10
0
        public object ExecuteCommand(string guid, string command, string stringFormat)
        {
            var serializer = new JavaScriptSerializer();
            var output     = new StringBuilder();

            if (!IsLoggedInUserAuthorized ||
                !SessionElevationManager.IsSessionTokenElevated(ApplicationNames.Console))
            {
                return(serializer.Serialize(
                           new
                {
                    status = StatusElevationRequired,
                    result =
                        "You need to be authenticated, elevated and have sufficient privileges to use the PowerShell console. Please (re)login to Sitecore.",
                    prompt = "PS >",
                    background = OutputLine.ProcessHtmlColor(ConsoleColor.DarkBlue)
                }));
            }

            PowerShellLog.Info($"Arbitrary script execution in Console session '{guid}' by user: '******'");

            var session = GetScriptSession(guid);

            session.Interactive = true;
            session.SetItemContextFromLocation();
            try
            {
                var handle     = ID.NewID.ToString();
                var jobOptions = new JobOptions(GetJobId(guid, handle), "PowerShell", "shell", this, nameof(RunJob),
                                                new object[] { session, command })
                {
                    AfterLife      = new TimeSpan(0, 0, 20),
                    ContextUser    = Sitecore.Context.User,
                    EnableSecurity = true,
                    ClientLanguage = Sitecore.Context.ContentLanguage
                };
                JobManager.Start(jobOptions);
                Thread.Sleep(WebServiceSettings.CommandWaitMillis);
                return(PollCommandOutput(guid, handle, stringFormat));
            }
            catch (Exception ex)
            {
                return
                    (serializer.Serialize(
                         new Result
                {
                    status = StatusError,
                    result =
                        output +
                        ScriptSession.GetExceptionString(ex, ScriptSession.ExceptionStringFormat.Console) +
                        "\r\n" +
                        "\r\n[[;#f00;#000]Uh oh, looks like the command you ran is invalid or something else went wrong. Is it something we should know about?]\r\n" +
                        "[[;#f00;#000]Please submit a support ticket here https://git.io/spe with error details, screenshots, and anything else that might help.]\r\n\r\n" +
                        "[[;#f00;#000]We also have a user guide here http://doc.sitecorepowershell.com/.]\r\n\r\n",
                    prompt = $"PS {session.CurrentLocation}>",
                    background = OutputLine.ProcessHtmlColor(session.PrivateData.BackgroundColor),
                    color = OutputLine.ProcessHtmlColor(session.PrivateData.ForegroundColor)
                }));
            }
        }
Ejemplo n.º 11
0
 public System.Windows.Input.ICommand GetDelLineCmd(CommonBaseVM vm, OutputLine key)
 {
     return(new Command(() =>
     {
         vm.DeleteOutputLine(vm.OutputList.FirstOrDefault(x => x.Name == key.Name));
     }));
 }
Ejemplo n.º 12
0
 public SolarPowerPlant(string name, Weather meteo) : base(name)
 {
     SetPriorityLevel(PLGasPowerPlant);
     OutputLine.SetPriorityLevel(GetPriorityLevel);
     this.meteo           = meteo;
     constantProduction   = false;
     adjustableProduction = false;
     Start();
 }
Ejemplo n.º 13
0
 public NuclearPowerPlant(string name, Market market) : base(name)
 {
     SetPriorityLevel(PLGasPowerPlant);
     OutputLine.SetPriorityLevel(GetPriorityLevel);
     this.market          = market;
     constantProduction   = true;
     adjustableProduction = false;
     Start();                                 // mise en marche automatique au moment de la création de la centrale
 }
Ejemplo n.º 14
0
 public GasPowerPlant(string name, Market market) : base(name)
 {
     SetPriorityLevel(PLGasPowerPlant);
     OutputLine.SetPriorityLevel(GetPriorityLevel);
     this.market          = market;
     constantProduction   = true;
     adjustableProduction = false;
     Start();
 }
Ejemplo n.º 15
0
        public object ExecuteCommand(string guid, string command, string stringFormat)
        {
            if (!WebServiceSettings.ServiceEnabledClient)
            {
                return(string.Empty);
            }
            var serializer = new JavaScriptSerializer();
            var output     = new StringBuilder();

            if (!HttpContext.Current.Request.IsAuthenticated &&
                !command.StartsWith("login-user", StringComparison.OrdinalIgnoreCase))
            {
                return(serializer.Serialize(
                           new
                {
                    result =
                        "You need to be authenticated to use the PowerShell console. Please login to Sitecore first.",
                    prompt = "PS >",
                    background = OutputLine.ProcessHtmlColor(ConsoleColor.DarkBlue)
                }));
            }

            var session = GetScriptSession(guid);

            session.Interactive = true;
            try
            {
                var handle     = ID.NewID.ToString();
                var jobOptions = new JobOptions(GetJobId(guid, handle), "PowerShell", "shell", this, "RunJob",
                                                new object[] { session, command })
                {
                    AfterLife      = new TimeSpan(0, 0, 20),
                    ContextUser    = Sitecore.Context.User,
                    EnableSecurity = true,
                    ClientLanguage = Sitecore.Context.ContentLanguage
                };
                JobManager.Start(jobOptions);
                Thread.Sleep(WebServiceSettings.CommandWaitMillis);
                return(PollCommandOutput(guid, handle, stringFormat));
            }
            catch (Exception ex)
            {
                return
                    (serializer.Serialize(
                         new Result
                {
                    status = StatusError,
                    result = output + ScriptSession.GetExceptionString(ex, ScriptSession.ExceptionStringFormat.Console) + "\r\n" +
                             "\r\n[[;#f00;#000]Uh oh, looks like the command you ran is invalid or something else went wrong. Is it something we should know about?]\r\n" +
                             "[[;#f00;#000]Please submit a support ticket here https://git.io/spe with error details, screenshots, and anything else that might help.]\r\n\r\n" +
                             "[[;#f00;#000]We also have a user guide here http://sitecorepowershell.gitbooks.io/sitecore-powershell-extensions/.]\r\n\r\n",
                    prompt = $"PS {session.CurrentLocation}>",
                    background = OutputLine.ProcessHtmlColor(session.PrivateData.BackgroundColor),
                    color = OutputLine.ProcessHtmlColor(session.PrivateData.ForegroundColor)
                }));
            }
        }
Ejemplo n.º 16
0
        protected virtual void UpdateSettings(ClientPipelineArgs args)
        {
            var settings        = ApplicationSettings.GetInstance(ApplicationNames.ISE);
            var backgroundColor = OutputLine.ProcessHtmlColor(settings.BackgroundColor);
            var bottomPadding   = CurrentVersion.IsAtLeast(SitecoreVersion.V80) ? 0 : 10;

            SheerResponse.Eval(
                $"spe.changeSettings('{settings.FontFamilyStyle}', {settings.FontSize}, '{backgroundColor}', {bottomPadding}, {settings.LiveAutocompletion.ToString().ToLower()});");
        }
Ejemplo n.º 17
0
        void Update()
        {
            //update all lines
            for (int i = 0; i < m_NumLines; ++i)
            {
                OutputLine rLine = m_Lines[i];
                if (rLine.m_Enabled)
                {
                    //update spring
                    float fToDesired = m_DesiredAngle - rLine.m_SpringAngle;
                    fToDesired *= m_SpringK;
                    float fDampenedVel = rLine.m_SpringVelocity * m_SpringDampen;
                    float fSpringForce = fToDesired - fDampenedVel;
                    rLine.m_SpringVelocity += fSpringForce;
                    rLine.m_SpringAngle    += (rLine.m_SpringVelocity * Time.deltaTime);

                    Quaternion qOrient = Quaternion.Euler(0.0f, rLine.m_SpringAngle, 0.0f);
                    rLine.m_Line.transform.rotation = qOrient;

                    //update height
                    float fToDesiredHeight = rLine.m_DesiredHeight - rLine.m_CurrentHeight;
                    rLine.m_CurrentHeight += (fToDesiredHeight * Time.deltaTime * m_LineHeightSpeed);

                    Vector3 vPos = rLine.m_Line.transform.position;
                    vPos.y = rLine.m_CurrentHeight;
                    rLine.m_Line.transform.position = vPos;

                    //update life
                    float fLife = rLine.m_LifeCountdown - Time.deltaTime;
                    rLine.m_LifeCountdown = fLife;
                    if (fLife <= 0.0f)
                    {
                        //turn off line!
                        rLine.m_Line.SetActive(false);
                        rLine.m_Enabled = false;

                        //scoot everything up
                        AdjustLineHeights(m_LineSpacing, rLine.m_DesiredHeight);
                    }
                    else
                    {
                        //fade the line out
                        Color rColor = rLine.m_Color;
                        rColor.a = Mathf.Min(fLife / m_FadeDuration, 1.0f);
                        rLine.m_TextMesh.color = rColor;
                    }
                }
            }

            //add next queued line
            if (m_LineQueue.Count > 0)
            {
                var line = m_LineQueue.Dequeue();
                CreateLineFromQueue(line.m_Text, line.m_Type);
            }
        }
Ejemplo n.º 18
0
 public InputProcessor(CommandProcesser commandProcesser)
 {
     this.commandProcesser = commandProcesser;
     isActive = false;
     CommandHistory = new CommandHistory();
     Out = new List<OutputLine>();
     Buffer = new OutputLine("", OutputLineType.Command);
     EventInput.CharEntered += EventInput_CharEntered; //Handles the typable characters
     EventInput.KeyDown += EventInput_KeyDown; //Handles the non-typable characters
 }
Ejemplo n.º 19
0
        public void HandlePanUpdated(GestureData data)
        {
            SwipeType  swipe = SwipeType.None;
            OutputLine line  = null;
            Section    sect  = null;

            switch (data.status)
            {
            case GestureStatus.Started:
                initialX = data.totalX;
                initialY = data.totalY;
                break;

            case GestureStatus.Running:
                // Translate and ensure we don't pan beyond the wrapped user interface element bounds.
                x = data.totalX;
                y = data.totalY;

                swipe = this.GetSwipe();
                sect  = (data.sender as View).Parent.Parent.BindingContext as Section;
                if (sect != null)
                {
                    sect.OnDragCmd.Execute(new SwipeAction()
                    {
                        Type = swipe, Finished = false
                    });
                }
                break;

            case GestureStatus.Completed:
                swipe = this.GetSwipe();
                try
                {
                    line = (data.sender as View).Parent.Parent.BindingContext as OutputLine;
                    sect = (data.sender as View).Parent.Parent.BindingContext as Section;
                    if (line != null)
                    {
                        line.OnDragCmd.Execute(swipe as object);
                    }
                    else if (sect != null)
                    {
                        sect.OnDragCmd.Execute(new SwipeAction()
                        {
                            Type = swipe, Finished = true
                        });
                    }
                }
                catch (Exception ex)
                {
                    StoreFactory.CurrentVM.Logs.Add("Swipe exception: " + ex.Message);
                }

                break;
            }
        }
Ejemplo n.º 20
0
        private void OnDataReceived(string data)
        {
            switch (data)
            {
            case MESSAGE_COMPILE_STARTED:
                IsCompiling = true;
                CompileStarted?.Invoke(this, EventArgs.Empty);
                break;

            case MESSAGE_COMPILE_ENDED:
            case MESSAGE_COMPILE_ENDED_WITH_WARNINGS:
                if (!IsStarting)
                {
                    IsCompiling = false;
                    CompileEnded?.Invoke(this, true);
                }
                else
                {
                    nodeProcesses = GetNodeProcessesByExecutablePath(ExecutablesDirectory);
                    IsStarting    = false;
                    Started?.Invoke(this, EventArgs.Empty);
                }
                break;

            case MESSAGE_COMPILE_FAILED:
                IsCompiling = false;
                CompileEnded?.Invoke(this, false);
                break;

            default:
                if (IsRunning && data.StartsWith(MESSAGE_NPM_ERROR))
                {
                    Stop();
                    IsStarting  = false;
                    IsCompiling = false;
                    CompileEnded?.Invoke(this, false);
                }
                else if (IsInstalling)
                {
                    if (data.StartsWith(MESSAGE_NPM_WARNING))
                    {
                        Stop();
                        InstallEnded?.Invoke(this, false);
                    }
                    else if (InstallEndedIdentifier.IsMatch(data))
                    {
                        IsInstalling = false;
                        InstallEnded?.Invoke(this, true);
                    }
                }
                break;
            }

            OutputLine?.Invoke(this, data);
        }
Ejemplo n.º 21
0
 public static void PrintEntry(OutputLine Line)
 {
     SetStandardColors(Line);
     FillLine();
     for (var i = 0; i < Line.Depth; ++i)
     {
         Console.Write(" |");
     }
     Console.WriteLine(FormatEntry(Line.Entry, Console.WindowWidth - (Line.Depth * 2)));
     Console.ResetColor();
 }
Ejemplo n.º 22
0
        public override PathInfo GetFormula(ConnectionLine invoker, PathInfo path)
        {
            if (InputLine == null)
            {
                throw new Exception(String.Format(Properties.Resources.ErrorInputModule, Name));
            }

            if (OutputLine == null)
            {
                throw new Exception(String.Format(Properties.Resources.ErrorOutputModule, Name));
            }


            foreach (var uiElement in Path.AllDeletedObjects)
            {
                if (uiElement.GetType().Name == "ConnectionLine")
                {
                    var line = (uiElement as ConnectionLine);

                    if (InputLine.Name == line.Name)
                    {
                        InputLine = null;
                    }

                    if (OutputLine.Name == line.Name)
                    {
                        OutputLine = null;
                    }
                }
            }


            bool isAnd = path.IsM2MConnection;
            var  rez   = Name;

            if (invoker == InputLine)
            {
                rez += OutputLine.GetFormula(this, path);
            }
            if (invoker == OutputLine)
            {
                rez += InputLine.GetFormula(this, path);
            }
            if (isAnd)
            {
                path.Formula = " AND " + rez;
            }
            else
            {
                path.Formula = rez;
            }

            return(path);
        }
Ejemplo n.º 23
0
        public void OnGPIO(int number, bool value)
        {
            if (number < 0 || number >= inputStates.Length)
            {
                this.Log(LogLevel.Error, "Received GPIO signal on an unsupported port #{0} (supported ports are 0 - {1}). Please check the platform configuration", number, inputStates.Length - 1);
                return;
            }

            inputStates[number] = value;
            OutputLine.Set(inputStates.Any(x => x));
        }
Ejemplo n.º 24
0
        public frmGame()
        {
            InitializeComponent();

            try
            {
                // graphics quality
                this.graphics = this.CreateGraphics();
                this.graphics.SmoothingMode      = SmoothingMode.HighQuality;
                this.graphics.CompositingMode    = CompositingMode.SourceCopy;
                this.graphics.CompositingQuality = CompositingQuality.HighQuality;

                // background image
                string path = ConfigurationManager.AppSettings["pathImages"];
                this.BackgroundImage = Image.FromFile(path + "GameBackground.png", false);

                // get the input method (keyboard/mouse) from settings
                string input = ConfigurationManager.AppSettings["input"];
                this.inputType = (input == "Mouse" ? Balls.eInputType.Mouse : Balls.eInputType.Keyboard);

                if (inputType == Balls.eInputType.Mouse)
                {
                    this.MouseMove += new MouseEventHandler(this.frmGame_MouseMove);
                }

                // world objects
                this.balls            = new Balls(inputType);
                this.board            = new Board(1);
                this.playerPad        = new PlayerPad();
                this.outputLine       = new OutputLine();
                this.gameControl      = new GameControl();
                this.scoreBoard       = new ScoreBoard();
                this.highScores       = new HighScores();
                this.particlesSystem  = new ParticlesSystem();
                this.collisionsSystem = new CollisionsSystem();

                // add the listeners for objects comunication
                this.playerPad.DoubleBallRewardEvent     += new PlayerPad.DoubleBallEventHandler(balls.DoubleBallEvent);
                this.playerPad.TripleBallRewardEvent     += new PlayerPad.TripleBallEventHandler(balls.TripleBallEvent);
                this.playerPad.WinLevelRewardEvent       += new PlayerPad.WinLevelEventHandler(gameControl.WinLevelEvent);
                this.playerPad.SlowBallRewardEvent       += new PlayerPad.SlowBallEventHandler(balls.SlowBallEvent);
                this.playerPad.DemolitionBallRewardEvent += new PlayerPad.DemolitionBallEventHandler(balls.DemolitionBallEvent);

                // start
                this.tmrStart.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
        }
Ejemplo n.º 25
0
 public PurchaseAbroad(string name, Market market) : base(name)
 {
     SetPriorityLevel(PLGasPowerPlant);
     OutputLine.SetPriorityLevel(GetPriorityLevel);
     OutputLine.SetIsMarketLine(true);
     //OutputLine.GetInputNode.SetHasMarket(true);
     //OutputLine.GetOutputeNode.SetHasMarket(true);
     OutPutNode.SetHasMarket(true);
     //OutputLine.GetInputNode.SetMyMarket(this);
     OutPutNode.SetMyMarket(this);
     this.market = market;
     Start();
 }
Ejemplo n.º 26
0
        public string AddReport_Click(string directory, string message)
        {
            if (directory != "" && directory != null)
            {
                OutputLine        outputLineStuff = new OutputLine();
                List <OutputLine> outline         = new List <OutputLine>();

                var command = "git add " + message;
                var text    = CreatePowershell.DewProcess(directory, command + "; git status");
                return(text);
            }
            return("BROKE");
        }
Ejemplo n.º 27
0
        internal Node GetNextNode(ConnectionLine invoker, PathFinder path)
        {
            if (invoker == InputLine)
            {
                return(OutputLine.GetNextNode(this, path));
            }
            if (invoker == OutputLine)
            {
                return(InputLine.GetNextNode(this, path));
            }

            return(null);
        }
Ejemplo n.º 28
0
        public string InitReport_Click(string directory)
        {
            if (directory != "" && directory != null)
            {
                OutputLine        outputLineStuff = new OutputLine();
                List <OutputLine> outline         = new List <OutputLine>();

                var command = "git init";
                var text    = CreatePowershell.DewProcess(directory, command);

                return(text);
            }
            return("BROKE");
        }
Ejemplo n.º 29
0
        public string OutputLine(OutputLine vEn)
        {
            if (vEn.v00.cmdName == eDev485obj.Free)
            {
                vEn.v00.cmdName = (eDev485obj)Enum.Parse(
                    typeof(eDev485obj),
                    vEn.GetType().Name);
            }
            // 调整位



            return(doObjectToString(vEn));
        }
Ejemplo n.º 30
0
        protected virtual void UpdateSettings(ClientPipelineArgs args)
        {
            var settings        = ApplicationSettings.GetInstance(ApplicationNames.IseConsole);
            var db              = Factory.GetDatabase(ApplicationSettings.ScriptLibraryDb);
            var fonts           = db.GetItem(ApplicationSettings.FontNamesPath);
            var font            = string.IsNullOrEmpty(settings.FontFamily) ? "monospace" : settings.FontFamily;
            var fontItem        = fonts.Children[font];
            var backgroundColor = OutputLine.ProcessHtmlColor(settings.BackgroundColor);

            font = fontItem != null
                ? fontItem["Phrase"]
                : "Monaco, Menlo, \"Ubuntu Mono\", Consolas, source-code-pro, monospace";
            var bottomPadding = CurrentVersion.IsAtLeast(SitecoreVersion.V80) ? 0 : 10;

            SheerResponse.Eval(
                $"cognifide.powershell.changeSettings('{font}', {settings.FontSize}, '{backgroundColor}', {bottomPadding}, {settings.LiveAutocompletion.ToString().ToLower()});");
        }
Ejemplo n.º 31
0
        protected override bool DoWrite(IDataReader dataReader)
        {
            Context.Log.Debug("Enter ProductFeedFileWriter.DoWrite");

            var utility    = new Utility(dataReader, Context);
            var outputLine = new OutputLine('|', Context, utility);

            string salePriceString;
            string listPriceString;

            outputLine
            .Add("gId")                                                                 // Product ID
            .Add("title", "title_fr", title =>                                          // Product Name
            {
                var titleResult = ((string)title).Replace("\n", string.Empty).Replace("\r", string.Empty);

                titleResult = titleResult.Substring(0, Math.Min((titleResult).Length, 255))
                              .Replace('|', '-');

                return(titleResult);
            })
            .Add(null)                                                                  // Product Parent ID
            .Add("price", price => ((decimal)price).ToString("0.00"))                   // Unit Price
            .AddLiteral("true")                                                         // Recommendable
            .Add("linkSku", sku => utility.GetEntryImageLink(sku.ToString()))           // Image Path
            .AddLiteral(utility.GetFeedEntryLinkValue(Context.Language))                // Product URL
            // Product Rating
            .Add("AverageRating", "AverageRating_fr", rating => rating == DBNull.Value ? "0" : ((decimal)rating).ToString("0.0000"))
            // Number of reviews
            .Add("NumberOfReviews", "NumberOfReviews_fr", reviewCount => reviewCount == DBNull.Value ? "0" : reviewCount.ToString())
            .Add("gBrand", "gBrand_fr")                                                 // Product brand
            .AddLiteral(salePriceString = utility.GetSalePriceString())                 // Minimum sale price
            .AddLiteral(salePriceString)                                                // Maximum sale price
            .AddLiteral(listPriceString = utility.GetListPriceString())                 // Minimum list price
            .AddLiteral(listPriceString);                                               // Maximum list price

            var result = outputLine.ToString();

            Context.StreamWriter.WriteLine(result);

            Context.Log.Debug("Exit ProductFeedFileWriter.DoWrite");

            return(true);
        }
Ejemplo n.º 32
0
    private static FI findPossible(OutputLine item, DateTime dateToLookFor_, SymmetryEntities dc)
    {
      var fi = FIHelpers.GetFIBySymmetryCode(item.BbgCode, dc, Symmetry.Core.ThrowBehavior.DontThrow);

      if (fi != null && !areVeryClose(dateToLookFor_, fi.Maturity.Value))
        fi = null;

      if (fi == null)
      {
        var possibles = dc.FIs.Where(x => x.SymmetryCode.StartsWith(item.SourceSpec.BbgStart) && x.SymmetryCode.EndsWith(item.SourceSpec.BbgSuffix)).ToArray();

        // have to put this separate as can't pass into entity framework
        fi = possibles.FirstOrDefault(x => OutputLine.AreSameBaseMonthCodeEndYear(x.SymmetryCode,item.BbgCode) && x.Maturity.HasValue && areVeryClose(x.Maturity.Value, dateToLookFor_));
      }

      return fi;
    }