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


C# DB.AddToDowntimeChildren方法代码示例

本文整理汇总了C#中DowntimeCollection_Demo.DB.AddToDowntimeChildren方法的典型用法代码示例。如果您正苦于以下问题:C# DB.AddToDowntimeChildren方法的具体用法?C# DB.AddToDowntimeChildren怎么用?C# DB.AddToDowntimeChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DowntimeCollection_Demo.DB的用法示例。


在下文中一共展示了DB.AddToDowntimeChildren方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Save


//.........这里部分代码省略.........
                var q = from o in db.DowntimeDataSet
                        where o.ID == id
                        select o;
                var dd = q.FirstOrDefault();
                if (dd == null) return false.ToString().ToLower();
                DowntimeReason reason = DCSDashboardDemoHelper.getReason(reasonId);

                if (dd.EventStop.HasValue == false)
                {

                    if (!DateTime.TryParse(request.Form["enddatetime"], out enddatetime))
                    {
                        context.Response.Write("end date time is empty.");
                        return "false";
                    }

                    dd.EventStop = enddatetime;
                    if (dd.EventStart != null)
                        dd.Minutes = Convert.ToDecimal(dd.EventStop.Value.Subtract(dd.EventStart.Value).TotalMinutes);

                    changeMinutes = false;

                    SwitchLineStatus(line, true);
                }

                dd.ReasonCodeID = reasonId;
                dd.ReasonCode = reasonCode;
                dd.Line = line;
                dd.Comment = comment;

                if(changeMinutes)
                    dd.Minutes = minutes;

                dd.Client = client;

                if (reason.HideReasonInReports && dd.Minutes > reason.Duration && reason.Duration > 0)//If Planned && duration is greater than 0
                {
                    DowntimeChild child1 = (from o in db.DowntimeChildren
                        where o.ParentDowntimeId == dd.ID
                        select o).FirstOrDefault();

                    if (child1 == null)
                    {
                        if (dd.EventStart != null)
                        {
                            dd.EventStop = dd.EventStart.Value.AddMinutes(reason.Duration);
                            // Tim mark

                            DowntimeData dd2 = new DowntimeData
                            {
                                Client = dd.Client,
                                ReasonCode = null,
                                ReasonCodeID = null,
                                Line = dd.Line,
                                Minutes = dd.Minutes - reason.Duration,
                                Comment = string.Empty,
                                EventStart = dd.EventStop
                            };
                            dd2.EventStop = dd.EventStop.Value.AddMinutes(Convert.ToDouble(dd2.Minutes));

                            child1 = new DowntimeChild {ParentDowntimeId = dd.ID};

                            dd.Minutes = reason.Duration;//Change after setting dd2's minutes

                            db.AddToDowntimeDataSet(dd2);
                            db.SaveChanges();

                            child1.DowntimeId = dd2.ID;
                            child1.ReasonCodeId = reason.ID;

                            db.AddToDowntimeChildren(child1);
                        }

                        db.SaveChanges();
                    }

                }
                else
                {
                    db.SaveChanges();
                }

                result = true;

                if (reason.IsChangeOver && throughputId > 0)
                {
                    DCSDashboardDemoHelper.CreateThroughPutHistory(throughputId, option1Id, option2Id, dd.EventStop.Value, line);
                }
                else if (option1Id > 0 || option2Id > 0)
                {
                    if (option1Id > 0)
                        DCSDashboardDemoHelper.CreateNOS(dd.ID, option1Id);

                    if (option2Id > 0)
                        DCSDashboardDemoHelper.CreateNOS(dd.ID, option2Id);
                }
            }

            return result.ToString().ToLower();
        }
开发者ID:bsimp6983,项目名称:BackupDashes,代码行数:101,代码来源:Service.ashx.cs


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