示例#1
0
        /// <summary>
        /// 保存App项目
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="entity"></param>
        /// <param name="templatesEntitys"></param>
        public void SaveProject(string keyValue, AppProjectEntity entity, List <AppTemplatesEntity> templatesEntitys)
        {
            var db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    entity.Modify(keyValue);
                    db.Update(entity);
                }
                else
                {
                    entity.Create();
                    db.Insert(entity);
                }
                var expression = LinqExtensions.True <AppTemplatesEntity>();
                expression = expression.And(t => t.F_ProjectId == entity.F_Id);
                db.Delete(expression);

                foreach (var item in templatesEntitys)
                {
                    item.Create();
                    item.F_ProjectId = entity.F_Id;
                    db.Insert(item);
                }
                db.Commit();
            }
            catch
            {
                db.Rollback();
                throw;
            }
        }
示例#2
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, AppProjectEntity entity)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         entity.Modify(keyValue);
         this.BaseRepository().Update(entity);
     }
     else
     {
         entity.Create();
         this.BaseRepository().Insert(entity);
     }
 }
示例#3
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, AppProjectModel entity)
 {
     try
     {
         AppProjectEntity appProjectEntity = new AppProjectEntity();
         appProjectEntity.F_Name    = entity.F_Name;
         appProjectEntity.F_Icon    = entity.F_Icon;
         appProjectEntity.F_IsTabed = entity.F_IsTabed;
         service.SaveProject(keyValue, appProjectEntity, entity.F_Templates);
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#4
0
        /// <summary>
        /// 下载app设计
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="entity"></param>
        public string DownForm(string keyValue, AppProjectModel entity, string outputDirectory)
        {
            try
            {
                AppProjectEntity appProjectEntity = new AppProjectEntity();
                appProjectEntity.F_Name    = entity.F_Name;
                appProjectEntity.F_Icon    = entity.F_Icon;
                appProjectEntity.F_IsTabed = entity.F_IsTabed;
                //service.SaveProject(keyValue, appProjectEntity, entity.F_Templates);

                return(webappTemplate.AppBuilder(entity.F_Templates, appProjectEntity, outputDirectory));
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#5
0
        /// <summary>
        /// 产生html页面
        /// </summary>
        /// <param name="lists"></param>
        /// <returns></returns>
        public string AppBuilder(List <AppTemplatesEntity> lists, AppProjectEntity projectEntity, string outputDirectory)
        {
            string path = "";
            Dictionary <string, AppTemplatesEntity>         pageEntitys      = new Dictionary <string, AppTemplatesEntity>();
            Dictionary <string, List <AppTemplatesEntity> > componentEntitys = new Dictionary <string, List <AppTemplatesEntity> >();
            List <AppTemplatesEntity> tabsEntitys = new List <AppTemplatesEntity>();
            AppTemplatesEntity        tabEntity   = null;

            try
            {
                //将数据做分类处理
                foreach (var item in lists)
                {
                    if (item.F_Value == "lrTabs")
                    {
                        tabEntity = item;
                    }
                    else if (item.F_Value == "lrTab")
                    {
                        tabsEntitys.Add(item);
                    }
                    if (item.F_Type == "Page" && item.F_Value != "lrTabs")
                    {
                        pageEntitys.Add(item.F_Id, item);
                    }
                    else if (item.F_Type == "Component")
                    {
                        if (componentEntitys.ContainsKey(item.F_Parent))
                        {
                            componentEntitys[item.F_Parent].Add(item);
                        }
                        else
                        {
                            List <AppTemplatesEntity> componentlists = new List <AppTemplatesEntity>();
                            componentlists.Add(item);
                            componentEntitys.Add(item.F_Parent, componentlists);
                        }
                    }
                }
                //JS文件
                string jsPath = outputDirectory + "\\js";

                #region 创建appJs文件
                string appJsPath = jsPath + "\\learun-app.js";
                if (!System.IO.File.Exists(appJsPath))
                {
                    DirFileHelper.CreateFileContent(appJsPath, JSApp());
                }
                #endregion

                #region 创建路由文件
                string routerJsPath = jsPath + "\\learun-uirouter.js";
                if (!System.IO.File.Exists(routerJsPath))
                {
                    DirFileHelper.CreateFileContent(routerJsPath, JSRouter(pageEntitys, tabsEntitys, projectEntity));
                }
                #endregion

                #region 创建controllers文件
                string controllersJsPath = jsPath + "\\learun-controllers.js";
                if (!System.IO.File.Exists(controllersJsPath))
                {
                    DirFileHelper.CreateFileContent(controllersJsPath, JSControllers(pageEntitys));
                }
                #endregion

                //html文件
                string htmlPath = outputDirectory + "\\templates";
                #region 创建页面
                foreach (var item in pageEntitys)
                {
                    string htmlPagePath = htmlPath + "\\page" + item.Value.F_Id.Replace("-", "") + ".html";
                    if (!System.IO.File.Exists(htmlPagePath))
                    {
                        DirFileHelper.CreateFileContent(htmlPagePath, PageBuilder(item.Value, componentEntitys[item.Key]));
                    }
                }
                #endregion

                #region 创建tabs页
                string htmlTabsPath = htmlPath + "\\tabs.html";
                if (!System.IO.File.Exists(htmlTabsPath))
                {
                    DirFileHelper.CreateFileContent(htmlTabsPath, TabBuilder(tabEntity, tabsEntitys));
                }
                #endregion

                ZipHelper.CreateZip(outputDirectory, outputDirectory + ".zip");

                return(outputDirectory + ".zip");
            }
            catch {
                throw;
            }
        }
示例#6
0
        public string JSRouter(Dictionary <string, AppTemplatesEntity> lists, List <AppTemplatesEntity> tablists, AppProjectEntity projectEntity)
        {
            StringBuilder sb = new StringBuilder();

            try
            {
                sb.Append("angular.module('starter.uirouter', [])\r\n");
                sb.Append(".config(function ($stateProvider, $urlRouterProvider) {\r\n");
                sb.Append("$stateProvider\r\n");

                if (projectEntity.F_IsTabed == 1)
                {
                    sb.Append(".state('tab', {\r\n");
                    sb.Append("url: '/tab',\r\n");
                    sb.Append("abstract: true,\r\n");
                    sb.Append("templateUrl: 'templates/tabs.html',\r\n");
                    sb.Append("controller: 'lrTabsCtrl'\r\n");
                    sb.Append("})");

                    foreach (var item in tablists)
                    {
                        AppPageAttrModel attr = item.F_Content.ToObject <AppPageAttrModel>();
                        sb.Append(".state('tab" + item.F_Id.Replace("-", "") + "', {\r\n");
                        sb.Append("url: '/" + attr.routing + "',\r\n");
                        sb.Append("views: {\r\n");
                        sb.Append("'tab-home': {\r\n");
                        sb.Append("templateUrl: 'templates/" + attr.routing + ".html'\r\n");
                        sb.Append("}\r\n");
                        sb.Append("}\r\n");
                        sb.Append("})\r\n");
                    }
                }
                foreach (var item in lists)
                {
                    AppPageAttrModel attr = item.Value.F_Content.ToObject <AppPageAttrModel>();
                    if (attr.isFirst == "true")
                    {
                        string pageName = "page" + item.Value.F_Id.Replace("-", "");
                        sb.Append(".state('" + pageName + "', {\r\n");
                        sb.Append("url: '/" + pageName + "',\r\n");
                        sb.Append("templateUrl: 'templates/" + pageName + ".html',\r\n");
                        sb.Append("controller:'" + pageName + "Ctrl'\r\n");
                        sb.Append("});\r\n");
                        break;
                    }
                }
                sb.Append("$urlRouterProvider.otherwise('/')\r\n");
                return(sb.ToString());
            }
            catch
            {
                throw;
            }
        }