Exemplo n.º 1
0
        public void Create()
        {
            lines = new List <ImportLine>();

            partner = partnerRepository.GetByCode(feedImporter.PartnerCode);

            trends         = new List <Trend>(trendRepository.GetCurrentTrends());
            silouhettes    = new List <Silouhette>(silouhetteRepository.GetAll());
            patterns       = new List <Pattern>(patternRepository.GetAll());
            colorFamilies  = new List <ColorFamily>(colorFamilyRepository.GetAll());
            outfitUpdaters = new List <OutfitUpdater>(outfitUpdaterRepository.GetFor(partner));

            // Retrieve Keywords
            colorFamilyKeywords = colorFamilyRepository.GetKeywordsByPartner(partner);
            patternKeywords     = patternRepository.GetKeywordsByPartner(partner);
            silouhetteKeywords  = silouhetteRepository.GetKeywordsByPartner(partner);

            // Set discard words
            wordsForDiscard.Add("men");
            wordsForDiscard.Add("mens");
            wordsForDiscard.Add("men's");
            wordsForDiscard.Add("men´s");
            wordsForDiscard.Add("kid");
            wordsForDiscard.Add("kids");
            wordsForDiscard.Add("kid's");
            wordsForDiscard.Add("infant");
            wordsForDiscard.Add("girl");
            wordsForDiscard.Add("boy");
            wordsForDiscard.Add("girls");
            wordsForDiscard.Add("boys");
            wordsForDiscard.Add("girl’s");
            wordsForDiscard.Add("boy’s");
            wordsForDiscard.Add("girl's");
            wordsForDiscard.Add("boy's");
            wordsForDiscard.Add("Toddler");
            wordsForDiscard.Add("4-6X");
            wordsForDiscard.Add("Newborn");
            wordsForDiscard.Add("Bedding Collection");
            wordsForDiscard.Add("Sleep Sense");
            wordsForDiscard.Add("7-16");
            wordsForDiscard.Add("Pajamas");
            wordsForDiscard.Add("Bra");
            wordsForDiscard.Add("Hipster");
            wordsForDiscard.Add("8-20");
            wordsForDiscard.Add("swimsuit");
            wordsForDiscard.Add("luggage");
            wordsForDiscard.Add("table linens");
            wordsForDiscard.Add("2T-10");
            wordsForDiscard.Add("China");
            wordsForDiscard.Add("stemwear");
            wordsForDiscard.Add("cuff links");
            wordsForDiscard.Add("Noritake");
            wordsForDiscard.Add("Jasmine & Ginger");

            _logger.InfoFormat("Looping through file");
            feedImporter.FeedLineRead += new FeedLineReadEventHandler(ouImportationClassBuilder_FeedLineRead);
            feedImporter.ProcessFeed();

            CheckToSaveLines();
        }
Exemplo n.º 2
0
        public ViewResult GarmentSelector()
        {
            if (IsLogged())
            {
                return(View("Redirect"));
            }

            if (Session["FashionFlavorSelected"] == null)
            {
                GetDataForIndex();
                return(View("Index", fashionFlavorRepository.GetAll()));
            }
            List <FashionFlavor> selectedFF = Session["FashionFlavorSelected"] as List <FashionFlavor>;
            List <EventType>     selectedET = (List <EventType>)Session["EventTypeSelected"];

            if (selectedFF != null)
            {
                List <Silouhette> silouhettes = silouhetteRepository.GetByFlavors(selectedFF, selectedET) as List <Silouhette>;
                if (silouhettes != null)
                {
                    IList <Fabric> fabrics  = fabricRepository.GetForSilouhette(silouhettes[0], selectedET);
                    Pattern        solid    = patternRepository.GetSolid();
                    List <Garment> garments = garmentRepository.GetBySelection(silouhettes[0], fabrics[0], solid, selectedET) as List <Garment>;
                    ViewData["Silouhettes"]  = silouhettes;
                    ViewData["Garments"]     = garments;
                    ViewData["SilouhetteId"] = silouhettes[0].Id;
                    ViewData["PatternId"]    = solid.Id;
                    ViewData["Patterns"]     = patternRepository.GetAll();
                    ViewData["Fabrics"]      = fabrics;
                    ViewData["FabricId"]     = fabrics[0].Id;
                }
            }


            return(View(selectedFF));
        }
Exemplo n.º 3
0
        public ActionResult UploadGarment()
        {
            MembershipUser mu = Membership.GetUser();

            if (mu != null)
            {
                ViewData["UserName"] = mu.UserName;
            }

            RegisteredUser user = registeredUserRepository.GetByMembershipId(Convert.ToInt32(mu.ProviderUserKey));

            IList <FashionFlavor> flavors = new List <FashionFlavor>();

            foreach (UserFlavor flavor in user.UserFlavors)
            {
                flavors.Add(flavor.Flavor);
            }
            ViewData["FashionFlavors"] = flavors;

            IList <FashionAde.Core.Clothing.Color> colors = colorRepository.GetAll();
            List <SelectListItem> lstcolors = new List <SelectListItem>();

            foreach (FashionAde.Core.Clothing.Color color in colors)
            {
                SelectListItem sl = new SelectListItem();
                sl.Text  = color.Description;
                sl.Value = color.Id.ToString();
                lstcolors.Add(sl);
            }
            ViewData["Colors"] = lstcolors;

            IList <Pattern>       patterns    = patternRepository.GetAll();
            List <SelectListItem> lstPatterns = new List <SelectListItem>();

            foreach (Pattern pattern in patterns)
            {
                SelectListItem sl = new SelectListItem();
                sl.Text  = pattern.Description;
                sl.Value = pattern.Id.ToString();
                lstPatterns.Add(sl);
            }
            ViewData["Patterns"] = lstPatterns;

            IList <Fabric>        fabrics    = fabricRepository.GetAll();
            List <SelectListItem> lstFabrics = new List <SelectListItem>();

            foreach (Fabric fabric in fabrics)
            {
                SelectListItem sl = new SelectListItem();
                sl.Text  = fabric.Description;
                sl.Value = fabric.Id.ToString();
                lstFabrics.Add(sl);
            }
            ViewData["Fabrics"] = lstFabrics;

            IList <Silouhette>    silouhettes    = silouhetteRepository.GetAll();
            List <SelectListItem> lstsilouhettes = new List <SelectListItem>();

            foreach (Silouhette silouhette in silouhettes)
            {
                SelectListItem sl = new SelectListItem();

                sl.Text  = silouhette.Category.Description + " " + silouhette.Description;
                sl.Value = silouhette.Id.ToString();
                lstsilouhettes.Add(sl);
            }
            ViewData["Titles"] = lstsilouhettes;

            IList <EventType>     eventTypes    = eventTypeRepository.GetAll();
            List <SelectListItem> lsteventTypes = new List <SelectListItem>();

            foreach (EventType type in eventTypes)
            {
                SelectListItem sl = new SelectListItem();
                sl.Text  = type.Description;
                sl.Value = type.Id.ToString();
                lsteventTypes.Add(sl);
            }
            ViewData["EventTypes"] = lsteventTypes;

            LoadSeasons();

            return(View());
        }
Exemplo n.º 4
0
        private OutfitView BuildOutfitView(OutfitSearch outfitSearch, int?userId)
        {
            int    totalCount;
            string originalSearch = outfitSearch.Search;

            bool           showAsPublicCloset = ShowAsPublicCloset(userId);
            RegisteredUser user = (showAsPublicCloset)
                                ? registeredUserRepository.Get(userId.Value)
                                : registeredUserRepository.Get(this.ProxyLoggedUser.Id);

            BasicUser currentUser = null;

            if (User.Identity.IsAuthenticated)
            {
                currentUser = registeredUserRepository.Get(this.UserId);
            }

            if (!AccessClosetService.CanViewCloset(currentUser, user.Closet))
            {
                throw new NotPublicClosetException();
            }

            if (originalSearch == SEARCH_TEXT)
            {
                outfitSearch.Search = string.Empty;
            }

            GetOutfitsInfo(showAsPublicCloset);

            IList <ClosetOutfitView> lstResults = new List <ClosetOutfitView>();

            lstResults = this.Search(out totalCount, outfitSearch, user);
            string userName = Membership.GetUser(user.MembershipUserId).UserName;

            OutfitView ov = new OutfitView();

            ov.Search = new OutfitSearch();
            if (showAsPublicCloset)
            {
                ov.StyleAlerts = contentService.GetRandomStyleAlerts();
                foreach (ClosetOutfitView cov in lstResults)
                {
                    cov.Disabled          = true;
                    cov.ShowAddToMyCloset = true;
                    cov.SendToFriends     = false;
                }
                userName += "'s Outfits";
            }
            else
            {
                ov.StyleAlerts = contentService.GetRandomStyleAlerts((IList <FashionFlavor>)ViewData["fashionFlavors"]);
            }

            ov.FilterText                = originalSearch;
            ov.Closet                    = user.Closet;
            ov.UserName                  = userName;
            ov.Outfits                   = lstResults;
            ov.TotalOutfits              = totalCount;
            ov.Season                    = outfitSearch.Season;
            ov.PrivacyLevel              = user.Closet.PrivacyLevel.ToString();
            ov.CurrentPage               = outfitSearch.Page;
            ov.ShowAsPublicCloset        = showAsPublicCloset;
            ov.Search.ShowAsPublicCloset = showAsPublicCloset;
            ov.Search.Patterns           = patterRepository.GetAll() as List <Pattern>;
            ov.Search.Categories         = new List <SelectListItem>();
            SelectListItem noCategory = new SelectListItem();

            noCategory.Text  = NOCATEGORY;
            noCategory.Value = "0";
            ov.Search.Categories.Add(noCategory);
            ov.Search.Categories.AddRange(GetCategorySelectListItemList(categoryRepository.GetAll()));
            ov.Search.Trends = new List <SelectListItem>();
            SelectListItem noTrend = new SelectListItem();

            noTrend.Text  = NOTREND;
            noTrend.Value = "0";
            ov.Search.Trends.Add(noTrend);
            ov.Search.Trends.AddRange(GetTrendSelectListItemList(trendRepository.GetCurrentTrends()));
            ov.Search.Colors     = colorRepository.GetAll() as List <Color>;
            ov.Search.Page       = outfitSearch.Page;
            ov.Search.Season     = outfitSearch.Season;
            ov.Search.SeasonName = outfitSearch.SeasonName;
            ov.Search.EventTypes = new List <SelectListItem>();
            foreach (EventType eventType in user.EventTypes)
            {
                SelectListItem item = new SelectListItem();
                item.Text  = eventType.Description;
                item.Value = eventType.Id.ToString();
                ov.Search.EventTypes.Add(item);
            }
            ov.Search.Flavors = new List <SelectListItem>();
            foreach (UserFlavor userFlavor in user.UserFlavors)
            {
                SelectListItem item = new SelectListItem();
                item.Text  = userFlavor.Flavor.Name;
                item.Value = userFlavor.Flavor.Id.ToString();
                ov.Search.Flavors.Add(item);
            }
            ov.Search.SavedFilters = savedFilterRepository.GetAllFor(UserId) as List <SavedFilter>;

            if (user.Closet.FavoriteOutfit != null)
            {
                ClosetOutfitView couv = closetOutfitRepository.GetByClosetOutfitId(ov.FavoriteOutfitId);
                if (couv != null)
                {
                    ov.FavoriteOutfitId = user.Closet.FavoriteOutfit.Id;
                    ov.FavoriteOutfit   = couv.ShortEventTypes + ov.FavoriteOutfitId;
                }
            }
            else
            {
                ov.FavoriteOutfit = "None Selected";
            }


            ViewData["procesingCloset"] = user.Closet.CreationStatus == ClosetGarmentStatus.Pending && IsSameUser(user.Id);
            ViewData["userId"]          = user.Id;
            ViewData["closetUserId"]    = user.MembershipUserId;
            ov.Pager          = PagingHelper.Paging(totalCount, Convert.ToInt32(outfitSearch.Page), Convert.ToInt32(outfitSearch.PageSize), 4);
            ViewData["Pages"] = ov.Pager;
            //TODO: Hacer modificable este seteo
            ViewData["StyleAlertsStep"] = 5;

            foreach (ClosetOutfitView cov in lstResults)
            {
                if (cov.OutfitUpdater == null)
                {
                    cov.OutfitUpdater = outfitUpdaterRepository.Get(ConfigurationManager.AppSettings["DefaultOU"]);
                }

                //We also need to be able to obtain the number of impressiones (views) of an outfit updaters.
                TrackingHelper.SaveOutfitUpdaterInfo(cov.OutfitUpdater.Id.ToString(), cov.ClosetOutfitId.ToString());
            }
            ov.Search.Public = false;

            return(ov);
        }
        public void Create()
        {
            InitializePerformanceCounters();
            if (ramCounter.NextValue() < (ramTotal * MemorySafe))
            {
                WriteInfo(string.Format("Safe Memory Limit"), string.Format("Available = {0} < Safe Limit = {1}MB", getAvailableRAM(), ramTotal * MemorySafe));
                return;
            }

            DateTime startTime    = DateTime.Now;
            int      totalRecords = 0;

            lines = new List <OUImportationLine>();

            // TODO: Fetch keywords to make it faster on the loops.
            trends         = new List <Trend>(trendRepository.GetAll());
            silouhettes    = new List <Silouhette>(silouhetteRepository.GetAll());
            patterns       = new List <Pattern>(patternRepository.GetAll());
            colorFamilies  = new List <ColorFamily>(colorFamilyRepository.GetAll());
            outfitUpdaters = new List <OutfitUpdater>(outfitUpdaterRepository.GetFor(Partner));
            wordsForDiscard.Add(" men");
            wordsForDiscard.Add(" mens");
            wordsForDiscard.Add(" men's");
            wordsForDiscard.Add(" men´s");
            wordsForDiscard.Add("kid");
            wordsForDiscard.Add("kids");
            wordsForDiscard.Add("kid's");
            wordsForDiscard.Add("kid´s");

            // Retrieve Keywords
            // TODO: Limit by partner
            colorFamilyKeywords = new Repository <ColorFamilyKeywordsByPartner>().GetAll();
            patternKeywords     = new Repository <PatternKeywordsByPartner>().GetAll();
            silouhetteKeywords  = new Repository <SilouhetteKeywordsByPartner>().GetAll();

            Write("--------------------------------------------------------------------------------");
            Write(string.Format("{0} - {1}\t\t{2}\t\t{3}\t{4}\t{5}", "Time", "Process Type", "Action", "CPU Usage", "RAM Available(MB)", "Records OK"));
            WriteFullInfo("Start");

            //REVIEW: The ZapposClassBuilder should read the file and create an event for the loop, returning an
            //REVIEW: understandable object that we can interchange when we have another builder. This way we can not
            //REVIEW: change the builder in a truly manner. Right now, is kind of complex and not clear how to change it.
            //REVIEW: That way is simple to change from reading from a file or other providers.
            //REVIEW: This class should worry about checking if the line is valid and import it in our system.
            DelimitedClassBuilder cb = ouImportationClassBuilder.CreateClassBuilder(Separator, HaveHeader);

            //REVIEW: Why is these here? We always read line at line.
            if (Sync)
            {
                FileHelperEngine engine = new FileHelperEngine(cb.CreateRecordClass());
                object[]         items  = engine.ReadFile(path + Filename);
                totalRecords = items.Length;
                WriteFullInfo("Ready");

                for (int i = 0; i < items.Length; i++)
                {
                    actualLine = i;
                    if (HaveHeader)
                    {
                        actualLine++;
                    }

                    ProcessOUImportationLine(items[i]);

                    CheckLimits();
                }
            }
            else
            {
                FileHelperAsyncEngine engine = new FileHelperAsyncEngine(cb.CreateRecordClass());
                engine.BeginReadFile(path + Filename);
                WriteFullInfo("Ready");

                while (engine.ReadNext() != null)
                {
                    actualLine = totalRecords + 1;
                    if (HaveHeader)
                    {
                        actualLine++;
                    }

                    ProcessOUImportationLine(engine.LastRecord);

                    CheckLimits();
                    totalRecords++;
                }

                ProcessList();
            }

            DateTime endTime = DateTime.Now;
            TimeSpan span    = endTime - startTime;

            WriteFullInfo("Finish");
            Write("--------------------------------------------------------------------------------");
            Write(string.Format("{0} - {1} {2} {3} records in {4} seconds", endTime.ToLongTimeString(), Process, "Finish", totalRecords, span.TotalSeconds.ToString("0")));
            WriteInfo("Total lines added/modified", linesOk.Count.ToString());
            WriteInfo("Total errors", TotalErrors.ToString());
            //WriteInfo("Lines with errors", string.Join(",", linesWithErrors.ToArray()));
            Write("--------------------------------------------------------------------------------");
        }
Exemplo n.º 6
0
        public ActionResult Index()
        {
            RegisteredUser user = this.ProxyLoggedUser;

            IList <FashionAde.Core.Clothing.Color> colors = colorRepository.GetAll();
            List <SelectListItem> lstcolors = new List <SelectListItem>();

            foreach (FashionAde.Core.Clothing.Color color in colors)
            {
                SelectListItem sl = new SelectListItem();
                sl.Text  = color.Description;
                sl.Value = color.Id.ToString();
                lstcolors.Add(sl);
            }
            ViewData["Colors"] = lstcolors;

            IList <Pattern>       patterns    = patternRepository.GetAll();
            List <SelectListItem> lstPatterns = new List <SelectListItem>();

            foreach (Pattern pattern in patterns)
            {
                SelectListItem sl = new SelectListItem();
                sl.Text  = pattern.Description;
                sl.Value = pattern.Id.ToString();
                lstPatterns.Add(sl);
            }
            ViewData["Patterns"] = lstPatterns;

            IList <Fabric>        fabrics    = fabricRepository.GetAll();
            List <SelectListItem> lstFabrics = new List <SelectListItem>();

            foreach (Fabric fabric in fabrics)
            {
                SelectListItem sl = new SelectListItem();
                sl.Text  = fabric.Description;
                sl.Value = fabric.Id.ToString();
                lstFabrics.Add(sl);
            }
            ViewData["Fabrics"] = lstFabrics;

            IList <Silouhette>    silouhettes    = silouhetteRepository.GetAll();
            List <SelectListItem> lstsilouhettes = new List <SelectListItem>();

            foreach (Silouhette silouhette in silouhettes)
            {
                SelectListItem sl = new SelectListItem();

                sl.Text  = silouhette.Category.Description + " " + silouhette.Description;
                sl.Value = silouhette.Id.ToString();
                lstsilouhettes.Add(sl);
            }
            ViewData["Titles"] = lstsilouhettes;

            IList <EventType>     eventTypes    = eventTypeRepository.GetAll();
            List <SelectListItem> lsteventTypes = new List <SelectListItem>();

            foreach (EventType type in eventTypes)
            {
                SelectListItem sl = new SelectListItem();
                sl.Text  = type.Description;
                sl.Value = type.Id.ToString();
                lsteventTypes.Add(sl);
            }
            ViewData["EventTypes"] = lsteventTypes;

            LoadSeasons();

            return(View());
        }