public ActionResult SaveForm(string keyValue, PageTemplateEntity entity)
 {
     if (string.IsNullOrEmpty(entity.TEMPLATETYPE))
     {
         entity.TEMPLATETYPE = "自有模板";
     }
     pagetemplatebll.SaveForm(keyValue, entity);
     return(Success("操作成功。"));
 }
Exemple #2
0
          /// <summary>
          /// 保存表单(新增、修改)
          /// </summary>
          /// <param name="keyValue">主键值</param>
          /// <param name="entity">实体对象</param>
          /// <returns></returns>
         public void SaveForm(string keyValue, PageTemplateEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public ActionResult SaveCopyForm(string keyValue)
        {
            var entity = pagetemplatebll.GetEntity(keyValue);

            if (null != entity)
            {
                PageTemplateEntity nentity = new PageTemplateEntity();
                nentity              = entity;
                nentity.ID           = string.Empty;
                nentity.TEMPLATENAME = nentity.TEMPLATENAME + "_复制对象";
                pagetemplatebll.SaveForm("", nentity);
            }
            return(Success("操作成功。"));
        }
        /// <summary>
        /// 导入json
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public ActionResult ImportData()
        {
            try
            {
                HttpPostedFileBase file       = HttpContext.Request.Files[0];
                string             fileName   = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName);
                string             serverpath = Server.MapPath("~/Resource/temp/" + fileName);
                file.SaveAs(serverpath);

                StreamReader sr    = new StreamReader(serverpath, Encoding.UTF8);
                string       input = sr.ReadToEnd();
                sr.Close();

                JArray jarray = (JArray)JsonConvert.DeserializeObject(input);
                foreach (JObject obj in jarray)
                {
                    string organizeid      = obj["organizeid"].ToString();
                    string organizename    = obj["organizename"].ToString();
                    string templatename    = obj["templatename"].ToString();
                    string filename        = obj["filename"].ToString();
                    string templatecode    = obj["templatecode"].ToString();
                    string templatetype    = obj["templatetype"].ToString();
                    string relativepath    = obj["relativepath"].ToString();
                    string modulename      = obj["modulename"].ToString();
                    string templatecontent = obj["templatecontent"].ToString();

                    PageTemplateEntity entity = new PageTemplateEntity();
                    entity.ORGANIZEID      = organizeid;
                    entity.ORGANIZENAME    = organizename;
                    entity.TEMPLATENAME    = templatename + "_导入";
                    entity.FILENAME        = filename;
                    entity.TEMPLATECODE    = templatecode;
                    entity.TEMPLATETYPE    = templatetype;
                    entity.RELATIVEPATH    = relativepath;
                    entity.MODULENAME      = modulename;
                    entity.ISENABLE        = "是";
                    entity.TEMPLATECONTENT = templatecontent;
                    pagetemplatebll.SaveForm("", entity);
                }
            }
            catch (Exception ex)
            {
                return(Error(ex.Message));
            }
            return(Success("操作成功。"));
        }