private void OnWorkItemsButtonCommand(object param) { //IUnityContainer container = new UnityContainer(); //container.RegisterType<IWorkItemsModel, WorkItemsModel>(); //container.RegisterType<IWorkItemsViewModel, WorkItemsViewModel>(); //var workItemsView = container.Resolve<WorkItemsView>(); //workItemsView.Show(); var workItemsModel = new WorkItemsModel(); var workItemsViewModel = new WorkItemsViewModel(workItemsModel); var workItemsView = new WorkItemsView { DataContext = workItemsViewModel }; workItemsView.Show(); }
public RootTopic(IBotContext context) : base(context) { // User state initialization should be done once in the welcome // new user feature. Placing it here until that feature is added. if (context.State.UserProperties[Constants.USER_STATE_WORKITEMS] == null) { context.State.UserProperties[Constants.USER_STATE_WORKITEMS] = new List <Workitem>(); } this.SubTopics.Add(Constants.ADD_WORKITEM_TOPIC, () => { var addWorkitemTopic = new AddWorkItemTopic(); if (context.State.UserProperties["owner"] != null && addWorkitemTopic.State.Workitem != null) { addWorkitemTopic.State.Workitem.Owner = context.State.UserProperties["owner"]; } addWorkitemTopic.Set .OnSuccess((ctx, workitem) => { this.ClearActiveTopic(); workitem.Attachment = $"{Startup.BlobEndPoint}{Startup.BlobContainerName}/{workitem.Attachment}"; ((List <Workitem>)ctx.State.UserProperties[Constants.USER_STATE_WORKITEMS]).Add(workitem); WorkItemsView.ShowWorkItems(context, context.State.UserProperties[Constants.USER_STATE_WORKITEMS], Accessor, true); SqlUtils sql = new SqlUtils(Startup.ConnectionString); sql.CreateNewWorkItem(workitem); }) .OnFailure((ctx, reason) => { this.ClearActiveTopic(); context.Reply("Let's try something else."); this.ShowDefaultMessage(ctx); }); return(addWorkitemTopic); }); }
private void OnRowClicked(object sender, TreeViewRowEventArgs e) { var node = _treeStore.GetNavigatorAt(e.Position); var nodeType = node.GetValue(_type); switch (nodeType) { case NodeType.SourceControl: node.MoveToParent(); var project = (ProjectInfo)node.GetValue(_item); SourceControlExplorerView.Open(project); break; case NodeType.WorkItemQuery: var query = (StoredQuery)node.GetValue(_item); WorkItemsView.Open(query); break; default: break; } }
public override Task OnReceiveActivity(IBotContext context) { if ((context.Request.Type == ActivityTypes.Message) && (!string.IsNullOrEmpty(context.Request.AsMessageActivity().Text) || context.Request.AsMessageActivity().Attachments != null)) { var message = context.Request.AsMessageActivity(); // If the user wants to change the topic of conversation... if (context.TopIntent != null && context.TopIntent.Score > 0.7) { if (context.TopIntent.Name == "intent.image") { context.Reply(((LuisEntity)context.TopIntent.Entities[0]).Value); } if (context.TopIntent.Name == "intent.currentuser") { if (context.State.UserProperties["owner"] != null) { context.Reply($"Current user: {context.State.UserProperties["owner"]}"); } else { context.Reply($"I've not recognized yet. What's your name?"); } return(Task.CompletedTask); } if (context.TopIntent.Name == "intent.workitem.add") { // Set the active topic and let the active topic handle this turn. this.SetActiveTopic(Constants.ADD_WORKITEM_TOPIC) .OnReceiveActivity(context); return(Task.CompletedTask); } if (context.TopIntent.Name == "intent.workitem.list") { this.ClearActiveTopic(); SqlUtils sql = new SqlUtils(Startup.ConnectionString); var owner = context.State.UserProperties["owner"]; //WorkItemsView.ShowWorkItems(context, context.State.UserProperties[Constants.USER_STATE_WORKITEMS], Accessor); WorkItemsView.ShowWorkItems(context, sql.GetWorkItems(owner), Accessor); return(Task.CompletedTask); } if (context.TopIntent.Name == "intent.help") { this.ClearActiveTopic(); this.ShowHelp(context); return(Task.CompletedTask); } if (context.TopIntent.Name == "intent.restart") { this.ClearActiveTopic(); context.State.ConversationProperties.Clear(); context.State.UserProperties.Clear(); //return Task.CompletedTask; } } // If there is an active topic, let it handle this turn until it completes. if (HasActiveTopic) { ActiveTopic.OnReceiveActivity(context); return(Task.CompletedTask); } ShowDefaultMessage(context); } return(Task.CompletedTask); }