WindowsForms 调用API
WindowsForms 后台
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Http;
using Newtonsoft.Json;
using Aspose.Cells;
namespace WindowsDB2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/// <summary>
/// 显示
/// </summary>
void Bind(string name="",int type=1)
{
Uri uri = new Uri("http://localhost:8231/");
HttpClient client = new HttpClient();
client.BaseAddress = uri;
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage mesa = client.GetAsync("actionApi/showApi/show?name=" + name + "&type=" + type).Result;
if (mesa.IsSuccessStatusCode)
{
var p = mesa.Content.ReadAsStringAsync().Result;
var js = JsonConvert.DeserializeObject<List<stuModel>>(p);
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AutoGenerateColumns = false;
dataGridView1.DataSource = js;
}
}
/// <summary>
/// 下拉
/// </summary>
void xia()
{
Uri uri = new Uri("http://localhost:8231/");
HttpClient client = new HttpClient();
client.BaseAddress = uri;
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage mesa = client.GetAsync("actionApi/showApi/xia").Result;
if (mesa.IsSuccessStatusCode)
{
var p = mesa.Content.ReadAsStringAsync().Result;
var js = JsonConvert.DeserializeObject<List<stuType>>(p);
comboBox1.DisplayMember = "TypeName";
comboBox1.ValueMember = "Typeid";
comboBox1.DataSource = js;
}
}
/// <summary>
/// 加载 显示
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form1_Load(object sender, EventArgs e)
{
xia();
Bind("", 1);
}
/// <summary>
/// 图片显示
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
DataGridView p = sender as DataGridView;
if (p.Columns[e.ColumnIndex].Name == "Tu")
{
e.Value = Image.FromFile(Application.StartupPath + "\\img\\" + e.Value);
}
}
/// <summary>
/// 添加
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
Add d = new Add();
d.ShowDialog();
Bind("", 1);
}
/// <summary>
/// 导出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
Uri uri = new Uri("http://localhost:8231/");
HttpClient client = new HttpClient();
client.BaseAddress = uri;
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage mesa = client.GetAsync("actionApi/showApi/show").Result;
if (mesa.IsSuccessStatusCode)
{
var p = mesa.Content.ReadAsStringAsync().Result;
var js = JsonConvert.DeserializeObject<List<stuModel>>(p);
Workbook book = new Workbook();
Worksheet s = book.Worksheets[0];
Cells cell = s.Cells;
int i = 0;
cell[i, 0].PutValue("编号");
cell[i, 1].PutValue("名称");
cell[i, 2].PutValue("价格");
cell[i, 3].PutValue("图片");
cell[i, 4].PutValue("类型");
foreach (stuModel item in js)
{
i++;
cell[i, 0].PutValue(item.ID);
cell[i, 1].PutValue(item.Names);
cell[i, 2].PutValue(item.Price);
cell[i, 3].PutValue(item.Imgname);
cell[i, 4].PutValue(item.TypeName);
}
string newname = Guid.NewGuid().ToString() + ".xlsx";
book.Save(newname);
System.Diagnostics.Process.Start(Application.StartupPath + "\\" + newname);
}
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Bitmap p = new Bitmap(groupBox1.Width, groupBox1.Height);
groupBox1.DrawToBitmap(p, new Rectangle(0,0,p.Width, p.Height));
e.Graphics.DrawImage(p, 0, 0, p.Width, p.Height);
}
/// <summary>
/// 打印
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button4_Click(object sender, EventArgs e)
{
printPreviewDialog1.ShowDialog();
}
/// <summary>
/// 删除 修改
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
DataGridView p = sender as DataGridView;
DataGridViewRow row = p.Rows[e.RowIndex];
if (p.Columns[e.ColumnIndex].Name == "del")
{
var id = row.Cells[0].Value;
Uri uri = new Uri("http://localhost:8231/");
HttpClient client = new HttpClient();
client.BaseAddress = uri;
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage mesa = client.DeleteAsync("actionApi/showApi/shan?id=" + id).Result;
if (mesa.IsSuccessStatusCode)
{
var ppp = mesa.Content.ReadAsStringAsync().Result;
if (Convert.ToInt32(ppp) > 0)
{
MessageBox.Show("删除成功");
Bind("", 1);
}
}
}
if (p.Columns[e.ColumnIndex].Name == "update")
{
var id = row.Cells[0].Value;
xiu f = new xiu(Convert.ToInt32(id));
f.ShowDialog();
Bind("", 1);
}
}
/// <summary>
/// 全选
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button5_Click(object sender, EventArgs e)
{
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
dataGridView1.Rows[i].Cells[1].Value = true;
}
}
//批量删除
private void button6_Click(object sender, EventArgs e)
{
string id = string.Empty;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
DataGridViewRow row = dataGridView1.Rows[i];
if (Convert.ToBoolean(row.Cells[1].Value))
{
id += row.Cells[0].Value + ",";
}
}
id = id.TrimEnd(',');
Uri uri = new Uri("http://localhost:8231/");
HttpClient client = new HttpClient();
client.BaseAddress = uri;
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage mesa = client.DeleteAsync("actionApi/showApi/shan?id=" + id).Result;
if (mesa.IsSuccessStatusCode)
{
var ppp = mesa.Content.ReadAsStringAsync().Result;
if (Convert.ToInt32(ppp) > 0)
{
MessageBox.Show("删除成功");
Bind("",1);
}
}
}
//查询
private void button3_Click(object sender, EventArgs e)
{
var name = textBox1.Text;
int type =Convert.ToInt32(comboBox1.SelectedValue);
Bind(name, type);
}
}
}
WindowsForms 添加
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WindowsDB2
{
public partial class Add : Form
{
public Add()
{
InitializeComponent();
}
string tus = "";
void xia()
{
Uri uri = new Uri("http://localhost:8231/");
HttpClient client = new HttpClient();
client.BaseAddress = uri;
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage mesa = client.GetAsync("actionApi/showApi/xia").Result;
if (mesa.IsSuccessStatusCode)
{
var p = mesa.Content.ReadAsStringAsync().Result;
var js = JsonConvert.DeserializeObject<List<stuType>>(p);
comboBox1.DisplayMember = "TypeName";
comboBox1.ValueMember = "Typeid";
comboBox1.DataSource = js;
}
}
/// <summary>
/// 下拉的列表
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Add_Load(object sender, EventArgs e)
{
xia();
}
/// <summary>
/// 添加
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog p = new OpenFileDialog();
if (p.ShowDialog() == DialogResult.OK)
{
string flirename = p.FileName;
int page = flirename.LastIndexOf("\\");
string newname = Guid.NewGuid().ToString() + (flirename.Substring(page + 1));
using (FileStream ds = new FileStream(@".\img\" + newname, FileMode.CreateNew))
{
using (Stream str = p.OpenFile())
{
str.CopyTo(ds);
str.Flush();
stuModel m = new stuModel();
m.Names = textBox1.Text;
m.Price = Convert.ToInt32(textBox2.Text);
m.Typeid = Convert.ToInt32(comboBox1.SelectedValue);
m.Imgname = newname;
Uri uri = new Uri("http://localhost:8231/");
HttpClient client = new HttpClient();
client.BaseAddress = uri;
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpContent cont = new StringContent(JsonConvert.SerializeObject(m));
cont.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
HttpResponseMessage mesa = client.PostAsync("actionApi/showApi/add", cont).Result;
if (mesa.IsSuccessStatusCode)
{
var pp = mesa.Content.ReadAsStringAsync().Result;
if (Convert.ToInt32(pp) > 0)
{
MessageBox.Show("添加成功");
this.Close();
}
else
{
MessageBox.Show("添加失败");
}
}
pictureBox1.ImageLocation = (@".\img\" + newname).ToString();
}
}
}
}
private void label4_Click(object sender, EventArgs e)
{
OpenFileDialog p = new OpenFileDialog();
if (p.ShowDialog() == DialogResult.OK)
{
string flirename = p.FileName;
int page = flirename.LastIndexOf("\\");
string newname = Guid.NewGuid().ToString() + (flirename.Substring(page + 1));
tus = newname;
using (FileStream ds = new FileStream(@".\img\" + newname, FileMode.CreateNew))
{
using (Stream str = p.OpenFile())
{
str.CopyTo(ds);
str.Flush();
pictureBox1.ImageLocation = (@".\img\" + newname).ToString();
}
}
}
}
private void button2_Click(object sender, EventArgs e)
{
stuModel m = new stuModel();
m.Names = textBox1.Text;
m.Price = Convert.ToInt32(textBox2.Text);
m.Typeid = Convert.ToInt32(comboBox1.SelectedValue);
m.Imgname = tus;
Uri uri = new Uri("http://localhost:8231/");
HttpClient client = new HttpClient();
client.BaseAddress = uri;
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpContent cont = new StringContent(JsonConvert.SerializeObject(m));
cont.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
HttpResponseMessage mesa = client.PostAsync("actionApi/showApi/add", cont).Result;
if (mesa.IsSuccessStatusCode)
{
var pp = mesa.Content.ReadAsStringAsync().Result;
if (Convert.ToInt32(pp) > 0)
{
MessageBox.Show("添加成功");
this.Close();
}
else
{
MessageBox.Show("添加失败");
}
}
}
}
}
修改
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsDB2
{
public partial class xiu : Form
{
public xiu()
{
InitializeComponent();
}
string ids = "";
void xia()
{
Uri uri = new Uri("http://localhost:8231/");
HttpClient client = new HttpClient();
client.BaseAddress = uri;
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage mesa = client.GetAsync("actionApi/showApi/xia").Result;
if (mesa.IsSuccessStatusCode)
{
var p = mesa.Content.ReadAsStringAsync().Result;
var js = JsonConvert.DeserializeObject<List<stuType>>(p);
comboBox1.DisplayMember = "TypeName";
comboBox1.ValueMember = "Typeid";
comboBox1.DataSource = js;
}
}
public xiu(int id)
{
InitializeComponent();
Uri uri = new Uri("http://localhost:8231/");
HttpClient client = new HttpClient();
client.BaseAddress = uri;
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage mesa = client.GetAsync("actionApi/showApi/dan?id=" + id).Result;
if (mesa.IsSuccessStatusCode)
{
var p = mesa.Content.ReadAsStringAsync().Result;
var js = JsonConvert.DeserializeObject<List<stuModel>>(p).FirstOrDefault();
textBox1.Text = js.Names;
textBox2.Text = js.Price.ToString();
comboBox1.Text = js.TypeName;
pictureBox1.ImageLocation = (@".\img\" + js.Imgname).ToString();
ids = id.ToString();
}
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog p = new OpenFileDialog();
if (p.ShowDialog() == DialogResult.OK)
{
string flirename = p.FileName;
int page = flirename.LastIndexOf("\\");
string newname = Guid.NewGuid().ToString() + (flirename.Substring(page + 1));
using (FileStream ds = new FileStream(@".\img\" + newname, FileMode.CreateNew))
{
using (Stream str = p.OpenFile())
{
str.CopyTo(ds);
str.Flush();
stuModel m = new stuModel();
m.Names = textBox1.Text;
m.Price = Convert.ToInt32(textBox2.Text);
m.Typeid = Convert.ToInt32(comboBox1.SelectedValue);
m.Imgname = newname;
m.ID =Convert.ToInt32(ids);
Uri uri = new Uri("http://localhost:8231/");
HttpClient client = new HttpClient();
client.BaseAddress = uri;
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpContent cont = new StringContent(JsonConvert.SerializeObject(m));
cont.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
HttpResponseMessage mesa = client.PutAsync("actionApi/showApi/xiu", cont).Result;
if (mesa.IsSuccessStatusCode)
{
var pp = mesa.Content.ReadAsStringAsync().Result;
if (Convert.ToInt32(pp) > 0)
{
MessageBox.Show("修改成功");
this.Close();
}
else
{
MessageBox.Show("修改失败");
}
}
pictureBox1.ImageLocation = (@".\img\" + newname).ToString();
}
}
}
}
private void xiu_Load(object sender, EventArgs e)
{
xia();
}
}
}
分页
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace WindowsDB2
{
public partial class fen : Form
{
public fen()
{
InitializeComponent();
}
int count = 0;
int PageIndex = 0;
int PageSize = 4;
void Bind(int PageIndex,string sql)
{
MySqlParameter[] app = new MySqlParameter[] { (new MySqlParameter("@Exstr", MySqlDbType.VarChar, 200)), new MySqlParameter("@PageIndex", MySqlDbType.Int32),new MySqlParameter("@PageSize", MySqlDbType.Int32) };
app[0].Value = "";
app[0].Direction = ParameterDirection.Input;
app[1].Value = PageIndex;
app[1].Direction = ParameterDirection.Input;
app[2].Value = PageSize;
app[2].Direction = ParameterDirection.Input;
DataSet ds = new DAL.stuDAL().show("P_Lianxi", app);
dataGridView1.DataSource = ds.Tables[0];
}
private void fen_Load(object sender, EventArgs e)
{
count = new DAL.stuDAL().cou();
PageIndex = (int)(Math.Ceiling(Convert.ToDouble(count) / PageSize));
for (int i = 1; i <=PageIndex; i++)
{
comboBox1.Items.Add(i);
}
comboBox1.Text = "1";
Bind(0, "");
}
/// <summary>
/// 首页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
comboBox1.Text = "1";
Bind(0, "");
}
/// <summary>
/// 尾页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button4_Click(object sender, EventArgs e)
{
var row = (int)(Math.Ceiling(Convert.ToDouble(count) / PageSize));
Bind((row - 1) * 4, "");
comboBox1.Text = row.ToString();
}
/// <summary>
/// 下一页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
int page = Convert.ToInt32(comboBox1.Text);
PageIndex = (int)(Math.Ceiling(Convert.ToDouble(count) / PageSize));
if (page < PageIndex)
{
comboBox1.Text = (page + 1).ToString();
Bind((Convert.ToInt32(comboBox1.Text) - 1) * 4, "");
}
}
/// <summary>
/// 上一页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button3_Click(object sender, EventArgs e)
{
int page = Convert.ToInt32(comboBox1.Text);
if (page!=1)
{
comboBox1.Text = (page -1).ToString();
Bind((Convert.ToInt32(comboBox1.Text) - 1) * 4, "");
}
}
}
}
分页的个数
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
using System.Data;
namespace DAL
{
public class stuDAL
{
public MySqlConnection conn = new MySqlConnection("database = 'lianxi'; data source = 'localhost'; user id = 'root'; password='1234';charset='utf8';pooling=true");
public DataSet show(string name, params MySqlParameter[] par)
{
MySqlCommand cmd = new MySqlCommand(name,conn);
cmd.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
MySqlDataAdapter data = new MySqlDataAdapter();
if (par == null)
{
return null;
}
foreach (MySqlParameter item in par)
{
cmd.Parameters.Add(item);
}
conn.Open();
cmd.ExecuteNonQuery();
data.SelectCommand = cmd;
data.Fill(ds, name);
data.Dispose();
conn.Close();
conn.Dispose();
return ds;
}
public int cou()
{
string sql = " SELECT COUNT(1) from lianxiinfo ";
conn.Open();
MySqlCommand cmd = new MySqlCommand(sql, conn);
object i = cmd.ExecuteScalar();
conn.Close();
return Convert.ToInt32(i);
}
}
}
API
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Model;
namespace WebApplicationDB2.Controllers
{
public class showApiController : ApiController
{
/// <summary>
/// 显示全部
/// </summary>
/// <returns></returns>
// GET: api/showApi
[HttpGet]
public List<stuModel> show(string name = "", int type = 1)
{
var p = new BLL.stuBLL().show(name,type);
return p.ToList();
}
/// <summary>
/// 显示下拉
/// </summary>
/// <returns></returns>
[HttpGet]
public List<stuType> xia()
{
var p = new BLL.stuBLL().xia();
return p.ToList();
}
/// <summary>
/// 一条数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
public List<stuModel> dan(int id)
{
var p = new BLL.stuBLL().dan(id);
return p.ToList();
}
/// <summary>
/// 添加
/// </summary>
/// <param name="m"></param>
/// <returns></returns>
// GET: api/showApi/5
[HttpPost]
public int add(stuModel m)
{
var p = new BLL.stuBLL().add(m);
return p;
}
/// <summary>
/// 删除
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpDelete]
public int shan(string id)
{
var p = new BLL.stuBLL().shan(id);
return p;
}
/// <summary>
/// 修改
/// </summary>
/// <param name="m"></param>
/// <returns></returns>
[HttpPut]
public int xiu(stuModel m)
{
var p = new BLL.stuBLL().xiu(m);
return p;
}
}
}
配置
config.Routes.MapHttpRoute(
name: "actionApi",
routeTemplate: "actionApi/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
WindowsForms 调用API的更多相关文章
- C#中调用API
介绍 API( Application Programming Interface ),我想大家不会陌生,它是我们Windows编程的常客,虽然基于.Net平台的C#有了强大的类库,但是,我们还是不能 ...
- [转]c#调用API截图
转自http://blog.csdn.net/hailiannanhai/article/details/6281471 要想完成这个功能,首先要了解一下在C#中如何调用API(应用程序接口)函数.虽 ...
- 一个 C# 获取高精度时间类(调用API QueryP*)
如果你觉得用 DotNet 自带的 DateTime 获取的时间精度不够,解决的方法是通过调用 QueryPerformanceFrequency 和 QueryPerformanceCounter这 ...
- ABP手机端调用API时的CORS
这个问题其实很早就考虑了,当时因为也没有特别着急去解决这个问题,就一直拖着.... 好吧,拖延症是不好的,所有不懒得做的,终将会逼着你去再很短的时间内去解决问题...实现项目 改写一个已有的webfo ...
- 调用API函数,在窗口非客户区绘图(通过GetWindowDC获得整个窗口的DC,就可以随意作画了)
http://hi.baidu.com/3582077/item/77d3c1ff60f9fa5ec9f33754 调用API函数,在窗口非客户区绘图 GDI+的Graphics类里有个FromHdc ...
- C#调用API函数EnumWindows枚举窗口的方法
原文 http://blog.csdn.net/dengta_snowwhite/article/details/6067928 与C++不同,C#调用API函数需要引入.dll文件,步骤如下: 1. ...
- 在C#中调用API获取网络信息和流量
原文 在C#中调用API获取网络信息和流量 最近一项目中要求显示网络流量,而且必须使用C#. 事实上,调用 IpHlpApi.dll 的 GetIfTable API 可以轻易获得网络信息和网络流量. ...
- C#区域截图——调用API截图
原文:C#区域截图——调用API截图 前言:截图对于一个C++开发者来说无非是小菜一碟,也有朋友使用C#的 Graphics.CopyFromScreen 方法屏幕操作,作为一名整天想着用 C++ 开 ...
- HttpClient调用api
/// <summary> /// 模拟调用API /// </summary> /// <param requestUrl="">请求地址&l ...
随机推荐
- Nginx技术研究系列7-Azure环境中Nginx高可用性和部署架构设计
前几篇文章介绍了Nginx的应用.动态路由.配置.在实际生产环境部署时,我们需要同时考虑Nginx的高可用性和部署架构. Nginx自身不支持集群以保证自身的高可用性,商业版本的Nginx+推荐: T ...
- Class_fifth
1,统计文件夹的文件总数 代码: package Class_fifth; import java.io.File; public class Statistics { public static v ...
- C/C++ strict-aliasing
最近发现了一个奇怪的编译参数-fno-strict-aliasing,好奇之下做了一点研究: 重点参考Understanding C/C++ Strict Aliasing: 所谓的aliasing就 ...
- java41 类的高级概念
- mac 遇到的奇怪问题?
1: 卸载 xcode,发现git报错了. mac git xcrun error active developer path 错误 解决办法:sudo xcode-select -switch / ...
- Git冲突和解决冲突-测试方法
原文链接:https://www.cnblogs.com/blogslee/p/6828659.html
- innoDB锁小结
innodb的锁分两类:lock和latch. 其中latch主要是保证并发线程操作临界资源的正确性,要求时间非常短,所以没有死锁检测机制.latch包括mutex(互斥量)和rwlock(读写锁). ...
- 牛客练习赛26—D xor序列 —线性基
这是我第一次写关于线性基的题目.其实这题很好理解,先把给出的数能异或出的值给存在p数组里面,p[i]代表着该异或出的数的最高位为第i位且为1. 求出来后,再把x,y处理下,然后直接一位一位的判断是否为 ...
- ORM模型
一.创建及映射(orm_intro_demo文件) 在项目新建App下的models.py文件下新建ORM模型: from django.db import models #如果要将一个普通的类变成一 ...
- Nginx教程--02.Nginx虚拟主机的配置
1.Nginx虚拟主机的配置 1.1 在conf目录下,使用命令 : vim nginx.conf 对上图解释: //全局区 worker _processes 1; //表示当前有1个工作的子进程, ...