本文整理汇总了C#中DowntimeCollection_Demo.DB.AddToLineStatus方法的典型用法代码示例。如果您正苦于以下问题:C# DB.AddToLineStatus方法的具体用法?C# DB.AddToLineStatus怎么用?C# DB.AddToLineStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DowntimeCollection_Demo.DB
的用法示例。
在下文中一共展示了DB.AddToLineStatus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateLineStatusWithTime
public bool UpdateLineStatusWithTime(string client, string line, bool on, string strEventTime)
{
try
{
if (string.IsNullOrEmpty(strEventTime))
return false;
DateTime eventTime;
if (!DateTime.TryParse(strEventTime, out eventTime))
return false;
using (DB db = new DB())
{
LineStatus lineStat = (from o in db.LineStatus
where o.Client == client
&& o.Line == line
select o).FirstOrDefault();
bool result = false;
if (lineStat != null)
{
if (on != lineStat.Status || lineStat.Status == true)//Only log False once, but constantly update time for True
{
lineStat.Status = on;
lineStat.EventTime = eventTime;
result = db.SaveChanges() > 0;
}
}
else
{
lineStat = new LineStatus();
lineStat.Client = client;
lineStat.Line = line;
lineStat.Status = on;
lineStat.ShiftStart = "06:00:00";
lineStat.Timezone = "Eastern Standard Time";
lineStat.EventTime = eventTime;
db.AddToLineStatus(lineStat);
result = db.SaveChanges() > 0;
}
if (result == true)
{
DBHelper.UpdateAscommPing(client, DateTime.Now, line, true);
}
return result;
}
}
catch (Exception ex)
{
String fileName = this.Server.MapPath("~/App_Data/log.txt");
File.AppendAllText(fileName, ex.ToString());
throw ex;
}
}