コード例 #1
0
ファイル: DB.Designer.cs プロジェクト: bsimp6983/BackupDashes
 /// <summary>
 /// Deprecated Method for adding a new object to the LineSetups EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToLineSetups(LineSetup lineSetup)
 {
     base.AddObject("LineSetups", lineSetup);
 }
コード例 #2
0
ファイル: DSCWS.asmx.cs プロジェクト: bsimp6983/BackupDashes
        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 = "******";

                            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)
            {
                String fileName = this.Server.MapPath("~/App_Data/log.txt");
                File.AppendAllText(fileName, ex.ToString());
                throw ex;

            }
        }
コード例 #3
0
ファイル: DB.Designer.cs プロジェクト: bsimp6983/BackupDashes
 /// <summary>
 /// Create a new LineSetup object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="line">Initial value of the Line property.</param>
 /// <param name="downtimeThreshold">Initial value of the DowntimeThreshold property.</param>
 /// <param name="uptimeThreshold">Initial value of the UptimeThreshold property.</param>
 public static LineSetup CreateLineSetup(global::System.Int32 id, global::System.String line, global::System.Int32 downtimeThreshold, global::System.Int32 uptimeThreshold)
 {
     LineSetup lineSetup = new LineSetup();
     lineSetup.Id = id;
     lineSetup.Line = line;
     lineSetup.DowntimeThreshold = downtimeThreshold;
     lineSetup.UptimeThreshold = uptimeThreshold;
     return lineSetup;
 }