Ejemplo n.º 1
0
        /// <summary>
        /// 生成文章类型前台控件
        /// </summary>
        /// <param name="model"></param>
        static void CreateArticleListControl(ModelInfo model)
        {
            NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath);
            string          path   = CreateDirectory(model, "List", "ArticleModelListDataControl", "列表");

            helper.Put("modelDesc", string.IsNullOrEmpty(model.Desc) ? model.Desc : model.ModelName);
            helper.Put("model", model);

            We7DataColumnCollection dcs = null;

            if (model.Layout.UCContrl.DetailFieldArray == null)
            {
                dcs = model.DataSet.Tables[0].Columns;
            }
            else
            {
                dcs = new We7DataColumnCollection();
                foreach (We7DataColumn dc in model.DataSet.Tables[0].Columns)
                {
                    if (Array.Exists(model.Layout.UCContrl.DetailFieldArray, s => s == dc.Name))
                    {
                        dcs.Add(dc);
                    }
                }
            }

            helper.Put("columns", dcs);

            helper.Put("CurrentDate", DateTime.Now.ToString());
            if (ModelConfig.IsCreateArticleUC)
            {
                helper.Save("ArticleList.vm", path);
            }
            helper.Save("DbModelList.vm", CreateNewFilePath(path, "DB"));
        }
Ejemplo n.º 2
0
        public static void SendNotificationEmail(List <DigitalCampaignSegmentItem> segmentItems, bool isPodEmail)
        {
            string subject       = string.Format("{0}Digital Campaign Launch Report", (IsInTestEnvironment() ? string.Format("DISREGARD - EMAIL ORIGINATED FROM TEST SYSTEM FOR {0} - ", (isPodEmail ? "SALES POD":"PHOTOGRAPHERS")) : ""));
            var    emailTemplate = isPodEmail ? GetPodEmailText() : GetPhotographerEmailText();
            var    emailBody     = new NVelocityHelper()
                                   .Add("model", segmentItems)
                                   .Merge(emailTemplate);

            Message notificationEmail = new Message(SmtpAddress);

            if (IsInTestEnvironment())
            {
                notificationEmail.AddRecipients(TestEmailAddress.Split(','));
            }
            else
            {
                if (isPodEmail)
                {
                    notificationEmail.AddRecipient(segmentItems[0].AccountExecutiveEmail);
                    if (!string.IsNullOrEmpty(segmentItems[0].PodEmails))
                    {
                        notificationEmail.AddCCs(segmentItems[0].PodEmails.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
                    }
                }
                else
                {
                    notificationEmail.AddRecipients(segmentItems[0].PhotographerEmails.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
                }
                notificationEmail.AddBCCs(new string[] { "*****@*****.**", "*****@*****.**" });
            }
            notificationEmail.From    = "*****@*****.**";
            notificationEmail.Subject = subject;
            notificationEmail.Body    = emailBody;
            notificationEmail.SendEmail();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 生成文章类型前台控件
        /// </summary>
        /// <param name="model"></param>
        static void CreateArticlePagedListWidget(ModelInfo model)
        {
            NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath);
            string          path   = CreateWidgetDirectory(model, "PagedList");

            helper.Put("modelDesc", string.IsNullOrEmpty(model.Desc) ? model.Desc : model.ModelName);
            helper.Put("model", model);

            We7DataColumnCollection dcs = null;

            if (model.Layout.UCContrl.WidgetListFields == null)
            {
                dcs = model.DataSet.Tables[0].Columns;
            }
            else
            {
                dcs = new We7DataColumnCollection();
                foreach (We7DataColumn dc in model.DataSet.Tables[0].Columns)
                {
                    if (Array.Exists(model.Layout.UCContrl.WidgetListFieldArray, s => s == dc.Name))
                    {
                        dcs.Add(dc);
                    }
                }
            }

            helper.Put("columns", dcs);

            helper.Put("CurrentDate", DateTime.Now.ToString());


            string[] tpls = GetWidgetModelPagedListTemplate();
            CreateWidgets(helper, path, tpls);
        }
Ejemplo n.º 4
0
        protected void btnGenerateFile_Click(object sender, EventArgs e)
        {
            string tempalte = "Templates/template.htm";//相对目录

            TestInfo info = new TestInfo();

            info.Title    = "测试标题";
            info.Content  = "测试内容,这是测试内容";
            info.Datetime = DateTime.Now;

            NVelocityHelper adapter = new NVelocityHelper(tempalte);

            adapter.AddKeyValue("title", "This is a title")
            .AddKeyValue("content", "This is a Content")
            .AddKeyValue("datetime", System.DateTime.Now)
            .AddKeyValue("TestInfo", info);

            adapter.FileNameOfOutput = "testTemplate";
            string filePath = adapter.ExecuteFile();

            if (!string.IsNullOrEmpty(filePath))
            {
                this.txtCode.InnerHtml = FileUtil.FileToString(filePath, System.Text.Encoding.UTF8);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 生成模型布局
        /// </summary>
        /// <param name="model"></param>
        /// <returns>布局存放路径</returns>
        public static string CreateModelLayout(ModelInfo model)
        {
            NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath);
            //string path = CreateDirectory(model, "Edit", "ArticleModelEditDataControl", "录入");
            //string path2 = CreateModelDirectory(model, "Edit", "ArticleModelEditDataControl", "录入");

            string   path = GetModelLayoutDirectory(model.ModelName) + "GenerateLayout.ascx";
            FileInfo fi   = new FileInfo(path);

            if (!fi.Directory.Exists)
            {
                fi.Directory.Create();
            }

            helper.Put("model", model);
            helper.Put("controls", model.Layout.Panels["edit"].EditInfo.Controls);
            helper.Put("CurrentDate", DateTime.Now.ToString());

            helper.Save("ArticleEditor.vm", path);

            path = String.Format("{0}/{1}/{2}/{3}", ModelConfig.ModelsDirectory, model.GroupName, model.Name, "GenerateLayout.ascx");
            return(path);

            //helper.Save("ArticleEditor.vm", path);
            //helper.Save("ArticleEditor.vm", path2);
        }
Ejemplo n.º 6
0
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            if (Design)
            {
                //可视化设计时
                StringWriter   output = new StringWriter();
                HtmlTextWriter tw     = new HtmlTextWriter(output);
                base.Render(tw);
                string ControlHtml = output.ToString();
                //格式化代码
                string formatControlHtml = FormatHtml(ControlHtml);

                NVelocityHelper helper = new NVelocityHelper(We7.CMS.Constants.VisualTemplatePhysicalTemplateDirectory);

                helper.Put("controlId", this.ID);
                helper.Put("controlContent", formatControlHtml);

                var rendHtml = helper.Save("We7LayoutDesign.vm");
                //格式化
                rendHtml = FormatHtml(rendHtml);
                //输出代码
                writer.Write(rendHtml);
            }
            else
            {
                base.Render(writer);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 获取CS文件
        /// </summary>
        /// <param name="parentName"></param>
        /// <param name="subName"></param>
        /// <param name="template"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        private string GetCSFile(string parentName, string subName, string template, string entity = "Entity")
        {
            var csFile = string.Empty;

            try
            {
                List <DBStructure> infos = DBInfo.DBInfoList.Where(w => w.DBName == parentName).Select(s => s.TableStruList).FirstOrDefault();
                var info = infos.Where(w => w.TableName == subName).FirstOrDefault() ?? null;
                if (info == null)
                {
                    return(csFile);
                }
                Dictionary <string, object> dicInfo = new Dictionary <string, object>();
                dicInfo.Add("Entity", info);
                dicInfo.Add("ClassLibrary", ABContent.SelectedProject.ProjectName);
                dicInfo.Add("FolderName", cbx_Folder.Text);
                var result = NVelocityHelper.ProcessTemplate(template, dicInfo);
                //string result = Engine.Razor.RunCompile(template, "template6111", null, dbs); razor 略卡
                csFile = FilesHelper.Write(Path.Combine(ABContent.SelectedProject.ProjectDirectoryName, cbx_Folder.Text), subName + "Entity.cs", result);
            }
            catch (Exception ex)
            {
                OutputWindowHelper.OutPutMessage($"获取CS文件出现异常 \n 信息:{ex.Message} \n 堆栈:{ex.StackTrace}");
            }
            return(csFile);
        }
Ejemplo n.º 8
0
        public void GenCode(TableInfo tableInfo)
        {
            NVelocityHelper nVelocityHelper = new NVelocityHelper(FilePathHelper.TemplatesPath);
            string          tableName       = tableInfo.TableName;

            string path = string.Format(@"{0}", TemplateParas.TemplateName);
            var    dic  = GetNVelocityVars();

            dic.Add("tableInfo", tableInfo);

            string str = nVelocityHelper.GenByTemplate(path, dic);


            string title = tableName + "." + (TemplateParas.CodeLanguage + "").ToLower();

            if (!string.IsNullOrEmpty(TemplateParas.SaveFileName))
            {
                title = TemplateParas.SaveFileName;
                title = nVelocityHelper.GenByStr(title, dic);
            }
            if (TemplateParas.IsShowGenCode)
            {
                CodeShow(title, str);
            }
            else
            {
                FileHelper.Write(TemplateParas.SaveFilePath + title, new[] { str }, SaveFileEncoding);
            }
        }
Ejemplo n.º 9
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (Design)
            {
                //可视化设计时
                StringWriter   output = new StringWriter();
                HtmlTextWriter tw     = new HtmlTextWriter(output);
                base.Render(tw);
                string ControlHtml = output.ToString();
                //格式化代码
                string formatControlHtml = FormatHtml(ControlHtml);

                NVelocityHelper helper = new NVelocityHelper(We7.CMS.Constants.VisualTemplatePhysicalTemplateDirectory);

                helper.Put("controlId", this.ID);
                helper.Put("controlContent", formatControlHtml);
                helper.Put("controlData", BuildData());
                var rendHtml = helper.Save("We7LayoutDesign.vm");
                //格式化
                rendHtml = FormatHtml(rendHtml);
                //输出代码
                writer.Write(rendHtml);
            }
            else
            {
                writer.Write("<div id=\"" + this.ID + "\" class=\"sf_cols\">");
                base.Render(writer);
                //writer.Write("<div style= \"clear:both; height:0;\"></div>");
                writer.Write("<div style= \"clear:both;height:0;font-size:1px;\"></div>");
                writer.Write("</div>");
            }
        }
Ejemplo n.º 10
0
        public JsonResult ToExamine(int ToExamineStatues, string Reason, int EntryId)
        {
            OperationResult      oper = new OperationResult(OperationResultType.Error);
            ResignationToExamine ete  = new ResignationToExamine();

            ete.AdminId       = AuthorityHelper.OperatorId.Value;
            ete.Reason        = Reason;
            ete.ResignationId = EntryId;
            ete.AuditStatus   = ToExamineStatues;
            ete.AuditTime     = DateTime.Now;
            ete.OperatorId    = AuthorityHelper.OperatorId;
            oper = _resignationToExamineContract.Insert(ete);
            if (oper.ResultType == OperationResultType.Success)
            {
                oper = _resignationContract.ToExamine(ToExamineStatues, EntryId);
                if (oper.ResultType == OperationResultType.Success)
                {
                    var dtoM           = _resignationContract.Resignations.Where(x => x.Id == EntryId).FirstOrDefault();
                    int NotificationId = _templateNotificationContract.templateNotifications.Where(x => x.Name == "离职审核未通过").Select(x => x.Id).FirstOrDefault();
                    var orgContent     = _templateContract.Templates.Where(x => !x.IsDeleted && x.IsEnabled && x.TemplateNotificationId == NotificationId)
                                         .Select(x => x.TemplateHtml).FirstOrDefault();
                    var title = _templateContract.Templates.Where(x => !x.IsDeleted && x.IsEnabled && x.TemplateNotificationId == NotificationId)
                                .Select(x => x.TemplateName).FirstOrDefault();
                    List <int> AuthorityList   = new List <int>();
                    var        receiveAdminIds = 0;
                    if (ToExamineStatues == -3)
                    {
                        receiveAdminIds = _resignationToExamineContract.EntryToExamines.Where(x => x.ResignationId == EntryId && x.AuditStatus == 2)
                                          .OrderByDescending(x => x.CreatedTime).Select(x => x.AdminId).FirstOrDefault();
                    }
                    else if (ToExamineStatues == -2 || ToExamineStatues == -5)
                    {
                        receiveAdminIds = _resignationToExamineContract.EntryToExamines.Where(x => x.ResignationId == EntryId && x.AuditStatus == 1)
                                          .OrderByDescending(x => x.CreatedTime).Select(x => x.AdminId).FirstOrDefault();
                    }
                    else if (ToExamineStatues == -1 || ToExamineStatues == -6)
                    {
                        receiveAdminIds = _resignationContract.Resignations.Where(x => x.Id == EntryId).Select(x => x.operationId ?? (AuthorityHelper.OperatorId ?? 0)).FirstOrDefault();
                    }
                    var dicPC = new Dictionary <string, object>();
                    dicPC.Add("entryName", dtoM.ResignationModel?.Member?.RealName ?? string.Empty);
                    dicPC.Add("entryDep", dtoM.Department?.DepartmentName ?? string.Empty);
                    dicPC.Add("ToExamine", AuthorityHelper.RealName);
                    var        content = NVelocityHelper.Generate(orgContent, dicPC, "Entry_PC");
                    List <int> lAdmin  = new List <int>();
                    lAdmin.Add(receiveAdminIds);
                    _notificationContract.Insert(sendNotificationAction, new NotificationDto()
                    {
                        Title            = title,
                        AdministratorIds = lAdmin,
                        Description      = content,
                        IsEnableApp      = true,
                        NoticeTargetType = (int)NoticeTargetFlag.Admin,
                        NoticeType       = (int)NoticeFlag.Immediate
                    });
                }
            }
            return(Json(oper));
        }
Ejemplo n.º 11
0
        private string createCommentSql()
        {
            NVelocityHelper             nVelocityHelper = new NVelocityHelper(FilePathHelper.TemplatesPath);
            Dictionary <string, object> dic             = new Dictionary <string, object>();

            dic.Add("tableInfo", tableInfo);
            dic.Add("codeGenHelper", new CodeGenHelper());
            return(nVelocityHelper.GenByTemplate("comment.sql.vm", dic));
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 创建部件
 /// </summary>
 /// <param name="helper"></param>
 /// <param name="refFilePath"></param>
 /// <param name="tpls"></param>
 static void CreateWidgets(NVelocityHelper helper, string refFilePath, string[] tpls)
 {
     foreach (string tpl in tpls)
     {
         string   file = Path.GetFileName(tpl);
         string[] ss   = file.Split('.');
         string   ext  = ss.Length > 2 ? ss[1] : "Default";
         helper.Save(file, CreateNewWidgetPath(refFilePath, ext));
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 初始化
        /// </summary>
        void BlogInit(string action)
        {
            if (action == "feed")
            {
                templatePath = HttpContext.Current.Server.MapPath(ConfigHelper.SitePath + "common/config/");
            }
            else
            {
                templatePath = HttpContext.Current.Server.MapPath(string.Format("{0}/themes/default/template/", ConfigHelper.SitePath));
            }
            if (BlogConfig.GetSetting().SiteStatus == 0)
            {
                ResponseError("网站已关闭", "网站已关闭,请与站长联系!");
            }

            pageindex = Framework.Web.PressRequest.GetQueryInt("page", 1);
            slug      = Framework.Web.PressRequest.GetQueryString("slug");

            UpdateViewCount();//更新访问量
            //主题处理
            _themeName = BlogConfig.GetSetting().Theme;
            string previewThemeName = Jqpress.Framework.Web.PressRequest.GetQueryString("theme", true);

            //if (Jqpress.Framework.Web.PressRequest.IsMobile)
            //{
            //    _themeName = BlogConfig.GetSetting().MobileTheme;
            //}
            if (!string.IsNullOrEmpty(previewThemeName))
            {
                _themeName = previewThemeName;
            }
            //非预览时
            if (!System.IO.Directory.Exists(templatePath) && string.IsNullOrEmpty(previewThemeName))
            {
                BlogConfigInfo s = BlogConfig.GetSetting();
                if (Jqpress.Framework.Web.PressRequest.IsMobile)
                {
                    s.MobileTheme = "default";
                }
                else
                {
                    s.Theme = "default";
                }
                _themeName = "default";

                // BlogConfig.UpdateSetting();

                templatePath = Server.MapPath(string.Format("{0}/themes/{1}/template/", ConfigHelper.SitePath, _themeName));
            }
            if (action != "feed")
            {
                templatePath = Server.MapPath(string.Format("{0}/themes/{1}/template/", ConfigHelper.SitePath, _themeName));
            }
            th = new NVelocityHelper(templatePath);
        }
Ejemplo n.º 14
0
        //
        // GET: /Home/

        public ActionResult Index()
        {
            string configData = SysVisitor.Instance.CurrentUser.ConfigJson;

            string          themePath = Server.MapPath("~/Content/theme/navtype/");
            NVelocityHelper vel       = new NVelocityHelper(themePath);

            vel.Put("username", SysVisitor.Instance.CurrentUser.TrueName);
            string navHTML = "Accordion.html";

            if (!string.IsNullOrEmpty(configData))
            {
                ConfigModel sysconfig = JSONhelper.ConvertToObject <ConfigModel>(configData);
                if (sysconfig != null)
                {
                    switch (sysconfig.ShowType)
                    {
                    case "menubutton":
                        navHTML = "menubutton.html";
                        break;

                    case "tree":
                        navHTML = "tree.html";
                        break;

                    case "menuAccordion":
                    case "menuAccordion2":
                    case "menuAccordionTree":
                        navHTML = "topandleft.html";
                        break;

                    default:
                        navHTML = "Accordion.html";
                        break;
                    }
                }
            }

            ViewBag.NavContent = vel.FileToString(navHTML);

            //============APP用户总数================
            ViewBag.AppCount = 0;// DriverUserDal.Instance.GetAppCount();

            //============订单签收总数================
            ViewBag.SignCount = 0;// SignDal.Instance.GetCount("");


            //系统更新日志
            int pdateLogCount;

            ViewBag.UpdateLogList  = SYS_UPDATELOGBLL.Instance.GetPageWithRecordCount(1, 3, out pdateLogCount);
            ViewBag.UpdateLogCount = pdateLogCount;

            return(View());
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 生成反馈类型 前台控件
        /// </summary>
        /// <param name="model"></param>
        static void CreateAdviceQueryListControl(ModelInfo model)
        {
            NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath);
            string          path   = CreateDirectory(model, "QueryList", "AdviceQueryListDataControl", "查询列表");

            helper.Put("model", model);
            helper.Put("columns", model.DataSet.Tables[0].Columns);
            helper.Put("CurrentDate", DateTime.Now.ToString());

            helper.Save("AdviceQueryList.vm", path);
        }
Ejemplo n.º 16
0
        private static void CreateAdviceDetailsWidget(ModelInfo model)
        {
            NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath);
            string          path   = CreateWidgetDirectory(model, "View");

            helper.Put("model", model);
            helper.Put("columns", model.DataSet.Tables[0].Columns);
            helper.Put("CurrentDate", DateTime.Now.ToString());

            helper.Save("WidgetAdviceView.vm", path);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 确认提交事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SubmitEvent(object sender, RoutedEventArgs e)
        {
            var theSelectedProject = _autoBuildEntityContent.SelectedProject;

            try
            {
                //获取物理表名
                var addAndUpdateList = _hadAddCheckSelectList.Union(_noAddCheckSelectList).ToList();
                var removeFiles      = _noExistCheckSelectList.Select(a => a.ToCaseCamelName() + ".cs").ToList();

                //查询出表结构
                var dbTable  = new DbTable(_autoBuildEntityContent.EntityXml.ConnString);
                var dbtables = dbTable.GetTables(addAndUpdateList, _sqlType);

                //根据模版输出
                var templateModel =
                    dbtables.Select(
                        a =>
                        new TemplateModel(a.TableName, a.Columns,
                                          theSelectedProject.ProjectName)).ToList();

                var templateDic = templateModel.ToDictionary(a => a.ClassName,
                                                             item =>
                                                             NVelocityHelper.ProcessTemplate(_autoBuildEntityContent.EntityXml.EntityTemplate,
                                                                                             new Dictionary <string, object> {
                    { "entity", item }
                }));

                //保存文件
                foreach (var templateData in templateDic)
                {
                    var path = FilesHelper.WriteAndSave(theSelectedProject.ProjectDirectoryName,
                                                        templateData.Key, templateData.Value);

                    if (_noAddCheckSelectList.Select(a => a.ToCaseCamelName()).Contains(templateData.Key))
                    {
                        theSelectedProject.ProjectDte.ProjectItems.AddFromFile(path);
                    }
                }

                //添加项目项和排除项目项
                theSelectedProject.ProjectDte.RemoveFilesFromProject(removeFiles);

                Close();
            }
            catch (ArgumentException)
            {
                MessageBox.Show("您的选项在数据库里存在多个项目命名规范的表(视图)名");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 生成反馈类型 前台控件
        /// </summary>
        /// <param name="model"></param>
        static void CreateAdviceEditControl(ModelInfo model)
        {
            NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath);
            string          path   = CreateDirectory(model, "Edit", "AdviceModelEditDataControl", "录入");

            helper.Put("model", model);
            helper.Put("controls", model.Layout.Panels["edit"].EditInfo.Controls);
            helper.Put("CurrentDate", DateTime.Now.ToString());

            helper.Save("Advice.vm", path);
        }
Ejemplo n.º 19
0
        public ActionResult Update(ResignationDto dto)
        {
            dto.ToExamineResult = 0;
            dto.operationId     = AuthorityHelper.OperatorId;
            OperationResult oper = _resignationContract.Update(dto);

            if (oper.ResultType == OperationResultType.Success)
            {
                int NotificationId = _templateNotificationContract.templateNotifications.Where(x => x.Name == "离职通知").Select(x => x.Id).FirstOrDefault();
                var mod            = _templateContract.Templates.Where(x => !x.IsDeleted && x.IsEnabled && x.TemplateNotificationId == NotificationId).Select(s => new
                {
                    s.Id,
                    s.TemplateHtml,
                    s.TemplateName,
                    s.EnabledPerNotifi
                }).FirstOrDefault();

                List <int> AuthorityList = new List <int>()
                {
                    1, 4, 5, 7
                };
                var resign = _administratorContract.Administrators.Where(x => x.Id == dto.ResignationId).FirstOrDefault();
                var dicPC  = new Dictionary <string, object>();
                dicPC.Add("entryName", resign?.Member?.RealName ?? string.Empty);
                dicPC.Add("entryDep", resign?.Department?.DepartmentName ?? string.Empty);
                dicPC.Add("ToExamine", "");
                var content = NVelocityHelper.Generate(mod.TemplateHtml, dicPC, "Entry_PC");

                var dtoNoti = new NotificationDto()
                {
                    Title            = mod.TemplateName,
                    Description      = content,
                    IsEnableApp      = true,
                    NoticeType       = (int)NoticeFlag.Immediate,
                    NoticeTargetType = mod.EnabledPerNotifi ? (int)NoticeTargetFlag.Admin : (int)NoticeTargetFlag.Department
                };

                if (mod.EnabledPerNotifi)
                {
                    var receiveAdminIds = _administratorContract.Administrators.Where(x => x.IsEnabled && !x.IsDeleted &&
                                                                                      AuthorityList.Contains(x.JobPosition.Auditauthority.Value)).Select(s => s.Id).ToList();
                    dtoNoti.AdministratorIds = receiveAdminIds;
                }
                else
                {
                    var depids = _templateContract.GetNotificationDepartIds(mod.Id);
                    dtoNoti.DepartmentIds = depids;
                }

                _notificationContract.Insert(sendNotificationAction, dtoNoti);
            }
            return(Json(oper));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 显示模板
        /// </summary>
        /// <param name="templatFileName">模板文件名</param>
        public static void Display(NVelocityHelper th, string templateFile)
        {
            //全局
            th.Put("querycount", querycount);
            th.Put("processtime", DateTime.Now.Subtract(starttick).TotalMilliseconds / 1000);
            th.Put("sqlanalytical", SqlAnalytical);

            // HttpContext.Current.Response.Clear();
            //   HttpContext.Current.Response.Write(writer.ToString());
            HttpContext.Current.Response.Write(th.BuildString(templateFile));

            //  HttpContext.Current.Response.End();
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 导出Model类
        /// </summary>
        /// <param name="strDbName">数据库名称</param>
        /// <param name="table">数据库表</param>
        /// <param name="savePath">文件夹存储路径</param>
        public void ExportModel(string strDbName, List <Table> tables, string saveDirectoryPath)
        {
            nVelocity = new NVelocityHelper(AppDomain.CurrentDomain.BaseDirectory + "Template");
            nVelocity.TemplateFileName = "ModelTpl.cstpl";
            nVelocity.Put("ConnType", Config.ConnType.ToString());
            nVelocity.Put("DatabaseName", Config.DatabaseName);
            nVelocity.Put("this", this);

            ExportEventArgs args = new ExportEventArgs();

            args.IsFinished = false;
            args.Info       = "开始生成Model类……";
            if (null != OnExport)
            {
                this.OnExport(this, args);
            }

            if (!Directory.Exists(saveDirectoryPath + Config.DatabaseName))
            {
                Directory.CreateDirectory(saveDirectoryPath + Config.DatabaseName);
            }

            args.TotalNum = tables.Count;
            foreach (Table table in tables)
            {
                nVelocity.Remove("Table");
                nVelocity.Put("Table", table);
                nVelocity.Remove("Columns");
                nVelocity.Put("Columns", table.Columns);
                int i = 0;
                nVelocity.Put("i", i);
                File.WriteAllText(Path.Combine(saveDirectoryPath, Config.DatabaseName + "/" + table.Name + ".cs"), nVelocity.Content, encoding);

                ++args.NowIndex;
                if (null != OnExport)
                {
                    this.OnExport(this, args);
                }
            }

            args.IsFinished = true;
            args.Info       = "Model类生成完成";
            if (null != OnExport)
            {
                this.OnExport(this, args);
            }

            nVelocity.Dispose();
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 反馈前台录入(自动布局)
        /// </summary>
        /// <param name="model"></param>
        private static void CreateAdviceEditWidget(ModelInfo model)
        {
            //Criteria c = new Criteria(CriteriaType.Equals, "ModelName", model.ModelName);
            //List<AdviceType> adviceList = Assistant.List<AdviceType>(c, null);

            NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath);
            string          path   = CreateWidgetDirectory(model, "Edit");

            helper.Put("model", model);
            helper.Put("controls", model.Layout.Panels["edit"].EditInfo.Controls);
            helper.Put("CurrentDate", DateTime.Now.ToString());
            //helper.Put("adviceType", adviceList);

            helper.Save("WidgetAdvice.vm", path);
        }
Ejemplo n.º 23
0
        private string GetContent()
        {
            string content    = "";
            string configData = CurrentUser.ConfigJson;

            string          themePath = Server.MapPath("~/content/theme/navtype/");
            NVelocityHelper vel       = new NVelocityHelper(themePath);

            vel.Put("welcome", Lang.welcome);
            vel.Put("username", CurrentUser.UserTrueName);
            vel.Put("update_pwd", Lang.update_pwd);
            vel.Put("logout", Lang.logout);
            vel.Put("system_name", Lang.system_name);
            vel.Put("nav_menu", Lang.nav_menu);
            string navHTML = "Accordion.html";

            if (!string.IsNullOrEmpty(configData))
            {
                ConfigModel sysconfig = Newtonsoft.Json.JsonConvert.DeserializeObject <ConfigModel>(configData);
                if (sysconfig != null)
                {
                    switch (sysconfig.ShowType)
                    {
                    case "menubutton":
                        navHTML = "menubutton.html";
                        break;

                    case "tree":
                        navHTML = "tree.html";
                        break;

                    case "menuAccordion":
                    case "menuAccordion2":
                    case "menuAccordionTree":
                        navHTML = "topandleft.html";
                        break;

                    default:
                        navHTML = "Accordion.html";
                        break;
                    }
                }
            }

            content = vel.FileToString(navHTML);
            return(content);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 确认提交事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SubmitEvent(object sender, RoutedEventArgs e)
        {
            var theSelectedProject = _autoBuildEntityContent.SelectedProject;

            try
            {
                //获取物理表名
                var addAndUpdateList = _hadAddCheckSelectList.Union(_noAddCheckSelectList).ToList();
                var removeFiles      = _noExistCheckSelectList.Select(a => a + ".cs").ToList();

                //查询出表结构
                var dbTable  = new DbTable(_autoBuildEntityContent.EntityXml.ConnString);
                var dbtables = dbTable.GetTables(addAndUpdateList);

                //根据模版输出
                var templateModel =
                    dbtables.Select(
                        a =>
                        new TemplateModel(a.TableName, a.Columns,
                                          theSelectedProject.ProjectName)).ToList();

                var templateDic = templateModel.ToDictionary(a => a.TableName,
                                                             item =>
                                                             NVelocityHelper.ProcessTemplate(_autoBuildEntityContent.EntityXml.EntityTemplate,
                                                                                             new Dictionary <string, object> {
                    { "entity", item }
                }));

                //保存文件
                var addfiles =
                    templateDic.Select(
                        templateData =>
                        FilesHelper.Write(theSelectedProject.ProjectDirectoryName,
                                          templateData.Key, templateData.Value)).ToList();

                //添加项目项和排除项目项、
                theSelectedProject.ProjectDte.AddFilesToProject(addfiles);
                theSelectedProject.ProjectDte.RemoveFilesFromProject(removeFiles);

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 生成图标文件
        /// </summary>
        /// <param name="iconSize">图表尺寸,可选16,32等</param>
        /// <returns></returns>
        public ActionResult GenerateIconCSS(int iconSize = 16)
        {
            CommonResult result = new CommonResult();

            string realPath = Server.MapPath("~/Content/icons-customed/" + iconSize);

            if (Directory.Exists(realPath))
            {
                List <CListItem> list = GetImageToList(realPath, iconSize);

                try
                {
                    //使用相对路径进行构造处理
                    string          template = string.Format("Content/icons-customed/{0}/icon.css.vm", iconSize);
                    NVelocityHelper helper   = new NVelocityHelper(template);
                    helper.AddKeyValue("FileNameList", list);

                    helper.FileNameOfOutput  = "icon";
                    helper.FileExtension     = ".css";
                    helper.DirectoryOfOutput = realPath;//指定实际路径

                    string outputFilePath = helper.ExecuteFile();
                    if (!string.IsNullOrEmpty(outputFilePath))
                    {
                        result.Success = true;

                        //写入数据库
                        bool write = BLLFactory <Icon> .Instance.BatchAddIcon(list, iconSize);
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(IconController));
                    result.ErrorMessage = ex.Message;
                }
            }
            else
            {
                result.ErrorMessage = "没有找到图片文件";
            }

            return(ToJsonContent(result));
        }
        /// <summary>
        /// 生成静态页
        /// </summary>
        /// <param name="articelInfo"></param>
        /// <param name="flag"></param>
        public void CreateHtmlPage(Articel articelInfo, string flag)
        {
            string html = NVelocityHelper.RenderTemplate("ArticelTemplateInfo", articelInfo, "/ArticelTemplate/");
            string dir  = "/ArticelHtml/" + articelInfo.AddDate.Year + "/" + articelInfo.AddDate.Month + "/" + articelInfo.AddDate.Day + "/";

            if (flag == "add")
            {
                //dir = "/ArticelHtml/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/";
                Directory.CreateDirectory(Path.GetDirectoryName(Request.MapPath(dir)));
            }
            //else
            //{
            //    dir = "/ArticelHtml/" + articelInfo.AddDate.Year + "/" + articelInfo.AddDate.Month + "/" + articelInfo.AddDate.Day + "/";
            //}

            string fullDir = dir + articelInfo.ID + ".html";

            System.IO.File.WriteAllText(Request.MapPath(fullDir), html, System.Text.Encoding.UTF8);
        }
Ejemplo n.º 27
0
        protected void btnGenerateString_Click(object sender, EventArgs e)
        {
            string tempalte = "Templates/template.htm";//相对目录

            TestInfo info = new TestInfo();

            info.Title    = "测试标题";
            info.Content  = "测试内容,这是测试内容";
            info.Datetime = DateTime.Now;

            NVelocityHelper adapter = new NVelocityHelper(tempalte);

            adapter.AddKeyValue("title", "This is a title")
            .AddKeyValue("content", "This is a Content")
            .AddKeyValue("datetime", System.DateTime.Now)
            .AddKeyValue("TestInfo", info);

            this.txtCode.InnerHtml = adapter.ExecuteString();
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 导出数据字典
        /// </summary>
        /// <param name="strDbName">数据库名称</param>
        /// <param name="table">数据库表</param>
        /// <param name="savePath">文件存储路径</param>
        public void ExportDbDic(string strDbName, List <Table> tables, string saveFilePath)
        {
            nVelocity = new NVelocityHelper(AppDomain.CurrentDomain.BaseDirectory + "Template");
            nVelocity.TemplateFileName = "DbDicTpl.html";
            nVelocity.Put("ConnType", Config.ConnType.ToString());
            nVelocity.Put("DatabaseName", Config.DatabaseName);
            nVelocity.Put("this", this);

            int i = 1;

            nVelocity.Put("i", i);

            int j = 0;

            nVelocity.Put("j", j);

            ExportEventArgs args = new ExportEventArgs();

            args.IsFinished = false;
            args.Info       = "开始生成数据字典……";
            if (null != OnExport)
            {
                this.OnExport(this, args);
            }

            args.TotalNum = tables.Count;
            args.NowIndex = 1;

            nVelocity.Remove("Tables");
            nVelocity.Put("Tables", tables);
            File.WriteAllText(saveFilePath, nVelocity.Content, encoding);

            args.IsFinished = true;
            args.NowIndex   = args.TotalNum;
            args.Info       = "数据字典生成完成";
            if (null != OnExport)
            {
                this.OnExport(this, args);
            }

            nVelocity.Dispose();
        }
Ejemplo n.º 29
0
        /*
         * /// <summary>
         * /// 解析外键列类型
         * /// </summary>
         * private IEnumerator ParseForeignKeyColumnType()
         * {
         *  foreach (var tableInfo in m_configDataTableInfoDic.Values)
         *  {
         *      foreach (var columnInfo in tableInfo.ColumnInfoList)
         *      {
         *          //遍历所有列定义,如果列名使用“."分割,说明是外键数据类型
         *          string typeStr = columnInfo.TypeStr;
         *          if (typeStr.IndexOf(".") != -1)
         *          {
         *              string[] tuple = typeStr.Split(new char[] { '.' });
         *              if (tuple.Length != 2)
         *              {
         *                  throw new Exception(string.Format("the column {0} at table {1} is a foreign key, but typeStr is not a tuple", columnInfo.ColumnName, tableInfo.TableName));
         *              }
         *              string foreignTableName = tuple[0];
         *              string foreignColumnName = tuple[1];
         *              if (!m_configDataTableInfoDic.ContainsKey(foreignTableName))
         *              {
         *                  throw new Exception(string.Format("can't find the foreign table {0} for the column {1} at table {2} ", foreignTableName, columnInfo.ColumnName, tableInfo.TableName));
         *              }
         *              var foreignTabelInfo = m_configDataTableInfoDic[foreignTableName];
         *              var foreignColumnInfo = foreignTabelInfo.GetColumnInfoByName(foreignColumnName);
         *              if (foreignColumnInfo == null)
         *              {
         *                  throw new Exception(string.Format("can't find the foreign column {0} for the column {1} at table {2}", foreignColumnName, columnInfo.ColumnName, tableInfo.TableName));
         *              }
         *              //设置正确的typeStr
         *              //columnInfo.RealTypeStr = foreignColumnInfo.TypeStr;
         *          }
         *      }
         *      yield return null;
         *  }
         * }
         */

        /// <summary>
        /// 产生ConfigDataLoaderAutoGen.cs
        /// </summary>
        private void GenerateConfigDataLoaderAutoGenFile()
        {
            string outputFolder = PathHelper.GetFullPath(m_setting.m_autoGenCodeOutputPath);

            if (Directory.Exists(outputFolder))
            {
                Directory.Delete(outputFolder, true);
            }
            Directory.CreateDirectory(outputFolder);

            var allConfigDataInfos = new List <ConfigDataTableInfo>(m_configDataTableInfoDic.Values);

            //产生ConfigDataLoaderAutoGen.cs,运行时读取功能
            {
                string template = File.ReadAllText(PathHelper.GetFullPath(m_setting.m_codeTempletePath) + "/ConfigDataLoaderAutoGen.cs.txt");
                string result   = NVelocityHelper.Parse(template, "AllConfigDataInfos", allConfigDataInfos);
                File.WriteAllText(outputFolder + "/ConfigDataLoaderAutoGen.cs", result);
            }
            AssetDatabase.Refresh();
        }
Ejemplo n.º 30
0
        public OperationResult CodeGeneration(GenerationViewModel gen)
        {
            var projectDirectory = GetSolutionDir();//ConfigurationManager.AppSettings["ProjectDirectory"];
            var hash             = new Dictionary <string, object>();
            var properties       = Type.GetType("App.Core.Domain." + gen.model.ModelName + ",App.Core").GetProperties();

            hash.Add("dtoFields", properties);
            hash.Add("properties", properties);
            hash.Add("model", gen.model);

            var nvelocity = NVelocityHelper.GetInstance().GetTemplate(gen.option, "/admin/GenerationTemplates/", hash);

            var outputPath = string.Format(projectDirectory + gen.outputPath, gen.model.ModelGroup, gen.model.ModelName);

            FileOperate.WriteFile(outputPath, nvelocity.ToString());

            return(new OperationResult {
                success = true, message = "位置:" + outputPath
            });
        }