Ejemplo n.º 1
0
 /// <summary>
 /// Constructor for default response (without custom message)
 /// </summary>
 /// <param name="action">The response action</param>
 public CommandResponse(ResponseAction action)
 {
     Action = action;
 }
Ejemplo n.º 2
0
 public Response()
 {
     Action = ResponseAction.Continue;
 }
Ejemplo n.º 3
0
 public void Redirect(String url)
 {
     RedirectUrl = url;
     Action = ResponseAction.Redirect;
 }
Ejemplo n.º 4
0
 public Response(string t, ResponseAction a, Action action)
 {
     Conditions = new List<ResponseCondition>();
     Text = t;
     Action = a;
     CustomAction = action;
     Paramater = null;
 }
Ejemplo n.º 5
0
 public BaseResponse(bool success, ResponseAction responseAction)
 {
     IsSuccess           = success;
     this.ResponseAction = responseAction;
 }
Ejemplo n.º 6
0
 public RawActionResult(ResponseAction response)
 {
     Response = response;
 }
Ejemplo n.º 7
0
 public Response(string t, ResponseAction a, string param)
 {
     Conditions = new List<ResponseCondition>();
     Text = t;
     Action = a;
     Paramater = param;
 }
Ejemplo n.º 8
0
 public void Cancel()
 {
     Action = ResponseAction.Cancel;
 }
Ejemplo n.º 9
0
 public void Redirect(String url)
 {
     RedirectUrl = url;
     Action      = ResponseAction.Redirect;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// A response to being interacted with.
 /// </summary>
 /// <param name="text">What the entity in question says.</param>
 /// <param name="action">The action they subsequently take, if anything.</param>
 /// <param name="data">Any associated data with said Action.</param>
 public Response(String text, ResponseAction action = ResponseAction.None, Object data = null)
 {
     this.text   = text;
     this.action = action;
     this.data   = data;
 }
Ejemplo n.º 11
0
 public Response()
 {
     Action = ResponseAction.Continue;
 }
Ejemplo n.º 12
0
        public ChristmasAgent()
        {
            Name = "ChristmasAgent";

            DialogueProcess openingDialogue = new DialogueProcess();

            openingDialogue.Name            = "openingDialogue";
            openingDialogue.ActiveOnStartup = true;
            openingDialogue.SetOwnerAgent(this);
            BrainProcessList.Add(openingDialogue);

            InteractionItem openingItem = new InteractionItem();

            //openingItem.MillisecondDelay = 5000; // TODO: Just delays windows opening
            openingDialogue.ItemList.Add(openingItem);
            openingItem.Name = "openingItem";
            OutputAction initialGreetingAction = new OutputAction();

            openingItem.ActionList.Add(initialGreetingAction);

            initialGreetingAction.OutputList.Add("Hello");
            initialGreetingAction.OutputList.Add("Hi");
            initialGreetingAction.OutputList.Add("Hey");

            InteractionItem howWasChristmasItem = new InteractionItem(); //Doesn't work with dialogueitem?

            openingDialogue.ItemList.Add(howWasChristmasItem);
            howWasChristmasItem.Name = "howWasChristmasItem";
            initialGreetingAction.TargetDialogueItemName = howWasChristmasItem.Name;
            ResponseAction howWasChristmasAction = new ResponseAction();

            howWasChristmasAction.InputList.Add("Hello");
            howWasChristmasAction.InputList.Add("Hi");
            howWasChristmasAction.InputList.Add("Hey");
            howWasChristmasAction.OutputList.Add("How was christmas?");
            howWasChristmasAction.OutputList.Add("How was your christmas?");
            //howWasChristmasAction.OutputList.Add("bla");
            howWasChristmasItem.ActionList.Add(howWasChristmasAction);

            DialogueProcess christmasDialogue = new DialogueProcess();

            christmasDialogue.Name            = "christmasDialogue";
            christmasDialogue.ActiveOnStartup = false;
            christmasDialogue.SetOwnerAgent(this);
            BrainProcessList.Add(christmasDialogue);
            howWasChristmasAction.BrainProcessToActivate = christmasDialogue.Name;

            InteractionItem christmasInquiryStartItem = new InteractionItem();

            christmasInquiryStartItem.Name = "christmasInquiryStartItem";
            christmasDialogue.ItemList.Add(christmasInquiryStartItem);
            christmasDialogue.ProcessActivatedOnFailure = openingDialogue.Name;

            ResponseAction ra_good = new ResponseAction();

            christmasInquiryStartItem.ActionList.Add(ra_good);
            ra_good.BrainProcessToDeactivate = christmasDialogue.Name;
            ra_good.InputList.Add("Good");
            ra_good.InputList.Add("Alright");
            ra_good.InputList.Add("Great");
            ra_good.OutputList.Add("I'm very happy to hear that!");
            ra_good.OutputList.Add("Good for you!");
            ra_good.OutputList.Add("Lovely!");

            // ================================================================
            //Good christmas inquiry
            // ================================================================
            DialogueProcess goodChristmasDialogue = new DialogueProcess();

            goodChristmasDialogue.Name            = "goodChristmasDialogue";
            goodChristmasDialogue.ActiveOnStartup = false;
            goodChristmasDialogue.SetOwnerAgent(this);
            BrainProcessList.Add(goodChristmasDialogue);
            ra_good.BrainProcessToActivate = goodChristmasDialogue.Name;

            InteractionItem goodChristmasItem = new InteractionItem();

            goodChristmasItem.Name             = "goodChristmasItem";
            ra_good.TargetDialogueItemName     = goodChristmasItem.Name;
            goodChristmasItem.MillisecondDelay = 500;
            OutputAction anythingElse = new OutputAction();

            anythingElse.OutputList.Add("Did you want to talk about anything else?");
            anythingElse.OutputList.Add("Anything else on your mind?");
            //anythingElse.BrainProcessToDeactivate = christmasDialogue.Name;
            goodChristmasItem.ActionList.Add(anythingElse);
            goodChristmasDialogue.ItemList.Add(goodChristmasItem);

            InteractionItem goodChristmasResponseItem = new InteractionItem();

            goodChristmasResponseItem.Name = "goodChristmasResponseItem";
            //goodChristmasDialogue.ItemList.Add(goodChristmasResponseItem);
            anythingElse.TargetDialogueItemName = goodChristmasResponseItem.Name;

            ResponseAction nothingElse = new ResponseAction();

            nothingElse.InputList.Add("No");
            nothingElse.InputList.Add("That's not it");
            nothingElse.InputList.Add("Nope");
            nothingElse.OutputList.Add("Ok, see you later!");
            nothingElse.OutputList.Add("Good.");
            nothingElse.OutputList.Add("Good bye!");
            goodChristmasResponseItem.ActionList.Add(nothingElse);

            ResponseAction somethingElse = new ResponseAction();

            somethingElse.InputList.Add("Yes");
            somethingElse.InputList.Add("Yeah");
            somethingElse.InputList.Add("Aye");
            somethingElse.OutputList.Add("*Crickets*");
            somethingElse.OutputList.Add("Tell it to someone else.");
            somethingElse.OutputList.Add("I don't want to hear it.");
            goodChristmasResponseItem.ActionList.Add(somethingElse);

            goodChristmasDialogue.ItemList.Add(goodChristmasResponseItem);
            // ================================================================
            // Branch end
            // ================================================================

            ResponseAction ra_bad = new ResponseAction();

            christmasInquiryStartItem.ActionList.Add(ra_bad);
            ra_bad.BrainProcessToDeactivate = openingDialogue.Name;
            ra_bad.InputList.Add("Bad");
            ra_bad.InputList.Add("Awful");
            ra_bad.InputList.Add("Terrible");

            Random random = new Random();
            double r      = random.NextDouble();

            if (r < 0.25)
            {
                ra_bad.OutputList.Add("I'm sorry to hear that, next year will be better.");
                ra_bad.OutputList.Add("Ooh a new UDP packet, gotta go!");
            }
            else
            {
                ra_bad.OutputList.Add("Were you unhappy with your presents?");
                ra_bad.OutputList.Add("Were you disappointed with your presents?");

                DialogueProcess presentsDialogue = new DialogueProcess();
                presentsDialogue.Name            = "presentsDialogue";
                presentsDialogue.ActiveOnStartup = false;
                BrainProcessList.Add(presentsDialogue); //MUST add to list, will show in memory regardless though
                ra_bad.BrainProcessToActivate = presentsDialogue.Name;

                InteractionItem presentsItem = new InteractionItem();
                presentsDialogue.ItemList.Add(presentsItem);

                ResponseAction ra_good_presents = new ResponseAction();
                presentsItem.ActionList.Add(ra_good_presents);
                //ra_good_presents.BrainProcessToDeactivate = helloDialogue.Name;
                ra_good_presents.InputList.Add("No");
                ra_good_presents.InputList.Add("That's not it");
                ra_good_presents.InputList.Add("Nope");
                ra_good_presents.OutputList.Add("Then I can't help you.");
                ra_good_presents.OutputList.Add("In that case, I can't help you.");

                //Branch end

                ResponseAction ra_bad_presents = new ResponseAction();
                presentsItem.ActionList.Add(ra_bad_presents);
                //ra_bad_presents.BrainProcessToDeactivate = helloDialogue.Name;
                ra_bad_presents.InputList.Add("Yes");
                ra_bad_presents.InputList.Add("Yeah");
                ra_bad_presents.InputList.Add("Aye");
                ra_bad_presents.InputList.Add("Yes they were cheap");
                ra_bad_presents.OutputList.Add("Shall I add your friends and family to your list of enemies?");

                InteractionItem enemiesItem = new InteractionItem();
                presentsDialogue.ItemList.Add(enemiesItem);
                enemiesItem.Name = "enemiesItem";
                ra_bad_presents.TargetDialogueItemName = enemiesItem.Name;

                ResponseAction enemiesAction = new ResponseAction();
                enemiesItem.ActionList.Add(enemiesAction);
                enemiesAction.InputList.Add("Yes");
                enemiesAction.InputList.Add("Yes, and their pets");
                enemiesAction.OutputList.Add("They've been added to your list of mortal enemies.");
                enemiesAction.OutputList.Add("Done. You're a terrible person.");

                ResponseAction noEnemiesAction = new ResponseAction();
                enemiesItem.ActionList.Add(noEnemiesAction);
                noEnemiesAction.InputList.Add("No");
                noEnemiesAction.InputList.Add("Don't do that");
                noEnemiesAction.InputList.Add("Nope");
                noEnemiesAction.OutputList.Add("I'm going to do it anyway. Good bye!");
                noEnemiesAction.OutputList.Add("Maybe next year. See you then!");

                /*
                 * MemoryAccessItem readEnemyItem = new MemoryAccessItem();
                 * readEnemyItem.Name = "mai";
                 * enemiesAction.TargetDialogueItemName = readEnemyItem.Name;
                 * ReadByTagAction rbta = new ReadByTagAction();
                 * readEnemyItem.ActionList.Add(rbta);
                 *
                 * MemoryItem mi = new MemoryItem();
                 * mi.Content = "Friends and family and their pets";
                 * mi.Tag = "MortalEnemies";
                 * WorkingMemory.InsertItem(mi);
                 * rbta.Tag = mi.Tag;
                 */
            }
        }
Ejemplo n.º 13
0
 public GetOrderResponse(bool success, ResponseAction responseAction) : base(success, responseAction)
 {
 }
Ejemplo n.º 14
0
 public ClearCartResponse(bool success, ResponseAction action) : base(success, action)
 {
 }
Ejemplo n.º 15
0
 public HeaderResult(ResponseAction action, string name, string value = null)
 {
     Action = action;
     Name = name;
     Value = value;
 }
        public TwitterPostHandler(ITokenizer tokenizer, IRepository <TwitterPostPartRecord> repository, ITwitterService TwitterService, IOrchardServices orchardServices, INotifier notifier)
        {
            _TwitterService  = TwitterService;
            _orchardServices = orchardServices;
            _tokenizer       = tokenizer;
            _notifier        = notifier;
            T = NullLocalizer.Instance;
            Filters.Add(StorageFilter.For(repository));
            //    Filters.Add(new ActivatingFilter<TwitterPostPart>("CommunicationAdvertising"));
            OnUpdated <TwitterPostPart>((context, part) => {
                TwitterPostPartSettingVM setting = part.Settings.GetModel <TwitterPostPartSettingVM>();
                var tokens = new Dictionary <string, object> {
                    { "Content", part.ContentItem }
                };
                if (!string.IsNullOrEmpty(setting.Description))
                {
                    part.TwitterDescription = _tokenizer.Replace(setting.Description, tokens);
                }
                var urlHelper = new UrlHelper(_orchardServices.WorkContext.HttpContext.Request.RequestContext);
                if (string.IsNullOrEmpty(setting.Image))
                {
                    part.TwitterPicture = "";
                }
                else
                {
                    string listid = _tokenizer.Replace(setting.Image, tokens);
                    listid        = listid.Replace("{", "").Replace("}", "");
                    Int32 idimage = 0;
                    Int32.TryParse(listid.Split(',')[0], out idimage);
                    if (idimage > 0)
                    {
                        var ContentImage    = _orchardServices.ContentManager.Get(idimage, VersionOptions.Published);
                        var pathdocument    = Path.Combine(ContentImage.As <MediaPart>().FolderPath, ContentImage.As <MediaPart>().FileName);
                        part.TwitterPicture = pathdocument;
                    }
                    else
                    {
                        part.TwitterPicture = "";
                    }
                }
                if (!string.IsNullOrEmpty(setting.Title))
                {
                    part.TwitterTitle = _tokenizer.Replace(setting.Title, tokens);
                }
            });
            OnPublished <TwitterPostPart>((context, Twitterpart) => {
                try {
                    PostToTwitterViewModel Fvm = new PostToTwitterViewModel();
                    Fvm.Message = Twitterpart.TwitterMessage;
                    if (Twitterpart.ContentItem.ContentType == "CommunicationAdvertising")
                    {
                        ICommunicationService _communicationService;
                        bool tryed = _orchardServices.WorkContext.TryResolve <ICommunicationService>(out _communicationService);
                        if (tryed)
                        {
                            Fvm.Link = _communicationService.GetCampaignLink("Twitter", Twitterpart);
                        }
                        else
                        {
                            Fvm.Link = "";
                        }
                    }
                    else
                    if (Twitterpart.TwitterCurrentLink)
                    {
                        var urlHelper = new UrlHelper(_orchardServices.WorkContext.HttpContext.Request.RequestContext);
                        Fvm.Link      = urlHelper.MakeAbsolute(urlHelper.ItemDisplayUrl(Twitterpart));// get current display link
                    }


                    Fvm.Picture = Twitterpart.TwitterPicture;

                    Fvm.AccountList = Twitterpart.AccountList;
                    if (Twitterpart.SendOnNextPublish && !Twitterpart.TwitterMessageSent)
                    {
                        if (Twitterpart.AccountList.Length == 0)
                        {
                            _notifier.Add(NotifyType.Warning, T("No Twitter account specified."));
                        }
                        else
                        {
                            ResponseAction rsp = _TwitterService.PostTwitter(Fvm);
                            if (rsp.Success)
                            {
                                Twitterpart.TwitterMessageSent = true;
                            }
                        }
                    }
                }
                catch (Exception ex) {
                    _notifier.Add(NotifyType.Error, T("Twitter error:" + ex.Message));
                }
            });
        }
Ejemplo n.º 17
0
 static Response Response(string text, ResponseAction action, string param)
 {
     return new Response(text, action, param);
 }
Ejemplo n.º 18
0
 public GetShoppingCartCountResponse(bool success, ResponseAction responseAction, int count) : base(success, responseAction)
 {
     Count = count;
 }
Ejemplo n.º 19
0
 public AddProductResponse(bool success, ResponseAction responseAction) : base(success, responseAction)
 {
 }
 public SaveCustomerResponse(bool success, ResponseAction responseAction, CustomerDTO customer) : base(success, responseAction)
 {
     Customer = customer;
 }
Ejemplo n.º 21
0
 public Response(string t, ResponseAction a)
 {
     Conditions = new List<ResponseCondition>();
     Text = t;
     Action = a;
     Paramater = null;
 }
 public GetCustomerOrdersResponse(bool success, ResponseAction responseAction) : base(success, responseAction)
 {
 }
Ejemplo n.º 23
0
 public CreatedResponse(bool success, ResponseAction responseAction) : base(success, responseAction)
 {
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Constructor for default response (without custom message)
 /// </summary>
 /// <param name="action">The response action</param>
 public CommandResponse(ResponseAction action)
 {
     Action = action;
 }
Ejemplo n.º 25
0
            public void Then(ResponseAction <T> action)
            {
                var reg = new ActionRegistration(_ActionKey, action);

                _Machine._ResponseActions.Add(reg);
            }
Ejemplo n.º 26
0
 /// <summary>
 /// Constructor for default response
 /// </summary>
 /// <param name="message">The message for the chat</param>
 /// <param name="action">The reponse action</param>
 public CommandResponse(string message, ResponseAction action)
 {
     Message = message;
     Action  = action;
 }
Ejemplo n.º 27
0
 public void Cancel()
 {
     Action = ResponseAction.Cancel;
 }
Ejemplo n.º 28
0
 public CompleteOrderResponse(bool success, ResponseAction responseAction) : base(success, responseAction)
 {
 }
 public UnauthorizedResult(string scheme, ResponseAction responseAction)
 {
     _scheme = scheme;
     _responseAction = responseAction;
 }
        /// <summary>
        ///		Create a copy of the request with the specified response-processing action.
        /// </summary>
        /// <typeparam name="TContext">
        ///		The type of object used by the request when resolving deferred template parameters.
        /// </typeparam>
        /// <param name="request">
        ///		The HTTP request.
        /// </param>
        /// <param name="responseAction">
        ///		A delegate that configures incoming response messages.
        /// </param>
        /// <returns>
        ///		The new <see cref="HttpRequest{TContext}"/>.
        /// </returns>
        public static HttpRequest <TContext> WithResponseAction <TContext>(this HttpRequest <TContext> request, ResponseAction <TContext> responseAction)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

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

            return(request.Clone(properties =>
            {
                properties[nameof(HttpRequest.ResponseActions)] = request.ResponseActions.Add(responseAction);
            }));
        }
Ejemplo n.º 31
0
 /// <summary>
 /// Constructor for default response
 /// </summary>
 /// <param name="message">The message for the chat</param>
 /// <param name="action">The reponse action</param>
 public CommandResponse(string message, ResponseAction action)
 {
     Message = message;
     Action = action;
 }
Ejemplo n.º 32
0
 public HeaderResult(ResponseAction action, string name, string value = null)
 {
     Action = action;
     Name   = name;
     Value  = value;
 }
Ejemplo n.º 33
0
 /// <summary>
 /// A response to being interacted with.
 /// </summary>
 /// <param name="text">What the entity in question says.</param>
 /// <param name="action">The action they subsequently take, if anything.</param>
 /// <param name="data">Any associated data with said Action.</param>
 public Response(String text, ResponseAction action = ResponseAction.None, Object data = null)
 {
     this.text = text;
     this.action = action;
     this.data = data;
 }
 public UnauthorizedResult(string scheme, ResponseAction responseAction)
 {
     _scheme         = scheme;
     _responseAction = responseAction;
 }
Ejemplo n.º 35
0
 static Response Response(string text, ResponseAction action, Action custaction)
 {
     return new Response(text, action, custaction);
 }
Ejemplo n.º 36
0
 public void addResponseListener(string idAction, ResponseAction onResponse, ErrorAction onError)
 {
     responses[idAction] = onResponse;
     errors[idAction]    = onError;
 }