日期:2014-05-20 浏览次数:20935 次
DataSet ds = new DataSet(); string explorerdata = @"SELECT TMPLOGID, APP, FILENAME, OPERATOR, FILESIZE, AUTHOR, LOGTIME, OTHER, LOGSEQUENCE, ISANALYSIS FROM TB_TMPLOG WHERE 1=1 and LogTime>='{0}' and LogTime<='{1}' and Author='{2}' and app='explorer.exe' and decode(isanalysis,null,0,1)=0"; explorerdata = string.Format(explorerdata, beginDate, endDate, userid); ds = getDataSetBySQL(explorerdata);//获取临时日志表数据 DataTable dt = ds.Tables[0]; //DataRow rowT = t.Rows[0]; //object obj = rowT[6]; //DateTime dt = Convert.ToDateTime(obj); //string strTime = dt.Year + "-" + dt.Month + "-" + dt.Day + " " + dt.TimeOfDay; /*end 获取临时日志表数据*/ /*处理数据*/ if (dt.Rows.Count < 1)//没数据则继续循环 continue; string operators = null; string filenames = null; string sizes = null; string strdate = null; string logids = null; var query1 = from pl in dt.AsEnumerable() orderby pl.Field<decimal>("logsequence") group pl by pl.Field<string>("logtime") into temppl select new { Desc = temppl.Key, Total = temppl.Count(), detail = temppl, AA = temppl.ToArray() };
------解决方案--------------------
排序可以用集合呀。
但我也想把代码写成可复用的。
#region T1字符串
public static void TTT1()
{
List<string> stdList = new List<string>() { "3" };
List<string> recordList = new List<string>() { "1", "0", "1", "3", "5", "1", "3", "0", "1", "3", "0", "1", "3", "1", "3", "0" };
List<string> nextList = FindNext(stdList, recordList);
foreach (var item in nextList)
{
Console.WriteLine(item.ToString());
}
}
/// <summary>
/// 字符串
/// </summary>
/// <param name="stdList"></param>
/// <param name="recordList"></param>
/// <returns></returns>
public static List<string> FindNext(List<string> stdList, List<string> recordList)
{
List<string> lstNext = new List<string>();
int La = 0;
string[] stArr = stdList.ToArray();
foreach (var item in recordList)
{
Console.Write(" : " + item.ToString());
int vResult = 0;
for (int i = 0; i < stArr.Length; i++)