Esempio n. 1
0
        public PartJsonResult ProcessJsonRequest(System.Collections.Specialized.NameValueCollection form,
                                                 MerchantTribeApplication app, Catalog.Category containerCategory)
        {
            PartJsonResult result = new PartJsonResult();

            string action = form["partaction"];

            switch (action.ToLowerInvariant())
            {
            case "addpart":
                string       parttype = form["parttype"];
                IContentPart part     = PartFactory.Instantiate(System.Guid.NewGuid().ToString(), parttype, this);
                if (part != null)
                {
                    this.AddPart(part);
                    app.CatalogServices.Categories.Update(containerCategory);
                    result.ResultHtml = part.RenderForEdit(app, containerCategory);
                }
                break;

            case "resort":
                string        sortedIds = form["sortedIds[]"];
                string[]      ids       = sortedIds.Split(',');
                List <string> idList    = new List <string>();
                foreach (string s in ids)
                {
                    idList.Add(s.Trim().Replace("part", ""));
                }
                result.Success = this.SortParts(idList);
                app.CatalogServices.Categories.Update(containerCategory);
                break;
            }
            return(result);
        }
Esempio n. 2
0
        public string Process(MerchantTribeApplication app, Dictionary <string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            string areaName = tag.GetSafeAttribute("name");

            string result = contents;

            // Get area data from the category if it exists, otherwise use the default area content
            if (app.CurrentRequestContext.CurrentCategory != null)
            {
                CategoryPageVersion v = app.CurrentRequestContext.CurrentCategory.GetCurrentVersion();
                if (v != null)
                {
                    string fromCat = v.Areas.GetAreaContent(areaName);
                    if (fromCat.Trim().Length > 0)
                    {
                        result = fromCat;
                    }
                }
            }

            // do replacements for legacy tags here
            result = MerchantTribe.Commerce.Utilities.TagReplacer.ReplaceContentTags(result,
                                                                                     app,
                                                                                     "",
                                                                                     app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection);
            return(result);
        }
Esempio n. 3
0
        public static string ReplaceContentTags(string source, MerchantTribeApplication app, string itemCount, bool isSecureRequest)
        {
            Accounts.Store currentStore  = app.CurrentStore;
            string         currentUserId = SessionManager.GetCurrentUserId(app.CurrentStore);

            string output = source;

            RouteCollection r = System.Web.Routing.RouteTable.Routes;

            //VirtualPathData homeLink = r.GetVirtualPath(requestContext.RoutingContext, "homepage", new RouteValueDictionary());

            output = output.Replace("{{homelink}}", app.StoreUrl(isSecureRequest, false));
            output = output.Replace("{{logo}}", HtmlRendering.Logo(app, isSecureRequest));
            output = output.Replace("{{logotext}}", HtmlRendering.LogoText(app));
            output = output.Replace("{{headermenu}}", HtmlRendering.HeaderMenu(app.CurrentRequestContext.RoutingContext, app.CurrentRequestContext));
            output = output.Replace("{{cartlink}}", HtmlRendering.CartLink(app, itemCount));
            output = output.Replace("{{copyright}}", "<span class=\"copyright\">Copyright &copy;" + DateTime.Now.Year.ToString() + "</span>");
            output = output.Replace("{{headerlinks}}", HtmlRendering.HeaderLinks(app, currentUserId));
            output = output.Replace("{{searchform}}", HtmlRendering.SearchForm(app));
            output = output.Replace("{{assets}}", MerchantTribe.Commerce.Storage.DiskStorage.BaseUrlForStoreTheme(app, currentStore.Settings.ThemeId, isSecureRequest) + "assets/");
            output = output.Replace("{{img}}", MerchantTribe.Commerce.Storage.DiskStorage.StoreAssetUrl(app, string.Empty, isSecureRequest));
            output = output.Replace("{{storeassets}}", MerchantTribe.Commerce.Storage.DiskStorage.StoreAssetUrl(app, string.Empty, isSecureRequest));
            output = output.Replace("{{sitefiles}}", MerchantTribe.Commerce.Storage.DiskStorage.BaseUrlForSingleStore(app, isSecureRequest));

            output = output.Replace("{{storeaddress}}", app.ContactServices.Addresses.FindStoreContactAddress().ToHtmlString());

            return(output);
        }
Esempio n. 4
0
        public string Render(MerchantTribeApplication app, BreadCrumbViewModel model)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<div class=\"breadcrumbs\">");
            sb.Append("<div class=\"links\">");
            if (model.HideHomeLink == false)
            {
                sb.Append("<a href=\"" + app.StoreUrl(false, false) + "\">Home</a>" + model.Spacer);
            }
            while (model.Items.Count > 0)
            {
                var item = model.Items.Dequeue();
                if (item.Link == string.Empty)
                {
                    sb.Append("<span class=\"current\">" + HttpUtility.HtmlEncode(item.Name) + "</span>");
                }
                else
                {
                    sb.Append("<a href=\"" + item.Link + "\" title=\"" + HttpUtility.HtmlEncode(item.Title) + "\">" + HttpUtility.HtmlEncode(item.Name) + "</a>");
                }

                if (model.Items.Count > 0 && model.Items.Peek() != null)
                {
                    sb.Append(model.Spacer);
                }
            }
            sb.Append("</div>");
            sb.Append("</div>");

            return(sb.ToString());
        }
Esempio n. 5
0
        public static void RedirectToMainStoreUrl(long storeId, System.Uri requestedUrl, MerchantTribeApplication app)
        {
            Accounts.Store store = app.AccountServices.Stores.FindById(storeId);
            if (store == null) return;
            app.CurrentStore = store;

            string host = requestedUrl.Authority;
            string relativeRoot = "http://" + host;

            bool secure = false;
            if (requestedUrl.ToString().ToLowerInvariant().StartsWith("https://")) secure = true;
            string destination = app.StoreUrl(secure, false);

            string pathAndQuery = requestedUrl.PathAndQuery;
            // Trim starting slash because root URL already has this
            pathAndQuery = pathAndQuery.TrimStart('/');

            destination = System.IO.Path.Combine(destination, pathAndQuery);

            // 301 redirect to main url
            if (System.Web.HttpContext.Current != null)
            {
                System.Web.HttpContext.Current.Response.RedirectPermanent(destination);
            }
        }
Esempio n. 6
0
        // Primary Method to Detect Store from Uri
        public static Accounts.Store ParseStoreFromUrl(System.Uri url, MerchantTribeApplication app)
        {
            var profiler = MvcMiniProfiler.MiniProfiler.Current;
            using (profiler.Step("UrlHelper.ParseStoreFromUrl"))
            {
                // Individual Mode
                if (WebAppSettings.IsIndividualMode)
                {
                    return app.AccountServices.FindOrCreateIndividualStore();
                }

                // Multi Mode
                Accounts.Store result = null;

                long storeid;
                using (profiler.Step("Parse Id"))
                {
                    storeid = ParseStoreId(url, app);
                }
                using (profiler.Step("Load Store"))
                {
                    if (storeid > 0)
                    {
                        result = app.AccountServices.Stores.FindById(storeid);
                    }
                }
                return result;
            }
        }
Esempio n. 7
0
        public static bool IsUrlInUse(string requestedUrl, string thisCustomUrlBvin, RequestContext context, MerchantTribeApplication app)
        {
            bool result = false;            
            string working = requestedUrl.ToLowerInvariant();

            // Check for Generic Page Use in a Flex Page
            if (IsCategorySlugInUse(working, thisCustomUrlBvin, context)) return true;

            // Check for Products
            if (IsProductSlugInUse(working, thisCustomUrlBvin, app)) return true;

            // Check Custom Urls
            Content.CustomUrl url = app.ContentServices.CustomUrls.FindByRequestedUrl(requestedUrl);
            if (url != null)
            {
                if (url.Bvin != string.Empty)
                {
                    if (url.Bvin != thisCustomUrlBvin)
                    {
                        return true;
                    }
                }
            }
            return result;
        }
Esempio n. 8
0
 public static string CategoryIconUrl(MerchantTribeApplication app, string categoryId, string imageName, bool isSecure)
 {
     string u = BaseUrlForSingleStore(app, isSecure);
     u += "categoryicons/" + categoryId.ToString() + "/small/";
     u += imageName;
     return u;
 }
Esempio n. 9
0
 public static string CategoryBannerOriginalUrl(MerchantTribeApplication app, string categoryId, string imageName, bool isSecure)
 {
     string u = BaseUrlForSingleStore(app, isSecure);
     u += "categorybanners/" + categoryId.ToString() + "/";
     u += imageName;
     return u;
 }
Esempio n. 10
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            this.App = app;
            this.Url = new System.Web.Mvc.UrlHelper(app.CurrentRequestContext.RoutingContext);
            CurrentCategory = app.CurrentRequestContext.CurrentCategory;
            if (CurrentCategory == null)
            {
                CurrentCategory = new Category();
                CurrentCategory.Bvin = "0";
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("<div class=\"categorymenu\">");
            sb.Append("<div class=\"decoratedblock\">");

            string title = tag.GetSafeAttribute("title");
            if (title.Trim().Length > 0)
            {
                sb.Append("<h4>" + title + "</h4>");
            }

            sb.Append("<ul>");

            int maxDepth = 5;

            string mode = tag.GetSafeAttribute("mode");
            switch (mode.Trim().ToUpperInvariant())
            {
                case "ROOT":
                case "ROOTS":
                    // Root Categories Only
                    LoadRoots(sb);
                    break;
                case "ALL":
                    // All Categories
                    LoadAllCategories(sb, maxDepth);
                    break;
                case "":
                case "PEERS":
                    // Peers, Children and Parents
                    LoadPeersAndChildren(sb);
                    break;
                case "ROOTPLUS":
                    // Show root and expanded children
                    LoadRootPlusExpandedChildren(sb);
                    break;
                default:
                    // All Categories
                    LoadPeersAndChildren(sb);
                    break;
            }

            sb.Append("</ul>");

            sb.Append("</div>");
            sb.Append("</div>");

            return sb.ToString();
        }
Esempio n. 11
0
        public string RenderForDisplay(MerchantTribeApplication app, Catalog.Category cat)
        {
            string sizeClass = "flexsize12";

            if (this._Container != null)
            {
                sizeClass  = "flexsize";
                sizeClass += ((int)_Container.Size).ToString();
                if (_Container.NoGutter && _Container.Size != ColumnSize.Size12)
                {
                    sizeClass += "w";
                }
            }
            string url = System.Web.VirtualPathUtility.ToAbsolute("~/images/system/flexedit/imagePlaceholder.png");
            string alt = "Placeholder Image";

            if (Images.Count > 0)
            {
                ImageDisplayFile img       = this.Images[0];
                long             versionId = cat.GetCurrentVersion().Id;
                url = Storage.DiskStorage.FlexPageImageUrl(app, cat.Bvin, versionId.ToString(), img.FileName, true);
                alt = img.AltText;
            }

            return("<img src=\"" + url + "\" alt=\"" + alt + "\" class=\"" + sizeClass + "\" />");
        }
Esempio n. 12
0
 public override string FriendlyDescription(MerchantTribeApplication app)
 {
     string result = "";
     
     switch(HasMode)
     {
         case QualificationHasMode.HasAtLeast:
             result += "When order has AT LEAST ";
             break;
     }
     result += this.Quantity.ToString();
     switch(SetMode)
     {
         case QualificationSetMode.AllOfTheseItems:
             result += " of ALL of these products";
             break;
         case QualificationSetMode.AnyOfTheseItems:
             result += " of ANY of these products";
             break;
     }
     result += ":<ul>";
     
     foreach (string bvin in this.CurrentProductIds())
     {
         Catalog.Product p = app.CatalogServices.Products.Find(bvin);
         if (p != null)
         {
             result += "<li>[" + p.Sku + "] " + p.ProductName + "</li>";
         }
     }
     result += "</ul>";
     return result;
 }
Esempio n. 13
0
        public override string FriendlyDescription(MerchantTribeApplication app)
        {
            string result = "";

            switch (HasMode)
            {
            case QualificationHasMode.HasAtLeast:
                result += "When order has AT LEAST ";
                break;
            }
            result += this.Quantity.ToString();
            switch (SetMode)
            {
            case QualificationSetMode.AllOfTheseItems:
                result += " of ALL of these products";
                break;

            case QualificationSetMode.AnyOfTheseItems:
                result += " of ANY of these products";
                break;
            }
            result += ":<ul>";

            foreach (string bvin in this.CurrentProductIds())
            {
                Catalog.Product p = app.CatalogServices.Products.Find(bvin);
                if (p != null)
                {
                    result += "<li>[" + p.Sku + "] " + p.ProductName + "</li>";
                }
            }
            result += "</ul>";
            return(result);
        }
        public SingleProductViewModel(Product p, MerchantTribeApplication mtapp)
        {
            var profiler = MiniProfiler.Current;

            using (profiler.Step("Price Product " + p.ProductName))
            {
                this.UserPrice = mtapp.PriceProduct(p, mtapp.CurrentCustomer, null, mtapp.CurrentlyActiveSales);
            }
            this.IsFirstItem = false;
            this.IsLastItem  = false;
            this.Item        = p;
            using (profiler.Step("Image Url Product" + p.ProductName))
            {
                this.ImageUrl = MerchantTribe.Commerce.Storage.DiskStorage.ProductImageUrlSmall(
                    mtapp,
                    p.Bvin,
                    p.ImageFileSmall,
                    mtapp.IsCurrentRequestSecure());
            }
            using (profiler.Step("Product Link " + p.ProductName))
            {
                this.ProductLink = UrlRewriter.BuildUrlForProduct(p,
                                                                  mtapp.CurrentRequestContext.RoutingContext,
                                                                  string.Empty);
            }
            this.SwatchDisplay = MerchantTribe.Commerce.Utilities.ImageHelper.GenerateSwatchHtmlForProduct(p, mtapp);
        }
Esempio n. 15
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            string areaName = tag.GetSafeAttribute("name");

            string result = contents;

            // Get area data from the category if it exists, otherwise use the default area content
            if (app.CurrentRequestContext.CurrentCategory != null)
            {
                CategoryPageVersion v = app.CurrentRequestContext.CurrentCategory.GetCurrentVersion();
                if (v != null)
                {
                    string fromCat = v.Areas.GetAreaContent(areaName);
                    if (fromCat.Trim().Length > 0)
                    {
                        result = fromCat;
                    }
                }
            }

            // do replacements for legacy tags here
            result = MerchantTribe.Commerce.Utilities.TagReplacer.ReplaceContentTags(result,
                            app,
                            "",
                            app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection);
            return result;
        }
Esempio n. 16
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            string fileUrl = string.Empty;
            bool secure = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection;

            ThemeManager tm = app.ThemeManager();

            string mode = tag.GetSafeAttribute("mode");
            if (mode == "legacy")
            {
                fileUrl = tm.CurrentStyleSheet(app, secure);
            }
            else if (mode == "system")
            {
                string cssFile = tag.GetSafeAttribute("file");
                fileUrl = app.StoreUrl(secure, false) + cssFile.TrimStart('/');
            }
            else
            {
                string fileName = tag.GetSafeAttribute("file");
                fileUrl = tm.ThemeFileUrl(fileName, app);
            }

            string result = string.Empty;
            result = "<link href=\"" + fileUrl + "\" rel=\"stylesheet\" type=\"text/css\" />";
            return result;
        }
Esempio n. 17
0
        public List<Content.HtmlTemplateTag> GetReplaceableTags(MerchantTribeApplication app)
        {
			List<Content.HtmlTemplateTag> result = new List<Content.HtmlTemplateTag>();
			result.Add(new Content.HtmlTemplateTag("[[VendorManufacturer.EmailAddress]]", this.EmailAddress));
			result.Add(new Content.HtmlTemplateTag("[[VendorManufacturer.Name]]", this.DisplayName));
			return result;
		}
Esempio n. 18
0
 public Processor(MerchantTribeApplication app, dynamic viewBag, string template, ITagProvider tagProvider)
 {
     this.MTApp       = app;
     this.TagProvider = tagProvider;
     this.Template    = template;
     this.ViewBag     = viewBag;
 }
Esempio n. 19
0
        public void CanGenerateCorrectSelectionData()
        {
            OptionList options = GetSampleOptions();

            VariantList target             = new VariantList();
            MerchantTribeApplication mtapp = MerchantTribeApplication.InstantiateForMemory(new RequestContext());

            List <OptionSelectionList> data = mtapp.CatalogServices.VariantsGenerateAllPossibleSelections(options);

            Assert.IsNotNull(data, "Data should not be null");
            Assert.AreEqual(6, data.Count, "There should be six possible combinations");

            List <string> keys = new List <string>();

            foreach (OptionSelectionList o in data)
            {
                string k = OptionSelection.GenerateUniqueKeyForSelections(o);
                keys.Add(k);
            }
            Assert.AreEqual(6, keys.Count, "Key Count should be six.");
            Assert.IsTrue(keys.Contains("1-101|2-201|"), "Keys should contain 1-101|2-201|");
            Assert.IsTrue(keys.Contains("1-101|2-202|"), "Keys should contain 1-101|2-202|");
            Assert.IsTrue(keys.Contains("1-101|2-203|"), "Keys should contain 1-101|2-203|");
            Assert.IsTrue(keys.Contains("1-102|2-201|"), "Keys should contain 1-102|2-201|");
            Assert.IsTrue(keys.Contains("1-102|2-202|"), "Keys should contain 1-102|2-202|");
            Assert.IsTrue(keys.Contains("1-102|2-203|"), "Keys should contain 1-102|2-203|");
        }
        public static void CollectPaymentAndShipPendingOrders(MerchantTribeApplication app)
        {
            OrderSearchCriteria criteria = new OrderSearchCriteria();
            criteria.IsPlaced = true;
            criteria.StatusCode = OrderStatusCode.ReadyForPayment;
            int pageSize = 1000;            
            int totalCount = 0;

            List<OrderSnapshot> orders = app.OrderServices.Orders.FindByCriteriaPaged(criteria, 1, pageSize, ref totalCount);
            if (orders != null)
            {
                foreach (OrderSnapshot os in orders)
                {
                    Order o = app.OrderServices.Orders.FindForCurrentStore(os.bvin);
                    OrderPaymentManager payManager = new OrderPaymentManager(o, app);
                    payManager.CreditCardCompleteAllCreditCards();
                    payManager.PayPalExpressCompleteAllPayments();
                    if (o.PaymentStatus == OrderPaymentStatus.Paid ||
                        o.PaymentStatus == OrderPaymentStatus.Overpaid)
                    {
                        if (o.ShippingStatus == OrderShippingStatus.FullyShipped)
                        {
                            o.StatusCode = OrderStatusCode.Completed;
                            o.StatusName = "Completed";
                        }
                        else
                        {
                            o.StatusCode = OrderStatusCode.ReadyForShipping;
                            o.StatusName = "Ready for Shipping";
                        }
                        app.OrderServices.Orders.Update(o);
                    }
                }
            }
        }
        private List <Product> LoadItems(MerchantTribeApplication app)
        {
            List <Product> myProducts = MerchantTribe.Commerce.PersonalizationServices.GetProductsViewed(app);
            List <Product> limited    = myProducts.Take(5).ToList();

            return(limited);
        }
Esempio n. 22
0
        public static string Logo(MerchantTribeApplication app, bool isSecureRequest)
        {
            string storeRootUrl = app.StoreUrl(isSecureRequest, false);
            string storeName = app.CurrentStore.Settings.FriendlyName;

            string logoImage = app.CurrentStore.Settings.LogoImageFullUrl(app, isSecureRequest);
            string logoText = app.CurrentStore.Settings.LogoText;

            StringBuilder sb = new StringBuilder();

            sb.Append("<a href=\"" + storeRootUrl + "\" title=\"" + storeName + "\"");

            if (app.CurrentStore.Settings.UseLogoImage)
            {
                sb.Append("><img src=\"" + logoImage + "\" alt=\"" + storeName + "\" />");

            }
            else
            {
                sb.Append(" class=\"logo\">");
                sb.Append(System.Web.HttpUtility.HtmlEncode(logoText));
            }
            sb.Append("</a>");

            return sb.ToString();
        }
Esempio n. 23
0
        public static string BuildForStore(MerchantTribeApplication app)
        {
            if (app == null)
            {
                return(string.Empty);
            }

            string      root     = app.CurrentStore.RootUrl();
            SiteMapNode rootNode = new SiteMapNode();

            // home
            rootNode.AddUrl(root);
            // sitemap
            rootNode.AddUrl(root + "sitemap");

            // Categories
            foreach (Catalog.CategorySnapshot cat in app.CatalogServices.Categories.FindAll())
            {
                string caturl = Utilities.UrlRewriter.BuildUrlForCategory(cat, app.CurrentRequestContext.RoutingContext);
                rootNode.AddUrl(root.TrimEnd('/') + caturl);
            }

            // Products
            foreach (Catalog.Product p in app.CatalogServices.Products.FindAllPaged(1, 3000))
            {
                string produrl = Utilities.UrlRewriter.BuildUrlForProduct(p, app.CurrentRequestContext.RoutingContext, string.Empty);
                rootNode.AddUrl(root.TrimEnd('/') + produrl);
            }
            return(rootNode.RenderAsXmlSiteMap());
        }
Esempio n. 24
0
 public TemplateProcessor(MerchantTribeApplication app, string template)
 {
     this.Handlers = new Dictionary<string, ITagHandler>();
     InitializeTagHandlers();
     this.MTApp = app;
     this.Template = template;
 }
Esempio n. 25
0
        public string Process(MerchantTribeApplication app, Dictionary <string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            string fileUrl = string.Empty;
            bool   secure  = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection;

            ThemeManager tm = app.ThemeManager();

            string mode = tag.GetSafeAttribute("mode");

            if (mode == "legacy")
            {
                fileUrl = tm.CurrentStyleSheet(app, secure);
            }
            else if (mode == "system")
            {
                string cssFile = tag.GetSafeAttribute("file");
                fileUrl = app.StoreUrl(secure, false) + cssFile.TrimStart('/');
            }
            else
            {
                string fileName = tag.GetSafeAttribute("file");
                fileUrl = tm.ThemeFileUrl(fileName, app);
            }

            string result = string.Empty;

            result = "<link href=\"" + fileUrl + "\" rel=\"stylesheet\" type=\"text/css\" />";
            return(result);
        }
Esempio n. 26
0
        private List <SingleProductViewModel> PrepProducts(List <Product> products, MerchantTribeApplication app)
        {
            List <SingleProductViewModel> result = new List <SingleProductViewModel>();

            int columnCount = 1;

            foreach (Product p in products)
            {
                SingleProductViewModel model = new SingleProductViewModel(p, app);

                bool isLastInRow  = false;
                bool isFirstInRow = false;
                if ((columnCount == 1))
                {
                    isFirstInRow = true;
                }

                if ((columnCount == 3))
                {
                    isLastInRow = true;
                    columnCount = 1;
                }
                else
                {
                    columnCount += 1;
                }

                //model.IsFirstItem = isFirstInRow;
                //model.IsLastItem = isLastInRow;

                result.Add(model);
            }

            return(result);
        }
Esempio n. 27
0
 public void OrderReceived(Orders.Order order, MerchantTribeApplication app)
 {
     if (OnOrderReceived != null)
     {
         OnOrderReceived(this, order, app);
     }
 }
Esempio n. 28
0
        private void Render(StringBuilder sb,
                            MerchantTribeApplication app,
                            dynamic viewBag,
                            ProductListViewModel model,
                            bool showPagers, int columns)
        {
            var profiler = MiniProfiler.Current;

            using (profiler.Step("Rendering Grid..."))
            {
                var preppedItems    = PrepProducts(model.Items, columns, app);
                var productRenderer = new code.TemplateEngine.TagHandlers.SingleProduct();

                if (showPagers == true)
                {
                    //RenderPager(model.PagerData, app, viewBag);
                    sb.Append("<div>PAGER</div>");
                }
                foreach (var item in preppedItems)
                {
                    productRenderer.RenderModel(sb, item, app);
                }
                if (showPagers == true)
                {
                    //RenderPager(model.PagerData, app, viewBag);
                    sb.Append("<div>PAGER</div>");
                }
            }
        }
Esempio n. 29
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            StringBuilder sb = new StringBuilder();
            bool isSecureRequest = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection;
            bool textOnly = false;
            string textOnlyTag = tag.GetSafeAttribute("textonly").Trim().ToLowerInvariant();
            if (textOnlyTag == "1" || textOnlyTag == "y" || textOnlyTag == "yes" || textOnlyTag == "true") textOnly = true;

            string storeRootUrl = app.CurrentStore.RootUrl();
            string storeName = app.CurrentStore.Settings.FriendlyName;

            string logoImage = app.CurrentStore.Settings.LogoImageFullUrl(app, isSecureRequest);
            string logoText = app.CurrentStore.Settings.LogoText;

            sb.Append("<a href=\"" + storeRootUrl + "\" title=\"" + storeName + "\"");

            if (contents.Trim().Length > 0)
            {
                sb.Append(">");
                sb.Append(contents);
            }
            else if (app.CurrentStore.Settings.UseLogoImage && textOnly == false)
            {
                sb.Append("><img src=\"" + logoImage + "\" alt=\"" + storeName + "\" />");
            }
            else
            {
                sb.Append(" class=\"logo\">");
                sb.Append(System.Web.HttpUtility.HtmlEncode(logoText));
            }
            sb.Append("</a>");

            return sb.ToString();
        }
Esempio n. 30
0
        public void LoadInstalledTheme(MerchantTribeApplication app, string themeId)
        {
            long storeId = app.CurrentStore.Id;
            string themePhysicalRoot = Storage.DiskStorage.BaseStoreThemePhysicalPath(storeId, themeId);

            if (!Directory.Exists(themePhysicalRoot))
            {
                return;
            }

            _Info = new ThemeInfo();
            if (File.Exists(Path.Combine(themePhysicalRoot,"bvtheme.xml")) )
            {
                _Info.LoadFromString(File.ReadAllText(Path.Combine(themePhysicalRoot,"bvtheme.xml")));
            }

            if (File.Exists(Path.Combine(themePhysicalRoot,".customized")))
            {
                _IsCustomized = true;
            }
            else
            {
                _IsCustomized = false;  
            }

            if (File.Exists(Path.Combine(themePhysicalRoot,"preview.png")))
            {
                _PreviewImageUrl = Storage.DiskStorage.BaseUrlForStoreTheme(app, themeId, true) + "preview.png";
            }
            else
            {
                _PreviewImageUrl = string.Empty;
            }
        }
Esempio n. 31
0
        public bool Void(MerchantTribe.Payment.Transaction t, MerchantTribeApplication app)
        {
            PayPalAPI ppAPI = Utilities.PaypalExpressUtilities.GetPaypalAPI(app.CurrentStore);

            try
            {
                if (t.PreviousTransactionNumber != null)
                {
                    DoVoidResponseType voidResponse = ppAPI.DoVoid(t.PreviousTransactionNumber,
                                                                   "Transaction Voided");
                    if ((voidResponse.Ack == AckCodeType.Success) || (voidResponse.Ack == AckCodeType.SuccessWithWarning))
                    {
                        t.Result.Succeeded = true;
                        t.Result.Messages.Add(new MerchantTribe.Payment.Message("PayPal Express Payment Voided Successfully.", "OK", MerchantTribe.Payment.MessageType.Information));
                        return(true);
                    }
                    else
                    {
                        t.Result.Succeeded = false;
                        t.Result.Messages.Add(new MerchantTribe.Payment.Message("Paypal Express Payment Void Failed.", "", MerchantTribe.Payment.MessageType.Error));
                        foreach (ErrorType ppError in voidResponse.Errors)
                        {
                            t.Result.Messages.Add(new MerchantTribe.Payment.Message(ppError.LongMessage, ppError.ErrorCode, MerchantTribe.Payment.MessageType.Error));
                        }
                        return(false);
                    }
                }
            }
            finally
            {
                ppAPI = null;
            }
            return(false);
        }
Esempio n. 32
0
        private void PopulateTags(MerchantTribeApplication app)
        {
            List <IReplaceable> items = new List <IReplaceable>();

            // Default Tags
            Replaceable defaultTags = new Replaceable();

            defaultTags.Tags.AddRange(new HtmlTemplate().DefaultReplacementTags(app));
            items.Add(defaultTags);

            // Objects with tags
            items.Add(new MailingListMember());
            items.Add(new CustomerAccount());
            items.Add(new VendorManufacturer());
            items.Add(new Order());
            items.Add(new LineItem());
            items.Add(new OrderPackage());
            items.Add(new Product());

            // Get all tags from everything into one big list
            List <HtmlTemplateTag> t = new List <HtmlTemplateTag>();

            foreach (IReplaceable r in items)
            {
                t.AddRange(r.GetReplaceableTags(app));
            }

            this.Tags.DataSource     = t;
            this.Tags.DataValueField = "Tag";
            this.Tags.DataTextField  = "Tag";
            this.Tags.DataBind();
        }
Esempio n. 33
0
        public static string RenderSuperMenu(MerchantTribeApplication app)
        {
            StringBuilder sb  = new StringBuilder();
            AdminTabType  tab = AdminTabType.None;

            string root = app.StoreUrl(true, false);

            root += "super/";

            sb.Append("<ul>");
            sb.Append(AddMainLink("Home", "", tab, AdminTabType.Dashboard, root));

            // catalog menu
            sb.Append(OpenMenu("Stores", tab, AdminTabType.Dashboard));
            sb.Append(AddMenuItem("Find Stores", "stores/", root));
            sb.Append(AddMenuItem("New Store Report", "stores/NewStoreReport", root));
            sb.Append(CloseMenu());

            sb.Append(OpenMenu("Search", tab, AdminTabType.Dashboard));
            sb.Append(AddMenuItem("Search", "search", root));
            sb.Append(AddMenuItem("Index Controls", "rebuildsearch", root));
            sb.Append(CloseMenu());

            sb.Append("</ul>");

            return(sb.ToString());
        }
Esempio n. 34
0
        public void CanRetrieveShippingMethod()
        {
            RequestContext           c   = new RequestContext();
            MerchantTribeApplication app = MerchantTribeApplication.InstantiateForMemory(c);

            c.CurrentStore    = new Accounts.Store();
            c.CurrentStore.Id = 230;

            Shipping.ShippingMethod target = new Shipping.ShippingMethod();
            target.Adjustment     = 1.23m;
            target.AdjustmentType = Shipping.ShippingMethodAdjustmentType.Percentage;
            target.Bvin           = string.Empty;
            //target.CustomProperties.Add("bvsoftware", "mykey", "myvalue");
            target.Name = "Test Name";
            target.Settings.AddOrUpdate("MySetting", "MySetVal");
            target.ShippingProviderId = "123456";
            target.ZoneId             = -101;

            app.OrderServices.ShippingMethods.Create(target);
            Assert.AreNotEqual(string.Empty, target.Bvin, "Bvin should not be empty");

            Shipping.ShippingMethod actual = app.OrderServices.ShippingMethods.Find(target.Bvin);
            Assert.IsNotNull(actual, "Actual should not be null");

            Assert.AreEqual(actual.Adjustment, target.Adjustment);
            Assert.AreEqual(actual.AdjustmentType, target.AdjustmentType);
            Assert.AreEqual(actual.Bvin, target.Bvin);
            //Assert.AreEqual(actual.CustomProperties[0].Key, target.CustomProperties[0].Key);
            Assert.AreEqual(actual.Name, target.Name);
            Assert.AreEqual(actual.Settings["MySetting"], target.Settings["MySetting"]);
            Assert.AreEqual(actual.ShippingProviderId, target.ShippingProviderId);
            Assert.AreEqual(actual.ZoneId, target.ZoneId);
        }
Esempio n. 35
0
        protected override void Render(StringBuilder sb,
                                       MerchantTribeApplication app,
                                       dynamic viewBag,
                                       ProductListViewModel model,
                                       bool showPagers, int columns)
        {
            var profiler = MiniProfiler.Current;

            using (profiler.Step("Rendering Detailed List..."))
            {
                var preppedItems  = base.PrepProducts(model.Items, columns, app);
                var pagerRenderer = new code.TemplateEngine.TagHandlers.Pager();

                string buttonUrlDetails   = app.ThemeManager().ButtonUrl("View", app.IsCurrentRequestSecure());
                string buttonUrlAddToCart = app.ThemeManager().ButtonUrl("AddToCart", app.IsCurrentRequestSecure());

                if (showPagers == true)
                {
                    pagerRenderer.Render(sb, model.PagerData);
                }
                foreach (var item in preppedItems)
                {
                    RenderSingleModel(sb, item, app, buttonUrlDetails, buttonUrlAddToCart);
                }
                if (showPagers == true)
                {
                    pagerRenderer.Render(sb, model.PagerData);
                }
            }
        }
Esempio n. 36
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            CurrentRequestContext.RoutingContext = this.Request.RequestContext;
            MTApp = new MerchantTribeApplication(CurrentRequestContext);

            // Determine store id
            CurrentStore = MerchantTribe.Commerce.Utilities.UrlHelper.ParseStoreFromUrl(System.Web.HttpContext.Current.Request.Url, MTApp);
            if (CurrentStore == null)
            {
                Response.Redirect("~/storenotfound");
            }

            if (CurrentStore.Status == MerchantTribe.Commerce.Accounts.StoreStatus.Deactivated)
            {
                Response.Redirect("~/storenotavailable");
            }

            // Culture Settings
            System.Threading.Thread.CurrentThread.CurrentCulture   = new System.Globalization.CultureInfo(CurrentStore.Settings.CultureCode);
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(CurrentStore.Settings.CultureCode);

            ValidateSuperLogin();

            // Jquery
            ViewData["JQueryInclude"] = Helpers.Html.JQueryIncludes(Url.Content("~/scripts"), this.Request.IsSecureConnection);

            ViewBag["AppVersion"]   = WebAppSettings.SystemVersionNumber;
            ViewBag["StoreName"]    = MTApp.CurrentStore.Settings.FriendlyName;
            ViewBag["RenderedMenu"] = Helpers.Html.RenderSuperMenu(MTApp);
        }
Esempio n. 37
0
        private bool SetNewAffiliate(string referrerId, string referrerUrl, MerchantTribeApplication app)
        {
            Contacts.Affiliate aff = Affiliates.FindByReferralId(referrerId);
            if (aff == null)
            {
                return(false);
            }
            if (!aff.Enabled)
            {
                return(false);
            }

            if (aff.Id != SessionManager.CurrentAffiliateID(app.CurrentStore))
            {
                System.DateTime expires = System.DateTime.UtcNow;
                if (aff.ReferralDays > 0)
                {
                    TimeSpan ts = new TimeSpan(aff.ReferralDays, 0, 0, 0);
                    expires = expires.Add(ts);
                }
                else
                {
                    expires = System.DateTime.UtcNow.AddYears(50);
                }
                SessionManager.SetCurrentAffiliateId(aff.Id, expires, app.CurrentStore);
            }
            return(LogReferral(aff.Id, referrerUrl));
        }
Esempio n. 38
0
        public static string Logo(MerchantTribeApplication app, bool isSecureRequest)
        {
            string storeRootUrl = app.StoreUrl(isSecureRequest, false);
            string storeName    = app.CurrentStore.Settings.FriendlyName;

            string logoImage = app.CurrentStore.Settings.LogoImageFullUrl(app, isSecureRequest);
            string logoText  = app.CurrentStore.Settings.LogoText;

            StringBuilder sb = new StringBuilder();

            sb.Append("<a href=\"" + storeRootUrl + "\" title=\"" + storeName + "\"");

            if (app.CurrentStore.Settings.UseLogoImage)
            {
                sb.Append("><img src=\"" + logoImage + "\" alt=\"" + storeName + "\" />");
            }
            else
            {
                sb.Append(" class=\"logo\">");
                sb.Append(System.Web.HttpUtility.HtmlEncode(logoText));
            }
            sb.Append("</a>");

            return(sb.ToString());
        }
Esempio n. 39
0
        public List <Content.HtmlTemplateTag> GetReplaceableTags(MerchantTribeApplication app)
        {
            List <Content.HtmlTemplateTag> result = new List <Content.HtmlTemplateTag>();

            result.Add(new Content.HtmlTemplateTag("[[LineItem.AdjustedPrice]]", this.AdjustedPricePerItem.ToString("c")));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.BasePrice]]", this.BasePricePerItem.ToString("c")));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.Discounts]]", this.DiscountDetailsAsHtml()));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.LineTotal]]", this.LineTotal.ToString("c")));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.ProductId]]", this.ProductId));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.VariantId]]", this.VariantId));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.ProductName]]", this.ProductName));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.ProductSku]]", this.ProductSku));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.Sku]]", this.ProductSku));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.ProductDescription]]", this.ProductShortDescription));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.Quantity]]", this.Quantity.ToString("#")));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.QuantityShipped]]", this.QuantityShipped.ToString("#")));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.QuantityReturned]]", this.QuantityReturned.ToString("#")));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.ShippingStatus]]", Utilities.EnumToString.OrderShippingStatus(this.ShippingStatus)));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.ShippingPortion]]", this.ShippingPortion.ToString("c")));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.TaxPortion]]", this.TaxPortion.ToString("c")));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.ExtraShipCharge]]", this.ExtraShipCharge.ToString("c")));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.ShipFromAddress]]", this.ShipFromAddress.ToHtmlString()));
            result.Add(new Content.HtmlTemplateTag("[[LineItem.ShipSeparately]]", this.ShipSeparately ? "Yes" : "No"));

            return(result);
        }
Esempio n. 40
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            string result = string.Empty;

            Orders.Order o = new Orders.Order();
            if (app.CurrentRequestContext.CurrentReceiptOrder != null)
            {
                o = app.CurrentRequestContext.CurrentReceiptOrder;

                // Adwords Tracker at bottom if needed
                if (app.CurrentStore.Settings.Analytics.UseGoogleAdWords)
                {
                    result = MerchantTribe.Commerce.Metrics.GoogleAnalytics.RenderGoogleAdwordTracker(
                                                            o.TotalGrand,
                                                            app.CurrentStore.Settings.Analytics.GoogleAdWordsId,
                                                            app.CurrentStore.Settings.Analytics.GoogleAdWordsLabel,
                                                            app.CurrentStore.Settings.Analytics.GoogleAdWordsBgColor,
                                                            app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection);
                }

                // Add Yahoo Tracker to Bottom if Needed
                if (app.CurrentStore.Settings.Analytics.UseYahooTracker)
                {
                    result += MerchantTribe.Commerce.Metrics.YahooAnalytics.RenderYahooTracker(
                        o, app.CurrentStore.Settings.Analytics.YahooAccountId);
                }
            }

            return result;
        }
Esempio n. 41
0
        public static string ReplaceContentTags(string source, MerchantTribeApplication app, string itemCount, bool isSecureRequest)
        {
            Accounts.Store currentStore = app.CurrentStore;
            string currentUserId = SessionManager.GetCurrentUserId(app.CurrentStore);

            string output = source;

            RouteCollection r = System.Web.Routing.RouteTable.Routes;
            //VirtualPathData homeLink = r.GetVirtualPath(requestContext.RoutingContext, "homepage", new RouteValueDictionary());

            output = output.Replace("{{homelink}}", app.StoreUrl(isSecureRequest, false));
            output = output.Replace("{{logo}}", HtmlRendering.Logo(app, isSecureRequest));
            output = output.Replace("{{logotext}}", HtmlRendering.LogoText(app));
            output = output.Replace("{{headermenu}}", HtmlRendering.HeaderMenu(app.CurrentRequestContext.RoutingContext, app.CurrentRequestContext));
            output = output.Replace("{{cartlink}}", HtmlRendering.CartLink(app, itemCount));
            output = output.Replace("{{copyright}}", "<span class=\"copyright\">Copyright &copy;" + DateTime.Now.Year.ToString() + "</span>");
            output = output.Replace("{{headerlinks}}", HtmlRendering.HeaderLinks(app, currentUserId));
            output = output.Replace("{{searchform}}", HtmlRendering.SearchForm(app));
            output = output.Replace("{{assets}}", MerchantTribe.Commerce.Storage.DiskStorage.BaseUrlForStoreTheme(app, currentStore.Settings.ThemeId, isSecureRequest) + "assets/");
            output = output.Replace("{{img}}", MerchantTribe.Commerce.Storage.DiskStorage.StoreAssetUrl(app, string.Empty, isSecureRequest));
            output = output.Replace("{{storeassets}}", MerchantTribe.Commerce.Storage.DiskStorage.StoreAssetUrl(app, string.Empty, isSecureRequest));
            output = output.Replace("{{sitefiles}}", MerchantTribe.Commerce.Storage.DiskStorage.BaseUrlForSingleStore(app, isSecureRequest));

            output = output.Replace("{{storeaddress}}", app.ContactServices.Addresses.FindStoreContactAddress().ToHtmlString());

            return output;
        }
Esempio n. 42
0
 public TemplateProcessor(MerchantTribeApplication app, string template)
 {
     this.Handlers = new Dictionary <string, ITagHandler>();
     InitializeTagHandlers();
     this.MTApp    = app;
     this.Template = template;
 }
Esempio n. 43
0
        public string ThemeFileUrl(string fileName, MerchantTribeApplication app)
        {
            string result = Storage.DiskStorage.BaseUrlForStoreTheme(app, app.CurrentStore.Settings.ThemeId);

            result = result + fileName;
            return(result);
        }
Esempio n. 44
0
        private int GetPageFromRequest(MerchantTribeApplication app)
        {
            int result = 1;

            if (app.CurrentRequestContext == null)
            {
                return(result);
            }
            if (app.CurrentRequestContext.RoutingContext == null)
            {
                return(result);
            }
            if (app.CurrentRequestContext.RoutingContext.HttpContext == null)
            {
                return(result);
            }
            if (app.CurrentRequestContext.RoutingContext.HttpContext.Request == null)
            {
                return(result);
            }
            if (app.CurrentRequestContext.RoutingContext.HttpContext.Request.QueryString["page"] != null)
            {
                int.TryParse(app.CurrentRequestContext.RoutingContext.HttpContext.Request.QueryString["page"], out result);
            }
            if (result < 1)
            {
                result = 1;
            }
            return(result);
        }
Esempio n. 45
0
        static void PerformScheduledTasks(string key, Object value, CacheItemRemovedReason reason)
        {
            try
            {
                MerchantTribe.Commerce.RequestContext context = new MerchantTribe.Commerce.RequestContext();
                MerchantTribeApplication app = MerchantTribe.Commerce.MerchantTribeApplication.InstantiateForDataBase(context);

                List <long> storeIds = app.ScheduleServices.QueuedTasks.ListStoresWithTasksToRun();
                if (storeIds != null)
                {
                    List <MerchantTribe.Commerce.Accounts.StoreDomainSnapshot> stores = app.AccountServices.Stores.FindDomainSnapshotsByIds(storeIds);
                    if (stores != null)
                    {
                        System.Threading.Tasks.Parallel.ForEach(stores, CallTasksOnStore);
                        //foreach (MerchantTribe.Commerce.Accounts.StoreDomainSnapshot snap in stores)
                        //{
                        //    string storekey = System.Configuration.ConfigurationManager.AppSettings["storekey"];
                        //    string rootUrl = snap.RootUrl();
                        //    string destination = rootUrl + "scheduledtasks/" + storekey;
                        //    MerchantTribe.Commerce.Utilities.WebForms.SendRequestByPost(destination, string.Empty);
                        //}
                    }
                }
            }
            catch
            {
                // suppress error and schedule next run
            }

            ScheduleTaskTrigger();
        }
Esempio n. 46
0
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);
            MTApp = MerchantTribeApplication.InstantiateForDataBase(new RequestContext());

            // Store routing context for URL Rewriting
            MTApp.CurrentRequestContext.RoutingContext = this.Request.RequestContext;

            // Determine store id
            MTApp.CurrentStore = MerchantTribe.Commerce.Utilities.UrlHelper.ParseStoreFromUrl(System.Web.HttpContext.Current.Request.Url, MTApp);
            if (MTApp.CurrentStore == null)
            {
                Response.Redirect("~/storenotfound");
            }

            if (MTApp.CurrentStore.Status == MerchantTribe.Commerce.Accounts.StoreStatus.Deactivated)
            {
                Response.Redirect("~/storenotavailable");
            }

            // Culture Settings
            System.Threading.Thread.CurrentThread.CurrentCulture   = new System.Globalization.CultureInfo(MTApp.CurrentStore.Settings.CultureCode);
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(MTApp.CurrentStore.Settings.CultureCode);

            IntegrationLoader.AddIntegrations(this.MTApp.CurrentRequestContext.IntegrationEvents, this.MTApp.CurrentStore);

            ValidateAdminLogin();
        }
Esempio n. 47
0
        public void CanPutAProductOnSale()
        {
            Promotion p = new Promotion();

            p.IsEnabled           = true;
            p.Name                = "Product Sale Test";
            p.CustomerDescription = "A Customer Discount";
            p.StartDateUtc        = DateTime.Now.AddDays(-1);
            p.EndDateUtc          = DateTime.Now.AddDays(1);
            p.StoreId             = 1;
            p.Id = 1;
            Assert.IsTrue(p.AddQualification(new ProductBvin("bvin1234")), "Add Qualification Failed");
            Assert.IsTrue(p.AddAction(new ProductPriceAdjustment(AmountTypes.MonetaryAmount, -20m)), "Add Action Failed");

            Catalog.Product prod = new Catalog.Product();
            prod.Bvin      = "bvin1234";
            prod.SitePrice = 59.99m;
            prod.StoreId   = 1;

            Catalog.UserSpecificPrice userPrice = new Catalog.UserSpecificPrice(prod, null);

            RequestContext           c   = new RequestContext();
            MerchantTribeApplication app = MerchantTribeApplication.InstantiateForMemory(c);

            bool actual = p.ApplyToProduct(app, prod, userPrice, null, DateTime.UtcNow);

            Assert.IsTrue(actual, "Promotion should have applied with return value of true");
            Assert.AreEqual(39.99m, userPrice.PriceWithAdjustments(), "Price should have been reduced by $20.00");
            Assert.AreEqual(p.CustomerDescription, userPrice.DiscountDetails[0].Description, "Description should match promotion");
        }
Esempio n. 48
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            StringBuilder sb = new StringBuilder();
            bool secure = app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection;
            string mode = tag.GetSafeAttribute("mode");

            if (mode == "system")
            {
                string baseScriptFolder = app.CurrentStore.RootUrl();
                if (secure) baseScriptFolder = app.CurrentStore.RootUrlSecure();
                if (baseScriptFolder.EndsWith("/") == false)
                {
                    baseScriptFolder += "/";
                }
                baseScriptFolder += "scripts/";

                bool useCDN = false;
                string cdn = tag.GetSafeAttribute("cdn");
                if (cdn == "1" || cdn == "true" || cdn == "y" || cdn == "Y") useCDN = true;

                if (useCDN)
                {
                    // CDN JQuery
                    if (secure)
                    {
                        sb.Append("<script src='https://ajax.microsoft.com/ajax/jQuery/jquery-1.5.1.min.js' type=\"text/javascript\"></script>");
                    }
                    else
                    {
                        sb.Append("<script src='http://ajax.microsoft.com/ajax/jQuery/jquery-1.5.1.min.js' type=\"text/javascript\"></script>");
                    }
                }
                else
                {
                    // Local JQuery
                    sb.Append("<script src='" + baseScriptFolder + "jquery-1.5.1.min.js' type=\"text/javascript\"></script>");
                }
                sb.Append(System.Environment.NewLine);

                sb.Append("<script src='" + baseScriptFolder + "jquery-ui-1.8.7.custom/js/jquery-ui-1.8.7.custom.min.js' type=\"text/javascript\"></script>");
                sb.Append("<script src='" + baseScriptFolder + "jquery.form.js' type=\"text/javascript\"></script>");
                sb.Append(System.Environment.NewLine);
            }
            else
            {
                string src = tag.GetSafeAttribute("src");
                string fileName = tag.GetSafeAttribute("file");
                if (fileName.Trim().Length > 0)
                {
                    ThemeManager tm = app.ThemeManager();
                    src = tm.ThemeFileUrl(fileName, app);
                }
                sb.Append("<script src=\"" + src + "\" type=\"text/javascript\"></script>");
            }

            return sb.ToString();
        }
Esempio n. 49
0
 public static string CartLink(MerchantTribeApplication app, string itemCount)
 {
     string storeRootUrl = app.StoreUrl(false, true);
     StringBuilder sb = new StringBuilder();
     sb.Append("<a href=\"" + storeRootUrl + "cart/\"><span>View Cart: ");
     sb.Append(itemCount);
     sb.Append(" items</span></a>");
     return sb.ToString();
 }
Esempio n. 50
0
        public static string HeaderLinks(MerchantTribeApplication app, string currentUserId)
        {
            StringBuilder sb = new StringBuilder();

            string rootUrl = app.StoreUrl(false, true);
            string rootUrlSecure = app.StoreUrl(true, false);

            sb.Append("<ul>");

            sb.Append("<li><a class=\"myaccountlink\" href=\"" + rootUrlSecure + "account\"><span>");
            sb.Append("My Account");
            sb.Append("</span></a></li>");

            sb.Append("<li><a class=\"signinlink\"");

            if (currentUserId == string.Empty)
            {
                sb.Append(" href=\"" + rootUrlSecure + "SignIn\"><span>");
                sb.Append("Sign In");
            }
            else
            {
                string name = string.Empty;
                MerchantTribe.Commerce.Membership.CustomerAccount a = app.MembershipServices.Customers.Find(currentUserId);
                if (a != null)
                {
                    name = a.Email;
                }
                sb.Append(" href=\"" + rootUrlSecure + "SignOut\" title=\"" + System.Web.HttpUtility.HtmlEncode(name) + "\"><span>");
                sb.Append("Sign Out");
            }
            sb.Append("</span></a></li>");

            //sb.Append("<li><a class=\"orderstatuslink\" href=\"" + rootUrlSecure + "OrderStatus\"><span>");
            //sb.Append("Order Status");
            //sb.Append("</span></a></li>");

            //sb.Append("<li><a class=\"emailsignuplink\" href=\"" + rootUrl + "EmailSignUp\"><span>");
            //sb.Append("Email Sign Up");
            //sb.Append("</span></a></li>");

            //sb.Append("<li><a class=\"giftcardslink\" href=\"" + rootUrl + "GiftCards\"><span>");
            //sb.Append("Gift Cards");
            //sb.Append("</span></a></li>");

            //sb.Append("<li><a class=\"contactlink\" href=\"" + rootUrl + "Contact\"><span>");
            //sb.Append("Contact Us");
            //sb.Append("</span></a></li>");

            sb.Append("<li><a class=\"contactlink\" href=\"" + rootUrl + "Checkout\"><span>");
            sb.Append("Checkout");
            sb.Append("</span></a></li>");

            sb.Append("</ul>");

            return sb.ToString();
        }
Esempio n. 51
0
 public override string FriendlyDescription(MerchantTribeApplication app)
 {
     string result = "When Order Has Any of These Coupon Codes:<ul>";
     foreach (string coupon in this.CurrentCoupons())
     {                
         result += "<li>" + coupon + "</li>";
     }
     result += "</ul>";
     return result;
 }
Esempio n. 52
0
        public static void EmailLowStockReport(object State, MerchantTribeApplication app)
        {
            RequestContext context = app.CurrentRequestContext;
            if (context == null) return;

            if (!EmailLowStockReport(context.CurrentStore.Settings.MailServer.EmailForGeneral, context.CurrentStore.StoreName, app))
            {
                EventLog.LogEvent("Low Stock Report", "Low Stock Report Failed", EventLogSeverity.Error);
            }
        }
Esempio n. 53
0
        public string RenderForEdit(MerchantTribeApplication app, Catalog.Category cat)
        {
            StringBuilder sb = new StringBuilder();            
            sb.Append("<div id=\"part" + Id + "\" class=\"editable issortable\">");
            sb.Append(PartHelper.RenderEditTools(this.Id));
            sb.Append(RenderForDisplay(app, cat));
            sb.Append("</div>");

            return sb.ToString();
        }
Esempio n. 54
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            string partName = tag.GetSafeAttribute("part");

            ThemeManager tm = app.ThemeManager();
            string result = tm.GetTemplatePartFromCurrentTheme(partName);
            TemplateProcessor proc = new TemplateProcessor(app, result, handlers);
            string processed = proc.RenderForDisplay();
            return processed;
        }
Esempio n. 55
0
        public List<Content.HtmlTemplateTag> GetReplaceableTags(MerchantTribeApplication app)
        {
            List<Content.HtmlTemplateTag> result = new List<Content.HtmlTemplateTag>();

            result.Add(new Content.HtmlTemplateTag("[[MailingListMember.EmailAddress]]", this.EmailAddress));
            result.Add(new Content.HtmlTemplateTag("[[MailingListMember.FirstName]]", this.FirstName));
            result.Add(new Content.HtmlTemplateTag("[[MailingListMember.LastName]]", this.LastName));

            return result;
        }
Esempio n. 56
0
        public static bool EmailLowStockReport(string recipientEmail, string storeName, MerchantTribeApplication app)
        {
            bool result = false;

            try
            {
                string fromAddress = string.Empty;
                fromAddress = recipientEmail;

                System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage(fromAddress, recipientEmail);
                m.IsBodyHtml = false;
                m.Subject = "Low Stock Report From " + storeName;

                System.Text.StringBuilder sb = new System.Text.StringBuilder();

                sb.AppendLine("The following are low in stock or out of stock:");
                sb.Append(Environment.NewLine);

                List<Catalog.ProductInventory> inventories = app.CatalogServices.ProductInventories.FindAllLowStock();

                if (inventories.Count < 1)
                {
                    sb.Append("No out of stock items found.");
                }
                else
                {
                    foreach (Catalog.ProductInventory item in inventories)
                    {
                        Catalog.Product product = app.CatalogServices.Products.Find(item.ProductBvin);
                        if (product != null)
                        {
                            sb.Append(WebAppSettings.InventoryLowReportLinePrefix);
                            sb.Append(product.Sku);
                            sb.Append(", ");
                            sb.Append(product.ProductName);
                            sb.Append(", ");
                            sb.Append(item.QuantityOnHand);
                            sb.AppendLine(" ");
                        }
                    }
                }
                m.Body = sb.ToString();

                result = Utilities.MailServices.SendMail(m, app.CurrentStore);
            }

            catch (Exception ex)
            {
                EventLog.LogEvent(ex);
                result = false;
            }

            return result;
        }
Esempio n. 57
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            StringBuilder sb = new StringBuilder();

            foreach (string s in app.CurrentRequestContext.TempMessages)
            {
                sb.Append(s);
            }

            return sb.ToString();
        }
Esempio n. 58
0
        public void RebuildProductSearchIndex(MerchantTribeApplication app)
        {
            MerchantTribe.Web.Search.Indexers.ComplexIndexer indexer = new MerchantTribe.Web.Search.Indexers.ComplexIndexer(searcher);
            int totalProducts = app.CatalogServices.Products.FindAllForAllStoresCount();
            int totalPages = MerchantTribe.Web.Paging.TotalPages(totalProducts, INDEXREBUILDPAGESIZE);

            for (int i = 1; i <= totalPages; i++)
            {
                IndexAPage(i, indexer, app);
            }
        }
Esempio n. 59
0
        public string Process(MerchantTribeApplication app, Dictionary<string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            StringBuilder sb = new StringBuilder();

            string rootUrl = app.StoreUrl(false, true);
            string buttonUrl = app.ThemeManager().ButtonUrl("Go", app.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection);
            sb.Append("<form class=\"searchform\" action=\"" + rootUrl + "search\" method=\"get\">");
            sb.Append("<input type=\"text\" name=\"q\" class=\"searchinput\" /> <input class=\"searchgo\" type=\"image\" src=\"" + buttonUrl + "\" alt=\"Search\" />");
            sb.Append("</form>");

            return sb.ToString();
        }
Esempio n. 60
0
 private void IndexAPage(int pageNumber, MerchantTribe.Web.Search.Indexers.ComplexIndexer indexer, MerchantTribeApplication app)
 {            
     int startIndex = MerchantTribe.Web.Paging.StartRowIndex(pageNumber, INDEXREBUILDPAGESIZE);
     List<Product> page = app.CatalogServices.Products.FindAllPagedForAllStores(startIndex, INDEXREBUILDPAGESIZE);
     if (page != null)
     {
         foreach (Product p in page)
         {
             IndexProduct(p, indexer);
         }
     }
 }