Пример #1
0
        public ActionResult SaveForm(string keyValue, App_ProjectEntity entity)
        {
            List <App_TemplatesEntity> strChildEntitys = entity.F_Templates;

            app_projectbll.SaveForm(keyValue, entity, strChildEntitys);



            return(this.Success("操作成功。"));
        }
Пример #2
0
 public void SaveForm(string keyValue, App_ProjectEntity entity, List <App_TemplatesEntity> entryList)
 {
     try
     {
         this.service.SaveForm(keyValue, entity, entryList);
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #3
0
 public void SaveForm(string keyValue, App_ProjectEntity entity)
 {
     try
     {
         this.service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #4
0
        public void SaveForm(string keyValue, App_ProjectEntity entity, List <App_TemplatesEntity> entryList)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    //主表
                    //entity.Modify(keyValue);
                    //entity.F_Templates = null;

                    //明细
                    db.ExecuteBySql("delete from App_Templates where F_ProjectId='" + keyValue + "'");
                    db.ExecuteBySql("update [App_Project] set F_Name='" + entity.F_Name + "',F_Icon='" + entity.F_Icon + "',F_IsTabed=" + entity.F_IsTabed + ",F_Description='" + entity.F_Description + "' where F_Id='" + keyValue + "'");
                    foreach (App_TemplatesEntity item in entryList)
                    {
                        item.Create();
                        item.F_ProjectId = keyValue;
                        //db.Insert(item);
                        db.ExecuteBySql("insert into App_Templates([F_Id],[F_ProjectId],[F_Name],[F_Value],[F_Type],[F_Parent],[F_level],[F_img],[F_Content],[F_CreateDate],[F_CreateUserId],[F_CreateUserName]) values('" + item.F_Id + "','" + item.F_ProjectId + "','" + item.F_Name + "','" + item.F_Value + "','" + item.F_Type + "','" + item.F_Parent + "'," + item.F_level + ",'" + item.F_img + "','" + item.F_Content + "','" + item.F_CreateDate + "','" + item.F_CreateUserId + "','" + item.F_CreateUserName + "')");
                    }
                }
                else
                {
                    //主表
                    entity.Create();
                    entity.F_Templates = null;
                    db.Insert(entity);
                    //明细
                    foreach (App_TemplatesEntity item in entryList)
                    {
                        item.Create();
                        item.F_ProjectId = entity.F_Id;
                        db.ExecuteBySql("insert into App_Templates([F_Id],[F_ProjectId],[F_Name],[F_Value],[F_Type],[F_Parent],[F_level],[F_img],[F_Content],[F_CreateDate],[F_CreateUserId],[F_CreateUserName]) values('" + item.F_Id + "','" + item.F_ProjectId + "','" + item.F_Name + "','" + item.F_Value + "','" + item.F_Type + "','" + item.F_Parent + "'," + item.F_level + ",'" + item.F_img + "','" + item.F_Content + "','" + item.F_CreateDate + "','" + item.F_CreateUserId + "','" + item.F_CreateUserName + "')");
                    }
                }
                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Пример #5
0
        public ActionResult DownForm(string keyValue, App_ProjectEntity entity)
        {
            //先创建文件
            List <App_TemplatesEntity> strChildEntitys = entity.F_Templates;
            string        filename    = "";
            string        PageTitle   = "";
            string        tempFId     = "";
            string        PageContent = "";
            string        FilePath    = "";
            StringBuilder sb0         = new StringBuilder();
            StringBuilder sb          = new StringBuilder();
            StringBuilder sb1         = new StringBuilder();
            string        zipFileName = entity.F_Name + DateTime.Now.ToString("yyyyMMddHHssmm");
            string        zipFold     = Server.MapPath("/templates/" + zipFileName + "/templates/");
            string        zipFoldJs   = Server.MapPath("/templates/" + zipFileName + "/js/");
            string        zipTemplate = "/templates/" + zipFileName + "/templates/";
            string        zipJs       = "/templates/" + zipFileName + "/js/";
            string        FID         = "";

            if (!Directory.Exists(zipFold))
            {
                Directory.CreateDirectory(zipFold);
            }
            if (!Directory.Exists(zipFoldJs))
            {
                Directory.CreateDirectory(zipFoldJs);
            }
            //打包

            foreach (App_TemplatesEntity item in strChildEntitys)
            {
                App_ContentEntity c1 = item.F_Content.ToObject <App_ContentEntity>();
                if (item.F_Type == "Page")
                {
                    if (sb0.ToString() != "")
                    {
                        StringBuilder strHtml = new StringBuilder();
                        using (StreamReader sr = new StreamReader(Server.MapPath("/templates/app/PageTemplate.html"), Encoding.GetEncoding("utf-8")))
                        {
                            strHtml = strHtml.Append(sr.ReadToEnd());
                            sr.Close();
                        }
                        //替换开始
                        strHtml = strHtml.Replace("{PageTitle}", PageTitle);
                        strHtml = strHtml.Replace("{PageContent}", sb0.ToString());
                        //替换结束

                        FilePath = Server.MapPath(zipTemplate + filename + ".html");
                        System.IO.FileInfo finfo = new System.IO.FileInfo(FilePath);
                        using (FileStream fs = finfo.OpenWrite())
                        {
                            StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8);
                            //把新的内容写到创建的HTML页面中
                            sw.WriteLine(strHtml);
                            sw.Flush();
                            sw.Close();
                        }
                    }
                    sb0.Remove(0, sb0.Length);
                    FID       = item.F_Id;
                    filename  = "page" + item.F_Id;
                    filename  = filename.Replace("-", "");
                    tempFId   = item.F_Id;
                    PageTitle = item.F_Name;
                }
                if (item.F_Type == "Component" && item.F_Value != "lrTab")
                {
                    if (item.F_Parent == tempFId)
                    {
                        if (item.F_Value == "lrHeader")
                        {
                            sb0.Append("<" + c1.size + " style=\"color:" + c1.color + "; text-align:" + c1.align + ";\">" + c1.text + "</" + c1.size + ">");
                        }
                        else if (item.F_Value == "lrList3")
                        {
                            sb0.Append("<div class=\"list lr-list-type3\"><ion-item class=\"item item-icon-left\"><i class=\"icon " + c1.icon + " " + c1.color + "\" ></i> <span>" + c1.name + "</span></ion-item></div>");
                        }
                        else if (item.F_Value == "lrList4")
                        {
                            sb0.Append("<div class=\"list lr-list-type3\"><ion-item class=\"item item-icon-left\"><i class=\"icon " + c1.icon + " " + c1.color + "\" ></i> <span>" + c1.name + "</span></ion-item></div>");
                        }
                        else if (item.F_Value == "lrInput")
                        {
                            sb0.Append("<label class=\"item item-input\"><input type=\"text\" placeholder=\"" + c1.placeholder + "\"></label>");
                        }
                        else if (item.F_Value == "lrParagraph")
                        {
                            sb0.Append("<p style=\"color:" + c1.color + ";font-size:" + c1.size + ";text-align:" + c1.align + ";\">" + c1.content + "</p>");
                        }
                        else if (item.F_Value == "lrBtn")
                        {
                            sb0.Append("<button style=\"color:" + c1.color + ";font-size:" + c1.size + ";text-align:" + c1.align + ";font-weight:500;\" class=\"button button-defaultbutton-standardbutton-positive\">" + c1.text + "</button>");
                        }
                    }
                }
                if (item.F_Value == "lrTabs")
                {
                    sb1.Append(".state('tab', {\r\n");
                    sb1.Append("url: '/tab',\r\n");
                    sb1.Append("abstract: true,\r\n");
                    sb1.Append("templateUrl: 'templates/tabs.html',\r\n");
                    sb1.Append("controller: 'lrTabsCtrl'\r\n");
                    sb1.Append("})");
                }
                else if (item.F_Value == "lrTab")
                {
                    sb1.Append(".state('tab" + item.F_Id + "', {\r\n");
                    sb1.Append("url: '/',\r\n");
                    sb1.Append("views: {\r\n");
                    sb1.Append("'tab-home': {\r\n");
                    sb1.Append("templateUrl: 'templates/.html'\r\n");
                    sb1.Append("}\r\n");
                    sb1.Append("}\r\n");
                    sb1.Append("})\r\n");
                    filename = "tabs";
                    if (item.F_Name == "首页")
                    {
                        sb.Append("<ion-tab title=\"首页\" icon-on=\"ion-ios-home\" icon-off=\"ion-ios-home-outline\" href=\"#/tab/DefaultPage\">\r\n");
                        sb.Append("<ion-nav-view name=\"tab-" + item.F_Id + "\"></ion-nav-view>");
                        sb.Append("</ion-tab>\r\n");
                    }
                    else if (item.F_Name == "实例")
                    {
                        sb.Append("<ion-tab title=\"实例\" icon-on=\"ion-ios-book\" icon-off=\"ion-ios-book-outline\" href=\"#/tab/DefaultPage\">\r\n");
                        sb.Append("<ion-nav-view name=\"tab-" + item.F_Id + "\"></ion-nav-view>");
                        sb.Append("</ion-tab>\r\n");
                    }
                    else if (item.F_Name == "通知")
                    {
                        sb.Append("<ion-tab title=\"通知\" icon-on=\"ion-ios-bell\" icon-off=\"ion-ios-bell-outline\" href=\"#/tab/DefaultPage\">\r\n");
                        sb.Append("<ion-nav-view name=\"tab-" + item.F_Id + "\"></ion-nav-view>");
                        sb.Append("</ion-tab>\r\n");
                    }
                    else if (item.F_Name == "我的")
                    {
                        sb.Append("<ion-tab title=\"我的\" icon-on=\"ion-ios-person\" icon-off=\"ion-ios-person-outline\" href=\"#/tab/DefaultPage\">\r\n");
                        sb.Append("<ion-nav-view name=\"tab-" + item.F_Id + "\"></ion-nav-view>");
                        sb.Append("</ion-tab>\r\n");
                    }
                }
            }

            StringBuilder strHtml1 = new StringBuilder();

            using (StreamReader sr = new StreamReader(Server.MapPath("/templates/app/tabs.html"), Encoding.GetEncoding("utf-8")))
            {
                strHtml1 = strHtml1.Append(sr.ReadToEnd());
                sr.Close();
            }
            //替换开始

            strHtml1 = strHtml1.Replace("{PageContent}", sb.ToString());
            //替换结束

            FilePath = Server.MapPath(zipTemplate + filename + ".html");
            System.IO.FileInfo finfo1 = new System.IO.FileInfo(FilePath);
            using (FileStream fs = finfo1.OpenWrite())
            {
                StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8);
                //把新的内容写到创建的HTML页面中
                sw.WriteLine(strHtml1);
                sw.Flush();
                sw.Close();
            }
            //JS替换
            //1.
            strHtml1.Remove(0, strHtml1.Length);
            //System.IO.File.Copy(Server.MapPath("/templates/app/learun-app.js"), Server.MapPath(zipJs));

            using (StreamReader sr = new StreamReader(Server.MapPath("/templates/app/learun-app.js"), Encoding.GetEncoding("utf-8")))
            {
                strHtml1 = strHtml1.Append(sr.ReadToEnd());
                sr.Close();
            }
            FilePath = Server.MapPath(zipJs + "learun-app.js");
            finfo1   = new System.IO.FileInfo(FilePath);
            using (FileStream fs = finfo1.OpenWrite())
            {
                StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8);
                //把新的内容写到创建的HTML页面中
                sw.WriteLine(strHtml1);
                sw.Flush();
                sw.Close();
            }
            //2.
            strHtml1.Remove(0, strHtml1.Length);

            using (StreamReader sr = new StreamReader(Server.MapPath("/templates/app/learun-controllers.js"), Encoding.GetEncoding("utf-8")))
            {
                strHtml1 = strHtml1.Append(sr.ReadToEnd());
                sr.Close();
            }
            //替换开始

            strHtml1 = strHtml1.Replace("{FID}", FID);
            //替换结束

            FilePath = Server.MapPath(zipJs + "learun-controllers.js");
            finfo1   = new System.IO.FileInfo(FilePath);
            using (FileStream fs = finfo1.OpenWrite())
            {
                StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8);
                //把新的内容写到创建的HTML页面中
                sw.WriteLine(strHtml1);
                sw.Flush();
                sw.Close();
            }
            //3.
            strHtml1.Remove(0, strHtml1.Length);
            strHtml1 = new StringBuilder();
            using (StreamReader sr = new StreamReader(Server.MapPath("/templates/app/learun-uirouter.js"), Encoding.GetEncoding("utf-8")))
            {
                strHtml1 = strHtml1.Append(sr.ReadToEnd());
                sr.Close();
            }
            //替换开始

            strHtml1 = strHtml1.Replace("{RouterStr}", sb1.ToString());
            //替换结束

            FilePath = Server.MapPath(zipJs + "learun-uirouter.js");
            finfo1   = new System.IO.FileInfo(FilePath);
            using (FileStream fs = finfo1.OpenWrite())
            {
                StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8);
                //把新的内容写到创建的HTML页面中
                sw.WriteLine(strHtml1);
                sw.Flush();
                sw.Close();
            }
            ZipDirectory(Server.MapPath("/templates/" + zipFileName), Server.MapPath("/templates/"), "", false);
            var fieldItem = new
            {
                path = zipFileName,
            };

            return(this.ToJsonResult(fieldItem));
        }