本文整理汇总了C#中CsvReader.Any方法的典型用法代码示例。如果您正苦于以下问题:C# CsvReader.Any方法的具体用法?C# CsvReader.Any怎么用?C# CsvReader.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsvReader
的用法示例。
在下文中一共展示了CsvReader.Any方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindTagPeople
public ActionResult FindTagPeople(string text, string tagname)
{
if (!tagname.HasValue())
return Content("no tag");
var csv = new CsvReader(new StringReader(text), false, '\t').ToList();
if (!csv.Any())
return Content("no data");
var line0 = csv.First().ToList();
var names = line0.ToDictionary(i => i.TrimEnd(),
i => line0.FindIndex(s => s == i));
var ActiveNames = new List<string>
{
"First",
"Last",
"Birthday",
"Email",
"CellPhone",
"HomePhone",
};
var hasvalidcolumn = false;
foreach (var name in names.Keys)
if (ActiveNames.Contains(name))
{
hasvalidcolumn = true;
break;
}
if (!hasvalidcolumn)
return Content("no valid column");
var list = new List<FindInfo>();
foreach (var a in csv.Skip(1))
{
var row = new FindInfo();
row.First = FindColumn(names, a, "First");
row.Last = FindColumn(names, a, "Last");
row.Birthday = FindColumnDate(names, a, "Birthday");
row.Email = FindColumn(names, a, "Email");
row.CellPhone = FindColumnDigits(names, a, "CellPhone");
row.HomePhone = FindColumnDigits(names, a, "HomePhone");
var pids = DbUtil.Db.FindPerson3(row.First, row.Last, row.Birthday, row.Email, row.CellPhone, row.HomePhone, null);
row.Found = pids.Count();
if (row.Found == 1)
row.PeopleId = pids.Single().PeopleId.Value;
list.Add(row);
}
var q = from pi in list
where pi.PeopleId.HasValue
select pi.PeopleId;
foreach (var pid in q.Distinct())
Person.Tag(DbUtil.Db, pid.Value, tagname, Util.UserPeopleId, DbUtil.TagTypeId_Personal);
DbUtil.Db.SubmitChanges();
return View(list);
}
示例2: FindTagPeople
public static List<FindInfo> FindTagPeople(string text, string tagname)
{
if (!tagname.HasValue())
throw new UserInputException("No Tag");
var csv = new CsvReader(new StringReader(text), true, '\t');
if (!csv.Any())
throw new UserInputException("No Data");
var cols = csv.GetFieldHeaders();
if (!cols.Contains("First") || !cols.Contains("Last"))
throw new UserInputException("Both First and Last are required");
if (!cols.Any(name => new[] { "Birthday", "Email", "Phone", "Phone2", "Phone3" }.Contains(name)))
throw new UserInputException("One of Birthday, Email, Phone, Phone2 or Phone3 is required");
var list = new List<FindInfo>();
while (csv.ReadNextRecord())
{
var row = new FindInfo
{
First = FindColumn(csv, "First"),
Last = FindColumn(csv, "Last"),
Birthday = FindColumnDate(csv, "Birthday"),
Email = FindColumn(csv, "Email"),
Phone = FindColumnDigits(csv, "Phone"),
Phone2 = FindColumnDigits(csv, "Phone2"),
Phone3 = FindColumnDigits(csv, "Phone3")
};
var pids = DbUtil.Db.FindPerson3(row.First, row.Last, row.Birthday, row.Email,
row.Phone, row.Phone2, row.Phone3).ToList();
row.Found = pids.Count;
if(pids.Count == 1)
row.PeopleId = pids[0].PeopleId;
list.Add(row);
}
var q = from pi in list
where pi.PeopleId.HasValue
select pi.PeopleId;
foreach (var pid in q.Distinct())
Person.Tag(DbUtil.Db, pid ?? 0, tagname, Util.UserPeopleId, DbUtil.TagTypeId_Personal);
DbUtil.Db.SubmitChanges();
return list;
}