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 string GetListHtml()
        {
            var directoryPath = GetTemplatesDirectoryPath();
            var htmlPath      = FormUtils.PathCombine(directoryPath, "list.html");
            var html          = CacheUtils.Get <string>(htmlPath);

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

            html = FormUtils.ReadText(htmlPath);

            CacheUtils.Insert(htmlPath, html, 24);
            return(html);
        }
Exemplo n.º 3
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.º 4
0
            public static List <KeyValuePair <string, FieldInfo> > GetAllFieldInfoList(int formId)
            {
                var cacheKey = GetCacheKey(formId);
                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 = Repository.GetAllFieldInfoList(formId);

                        CacheUtils.Insert(cacheKey, retVal, 12);
                    }
                }

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

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

                lock (LockObject)
                {
                    retVal = CacheUtils.Get <IList <FormInfo> >(cacheKey);
                    if (retVal == null)
                    {
                        retVal = Repository.GetFormInfoList(siteId);

                        CacheUtils.Insert(cacheKey, retVal, 12);
                    }
                }

                return(retVal);
            }
Exemplo n.º 6
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);
            }