Beispiel #1
0
        private string GetWikiImageRef(string addr, string name, string tail, IMvcContext context)
        {
            var appname = context.Application.ApplicationName;
            var call    = ("/" + appname + "/wiki/getfile.filedesc.qweb?code=" + addr.Substring(4)).Replace("//", "/");

            return(string.Format("<img src='{0}' {1} title='{2}' />", call, tail, name));
        }
Beispiel #2
0
        private string GetWikiBinaryRef(string addr, string name, string tail, IMvcContext context)
        {
            var appname = context.Application.ApplicationName;
            var call    = ("/" + appname + "/wiki/getfile.filedesc.qweb?code=" + addr.Substring(5)).Replace("//", "/");

            return(string.Format("<a href='{0}' {1}>{2}</a>", call, tail, name));
        }
Beispiel #3
0
        private string PageOpenUrl(string addr, string name, string tail, IMvcContext context)
        {
            var appname = context.Application.ApplicationName;
            var call    = ("/" + appname + "/wiki/get.wiki.qweb?code=" + addr).Replace("//", "/");

            return(string.Format("<a href='{0}' {1}>{2}</a>", call, tail, name));
        }
Beispiel #4
0
        private string ReferenceReplacer(Match match, string usage, WikiPage page, IMvcContext context)
        {
            var addr = match.Groups["addr"].Value;
            var name = match.Groups["name"].Value;
            var tail = match.Groups["tail"].Value;

            if (string.IsNullOrWhiteSpace(name))
            {
                name = addr;
            }
            if (context != null)
            {
                if (addr.StartsWith("/"))
                {
                    return(PageOpenUrl(addr, name, tail, context));
                }
                else if (addr.StartsWith("img:"))
                {
                    return(GetWikiImageRef(addr, name, tail, context));
                }
                else if (addr.StartsWith("file:"))
                {
                    return(GetWikiBinaryRef(addr, name, tail, context));
                }
                else
                {
                    return(GetDefaultReference(addr, name, tail, context));
                }
            }
            else
            {
                return(GetDefaultReference(addr, name, tail, context));
            }
        }
Beispiel #5
0
		private void generateNewWiki(string wikiname, IMvcContext context, IWikiRepository repo)
		{
			var executor = context.Application.MvcFactory.GetAction(context);
			try {
				var sb = new StringBuilder();
				sb.AppendFormat("<h1>JSONAPI: {0}</h1>", context.ActionName);
				sb.AppendFormat("<ul><li>{0}</li></ul>", executor.GetType().FullName);

				sb.AppendLine("<p>Документация на данный момент отсутствует. Данный файл сформирован автоматически</p>");
				var page = new WikiPage
				           	{
				           		Level = FileLevel.sys,
				           		Code = wikiname,
				           		Content = sb.ToString(),
				           		Properties = new Dictionary<string, string>
				           		             	{
				           		             		{"type", "quickdoc"},
				           		             		{"quickname", context.ActionName},
				           		             	}
				           	};
				repo.Save(page);
			}finally {
				context.Application.MvcFactory.ReleaseAction(context);
			}
		}
        private object TransformResultWithXslt(IMvcContext context, string xslt, IXPathNavigable xnav)
        {
            var resolvedxslt = FileNameResolver.Resolve(
                new FileSearchQuery {
                ProbePaths  = new[] { "~/styles", "~/usr/xslt", "~/report" },
                ProbeFiles  = new[] { xslt + ".xslt", xslt },
                ExistedOnly = true,
                PathType    = FileSearchResultType.FullPath,
                UseCache    = false,
            });

            if (null == resolvedxslt)
            {
                throw new Exception("cannot find xslt with code " + xslt);
            }
            var transform = new XslCompiledTransform(true);

            transform.Load(resolvedxslt, XsltSettings.TrustedXslt, new XmlUrlResolver());
            var sw   = new StringWriter();
            var xw   = XmlWriter.Create(sw);
            var args = new XsltArgumentList();

            args.AddExtensionObject("qorpent.mvc.context", context);
            args.AddExtensionObject("qorpent://std", new XsltStdExtensions());
            foreach (var extension in XsltExtensions)
            {
                args.AddExtensionObject(extension.GetNamespace(), extension);
            }
            transform.Transform(xnav, args, xw);
            xw.Flush();
            xw.Close();
            return(XElement.Parse(sw.ToString()));
        }
Beispiel #7
0
        /// <summary>
        /// Method to get image album
        /// </summary>
        /// <returns>IImage_Album<ListingSearchResultItem></returns>
        public IImage_Album GetImageAlbum()
        {
            IMvcContext  mvcContext = _mvcContext();
            IImage_Album imageAlbum = mvcContext.GetContextItem <IImage_Album>();

            return(imageAlbum ?? _imageAlbum);
        }
Beispiel #8
0
        /// <summary>
        /// Getting all Home Carousel component asigned in Sitecore with the Background CSS (eg:explore)
        /// </summary>
        /// <returns>Home Carousel content Slides details</returns>
        public IHomepage_Carousels HomePageCarousels()
        {
            IMvcContext         mvcContext         = _mvcContext();
            IHomepage_Carousels homepage_Carousels = mvcContext.GetDataSourceItem <IHomepage_Carousels>();

            return(homepage_Carousels ?? _homepage_Carousels);
        }
Beispiel #9
0
        /// <summary>
        /// Getting all Hero component asigned in Sitecore on field (Hero Metrics)
        /// </summary>
        /// <returns>HeroBannerList</returns>
        public IHero GetHero()
        {
            IMvcContext mvcContext = _mvcContext();
            IHero       hero       = mvcContext.GetDataSourceItem <IHero>();

            return(hero ?? _hero);
        }
Beispiel #10
0
        /// <summary>
        /// Getting 2 variants of ImageText components(Left,Right )
        /// </summary>
        /// <returns>ImageText component variation based on parameter selected from Sitecore</returns>

        public IImageText GetImageText()
        {
            IMvcContext mvcContext = _mvcContext();
            IImageText  imageText  = mvcContext.GetDataSourceItem <IImageText>();

            return(imageText ?? _imageText);
        }
Beispiel #11
0
        /// <summary>
        /// Getting 2 variants of Parallax components(background image )
        /// </summary>
        /// <returns>Parallax</returns>
        public IParallax GetParallax()
        {
            IMvcContext mvcContext = _mvcContext();
            IParallax   parallax   = mvcContext.GetDataSourceItem <IParallax>();

            return(parallax ?? _parallax);
        }
Beispiel #12
0
        /// <summary>
        ///     Renders error, occured in given context
        /// </summary>
        /// <param name="error"> </param>
        /// <param name="context"> </param>
        public override void RenderError(Exception error, IMvcContext context)
        {
            context.ContentType = "text/plain";
            var x = ResolveService <IBxlParser>().Generate(new XElement("error", new XCData(error.ToString())));

            context.Output.Write(x);
        }
 public LoginService(IAdventureAccountsProvider accountsProvider, IMvcContext context)
 {
     Throw.IfNull(accountsProvider, nameof(accountsProvider));
     Throw.IfNull(context, nameof(context));
     _accountsProvider = accountsProvider;
     _context          = context;
 }
		/// <summary>
		/// 	Отрисовывает переданный <see cref="IFileDescriptor" /> как контент с указанным MIME
		/// </summary>
		/// <param name="context"> </param>
		public override void Render(IMvcContext context) {
			var descriptor = context.ActionResult as IFileDescriptor;
			if (null == descriptor) {
				throw new QorpentException("Тип результата NULL или не совместим с FileDescriptorRender");
			}
			if (descriptor.Role.IsNotEmpty()) {
			    var auth = Application.Roles.IsInRole(context.User.Identity, descriptor.Role);
				if (!auth) {
					throw new QorpentSecurityException("Доступ к файлу не авторизован " + auth);
				}
			}
			if(descriptor.NeedDisposition) {
				var filename = descriptor.Name;
				var extension = Path.GetExtension(filename);
				if(string.IsNullOrWhiteSpace(extension)) {
					extension = MimeHelper.GetExtensionByMime(descriptor.MimeType);
					filename = filename + extension;
				}
				context.FileDisposition = filename;
			}
			
			context.ContentType = descriptor.MimeType;
			if(descriptor.IsStream) {
				context.WriteOutStream(descriptor.GetStream());
			}else {
				if (descriptor.Data != null) {
					context.WriteOutStream(new MemoryStream(descriptor.Data));
				}
				else {
					context.Output.Write(descriptor.Content);
				}
			}
		}
Beispiel #15
0
        private WikiPage GetWikiPage(IMvcContext context)
        {
            WikiPage page = null;

            if (context.ActionResult is WikiPage)
            {
                page = context.ActionResult as WikiPage;
            }
            else if (context.ActionResult is WikiPage[])
            {
                page = (context.ActionResult as WikiPage[])[0];
            }
            else if (context.ActionResult is string)
            {
                page = new WikiPage {
                    Text = context.ActionResult as string
                };
            }
            else
            {
                var code = context.Get("code", "");
                if (!string.IsNullOrWhiteSpace(code))
                {
                    page = WikiSource.Get(code).First();
                }
                else
                {
                    throw new Exception("cannot determine wiki to be rendered");
                }
            }
            return(page);
        }
Beispiel #16
0
        public IVideo_Gallery_Page GetVideoGalleryModel()
        {
            IMvcContext         mvcContext   = _mvcContext();
            IVideo_Gallery_Page VideoGallery = mvcContext.GetContextItem <IVideo_Gallery_Page>();

            return(VideoGallery ?? _videoGallery);
        }
Beispiel #17
0
        /// <summary>
        /// Method to get news model
        /// </summary>
        /// <returns>INews_Listing_Page<ListingSearchResultItem> </returns>
        public INews_Listing_Page GetNewsListingPageModel()
        {
            IMvcContext        mvcContext = _mvcContext();
            INews_Listing_Page newsModel  = mvcContext.GetContextItem <INews_Listing_Page>();

            return(newsModel ?? _newsModel);
        }
Beispiel #18
0
		/// <summary>
		/// Отрисовывает переданный текстовой контент в виде Wiki
		/// </summary>
		/// <param name="usage"></param>
		/// <param name="page"></param>
		/// <param name="context"></param>
		/// <returns></returns>
		public string ToHTML(string usage, WikiPage page, IMvcContext context) {
			if (string.IsNullOrWhiteSpace(page.Text)) return "";
			var lines = Preprocess(usage, page.Text, context);
			IList<string> processed = new List<string>();
			ProcessHTML(lines, processed, usage, page, context);
			return string.Join("\n",processed.ToArray()).Replace("__BLOCK__", "[[");
		}
        /// <summary>
        ///     Renders given context
        /// </summary>
        /// <param name="context"> </param>
        public override void Render(IMvcContext context)
        {
            context.ContentType = GetContentType();
            if (null != context.ActionResult)
            {
                if (context.ActionResult is string)
                {
                    if (IsNativeString(context.ActionResult as string))
                    {
                        context.Output.Write(context.ActionResult);
                        return;
                    }
                }
            }


            if (null == context.ActionResult)
            {
                context.Output.Write("null");
            }
            else
            {
                //Q-11 äîáàâëåíà ïîääåðæêà ïðåä-ïîäãîòîâêè è ôèëüòðàöèè îáúåêòà ïðè ðåíäåðèíãå
                var objectToRender = PrepareRenderObject(context);
                /////////////////////////////////////////////////////////////////
                SendOutput(context, objectToRender);
            }
        }
Beispiel #20
0
        // Checks what link item is == to contextname in order to remove it from the list of selectable links
        private void RemoveItem(IMvcContext context)
        {
            var contextName = context.ContextItem.DisplayName.ToLowerInvariant();
            var temp        = new List <Item>();

            foreach (var item in _parentItems)
            {
                temp.Add(item);
                if (item.DisplayName.ToLowerInvariant() == contextName)
                {
                    temp.Remove(item);
                }

                _parentItems = temp;
            }
            var temp2 = new List <Item>();

            foreach (var items in _childItems)
            {
                var itemName = items.DisplayName.ToString().Replace("-", string.Empty).ToLowerInvariant();
                temp2.Add(items);
                if (itemName == contextName)
                {
                    temp2.Remove(items);
                }
            }
            _childItems = temp2;
        }
Beispiel #21
0
        /// <summary>
        /// Method to get search model
        /// </summary>
        /// <returns>ISearchPage<ListingSearchResultItem> </returns>
        public ISearchPage GetSearchPageModel()
        {
            IMvcContext mvcContext      = _mvcContext();
            ISearchPage searchPageModel = mvcContext.GetContextItem <ISearchPage>();

            return(searchPageModel ?? _searchPageModel);
        }
Beispiel #22
0
        /// <summary>
        /// Getting all Interactive Map component asigned in Sitecore on field (Interactive Maps)
        /// </summary>
        /// <returns>InteractiveMapList</returns>
        public IInteractive_Map InteractiveMaps()
        {
            IMvcContext      mvcContext      = _mvcContext();
            IInteractive_Map interactive_Map = mvcContext.GetDataSourceItem <IInteractive_Map>();

            return(interactive_Map ?? _interactive_Map);
        }
Beispiel #23
0
        /// <summary>
        /// Method to get image gallery
        /// </summary>
        /// <returns>IImage_Gallery_Page<ListingSearchResultItem> </returns>
        public IImage_Gallery_Page GetImageGallery()
        {
            IMvcContext         mvcContext   = _mvcContext();
            IImage_Gallery_Page imageGallery = mvcContext.GetContextItem <IImage_Gallery_Page>();

            return(imageGallery ?? _imageGallery);
        }
Beispiel #24
0
        public static T GetRenderingItem <T>(this IMvcContext context, Action <GetKnownItemBuilder> config) where T : class
        {
            var builder = new GetKnownItemBuilder();

            config(builder);
            return(context.GetRenderingItem <T>(builder));
        }
Beispiel #25
0
        /// <summary>
        /// Method to get downloads model
        /// </summary>
        /// <returns>IDownloads_Page<ListingSearchResultItem> </returns>
        public IDownloads_Page GetDownloadsListingPageModel()
        {
            IMvcContext     mvcContext     = _mvcContext();
            IDownloads_Page downloadsModel = mvcContext.GetContextItem <IDownloads_Page>();

            return(downloadsModel ?? _downloadsModel);
        }
Beispiel #26
0
        // Query book types for either author or book name
        public static List <Book> GetBookResults(string searchTerm, IMvcContext context, IRequestContext requestContext)
        {
            var siteSearchIndexName = context.SitecoreService.Database.Name;

            using (var searchContext = ContentSearchManager.GetIndex("sitecore_" + siteSearchIndexName + "_index")
                                       .CreateSearchContext(SearchSecurityOptions.DisableSecurityCheck))
            {
                var query = searchContext.GetQueryable <SearchItem>()
                            .Where(i => i.Title.Contains(searchTerm) &&
                                   i.IsLatestVersion &&
                                   i.TemplateId == Books.Foundation.Orm.Models.sitecore.templates.User_Defined.Base.IBase_BookConstants.TemplateId &&
                                   i.Name != "__Standard Values" ||
                                   i.Author.Contains(searchTerm)).GetResults().Select(e => e.Document.GetItem()).ToList();
                var bookList = new List <Book>();
                var book     = new Book();
                foreach (var item in query)
                {
                    // Try to get it as a book
                    book = new SitecoreRepository(requestContext).FindById <Book>(item.ID.ToGuid());
                    if (book.Author != null)
                    {
                        bookList.Add(book);
                    }
                }
                return(bookList);
            };
        }
Beispiel #27
0
        public bool IsInRole(string username, string role, bool exact = false, IMvcContext callcontext = null,
                             object customcontext = null)
        {
            var principal = new GenericPrincipal(new GenericIdentity(username), null);

            return(IsInRole(principal.Identity, role, exact));
        }
Beispiel #28
0
 /// <summary>
 ///     Prepares given mvc context
 /// </summary>
 /// <param name="urlbase"> </param>
 /// <param name="context"> </param>
 public void Setup(string urlbase, IMvcContext context)
 {
     context.Uri = new Uri(urlbase + Action.Replace(".", "/") + "." + RenderName.ToLower() + ".qweb");
     if (null != Parameters)
     {
         if (Parameters is IDictionary <string, object> )
         {
             foreach (var o in ((IDictionary <string, Object>)Parameters))
             {
                 context.Set(o.Key, o.Value);
             }
         }
         else if (Parameters is IDictionary <string, string> )
         {
             foreach (var o in ((IDictionary <string, string>)Parameters))
             {
                 context.Set(o.Key, o.Value);
             }
         }
         else
         {
             var props = Parameters.GetType().GetProperties();
             foreach (var p in props)
             {
                 context.Set(p.Name, p.GetValue(Parameters, null));
             }
         }
     }
 }
Beispiel #29
0
        /// <summary>
        ///     Renders given context
        /// </summary>
        /// <param name="context"> </param>
        public override void Render(IMvcContext context)
        {
            var filename = context.ActionResult as string;

            if (null == filename)
            {
                throw new Exception("file is null");
            }
            if (!File.Exists(filename))
            {
                throw new Exception("file not existed " + filename);
            }
            var extension = Path.GetExtension(filename);

            if (extension != null)
            {
                context.ContentType = resoleMimeType(extension.Substring(1));
            }
            if (context.ContentType == "application/bin")
            {
                if (!Application.Roles.IsInRole(context.User.Identity, "DEVELOPER"))
                {
                    throw new SecurityException("only developers can access this file");
                }
                context.WriteOutFile(filename);
            }
            else
            {
                context.Output.Write(File.ReadAllText(filename));
            }
        }
Beispiel #30
0
        public virtual bool IsMatch(IMvcContext context){
            if (ControllerName.hasContent() && !ControllerName.ToUpper().Equals(context.Name.ToUpper())){
                return false;
            }
            if (ActionName.hasContent() && !ActionName.ToUpper().Equals(context.Action.ToUpper())){
                return false;
            }

            if (Roles.hasContent()){
                var match = false;
                foreach (var role in Roles.split()){
                    if (myapp.roles.IsInRole(context.User, role, false)){
                        match = true;
                        break;
                    }
                }
                if (!match){
                    return false;
                }
            }
            if (Users.hasContent()){
                if (!Users.split().Contains(myapp.usrName)){
                    return false;
                }
            }
            return true;
        }
Beispiel #31
0
		/// <summary>
		/// 	Renders given context
		/// </summary>
		/// <param name="context"> </param>
		public override void Render(IMvcContext context) {
			var standalone = context.Get("standalone", true);
			var usage = context.Get("usage", "default");
			var onserver = context.Get("onserver", true);
			var page = GetWikiPage(context);
			Render(page,usage,standalone,onserver,context);
		}
Beispiel #32
0
 public HeaderController(IMvcContext mvccontext,
                         IRequestContext requestContext, ISitecoreService sitecoreService)
 {
     this.mvccontext      = mvccontext;
     this.requestContext  = requestContext;
     this.sitecoreService = sitecoreService;
 }
Beispiel #33
0
 /// <summary>
 ///     Renders error, occured in given context
 /// </summary>
 /// <param name="error"> </param>
 /// <param name="context"> </param>
 public override void RenderError(Exception error, IMvcContext context)
 {
     context.ContentType = "text/xml";
     //var x = new XElement("error", new XCData(error.ToString()));
     //context.Output.Write(x.ToString());
     base.RenderError(error, context);
 }
Beispiel #34
0
 /// <summary>
 ///     Executes before all other calls to Action
 /// </summary>
 /// <param name="context"> </param>
 public override void SetContext(IMvcContext context)
 {
     if (null == _viewEngine)
     {
         _viewEngine = ResolveService <IViewEngine>();
     }
 }
        private object PrepareRenderObject(IMvcContext context)
        {
            //Q-14 common xpath/xslt support
            var xpath = context.Get("__xpath");
            var xslt  = context.Get("__xslt");

            if (string.IsNullOrWhiteSpace(xpath))
            {
                xpath = context.Get("xpath__");
            }
            if (string.IsNullOrWhiteSpace(xslt))
            {
                xslt = context.Get("xslt__");
            }
            var objectToRender = context.ActionResult;

            if (!string.IsNullOrWhiteSpace(xpath) || !string.IsNullOrWhiteSpace(xslt))
            {
                objectToRender = TransformResult(context, objectToRender, xpath, xslt);
            }
            if (objectToRender is XElement)
            {
                ((XElement)objectToRender).SetAttributeValue("__jsontype", "object");
            }
            return(objectToRender);
        }
Beispiel #36
0
		private void RenderStandalone(WikiPage page, string usage, bool onserver, IMvcContext context) {
			if (onserver) {
				RenderStandaloneServerProcessedPage(page,usage,context);
			}
			else {
				RenderStandaloneClientProcessedPage(page,usage,context);
			}
		}
Beispiel #37
0
		private void Render(WikiPage page, string usage, bool standalone, bool onserver,IMvcContext context) {
			context.ContentType = MimeHelper.HTML;
			if (standalone) {
				RenderStandalone(page, usage, onserver,context);
			}
			else {
				RenderEmbeded(page, usage, context);
			}
		}
 protected IReportRequest CreateRequest(IMvcContext context, IDictionary<string, object> parameters){
     var newrequest = Container.get<IReportFactory>().CreateEmptyRequest();
     var key = Container.get<IApplicationCache>().Store(newrequest);
     newrequest.RequestId = new ReportRequestIdentity{Uid = key};
     if (parameters.yes()){
         newrequest.Parameters = new Dictionary<string, object>(parameters);
     }
     return newrequest;
 }
 public IReportRequest Load(string uid, IDictionary<string, object> advancedParameters,
                            IMvcContext callingContext){
     try{
         return innerLoad(uid, advancedParameters, callingContext);
     }
     catch (Exception ex){
         throw new ReportLoadException("Report loading fails", ex, advancedParameters, uid);
     }
 }
Beispiel #40
0
		public void Render( IMvcContext context) {
			var wikiname = "_quicks/" + context.ActionName.Replace(".", "_");
			var repo = myapp.ioc.get<IWikiRepository>() ?? new WikiRepository();
			if (!repo.Exists(wikiname))
			{
				generateNewWiki(wikiname, context, repo);
			}
			var render = myapp.ioc.get<IWikiRenderService>();
			context.Output.Write(render.Start().Render(repo.Get(wikiname)));
		}
        public bool Authorize(string key, bool defaultValue, IMvcContext descriptor){
            lock (this){


                if (myapp.roles.IsAdmin()){
                    return true;
                }
                return acl.get(descriptor, false);
            }
        }
		/// <summary>
		/// 	Test given principal against role
		/// </summary>
		/// <param name="principal"> </param>
		/// <param name="role"> </param>
		/// <param name="exact"> </param>
		/// <param name="callcontext"> </param>
		/// <param name="customcontext"> </param>
		/// <returns> </returns>
		public bool IsInRole(IPrincipal principal, string role, bool exact = false, IMvcContext callcontext = null, object customcontext = null) {
			var p = principal;
			if (principal is WindowsPrincipal)
			{
				if (principal.Identity.Name.toDomain().ToLower() == Environment.MachineName.ToLower())
				{
					p = ("local\\" + principal.Identity.Name.toUserName(false)).toPrincipal();
				}
			}
			return myapp.roles.IsInRole(p, role, exact);
		}
		private void Execute(IMvcContext context)
		{
			if (!context.IgnoreActionResult)
			{
				EvaluateActionResult(context);
			}
			else
			{
				ExecuteWithoutResult(context);
			}
		}
		/// <summary>
		/// 	Executes binding action to context
		/// </summary>
		/// <param name="action"> </param>
		/// <param name="context"> </param>
		public void Bind(ActionDescriptor action, IMvcContext context) {
			lock (this) {
				if (null == _binders) {
					Setup(action.ActionType);
				}
				if (_binders != null) {
					foreach (var binder in _binders) {
						binder.Bind(action.Action, context);
					}
				}
			}
		}
Beispiel #45
0
        /// <summary>
        /// Renders given context
        /// </summary>
        /// <param name="context"></param>
        public override void Render(IMvcContext context) {

	        IChartConfig config = PrepareChartConfig(context);
	        var script = string.Empty;

	        if (config.State.IsNormal) {
		        script = GetNormalChartContent(context, config);
	        } else {
		        script = GetErrorChartContent(context, config);
	        }

	        context.Output.Write(script);
        }
 public static object Run(string name, object defaultResult, IMvcContext descriptor){
     if (NotAvail){
         return defaultResult;
     }
     var expert = storage.Load(name);
     if (null == expert){
         return defaultResult;
     }
     var context = CreateContext(descriptor);
     if (expert.Test(context)){
         expert.Execute(context);
     }
     return context.ControllerRuleResult();
 }
 protected override string rewrite(string currentresult, IMvcContext context){
     if (null == Parameters || 0 == Parameters.Count){
         return currentresult;
     }
     foreach (var param in Parameters){
         var p = "/" + param;
         var v = "null";
         if (context.ParamSource.ContainsKey(param)){
             if (null != context.ParamSource[param]){
                 v = context.ParamSource[param].ToString();
             }
         }
         currentresult += p + "_" + v;
     }
     return currentresult.ToLower();
 }
		public void Process(string viewname, string masterviewname, object viewdata, IMvcContext context) {
			var dict = new Dictionary<string, object>();
			foreach (var parameter in context.Parameters)
			{
				dict[parameter.Key] = parameter.Value;
			}
			dict["_context"] = context;
			dict["_result"] = viewdata;
		    dict["siteroot"] = ((MvcContext)context).NativeAspContext.Request.ApplicationPath;
            if (null != viewdata) {
                if (viewdata.GetType().GetCustomAttributes(typeof (CompilerGeneratedAttribute), true).Length > 0) {
                    foreach (var p in viewdata.GetType().GetProperties()) {
                        dict[p.Name] = p.GetValue(viewdata, null);
                    }
                }
            }
		    engine.Process(viewname,masterviewname,context.Output,dict);
		}
Beispiel #49
0
		private void ProcessHTML(string[] lines, IList<string> processed, string usage, WikiPage page, IMvcContext context) {
			bool codeblock = false;
			bool nowikiblock = false;
			bool table = false;
			bool ishead = false;
			for (var idx = 0; idx < lines.Length; idx++) {
				var curline = lines[idx];
				if (string.IsNullOrWhiteSpace(curline)) continue;
				if (CheckoutCodeBlock(processed, usage, page, context, curline, ref codeblock)) continue;
				//WIKI IGNORANCE SUPPORT WITH BLOCK AND INLINE
				if (CheckoutNoWikiBlock(processed, curline, ref nowikiblock)) continue;
				if (CheckoutTable(processed, usage, page, context, curline, ref table, ref ishead)) continue;
				if (CheckoutSampleBlock(processed, curline)) continue;
				if (CheckoutPageDelimiter(processed, curline)) continue;
				var defaultProcessed = ProcessDefault(curline, usage, page, context);
				if (!string.IsNullOrWhiteSpace(defaultProcessed)) {
					processed.Add(defaultProcessed);
				}
			}
		}
Beispiel #50
0
		/// <summary>
		/// 	Prepares given mvc context
		/// </summary>
		/// <param name="urlbase"> </param>
		/// <param name="context"> </param>
		public void Setup(string urlbase, IMvcContext context) {
			context.Uri = new Uri(urlbase + Action.Replace(".", "/") + "." + RenderName.ToLower() + ".qweb");
			if (null != Parameters) {
				if (Parameters is IDictionary<string, object>) {
					foreach (var o in ((IDictionary<string, Object>) Parameters)) {
						context.Set(o.Key, o.Value);
					}
				}
				else if (Parameters is IDictionary<string, string>) {
					foreach (var o in ((IDictionary<string, string>) Parameters)) {
						context.Set(o.Key, o.Value);
					}
				}
				else {
					var props = Parameters.GetType().GetProperties();
					foreach (var p in props) {
						context.Set(p.Name, p.GetValue(Parameters, null));
					}
				}
			}
		}
Beispiel #51
0
		private string ProcessDefault(string curline, string usage, WikiPage page, IMvcContext context)
		{
				// BY LINE IGNORE
				if (curline.StartsWith("!")){ //must ignore any wiki syntax this row
					curline = curline.Substring(1);
					return curline;
				}
				/////////////////////////////////////////////////////	
				// LINE BREAK SUPPORT
				if (curline == "[BR]") {
					return "<br/>";
				}
				
				curline = ProcessInline(curline,usage,page,context);
				// references
				curline = ProcessReferences(curline, usage, page, context);

				curline = ProcessLine(curline, usage, page, context);
				
				return curline;
		}
	    /// <param name="principal"> </param>
	    /// <param name="role"> </param>
	    /// <param name="exact"> </param>
	    /// <param name="callcontext"> </param>
	    /// <param name="customcontext"> </param>
	    /// <returns> </returns>
	    public bool IsInRole(IPrincipal principal, string role, bool exact = false, IMvcContext callcontext = null, object customcontext = null) {
			if (null != storage)
			{
				try
				{
					var name = principal.Identity.Name;
					var mylogin = storage.First("? in (Login,Login2)", name);

					if (null != mylogin)
					{
						return mylogin.Active &&
							   Enumerable.Contains(mylogin.Roles.split().Select(r => r.ToUpper()), role.ToUpper());
					}
				}
				catch (Exception ex)
				{
					//   CoreLogger.Common.Error("Ошибка при разрешении ролей",ex);
				}
			}
			return false;
	    }
Beispiel #53
0
	    private string GetErrorChartContent(IMvcContext context, IChartConfig config) {
			if (context.Get("format", context.Get("__format")) == "json")
			{
				dynamic result = new UObj();
				result.config = config;			
				result.error = config.State.Message;
				context.ContentType = MimeHelper.JSON;
				return result.ToJson();
			}
		    var id = "g"+Guid.NewGuid().ToString().Replace("-", "");
		    var script = @"<div class='chart_Error chart_Error_'"+config.State.Level+"'>";
			if (!string.IsNullOrWhiteSpace(config.State.Title)){
				script += "<h3>" + config.State.Title + "</h3>";
			} else if (null != config.State.Exception) {
				script += "<p>Произошла ошибка " + config.State.Exception.GetType().Name + "</p>"; 
			}
			if (!string.IsNullOrWhiteSpace(config.State.Message)) {
				script += "<p>" + config.State.Message.Replace("\r\n", "<br/>") + "</p>";
			} else if (null != config.State.Exception) {
				script += "<p>" + config.State.Exception.Message.Replace("\r\n", "<br/>") + "</p>";
			}
			if (null != config.State.Exception){
				script += "<button onclick='$(\"#" + id + "\").toggle()'>Показать подробности ошибки</button>";
				script += "<BR /><textarea rows='30' cols='120' id='" + id + "' style='display:none'>" + config.State.Exception + "</textarea>";
			}
		    script += "</div>";
			if (!string.IsNullOrWhiteSpace(context.Get("standalone")))
			{
				script = @"
<html>
<header>
</header>
<body>
<script type=""text/javascript"" src=""../scripts/jquery.min.js""></script>
" + script + @"
</body>
</html>";
			}
		    return script;
	    }
Beispiel #54
0
		private WikiPage GetWikiPage(IMvcContext context) {
			WikiPage page = null;
			if (context.ActionResult is WikiPage) {
				page = context.ActionResult as WikiPage;
			}
			else if (context.ActionResult is WikiPage[]) {
				page = (context.ActionResult as WikiPage[])[0];
			}
			else if (context.ActionResult is string) {
				page = new WikiPage {Text = context.ActionResult as string};
			}
			else {
				var code = context.Get("code", "");
				if (!string.IsNullOrWhiteSpace(code)) {
					page = WikiSource.Get(code).First();
				}
				else {
					throw new Exception("cannot determine wiki to be rendered");
				}
			}
			return page;
		}
		/// <summary>
		/// 	Renders given context
		/// </summary>
		/// <param name="context"> </param>
		public override void Render(IMvcContext context) {
            context.ContentType = GetContentType();
            if (null != context.ActionResult) {
                if (context.ActionResult is string) {
                    if (IsNativeString(context.ActionResult as string)) {
                        context.Output.Write(context.ActionResult);
                        return;
                    }
                }
            }

			
			if (null == context.ActionResult) {
				context.Output.Write("null");
			}
			else {
			    //Q-11 äîáàâëåíà ïîääåðæêà ïðåä-ïîäãîòîâêè è ôèëüòðàöèè îáúåêòà ïðè ðåíäåðèíãå
			    var objectToRender = PrepareRenderObject(context);
			    /////////////////////////////////////////////////////////////////
			    SendOutput(context, objectToRender);
			}
		}
        public  void SetConverted(object action, string val, IMvcContext context, Action<object,object> directsetter) {
			if(null==val) {
				directsetter(action, null);
				return;
			}
            var sys = System;
            if(ContextSystem) {
                sys = context.Get("system");
            }
            if(sys.noContent()) {
                sys = System;
                if(sys.noContent()) {
                    sys = "Default";
                }
            }
            
            this.storage = this.storage ?? myapp.storage.Get(TargetType, sys, true);
            object key = val;
            if(val.ToStr().like(@"^\d+$")) {
                key = key.toInt();
            }
            var realval = storage.Load(TargetType, key, sys);
            directsetter(action, realval);
        }
Beispiel #57
0
		/// <summary>
		/// 	Executes given context on action with binding to it
		/// </summary>
		/// <param name="context"> </param>
		/// <returns> </returns>
		public object Process(IMvcContext context) {
			return Action.Process(context);
		}
Beispiel #58
0
		/// <summary>
		/// 	Binds given context to action
		/// </summary>
		/// <param name="context"> </param>
		public void Bind(IMvcContext context) {
			if (null == _binder) {
				_binder = Factory.GetBinder();
				_binder.Setup(Action.GetType());
			}
			_binder.Bind(this, context);
		}
Beispiel #59
0
		/// <summary>
		/// 	Renders error, occured in given context
		/// </summary>
		/// <param name="error"> </param>
		/// <param name="context"> </param>
		public override void RenderError(Exception error, IMvcContext context) {}
Beispiel #60
0
		/// <summary>
		/// 	Renders given context
		/// </summary>
		/// <param name="context"> </param>
		public override void Render(IMvcContext context) {}