Beispiel #1
0
        public async Task ConnectAndSendSMS(DM_ThietBi thietbi)
        {
            if (AbpSession.UserId != null)
            {
                var hoatdong = _repositoryLichSuHoatDongThietBi.GetAll().Where(x => x.IDTHIETBI == thietbi.Id && x.THONGTINQUANLY.CODE == "MATLL" && x.SUSSES == 0).FirstOrDefault();
                if (hoatdong != null)
                {
                    hoatdong.SUSSES  = 1;
                    hoatdong.ENDDATE = DateTime.Now;
                    await _repositoryLichSuHoatDongThietBi.UpdateAsync(hoatdong);

                    var phones = _userService.GetLsSoDienThoaiByIddonvi(thietbi.TRAM.IDDONVI);
                    if (phones.Count > 0)
                    {
                        await _webService.SendSMS(phones, "GIAMSAT_NHATRAM:" + thietbi.CODE + ": " + thietbi.IP + " DA KET NOI " + DateTime.Now.ToLongTimeString() + " 10.10.117.186");
                    }
                }
            }
            else
            {
                AbpSession.Use(1, 2);
                var hoatdong = _repositoryLichSuHoatDongThietBi.GetAll().Where(x => x.IDTHIETBI == thietbi.Id && x.THONGTINQUANLY.CODE == "MATLL" && x.SUSSES == 0).FirstOrDefault();
                if (hoatdong != null)
                {
                    hoatdong.SUSSES  = 1;
                    hoatdong.ENDDATE = DateTime.Now;
                    await _repositoryLichSuHoatDongThietBi.UpdateAsync(hoatdong);

                    var phones = _userService.GetLsSoDienThoaiByIddonvi(thietbi.TRAM.IDDONVI);
                    if (phones.Count > 0)
                    {
                        await _webService.SendSMS(phones, "GIAMSAT_NHATRAM:" + thietbi.CODE + ": " + thietbi.IP + " DA KET NOI " + DateTime.Now.ToLongTimeString() + " 10.10.117.186");
                    }
                }
            }
        }
Beispiel #2
0
        public async Task <DM_ThietBiDto> GetForEdit(GetDM_ThietBi input)
        {
            DM_ThietBi nhomVT = await _repository.GetAsync(input.Id);

            return(nhomVT.MapTo <DM_ThietBiDto>());
        }
Beispiel #3
0
        public async Task DisPingAndSendSMS(DM_ThietBi thietbi)
        {
            bool pingable = false;
            Ping pinger   = null;

            try
            {
                pinger = new Ping();
                PingReply reply = pinger.Send(thietbi.IP);
                pingable = reply.Status == IPStatus.Success;
            }
            catch (PingException)
            {
                // Discard PingExceptions and return false;
            }
            if (pingable == false)
            {
                if (AbpSession.UserId != null)
                {
                    var thongtin = _DM_THONGTINQUANLYAppService.GetThongTinQuanLyByCode("MATLL", thietbi.Id);
                    if (thongtin != null)
                    {
                        LichSuHoatDongThietBi log = new LichSuHoatDongThietBi();
                        log.IDTHIETBI        = thietbi.Id;
                        log.IDTHONGTINQUANLY = thongtin.Id;
                        log.SUSSES           = 0;
                        log.STARTDATE        = DateTime.Now;
                        log.ENDDATE          = DateTime.Now;
                        log.TenantId         = 1;
                        try
                        {
                            await _repositoryLichSuHoatDongThietBi.InsertAsync(log);
                        }
                        catch (Exception ex)
                        {
                        }

                        var phones = _userService.GetLsSoDienThoaiByIddonvi(thietbi.TRAM.IDDONVI);
                        if (phones.Count > 0)
                        {
                            await _webService.SendSMS(phones, "GIAMSAT_NHATRAM:" + thietbi.CODE + ": " + thietbi.IP + " CANH BAO MAT LIEN LAC: " + DateTime.Now.ToLongTimeString() + " 10.10.117.186");
                        }
                    }
                }
                else
                {
                    AbpSession.Use(1, 2);
                    var thongtin = _DM_THONGTINQUANLYAppService.GetThongTinQuanLyByCode("MATLL", thietbi.Id);
                    if (thongtin != null)
                    {
                        LichSuHoatDongThietBi log = new LichSuHoatDongThietBi();
                        log.IDTHIETBI        = thietbi.Id;
                        log.IDTHONGTINQUANLY = thongtin.Id;
                        log.SUSSES           = 0;
                        log.STARTDATE        = DateTime.Now;
                        log.ENDDATE          = DateTime.Now;
                        log.TenantId         = 1;
                        try
                        {
                            await _repositoryLichSuHoatDongThietBi.InsertAsync(log);
                        }
                        catch (Exception ex)
                        {
                        }

                        var phones = _userService.GetLsSoDienThoaiByIddonvi(thietbi.TRAM.IDDONVI);
                        if (phones.Count > 0)
                        {
                            await _webService.SendSMS(phones, "GIAMSAT_NHATRAM:" + thietbi.CODE + ": " + thietbi.IP + " CANH BAO MAT LIEN LAC: " + DateTime.Now.ToLongTimeString() + " 10.10.117.186");
                        }
                    }
                }
            }
        }