Esempio n. 1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";

            VelocityHelper vh = new VelocityHelper();

            vh.Init("~/template/front");    //模板路径

            #region 获取head.html中菜单项
            vh.Put("menu", this.Menu);
            vh.Put("submenu", this.SubMenu);
            vh.Put("parentmenu", this.ParentMenu);
            #endregion

            #region 工程中心简介
            string ec_title;
            string ec_content;
            string ec_date;
            Front_DataHandlerBLL.GetIntroBLL(out ec_title, out ec_content, out ec_date);

            vh.Put("ec_content", ec_content);
            #endregion

            #region 科研成果
            vh.Put("productlist", Front_DataHandlerBLL.GetIndexProductListBLL());
            #endregion

            vh.Display("index.html");
        }
Esempio n. 2
0
File: Map.cs Progetto: Mixi59/Cookie
        public bool MoveToCell(int cellid, bool changemap = false)
        {
            var pathFinder = new Pathfinder();

            pathFinder.SetMap(_client.Account.Character.MapData, true);
            var timePath =
                pathFinder.GetPath((short)_client.Account.Character.CellId, (short)cellid);
            var path = pathFinder.GetCompressedPath(timePath);

            if (path == null || timePath == null)
            {
                return(false);
            }

            _time = VelocityHelper.GetPathVelocity(timePath,
                                                   path.Length < 4 ? MovementTypeEnum.Walking : MovementTypeEnum.Running);

            if (path[path.Length - 1] == _client.Account.Character.CellId)
            {
                _moving = false;
                _client.Account.Character.Status = CharacterStatus.None;
                ConfirmMove(changemap);
                return(true);
            }

            var msg = new GameMapMovementRequestMessage(path.ToList(), _client.Account.Character.MapId);

            _client.Send(msg);
            ConfirmMove(changemap);
            _client.Account.Character.Status = CharacterStatus.Moving;
            _moving = true;
            return(true);
        }
Esempio n. 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";

            VelocityHelper vh = new VelocityHelper();
            vh.Init("~/template/front");    //模板路径

            #region 获取head.html中菜单项
            vh.Put("menu", this.Menu);
            vh.Put("submenu", this.SubMenu);
            vh.Put("parentmenu", this.ParentMenu);
            #endregion

            #region 工程中心简介
            string ec_title;
            string ec_content;
            string ec_date;
            Front_DataHandlerBLL.GetIntroBLL(out ec_title, out ec_content, out ec_date);

            vh.Put("ec_content",ec_content);
            #endregion

            #region 科研成果
            vh.Put("productlist", Front_DataHandlerBLL.GetIndexProductListBLL());
            #endregion

            vh.Display("index.html");
        }
        public override void Execute(RequestContext context)
        {
            var velocity = new VelocityHelper(string.Format("~/Views/{0}/", context.RouteData["controller"].ToString()));

            // 绑定实体model
            velocity.Put("model", this.model);
            // 显示具体html
            velocity.Display(string.Format("{0}.html", context.RouteData["action"].ToString()));
            // 设置响应头类型
            context.HttpContext.Response.ContentType = "text/html";
        }
Esempio n. 5
0
        public override void ExecuteResult(RouteData routeData)
        {
            //var filepath = AppDomain.CurrentDomain.BaseDirectory + @"Views\" + routeData.RouteValue["controller"];
            //这里必须是虚拟路径
            var velocity = new VelocityHelper(string.Format("~/Views/{0}/", routeData.RouteValue["controller"]));

            // 绑定实体model
            velocity.Put("model", Data);
            // 显示具体html
            HttpResponse response = HttpContext.Current.Response;

            response.ContentType = "text/html";
            velocity.Display(string.Format("{0}.cshtml", routeData.RouteValue["action"].ToString()));
        }
Esempio n. 6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            VelocityHelper vh = new VelocityHelper();
            vh.Init("~/template/front");    //模板路径

            #region 科研成果列表
            vh.Put("pl",Front_DataHandlerBLL.GetIndexProductListBLL());
            #endregion

            #region 获取head.html中菜单项
            vh.Put("menu", this.Menu);
            vh.Put("submenu", this.SubMenu);
            vh.Put("parentmenu", this.ParentMenu);

            #endregion

            vh.Display("products.html");
        }
Esempio n. 7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            VelocityHelper vh = new VelocityHelper();

            vh.Init("~/template/front");
            int pid = 0;

            try
            {
                pid = Convert.ToInt32(context.Request["id"].ToString());
            }
            catch (Exception)
            {
            }
            string ptitle;
            string pinfo;
            string pdes;
            string pimage;
            string psort;

            Front_DataHandlerBLL.GetProductInfoBLL(pid, out ptitle, out pinfo, out pdes, out pimage, out psort);

            vh.Put("title", ptitle);
            vh.Put("info", pinfo);
            vh.Put("des", pdes);
            vh.Put("image", pimage);
            vh.Put("sort", psort);

            #region 获取head.html中菜单项

            vh.Put("menu", this.Menu);
            vh.Put("submenu", this.SubMenu);
            vh.Put("parentmenu", this.ParentMenu);

            #endregion



            vh.Display("product_detail.html");
        }
Esempio n. 8
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            string         template      = context.Server.MapPath("/Template");
            string         imageDataPath = context.Server.MapPath("~/imagedata.txt");
            VelocityHelper helper        = new VelocityHelper(template);

            if (context.Session["password"] != null)
            {
                if (context.Session["password"].ToString() == ConfigHelper.Password)
                {
                    List <FBImageInfo> ls = FBCommon.LoadFBImage(imageDataPath);
                    helper.PutSet("imagelist", ls);
                    helper.Display("imageview.html");
                }
            }
            else
            {
                helper.Display("password.html");
            }
        }
Esempio n. 9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            VelocityHelper vh = new VelocityHelper();

            vh.Init("~/template/front");    //模板路径

            #region 科研成果列表
            vh.Put("pl", Front_DataHandlerBLL.GetIndexProductListBLL());
            #endregion

            #region 获取head.html中菜单项
            vh.Put("menu", this.Menu);
            vh.Put("submenu", this.SubMenu);
            vh.Put("parentmenu", this.ParentMenu);

            #endregion


            vh.Display("products.html");
        }
Esempio n. 10
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            VelocityHelper vh = new VelocityHelper();
            vh.Init("~/template/front");
            int pid=0;
            try
            {
                pid = Convert.ToInt32(context.Request["id"].ToString());
            }
            catch (Exception)
            {
            }
            string ptitle;
            string pinfo;
            string pdes;
            string pimage;
            string psort;
            Front_DataHandlerBLL.GetProductInfoBLL(pid, out ptitle, out pinfo, out pdes, out pimage, out psort);

            vh.Put("title", ptitle);
            vh.Put("info", pinfo);
            vh.Put("des", pdes);
            vh.Put("image", pimage);
            vh.Put("sort", psort);

            #region 获取head.html中菜单项

            vh.Put("menu", this.Menu);
            vh.Put("submenu", this.SubMenu);
            vh.Put("parentmenu", this.ParentMenu);

            #endregion

            vh.Display("product_detail.html");
        }
Esempio n. 11
0
		public static string GetTableStructCode(Config config, string tableName, string projectName, out string factoryCode, out string sqlCode, bool isView) {
			string title = string.Empty;
			list = GetTableStructure(tableName, out title);

			VelocityHelper entity = new VelocityHelper("\\templates\\{0}\\".FormatWith(config.TemplateName));
			entity.Put("Project", projectName);
			entity.Put("ProjectStartDate", config.ProjectStartDate);
			entity.Put("CopyRight", config.CopyRight);
			entity.Put("TableName", tableName);
			entity.Put("TableNameCN", title);
			entity.Put("Now", DateTime.Now.ToString("yyyy-MM-dd"));
			entity.Put("Fields", list);
			entity.Put("helper", new helper());
			string code = entity.Display("entity.tmp");

			factoryCode = string.Empty; sqlCode = string.Empty;
			var pkInfo = list.Where(p => p.IsPK && p.IsIdentity).FirstOrDefault();
			var currTableOP = config.OPList.Where(p => p.Table == tableName).FirstOrDefault();
			if (!currTableOP.Insert && !currTableOP.Update && !currTableOP.DeleteByID && !currTableOP.SelectByID && !currTableOP.IsExistByID && !currTableOP.SelectListByAll && !currTableOP.SelectListByFK && !currTableOP.SelectPageList && !currTableOP.UpdateAndInsert) return code;
			VelocityHelper factory = new VelocityHelper("\\templates\\{0}\\".FormatWith(config.TemplateName));
			factory.Put("Project", projectName);
			factory.Put("ProjectStartDate", config.ProjectStartDate);
			factory.Put("CacheTime", config.CacheTime);
			factory.Put("DesignPatternExtName", config.DesignPatternExtName);
			factory.Put("CopyRight", config.CopyRight);
			factory.Put("TableName", tableName);
			factory.Put("TableNameCN", title);
			factory.Put("Now", DateTime.Now.ToString("yyyy-MM-dd"));
			factory.Put("Fields", list);
			factory.Put("NoPKFields", list.Where(p => !p.IsPK).ToList());
			factory.Put("PKFields", list.Where(p => p.IsPK).ToList());
			factory.Put("FKFields", list.Where(p => p.IsFK).ToList());
			factory.Put("helper", new helper());
			factory.Put("currTableOP", currTableOP);
			factory.Put("PKInfo", pkInfo);
			factory.Put("isView", isView);
			factoryCode = factory.Display("helper.tmp");
			//MessageBox.Show(list.Where(p => p.IsPK && p.IsIdentity).Count().ToString());

			string dbfile = "".GetMapPath() + "\\templates\\{0}\\db.tmp".FormatWith(config.TemplateName);
			if (FileDirectory.FileExists(dbfile)) {
				VelocityHelper db = new VelocityHelper("\\templates\\{0}\\".FormatWith(config.TemplateName));
				db.Put("Project", projectName);
				db.Put("ProjectStartDate", config.ProjectStartDate);
				db.Put("CacheTime", config.CacheTime);
				db.Put("DesignPatternExtName", config.DesignPatternExtName);
				db.Put("CopyRight", config.CopyRight);
				db.Put("TableName", tableName);
				db.Put("TableNameCN", title);
				db.Put("Now", DateTime.Now.ToString("yyyy-MM-dd"));
				db.Put("Fields", list);
				db.Put("NoPKFields", list.Where(p => !p.IsPK).ToList());
				db.Put("PKFields", list.Where(p => p.IsPK).ToList());
				db.Put("FKFields", list.Where(p => p.IsFK).ToList());
				db.Put("helper", new helper());
				db.Put("currTableOP", currTableOP);
				db.Put("PKInfo", pkInfo);
				db.Put("isView", isView);
				sqlCode = factory.Display("db.tmp");
			}

			if (!string.IsNullOrEmpty(config.AdminPath)) {
				//AdminCode(tableName, tableName.LowerFirstChar2(), projectName, pkInfo.IsNull() || pkInfo.ColumnName.IsNullEmpty() ? false : true, isView, pkInfo.IsNull() || pkInfo.ColumnName.IsNullEmpty() ? string.Empty : pkInfo.ColumnType);

				StringBuilder dbCode = new StringBuilder();
				bool isOnePage = false; int addTotalCount = 0; int pks = 0; int idspks = 0; bool max200 = false; int max200Count = 0;
				string csCode = string.Empty; string aspxCode = string.Empty, entityName = tableName.LowerFirstChar2();
				string folder = (tableName.IndexOf("_") >= 0 ? tableName.Substring(0, tableName.IndexOf("_")) : tableName).ToLower();
				string aspxPath = config.AdminPath + "\\admin\\" + folder + "\\";

				foreach (TableStructureEntity entity2 in list) {
					if (entity2.IsPK) { pks++; };
					if (!max200 && (entity2.Length > 200 || entity2.DBType == "ntext" || entity2.DBType == "text" || entity2.Length <= 0)) max200 = true;
					if (entity2.IsPK && entity2.IsIdentity) { idspks++; };
					if (!entity2.IsIdentity && entity2.IsPK) addTotalCount++;
					if (!entity2.IsIdentity && !entity2.IsPK) addTotalCount++;
					if (entity2.Length > 200 || entity2.DBType == "ntext" || entity2.DBType == "text" || entity2.Length <= 0) max200Count++;
				}
				if (addTotalCount < 6 && !max200) isOnePage = true;
				if (pks > 1) isOnePage = true;
				int height = addTotalCount < 10 ? addTotalCount * 31 + 65 + (110 * max200Count) : ((addTotalCount / 2) + (addTotalCount % 2)) * 31 + 65;

				VelocityHelper manage = new VelocityHelper("\\templates\\{0}\\".FormatWith(config.TemplateName));
				manage.Put("Project", projectName);
				manage.Put("ProjectStartDate", config.ProjectStartDate);
				manage.Put("CopyRight", config.CopyRight);
				manage.Put("TableName", tableName);
				manage.Put("TableNameCN", title);
				manage.Put("Fields", list);
				manage.Put("NoPKFields", list.Where(p => !p.IsPK).ToList());
				manage.Put("PKFields", list.Where(p => p.IsPK).ToList());
				manage.Put("FKFields", list.Where(p => p.IsFK).ToList());
				manage.Put("helper", new helper());
				manage.Put("PKInfo", pkInfo);
				manage.Put("isOnePage", isOnePage);
				manage.Put("PagerSqlEnum", config.PagerSqlEnum);
				manage.Put("PageSize", config.PageSize);
				manage.Put("WinHeight", height);
				aspxCode = manage.Display("manage.tmp");

				VelocityHelper managecs = new VelocityHelper("\\templates\\{0}\\".FormatWith(config.TemplateName));
				managecs.Put("Project", projectName);
				managecs.Put("ProjectStartDate", config.ProjectStartDate);
				managecs.Put("CopyRight", config.CopyRight);
				managecs.Put("TableName", tableName);
				managecs.Put("TableNameCN", title);
				managecs.Put("Fields", list);
				managecs.Put("NoPKFields", list.Where(p => !p.IsPK).ToList());
				managecs.Put("PKFields", list.Where(p => p.IsPK).ToList());
				managecs.Put("FKFields", list.Where(p => p.IsFK).ToList());
				managecs.Put("helper", new helper());
				managecs.Put("PKInfo", pkInfo);
				managecs.Put("isOnePage", isOnePage);
				managecs.Put("PagerSqlEnum", config.PagerSqlEnum);
				managecs.Put("PageSizes", config.PageSize);
				csCode = managecs.Display("manage.cs.tmp");

				FileDirectory.DirectoryCreate(aspxPath);
				FileDirectory.FileDelete(aspxPath + entityName + "Manage.aspx");
				FileDirectory.FileWrite(aspxPath + entityName + "Manage.aspx", aspxCode.ToString());
				FileDirectory.FileDelete(aspxPath + entityName + "Manage.aspx.cs");
				FileDirectory.FileWrite(aspxPath + entityName + "Manage.aspx.cs", csCode.ToString());
				if (!string.IsNullOrEmpty(config.AdminPath) && config.IsAll) {
					dbCode.AppendFormat(string.Format("    <table cellspacing='0' cellpadding='0' style='width: 100%;'><tbody><tr class='MenuItemRow'><td style='width: 7px;' /><td align='RIGHT' style='width: 10px; vertical-align: top;'><div class='IconContainer' style='width: 10px;'></div></td><td style='padding: 0px 9px 0px 5px;'><font class='MenuItemLabel'><a href='#' onclick=\"parent.window.frames[1].location.href='{0}'\" style='text-decoration:none; color:#428eff'>{1}</a></font></td></tr></tbody></table>", "../" + folder + "/" + entityName + "Manage.aspx", (string.IsNullOrEmpty(title) ? tableName : title) + "管理"));
					FileDirectory.FileWrite(config.AdminPath + "\\xml\\db.aspx", dbCode.ToString());
				}
				if (!isOnePage) {
					VelocityHelper add = new VelocityHelper("\\templates\\{0}\\".FormatWith(config.TemplateName));
					add.Put("Project", projectName);
					add.Put("ProjectStartDate", config.ProjectStartDate);
					add.Put("CopyRight", config.CopyRight);
					add.Put("TableName", tableName);
					add.Put("TableNameCN", title);
					add.Put("Fields", list);
					add.Put("NoPKFields", list.Where(p => !p.IsPK).ToList());
					add.Put("PKFields", list.Where(p => p.IsPK).ToList());
					add.Put("FKFields", list.Where(p => p.IsFK).ToList());
					add.Put("helper", new helper());
					add.Put("currTableOP", currTableOP);
					add.Put("PKInfo", pkInfo);
					aspxCode = add.Display("add.tmp");

					VelocityHelper addcs = new VelocityHelper("\\templates\\{0}\\".FormatWith(config.TemplateName));
					addcs.Put("Project", projectName);
					addcs.Put("ProjectStartDate", config.ProjectStartDate);
					addcs.Put("CopyRight", config.CopyRight);
					addcs.Put("TableName", tableName);
					addcs.Put("TableNameCN", title);
					addcs.Put("Fields", list);
					addcs.Put("NoPKFields", list.Where(p => !p.IsPK).ToList());
					addcs.Put("PKFields", list.Where(p => p.IsPK).ToList());
					addcs.Put("FKFields", list.Where(p => p.IsFK).ToList());
					addcs.Put("helper", new helper());
					addcs.Put("currTableOP", currTableOP);
					addcs.Put("PKInfo", pkInfo);
					csCode = addcs.Display("add.cs.tmp");

					FileDirectory.FileDelete(aspxPath + entityName + "Add.aspx");
					FileDirectory.FileWrite(aspxPath + entityName + "Add.aspx", aspxCode.ToString());
					FileDirectory.FileDelete(aspxPath + entityName + "Add.aspx.cs");
					FileDirectory.FileWrite(aspxPath + entityName + "Add.aspx.cs", csCode.ToString());
				}
			}

			return code;
			//return sb.ToString();
		}
Esempio n. 12
0
        public void ProcessRequest(HttpContext context)
        {
            VelocityHelper vh = new VelocityHelper();

            vh.Init(@"~/TemplateModel");//指定模板文件的相对路径

            List <string> templatFileNameModel = new List <string>();

            templatFileNameModel.Add("Model.html");
            templatFileNameModel.Add("Model_js.js");
            templatFileNameModel.Add("Model_layer.html");

            string urlPath = HttpContext.Current.Server.MapPath("~/TemplateModel/Model/");

            //打开数据库查询表名及字段信息
            SqlConnection con = new SqlConnection();

            con.ConnectionString = ConnectionString;
            con.Open();

            string tableName               = null; //表名
            string tableCatalog            = null; //数据库名
            string columnName              = null; //字段名称
            string dataType                = null; //字段类型
            string dataLength              = null; //字段长度
            string description             = null; //字段说明
            List <Table_Column> columnList = new List <Table_Column>();

            //获得数据库中的所有表的表名
            string[] restrictions = new string[4];
            restrictions[3] = "BASE TABLE";

            DataTable table = con.GetSchema("Tables", restrictions);

            foreach (DataRow row in table.Rows)
            {
                tableName    = row["TABLE_NAME"].ToString();    //表名
                tableCatalog = row["TABLE_CATALOG"].ToString(); //数据库名

                string[] restrictionsColumn = new string[4];
                restrictionsColumn[2] = tableName;
                DataTable tableColumn = con.GetSchema("Columns", restrictionsColumn);

                foreach (DataRow rowColumn in tableColumn.Rows)
                {
                    columnName  = rowColumn["COLUMN_NAME"].ToString();              //字段名称
                    dataType    = rowColumn["DATA_TYPE"].ToString();                //字段类型
                    dataLength  = rowColumn["CHARACTER_MAXIMUM_LENGTH"].ToString(); //字段长度
                    description = "";                                               //无法获得字段说明
                    columnList.Add(new Table_Column(columnName, dataType, dataLength, description));
                }

                vh.Put("tableName", tableName);
                vh.Put("columnList", columnList);

                vh.CreateHtml(templatFileNameModel[0], CreateFile(urlPath + tableCatalog + @"\Html\") + tableName.ToString() + ".html");
                vh.CreateHtml(templatFileNameModel[1], CreateFile(urlPath + tableCatalog + @"\js\") + tableName.ToString() + ".js");
                vh.CreateHtml(templatFileNameModel[2], CreateFile(urlPath + tableCatalog + @"\Html\layer\") + tableName.ToString() + "_layer.html");

                columnList.Clear();
            }
            con.Close();

            context.Response.Clear();
            context.Response.ContentEncoding = Encoding.UTF8;
            context.Response.ContentType     = "application/json";
            context.Response.Write("生成成功!");
            context.Response.Flush();
            context.ApplicationInstance.CompleteRequest();
        }