当前位置: 首页>>代码示例>>C#>>正文


C# DB.AddToNatureOfStoppages方法代码示例

本文整理汇总了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.");
            }
        }
开发者ID:bsimp6983,项目名称:BackupDashes,代码行数:101,代码来源:Import.ashx.cs


注:本文中的DowntimeCollection_Demo.DB.AddToNatureOfStoppages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。