Exemplo n.º 1
0
        public static async void Init(Action setterNewNotify)
        {
            setNewNotification = setterNewNotify;

            Load();
            GetNotify();
            while (true)
            {
                while (popupNotifies.Count != 0)
                {
                    PopupNotify popup;
                    lock (sync)
                    {
                        NotifyModel popupModel = popupNotifies.Dequeue();
                        popup = new PopupNotify(popupModel);
                        Notifications.Notifications.Add(popupModel);
                    }

                    NotifyList.NotifyPanel?.panelList.Children.Insert(0, popup);
                    popup.Margin      = new Thickness(0, 0, 0, 20);
                    popup.ClickClose += Popup_ClickClose;
                }
                await Task.Delay(100);
            }
        }
Exemplo n.º 2
0
        public void AddDefaultNote(string text, string userId)
        {
            NotifyModel notify = new NotifyModel();

            notify.Text = text;
            AddNote(notify, userId);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,Domain,CurrentIP,DestinationIP,IsScheduled")] NotifyModel notifyModel)
        {
            if (id != notifyModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(notifyModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NotifyModelExists(notifyModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(notifyModel));
        }
        /// <summary>
        /// The process request.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <exception cref="Exception">ex
        /// </exception>
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var url      = context.Request.Url;
            var formData = context.Request.Form;

            try
            {
                // todo 校验header中的OpenId

                var subscribeId = context.Request.QueryString["subscribeID"];
                var msgType     = context.Request.Form["msgType"];
                var data        = context.Request.Form["data"];
                var datas       = JsonUtil.DeserializeObject <List <NedeviceData> >(data);
                if (!datas.Any())
                {
                    throw new Exception($"The message do not contain \"data\" param .");
                }
                var alarmData = datas.FirstOrDefault();
                if (alarmData == null)
                {
                    throw new Exception($"alarmData is null");
                }
                HWLogger.NOTIFICATION.Info($"url :{url},msgType{msgType}, data:{JsonUtil.SerializeObject(alarmData)}");
                if (string.IsNullOrWhiteSpace(alarmData.DeviceId))
                {
                    throw new Exception($"The message do not contain \"DeviceId\" param.");
                }
                var eSight = ESightDal.Instance.GetEntityBySubscribeId(subscribeId);
                if (eSight == null)
                {
                    HWLogger.NOTIFICATION.Warn($"can not find the eSight,subscribeID:{subscribeId}");
                }
                else
                {
                    var nedevice = new NotifyModel <NedeviceData>
                    {
                        SubscribeId  = subscribeId,
                        MsgType      = Convert.ToInt32(msgType),
                        ResourceURI  = context.Request.Form["resourceURI"],
                        Timestamp    = context.Request.Form["timestamp"],
                        Description  = context.Request.Form["description"],
                        ExtendedData = context.Request.Form["extendedData"],
                        Data         = datas.FirstOrDefault()
                    };
                    Task.Run(() =>
                    {
                        var message = new TcpMessage <NotifyModel <NedeviceData> >(eSight.HostIP, TcpMessageType.NeDevice, nedevice);
                        NotifyClient.Instance.SendMsg(message);
                    });
                }
            }
            catch (Exception ex)
            {
                HWLogger.NOTIFICATION.Error($"NeDevice Notification Error:{url} formData:{formData}", ex);
                context.Response.Write($"NeDevice Notification Error:{ ex } ");
            }
            context.Response.End();
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,Domain,CurrentIP,DestinationIP,IsScheduled")] NotifyModel notifyModel)
        {
            if (ModelState.IsValid)
            {
                notifyModel.Id = Guid.NewGuid();
                _context.Add(notifyModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(notifyModel));
        }
Exemplo n.º 6
0
        public static async void CheckDNSEntry(NotifyModel notify, NotifyDNSDbContext context)
        {
            notify.CurrentIP = GetIPFromDNS(notify.Domain);

            //if(notify.CurrentIP == notify.DestinationIP && !notify.IsNotified)
            //{
            //    Mailer.SendMail();
            //    notify.IsNotified = true;
            //}

            context.Update(notify);
            await context.SaveChangesAsync();
        }
        public PopupNotify(NotifyModel model)
        {
            InitializeComponent();
            notifyModel = model;

            description.Text = model.Text;
            time.Text        = model.DateTime.ToString("HH:mm");

            if (model.Color != null)
            {
                description.Foreground = new BrushConverter().ConvertFromString(model.Color) as SolidColorBrush;
            }

            closeBtn.Click += (s, e) => ClickClose?.Invoke(this, e);
        }
Exemplo n.º 8
0
 public ActionResult PhanQuyen(FormCollection collection)
 {
     if (SessionManager.CheckSession(ConstantValues.SessionKeyCurrentUser))
     {
         NotifyModel thongBao = new NotifyModel();
         string      id       = collection["nguoiDungId"].ToString();
         if (string.IsNullOrEmpty(id))
         {
             return(RedirectToAction("Index", "NguoiDung"));
         }
         NguoiDung nguoiDung = xlNguoiDung.Doc(id);
         try
         {
             if (!string.IsNullOrEmpty(collection["save"].ToString()))
             {
                 var chucNangList = collection["chucNang"].Split(',');
                 nguoiDung.DanhSachChucNang = chucNangList.ToList();
                 nguoiDung.IdNguoiCapNhat   = currentUser.Id.ToString();
                 if (xlNguoiDung.CapNhat(nguoiDung))
                 {
                     thongBao.TypeNotify = "alert-success";
                     thongBao.Message    = "Cập nhật phân quyền thành công";
                 }
                 else
                 {
                     thongBao.TypeNotify = "alert-danger";
                     thongBao.Message    = "Cập nhật phân quyền thất bại!";
                 }
             }
         }
         catch (Exception)
         {
             thongBao.TypeNotify = "alert-danger";
             thongBao.Message    = "Cập nhật phân quyền thất bại!";
         }
         ViewBag.ThongBao = thongBao;
         var model = new NguoiDungModel();
         model.DanhSachChucNang = DocDanhSachChucNang();
         model.NguoiDungHienTai = nguoiDung;
         return(View("PhanQuyen", model));
     }
     if (Request.Url != null)
     {
         SessionManager.RegisterSession(ConstantValues.SessionKeyUrl, Request.Url.AbsolutePath);
     }
     return(RedirectToAction("Index", "Login"));
 }
 public ActionResult Them(FormCollection collection)
 {
     if (SessionManager.CheckSession(ConstantValues.SessionKeyCurrentUser))
     {
         NotifyModel thongBao = new NotifyModel();
         try
         {
             if (!string.IsNullOrEmpty(collection["save"].ToString()))
             {
                 NhomNguoiDung nhomNguoiDung = new NhomNguoiDung();
                 nhomNguoiDung.Ten     = collection["ten"].ToString();
                 nhomNguoiDung.MoTa    = collection["moTa"].ToString();
                 nhomNguoiDung.IdDonVi = collection["donVi"].ToString();
                 //nguoi dung chi co the phan quyen nhung chuc nang ma ho co
                 var chucNangList = collection["chucNang"].Split(',');
                 nhomNguoiDung.DanhSachChucNang = chucNangList.ToList();
                 nhomNguoiDung.IdNguoiTao       = currentUser.Id.ToString();
                 nhomNguoiDung.IdNguoiCapNhat   = currentUser.Id.ToString();
                 if (xlNhomNguoiDung.Ghi(nhomNguoiDung))
                 {
                     thongBao.TypeNotify = "alert-success";
                     thongBao.Message    = "Thêm thành công";
                 }
                 else
                 {
                     thongBao.TypeNotify = "alert-danger";
                     thongBao.Message    = "Thêm thất bại!";
                 }
             }
         }
         catch (Exception)
         {
             thongBao.TypeNotify = "alert-danger";
             thongBao.Message    = "Thêm thất bại!";
         }
         ViewBag.ThongBao = thongBao;
         var model = new NhomNguoiDungModel();
         model.DanhSachDonVi    = xlDonVi.DocDanhSachTuDonViCha(currentUser.IdDonVi, (bool)Session[ConstantValues.SessionKeyVaiTro]);
         model.DanhSachChucNang = DocDanhSachChucNang();
         return(View("Them", model));
     }
     if (Request.Url != null)
     {
         SessionManager.RegisterSession(ConstantValues.SessionKeyUrl, Request.Url.AbsolutePath);
     }
     return(RedirectToAction("Index", "Login"));
 }
Exemplo n.º 10
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (!model.Password.Equals(model.ConfirmPassword))
                    {
                        ModelState["Password"].Errors.Add("Password is not match");
                        return(RedirectToAction("Login", "Account"));
                    }
                    _userService.Insert(model);
                    var pwd = UtilEncrypt.GetMd5Hash(model.Password);

                    var acc = _userService.GetAll().FirstOrDefault(a => a.Username.Equals(model.UserName) && a.Password.Equals(pwd));
                    if (acc != null)
                    {
                        StoreCookie(acc);
                    }
                    return(RedirectToAction("Index", "Home"));
                }
                catch (Exception ex)
                {
                    var notify = new NotifyModel()
                    {
                        Result  = false,
                        Message = Resource.InternalException
                    };
                    if (ex.InnerException == null)
                    {
                        notify.Message = ex.Message;
                    }
                    TempData[Constants.NotifyMessage] = notify;
                    return(RedirectToAction("Login", "Account"));
                }
            }
            TempData[Constants.NotifyMessage] = new NotifyModel()
            {
                Result  = true,
                Message = string.Format(Resource.InvalidData, Resource.User)
            };
            return(RedirectToAction("Login", "Account"));
            // If we got this far, something failed, redisplay form
        }
Exemplo n.º 11
0
        public async Task <IActionResult> CheckOrder([FromBody] BaseInput input)
        {
            var doctorAuditTime = System.DateTime.Now;
            var entity          = await _ordersApp.GetForm(input.KeyValue);

            if (entity != null)
            {
                if (entity.F_OrderStatus == 0)
                {
                    entity.F_DoctorAuditTime = doctorAuditTime;
                    entity.F_OrderStatus     = 1;
                    await _ordersApp.UpdateForm(entity);

                    var childrens = await _ordersApp.GetChildrens(input.KeyValue);

                    foreach (var item in childrens)
                    {
                        item.F_DoctorAuditTime = doctorAuditTime;
                        item.F_OrderStatus     = 1;
                        await _ordersApp.UpdateForm(item);
                    }
                    var patient = await _patientApp.GetForm(entity.F_Pid);

                    var notify = new NotifyModel
                    {
                        Title   = "新医嘱",
                        Content = patient.F_Name + System.Environment.NewLine + entity.F_OrderText + entity.F_OrderAmount + entity.F_OrderUnitSpec
                    };

                    await Task.Run(() =>
                    {
                        _hubContext.Clients.All.SendCoreAsync("addTasksNotify", new object[] { notify.ToJson() });
                    });

                    return(Success("提交成功。"));
                }
                else
                {
                    return(Error("医嘱已提交。"));
                }
            }
            return(Error("医嘱ID有误。"));
        }
Exemplo n.º 12
0
 public ActionResult ThongTinCaNhan(FormCollection collection)
 {
     if (SessionManager.CheckSession(ConstantValues.SessionKeyCurrentUser))
     {
         NotifyModel thongBao  = new NotifyModel();
         NguoiDung   nguoiDung = xlNguoiDung.Doc(currentUser.Id.ToString());
         try
         {
             if (!string.IsNullOrEmpty(collection["save"].ToString()))
             {
                 nguoiDung.Ten            = collection["ten"].ToString();
                 nguoiDung.Email          = collection["email"].ToString();
                 nguoiDung.DienThoai      = collection["dienThoai"].ToString();
                 nguoiDung.IdNguoiCapNhat = currentUser.Id.ToString();
                 if (xlNguoiDung.CapNhat(nguoiDung))
                 {
                     thongBao.TypeNotify = "alert-success";
                     thongBao.Message    = "Chỉnh sửa thông tin thành công";
                     SessionManager.RegisterSession(ConstantValues.SessionKeyCurrentUser, nguoiDung);
                 }
                 else
                 {
                     thongBao.TypeNotify = "alert-danger";
                     thongBao.Message    = "Chỉnh sửa thông tin thất bại!";
                 }
             }
         }
         catch (Exception)
         {
             thongBao.TypeNotify = "alert-danger";
             thongBao.Message    = "Chỉnh sửa thông tin thất bại!";
         }
         ViewBag.ThongBao = thongBao;
         var model = new NguoiDungModel();
         model.NguoiDungHienTai = nguoiDung;
         return(View("ThongTinCaNhan", model));
     }
     if (Request.Url != null)
     {
         SessionManager.RegisterSession(ConstantValues.SessionKeyUrl, Request.Url.AbsolutePath);
     }
     return(RedirectToAction("Index", "Login"));
 }
Exemplo n.º 13
0
        // GET: Payover
        public ActionResult Index()
        {
            Log.Debug("收到通知:", "收到通知");
            //微信会把付款结果通知到这里
            ResultNotify resultNotify = new ResultNotify(System.Web.HttpContext.Current);
            WxPayData    notifyData   = resultNotify.GetNotifyData();
            //序列化  notifyData
            NotifyModel notify = new NotifyModel();

            notify = JSONHelper.JsonDeserialize <NotifyModel>(notifyData.ToJson());

            //////////这个必须给微信的通知回复收到信息,不然微信会一直发8次 ///////
            WxPayData res = new WxPayData();

            res.SetValue("return_code", "SUCCESS");
            res.SetValue("return_msg", "OK");
            HttpContext.Response.Clear();
            HttpContext.Response.Write(res.ToXml());
            HttpContext.Response.End();
            //////////回复结束//////////////
            Log.Debug("通知结束:", "通知结束");

            if (notify.result_code == "SUCCESS" && notify.return_code == "SUCCESS" && !string.IsNullOrEmpty(notify.out_trade_no) && !string.IsNullOrEmpty(notify.transaction_id))
            {
                //根据后台的充值记录
                // Log.Debug("微信支付结果通知:", "序列化后的openid:" + notify.openid);
                //Log.Debug("微信支付结果通知:", "序列化后的total_fee(该字段返回来的单位是分):" + notify.total_fee);
                //Log.Debug("微信支付结果通知:", "序列化后的out_trade_no:" + notify.out_trade_no);
                //Log.Debug("微信支付结果通知:", "序列化后的transaction_id:" + notify.transaction_id);
                //Log.Debug("微信支付结果通知:", "序列化后的notifyData:" + notifyData.ToJson());

                //OverAddFee(out_trade_no,openid) openid?
                //填写记录
                //using (var balancebLL = new BalanceBLL())
                //{
                //    balancebLL.PayOk(notify.out_trade_no).ConfigureAwait(true);
                //}
            }


            return(View());
        }
Exemplo n.º 14
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var url      = context.Request.Url;
            var formData = context.Request.Form;

            try
            {
                // todo 校验header中的OpenId
                var subscribeId = context.Request.QueryString["subscribeID"];
                var msgType     = context.Request.Form["msgType"];
                var data        = context.Request.Form["data"];
                var datas       = JsonUtil.DeserializeObject <List <KeepAliveData> >(data);
                if (!datas.Any())
                {
                    throw new Exception($"The message do not contain \"data\" param .");
                }
                HWLogger.NotifyRecv.Info($"url :{url},[msgType:{msgType}], data:{JsonUtil.SerializeObject(datas)}");

                Task.Run(() =>
                {
                    var aliveData = new NotifyModel <KeepAliveData>
                    {
                        SubscribeId  = subscribeId,
                        MsgType      = Convert.ToInt32(msgType),
                        ResourceURI  = context.Request.Form["resourceURI"],
                        Timestamp    = context.Request.Form["timestamp"],
                        Description  = context.Request.Form["description"],
                        ExtendedData = context.Request.Form["extendedData"],
                        Data         = datas.FirstOrDefault()
                    };
                    var message = new TcpMessage <NotifyModel <KeepAliveData> >(subscribeId, TcpMessageType.KeepAlive, aliveData);
                    NotifyClient.Instance.SendMsg(message);
                });
            }
            catch (Exception ex)
            {
                HWLogger.NotifyRecv.Error($"SystemKeepAlive Notification Error:{url} formData:{formData}", ex);
                context.Response.Write($"SystemKeepAlive Notification Error:{ ex } ");
            }
            context.Response.End();
        }
Exemplo n.º 15
0
 public App()
 {
     InitializeComponent();
     notifylist = new List <NotifyModel>();
     MainPage   = new NavigationPage(new GenericPage());
     MessagingCenter.Subscribe <Xamarin.Forms.Application, List <NotifyModel> >(App.Current, "info",
                                                                                (sender, arg) =>
     {
         if (arg != null)
         {
             foreach (var item in arg)
             {
                 NotifyModel model = new NotifyModel()
                 {
                     Id    = item.Id,
                     Value = item.Value,
                 };
                 notifylist.Add(model);
             }
         }
         foreach (var items in notifylist)
         {
             if (items.Id == "TypeId")
             {
                 TypeGuid = Guid.Parse(items.Value);
             }
             else if (items.Id == "Type")
             {
                 typeId = int.Parse(items.Value);
             }
         }
         if (typeId == 1)
         {
             App.Current.MainPage = new NavigationPage(new DetailCong(TypeGuid));
         }
         else if (typeId == 3)
         {
             App.Current.MainPage = new NavigationPage(new DetailsPages(TypeGuid));
         }
     });
 }
Exemplo n.º 16
0
        private static void HandleNotificationOpened(OSNotificationOpenedResult result)
        {
            OSNotificationPayload       payload        = result.notification.payload;
            Dictionary <string, object> additionalData = payload.additionalData;
            List <NotifyModel>          payloadList    = new List <NotifyModel>();

            foreach (var item in payload.additionalData)
            {
                NotifyModel model = new NotifyModel()
                {
                    Id    = item.Key,
                    Value = item.Value.ToString()
                };
                payloadList.Add(model);
            }
            if (payloadList.Count != 0)
            {
                MessagingCenter.Send <Xamarin.Forms.Application, List <NotifyModel> >(App.Current, "info",
                                                                                      payloadList);
            }
        }
Exemplo n.º 17
0
        public ActionResult Notify()
        {
            try
            {
                NotifyModel      model = new NotifyModel();
                List <NotifyRow> rows  = new List <NotifyRow>();
                var Receiver           = User.Identity.Name.ToString();
                var user = swdb.Users.Where(x => x.UserName.ToUpper().Trim() == Receiver.ToUpper().Trim()).FirstOrDefault();
                if (user != null)
                {
                    var roles = user.Roles.Select(x => x.RoleName.ToUpper().Trim()).ToList();
                    if (roles != null)
                    {
                        rows = swdb.Notification.Where(n => (n.NotificationTypeId == 3 || n.NotificationTypeId == 4) && n.NotificationStatusId == 0 && (roles.Contains(n.Receiver.ToUpper().Trim()) || n.Receiver.Equals(Receiver, StringComparison.CurrentCultureIgnoreCase))).OrderByDescending(n => n.SentDate)
                               .Select(x => new NotifyRow {
                            Receiver = x.Receiver, Sender = x.Sender, SentDate = x.SentDate, Id = x.Id
                        }).ToList();
                    }
                    else
                    {
                        rows = swdb.Notification.Where(n => n.Receiver == Receiver && n.NotificationStatusId == 0 && n.NotificationTypeId == 3).OrderByDescending(n => n.SentDate)
                               .Select(x => new NotifyRow {
                            Receiver = x.Receiver, Sender = x.Sender, SentDate = x.SentDate, Id = x.Id
                        }).ToList();
                    }
                }
                model.Row   = rows;
                model.Count = rows.Count;

                //List<Notification> rows = (from n in db.Notification
                //                           where n.Receiver == Context.User.Identity.Name && n.NotificationStatusId == 0 && n.NotificationTypeId == 3
                //                           orderby n.SentDate descending
                //                           select n).ToList();
                return(Json(model, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemplo n.º 18
0
 public void Notify(NotifyModel notifyModel)
 {
     // send notification
 }
Exemplo n.º 19
0
 public ActionResult ChinhSua(FormCollection collection)
 {
     if (SessionManager.CheckSession(ConstantValues.SessionKeyCurrentUser))
     {
         NotifyModel thongBao = new NotifyModel();
         string      id       = collection["nguoiDungId"].ToString();
         if (string.IsNullOrEmpty(id))
         {
             return(RedirectToAction("Index", "NguoiDung"));
         }
         NguoiDung nguoiDung = xlNguoiDung.Doc(id);
         try
         {
             if (!string.IsNullOrEmpty(collection["save"].ToString()))
             {
                 int kichHoat = 0;
                 if (collection["kich_hoat"] != null && !string.IsNullOrEmpty(collection["kich_hoat"].ToString()) && collection["kich_hoat"].ToString() == "on")
                 {
                     kichHoat = 1;
                 }
                 nguoiDung.Ten       = collection["ten"].ToString();
                 nguoiDung.Email     = collection["email"].ToString();
                 nguoiDung.DienThoai = collection["dienThoai"].ToString();
                 nguoiDung.IdVaiTro  = collection["vaiTro"].ToString();
                 nguoiDung.IdDonVi   = collection["donVi"].ToString();
                 var           nhomNguoiDungIds = collection["nhomNguoiDung"].Split(',');
                 List <string> nndIdList        = nhomNguoiDungIds.ToList();
                 nguoiDung.DanhSachNhom = nndIdList;
                 List <string> dsChucNang = nguoiDung.DanhSachChucNang;
                 foreach (var nndId in nndIdList)
                 {
                     NhomNguoiDung nhomNguoiDung = xlNhomNguoiDung.Doc(nndId);
                     foreach (var cn in nhomNguoiDung.DanhSachChucNang)
                     {
                         if (!dsChucNang.Contains(cn))
                         {
                             dsChucNang.Add(cn);
                         }
                     }
                 }
                 nguoiDung.DanhSachChucNang = dsChucNang;
                 nguoiDung.KichHoat         = kichHoat;
                 nguoiDung.IdNguoiCapNhat   = currentUser.Id.ToString();
                 if (xlNguoiDung.CapNhat(nguoiDung))
                 {
                     thongBao.TypeNotify = "alert-success";
                     thongBao.Message    = "Chỉnh sửa thông tin thành công";
                 }
                 else
                 {
                     thongBao.TypeNotify = "alert-danger";
                     thongBao.Message    = "Chỉnh sửa thông tin thất bại!";
                 }
             }
         }
         catch (Exception)
         {
             thongBao.TypeNotify = "alert-danger";
             thongBao.Message    = "Chỉnh sửa thông tin thất bại!";
         }
         ViewBag.ThongBao = thongBao;
         var model = new NguoiDungModel();
         model.DanhSachVaiTro        = DocDanhSachVaiTro();
         model.DanhSachDonVi         = DocDanhSachDonVi();
         model.DanhSachNhomNguoiDung = DocDanhSachNhomNguoiDung();
         model.NguoiDungHienTai      = nguoiDung;
         return(View("ChinhSua", model));
     }
     if (Request.Url != null)
     {
         SessionManager.RegisterSession(ConstantValues.SessionKeyUrl, Request.Url.AbsolutePath);
     }
     return(RedirectToAction("Index", "Login"));
 }
Exemplo n.º 20
0
        public override void ProcessNotify(Action<NotifyModel> action)
        {
            WxPayData notifyData = GetNotifyData();

            //检查支付结果中transaction_id是否存在
            if (!notifyData.IsSet("transaction_id"))
            {
                //若transaction_id不存在,则立即返回结果给微信支付后台
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", "支付结果中微信订单号不存在");
                Log.Error(this.GetType().ToString(), "The Pay result is error : " + res.ToXml());
                action(new NotifyModel
                {
                    IsSuccess = false,
                    NotifyMessage = "支付结果中微信订单号不存在",
                });
                page.Response.Write(res.ToXml());
                page.Response.End();
            }
            string transaction_id = notifyData.GetValue("transaction_id").ToString();
            string out_trade_no = notifyData.GetValue("out_trade_no").ToString();
            string openId = notifyData.GetValue("openid").ToString();
            string uniqueId = string.Empty;//new JsApiPay(System.Web.HttpContext.Current).GetUnionIdByOpenId(openId);
            //查询订单,判断订单真实性
            if (!QueryOrder(transaction_id))
            {
                //若订单查询失败,则立即返回结果给微信支付后台
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", "订单查询失败");
                Log.Error(this.GetType().ToString(), "Order query failure : " + res.ToXml());
                action(new NotifyModel
                {
                    IsSuccess = false,
                    NotifyMessage = "订单查询失败",
                    Transaction_Id = transaction_id,
                    Out_Trade_No = out_trade_no,
                    OpenId = openId,
                    UniqueId = uniqueId
                });
                page.Response.Write(res.ToXml());
                page.Response.End();
            }
            //查询订单成功
            else
            {
                WxPayData res = new WxPayData();
                res.SetValue("return_code", "SUCCESS");
                res.SetValue("return_msg", "OK");
                Log.Info(this.GetType().ToString(), "order query success : " + res.ToXml());
                //处理相关业务逻辑
                NotifyModel model = new NotifyModel
                {
                    Transaction_Id = transaction_id,
                    Out_Trade_No = out_trade_no,
                    OpenId = openId,
                    UniqueId = uniqueId,
                    IsSuccess = true,
                    NotifyMessage = "回调成功",
                };
                action(model);
                page.Response.Write(res.ToXml());
                page.Response.End();
            }
        }
Exemplo n.º 21
0
 public async void Add(NotifyModel notify)
 {
     await connection.InsertAsync(notify);
 }
Exemplo n.º 22
0
 private void SetTempData(NotifyModel model)
 {
     _tempData[_tempDataName] = model;
 }
 public NotificationPageViewModel()
 {
     notify = new NotifyModel();
     notify.addFriendReq = Helper.Instance().CountNotifi.ToString();
 }
Exemplo n.º 24
0
        /// <summary>
        /// The process request.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <exception cref="Exception">ex
        /// </exception>
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var url      = context.Request.Url;
            var formData = context.Request.Form;

            try
            {
                // todo 校验header中的OpenId

                var subscribeId = context.Request.QueryString["subscribeID"];
                var data        = context.Request.Form["data"];
                var msgType     = context.Request.Form["msgType"];

                var datas = JsonUtil.DeserializeObject <List <AlarmData> >(data);
                if (!datas.Any())
                {
                    throw new Exception($"The message do not contain data param.");
                }
                var alarmData = datas.FirstOrDefault();
                if (alarmData == null)
                {
                    throw new Exception($"alarmData is null");
                }
                HWLogger.NotifyRecv.Info($"url :{url},[msgType:{msgType}], data:{JsonUtil.SerializeObject(alarmData)}");
                if (string.IsNullOrWhiteSpace(alarmData.NeDN))
                {
                    throw new Exception($"The message do not contain DN param.");
                }
                if (alarmData.OptType == 3 || alarmData.OptType == 4 || alarmData.OptType == 6)
                {
                    // 过滤掉3:确认告警4:反确认告警 6:新增事件,
                    HWLogger.NotifyRecv.Info($"alarmData OptType is {alarmData.OptType}. Do not need handle");
                }
                else
                {
                    var alarm = new NotifyModel <AlarmData>
                    {
                        SubscribeId  = subscribeId,
                        ResourceURI  = context.Request.Form["resourceURI"],
                        MsgType      = Convert.ToInt32(msgType),
                        Timestamp    = context.Request.Form["timestamp"],
                        Description  = context.Request.Form["description"],
                        ExtendedData = context.Request.Form["extendedData"],
                        Data         = alarmData
                    };

                    Task.Run(() =>
                    {
                        var message = new TcpMessage <NotifyModel <AlarmData> >(subscribeId, TcpMessageType.Alarm, alarm);
                        NotifyClient.Instance.SendMsg(message);
                    });
                }
            }
            catch (Exception ex)
            {
                HWLogger.NotifyRecv.Error($"Alarm Notification Error:{url} formData:{formData}", ex);
                context.Response.Write($"Alarm Notification Error: { ex }");
            }
            context.Response.End();
        }
Exemplo n.º 25
0
        public ActionResult ThemChucNang(FormCollection collection)
        {
            if (SessionManager.CheckSession(ConstantValues.SessionKeyCurrentUser))
            {
                NotifyModel thongBao   = new NotifyModel();
                var         dsChucNang = xlchucnang.DocDanhSachChucNangCapCha();
                try
                {
                    if (!string.IsNullOrEmpty(collection["save"].ToString()))
                    {
                        var      user     = (NguoiDung)SessionManager.ReturnSessionObject(ConstantValues.SessionKeyCurrentUser);
                        ChucNang chucNang = new ChucNang();
                        int      kichHoat = 0;
                        if (collection["kich_hoat"] != null && !string.IsNullOrEmpty(collection["kich_hoat"].ToString()) && collection["kich_hoat"].ToString() == "on")
                        {
                            kichHoat = 1;
                        }
                        chucNang.Ten       = collection["ten"].ToString();
                        chucNang.BieuTuong = collection["bieu_tuong"].ToString();
                        chucNang.LienKet   = collection["lien_ket"].ToString();
                        chucNang.IdCha     = collection["chuc_nang_cha"].ToString();
                        if (chucNang.IdCha != "0")
                        {
                            //hiện tại chỉ hỗ trợ cho 2 cấp thôi nên nếu có cha thì cấp con sẽ là 2
                            chucNang.CapDo = 2;
                        }
                        chucNang.NgayCapNhat    = Utility.ConvertToUnixTimestamp(DateTime.UtcNow);
                        chucNang.IdNguoiTao     = user.Id.ToString();
                        chucNang.IdNguoiCapNhat = user.Id.ToString();
                        chucNang.SapXep         = int.Parse(collection["sap_xep"].ToString());
                        chucNang.KichHoat       = kichHoat;

                        if (xlchucnang.Ghi(chucNang))
                        {
                            thongBao.TypeNotify = "alert-success";
                            thongBao.Message    = "Thêm thành công";
                            if (chucNang.CapDo == 1)
                            {
                                dsChucNang.Add(chucNang);
                            }
                        }
                        else
                        {
                            thongBao.TypeNotify = "alert-danger";
                            thongBao.Message    = "Thêm thất bại!";
                        }
                    }
                }
                catch (Exception)
                {
                    thongBao.TypeNotify = "alert-danger";
                    thongBao.Message    = "Thêm thất bại!";
                }
                ViewBag.ThongBao = thongBao;
                return(View("ThemChucNang", dsChucNang));
            }
            if (Request.Url != null)
            {
                SessionManager.RegisterSession(ConstantValues.SessionKeyUrl, Request.Url.AbsolutePath);
            }
            return(RedirectToAction("Index", "Login"));
        }
        /// <returns>Success</returns>
        /// <exception cref="SwaggerException">A server side error occurred.</exception>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        public async System.Threading.Tasks.Task <NotifyModel> Notification4Async(int id, NotifyModel body, System.Threading.CancellationToken cancellationToken)
        {
            if (id == null)
            {
                throw new System.ArgumentNullException("id");
            }

            var urlBuilder_ = new System.Text.StringBuilder();

            urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/Notification/{id}");
            urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture)));

            var client_ = _httpClient;

            try
            {
                using (var request_ = new System.Net.Http.HttpRequestMessage())
                {
                    var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value));
                    content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
                    request_.Content             = content_;
                    request_.Method = new System.Net.Http.HttpMethod("PUT");
                    request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));

                    PrepareRequest(client_, request_, urlBuilder_);
                    var url_ = urlBuilder_.ToString();
                    request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
                    PrepareRequest(client_, request_, url_);

                    var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);

                    try
                    {
                        var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
                        if (response_.Content != null && response_.Content.Headers != null)
                        {
                            foreach (var item_ in response_.Content.Headers)
                            {
                                headers_[item_.Key] = item_.Value;
                            }
                        }

                        ProcessResponse(client_, response_);

                        var status_ = ((int)response_.StatusCode).ToString();
                        if (status_ == "200")
                        {
                            var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);

                            var result_ = default(NotifyModel);
                            try
                            {
                                result_ = Newtonsoft.Json.JsonConvert.DeserializeObject <NotifyModel>(responseData_, _settings.Value);
                                return(result_);
                            }
                            catch (System.Exception exception_)
                            {
                                throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_);
                            }
                        }
                        else
                        if (status_ == "400")
                        {
                            var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);

                            var result_ = default(ProblemDetails);
                            try
                            {
                                result_ = Newtonsoft.Json.JsonConvert.DeserializeObject <ProblemDetails>(responseData_, _settings.Value);
                            }
                            catch (System.Exception exception_)
                            {
                                throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_);
                            }
                            throw new SwaggerException <ProblemDetails>("Bad Request", (int)response_.StatusCode, responseData_, headers_, result_, null);
                        }
                        else
                        if (status_ != "200" && status_ != "204")
                        {
                            var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);

                            throw new SwaggerException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
                        }

                        return(default(NotifyModel));
                    }
                    finally
                    {
                        if (response_ != null)
                        {
                            response_.Dispose();
                        }
                    }
                }
            }
            finally
            {
            }
        }
 /// <returns>Success</returns>
 /// <exception cref="SwaggerException">A server side error occurred.</exception>
 public System.Threading.Tasks.Task <NotifyModel> Notification4Async(int id, NotifyModel body)
 {
     return(Notification4Async(id, body, System.Threading.CancellationToken.None));
 }
Exemplo n.º 28
0
        public async Task <ResultModel> Post(FinancialRecord record)
        {
            var result             = new ResultModel();
            var existFinancialItem = _context.FinancialItems.FirstOrDefault(a => a.Id == record.FinancialItemId);

            if (record.FinancialItemId == 57 || record.FinancialItemId == 75)
            {
                //計算xx燈剩餘位子數量
                int max_Light = 666;
                if (record.Position > max_Light / 2)
                {
                    result.IsSuccess = false;
                    result.Message   = "位置最多為" + max_Light / 2;
                    return(result);
                }

                var existPosition = _context.FinancialRecords
                                    .Where(a => a.FinancialItemId == record.FinancialItemId)
                                    .Where(a => a.Position == record.Position)
                                    .Where(a => a.DueDate > DateTime.Now);
                if (existPosition.Count() > 0)
                {
                    result.IsSuccess = false;
                    result.Message   = "位置已佔用,請重新選擇";
                    return(result);
                }
            }
            try
            {
                NotifyModel notify = new NotifyModel();
                notify.CreateDate = DateTime.Now;
                notify.IsRead     = false;
                notify.ItemName   = existFinancialItem.Name;
                notify.MemberName = record.CustomerName;
                _context.Notification.Add(notify);

                record.CreateDate = DateTime.Now.ToLocalTime();

                _context.FinancialRecords.Add(record);
                result.IsSuccess = true;
                result.Message   = "添加紀錄成功.";
                await _context.SaveChangesAsync();

                result.Data = new
                {
                    Id = record.Id
                };
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message   = "DB ERROR";
            }

            var accessToken = Request.Headers["Authorization"];
            var user        = await _TokenGetUserHelper.GetUser(accessToken);

            logger.Info("userId=" + user.Id + ", username="******"\n Create " + "FinancialRecord id= " + record.Id + " successfully.");


            return(result);
        }
Exemplo n.º 29
0
 private static void Add(NotifyModel model)
 {
     lock (sync)
         popupNotifies.Enqueue(model);
     setNewNotification?.Invoke();
 }
Exemplo n.º 30
0
        public ActionResult Them(FormCollection collection)
        {
            if (SessionManager.CheckSession(ConstantValues.SessionKeyCurrentUser))
            {
                NotifyModel thongBao  = new NotifyModel();
                NguoiDung   nguoiDung = new NguoiDung();
                try
                {
                    if (!string.IsNullOrEmpty(collection["save"].ToString()))
                    {
                        string tenDangNhap = collection["tenDangNhap"].ToString();
                        int    kichHoat    = 0;
                        if (collection["kich_hoat"] != null && !string.IsNullOrEmpty(collection["kich_hoat"].ToString()) && collection["kich_hoat"].ToString() == "on")
                        {
                            kichHoat = 1;
                        }
                        nguoiDung.Ten         = collection["ten"].ToString();
                        nguoiDung.TenDangNhap = tenDangNhap;
                        nguoiDung.setMatKhau(collection["matKhau"].ToString());

                        nguoiDung.Email     = collection["email"].ToString();
                        nguoiDung.DienThoai = collection["dienThoai"].ToString();

                        nguoiDung.IdVaiTro = collection["vaiTro"].ToString();
                        nguoiDung.IdDonVi  = collection["donVi"].ToString();
                        string        nhomNguoiDungIds = collection["nhomNguoiDung"].ToString();
                        List <string> nndIdList        = nhomNguoiDungIds.Split(',').ToList();
                        nguoiDung.DanhSachNhom = nndIdList;
                        List <string> dsChucNang = new List <string>();
                        foreach (var nndId in nndIdList)
                        {
                            NhomNguoiDung nhomNguoiDung = xlNhomNguoiDung.Doc(nndId);
                            foreach (var cn in nhomNguoiDung.DanhSachChucNang)
                            {
                                if (!dsChucNang.Contains(cn))
                                {
                                    dsChucNang.Add(cn);
                                }
                            }
                        }
                        nguoiDung.DanhSachChucNang = dsChucNang;
                        nguoiDung.KichHoat         = kichHoat;
                        nguoiDung.IdNguoiTao       = currentUser.Id.ToString();
                        nguoiDung.IdNguoiCapNhat   = currentUser.Id.ToString();
                        var nguoiDungExists = xlNguoiDung.DocDanhSach(nd => nd.TenDangNhap == tenDangNhap);
                        if (nguoiDungExists.Count() > 0)
                        {
                            thongBao.TypeNotify = "alert-danger";
                            thongBao.Message    = "Tên người dùng đã tồn tại! Thêm thất bại!";
                        }
                        else
                        {
                            if (xlNguoiDung.Ghi(nguoiDung))
                            {
                                thongBao.TypeNotify = "alert-success";
                                thongBao.Message    = "Thêm thành công";
                                nguoiDung           = new NguoiDung();
                            }
                            else
                            {
                                thongBao.TypeNotify = "alert-danger";
                                thongBao.Message    = "Thêm thất bại!";
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    thongBao.TypeNotify = "alert-danger";
                    thongBao.Message    = "Thêm thất bại!";
                }
                ViewBag.ThongBao = thongBao;
                var model = new NguoiDungModel();
                model.DanhSachVaiTro        = DocDanhSachVaiTro();
                model.DanhSachDonVi         = DocDanhSachDonVi();
                model.DanhSachNhomNguoiDung = DocDanhSachNhomNguoiDung();
                model.NguoiDungHienTai      = nguoiDung;
                return(View("Them", model));
            }
            if (Request.Url != null)
            {
                SessionManager.RegisterSession(ConstantValues.SessionKeyUrl, Request.Url.AbsolutePath);
            }
            return(RedirectToAction("Index", "Login"));
        }