Exemplo n.º 1
0
        public static string GetTemplateHtml(string templateType, string directoryName)
        {
            var htmlPath = Context.PluginApi.GetPluginPath(FormUtils.PluginId, $"templates/{directoryName}/index.html");

            var html = CacheUtils.Get <string>(htmlPath);

            if (html != null)
            {
                return(html);
            }

            html = FormUtils.ReadText(htmlPath);
            var startIndex = html.IndexOf("<body", StringComparison.Ordinal) + 5;
            var length     = html.IndexOf("</body>", StringComparison.Ordinal) - startIndex;

            html = html.Substring(startIndex, length);
            html = html.Substring(html.IndexOf('\n'));

//            var jsPath = Context.PluginApi.GetPluginPath(FormUtils.PluginId, $"assets/js/{templateType}.js");
//            var javascript = FormUtils.ReadText(jsPath);
//            html = html.Replace(
//                $@"<script src=""../../assets/js/{templateType}.js"" type=""text/javascript""></script>",
//                $@"<script type=""text/javascript"">
//{javascript}
//</script>");
            html = html.Replace("../../", "{stl.siteUrl}/sitefiles/plugins/ss.form/");
            html = html.Replace("../", "{stl.siteUrl}/sitefiles/plugins/ss.form/templates/");

            CacheUtils.InsertHours(htmlPath, html, 1);
            return(html);
        }
Exemplo n.º 2
0
            public static List <KeyValuePair <string, FieldInfo> > GetAllTableStyles()
            {
                var retval = CacheUtils.Get <List <KeyValuePair <string, FieldInfo> > >(CacheKey);

                if (retval != null)
                {
                    return(retval);
                }

                lock (LockObject)
                {
                    retval = CacheUtils.Get <List <KeyValuePair <string, FieldInfo> > >(CacheKey);
                    if (retval == null)
                    {
                        retval = FieldDao.GetAllFieldInfoList();

                        CacheUtils.InsertHours(CacheKey, retval, 12);
                    }
                }

                return(retval);
            }
Exemplo n.º 3
0
            public static List <FormInfo> GetCacheFormInfoList(int siteId)
            {
                var cacheKey = GetCacheKey(siteId);
                var retval   = CacheUtils.Get <List <FormInfo> >(cacheKey);

                if (retval != null)
                {
                    return(retval);
                }

                lock (LockObject)
                {
                    retval = CacheUtils.Get <List <FormInfo> >(cacheKey);
                    if (retval == null)
                    {
                        retval = FormDao.GetFormInfoList(siteId);

                        CacheUtils.InsertHours(cacheKey, retval, 12);
                    }
                }

                return(retval);
            }