public void Process(PipelineArgs args)
        {
            if (Context.ClientPage.IsEvent)
            {
                return;
            }

            var context = HttpContext.Current;
            if (context == null)
            {
                return;
            }

            var page = context.Handler as Page;
            if (page == null)
            {
                return;
            }

            Assert.IsNotNull(page.Header, "Content Editor <head> tag is missing runat='value'");

            var scripts = new[]
            {
              "/sitecore/shell/Controls/Lib/Scriptaculous/Scriptaculous.js",
              "/sitecore/shell/Controls/Lib/Scriptaculous/builder.js",
              "/sitecore/shell/Controls/Lib/Scriptaculous/effects.js",
              "/sitecore/shell/Controls/Lib/Scriptaculous/dragdrop.js",
              "/sitecore/shell/Controls/Lib/Scriptaculous/slider.js"
            };

            foreach (var script in scripts)
            {
                page.Header.Controls.Add(new LiteralControl("<script type='text/javascript' language='javascript' src='{0}'></script>".FormatWith(script)));
            }
        }
        public ActionResult Upload()
        {
            HttpPostedFileBase file = Request.Files[0];
            bool hasFile =  file != null && file.InputStream != null && file.ContentLength != 0;

            if (hasFile)
            {
                //Here the file should be saved to any temporary storage.
                //E.g. file system or Azure blob storage

                string uploaded = "http://yourpathtofile.com/file";

                var response = new
                {
                    status = "success",
                    url = uploaded,
                    filename = uploaded
                };

                return new JsonResult()
                {
                    Data = response,
                };
            }

            return new JsonResult
            {
                Data = new
                {
                    status = "error",
                    error = "Reason what happened"
                }
            };
        }
        public static ISessionFactory CreateSessionFactory(string connString = "")
        {
            // Use by default, production backend.
            if (connString == string.Empty)
                connString = @"Data Source=RICHARD-VAIO\RICHARDDB;Initial Catalog='Lighthouse - PIMS';Integrated Security=True";

            // Use default subclassed Identity model.
            var appUsers = new[] { typeof(ApplicationUser) };

            return FluentNHibernate.Cfg.Fluently.Configure()
                //TODO: Modify to use web.config settings for connection string
                //.Database(MsSqlConfiguration.MsSql2008.ConnectionString(c => c.FromConnectionStringWithKey("Connection-String"))
                .ExposeConfiguration(cfg => cfg.AddDeserializedMapping(MappingHelper.GetIdentityMappings(appUsers), null))
                .Database(MsSqlConfiguration.MsSql2008
                                            .ConnectionString(c => c.Is(connString))
                                                    //.ShowSql() // temp for testing/debugging.
                                                    //.IsolationLevel(IsolationLevel.RepeatableRead)
                                                    //.AdoNetBatchSize(10) // Limit batch inserts (etc)
                         )
                .CurrentSessionContext("web")  // Use current HttpContext in managing NH ISession.
                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<AssetMap>()
                                // Export current mappings for debug, if necessary - NOT WORKING
                                //.ExportTo(@"C:\Development\VS2012\IncomeMgmtSystem\src\PIMS.Data\Documentation")
                         )
                .BuildSessionFactory();
        }
        public ActionResult Login(LoginModel model)
        {
            try
            {
                User user = Service.FindByUsernamePassword(model.UserName, model.Password);
                if (user != null)
                {
                    var obj = new { status = "ok" };

                    this.AddUserAuthenticatedCookie(user.Code.ToString());

                    return Json(obj, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    var obj = new { status = "error" };
                    return Json(obj, JsonRequestBehavior.DenyGet);
                }
            }
            catch
            {
                var obj = new { status = "error" };
                return Json(obj, JsonRequestBehavior.DenyGet);
            }
        }
        public void Process(PipelineArgs args)
        {
            if (Context.ClientPage.IsEvent)
            {
                return;
            }

            var current = HttpContext.Current;

            if (current == null)
            {
                return;
            }

            var page = current.Handler as Page;

            if (page == null)
            {
                return;
            }

            Assert.IsNotNull(page.Header, "Content Editor <head> tag is missing runat='value'");

            var array = new []  { "/sitecore modules/Shell/MarkdownField/js/showdown.js" };

            foreach (var text in array)
            {
                page.Header.Controls.Add(new LiteralControl("<script type='text/javascript' language='javascript' src='{0}'></script>".FormatWith(new object[]{ text })));
            }
        }
示例#6
0
		internal static void RegisterRoutes()
		{
			var urls = new[] 
		    { 
		        "ssr-jquip.all", 
		        "ssr-includes.js", 
		        "ssr-includes.css", 
		        "ssr-includes.tmpl", 
		        "ssr-results"
		    };
			var routes = RouteTable.Routes;
			var handler = new MiniProfilerRouteHandler(new MiniProfilerHandler());
			var prefix = (Profiler.Settings.RouteBasePath ?? "").Replace("~/", "").WithTrailingSlash();

			using (routes.GetWriteLock())
			{
				foreach (var url in urls)
				{
					var route = new Route(prefix + url, handler) {
						// we have to specify these, so no MVC route helpers will match, e.g. @Html.ActionLink("Home", "Index", "Home")
						Defaults = new RouteValueDictionary(new { controller = "MiniProfilerHandler", action = "ProcessRequest" })
					};

					// put our routes at the beginning, like a boss
					routes.Insert(0, route);
				}
			}
		}
示例#7
0
        /// <summary>
        /// Identity current request sent by mobile device.
        /// </summary>
        /// <param name="request">The http request object</param>
        /// <returns>A boolean value</returns>
        public static bool IsMobileRequest(this HttpRequestBase request)
        {
            //FIRST TRY BUILT IN ASP.NT CHECK
            if (request.Browser.IsMobileDevice)
            {
                return true;
            }
            //THEN TRY CHECKING FOR THE HTTP_X_WAP_PROFILE HEADER
            if (request.ServerVariables["HTTP_X_WAP_PROFILE"] != null)
            {
                return true;
            }
            //THEN TRY CHECKING THAT HTTP_ACCEPT EXISTS AND CONTAINS WAP
            if (request.ServerVariables["HTTP_ACCEPT"] != null &&
                request.ServerVariables["HTTP_ACCEPT"].ToLower().Contains("wap"))
            {
                return true;
            }
            //AND FINALLY CHECK THE HTTP_USER_AGENT
            //HEADER VARIABLE FOR ANY ONE OF THE FOLLOWING
            if (request.ServerVariables["HTTP_USER_AGENT"] != null)
            {
                //Create a list of all mobile types
                string[] mobiles =
                    new[]
              {
                  "midp", "j2me", "avant", "docomo",
                  "novarra", "palmos", "palmsource",
                  "240x320", "opwv", "chtml",
                  "pda", "windows ce", "mmp/",
                  "blackberry", "mib/", "symbian",
                  "wireless", "nokia", "hand", "mobi",
                  "phone", "cdm", "up.b", "audio",
                  "SIE-", "SEC-", "samsung", "HTC",
                  "mot-", "mitsu", "sagem", "sony"
                  , "alcatel", "lg", "eric", "vx",
                  "NEC", "philips", "mmm", "xx",
                  "panasonic", "sharp", "wap", "sch",
                  "rover", "pocket", "benq", "java",
                  "pt", "pg", "vox", "amoi",
                  "bird", "compal", "kg", "voda",
                  "sany", "kdd", "dbt", "sendo",
                  "sgh", "gradi", "jb", "dddi",
                  "moto", "iphone"
              };

                //Loop through each item in the list created above
                //and check if the header contains that text
                foreach (string s in mobiles)
                {
                    if (request.ServerVariables["HTTP_USER_AGENT"].ToLower().Contains(s.ToLower()))
                    {
                        return true;
                    }
                }
            }

            return false;
        }
 private void BootstrapContainer()
 {
     var installers = new[]
     {
         FromAssembly.Containing<AuthInstaller>(),
         FromAssembly.Containing<ControllerInstaller>(),
         FromAssembly.Containing<RepositoryInstaller>(),
         FromAssembly.Containing<DependencyInversionInstaller>()
     };
     _windsorContainer = new WindsorContainer();
     _windsorContainer.Install(installers);
     _windsorContainer.Kernel.Resolver.AddSubResolver(new CollectionResolver(_windsorContainer.Kernel, true));
     GlobalConfiguration.Configuration.DependencyResolver = new WindsorResolver(_windsorContainer);
 }
示例#9
0
        public static void Start()
        {
            var engine = new PrecompiledMvcEngine(typeof(RazorGeneratorMvcStart).Assembly)
            {
#if DEBUG
                UsePhysicalViewsIfNewer = true
#else
                UsePhysicalViewsIfNewer = false
#endif
            };

            ViewEngines.Engines.Insert(0, engine);

            // StartPage lookups are done by WebPages. 
            VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
        }
    }
示例#10
0
        /// <summary>
        /// Display the users avatar
        /// </summary>
        public static MvcHtmlString DisplayAvatar(this HtmlHelper helper, string userName, string thumbSrc)
        {
            var url = new UrlHelper(helper.ViewContext.RequestContext);
            var urlRoute = url.RouteUrl(routeValues: new
            {
                Action = "Index",
                Controller = "Profile",
                username = userName
            });

            var attributes = new
            {
                onerror = "this.src='/Uploads/default.png';",
                title = userName
            };

            return ImageLink(helper, urlRoute, Image(helper, thumbSrc, "thumbnail", htmlAttributes: attributes));
        }
        public static MvcHtmlString MetaRobots(this HtmlHelper htmlHelper)
        {
            object allowRobotsObject = htmlHelper.ViewData[DataKeys.AllowRobots];
            if (allowRobotsObject == null || !(allowRobotsObject is AllowRobots))
                return new MvcHtmlString(string.Empty);

            var allowRobots = (AllowRobots)allowRobotsObject;
            var elements = new[] { "noindex", "nofollow", "noarchive" };
            if ((allowRobots & AllowRobots.Index) == AllowRobots.Index)
                elements[0] = "index";
            if ((allowRobots & AllowRobots.Follow) == AllowRobots.Follow)
                elements[1] = "follow";
            if ((allowRobots & AllowRobots.Archive) == AllowRobots.Archive)
                elements[1] = "archive";

            string content = string.Join(", ", elements);
            string metaTag = string.Format("<meta name='robots' content='{0}' />", content);
            return new MvcHtmlString(metaTag);
        }
示例#12
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            var nserviceBusAssemblies = new[]
                                            {
                                                typeof (IMessage).Assembly,
                                                typeof (Configure).Assembly,
                                            };
            var windsorContainer = new WindsorContainer();
            Configure
                .With(nserviceBusAssemblies)
                .Log4Net()
                .CastleWindsorBuilder(windsorContainer)
                .BinarySerializer()
                .MsmqTransport()
                .UnicastBus()
                .LoadMessageHandlers()
                .CreateBus()
                .Start();
            NhibernateInstaller.SetUnitOfWorkLifeStyle(x => x.PerWebRequest);
            windsorContainer.Install(
                FromAssembly.Containing<ControllerInstaller>(),
                FromAssembly.Containing<QueryExecutorInstaller>(),
                FromAssembly.Containing<CommandHandlerInstaller>(),
                FromAssembly.Containing<EventHandlerInstaller>(),
                FromAssembly.Containing<QueryHandlerInstaller>(),
                FromAssembly.Containing<NhibernateInstaller>(),
                FromAssembly.Containing<EmailMakerNhibernateInstaller>()
                );
            IoC.Initialize(new CastleContainer(windsorContainer));

            ControllerBuilder.Current.SetControllerFactory(new IoCControllerFactory());
            ModelBinders.Binders.DefaultBinder = new EnumConverterModelBinder();
        }
示例#13
0
        public static void RegisterSecurity(this Container container)
        {
            container.Register<SecurityStore>();
            container.Register<IUserStore<User, int>, SecurityStore>();
            container.Register<IUserLoginStore<User, int>, SecurityStore>();
            container.Register<IUserRoleStore<User, int>, SecurityStore>();
            container.Register<IUserPasswordStore<User, int>, SecurityStore>();
            container.Register<IUserClaimStore<User, int>, SecurityStore>();
            container.Register<IUserSecurityStampStore<User, int>, SecurityStore>();
            container.Register<IQueryableUserStore<User, int>, SecurityStore>();

            // identity UserManager<User, int> registration
            container.Register(() => new UserManager<User, int>(container.GetInstance<IUserStore<User, int>>()));

            container.Register<IUserStore<UserTicket, string>, UserTokenSecurityStore>();
            container.Register(() =>
            {
                var userManager = new UserManager<UserTicket, string>(container.GetInstance<IUserStore<UserTicket, string>>());
                var protectionProvider = container.GetInstance<IDataProtectionProvider>();
                var purposes = new[]
                {
                    EmailVerificationPurpose.CreateLocalUser.ToString(),
                    EmailVerificationPurpose.CreateRemoteUser.ToString(),
                    EmailVerificationPurpose.AddEmail.ToString(),
                    EmailVerificationPurpose.ForgotPassword.ToString(),
                };
                IDataProtector dataProtector = protectionProvider.Create(purposes);
                userManager.UserTokenProvider = new DataProtectorTokenProvider<UserTicket, string>(dataProtector);
                return userManager;
            });

            // owin IAuthenticationManager registration
            container.Register(() => HasOwinContext()
                ? HttpContext.Current.GetOwinContext().Authentication : new BigFatPhonyAuthenticationManager());

            container.Register<IAuthenticate, OwinAuthenticator>();
        }
示例#14
0
 public static void RegisterRoutes(RouteCollection routes)
 {
     routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
     var defaults = new { controller = "Home", action = "Index", id = UrlParameter.Optional };
     routes.MapRoute("Default", "{controller}/{action}/{id}", defaults);
 }
示例#15
0
 /// <summary>
 /// 创建永久带参数二维码
 /// </summary>
 /// <param name="sceneId">参数值</param>
 /// <param name="accessToken"></param>
 /// <returns></returns>
 internal static QRCodeInfo CreateQR_LIMIT_SCEN(long sceneId, string accessToken)
 {
     var obj = new { action_name = "QR_LIMIT_SCENE", action_info = new { scene = new { scene_id = sceneId } } };
     return CreateQR(obj, accessToken);
 }
示例#16
0
 /// <summary>
 /// 创建临时带参数二维码
 /// </summary>
 /// <param name="sceneId">参数值</param>
 /// <param name="accessToken"></param>
 /// <returns></returns>
 internal static QRCodeInfo CreateQR_SCENE(long sceneId, string accessToken)
 {
     var obj = new { expire_seconds = 1800, action_name = "QR_SCENE", action_info = new { scene = new { scene_id = sceneId } } };
     return CreateQR(obj, accessToken);
 }
示例#17
0
        public object GetExtendProperty(string strUserName)
        {
            var userid = WebSecurity.GetUserId(strUserName);

            var userExtend = this._userExtendRepository.Single(x => x.UserId == userid);

            var uid = userExtend.Uid;

            var profile = this._userProfileRepository.Single(x => x.UserId == userid);


            var obj = new
                          {
                              Uid = uid,
                              profile.Sex,
                              profile.NickName,
                              profile.City,
                              profile.Province,
                              profile.UserName,
                              profile.Email,
                              profile.Avator,
                              profile.CityName,
                              profile.ProvinceName,
                              profile.UserId
                          };

            return obj;
        }