Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
 //
 //  POST api/ProdCategory           create
 //  PUT api/ProdCategory/<key>      update
 //  DELETE api/ProdCategory/<key>   delete
 //
 #region "restful updates"
 //
 /// <summary>
 /// POST api/<controller>
 /// NetworkIncidentData Insert(NetworkIncidentSave data)
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public NetworkIncidentData Post([FromBody] NetworkIncidentSave data)
 {            //
     try
     {
         NetworkIncidentAccess _access = new NetworkIncidentAccess(_incidentEntities);
         return(_access.Insert(data));
     }
     catch (Exception _ex)
     {
         Log.Logger.Log(LoggingLevel.Error, data.user.UserName, MethodBase.GetCurrentMethod(), data.incident.ToString() + _ex.Message, _ex);
         System.Diagnostics.Debug.WriteLine(_ex.ToString());
     }
     return(new NetworkIncidentData());
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        //
        /// <summary>
        /// PUT api/<controller>/5
        /// NetworkIncidentData Update(NetworkIncidentSave data)
        /// </summary>
        /// <param name="id"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public NetworkIncidentData Put(int id, [FromBody] NetworkIncidentSave value)
        {
            NetworkIncidentAccess _access = new NetworkIncidentAccess(_incidentEntities);

            return(_access.Update(value));
        }