コード例 #1
0
        public static void Run([QueueTrigger("station-imports", Connection = "StationStorage")] string stationImportItem,
                               TraceWriter log)
        {
            WebAppSettings settings = new WebAppSettings
            {
                CosmosEndpoint    = ConfigurationManager.AppSettings[""],
                CosmosAuthKey     = ConfigurationManager.AppSettings[""],
                DatabaseId        = "",
                EventCollectionId = "",
                ViewCollectionId  = ""
            };

            WebAppService app = new WebAppService(settings);

            StationImportModel stationImportModel = JsonConvert.DeserializeObject <StationImportModel>(stationImportItem);

            log.Info($"Importing station: {stationImportModel.StationName}");

            // todo create import command
            var importStation = new ImportStation(stationImportModel.StationName, stationImportModel.ThreeAlphaCode);

            app.Bus.Send(importStation);

            log.Info($"Imported station: {stationImportModel.StationName}");
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sm"></param>
        /// <param name="page"></param>
        public static void EnsureScriptManager(ref ScriptManager sm, Page page)
        {
            if (sm == null)
            {
                sm = ScriptManager.GetCurrent(page);
                if (sm == null)
                {
                    ExceptionHelper.TrueThrow(page.Form.Controls.IsReadOnly, Resources.DeluxeWebResource.E_NoScriptManager);

                    sm = new ScriptManager();

                    //根据应用的Debug状态来决定ScriptManager的状态 2008-9-18
                    bool debug = WebAppSettings.IsWebApplicationCompilationDebug();
                    sm.ScriptMode = debug ? ScriptMode.Debug : ScriptMode.Release;

                    sm.EnableScriptGlobalization = true;
                    page.Form.Controls.Add(sm);
                }
            }
            else
            {
                ExceptionHelper.FalseThrow(sm.EnableScriptGlobalization, "页面中ScriptManger对象中属性EnableScriptGlobalization值应该设置为True!");
            }

            if (sm != null)
            {
                sm.AsyncPostBackError -= sm_AsyncPostBackError;
                sm.AsyncPostBackError += new EventHandler <AsyncPostBackErrorEventArgs>(sm_AsyncPostBackError);
            }
        }
コード例 #3
0
 public WeatherController(MyContext context, WebAppSettings settings, JsonSerializerOptions jsonOptions, ILogger <WeatherController> logger)
 {
     _context     = context;
     _settings    = settings;
     _jsonOptions = jsonOptions;
     _logger      = logger;
 }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PublishService"/> class.
        /// </summary>
        /// <param name="settings"><see cref="WebAppSettings"/> instance.</param>
        /// <param name="markdownHelper"><see cref="IMarkdownHelper"/> instance.</param>
        /// <param name="fileHelper"><see cref="IFileHelper"/> instance.</param>
        /// <param name="httpClientHelper"><see cref="IHttpClientHelper"/> instance.</param>
        public PublishService(WebAppSettings settings, IMarkdownHelper markdownHelper, IFileHelper fileHelper, IHttpClientHelper httpClientHelper)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            this._settings = settings;

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

            this._markdownHelper = markdownHelper;

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

            this._fileHelper = fileHelper;

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

            this._httpClientHelper = httpClientHelper;
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostController"/> class.
        /// </summary>
        /// <param name="settings"><see cref="WebAppSettings"/> instance.</param>
        /// <param name="markdownHelper"><see cref="IMarkdownHelper"/> instance.</param>
        /// <param name="themeService"><see cref="IThemeService"/> instance.</param>
        /// <param name="publishService"><see cref="IPublishService"/> instance.</param>
        public PostController(WebAppSettings settings, IMarkdownHelper markdownHelper, IThemeService themeService, IPublishService publishService)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            this._settings = settings;

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

            this._markdownHelper = markdownHelper;

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

            this._themeService = themeService;

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

            this._publishService = publishService;
        }
コード例 #6
0
        public AppDataPortalBusOptions(WebAppSettings webAppSettings)
        {
            var retryStrategy = new Incremental(5, new TimeSpan(0, 0, 1), new TimeSpan(0, 0, 1));

            this.AppDataPath = "~/App_Data/Adxstudio.Xrm.AspNet.PortalBus/" + typeof(TMessage).Name;
            this.InstanceId  = webAppSettings.InstanceId;
            this.Timeout     = TimeSpan.FromMinutes(5);
            this.RetryPolicy = retryStrategy.CreateRetryPolicy();
        }
コード例 #7
0
        public bool LogoutCustomer(HttpContextBase context, HotcakesApplication app)
        {
            var result = true;

            Cookies.SetCookieString(WebAppSettings.CookieNameAuthenticationTokenCustomer(app.CurrentStore.Id),
                                    string.Empty,
                                    context, false, Factory.CreateEventLogger());
            return(result);
        }
コード例 #8
0
        public bool LogoutCustomer(System.Web.HttpContextBase context, MerchantTribeApplication app)
        {
            bool result = true;

            Cookies.SetCookieString(WebAppSettings.CookieNameAuthenticationTokenCustomer(app.CurrentStore.Id),
                                    "",
                                    context, false, new EventLog());
            return(result);
        }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FileHelper"/> class.
        /// </summary>
        /// <param name="settings"><see cref="WebAppSettings"/> instance.</param>
        public FileHelper(WebAppSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            this._settings = settings;
        }
コード例 #10
0
        public bool LogoutAdminUser(System.Web.HttpContextBase httpContext, MerchantTribeApplication app)
        {
            bool result = true;

            Cookies.SetCookieGuid(WebAppSettings.CookieNameAuthenticationTokenAdmin(app.CurrentStore.Id),
                                  System.Guid.NewGuid(),
                                  httpContext, false, new EventLog());

            return(result);
        }
コード例 #11
0
 public static string ChangeToCssHost(this string virtuelpath)
 {
     if (_isLocal || WebAppSettings.Get().OptimzeUrl == false)
     {
         return(virtuelpath);
     }
     else
     {
         return(virtuelpath);
     }
 }
コード例 #12
0
ファイル: ScriptSettings.cs プロジェクト: kahanu/CondorXE
        private WebAppSettings CreateWebAppSettings()
        {
            WebAppSettings settings = new WebAppSettings();

            settings.DataOptions = new DataOptions();
            settings.DataOptions.DataObjectsNamespace = "BlogApp.DataObjects";

            settings.DataOptions.ORMFramework          = new ORMFramework();
            settings.DataOptions.ORMFramework.Selected = "EntityFramework";

            return(settings);
        }
コード例 #13
0
 public ScriptController(
     IHostEnvironment hostEnvironment,
     ITargetExtractor targetExtractor,
     ICommandExecutor commandExecutor,
     CommandArguments commandArguments,
     IOptions <WebAppSettings> webApiOptions)
 {
     _hostEnvironment  = hostEnvironment;
     _targetExtractor  = targetExtractor;
     _commandExecutor  = commandExecutor;
     _commandArguments = commandArguments;
     _webAppSettings   = webApiOptions.Value;
 }
コード例 #14
0
        // Admin Users
        public bool LoginAdminUser(string email, string password, ref string errorMessage, System.Web.HttpContextBase httpContext, MerchantTribeApplication app)
        {
            bool result = false;

            try
            {
                UserAccount u = AdminUsers.FindByEmail(email);
                if (u == null)
                {
                    errorMessage = "Please check your email address and password and try again.";
                    return(false);
                }

                if (!u.DoesPasswordMatch(password))
                {
                    errorMessage = "Please check your email address and password and try again.";
                    return(false);
                }

                if (u.Status == UserAccountStatus.Disabled)
                {
                    errorMessage = "Your account is not currently active. Please contact an administrator for details.";
                    return(false);
                }

                AuthToken token = new AuthToken();
                token.UserId  = u.Id;
                token.Expires = DateTime.UtcNow.AddDays(WebAppSettings.AuthenticationTokenValidForDays());

                if (AuthTokens.Create(token))
                {
                    Cookies.SetCookieGuid(WebAppSettings.CookieNameAuthenticationTokenAdmin(app.CurrentStore.Id),
                                          token.TokenId,
                                          httpContext, false, new EventLog());
                    result = true;
                }
                else
                {
                    errorMessage = "There was a problem with your authentication token. Please contact an administrator for assistance.";
                    return(false);
                }
            }
            catch (Exception ex)
            {
                result = false;
                EventLog.LogEvent(ex);
                errorMessage = "Unknown login error. Contact administrator for assistance.";
            }

            return(result);
        }
コード例 #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ThemeLoader"/> class.
        /// </summary>
        /// <param name="settings"><see cref="WebAppSettings"/> instance.</param>
        /// <param name="fileHelper"><see cref="IFileHelper"/> instance.</param>
        public ThemeLoader(WebAppSettings settings, IFileHelper fileHelper)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            this._settings = settings;

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

            this._fileHelper = fileHelper;
        }
コード例 #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ThemeService"/> class.
        /// </summary>
        /// <param name="settings"><see cref="WebAppSettings"/> instance.</param>
        public ThemeService(WebAppSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            this._settings = settings;

            this._controllers = new Dictionary <string, List <string> >
            {
                { "Post", new List <string>()
                  {
                      "Preview", "PublishHtml"
                  } },
            };
        }
コード例 #17
0
        public bool IsCurrentUserAdmin(MerchantTribeApplication app, HttpContextBase httpContext)
        {
            Guid?tokenId = MerchantTribe.Web.Cookies.GetCookieGuid(
                WebAppSettings.CookieNameAuthenticationTokenAdmin(app.CurrentStore.Id),
                httpContext, new EventLog());

            // no token, return
            if (!tokenId.HasValue)
            {
                return(false);
            }

            if (app.AccountServices.IsTokenValidForStore(app.CurrentStore.Id, tokenId.Value))
            {
                return(true);
            }

            return(false);
        }
コード例 #18
0
        public void Setup()
        {
            WebAppSettings.SetUnitTestPhysicalPath(@"C:\git\MerchantTribe\App\MerchantTribeStore");

            context = ContextHelper.GetFakeRequestContext("", "http://demo.localhost.dev/", "");
            app     = MerchantTribeApplication.InstantiateForMemory(context);

            viewBag = new DynamicViewDataDictionary(() => new System.Web.Mvc.ViewDataDictionary());
            //viewBag.RootUrlSecure = app.StoreUrl(true, false);
            //viewBag.RootUrl = app.StoreUrl(false, true);
            //viewBag.StoreClosed = app.CurrentStore.Settings.StoreClosed;
            //viewBag.StoreName = app.CurrentStore.Settings.FriendlyName;
            //viewBag.StoreUniqueId = app.CurrentStore.StoreUniqueId(app);
            viewBag.CustomerIp = "0.0.0.0";
            //viewBag.CustomerId = app.CurrentCustomerId ?? string.Empty;
            //viewBag.HideAnalytics = app.CurrentStore.Settings.Analytics.DisableMerchantTribeAnalytics;

            tagProvider = new TagProvider();
        }
コード例 #19
0
        public override bool LoginUser(string email, string password, out string errorMessage, out string userId)
        {
            var result = false;

            errorMessage = string.Empty;
            userId       = null;

            try
            {
                var op = ValidateUser(email, password);
                if (op.Success == false)
                {
                    errorMessage = op.Message;
                    return(false);
                }

                var u = Customers.FindByEmail(email).FirstOrDefault();
                if (u == null)
                {
                    errorMessage = "Please check your email address and password and try again.";
                    return(false);
                }

                userId = u.Bvin;

                Cookies.SetCookieString(WebAppSettings.CookieNameAuthenticationTokenCustomer(Context.CurrentStore.Id),
                                        u.Bvin,
                                        Context.RoutingContext.HttpContext, false, Factory.CreateEventLogger());
                result = true;
            }
            catch (Exception ex)
            {
                result = false;
                EventLog.LogEvent(ex);
                errorMessage = "Unknown login error. Contact administrator for assistance.";
            }

            return(result);
        }
コード例 #20
0
        public void ValidateAdminLogin()
        {
            bool validLogin = false;

            Guid?tokenId = MerchantTribe.Web.Cookies.GetCookieGuid(WebAppSettings.CookieNameAuthenticationTokenAdmin(MTApp.CurrentStore.Id),
                                                                   this.HttpContext,
                                                                   new EventLog());

            if (tokenId.HasValue)
            {
                if (this.MTApp.AccountServices.IsTokenValidForStore(this.MTApp.CurrentStore.Id, tokenId.Value))
                {
                    validLogin = true;
                }
            }

            if (validLogin == false)
            {
                Response.Redirect("~/adminaccount/login");
            }

            _AuthTokenGuid = tokenId;
        }
コード例 #21
0
        public bool LoginCustomer(string email, string password, ref string errorMessage, System.Web.HttpContextBase context, ref string userId, MerchantTribeApplication app)
        {
            bool result = false;

            try
            {
                SystemOperationResult op = ValidateUser(email, password);
                if (op.Success == false)
                {
                    errorMessage = op.Message;
                    return(false);
                }

                CustomerAccount u = Customers.FindByEmail(email);
                if (u == null)
                {
                    errorMessage = "Please check your email address and password and try again.";
                    return(false);
                }

                userId = u.Bvin;

                Cookies.SetCookieString(WebAppSettings.CookieNameAuthenticationTokenCustomer(app.CurrentStore.Id),
                                        u.Bvin,
                                        context, false, new EventLog());
                result = true;
            }
            catch (Exception ex)
            {
                result = false;
                EventLog.LogEvent(ex);
                errorMessage = "Unknown login error. Contact administrator for assistance.";
            }

            return(result);
        }
コード例 #22
0
    public static string ChangeToJsHost(this string virtuelpath)
    {
        string fileGzType = null;

        if (AcceptGzip())
        {
            fileGzType = ".gz";
        }

        if (_isLocal || WebAppSettings.Get().OptimzeUrl == false)
        {
            return(GetSiteRoot() + "/" + VirtualPathUtility.MakeRelative("~/", virtuelpath));
        }
        else
        {
            AmazonUploadContent(virtuelpath);

            Uri    path = new Uri(GetSiteRoot() + "/" + VirtualPathUtility.MakeRelative("~/", virtuelpath));
            string q    = path.Query;
            string qp   = HttpUtility.ParseQueryString(q).Get("p");

            return(P + "d2eiw75x9n1bsg.cloudfront.net/" + virtuelpath.Remove(0).GetHashCode() + "-" + context.Server.UrlEncode(qp) + ".js" + fileGzType);
        }
    }
コード例 #23
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            //Cart Count
            string itemCount = "0";
            string subTotal  = "$0.00";

            if (SessionManager.CurrentUserHasCart(MTApp.CurrentStore))
            {
                itemCount = SessionManager.GetCookieString(WebAppSettings.CookieNameCartItemCount(MTApp.CurrentStore.Id), MTApp.CurrentStore);
                subTotal  = SessionManager.GetCookieString(WebAppSettings.CookieNameCartSubTotal(MTApp.CurrentStore.Id), MTApp.CurrentStore);
                if (itemCount.Trim().Length < 1)
                {
                    itemCount = "0";
                }
                if (subTotal.Trim().Length < 1)
                {
                    subTotal = "$0.00";
                }
            }
            ViewData["CurrentCartItemCount"] = itemCount;
            this.MTApp.CurrentRequestContext.CartItemCount = itemCount;

            ViewData["CurrentCartSubTotal"] = subTotal;
            this.MTApp.CurrentRequestContext.CartSubtotal = subTotal;

            // style sheet
            ThemeManager themes = MTApp.ThemeManager();

            ViewBag.Css = themes.CurrentStyleSheet(MTApp, System.Web.HttpContext.Current.Request.IsSecureConnection);

            // Add Google Tracker to Page
            if (MTApp.CurrentStore.Settings.Analytics.UseGoogleTracker)
            {
                ViewData["analyticstop"] = MerchantTribe.Commerce.Metrics.GoogleAnalytics.RenderLatestTracker(MTApp.CurrentStore.Settings.Analytics.GoogleTrackerId);
            }

            // Additional Meta Tags
            ViewData["AdditionalMetaTags"] = MTApp.CurrentStore.Settings.Analytics.AdditionalMetaTags;

            // Bottom Analytics Tags
            this.ViewData["analyticsbottom"] = MTApp.CurrentStore.Settings.Analytics.BottomAnalytics ?? string.Empty;

            // JQuery
            ViewBag.JqueryInclude = Helpers.Html.JQueryIncludes(Url.Content("~/scripts"), this.Request.IsSecureConnection);

            // header and footer
            string header = MerchantTribe.Commerce.Storage.DiskStorage.ReadCustomHeader(MTApp.CurrentStore.Id, MTApp.CurrentStore.Settings.ThemeId);
            string footer = MerchantTribe.Commerce.Storage.DiskStorage.ReadCustomFooter(MTApp.CurrentStore.Id, MTApp.CurrentStore.Settings.ThemeId);

            if ((header.Trim().Length < 1))
            {
                header = MerchantTribe.Commerce.Utilities.HtmlRendering.StandardHeader();
            }
            ViewData["siteheader"] = MerchantTribe.Commerce.Utilities.TagReplacer.ReplaceContentTags(header, MTApp, itemCount, Request.IsSecureConnection);
            if ((footer.Trim().Length < 1))
            {
                footer = MerchantTribe.Commerce.Utilities.HtmlRendering.StandardFooter(MTApp);
            }
            footer = footer + MerchantTribe.Commerce.Utilities.HtmlRendering.PromoTag();
            ViewData["sitefooter"] = MerchantTribe.Commerce.Utilities.TagReplacer.ReplaceContentTags(footer, MTApp, itemCount, Request.IsSecureConnection);

            //log affiliate request
            if (!((string)Request.Params[WebAppSettings.AffiliateQueryStringName] == null))
            {
                string affid = string.Empty;
                try
                {
                    affid = Request.Params[WebAppSettings.AffiliateQueryStringName];
                    string referrerURL = Request.UrlReferrer.AbsoluteUri;
                    if (referrerURL == null)
                    {
                        referrerURL = string.Empty;
                    }
                    MTApp.ContactServices.RecordAffiliateReferral(affid, referrerURL, MTApp);
                }
                catch (System.Exception ex)
                {
                    EventLog.LogEvent("BaseStorePage - Page_Init", "Error loading affiliate " + ex.Message, MerchantTribe.Web.Logging.EventLogSeverity.Warning);
                }
            }

            //If this is a private store, force login before showing anything.
            if (MTApp.CurrentStore.Settings.IsPrivateStore == true)
            {
                if (SessionManager.IsUserAuthenticated(this.MTApp) == false)
                {
                    string nameOfPage = Request.AppRelativeCurrentExecutionFilePath;
                    // Check to make sure we're not going to end up in an endless loop of redirects
                    if ((!nameOfPage.ToLower().StartsWith("~/signin")) &&
                        (!nameOfPage.ToLower().StartsWith("~/forgotpassword.aspx")) &&
                        (!nameOfPage.ToLower().StartsWith("~/contactus.aspx")))
                    {
                        Response.Redirect("~/signin?ReturnUrl=" + HttpUtility.UrlEncode(this.Request.RawUrl));
                    }
                }
            }

            ViewBag.MetaKeywords    = MTApp.CurrentStore.Settings.MetaKeywords;
            ViewBag.MetaDescription = MTApp.CurrentStore.Settings.MetaDescription;


            // Save current URL for facebook like, etc.
            ViewBag.RawUrl     = Request.Url.ToString();
            ViewBag.CurrentUrl = MTApp.CurrentStore.RootUrl() + Request.Path.TrimStart('/');

            // Social Media Globals
            ViewBag.UseFaceBook    = MTApp.CurrentStore.Settings.FaceBook.UseFaceBook;
            ViewBag.FaceBookAdmins = MTApp.CurrentStore.Settings.FaceBook.Admins;
            ViewBag.FaceBookAppId  = MTApp.CurrentStore.Settings.FaceBook.AppId;

            ViewBag.UseTwitter              = MTApp.CurrentStore.Settings.Twitter.UseTwitter;
            ViewBag.TwitterHandle           = MTApp.CurrentStore.Settings.Twitter.TwitterHandle;
            ViewBag.TwitterDefaultTweetText = MTApp.CurrentStore.Settings.Twitter.DefaultTweetText;

            ViewBag.UseGooglePlus = MTApp.CurrentStore.Settings.GooglePlus.UseGooglePlus;

            // 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);
        }
コード例 #24
0
 public LocationsController(MyContext context, WebAppSettings settings, ILogger <LocationsController> logger)
 {
     _context  = context;
     _settings = settings;
     _logger   = logger;
 }
コード例 #25
0
        public string Process(MerchantTribeApplication app, Dictionary <string, ITagHandler> handlers, ParsedTag tag, string contents)
        {
            StringBuilder sb = new StringBuilder();

            string mode  = tag.GetSafeAttribute("mode");
            string href  = string.Empty;
            string sysid = tag.GetSafeAttribute("sysid");

            switch (mode.Trim().ToLowerInvariant())
            {
            case "home":
                href = app.CurrentStore.RootUrl();
                break;

            case "checkout":
                href = app.CurrentStore.RootUrlSecure() + "checkout";
                if (contents == string.Empty)
                {
                    contents = "<span>Checkout</span>";
                }
                break;

            case "cart":
                href = app.CurrentStore.RootUrl() + "cart";
                if (contents == string.Empty)
                {
                    string itemCount = "0";
                    string subTotal  = "$0.00";

                    if (SessionManager.CurrentUserHasCart(app.CurrentStore))
                    {
                        itemCount = SessionManager.GetCookieString(WebAppSettings.CookieNameCartItemCount(app.CurrentStore.Id), app.CurrentStore);
                        subTotal  = SessionManager.GetCookieString(WebAppSettings.CookieNameCartSubTotal(app.CurrentStore.Id), app.CurrentStore);
                        if (itemCount.Trim().Length < 1)
                        {
                            itemCount = "0";
                        }
                        if (subTotal.Trim().Length < 1)
                        {
                            subTotal = "$0.00";
                        }
                    }

                    contents = "<span>View Cart: " + itemCount + " items</span>";
                }
                break;

            case "category":
                Catalog.Category cat = app.CatalogServices.Categories.Find(sysid);
                href = app.CurrentStore.RootUrl() + cat.RewriteUrl;
                break;

            case "product":
                Catalog.Product p = app.CatalogServices.Products.Find(sysid);
                href = app.CurrentStore.RootUrl() + p.UrlSlug;
                break;

            case "":
                string temp = tag.GetSafeAttribute("href");
                if (temp.StartsWith("http://") || temp.StartsWith("https://"))
                {
                    href = temp;
                }
                else
                {
                    href = app.CurrentStore.RootUrl() + temp.TrimStart('/');
                }
                break;

            case "myaccount":
                href = app.CurrentStore.RootUrlSecure() + "account";
                if (contents == string.Empty)
                {
                    contents = "<span>My Account</span>";
                }
                break;

            case "signin":
                string currentUserId = SessionManager.GetCurrentUserId(app.CurrentStore);
                if (currentUserId == string.Empty)
                {
                    href = app.CurrentStore.RootUrlSecure() + "signin";
                    if (contents == string.Empty)
                    {
                        contents = "<span>Sign In</span>";
                    }
                }
                else
                {
                    href = app.CurrentStore.RootUrlSecure() + "signout";
                    if (contents == string.Empty)
                    {
                        contents = "<span>Sign Out</span>";
                    }
                }

                break;
            }

            if (href.Trim().Length > 0)
            {
                sb.Append("<a href=\"" + href + "\"");

                PassAttribute(ref sb, tag, "id");
                PassAttribute(ref sb, tag, "title");
                PassAttribute(ref sb, tag, "style");
                PassAttribute(ref sb, tag, "class");
                PassAttribute(ref sb, tag, "dir");
                PassAttribute(ref sb, tag, "lang");
                PassAttribute(ref sb, tag, "target");
                PassAttribute(ref sb, tag, "rel");
                PassAttribute(ref sb, tag, "media");
                PassAttribute(ref sb, tag, "hreflang");
                PassAttribute(ref sb, tag, "type");
                PassAttribute(ref sb, tag, "name");

                sb.Append(">" + contents + "</a>");
            }
            return(sb.ToString());
        }
コード例 #26
0
        public void Process(StringBuilder output,
                            MerchantTribe.Commerce.MerchantTribeApplication app,
                            dynamic viewBag,
                            ITagProvider tagProvider,
                            ParsedTag tag,
                            string innerContents)
        {
            string mode  = tag.GetSafeAttribute("mode");
            string href  = string.Empty;
            string sysid = tag.GetSafeAttribute("sysid");

            switch (mode.Trim().ToLowerInvariant())
            {
            case "home":
                href = app.CurrentStore.RootUrl();
                break;

            case "checkout":
                href = app.CurrentStore.RootUrlSecure() + "checkout";
                if (innerContents == string.Empty)
                {
                    innerContents = "<span>Checkout</span>";
                }
                break;

            case "cart":
                href = app.CurrentStore.RootUrl() + "cart";
                if (innerContents == string.Empty)
                {
                    string itemCount = "0";
                    string subTotal  = "$0.00";

                    if (SessionManager.CurrentUserHasCart(app.CurrentStore))
                    {
                        itemCount = SessionManager.GetCookieString(WebAppSettings.CookieNameCartItemCount(app.CurrentStore.Id), app.CurrentStore);
                        subTotal  = SessionManager.GetCookieString(WebAppSettings.CookieNameCartSubTotal(app.CurrentStore.Id), app.CurrentStore);
                        if (itemCount.Trim().Length < 1)
                        {
                            itemCount = "0";
                        }
                        if (subTotal.Trim().Length < 1)
                        {
                            subTotal = "$0.00";
                        }
                    }

                    innerContents = "<span>View Cart: " + itemCount + " items</span>";
                }
                break;

            case "carttotal":
                href = app.CurrentStore.RootUrl() + "cart";
                if (innerContents == string.Empty)
                {
                    string subTotal = "$0.00";

                    if (SessionManager.CurrentUserHasCart(app.CurrentStore))
                    {
                        subTotal = SessionManager.GetCookieString(WebAppSettings.CookieNameCartSubTotal(app.CurrentStore.Id), app.CurrentStore);
                        if (subTotal.Trim().Length < 1)
                        {
                            subTotal = "$0.00";
                        }
                    }

                    innerContents = "<span>" + subTotal + "</span>";
                }
                break;

            case "category":
                Category cat = app.CatalogServices.Categories.Find(sysid);
                href = app.CurrentStore.RootUrl() + cat.RewriteUrl;
                break;

            case "product":
                Product p = app.CatalogServices.Products.Find(sysid);
                href = app.CurrentStore.RootUrl() + p.UrlSlug;
                break;

            case "":
                string temp = tag.GetSafeAttribute("href");
                if (temp.StartsWith("http://") || temp.StartsWith("https://"))
                {
                    href = temp;
                }
                else
                {
                    href = app.CurrentStore.RootUrl() + temp.TrimStart('/');
                }
                break;

            case "myaccount":
                href = app.CurrentStore.RootUrlSecure() + "account";
                if (innerContents == string.Empty)
                {
                    innerContents = "<span>My Account</span>";
                }
                break;

            case "signin":
                string currentUserId = app.CurrentCustomerId;
                if (currentUserId == string.Empty)
                {
                    href = app.CurrentStore.RootUrlSecure() + "signin";
                    if (innerContents == string.Empty)
                    {
                        innerContents = "<span>Sign In</span>";
                    }
                }
                else
                {
                    href = app.CurrentStore.RootUrlSecure() + "signout";
                    if (innerContents == string.Empty)
                    {
                        innerContents = "<span>Sign Out</span>";
                    }
                }

                break;
            }

            //if (href.Trim().Length > 0)
            //{
            output.Append("<a href=\"" + href + "\"");
            PassAttribute(ref output, tag, "id");
            PassAttribute(ref output, tag, "title");
            PassAttribute(ref output, tag, "style");
            PassAttribute(ref output, tag, "class");
            PassAttribute(ref output, tag, "dir");
            PassAttribute(ref output, tag, "lang");
            PassAttribute(ref output, tag, "target");
            PassAttribute(ref output, tag, "rel");
            PassAttribute(ref output, tag, "media");
            PassAttribute(ref output, tag, "hreflang");
            PassAttribute(ref output, tag, "type");
            PassAttribute(ref output, tag, "name");
            output.Append(">");

            // Process any inner tags
            Processor proc = new Processor(app, viewBag, innerContents, tagProvider);

            proc.RenderForDisplay(output);

            output.Append("</a>");
            //}
        }
コード例 #27
0
 public TopMenuViewComponent(IOptions <WebAppSettings> webApiOptions)
 {
     _webAppSettings = webApiOptions.Value;
 }
コード例 #28
0
 public WebAppWeatherRequestBuilder(WebAppSettings settings, Location location)
 {
     _appSettings = settings;
     _location    = location;
 }
コード例 #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CacheInvalidationJobSettings" /> class.
 /// </summary>
 /// <param name="webAppSettings">The web app settings.</param>
 public CacheInvalidationJobSettings(WebAppSettings webAppSettings)
 {
     this.StartedOn   = webAppSettings.StartedOn;
     this.JobInterval = 2;
 }
コード例 #30
0
 public LocationsRequestBuilder(WebAppSettings settings, string searchStr)
 {
     _appSettings = settings;
     _searchStr   = searchStr;
 }