MES总结:CBF.Common 文件Net下的有类型转换。

using System.Text;
using System.Data;
using System.ComponentModel;
using CBF.WMS.Common.Comm;
using CBF.WMS.Common.Constant;
using System.Reflection;
using System.Collections;

namespace CBF.WMS.Common.Net
{
public static class ConvertHelper
{
public static List<M> IListToList<M>(IList<M> tmpList)
{
List<M> list = new List<M>();
foreach (M table in tmpList)
{
list.Add(table);
}
return list;
}

/// <summary>
/// Ilist 转换成 DataTable
/// </summary>
/// <typeparam name="T">数据类型</typeparam>
/// <param name="i_objlist"></param>
/// <returns></returns>
public static DataTable ConvertToDataTable<T>(IList i_objlist)
{
if (i_objlist == null || i_objlist.Count <= 0)
{
return null;
}
DataTable dt = new DataTable(typeof(T).Name);
DataColumn column;
DataRow row;
PropertyInfo[] myPropertyInfo = typeof(T).GetProperties(BindingFlags.Public |
BindingFlags.Instance);
foreach (T t in i_objlist)
{
if (t == null)
{
continue;
}
row = dt.NewRow();
for (int i = 0, j = myPropertyInfo.Length; i < j; i++)
{
PropertyInfo pi = myPropertyInfo[i];
string name = pi.Name;
if (dt.Columns[name] == null)
{
column = new DataColumn(name, pi.PropertyType);
dt.Columns.Add(column);
}
row[name] = pi.GetValue(t, null);
}
dt.Rows.Add(row);
}
return dt;
}

public static DataTable ToDataTable(IList list)
{
DataTable result = new DataTable();

if (list.Count > 0)
{
PropertyInfo[] propertys = list[0].GetType().GetProperties();

foreach (PropertyInfo pi in propertys)
{

result.Columns.Add(pi.Name, pi.PropertyType);

}

for (int i = 0; i < list.Count; i++)
{

ArrayList tempList = new ArrayList();

foreach (PropertyInfo pi in propertys)
{

object obj = pi.GetValue(list[i], null);

tempList.Add(obj);

}

object[] array = tempList.ToArray();

result.LoadDataRow(array, true);

}
}
return result;

}

public static IList<T> ConvertListToIList<T>(
IList source
)
{
T[] output = new T[source.Count];
source.CopyTo(output, 0);
return output;
}

public static DataTable CreateTable<T>()
{
Type entityType = typeof(T);
DataTable table = new DataTable(entityType.Name);
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(entityType);
foreach (PropertyDescriptor prop in properties)
{
table.Columns.Add(prop.Name, prop.PropertyType);
}
return table;
}

public static T CreateItem<T>(DataRow row)
{
T obj = default(T);
if (row != null)
{
obj = Activator.CreateInstance<T>();

foreach (DataColumn column in row.Table.Columns)
{
PropertyInfo prop = obj.GetType().GetProperty(column.ColumnName);
try
{
object value = row[column.ColumnName];
prop.SetValue(obj, value, null);
}
catch (Exception ex)
{
// You can log something here
CLog.WriteLog(CMessage.ERR, ex);
throw;
}
}
}
return obj;
}

/// <summary>
/// 转换DataTa为IList<T>泛型
/// </summary>
/// <typeparam name="T">泛型类型</typeparam>
/// <param name="table">所需转换DataTab</param>
/// <returns>IList<T></returns>
public static IList<T> DataTableToList<T>(DataTable table)
{
if (table == null)
{
return null;
}
List<DataRow> rows = new List<DataRow>();

foreach (DataRow row in table.Rows)
{
rows.Add(row);
}
return ConvertTo<T>(rows);
}

public static IList<T> ConvertTo<T>(IList<DataRow> rows)
{
IList<T> list = null;
if (rows != null)
{
list = new List<T>();
foreach (DataRow row in rows)
{
T item = CreateItem<T>(row);
list.Add(item);
}
}
return list;
}

/// <summary>
/// 转换IList<T>为DataTable
/// </summary>
/// <typeparam name="T">泛型类型</typeparam>
/// <param name="list">泛型List集合</param>
/// <returns>Datatable 对象</returns>
public static DataTable ListToDataTable<T>(IList<T> list)
{
DataTable table = CreateTable<T>();
Type entityType = typeof(T);
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(entityType);
foreach (T item in list)
{
DataRow row = table.NewRow();
foreach (PropertyDescriptor prop in properties)
{
row[prop.Name] = prop.GetValue(item);
}
table.Rows.Add(row);
}
return table;
}

}
}

=============================递归菜单的应用(CBF.DAL.BaseInfo下的Bom_DAL.cs)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CBF.Model;
using NHibernate;
using NHibernate.Linq;
using System.Data;
using System.Collections;
using CBF.DataAccess;
using CBF.Integration;
using NHibernate.Criterion;
using CBF.Common.Constant;
using CBF.Common.Comm;

namespace CBF.DAL.BaseInfo
{

public class BOM_DAL : BaseDAL<BOM>
{
/// <summary>
/// 根据ID取表
/// </summary>
/// <param name="id">ID</param>
/// <returns>表</returns>
public CBF.Model.BOM GetBOMById(int id)
{
try
{
if (!this._session.IsOpen) this._session = NhbHelper.GetCurrentSession();
return this._session.Get<BOM>(id);
}
catch (Exception ex)
{
CLog.WriteLog(CMessage.ERR, ex);
}
return Activator.CreateInstance<BOM>();
}

public DataTable SelectStationList(string lanText)
{
string strSQL = "";
strSQL = @"select StaCode, StaName from mes_station";

DataTable dtTmp = SQLHelper.ExecuteDataTable(CommonInfo.Instance.DefaultConnectString,
strSQL);
return dtTmp;

}
public DataTable SelectMaterialList(string MaterialNO)
{
string strSQL = "";
strSQL = @"select distinct MaterialNO, MaterialName from MES_MaterialPacket where ('' = @MaterialNO or MaterialNO = @MaterialNO1)";
DataTable dtTmp = SQLHelper.ExecuteDataTable(CommonInfo.Instance.DefaultConnectString,
strSQL, new object[] { MaterialNO, MaterialNO });
return dtTmp;

}
public DataTable SelectItemList(string lanText)
{
string strSQL = "";
strSQL = @"select ItemNO, ItemName from mes_item";

DataTable dtTmp = SQLHelper.ExecuteDataTable(CommonInfo.Instance.DefaultConnectString,
strSQL);
return dtTmp;

}

public DataTable GetBomList(string prefix, string flag)
{
string strSQL = "";
if (flag == "like")
{
strSQL = string.Format(@"select * from MES_BOM where BOMNO like '{0}'", prefix);
}
else
{
strSQL = string.Format("select * from MES_BOM where BOMNO='{0}'", prefix);
}
DataTable dtTmp = SQLHelper.ExecuteDataTable(CommonInfo.Instance.DefaultConnectString, strSQL);
return dtTmp;
}

/// <summary>
/// 执行传入的SQL
/// </summary>
public int exeERPBOM(string strSQL)
{
return SQLHelper.ExecuteNoneQuery(CommonInfo.Instance.DefaultConnectString,
strSQL);
}

/// <summary>
/// 执行传入的SQL
/// </summary>
public DataTable LoadERPBOM(string strSQL)
{
return SQLHelper.ExecuteDataTable(CommonInfo.Instance.DefaultConnectString,
strSQL);
}

/// <summary>
/// 最大子表ID号
/// </summary>
public DataRow GetMaxChildID()
{
string strSQL = @"select Id = isnull(max(id),1)+1 from mes_subitem ";
return SQLHelper.ExecuteDataRow(CommonInfo.Instance.DefaultConnectString,
strSQL);
}

/// <summary>
/// 删除子表记录
/// </summary>
public int DeleteChildDetailInfo(int ID)
{
string strSQL = @"delete mes_bomchild where ID = @ID";
return SQLHelper.ExecuteNoneQuery(CommonInfo.Instance.DefaultConnectString,
strSQL, new object[] { ID });
}

/// <summary>
///删除BOM结构
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataTable DeleteBOM(string[] aIDList)
{
string strSQL = string.Format("delete MES_BOM where BOMNO in (select BOMNO from MES_BOM where Id in ('{0}')) ", String.Join("','", aIDList));
DataTable dtTmp = SQLHelper.ExecuteDataTable(CommonInfo.Instance.DefaultConnectString,
strSQL);
return dtTmp;
}

/// <summary>
/// Insert into Route
/// </summary>
public int ChangeBOMInfo(BOM m_BOM, DataTable tblChild, Boolean IsUpdate, string @User)
{
int Flag = 0;
try
{
try
{
Begin();

SaveOrUpdate(m_BOM);

//插入从表
foreach (DataRow dr in tblChild.Rows)
{
BOMChild bomChild = new BOMChild();
if (dr.RowState == DataRowState.Added)
{
}
else
{
bomChild = GetTableById<BOMChild>(dr["id"].ToString());
}

bomChild.ParentNO = m_BOM.BOMNO;
bomChild.ItemNO = dr["ItemNO"].ToString();
//bomChild.ItemName = dr["ItemName"].ToString();
if (dr["Qty"] != null)
{
bomChild.Qty = Convert.ToInt32(dr["Qty"]);
}
bomChild.Unit = dr["Unit"].ToString();
bomChild.StaCode = dr["StaCode"].ToString();
bomChild.Specification = dr["Specification"].ToString();
if (dr["Scrap"] != null)
{
bomChild.Scrap = Convert.ToDouble(dr["Scrap"]);
}
bomChild.Remark = dr["remark"].ToString();
SaveOrUpdate(bomChild);
}
if (Commit() == true)
{
Flag = 1;
}
}
catch (Exception e)
{
Rollback();
}
}
catch (Exception e)
{
Flag = 0;
}
return Flag;
}

/// <summary>
/// 获取替换子表记录
/// </summary>
public DataTable SelectSubChildInfo(string bomNO,string itemNo)
{
string strSQL = @"select BOMNO,id,ItemNO,SubItemId,SubItemName, CheckDate,CheckMan,InvalidDate,State,remark
from Mes_subitem
where BOMNO = @bomNO and Itemno=@Subitemid
order by ID ";
DataTable dtTmp = SQLHelper.ExecuteDataTable(CommonInfo.Instance.DefaultConnectString,
strSQL, new object[] { bomNO, itemNo });
return dtTmp;

}

/// <summary>
/// 最大替换子表ID号
/// </summary>
public DataRow GetSubMaxChildID()
{
string strSQL = @"select Id = isnull(max(id),1)+1 from mes_bomchild ";
return SQLHelper.ExecuteDataRow(CommonInfo.Instance.DefaultConnectString,
strSQL);
}

/// <summary>
/// 根据物料编号获取BOM信息
/// </summary>
public DataTable GetBomByItemNo(string itemNo)
{
string strSQL = @"select * from dbo.MES_BOM where itemno=@ItemNo";
return SQLHelper.ExecuteDataTable(CommonInfo.Instance.DefaultConnectString,
strSQL, itemNo);
}

/// <summary>
/// 删除物料替换子表记录
/// </summary>
public int DeleteSubChildInfo(int ID)
{
string strSQL = @"delete mes_subitem where id = @Id";
return SQLHelper.ExecuteNoneQuery(CommonInfo.Instance.DefaultConnectString,
strSQL, new object[] { ID });
}

/// <summary>
/// 删除物料替换子表记录
/// </summary>
public int DeleteAllSubChildInfo(string bomNo, string subItemId)
{
string strSQL = @"delete mes_subitem where bomno=@BOMNo and subItemId = @subItemId";
return SQLHelper.ExecuteNoneQuery(CommonInfo.Instance.DefaultConnectString,
strSQL, new object[] { bomNo,subItemId });
}

/// <summary>
/// Insert into Route
/// </summary>
public int ChangeSubInfo(BOM m_BOM, DataTable tblChild, Boolean IsUpdate, string @User)
{
int Flag = 0;
try
{
try
{
Begin();

foreach (DataRow dr in tblChild.Rows)
{
SubItem subItem = new SubItem();
if (dr.RowState == DataRowState.Added)
{
subItem.CreateMan = @User;
subItem.CreateTime = DateTime.Now;
}
else
{
subItem = GetTableById<SubItem>(dr["id"].ToString());
subItem.UpdateMan = @User;
subItem.UpdateTime = DateTime.Now;
}
subItem.BOMNO = m_BOM.BOMNO;
subItem.ItemNO = m_BOM.ItemNO;
subItem.SubItemName = dr["SubItemName"].ToString();
if (dr["checkdate"] != null)
{
subItem.CheckDate = Convert.ToDateTime(dr["checkdate"]);
}
subItem.SubItemId = dr["subitemid"].ToString();
if (dr["InvalidDate"] != null)
{
try
{
subItem.InvalidDate = Convert.ToDateTime("2059-12-31");
}
catch (Exception) { }

}
subItem.State = Convert.ToBoolean(dr["State"]);
subItem.Remark = dr["remark"].ToString();
subItem.CheckMan = dr["CheckMan"].ToString();
if (dr.RowState == DataRowState.Added)
{
subItem.CreateMan = @User;
subItem.CreateTime = DateTime.Now;
}
else
{
SubItem anothersubItem = GetTableById<SubItem>(dr["id"].ToString());
subItem.CreateMan = anothersubItem.CreateMan;
subItem.CreateTime = anothersubItem.CreateTime;
subItem.UpdateMan = @User;
subItem.UpdateTime = DateTime.Now;
}

SaveOrUpdate(subItem);
}
if (Commit() == true)
{
Flag = 1;
}
}
catch (Exception e)
{
Rollback();
}
}
catch (Exception e)
{
Flag = 0;
}
return Flag;
}

/// <summary>
/// 添加或更新替代料到所有的BOM含有这个物料的资料
/// </summary>
public int ChangeAllSubInfo(BOM m_BOM, DataTable tblChild, Boolean IsUpdate, string @User)
{
int Flag = 0;
try
{
try
{
//Begin();

DataTable bomDt = GetBomByItemNo(m_BOM.ItemNO);

for (int i = 0; i < bomDt.Rows.Count; i++)
{
foreach (DataRow dr in tblChild.Rows)
{
DeleteAllSubChildInfo(bomDt.Rows[i]["BOMNO"].ToString(),dr["subitemid"].ToString());
SubItem subItem = new SubItem();
//if (dr.RowState == DataRowState.Added)
//{
subItem.CreateMan = @User;
subItem.CreateTime = DateTime.Now;
//}
//else
//{
// DataTable dtSubItem = GetSubItem(bomDt.Rows[i]["BOMNO"].ToString(), dr["subitemid"].ToString());

// if (dtSubItem.Rows.Count > 0)
// {
// subItem.CreateMan = dtSubItem.Rows[0]["CreateMan"].ToString();
// subItem.CreateTime = Convert.ToDateTime(dtSubItem.Rows[0]["CreateTime"]);
subItem.UpdateMan = @User;
subItem.UpdateTime = DateTime.Now;
// }
//}
subItem.BOMNO = bomDt.Rows[i]["BOMNO"].ToString();
subItem.ItemNO = m_BOM.ItemNO;
subItem.SubItemName = dr["SubItemName"].ToString();
if (dr["checkdate"] != null)
{
subItem.CheckDate = Convert.ToDateTime(dr["checkdate"]);
}
subItem.SubItemId = dr["subitemid"].ToString();
if (dr["InvalidDate"] != null)
{
try
{
subItem.InvalidDate = Convert.ToDateTime("2059-12-31");
}
catch (Exception) { }

}
subItem.State = Convert.ToBoolean(dr["State"]);
subItem.Remark = dr["remark"].ToString();
subItem.CheckMan = dr["CheckMan"].ToString();

DSaveOrUpdate<SubItem>(subItem);
}
}
//if (Commit() == true)
//{
Flag = 1;
//}
}
catch (Exception e)
{
//Rollback();
Flag = 0;
}
}
catch (Exception e)
{
Flag = 0;
}
return Flag;
}

/// <summary>
/// 递归显示BOM树
/// </summary>
/// <param name="bom"></param>
/// <param name="nodes"></param>
public void ShowBOM(IList<CBF.Model.BOM> boms, IList<CBF.Model.BOMDisplay> listBoms,int parentId)
{
foreach (var b in boms)
{
BOMDisplay bOMToBOMDisplay = BOMToBOMDisplay(b, listBoms,parentId);
listBoms.Add(bOMToBOMDisplay);

//ICriteria criteria = this._session.CreateCriteria(typeof(CBF.Model.BOM));

//criteria.Add(Expression.In("ParentId", new List<string>() { b.Id.ToString() }));
string strSQL = string.Format(@"if exists(select * from mes_bom where parentid ='{0}')
begin
select * from mes_bom where parentid ='{1}'
end
else if exists(select * from MES_BOM where ItemNO = '{2}' and ParentID = 0)
begin
select * from MES_BOM where ParentID in(select ID from MES_BOM where ItemNO = '{3}' and ParentID = 0)
end
else
select * from mes_bom where parentid ='{4}'

", b.Id, b.Id, b.ItemNO, b.ItemNO,b.Id);

IList<CBF.Model.BOM> iboms = _session.CreateSQLQuery(strSQL).AddEntity(typeof(BOM)).List<BOM>();

if (iboms.Count > 0)
{
ShowBOM(iboms, listBoms, bOMToBOMDisplay.IId);
}

}
}

public DataTable GetSubItem(string BomNo, string ItemNO)
{
string strSQL = "select * from MES_SubItem where bomno=@BomNo and SubItemId=@ItemNo";

DataTable dtTmp = SQLHelper.ExecuteDataTable(CommonInfo.Instance.DefaultConnectString,
strSQL, new object[] { BomNo, ItemNO });
return dtTmp;
}

/// <summary>
/// 判断bom里面是否已存在当前物料
/// </summary>
/// <param name="BomNo">bom编号</param>
/// <param name="ItemNO">物料编号</param>
/// <returns></returns>
public DataTable ItemIsExist(string BomNo,string ItemNO)
{
string strSQL = "select * from dbo.FN_GetBOM (@BomNo, @ItemNo)";

DataTable dtTmp = SQLHelper.ExecuteDataTable(CommonInfo.Instance.DefaultConnectString,
strSQL, new object[] { BomNo,ItemNO });
return dtTmp;
}

/// <summary>
/// 获取ID获取根BOM
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public IList<CBF.Model.BOM> GetRootBOM(string id)
{
return _session.CreateSQLQuery("select * from mes_bom where parentid = '" + id + "'").AddEntity(typeof(BOM)).List<BOM>();
}

/// <summary>
/// BOM转换成BOMDisplay
/// </summary>
/// <param name="bom"></param>
/// <param name="boms"></param>
/// <param name="parentId"></param>
/// <returns></returns>
public BOMDisplay BOMToBOMDisplay(BOM bom, IList<BOMDisplay> boms,int parentId)
{
BOMDisplay bomDis = new BOMDisplay();
bomDis.IId = boms.Count + 1;
bomDis.Id = bom.Id;
bomDis.ItemNO = bom.ItemNO;
bomDis.ItemName = bom.ItemName;
bomDis.Unit = bom.Unit;
bomDis.Qty = bom.Qty;
bomDis.Yield = bom.Yield;
bomDis.Scrap = bom.Scrap;
bomDis.ParentId = parentId;

return bomDis;
}

/// <summary>
/// 批量删除
/// </summary>
/// <param name="ids">列表</param>
/// <returns>是否删除成功</returns>
public bool DDelete(int[] ids)
{
if (!this._session.IsOpen) this._session = NhbHelper.GetCurrentSession();
using (ITransaction tran = _session.BeginTransaction())
{
try
{
foreach (int id in ids)
{
BOM table = this._session.Get<BOM>(id);
if (!table.IsNull())
{
this._session.Delete(table);
}
}
this._session.Flush();
tran.Commit();
return true;
}
catch (Exception ex)
{
CLog.WriteLog(CMessage.ERR, ex);
tran.Rollback();
return false;
}
}
}

/// <summary>
/// 删除表(自动生成事务)
/// </summary>
/// <param name="id">ID</param>
public bool DDelete(int id)
{
if (!this._session.IsOpen) this._session = NhbHelper.GetCurrentSession();
using (ITransaction tran = _session.BeginTransaction())
{
try
{
BOM table = this._session.Get<BOM>(id);
if (!table.IsNull())
{
this._session.Delete(table);
this._session.Flush();
tran.Commit();
}
return true;
}
catch (Exception ex)
{
CLog.WriteLog(CMessage.ERR, ex);
tran.Rollback();
return false;
}
}
}
}
}

MES总结:CBF.Common 文件Net下的有类型转换的更多相关文章

  1. 安装myeclipse10后破解时发现没有common文件夹

    今天重新安装了myeclipse10软件,然后在破解的时候发现安装目录下没有common,这是因为以前安装过myeclipse,卸载时没有完全清除,再次安装时,myeclipse会自动找到以前安装的c ...

  2. Caffe源码中common文件分析

    Caffe源码(caffe version:09868ac , date: 2015.08.15)中的一些重要头文件如caffe.hpp.blob.hpp等或者外部调用Caffe库使用时,一般都会in ...

  3. WINDOWS批量替换不同文件夹下的相同文件

    今天帮媳妇解决的问题,记录一下,也许以后有用 例子: N个文件夹下有同一个文件(common.php),但是,现在对common.php文件进行了大量修改. 现在想用最新的common.php替换掉所 ...

  4. GreenDao 数据库:使用Raw文件夹下的数据库文件以及数据库升级

    一.使用Raw文件夹下的数据库文件 在使用GreenDao框架时,数据库和数据表都是根据生成的框架代码来自动创建的,从生成的DaoMaster中的OpenHelper类可以看出: public sta ...

  5. 脚本工具(获取某个文件夹下的所有图片属性批量生成css样式)

    问题描述: 由于有一次工作原因,就是将某个文件夹下的所有图片,通过CSS描述他们的属性,用的时候就可以直接引用.但是我觉得那个文件夹下的图片太多,而且CSS文件的格式又有一定的规律,所有想通过脚本来生 ...

  6. 使用Dir,遍历文件夹下所有子文件夹及文件

    '------------------------------------------- '获取某文件夹下所有文件和子目录下的文件 '--------------------------------- ...

  7. 怎么统计指定文件夹下含有.xml格式的文件数目

    如何统计指定文件夹下含有.xml格式的文件数目?如题 ------解决思路----------------------Directory.GetFiles(@"路径", " ...

  8. C#遍历文件夹下所有文件

    FolderForm.cs的代码如下: using System; using System.Collections.Generic; using System.Diagnostics; using ...

  9. python 替换 文件夹下的 文件名称 及 文件内容

    示例效果: 1.替换某文件夹下的 文件夹及子文件夹 的名称 由OldStrDir 变为 NewStrDir: 2.替换某文件夹下的 文件夹及子文件夹 下 所有的文件的名称 由OldStrFile 变为 ...

随机推荐

  1. UVa725 - Division

    #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; int ...

  2. 【英语】Bingo口语笔记(48) - 关于春节的表达

  3. Android中的事件分发和处理

    上次跟大家分享了一下自定义View的一下要点,这次跟大家聊一下View的事件分发及处理,为什么主题都是View,因为作为一名初级应用层Android工程师,跟我打交道最多的莫过于各种各样的View,只 ...

  4. Jquery Mobile设计Android通讯录第二章

    本文是jQuery Mobile设计Android通讯录系统教程的第二篇,在上一篇教程中(http://publish.itpub.net/a2011/0517/1191/000001191561.s ...

  5. IRequiresSessionState和IReadOnlySessionState应用上的一些差异

    在调用ashx时,如果需要应用Session,则必须继承接口 IRequiresSessionState,IReadOnlySessionState,但根据字面,可以知道 IRequiresSessi ...

  6. Linux基本命令(9)定位、查找文件的命令

    定位.查找文件的命令 命令 功能 命令 功能 which 从path中找出文件的位置 find 找出所有符合要求的文件 whereis 找出特定程序的路径 locate 从索引中找出文件位置 9.1 ...

  7. 组建自动化工具Ant

    组建自动化工具Ant Ant可以帮助我们自动化的完成项目的构建 下面是维基百科对Ant的介绍:http://zh.wikipedia.org/wiki/Apache_Ant Apache Ant,是一 ...

  8. WebApi参数传递

    c# webapi的参数传递方式:1.查询字符串(query string):2.内容主体(content body) 当然也有cookie或url部分或头部信息(header)等其它传方式,这里仅讨 ...

  9. Redis批量导入数据

    首先准备数据文件 格式为 SET Key0 Value0 SET Key1 Value1 ... SET KeyN ValueN 利用shell转换数据 #!/bin/bash while read ...

  10. PHP强大的内置filter (二) 完

    <?php #Sanitize filters #Sanitize filters 可以清理掉不规范的字符 # FILTER_SANITIZE_EMAIL 可以清理除了 字母和数字 以及 !#$ ...