求文件分类操作方法 现在有很多文件需要操作,文件可以大致分为4类,怎么将他们分类,进行相应操作,请各位说说想法 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 linq to dataset: if (dt.Rows.Count > 0)//有数据才进行操作 { string other = null; 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"), pl.Field<string>("logtime") group pl by pl.Field<string>("logtime") into temppl select new { Desc = temppl.Key, Total = temppl.Count(), detail = temppl, AA = temppl.ToArray() }; var query2 = query1; /*********准备数据**********************************************************************/ string oper1 = null; string ids1 = null; string date1 = null; string size1 = null; string fpname1 = null; string other1 = null; List<string> Lopcr = new List<string>();//opencreate List<string> Ldelete = new List<string>();//delete List<string> LdeleteLeft = new List<string>(); foreach (var item1 in query1)//筛选出"open,create"和"delete"日志 { if (item1.Total == 2 || item1.Total == 1) { oper1 = null;//清除历史数据 ids1 = null;//清除历史数据 date1 = null;//清除历史数据 size1 = null;//清除历史数据 other1 = null; fpname1 = null; DataRow[] a = (DataRow[])item1.AA;//分组 for (int i = 0; i < a.Length; i++) { ids1 = ids1 + a[i].Field<string>("tmplogid") + "*"; oper1 = oper1 + a[i].Field<string>("operator") + "*"; fpname1 = fpname1 + a[i].Field<string>("filename") + "*"; size1 = size1 + a[i].Field<string>("filesize") + "*"; date1 = date1 + a[i].Field<string>("logtime") + "*"; other1 = other1 + a[i].Field<string>("other") + "*"; }//end for (int i = 0; i < a.Length; i++) if (item1.Total == 2 && oper1.Trim('*').ToLower() == "open*create") { string tempstr = ids1.Trim('*') + "?" + oper1.Trim('*') + "?" + fpname1.Trim('*') + "?" + size1.Trim('*') + "?" + date1.Trim('*') + "?" + other1.Trim('*'); Lopcr.Add(tempstr); continue; } if (item1.Total == 1 && oper1.Trim('*').ToLower() == "delete") { string tempstr = ids1.Trim('*') + "?" + oper1.Trim('*') + "?" + fpname1.Trim('*') + "?" + size1.Trim('*') + "?" + date1.Trim('*') + "?" + other1.Trim('*'); Ldelete.Add(tempstr); continue; } }//end if (item1.Total == 2 || item1.Total == 1) }//end foreach (var item1 in query1)//筛选出"open,create".............. "group pl by pl.Field<string>("logtime")"我这句按照时间来分组,logtime相同的会被分在一组里面。 DataRow[] a = (DataRow[])item1.AA;//分组在这里,数组a里全部是logtime相同的数据的记录 字符读取操作,被大括号{}难住了,求解 求MDI主窗体工具栏可分别控制子窗体的方法 求助,OpenFileDialog怎么获取选中N个文件的路径! BasicHttpBinding/EndpointAddress的替代品有吗? 图片放大后坐标问题。急! 用过socket编程的站过来! 如何做frame跳转啊...20分在线着等.. 子类化.net的控件-比如TextBox, ListView等 新年新气象,祝各位在新的一年里,分多多,RMB多多! 求救。请问如何实现导入数据库??? 就是利用Visual Studio开发的KTV项目相关代码 如何把二维数组的一行作为参数传入一个函数?
{
string other = null;
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"), pl.Field<string>("logtime")
group pl by pl.Field<string>("logtime")
into temppl
select new { Desc = temppl.Key, Total = temppl.Count(), detail = temppl, AA = temppl.ToArray() };
var query2 = query1;
/*********准备数据**********************************************************************/ string oper1 = null;
string ids1 = null;
string date1 = null;
string size1 = null;
string fpname1 = null;
string other1 = null;
List<string> Lopcr = new List<string>();//opencreate
List<string> Ldelete = new List<string>();//delete List<string> LdeleteLeft = new List<string>();
foreach (var item1 in query1)//筛选出"open,create"和"delete"日志
{
if (item1.Total == 2 || item1.Total == 1)
{
oper1 = null;//清除历史数据
ids1 = null;//清除历史数据
date1 = null;//清除历史数据
size1 = null;//清除历史数据
other1 = null;
fpname1 = null;
DataRow[] a = (DataRow[])item1.AA;//分组
for (int i = 0; i < a.Length; i++)
{ ids1 = ids1 + a[i].Field<string>("tmplogid") + "*";
oper1 = oper1 + a[i].Field<string>("operator") + "*";
fpname1 = fpname1 + a[i].Field<string>("filename") + "*";
size1 = size1 + a[i].Field<string>("filesize") + "*";
date1 = date1 + a[i].Field<string>("logtime") + "*";
other1 = other1 + a[i].Field<string>("other") + "*"; }//end for (int i = 0; i < a.Length; i++) if (item1.Total == 2 && oper1.Trim('*').ToLower() == "open*create")
{
string tempstr = ids1.Trim('*') + "?" + oper1.Trim('*') + "?" + fpname1.Trim('*') + "?" + size1.Trim('*') + "?" + date1.Trim('*') + "?" + other1.Trim('*');
Lopcr.Add(tempstr);
continue;
} if (item1.Total == 1 && oper1.Trim('*').ToLower() == "delete")
{
string tempstr = ids1.Trim('*') + "?" + oper1.Trim('*') + "?" + fpname1.Trim('*') + "?" + size1.Trim('*') + "?" + date1.Trim('*') + "?" + other1.Trim('*');
Ldelete.Add(tempstr);
continue;
}
}//end if (item1.Total == 2 || item1.Total == 1) }//end foreach (var item1 in query1)//筛选出"open,create"
..............
在这里,数组a里全部是logtime相同的数据的记录