一步一步搭框架(asp.netmvc+easyui+sqlserver)-03

我们期望简洁的后台代码,如下:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using formula;
  7. using System.Data;
  8.  
  9. namespace demo.Areas.basic.Controllers
  10. {
  11. public class customerController : BaseController
  12. {
  13. public JsonResult getList(QueryBuilder qb)
  14. {
  15. SqlHelper sqlHelper = new SqlHelper("demo");
  16. var data = sqlHelper.ExecuteGridData("select *,id=customerId from customer", qb);
  17. return Json(data);
  18. }
  19. }
  20. }

为了这种简洁的代码我们需要:

1、Controller基类BaseController:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Web.Mvc;
  6. using System.Data.Entity;
  7. using System.Data.SqlClient;
  8. using System.Data.Entity.Validation;
  9. using System.ComponentModel;
  10. using System.Reflection;
  11. using System.Web.Security;
  12. using formula;
  13.  
  14. namespace formula
  15. {
  16. public abstract class BaseController : Controller
  17. {
  18. #region 处理不存在的Action
  19.  
  20. protected override void HandleUnknownAction(string actionName)
  21. {
  22. if (Request.HttpMethod == "POST")
  23. {
  24. HttpContext.ClearError();
  25. HttpContext.Response.Clear();
  26. HttpContext.Response.StatusCode = ;
  27. HttpContext.Response.Write("没有Action:" + actionName);
  28. HttpContext.Response.End();
  29. }
  30.  
  31. // 搜索文件是否存在
  32. var filePath = "";
  33. if (RouteData.DataTokens["area"] != null)
  34. filePath = string.Format("~/Areas/{2}/Views/{1}/{0}.cshtml", actionName, RouteData.Values["controller"], RouteData.DataTokens["area"]);
  35. else
  36. filePath = string.Format("~/Views/{1}/{0}.cshtml", actionName, RouteData.Values["controller"]);
  37. if (System.IO.File.Exists(Server.MapPath(filePath)))
  38. {
  39. View(filePath).ExecuteResult(ControllerContext);
  40. }
  41. else
  42. {
  43. HttpContext.ClearError();
  44. HttpContext.Response.Clear();
  45. HttpContext.Response.StatusCode = ;
  46. HttpContext.Response.Write("没有Action:" + actionName);
  47. HttpContext.Response.End();
  48. }
  49. }
  50. #endregion
  51.  
  52. #region 基类Json方法重载
  53.  
  54. protected override JsonResult Json(object data, string contentType, Encoding contentEncoding, JsonRequestBehavior behavior)
  55. {
  56. NewtonJsonResult result = new NewtonJsonResult() { Data = data, ContentType = contentType, ContentEncoding = contentEncoding, JsonRequestBehavior = behavior };
  57.  
  58. return result;
  59. }
  60. protected override JsonResult Json(object data, string contentType, Encoding contentEncoding)
  61. {
  62. NewtonJsonResult result = new NewtonJsonResult() { Data = data, ContentType = contentType, ContentEncoding = contentEncoding };
  63.  
  64. return result;
  65. }
  66.  
  67. #endregion
  68.  
  69. #region 异常处理
  70.  
  71. protected override void OnException(ExceptionContext filterContext)
  72. {
  73. Exception exp = filterContext.Exception;
  74. if (string.IsNullOrEmpty(exp.Message))
  75. exp = exp.GetBaseException();
  76.  
  77. if (filterContext.RequestContext.HttpContext.Request.IsAjaxRequest())
  78. {
  79. var response = filterContext.RequestContext.HttpContext.Response;
  80. response.Clear();
  81. response.Write(exp.Message);
  82. response.StatusCode = ;
  83. response.End();
  84. }
  85. }
  86.  
  87. #endregion
  88. }
  89.  
  90. }

2、查询构造器QueryBuilder:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Collections;
  6. using System.Web.Mvc;
  7.  
  8. namespace formula
  9. {
  10. [ModelBinder(typeof(QueryBuilderBinder))]
  11. public class QueryBuilder : SearchCondition
  12. {
  13. public int page { get; set; }
  14. public int rows { get; set; }
  15. public string sort { get; set; }
  16. public string order { get; set; }
  17. public int total { get; set; }
  18.  
  19. public string getOrderByString(bool hasOrderBy = true)
  20. {
  21. var sortFields = this.sort.Split(',');
  22. var sortOrders = this.order.Split(',');
  23.  
  24. string str = "";
  25. for (int i = ; i < sortFields.Length; i++)
  26. {
  27. str += sortFields[i] + " " + sortOrders[i] + ",";
  28. }
  29. if (hasOrderBy && str != "")
  30. str = "order by " + str;
  31. return str.Trim(',');
  32. }
  33.  
  34. }
  35.  
  36. public class SearchCondition
  37. {
  38. public string fields = "*";
  39. private List<ConditionItem> quickItems = new List<ConditionItem>();
  40. private List<ConditionItem> complexItems = new List<ConditionItem>();
  41.  
  42. public SearchCondition add(string field, string method, object val, bool isQuickSearch = false)
  43. {
  44. //处理日期型数据
  45. if (method == "<" || method == "<=")
  46. {
  47. if (val.GetType() == typeof(DateTime))
  48. {
  49. DateTime t = (DateTime)val;
  50. val = t.Date.AddHours().AddMinutes().AddSeconds();
  51. }
  52. }
  53.  
  54. ConditionItem item = new ConditionItem(field, method, val);
  55. if (isQuickSearch)
  56. quickItems.Add(item);
  57. else
  58. complexItems.Add(item);
  59. return this;
  60. }
  61.  
  62. public string getWhereString(bool hasWhere = true)
  63. {
  64. if (quickItems.Count == && complexItems.Count == )
  65. return "";
  66.  
  67. string strWhere = "";
  68.  
  69. if (quickItems.Count > )
  70. strWhere += " and (" + getGourpWhereString(quickItems, true) + ")";
  71. if (complexItems.Count > )
  72. strWhere += " and (" + getGourpWhereString(complexItems, false) + ")";
  73.  
  74. if (hasWhere)
  75. strWhere = " where " + strWhere.Substring();
  76. else
  77. strWhere = " and " + strWhere.Substring();
  78.  
  79. return strWhere;
  80. }
  81.  
  82. #region 私有方法
  83.  
  84. private string getGourpWhereString(List<ConditionItem> list, bool isOrRelation = false)
  85. {
  86.  
  87. if (list.Count == )
  88. return "";
  89.  
  90. string strWhere = "";
  91. for (int i = ; i < list.Count(); i++)
  92. {
  93. var item = list[i];
  94. string str = item.getWhereString();
  95.  
  96. if (isOrRelation)
  97. {
  98. strWhere += " or " + str;
  99. }
  100. else
  101. {
  102. strWhere += " and " + str;
  103. }
  104. }
  105.  
  106. strWhere = strWhere.Substring();
  107.  
  108. return strWhere;
  109. }
  110.  
  111. #endregion
  112.  
  113. }
  114.  
  115. public class ConditionItem
  116. {
  117. public ConditionItem(string field, string method, object val)
  118. {
  119. this.field = field;
  120. this.method = method;
  121. this.value = val;
  122. }
  123. public string field { get; set; }
  124. public string method { get; set; }
  125. public object value { get; set; }
  126.  
  127. public string getWhereString()
  128. {
  129. var item = this;
  130. switch (item.method)
  131. {
  132. case "=":
  133. case "<":
  134. case ">":
  135. case "<=":
  136. case ">=":
  137. case "<>":
  138. return string.Format("{0} {1} '{2}'", item.field, item.method, item.value);
  139. case "in":
  140. string v = "";
  141. if (item.value is ICollection)
  142. {
  143. ICollection<string> collection = item.value as ICollection<string>;
  144. v = string.Join("','", collection.ToArray<string>());
  145. return string.Format("{0} in('{1}')", item.field, v);
  146. }
  147. else
  148. {
  149. v = item.value.ToString().Replace(",", "','");
  150. }
  151. return string.Format("{0} in ('{1}')", item.field, v);
  152. case "between":
  153. object[] objs = item.value as object[];
  154. return string.Format("{0} between '{1}' and '{2}'", item.field, objs[], objs[]);
  155. case "inLike":
  156. string[] arr = null;
  157. if (item.value is ICollection)
  158. {
  159. ICollection<string> collection = item.value as ICollection<string>;
  160. arr = collection.ToArray<string>();
  161. }
  162. else
  163. {
  164. arr = item.value.ToString().Split(',', ',');
  165. }
  166. string str = "";
  167. foreach (string s in arr)
  168. {
  169. str += string.Format("or {0} like '%{1}%'", item.field, s);
  170. }
  171. return "(" + str.Substring() + ")";
  172. case "day":
  173. DateTime dt = DateTime.Now;
  174. if (!DateTime.TryParse(item.value.ToString(), out dt))
  175. {
  176. throw new BuessinessException("查询条件不能转化为日期时间");
  177. }
  178. string start = dt.Date.ToString("yyyy-MM-dd");
  179. string end = dt.Date.AddDays().ToString("yyyy-MM-dd");
  180. return string.Format("{0} between '{1}' and '{2}'", item.field, start, end);
  181. case "startWith":
  182. return string.Format("{0} like '{1}%'", item.field, item.value);
  183. case "endWith":
  184. return string.Format("{0} like '%{1}'", item.field, item.value);
  185. default:
  186. return "";
  187. }
  188.  
  189. }
  190. }
  191. }

3、查询构造器QueryBuilder的创建方法QueryBuilderBinder:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Web.Mvc;
  6.  
  7. namespace formula
  8. {
  9. public class QueryBuilderBinder : IModelBinder
  10. {
  11. public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
  12. {
  13. var qb = (QueryBuilder)(bindingContext.Model ?? new QueryBuilder());
  14. var dict = controllerContext.HttpContext.Request.Params;
  15.  
  16. var quickQueryList = !string.IsNullOrEmpty(dict["quickQueryData"]) ? JsonHelper.ToList(dict["quickQueryData"]) : new List<Dictionary<string, object>>();
  17. var queryList = !string.IsNullOrEmpty(dict["queryData"]) ? JsonHelper.ToList(dict["queryData"]) : new List<Dictionary<string, object>>();
  18.  
  19. foreach (var dic in quickQueryList)
  20. {
  21. var val = dic["value"].ToString();
  22. if (val == "") continue;
  23. qb.add(dic["field"].ToString(), dic["method"].ToString(), val, true);
  24. }
  25.  
  26. foreach (var dic in queryList)
  27. {
  28. var val = dic["value"].ToString();
  29. if (val == "") continue;
  30. qb.add(dic["field"].ToString(), dic["method"].ToString(), val, false);
  31. }
  32.  
  33. qb.page = !string.IsNullOrEmpty(dict["page"]) ? int.Parse(dict["page"].ToString()) : ;
  34. qb.rows = !string.IsNullOrEmpty(dict["rows"]) ? int.Parse(dict["rows"].ToString()) : ;
  35. qb.sort = !string.IsNullOrEmpty(dict["sort"]) ? dict["page"].ToString() : "id";
  36. qb.order = !string.IsNullOrEmpty(dict["order"]) ? dict["order"].ToString() : "desc";
  37.  
  38. return qb;
  39.  
  40. }
  41. }
  42. }

4、数据库查询帮助类SqlHelper:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data.SqlClient;
  6. using System.Data;
  7. using System.Web;
  8.  
  9. namespace formula
  10. {
  11. public class SqlHelper
  12. {
  13. #region 构造函数
  14.  
  15. public SqlHelper(string connName)
  16. {
  17. if (System.Configuration.ConfigurationManager.ConnectionStrings[connName] == null)
  18. throw new BuessinessException(string.Format("配置文件中不包含数据库连接字符串:{0}", connName));
  19. this.connName = connName;
  20. this.connString = System.Configuration.ConfigurationManager.ConnectionStrings[connName].ConnectionString;
  21. }
  22.  
  23. public string connName { get; private set; }
  24. public string connString { get; private set; }
  25. public string dbName
  26. {
  27. get
  28. {
  29. SqlConnection conn = new SqlConnection(connString);
  30. return conn.Database;
  31. }
  32. }
  33.  
  34. #endregion
  35.  
  36. #region 基本方法
  37.  
  38. public object ExecuteScalar(string cmdText)
  39. {
  40. using (SqlConnection conn = new SqlConnection(connString))
  41. {
  42. conn.Open();
  43. SqlCommand cmd = new SqlCommand(cmdText, conn);
  44. return cmd.ExecuteScalar();
  45. }
  46. }
  47.  
  48. public DataTable ExecuteDataTable(string cmdText)
  49. {
  50. using (SqlConnection conn = new SqlConnection(connString))
  51. {
  52. DataTable dt = new DataTable();
  53. SqlDataAdapter apt = new SqlDataAdapter(cmdText, conn);
  54. apt.Fill(dt);
  55. return dt;
  56. }
  57. }
  58.  
  59. public DataTable ExecuteDataTable(string cmdText, int start, int len)
  60. {
  61. using (SqlConnection conn = new SqlConnection(connString))
  62. {
  63. DataTable dt = new DataTable();
  64. SqlDataAdapter apt = new SqlDataAdapter(cmdText, conn);
  65. apt.Fill(start, len, dt);
  66. return dt;
  67. }
  68. }
  69.  
  70. public string ExecuteNonQuery(string cmdText)
  71. {
  72. using (SqlConnection conn = new SqlConnection(connString))
  73. {
  74. conn.Open();
  75. SqlCommand cmd = new SqlCommand(cmdText, conn);
  76. return cmd.ExecuteNonQuery().ToString();
  77. }
  78. }
  79.  
  80. #endregion
  81.  
  82. #region 支持查询对象
  83.  
  84. public DataTable ExecuteDataTable(string sql, SearchCondition cnd, string orderBy)
  85. {
  86. string sqlWhere = " where 1=1" + GetUrlFilterSqlWhere(sql) + cnd.getWhereString(false);
  87. sql = string.Format("select {0} from ({1}) sourceTable {2} {3}", cnd.fields, sql, sqlWhere, orderBy);
  88. DataTable dt = this.ExecuteDataTable(sql);
  89. return dt;
  90. }
  91.  
  92. public Dictionary<string, object> ExecuteGridData(string sql, QueryBuilder qb)
  93. {
  94. string sqlWhere = " where 1=1" + GetUrlFilterSqlWhere(sql) + qb.getWhereString(false);
  95.  
  96. qb.total = (int)this.ExecuteScalar(string.Format("select count(1) from ({0}) sourceTable {1}", sql, sqlWhere));
  97.  
  98. sql = string.Format("select {0} from ({1}) sourceTable {2} {3}", qb.fields, sql, sqlWhere, qb.getOrderByString());
  99. DataTable dt = ExecuteDataTable(sql, (qb.page - ) * qb.rows, qb.rows);
  100.  
  101. Dictionary<string, object> dic = new Dictionary<string, object>();
  102. dic.Add("total", qb.total);
  103. dic.Add("rows", dt);
  104. return dic;
  105. }
  106.  
  107. #endregion
  108.  
  109. #region 私有方法
  110.  
  111. private string GetUrlFilterSqlWhere(string sql)
  112. {
  113. sql = string.Format("select * from({0}) as dt1 where 1=2", sql);
  114. var dtField = ExecuteDataTable(sql);
  115.  
  116. StringBuilder sb = new StringBuilder();
  117. foreach (string key in HttpContext.Current.Request.QueryString.Keys)
  118. {
  119. if (string.IsNullOrEmpty(key) || key.ToLower() == "id")
  120. continue;
  121.  
  122. if (dtField.Columns.Contains(key))
  123. {
  124. string value = HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request[key]);
  125. value = value.Replace(",", "','");
  126. sb.AppendFormat(" and {0} in ('{1}')", key, value);
  127. }
  128. }
  129. return sb.ToString();
  130. }
  131.  
  132. #endregion
  133.  
  134. }
  135. }

5、用于取代返回值JsonResult的NewtonJsonResult:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Web.Mvc;
  6. using System.Web;
  7. using System.Data;
  8.  
  9. namespace formula
  10. {
  11. public class NewtonJsonResult : JsonResult
  12. {
  13. public override void ExecuteResult(ControllerContext context)
  14. {
  15. //确认是否用于响应HTTP-Get请求
  16. if (this.JsonRequestBehavior == JsonRequestBehavior.DenyGet &&
  17. string.Compare(context.HttpContext.Request.HttpMethod, "GET", true) == )
  18. {
  19. throw new InvalidOperationException("禁止Get请求");
  20. }
  21.  
  22. HttpResponseBase response = context.HttpContext.Response;
  23. //设置媒体类型和编码方式
  24. response.ContentType = string.IsNullOrEmpty(this.ContentType) ?
  25. "application/json" : this.ContentType;
  26. if (this.ContentEncoding != null)
  27. {
  28. response.ContentEncoding = this.ContentEncoding;
  29. }
  30.  
  31. //序列化对象,并写入当前的HttpResponse
  32. if (null == this.Data) return;
  33.  
  34. if (this.Data is string)
  35. {
  36. response.Write(Data);
  37. }
  38. else if (this.Data is DataRow)
  39. {
  40. Dictionary<string, object> dic = new Dictionary<string, object>();
  41. DataRow row = this.Data as DataRow;
  42. foreach (DataColumn col in row.Table.Columns)
  43. {
  44. dic.Add(col.ColumnName, row[col]);
  45. }
  46. response.Write(JsonHelper.ToJson(dic));
  47. }
  48. else
  49. {
  50. response.Write(JsonHelper.ToJson(this.Data));
  51. }
  52. }
  53. }
  54.  
  55. }

6、Json序列化和反序列的帮助类JsonHelper:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Newtonsoft.Json.Converters;
  6. using Newtonsoft.Json;
  7.  
  8. namespace formula
  9. {
  10. public static class JsonHelper
  11. {
  12. public static string ToJson<T>(T obj)
  13. {
  14.  
  15. if (obj == null || obj.ToString() == "null") return null;
  16.  
  17. if (obj != null && (obj.GetType() == typeof(String) || obj.GetType() == typeof(string)))
  18. {
  19. return obj.ToString();
  20. }
  21.  
  22. IsoDateTimeConverter dt = new IsoDateTimeConverter();
  23. dt.DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss";
  24. return JsonConvert.SerializeObject(obj, dt);
  25.  
  26. }
  27.  
  28. /// <summary>
  29. /// 从一个Json串生成对象信息
  30. /// </summary>
  31. /// <param name="jsonString">JSON字符串</param>
  32. /// <typeparam name="T">对象类型</typeparam>
  33. /// <returns></returns>
  34. public static T ToObject<T>(string json) where T : class
  35. {
  36. if (String.IsNullOrEmpty(json)) return null;
  37. T obj = JsonConvert.DeserializeObject<T>(json);
  38. return obj;
  39. }
  40.  
  41. /// <summary>
  42. /// 返回 Diction<string,object>
  43. /// </summary>
  44. /// <param name="json"></param>
  45. /// <returns></returns>
  46. public static Dictionary<string, object> ToObject(string json)
  47. {
  48. if (String.IsNullOrEmpty(json)) return new Dictionary<string, object>();
  49. return ToObject<Dictionary<string, object>>(json);
  50. }
  51.  
  52. /// <summary>
  53. /// 返回 List<Dictionary<string, object>>
  54. /// </summary>
  55. /// <param name="json"></param>
  56. /// <returns></returns>
  57. public static List<Dictionary<string, object>> ToList(string json)
  58. {
  59. if (String.IsNullOrEmpty(json)) return new List<Dictionary<string, object>>();
  60. return ToObject<List<Dictionary<string, object>>>(json);
  61. }
  62.  
  63. /// <summary>
  64. /// 组装对象
  65. /// </summary>
  66. /// <param name="json"></param>
  67. /// <param name="obj"></param>
  68. public static void PopulateObject(string json, object obj)
  69. {
  70. if (String.IsNullOrEmpty(json)) return;
  71. JsonConvert.PopulateObject(json, obj);
  72. }
  73. }
  74. }

7、用于区分系统异常和业务异常的BusinessException:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Runtime.Serialization;
  6.  
  7. namespace formula
  8. {
  9. /// <summary>
  10. /// 业务异常
  11. /// </summary>
  12. [Serializable]
  13. public class BuessinessException : Exception
  14. {
  15. /// <summary>
  16. /// 系统异常构造函数
  17. /// </summary>
  18. public BuessinessException()
  19. {
  20.  
  21. }
  22.  
  23. /// <summary>
  24. /// 系统异常构造函数
  25. /// </summary>
  26. /// <param name="message">异常的消息</param>
  27. public BuessinessException(string message)
  28. : base(message)
  29. {
  30.  
  31. }
  32.  
  33. /// <summary>
  34. /// 系统异常构造函数
  35. /// </summary>
  36. /// <param name="message">异常的消息</param>
  37. /// <param name="inner">内部的异常</param>
  38. public BuessinessException(string message, System.Exception inner)
  39. : base(message, inner)
  40. {
  41.  
  42. }
  43.  
  44. /// <summary>
  45. /// 系统异常构造函数
  46. /// </summary>
  47. /// <param name="info">存有有关所引发异常的序列化的对象数据</param>
  48. /// <param name="context">包含有关源或目标的上下文信息</param>
  49. public BuessinessException(SerializationInfo info, StreamingContext context)
  50. : base(info, context)
  51. {
  52.  
  53. }
  54. }
  55. }

以上为目前的全部代码。

一步一步搭框架(asp.netmvc+easyui+sqlserver)-03的更多相关文章

  1. 一步一步搭框架(asp.netmvc+easyui+sqlserver)-02

    一步一步搭框架(asp.netmvc+easyui+sqlserver)-02 我们期望简洁带前台代码,如下: <table id="dataGrid" class=&quo ...

  2. 一步一步搭框架(asp.netmvc+easyui+sqlserver)-01

    一步一步搭框架(asp.netmvc+easyui+sqlserver)-01 要搭建的框架是企业级开发框架,适用用企业管理信息系统的开发,如:OA.HR等 1.框架名称:sampleFrame. 2 ...

  3. (转) 一步一步学习ASP.NET 5 (四)- ASP.NET MVC 6四大特性

    转发:微软MVP 卢建晖 的文章,希望对大家有帮助.原文:http://blog.csdn.net/kinfey/article/details/44459625 编者语 : 昨晚写好的文章居然csd ...

  4. ASP.NET MVC 3 Model【通过一简单实例一步一步的介绍】

    今天主要讲Model的两个方面: 1. ASP.Net MVC 3 Model 简介 通过一简单的事例一步一步的介绍 2. ASP.Net MVC 3 Model 的一些验证 MVC 中 Model ...

  5. 一步一步创建ASP.NET MVC5程序[Repository+Autofac+Automapper+SqlSugar](一)

    前言 大家好,我是Rector 从今天开始,Rector将为大家推出一个关于创建ASP.NET MVC5程序[Repository+Autofac+Automapper+SqlSugar]的文章系列, ...

  6. 一步一步创建ASP.NET MVC5程序[Repository+Autofac+Automapper+SqlSugar](四)

    前言 上一篇<一步一步创建ASP.NET MVC5程序[Repository+Autofac+Automapper+SqlSugar](三)>,我们完成了: * 引用SqlSugar * ...

  7. 一步一步创建ASP.NET MVC5程序[Repository+Autofac+Automapper+SqlSugar](三)

    前言 上一篇<一步一步创建ASP.NET MVC5程序[Repository+Autofac+Automapper+SqlSugar](二)>我们通过如下操作: 创建实体及工具类 创建Re ...

  8. #使用abp框架与vue一步一步写我是月老的小工具(2) 后台搭建初体验

    #使用abp框架与vue一步一步写我是月老的小工具(2) 后台搭建初体验 一.续上前言 关于这个小玩意的产品思考,假设我暂时把他叫我是月老热心人 这是一个没有中心的关系链,每个人进入以后都是以自己为中 ...

  9. 3、带你一步一步学习ASP.NET Core中的配置之Configuration

    如果你是刚接触ASP.NET Core的学习的话,你会注意到:在ASP.NET Core项目中,看不到.NET Fraemwork时代中的web.config文件和app.config文件了.那么你肯 ...

随机推荐

  1. Android Studio安装和配置(个人研究,有错请指导)

    安装Android Studio的原因:公司有app开发者,然而公司没有测试,只好互相测试,本人并没有接触过app开发,纯小白: 自己试着安装了一下Android Studio来这里记录并分享遇到的问 ...

  2. Win7/Win8/Win8.1/Win10下的DragEnter DragDrop事件不触发

    Win7/Win8/Win8.1/Win10下的DragDrop事件不触发 2011-02-02  来自:博客园  字体大小:[大 中 小] 摘要:你的应用程序需要从windows资源管理器拖动文件到 ...

  3. ARM: STM32F7: hardfault caused by unaligned memory access

    ARM: STM32F7: hardfault caused by unaligned memory access ARM: STM32F7: 由未对齐的内存访问引起的hardfault异常 Info ...

  4. git 忽略提交某个指定的文件(不从版本库中删除)

    执行指令: 1 2 [Sun@webserver2 demo]$ git update-index --assume-unchanged config.conf [Sun@webserver2 dem ...

  5. yii2 框架的 save() 方法 执行模式条件。

     save() 方法会调用 insert() 和 update() 中的一个, 用哪个取决于当前 AR 对象是不是新对象(在函数内部,他会检查 yii\db\ActiveRecord::isNewRe ...

  6. 总结js中数据类型的bool值及其比较

    首先需要知道的是,js中有6个值为false,分别是: 0, '', null, undefined, NaN 和 false, 其他(包括{}, [], Infinity)为true. 可以使用Bo ...

  7. Xcode5 + phoneGap2.9搭建ios开发环境-配置-测试-归档上传/phoneG...

    前言: 小弟是做JAVA/Android的第一次搞这个ios,公司有mobile项目是使用phoneGap开发的,需要开发ios版本.什么都不会只能一点一点琢磨了……大神越过…… 原文链接:http: ...

  8. 通过select的value值来改变textarea内字体和大小

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. adapter用法

    Android之Adapter用法总结 1.概念 Adapter是连接后端数据和前端显示的适配器接口,是数据和UI(View)之间一个重要的纽带.在常见的View(ListView,GridView) ...

  10. python网络编程【三】(网络服务器)

    建立一个服务器需要以下4步: 1.建立socket对象. 2.设置socket选项(可选的) 3.绑定到一个端口(同样,也可以是一个指定的网卡). 4.侦听连接. 下面代码片段可以实现这些功能: ho ...