本文整理匯總了C#中Service.List.First方法的典型用法代碼示例。如果您正苦於以下問題:C# List.First方法的具體用法?C# List.First怎麽用?C# List.First使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Service.List
的用法示例。
在下文中一共展示了List.First方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetSomething
public Playlist GetSomething(string some)
{
List<Playlist> list = new List<Playlist>();
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
path = Path.Combine(path, "AudioStreamer");
if (Directory.Exists(path))
{
var l = Directory.GetFileSystemEntries(path, "*.xml");
foreach (var s in l)
{
var x = s.Substring(s.LastIndexOf("\\")+1, s.Length - s.LastIndexOf("\\") - 5);
Playlist p = new Playlist { FriendlyName = x, Path = s, Songs = new List<Song>()};
DataSet d = new DataSet();
DataTable Playlist = new DataTable();
d.ReadXml(s);
if (d.Tables.Contains("BasePlaylist"))
{
Playlist = d.Tables["BasePlaylist"];
}
Playlist.PrimaryKey = new[] { Playlist.Columns["Path"] };
int track;
foreach (DataRow row in Playlist.Rows)
{
p.Songs.Add(new Song
{
Album = row["Album"].ToString(),
Artist = row["Artist"].ToString(),
Genre = row["Genre"].ToString(),
StringLength = row["Length"].ToString(),
Path = row["Path"].ToString().Replace("\\", "|"),
Title = row["Title"].ToString(),
Track = int.TryParse(row["Track"].ToString(), out track) ? track : 0
});
}
list.Add(p);
}
}
list.First().Path = list.First().Path.Replace("\\","|");
return list.First();
}
示例2: Edit
public ActionResult Edit(SequenceGroup sequenceGroup)
{
ViewBag.HaveEditPrevTraceCode = CurrentUser.Permissions.Where(p => p.PermissionCode == "Url_SequenceGroup_EditPrevTraceCode").Count() > 0;
if (ModelState.IsValid)
{
bool noenError = true;
if (!ViewBag.HaveEditPrevTraceCode && !string.IsNullOrWhiteSpace(sequenceGroup.PreviousTraceCode))
{
SaveErrorMessage("您沒有修改前個Van號的權限。");
noenError = false;
}
if (sequenceGroup.IsActive && string.IsNullOrWhiteSpace(sequenceGroup.PreviousTraceCode))
{
SaveErrorMessage("排序組有效的情況下,前麵Van號不能為空。");
noenError = false;
}
IList<OrderSeq> orderSeqs = new List<OrderSeq>();
if (!string.IsNullOrWhiteSpace(sequenceGroup.PreviousTraceCode))
{
orderSeqs = this.genericMgr.FindAll<OrderSeq>("select o from OrderSeq as o where o.ProductLine=? and o.TraceCode=?", new object[] { sequenceGroup.ProductLine, sequenceGroup.PreviousTraceCode });
if (orderSeqs == null || orderSeqs.Count == 0)
{
SaveErrorMessage(string.Format("生產線{0}前麵Van號{1}找不到有效的數據。", sequenceGroup.ProductLine, sequenceGroup.PreviousTraceCode));
noenError = false;
}
}
if (!string.IsNullOrWhiteSpace(sequenceGroup.OpReference))
{
try
{
sequenceGroup.OpReference.Split('|');
}
catch (Exception)
{
SaveErrorMessage(string.Format("工位{0}填寫有誤,正確的格式為{1}。", sequenceGroup.OpReference, Resources.SCM.SequenceGroup.SequenceGroup_OpRefRemark));
noenError = false;
}
}
if (noenError)
{
var dbSsequenceGroup = base.genericMgr.FindById<SequenceGroup>(sequenceGroup.Code);
//dbSsequenceGroup.SequenceBatch = sequenceGroup.SequenceBatch;
//dbSsequenceGroup.OpReference = sequenceGroup.OpReference;
//dbSsequenceGroup.IsActive = sequenceGroup.IsActive;
//if (!string.IsNullOrWhiteSpace(sequenceGroup.PreviousTraceCode))
//{
// dbSsequenceGroup.PreviousTraceCode = sequenceGroup.PreviousTraceCode;
// dbSsequenceGroup.PreviousOrderNo = orderSeqs.First().OrderNo;
// dbSsequenceGroup.PreviousSeq = orderSeqs.First().Sequence;
// dbSsequenceGroup.PreviousSubSeq = orderSeqs.First().SubSequence;
//}
//base.genericMgr.Update(dbSsequenceGroup);
string updateSql = "update SCM_SeqGroup set Version=Version+1,IsActive=?,SeqBatch=? ";
IList<object> parems = new List<object>();
parems.Add(sequenceGroup.IsActive);
parems.Add(sequenceGroup.SequenceBatch);
if (!string.IsNullOrWhiteSpace(sequenceGroup.OpReference))
{
updateSql += " ,OpRef=? ";
parems.Add(sequenceGroup.OpReference);
}
if (!string.IsNullOrWhiteSpace(sequenceGroup.PreviousTraceCode))
{
updateSql += ",PrevTraceCode=?,PrevOrderNo=?,PrevSeq=?,PrevSubSeq=? ";
parems.Add(sequenceGroup.PreviousTraceCode);
parems.Add(orderSeqs.First().OrderNo);
parems.Add(orderSeqs.First().Sequence);
parems.Add(orderSeqs.First().SubSequence);
}
updateSql += " where Code=? and Version=? ";
parems.Add(sequenceGroup.Code);
parems.Add(sequenceGroup.Version);
this.genericMgr.UpdateWithNativeQuery(updateSql, parems.ToArray());
SaveSuccessMessage(Resources.SCM.SequenceGroup.SequenceGroup_Updated);
return View(dbSsequenceGroup);
}
}
return View(sequenceGroup);
}