Exemplo n.º 1
0
        /// <summary>
        /// 复制报表模板
        /// </summary>
        /// <param name="id">报表模板ID</param>
        /// <param name="templet">报表模板</param>
        /// <returns>Result</returns>
        public Result <object> copyTemplate(string id, ReportTemplet templet)
        {
            if (!verify("copyTemplet"))
            {
                return(result);
            }

            var data = DbHelper.find <ReportTemplet>(id);

            if (data == null)
            {
                return(result.notFound());
            }

            templet.id            = Util.newId();
            templet.tenantId      = tenantId;
            templet.content       = data.content;
            templet.isBuiltin     = false;
            templet.creatorDeptId = deptId;
            templet.creator       = userName;
            templet.creatorId     = userId;
            templet.createTime    = DateTime.Now;
            if (existed(templet))
            {
                return(result.dataAlreadyExists());
            }

            return(DbHelper.insert(templet) ? result.success(templet) : result.dataBaseError());
        }
Exemplo n.º 2
0
 /// <summary>
 /// 模板是否存在
 /// </summary>
 /// <param name="templet"></param>
 /// <returns>bool 是否存在</returns>
 private static bool existed(ReportTemplet templet)
 {
     using (var context = new Entities())
     {
         return(context.templates.Any(i => i.id != templet.id && i.tenantId == templet.tenantId &&
                                      i.categoryId == templet.categoryId && i.name == templet.name));
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 导入报表模板
        /// </summary>
        /// <param name="template">报表模板</param>
        /// <returns>Result</returns>
        public Result <object> importTemplate(ReportTemplet template)
        {
            if (!verify("importTemplet"))
            {
                return(result);
            }

            template.id            = Util.newId();
            template.tenantId      = tenantId;
            template.isBuiltin     = false;
            template.creatorDeptId = deptId;
            template.creator       = userName;
            template.creatorId     = userId;
            template.createTime    = DateTime.Now;
            if (existed(template))
            {
                return(result.dataAlreadyExists());
            }

            return(DbHelper.insert(template) ? result.success(template) : result.dataBaseError());
        }
Exemplo n.º 4
0
        /// <summary>
        /// 编辑报表模板
        /// </summary>
        /// <param name="id">报表模板ID</param>
        /// <param name="templet">报表模板</param>
        /// <returns>Result</returns>
        public Result <object> editTemplate(string id, ReportTemplet templet)
        {
            if (!verify("editTemplet"))
            {
                return(result);
            }

            var data = DbHelper.find <ReportTemplet>(id);

            if (data == null)
            {
                return(result.notFound());
            }

            data.categoryId = templet.categoryId;
            data.name       = templet.name;
            data.remark     = templet.remark;
            if (existed(data))
            {
                return(result.dataAlreadyExists());
            }

            return(DbHelper.update(data) ? result : result.dataBaseError());
        }