protected override void OnUpdate(GameplayScreen gameplayScreen)
        {
            if (ItemInfo == null || hasReplacedItemScript)
            {
                return;
            }

            animationIndex = ItemInfo.AnimationIndex;

            // ReSharper disable once SimplifyLinqExpression
            if (!Scripts.Any(s => s.AsDynamic().ScriptType == EScriptType.RelicOrbGetToast))
            {
                return;
            }

            Scripts.UpdateRelicOrbGetToastToItem(Level, ItemInfo);

            var rewardItemDelegate = Scripts.Single(s =>
            {
                var script = s.AsDynamic();
                return(script.ScriptType == EScriptType.Delegate &&
                       script.Arguments != ScriptActionQueueExtensions.ReplacedArguments);
            });

            rewardItemDelegate.AsDynamic().Delegate = new Action(() =>
            {
                AwardContainedItem();
                var itemPopupAppendage = (Appendage)Dynamic._itemPopupAppendage;
                itemPopupAppendage.ChangeAnimation(animationIndex);
                itemPopupAppendage.AsDynamic().IsPopppingUp = true;
                Dynamic._appendages.Add(itemPopupAppendage);
            });

            hasReplacedItemScript = true;
        }
Пример #2
0
        public override string ToString()
        {
            var sb = new StringBuilder();

            if (PreScripts.Any())
            {
                sb.Append(PrintString(PreScripts));

                if (Scripts.Any() || PostScripts.Any())
                {
                    sb.AppendLine(StatementSeparator);
                    sb.AppendLine();
                }
            }

            if (Scripts.Any())
            {
                sb.Append(PrintString(Scripts));

                if (PostScripts.Any())
                {
                    sb.AppendLine(StatementSeparator);
                    sb.AppendLine();
                }
            }

            if (PostScripts.Any())
            {
                sb.Append(PrintString(PostScripts));
                sb.AppendLine();
            }

            return(sb.ToString());
        }
 public override string ToString()
 {
     return(string.Join(Environment.NewLine, $"{{",
                        $"{Description}",
                        $"IsAutomated: {Automated}",
                        $"Portal Link: {PortalLink}",
                        $"Script:",
                        (Scripts.Any() ? $"{string.Join(Environment.NewLine, Scripts)}" : "{}"),
                        $"}}"));
 }
        private string BundleHtml()
        {
            var result = new StringBuilder();
            var hash   = "";

            if (Scripts.Any())
            {
                hash = GetHash(Scripts);
            }
            else if (Styles.Any())
            {
                hash = GetHash(Styles);
            }

            var path    = string.Format("~{0}{1}-{2}", BundleHelper.BUNDLE_VPATH, GetCategory(CategoryName), hash);
            var pathcss = path + ".css";
            var pathjs  = path + ".js";

            var bundlecss = BundleHelper.GetCssBundle(pathcss);
            var bundlejs  = BundleHelper.GetJsBundle(pathjs);

            if (bundlecss == null && bundlejs == null)
            {
                if (Styles.Any())
                {
                    bundlecss = BundleHelper.CssBundle(pathcss);
                    foreach (var style in Styles)
                    {
                        bundlecss.Include(style);
                    }
                    BundleHelper.AddBundle(bundlecss);
                }

                if (Scripts.Any())
                {
                    bundlejs = BundleHelper.JsBundle(pathjs);
                    foreach (var script in Scripts)
                    {
                        bundlejs.Include(script, true);
                    }
                    BundleHelper.AddBundle(bundlejs);
                }
            }

            if (bundlecss != null)
            {
                result.AppendLine(BundleHelper.HtmlLink(pathcss));
            }
            if (bundlejs != null)
            {
                result.AppendLine(BundleHelper.HtmlScript(pathjs));
            }
            return(result.ToString());
        }
Пример #5
0
 public bool IsValid()
 {
     return(!string.IsNullOrEmpty(Name) &&
            !string.IsNullOrEmpty(Title) &&
            !string.IsNullOrEmpty(Description) &&
            Uri.IsWellFormedUriString(Url.ToString(), UriKind.RelativeOrAbsolute) &&
            Uri.IsWellFormedUriString(ParentStoryUrl.ToString(), UriKind.RelativeOrAbsolute) &&
            KeyIdentifiers != null &&
            KeyIdentifiers.Any() ? KeyIdentifiers.All(s => s.IsValid()) : true &&
            TestCases != null &&
            TestCases.Any() ? TestCases.All(s => s.IsValid()) : true &&
            Checkups != null &&
            Checkups.Any() ? Checkups.All(s => s.IsValid()) : true &&
            Attachments != null &&
            Attachments.Any() ? Attachments.All(s => Uri.IsWellFormedUriString(s.Value, UriKind.RelativeOrAbsolute)) : true &&
            Queries != null &&
            Queries.Any() ? Queries.All(s => Uri.IsWellFormedUriString(s.Value, UriKind.RelativeOrAbsolute)) : true &&
            Scripts != null &&
            Scripts.Any() ? Scripts.All(s => Uri.IsWellFormedUriString(s.Value, UriKind.RelativeOrAbsolute)) : true &&
            SubTasks.Any() ? SubTasks.All(s => s.IsValid()) : true);
 }
Пример #6
0
 public void LoadScripts(string sDir)
 {
     try
     {
         foreach (string filename in Directory.GetFiles(sDir)
                  .Where(fn =>
                         Path.GetExtension(fn).ToLower() == ScriptExtension
                         )
                  .OrderBy(s => s))
         {
             var extension = Path.GetExtension(filename);
             if (!Scripts.Any(s => s.FileName == filename))
             {
                 var script = new ChangeScript();
                 script.Script   = Path.GetFileName(filename);
                 script.FileName = filename;
                 Scripts.Add(script);
             }
         }
     }
     catch (Exception)
     {
     }
 }
Пример #7
0
        protected Tuple <DateTime, ScheduleMessageState> ExecuteScript(string scriptName, IComponentContext context)
        {
            var script = Scripts[scriptName];

            if (script == null)
            {
                throw new Exception("Script not found");
            }
            RunningScriptName = scriptName;

            var flow = new ScriptFlow(this);

            flow.OnNewMessage +=
                (m) =>
            {
                if (m.Type == ScheduleMessageState.Error)
                {
                    log.Error(String.Format("{0}: {1}", m.Type, m.Message));
                }
                else
                {
                    log.Info(String.Format("{0}: {1}", m.Type, m.Message));
                }
                Progress.SetProgress(m.Message);
            };
            scriptUtility.Flow = flow;

            flow.AddMessage(String.Format("Starting {1} for {0}", TaskName, scriptName));
            OnScriptStarted(script);
            //init
            try
            {
                flow.AddMessage(String.Format("Initializing {0}", scriptName), ScheduleMessageState.Debug);
                var dependency = ResolveScriptDependency(script, context);
                ValidateDependencies(dependency);
                script.Init(dependency, Settings, flow, scriptUtility);
            }
            catch (Exception ex)
            {
                flow.AddMessage("Script init failed", ScheduleMessageState.Error);
                flow.Dump(ex);
            }
            //execution
            if (flow.MessagesState < ScheduleMessageState.Error)
            {
                try
                {
                    script.Execute();
                }
                catch (FlowException ex)
                {
                    if (ex.ExceptionType == FlowExceptionType.Fail)
                    {
                        flow.AddMessage(ex.Message, ScheduleMessageState.Error);
                    }
                    else if (!String.IsNullOrEmpty(ex.Message))
                    {
                        flow.AddMessage(ex.Message);
                    }
                }
                catch (Exception ex)
                {
                    flow.AddMessage("Script failed with exception", ScheduleMessageState.Error);
                    flow.Dump(ex);
                }
            }
            //execution done - changing and saving settings
            Settings.Set(SETTING_LAST_STATE, flow.MessagesState);

            var currentTime = DateTime.Now;

            if (flow.MessagesState < ScheduleMessageState.Error)
            {
                //update schedules
                ScheduledScripts = ScheduledScripts.Skip(1).ToList();
                flow.ScheduledScripts.ForEach(x =>
                {
                    if (Scripts.Any(s => s.Key == x.Key))
                    {
                        ScheduledScripts.Add(new BrowsingGoalScriptSchedule()
                        {
                            ScriptName = x.Key, Date = currentTime.AddSeconds(x.Value)
                        });
                    }
                    else
                    {
                        flow.AddMessage(String.Format("Script {0} not found for schedule.", x.Key), ScheduleMessageState.Error);
                    }
                });
                ScheduledScripts = ScheduledScripts.OrderBy(x => x.Date).ToList();
                flow.AddMessage(String.Format("{0} scripts in queue", ScheduledScripts.Count), ScheduleMessageState.Debug);
            }
            flow.AddMessage(String.Format("Script {0}.{1} finished", TaskName, RunningScriptName), flow.MessagesState);
            Settings.Set(SETTING_PREFIX_MESSAGES + scriptName, flow.Messages);

            Progress.SetProgressRemaining(RunningScriptName + " complete",
                                          (int)((0.0 + ProgressStatus.PROGRESS_MAX) * (Math.Min(ScheduledScripts.Count, Scripts.Count) / (0.0 + Scripts.Count))));

            OnScriptFinished(script);
            if (ScheduledScripts.Count == 0 || flow.MessagesState >= ScheduleMessageState.Error)
            {
                flow.AddMessage(String.Format("Task '{0}' finished", TaskName));
                OnTaskFinished();
            }
            RunningScriptName = null;
            return(new Tuple <DateTime, ScheduleMessageState>(
                       (ScheduledScripts.Count == 0) ? DateTime.MaxValue :
                       ScheduledScripts.First().Date, flow.MessagesState));
        }
Пример #8
0
 public bool FunctionExists(string n)
 {
     return(Context.FunctionExists(n) || Scripts.Any(s => s.Value.Name == n));
 }
Пример #9
0
        private FlowDocument BuildDocument()
        {
            var doc = new FlowDocument();

            doc.LineStackingStrategy = System.Windows.LineStackingStrategy.BlockLineHeight;
            doc.LineHeight           = 12;
            doc.Blocks.Add(new Paragraph(new Bold(new Run("Summary"))));
            doc.Blocks.Add(new Paragraph(new Run(" " + Title)));
            doc.Blocks.Add(new Paragraph(new Bold(new Run("Description"))));
            doc.Blocks.Add(new Paragraph(new Run(" " + Description)));

            doc.Blocks.Add(new Paragraph(new Bold(new Run("Url"))));
            var url = new Hyperlink(new Run(Url.ToString()));

            doc.Blocks.Add(new Paragraph(url));
            doc.Blocks.Add(new Paragraph(new Bold(new Run("Parent Story"))));
            var parentUrl = new Hyperlink(new Run(ParentStoryUrl.ToString()));

            parentUrl.NavigateUri = ParentStoryUrl;
            doc.Blocks.Add(new Paragraph(parentUrl));

            doc.Blocks.Add(new Paragraph(new Italic(new Run("Status: " + Status.ToString()))));

            doc.Blocks.Add(new Paragraph(new Italic(new Run("Date Started: " + DateStarted.Value.ToString("yyyy-MM-dd hh:mm:ss")))));
            if (DateEnded.HasValue && DateEnded.Value != DateTime.MinValue)
            {
                doc.Blocks.Add(new Paragraph(new Italic(new Run("Date Ended: " + DateEnded.Value.ToString("yyyy-MM-dd hh:mm:ss")))));
            }

            if (Attachments.Any())
            {
                doc.Blocks.Add(new Paragraph(new Bold(new Run("Attachments"))));
                foreach (var item in Attachments)
                {
                    var itemUri = new Uri(item.Value);
                    var itemUrl = new Hyperlink(new Run(item.Value));
                    doc.Blocks.Add(new Paragraph(itemUrl));
                }
            }

            if (AcceptanceCriteria.Any())
            {
                doc.Blocks.Add(new Paragraph(new Bold(new Run("Acceptance Criteria"))));
                foreach (var item in AcceptanceCriteria)
                {
                    doc.Blocks.Add(new Paragraph(new Run(" + " + item.Value)));
                }
            }

            if (DeveloperCriteria.Any())
            {
                doc.Blocks.Add(new Paragraph(new Bold(new Run("Development Criteria"))));
                foreach (var item in DeveloperCriteria)
                {
                    doc.Blocks.Add(new Paragraph(new Run(" + " + item.Value)));
                }
            }

            var i = 0;
            var j = 0;

            if (KeyIdentifiers.Any())
            {
                doc.Blocks.Add(new Paragraph(new Bold(new Run("Key Identifiers"))));
                foreach (var item in KeyIdentifiers)
                {
                    doc.Blocks.Add(new Paragraph(new Run(" " + (++i).ToString() + ". " + item.Description)));

                    if (item.Questions.Any())
                    {
                        j = 0;
                        doc.Blocks.Add(new Paragraph(new Italic(new Run(" Questions"))));
                        foreach (var q in item.Questions)
                        {
                            doc.Blocks.Add(new Paragraph(new Run("   " + (++j).ToString() + ".Q. " + q.Ask)));
                            doc.Blocks.Add(new Paragraph(new Run("     A. " + q.Answer)));
                        }
                    }
                }
            }

            if (Issues.Any())
            {
                i = 0;
                doc.Blocks.Add(new Paragraph(new Bold(new Run("Issues"))));
                foreach (var item in Issues)
                {
                    doc.Blocks.Add(new Paragraph(new Run(" " + (++i).ToString() + ". " + item.Description)));
                    doc.Blocks.Add(new Paragraph(new Italic(new Run("  Is Open: " + item.IsOpen.ToString()))));
                }
            }

            if (Queries.Any())
            {
                doc.Blocks.Add(new Paragraph(new Bold(new Run("Queries"))));
                foreach (var item in Queries)
                {
                    var itemUri = new Uri(item.Value);
                    var itemUrl = new Hyperlink(new Run(item.Value));
                    doc.Blocks.Add(new Paragraph(itemUrl));
                }
            }

            if (Scripts.Any())
            {
                doc.Blocks.Add(new Paragraph(new Bold(new Run("Scripts"))));
                foreach (var item in Scripts)
                {
                    var itemUri = new Uri(item.Value);
                    var itemUrl = new Hyperlink(new Run(item.Value));
                    doc.Blocks.Add(new Paragraph(itemUrl));
                }
            }

            if (TestCases.Any())
            {
                i = 0;
                doc.Blocks.Add(new Paragraph(new Bold(new Run("Test Cases"))));
                foreach (var item in TestCases)
                {
                    doc.Blocks.Add(new Paragraph(new Run(" " + (++i).ToString() + ". " + item.Description)));
                    doc.Blocks.Add(new Paragraph(new Italic(new Run("  Status: " + item.Status.ToString()))));

                    if (item.Steps.Any())
                    {
                        j = 0;
                        doc.Blocks.Add(new Paragraph(new Italic(new Run(" Steps"))));
                        foreach (var q in item.Steps)
                        {
                            doc.Blocks.Add(new Paragraph(new Run("   " + (++j).ToString() + ". " + q.Value)));
                        }
                    }
                }
            }

            if (Checkups.Any())
            {
                i = 0;
                doc.Blocks.Add(new Paragraph(new Bold(new Run("Checkups"))));
                foreach (var item in Checkups)
                {
                    doc.Blocks.Add(new Paragraph(new Run(" " + (++i).ToString() + ". " + item.Description)));
                    doc.Blocks.Add(new Paragraph(new Italic(new Run("  Applied: " + item.Applied.ToString()))));
                }
            }

            if (SubTasks.Any())
            {
                i = 0;
                doc.Blocks.Add(new Paragraph(new Bold(new Run("SubTasks"))));
                foreach (var item in SubTasks)
                {
                    doc.Blocks.Add(new Paragraph(new Run(" " + (++i).ToString() + ". " + item.Title)));
                    doc.Blocks.Add(new Paragraph(new Italic(new Run("  Status: " + item.Status))));
                }
            }

            return(doc);
        }
 private bool RunSelectedScriptsCommandCanExecute()
 {
     return(Scripts.Any(script => script.IsChecked));
 }
 private bool ClearScriptsCommandCanExecute()
 {
     return(Scripts.Any());
 }
 private bool RemoveScriptCommandCanExecute()
 {
     return(Scripts.Any(script => script.IsSelected));
 }