private void Button_Click(object sender, RoutedEventArgs e)
        {
            var api = ((App)App.Current).Api;
            api.CatalogUpdateCompleted += new EventHandler<EchoNestApiEventArgs>(api_CatalogUpdateCompleted);

            var songsActions = new List<CatalogAction<BMSong>>();
            using (var mediaLib = new MediaLibrary())
            {
                foreach (var song in mediaLib.Songs)
                {
                    var catalogAction = new CatalogAction<BMSong>();
                    catalogAction.Action = CatalogAction<BMSong>.ActionType.update;
                    catalogAction.Item = new BMSong
                    {
                        ItemId = Guid.NewGuid().ToString("D"),
                        ArtistName = song.Artist.Name,
                        SongName = song.Name,
                    };

                    songsActions.Add(catalogAction);
                }
            }

            var catalog = new Catalog();
            catalog.Id = catalogId.Text;
            catalog.SongActions = songsActions;

            api.CatalogUpdateAsync(catalog, null, null);
        }
Пример #2
0
        public void LinkButton_Command(object sender, CommandEventArgs e)
        {
            CatalogAction action = new CatalogAction(Context);

            action.ShowProductsByCategory(e.CommandArgument.ToString());
            this.CurrentController.NextView = action.NextViewToDisplay;
        }
Пример #3
0
        private void RepeaterProduct_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
        {
            CatalogAction action = new CatalogAction(Context);

            action.ShowItemsByProduct(e.CommandArgument.ToString());
            this.CurrentController.NextView = action.NextViewToDisplay;
        }
Пример #4
0
        private void LinkButtonSearch_Click(object sender, System.EventArgs e)
        {
            string keywords = TextBoxSearch.Text;

            CatalogAction action = new CatalogAction(Context);

            action.SearchProducts(keywords);
            this.CurrentController.NextView = action.NextViewToDisplay;
        }
Пример #5
0
 protected void RepeaterItem_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "ShowItem")
     {
         CatalogAction action = new CatalogAction(Context);
         action.ShowItem(e.CommandArgument.ToString());
         this.CurrentController.NextView = action.NextViewToDisplay;
     }
     else if (e.CommandName == "AddToCart")
     {
         ShoppinAction action = new ShoppinAction(Context);
         action.AddItemToCart(e.CommandArgument.ToString());
         this.CurrentController.NextView = action.NextViewToDisplay;
     }
 }
Пример #6
0
 private void Page_Load(object sender, System.EventArgs e)
 {
     if (IsPostBack && (Request.Form["__EVENTTARGET"] == "BODY_CONTROL"))
     {
         CatalogAction action = new CatalogAction(this.Context);
         try
         {
             action.ShowProductsByCategory(Request.Form["__EVENTARGUMENT"]);
             this.CurrentController.NextView = action.NextViewToDisplay;
         }
         catch
         {
             this.CurrentController.NextView = WebViews.ERROR;
         }
     }
 }
Пример #7
0
 protected void RepeaterCart_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "RemoveItem")
     {
         ShoppinAction action = new ShoppinAction(this.Context);
         action.RemoveItemFromCart(e.CommandArgument.ToString());
         this.CurrentController.NextView = action.NextViewToDisplay;
     }
     else if (e.CommandName == "Update")
     {
         this.CurrentController.NextView = WebViews.CART;
     }
     else if (e.CommandName == "ShowItem")
     {
         CatalogAction action = new CatalogAction(this.Context);
         action.ShowItem(e.CommandArgument.ToString());
         this.CurrentController.NextView = action.NextViewToDisplay;
     }
 }
Пример #8
0
 public CatalogActionAddedEvent(IAcSession acSession, CatalogAction source)
     : base(acSession, source)
 {
 }
Пример #9
0
 public CatalogActionUpdatedEvent(IAcSession acSession, CatalogAction source)
     : base(acSession, source)
 {
 }
Пример #10
0
        public ActionResult AddOrUpdateCatalogActions()
        {
            String json = Request["data"];
            var    rows = (ArrayList)MiniJSON.Decode(json);

            foreach (Hashtable row in rows)
            {
                //根据记录状态,进行不同的增加、删除、修改操作
                String state = row["_state"] != null ? row["_state"].ToString() : "";

                if (state == "modified" || state == "") //更新:_state为空或modified
                {
                    var inputModel = new CatalogAction(new Guid(row["Id"].ToString()))
                    {
                        CatalogId = new Guid(row["CatalogId"].ToString()),
                        ActionId  = new Guid(row["ActionId"].ToString()),
                        IsAudit   = row["IsAudit"].ToString(),
                        IsAllowed = row["IsAllowed"].ToString()
                    };
                    var action = AcDomain.NodeHost.Ontologies.GetAction(inputModel.ActionId);
                    if (action == null)
                    {
                        throw new ValidationException("意外的本体动作标识" + action.Id);
                    }
                    OntologyDescriptor ontology;
                    if (!AcDomain.NodeHost.Ontologies.TryGetOntology(action.Id, out ontology))
                    {
                        throw new ValidationException("意外的动作本体标识" + action.OntologyId);
                    }
                    CatalogState catalog;
                    if (!AcDomain.CatalogSet.TryGetCatalog(inputModel.CatalogId, out catalog))
                    {
                        throw new ValidationException("意外的目录标识");
                    }
                    var           ontologyOrgDic = AcDomain.NodeHost.Ontologies.GetOntologyCatalogs(ontology);
                    CatalogAction entity         = null;
                    if (ontologyOrgDic.ContainsKey(catalog))
                    {
                        entity = new CatalogAction(inputModel.Id)
                        {
                            ActionId  = inputModel.ActionId,
                            IsAllowed = inputModel.IsAllowed,
                            IsAudit   = inputModel.IsAudit,
                            CatalogId = inputModel.CatalogId
                        };
                        AcDomain.PublishEvent(new CatalogActionUpdatedEvent(AcSession, entity));
                    }
                    else
                    {
                        entity           = new CatalogAction(inputModel.Id);
                        entity.CatalogId = inputModel.CatalogId;
                        entity.ActionId  = inputModel.ActionId;
                        entity.IsAudit   = inputModel.IsAudit;
                        entity.IsAllowed = inputModel.IsAllowed;
                        AcDomain.PublishEvent(new CatalogActionAddedEvent(AcSession, entity));
                    }
                    AcDomain.CommitEventBus();
                }
            }

            return(this.JsonResult(new ResponseData {
                success = true
            }));
        }