本文整理汇总了C#中DowntimeCollection_Demo.DB.AddToNatureOfStoppages方法的典型用法代码示例。如果您正苦于以下问题:C# DB.AddToNatureOfStoppages方法的具体用法?C# DB.AddToNatureOfStoppages怎么用?C# DB.AddToNatureOfStoppages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DowntimeCollection_Demo.DB
的用法示例。
在下文中一共展示了DB.AddToNatureOfStoppages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: importExcel
//.........这里部分代码省略.........
object oDate = currentWorksheet.Cells[rowNumber, 1].Value;
object oEventStart = currentWorksheet.Cells[rowNumber, 3].Value;
object oMinutes = currentWorksheet.Cells[rowNumber, 6].Value;//It's a Date in H:MM:SS format
object oReason = currentWorksheet.Cells[rowNumber, 7].Value;
object oStoppageOfNature = currentWorksheet.Cells[rowNumber, 9].Value;
if ((oEventStart != null && oEventStart.ToString() != "") && (oStoppageOfNature != null && oStoppageOfNature.ToString() != ""))
{
decimal minutes = 0;
if (oMinutes != null)
{
DateTime minTime = (DateTime)oMinutes;
minutes = Convert.ToDecimal((minTime.TimeOfDay.TotalHours / 60) + minTime.TimeOfDay.TotalMinutes);
}
DateTime EventStart = DateTime.Now;
try
{
EventStart = (DateTime)oEventStart;
}
catch (Exception e)
{
Console.Write(e.Message);
}
DateTime EventStop = EventStart.AddMinutes((double)minutes);
string reason = oReason.ToString();
string nos = oStoppageOfNature.ToString();
Options opt = (from o in options
where o.Name.Equals(nos, StringComparison.InvariantCultureIgnoreCase)
select o).FirstOrDefault();
if (opt != null)
{
DowntimeData dt = new DowntimeData();
dt.Client = client;
dt.Comment = reason;
dt.EventStart = EventStart;
dt.EventStop = EventStop;
dt.Line = line;
dt.Minutes = minutes;
dt.IsCreatedByAcromag = true;
dtData.Add(dt);
db.AddToDowntimeDataSet(dt);
db.SaveChanges();
if (dt.ID > 0)
{
NatureOfStoppage NOS = new NatureOfStoppage();
NOS.OptionId = opt.Id;
NOS.DowntimeId = dt.ID;
db.AddToNatureOfStoppages(NOS);
}
}
else
{
Console.Write("NOS IS EMPTY");
}
}
}
index++;
}
Console.Write("DONE" + dtData.Count);
}
}
}
}
}
catch (IOException ioEx)
{
if (!String.IsNullOrEmpty(ioEx.Message))
{
if (ioEx.Message.Contains("because it is being used by another process."))
{
Console.WriteLine("Could not read example data. Please make sure it not open in Excel.");
}
}
Console.WriteLine("Could not read example data. " + ioEx.Message, ioEx);
}
catch (Exception ex)
{
Console.WriteLine("An error occured while reading example data. " + ex.Message, ex);
}
finally
{
Console.WriteLine();
Console.WriteLine("press any key to exit.");
}
}