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


C# DB.AddToLineSetups方法代码示例

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


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

示例1: InsertDevice

        public bool InsertDevice(NodeLine device)
        {
            try
            {
                using (DB db = new DB())
                {
                    NodeLine node = (from o in db.DeviceSetups
                                      where o.Id == device.DeviceSetupId
                                      select new NodeLine
                                      {
                                          DeviceSetupId = o.Id,
                                          Client = o.LineSetup.DataCollectionNode.Client,
                                          AddressType = o.AddressType,
                                          DataType = o.DataType,
                                          DowntimeThreshold = o.LineSetup.DowntimeThreshold,
                                          UptimeThreshold = o.LineSetup.UptimeThreshold,
                                          IPAddress = o.IpAddress,
                                          Line = o.LineSetup.Line,
                                          TagType = o.TagType,
                                          TrackDowntime = o.TrackDowntime,
                                          TrackingType = o.TrackingType,
                                          TagName = o.TagName
                                      }).FirstOrDefault();

                    if (node != null)//Already exists
                    {
                        DeviceSetup setup = (from o in db.DeviceSetups
                                             where o.Id == node.DeviceSetupId
                                             select o).FirstOrDefault();

                        if (setup != null)
                        {
                            setup.IpAddress = device.IPAddress;
                            setup.TagName = device.TagName;
                            setup.TagType = device.TagType;
                            setup.TrackDowntime = device.TrackDowntime;
                            setup.TrackingType = device.TrackingType;

                            setup.AddressType = device.AddressType;
                            setup.DataType = device.DataType;
                            setup.LineSetup.Line = device.Line;
                            setup.LineSetup.DowntimeThreshold = device.DowntimeThreshold;
                            setup.LineSetup.UptimeThreshold = device.UptimeThreshold;
                            setup.LineSetup.DataCollectionNode.Client = device.Client;
                            setup.LineSetup.DataCollectionNode.ServerName = device.ServerName;

                            return db.SaveChanges() > 0;
                        }

                    }
                    else
                    {
                        DeviceSetup setup = new DeviceSetup();

                        setup.IpAddress = device.IPAddress;
                        setup.TagName = device.TagName;
                        setup.TagType = device.TagType;
                        setup.TrackDowntime = device.TrackDowntime;
                        setup.TrackingType = device.TrackingType;

                        setup.AddressType = device.AddressType;
                        setup.DataType = device.DataType;

                        DataCollectionNode dataNode = (from o in db.DataCollectionNodes
                                                       where o.Client == device.Client
                                                       select o).FirstOrDefault();

                        if (dataNode == null)
                        {
                            dataNode = new DataCollectionNode();
                            dataNode.Password = "password";

                            setup.LineSetup.DataCollectionNode = dataNode;
                        }

                        setup.LineSetup.DataCollectionNode.Client = device.Client;

                        LineSetup lineSetup = (from o in db.LineSetups
                                               where o.DataCollectionNode.Id == dataNode.Id
                                               select o).FirstOrDefault();

                        if (lineSetup == null)
                        {
                            lineSetup = new LineSetup();
                            setup.LineSetup = lineSetup;
                        }

                        setup.LineSetup.Line = device.Line;
                        setup.LineSetup.DowntimeThreshold = device.DowntimeThreshold;
                        setup.LineSetup.UptimeThreshold = device.UptimeThreshold;

                        db.AddToLineSetups(lineSetup);

                        return db.SaveChanges() > 0;
                    }
                }

                return false;
            }
            catch (Exception ex)
//.........这里部分代码省略.........
开发者ID:bsimp6983,项目名称:BackupDashes,代码行数:101,代码来源:DSCWS.asmx.cs


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