public void WebSrv_NI_NetworkIncident_Get1_Test()
        {
            long _id = 1;
            NetworkIncidentAccess _sut  = new NetworkIncidentAccess(_niEntities);
            NetworkIncidentData   _data = _sut.GetByPrimaryKey(_id, 1);

            Assert.IsNotNull(_data);
            Assert.AreEqual(_data.incident.IncidentId, _id);
            System.Diagnostics.Debug.WriteLine(_data.incident.ToString());
            foreach (IncidentNoteData _note in _data.incidentNotes)
            {
                System.Diagnostics.Debug.WriteLine(_note.ToString());
            }
            foreach (NetworkLogData _log in _data.networkLogs)
            {
                System.Diagnostics.Debug.WriteLine(_log.ToString());
            }
            foreach (NetworkLogData _ilog in _data.deletedLogs)
            {
                System.Diagnostics.Debug.WriteLine(_ilog.ToString());
            }
            foreach (SelectItem _nic in _data.NICs)
            {
                System.Diagnostics.Debug.WriteLine(_nic.ToString());
            }
            foreach (SelectItem _it in _data.incidentTypes)
            {
                System.Diagnostics.Debug.WriteLine(_it.ToString());
            }
            foreach (SelectItem _nt in _data.noteTypes)
            {
                System.Diagnostics.Debug.WriteLine(_nt.ToString());
            }
        }
Esempio n. 2
0
        //
        // GET api/<controller>/5&serverId=1
        public NetworkIncidentData Get(long id, [FromUri] int serverId)
        {
            NetworkIncidentAccess _access    = new NetworkIncidentAccess(_incidentEntities);
            NetworkIncidentData   _incidents = null;

            _incidents = _access.GetByPrimaryKey(id, serverId);
            return(_incidents);
        }
Esempio n. 3
0
        public void Effort_NetworkIncident_Update1_Test()
        {
            NetworkIncidentSave _data = new NetworkIncidentSave();
            string   _ip  = "104.42.229.49";
            long     _id  = 2;
            DateTime _idt = new DateTime(2016, 4, 21, 12, 12, 12);

            _data.user         = _user;
            _data.deletedNotes = new List <IncidentNoteData>();
            _data.deletedLogs  = new List <NetworkLogData>();
            _data.message      = "";
            NetworkIncidentData _nid = _sut.GetByPrimaryKey(_id, 1);

            _data.incident           = _nid.incident;
            _data.incident.IPAddress = _ip;
            _data.incidentNotes      = _nid.incidentNotes;
            // IncidentNoteId < 0 are added
            _data.incidentNotes.Add(new IncidentNoteData()
            {
                IncidentNoteId = -2,
                NoteTypeId     = 1, NoteTypeShortDesc = "Ping",
                Note           = "Ping " + _ip, CreatedDate = _idt
            });
            //8,1,,"104.42.229.49",04/22/2016 04:34:09,"URL = https://www.mimilk.com/Download.ashx?Category=Files&Id=62'A=0\r\n",2
            //9,1,,"104.42.229.49",04/22/2016 04:31:33,"URL = https://www.mimilk.com/Download.ashx?Category=Files&Id=62'A=0\r\n",2
            long[] ids = new long[] { 8, 9 };
            _data.networkLogs =
                (from _r in _niEntities.NetworkLogs
                 where (ids.Contains(_r.NetworkLogId))
                 select new NetworkLogData()
            {
                NetworkLogId = _r.NetworkLogId,
                ServerId = _r.ServerId,
                IncidentId = _id,
                IPAddress = _r.IPAddress,
                NetworkLogDate = _r.NetworkLogDate,
                Log = _r.Log,
                IncidentTypeId = _r.IncidentTypeId,
                IncidentTypeShortDesc = _r.IncidentType.IncidentTypeShortDesc,
                Selected = true,
                IsChanged = true
            }).ToList();
            _nid.networkLogs[0].IncidentId = 0;
            _nid.networkLogs[0].IsChanged  = true;
            _nid.networkLogs[0].Selected   = false;
            _data.networkLogs.Add(_nid.networkLogs[0]);
            // call update
            NetworkIncidentData _ret = _sut.Update(_data);

            Assert.AreEqual(2, _ret.incident.IncidentId);
            Console.WriteLine(_ret.networkLogs.Count);
            Assert.IsTrue(_ret.networkLogs.Count > 5);
            Assert.AreEqual(2, _ret.networkLogs.Where(nl => nl.Selected == true).Count());
            Assert.AreEqual(2, _ret.incidentNotes.Count);
        }
Esempio n. 4
0
        public void Effort_NetworkIncident_Insert1_Test()
        {
            int    _before            = _niEntities.Incidents.Count();
            string ip                 = "104.42.229.49";
            NetworkIncidentSave _data = new NetworkIncidentSave();

            _data.user         = _user;
            _data.deletedNotes = new List <IncidentNoteData>();
            _data.deletedLogs  = new List <NetworkLogData>();
            _data.message      = "";
            DateTime _idt = new DateTime(2016, 4, 21, 12, 12, 12);

            _data.incident = new IncidentData()
            {
                IncidentId      = 0, ServerId = 1, IPAddress = ip,
                NIC             = "arin.net", NetworkName = "MSFT", AbuseEmailAddress = "*****@*****.**",
                ISPTicketNumber = "", Mailed = false, Closed = false,
                Special         = false, Notes = "", CreatedDate = _idt, IsChanged = true
            };
            _data.incidentNotes = new List <IncidentNoteData>()
            {
                new IncidentNoteData()
                {
                    IncidentNoteId = 0,
                    NoteTypeId     = 1, NoteTypeShortDesc = "Ping",
                    Note           = "Ping " + ip, CreatedDate = _idt
                }
            };
            //8,1,,"104.42.229.49",04/22/2016 04:34:09,"URL = https://www.mimilk.com/Download.ashx?Category=Files&Id=62'A=0\r\n",2
            //9,1,,"104.42.229.49",04/22/2016 04:31:33,"URL = https://www.mimilk.com/Download.ashx?Category=Files&Id=62'A=0\r\n",2
            long[] ids = new long[] { 8, 9 };
            _data.networkLogs =
                (from _r in _niEntities.NetworkLogs
                 where (ids.Contains(_r.NetworkLogId))
                 select new NetworkLogData()
            {
                NetworkLogId = _r.NetworkLogId, ServerId = _r.ServerId,
                IncidentId = 0, IPAddress = _r.IPAddress,
                NetworkLogDate = _r.NetworkLogDate, Log = _r.Log,
                IncidentTypeId = _r.IncidentTypeId,
                IncidentTypeShortDesc = _r.IncidentType.IncidentTypeShortDesc,
                Selected = true, IsChanged = true
            }).ToList();
            NetworkIncidentData _ret = _sut.Insert(_data);

            Assert.IsTrue(_ret.incident.IncidentId > 1);
            int _after = _niEntities.Incidents.Count();

            Assert.AreEqual(_before + 1, _after);
        }
        public void WebSrv_NI_NetworkIncident_Get0_Test()
        {
            long _id = 0;
            NetworkIncidentAccess _sut  = new NetworkIncidentAccess(_niEntities);
            NetworkIncidentData   _data = _sut.GetByPrimaryKey(_id, 1);

            Assert.IsNotNull(_data);
            Assert.AreEqual(_data.incident.IncidentId, _id);
            System.Diagnostics.Debug.WriteLine(_data.incident.ToString());
            System.Diagnostics.Debug.WriteLine("Notes");
            foreach (IncidentNoteData _note in _data.incidentNotes)
            {
                System.Diagnostics.Debug.WriteLine(_note.ToString());
            }
            System.Diagnostics.Debug.WriteLine("Logs");
            foreach (NetworkLogData _log in _data.networkLogs)
            {
                System.Diagnostics.Debug.WriteLine(_log.ToString());
            }
            Assert.IsTrue(_data.networkLogs.Count > 0);
        }