Beispiel #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the DataCollectionNodes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDataCollectionNodes(DataCollectionNode dataCollectionNode)
 {
     base.AddObject("DataCollectionNodes", dataCollectionNode);
 }
Beispiel #2
0
        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;

            }
        }
Beispiel #3
0
 /// <summary>
 /// Create a new DataCollectionNode object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="serverName">Initial value of the ServerName property.</param>
 /// <param name="client">Initial value of the Client property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="timeZone">Initial value of the TimeZone property.</param>
 /// <param name="monitor">Initial value of the Monitor property.</param>
 /// <param name="uptime">Initial value of the Uptime property.</param>
 public static DataCollectionNode CreateDataCollectionNode(global::System.Int32 id, global::System.String serverName, global::System.String client, global::System.String password, global::System.String timeZone, global::System.Boolean monitor, global::System.Int32 uptime)
 {
     DataCollectionNode dataCollectionNode = new DataCollectionNode();
     dataCollectionNode.Id = id;
     dataCollectionNode.ServerName = serverName;
     dataCollectionNode.Client = client;
     dataCollectionNode.Password = password;
     dataCollectionNode.TimeZone = timeZone;
     dataCollectionNode.Monitor = monitor;
     dataCollectionNode.Uptime = uptime;
     return dataCollectionNode;
 }