Beispiel #1
0
        public ActionResult Tracking()
        {
            string urlKey = Request.QueryString["k"];

            if (string.IsNullOrWhiteSpace(urlKey) || urlKey != OpenpayWebhookKey)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            System.IO.StreamReader reader = new System.IO.StreamReader(HttpContext.Request.InputStream);
            string rawJSON = reader.ReadToEnd();

            System.Diagnostics.Trace.TraceInformation("PaymentsController [rawJSON] : " + rawJSON); // For debugging to the Azure Streaming logs

            PaymentEventModel paymentEvent = JsonConvert.DeserializeObject <PaymentEventModel>(rawJSON);

            if (paymentEvent != null)
            {
                if (!string.IsNullOrWhiteSpace(paymentEvent.type))
                {
                    System.Diagnostics.Trace.TraceInformation("\tTransaction: " + paymentEvent.transaction);
                    if (paymentEvent.transaction != null)
                    {
                        System.Diagnostics.Trace.TraceInformation("\t\t Transaction Id: " + paymentEvent.transaction.id);
                        System.Diagnostics.Trace.TraceInformation("\t\t Order Id: " + paymentEvent.transaction.order_id);
                        System.Diagnostics.Trace.TraceInformation("\t\t Authorization: " + paymentEvent.transaction.authorization);

                        Payment paymentBO = _paymentService.GetByOrderId(paymentEvent.transaction.order_id);
                        User    user      = paymentBO.User;//_userService.GetById(payment.User.Id);

                        if (paymentBO != null)
                        {
                            System.Diagnostics.Trace.TraceInformation("\t\t Payment BO ID: " + paymentBO.Id);
                            paymentBO.Status  = paymentEvent.transaction.status;
                            paymentBO.LogData = rawJSON;
                            if (paymentEvent.type == PaymentEventStatus.CHARGE_SUCCEEDED)
                            {
                                paymentBO.ConfirmationDate  = DateUtil.GetDateTimeNow(); //lo tomamos cuando llega el evento
                                paymentBO.AuthorizationCode = paymentEvent.transaction.authorization;

                                Dictionary <string, string> customParams = new Dictionary <string, string>();
                                customParams.Add("param1", user.FirstName);
                                customParams.Add("param2", paymentEvent.transaction.order_id);
                                customParams.Add("param3", paymentBO.AuthorizationCode);
                                customParams.Add("param4", paymentEvent.transaction.id);
                                customParams.Add("param5", paymentBO.ConfirmationDate.Value.ToString(Constants.DATE_FORMAT));
                                customParams.Add("param6", string.Format("{0:#.00}", paymentBO.Amount));
                                customParams.Add("param7", paymentBO.Method);
                                string confirmationEmail = !string.IsNullOrWhiteSpace(paymentBO.ConfirmationEmail) ? paymentBO.ConfirmationEmail : user.Email;
                                NotificationUtil.SendNotification(confirmationEmail, customParams, Constants.NOT_TEMPLATE_CHARGESUCCESS);
                            }
                            _paymentService.Update(paymentBO);
                            System.Diagnostics.Trace.TraceInformation("\t\t Payment BO Status Updated: " + paymentBO.Status);
                        }
                    }
                }
            }

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
        public ActionResult ResetPassword(RecoverPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new
                {
                    success = false,
                    issue = model,
                    errors = ModelState.Keys.Where(k => ModelState[k].Errors.Count > 0)
                             .Select(k => new { propertyName = k, errorMessage = ModelState[k].Errors[0].ErrorMessage })
                }));
            }
            try
            {
                var resultado = _userService.FindBy(e => e.Email == model.Email).First();
                if (resultado != null)
                {
                    ViewBag.mensajeError  = string.Empty;
                    resultado.ExpiraToken = System.DateTime.Now.AddDays(1);
                    string token = (resultado.Uuid + "@" + DateTime.Now.AddDays(1).ToString());
                    token           = EncryptorText.DataEncrypt(token).Replace("/", "!!").Replace("+", "$");
                    resultado.Token = token;
                    Dictionary <string, string> customParams = new Dictionary <string, string>();
                    string urlAccion = (string)ConfigurationManager.AppSettings["_UrlServerAccess"];
                    string link      = urlAccion + "Auth/AccedeToken?token=" + token;
                    customParams.Add("param1", resultado.Email);
                    customParams.Add("param2", link);
                    NotificationUtil.SendNotification(resultado.Email, customParams, Constants.NOT_TEMPLATE_PASSWORDRECOVER);
                    _userService.Update(resultado);
                    AddViewMessage(TypeMessageView.SUCCESS, Messages.RequestSuccessful);
                    return(View("Login"));
                }
            }
            catch (Exception ex)
            {
                //ErrorController.SaveLogError(this, listAction.Update, "RecuperarContrasena", ex);
            }

            ModelState.AddModelError("Email", "No se encontró ninguna cuenta con el correo proporcionado. Verifique su información.");
            return(Json(new
            {
                success = false,
                issue = model,
                errors = ModelState.Keys.Where(k => ModelState[k].Errors.Count > 0)
                         .Select(k => new { propertyName = k, errorMessage = ModelState[k].Errors[0].ErrorMessage })
            }));
        }
        public HttpResponseMessage Recover([FromUri(Name = "email")] string email)
        {
            try
            {
                var user = _userService.FindBy(e => e.Email == email).FirstOrDefault();
                if (user == null)
                {
                    return(CreateErrorResponse(HttpStatusCode.BadRequest, "El correo electrónico solicitado no se encuentra registrado."));
                }
                if (user.Role.Code != Constants.ROLE_DEFAULT_API)
                {
                    return(CreateErrorResponse(HttpStatusCode.BadRequest, "El usuario no cuenta con acceso al API"));
                }
                string token = (user.Uuid + "@" + DateTime.Now.AddDays(1).ToString());
                token = EncryptorText.DataEncrypt(token).Replace("/", "!!").Replace("+", "$");
                List <string> Email = new List <string>();
                Email.Add(user.Email);
                Dictionary <string, string> customParams = new Dictionary <string, string>();
                string urlAccion = ConfigurationManager.AppSettings["_UrlServerAccess"].ToString();
                string link      = urlAccion + "Auth/AccedeToken?token=" + token;
                customParams.Add("param1", user.Email);
                customParams.Add("param2", link);
                string template = "aa61890e-5e39-43c4-92ff-fae95e03a711";
                NotificationUtil.SendNotification(Email, customParams, template);

                user.ExpiraToken = DateUtil.GetDateTimeNow().AddDays(1);
                user.Token       = token;
                _userService.Update(user);

                return(CreateResponse("OK", "Datos devueltos correctamente"));
            }
            catch (Exception e)
            {
                return(CreateErrorResponse(e));
            }
        }
        public ActionResult Check(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 申请ID
            int aid = 0;

            /*
             * 参数获取
             */
            // 申请ID
            var id = collection["id"];
            // 审批意见
            var checkOpinion = collection["checkOpinion"];
            // 审批状态
            var checkStatus = collection["checkStatus"];

            /*
             * 参数校验
             */
            // 申请ID
            if (string.IsNullOrEmpty(id))
            {
                return(ResponseUtil.Error(400, "申请ID不能为空"));
            }
            else
            {
                if (!int.TryParse(id, out aid))
                {
                    return(ResponseUtil.Error(400, "申请ID不正确"));
                }
            }
            // 审批意见
            if (string.IsNullOrEmpty(checkOpinion))
            {
                return(ResponseUtil.Error(400, "审批意见不能为空"));
            }
            // 审批状态
            if (string.IsNullOrEmpty(checkStatus))
            {
                return(ResponseUtil.Error(400, "审批状态不能为空"));
            }

            /*
             * 审核逻辑
             */
            using (var db = new YGSDbContext())
            {
                var apply = db.Apply.Where(n => n.ID == aid).FirstOrDefault();
                if (apply == null)
                {
                    return(ResponseUtil.Error(400, "申请不存在"));
                }
                else
                {
                    apply.CheckOpinion = checkOpinion;
                    if (checkStatus == WHConstants.Check_Status_Pass)
                    {
                        // 获得所有外出人员id
                        //var historyIdList = apply.OutUsers.Split(',').Select(int.Parse).ToList();
                        //var outUserIds = db.History.Where(n => historyIdList.Contains(n.ID)).Select(n => n.UserId).ToList();
                        //var illegalUsers = db.User.Where(m => outUserIds.Contains(m.ID) && string.IsNullOrEmpty(m.CredNo)).ToList();

                        //if (illegalUsers.Count > 0)
                        //{
                        //    return ResponseUtil.Error(400, "出国人员缺少身份证号,请先到申请详情中补全");
                        //}
                        //else
                        //{
                        //    apply.ApplyStatus = WHConstants.Apply_Status_Passed;
                        //    NotificationUtil.SendNotification(apply.UserId, "您的出国申请已通过", "/Apps/YGS/Home/");
                        //}
                        apply.ApplyStatus = WHConstants.Apply_Status_Passed;
                        NotificationUtil.SendNotification(apply.UserId, "您的出国申请已通过", "/Apps/YGS/Home/");
                    }
                    else
                    {
                        apply.ApplyStatus = WHConstants.Apply_Status_Rejected;
                        NotificationUtil.SendNotification(apply.UserId, "您的出国申请被拒绝", "/Apps/YGS/Home/");
                    }
                    db.SaveChanges();

                    return(ResponseUtil.OK(200, "审批成功"));
                }
            }
        }
Beispiel #5
0
        public ActionResult DoAdd(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 当前用户
            var employee = (User.Identity as AppkizIdentity).Employee;

            /*
             * 参数获取
             */
            // 组团名
            var outName = collection["outName"];
            // 任务描述
            var descn = collection["desc"];
            // 出访类型
            var credType = collection["credType"];
            // 出访人员履历
            var outUsers = collection["outUsers"];
            // 申请附件
            var applyAtt = collection["applyAtt"];

            /*
             * 参数校验
             */
            // 团组名
            if (string.IsNullOrEmpty(outName))
            {
                return(ResponseUtil.Error(400, "团组名不能为空"));
            }
            // 出访任务
            if (string.IsNullOrEmpty(descn))
            {
                return(ResponseUtil.Error(400, "任务描述不能为空"));
            }
            // 出访类型
            if (string.IsNullOrEmpty(credType))
            {
                return(ResponseUtil.Error(400, "出访类型不能为空"));
            }
            // 人员ID列表
            if (string.IsNullOrEmpty(outUsers))
            {
                return(ResponseUtil.Error(400, "出访人员不能为空"));
            }
            // 申请附件ID不能为空
            if (string.IsNullOrEmpty(applyAtt))
            {
                return(ResponseUtil.Error(400, "申请附件不能为空"));
            }

            /*
             * 存储申请
             */
            using (var db = new YGSDbContext())
            {
                var apply = new YGS_Apply();
                apply.OutName     = outName;
                apply.Desc        = descn;
                apply.UserId      = employee.EmplID;
                apply.CredType    = credType;
                apply.OutUsers    = outUsers;
                apply.ApplyAtt    = applyAtt;
                apply.ApplyStatus = WHConstants.Apply_Status_Examing;
                apply.ApplyDate   = DateTime.Now;
                apply.NextStep    = "下载并填写表格";
                apply.CreateTime  = DateTime.Now;
                apply.UpdateTime  = DateTime.Now;
                apply.IsDelete    = false;
                db.Apply.Add(apply);
                db.SaveChanges();

                var notifyUserIdList = NotificationUtil.GetNotificationUsers();

                foreach (var user in notifyUserIdList)
                {
                    NotificationUtil.SendNotification(user, "您有新的出国申请审核", "/Apps/YGS/Home/Check");
                }

                return(ResponseUtil.OK(200, "创建成功"));
            }
        }
Beispiel #6
0
        public ActionResult DoUpdate(FormCollection collection)
        {
            /*
             * 变量定义
             */
            // 申请ID
            int aid = 0;

            /*
             * 参数获取
             */
            // 申请ID
            var id = collection["id"];
            // 团组名
            var outName = collection["outName"];
            // 出访任务
            var descn = collection["desc"];
            // 出访类型
            var credType = collection["credType"];
            // 人员ID列表
            var outUsers = collection["outUsers"];
            // 申请附件ID列表
            var applyAtt = collection["applyAtt"];
            // 资料回传附件ID列表
            var afterAtt = collection["afterAtt"];

            /*
             * 参数校验
             */
            // 申请ID
            if (string.IsNullOrEmpty(id))
            {
                return(ResponseUtil.Error(400, "申请ID不能为空"));
            }
            else
            {
                if (!int.TryParse(id, out aid))
                {
                    return(ResponseUtil.Error(400, "申请ID不正确"));
                }
            }
            // 团组名
            if (string.IsNullOrEmpty(outName))
            {
                return(ResponseUtil.Error(400, "团组名不能为空"));
            }
            // 出访任务
            if (string.IsNullOrEmpty(descn))
            {
                return(ResponseUtil.Error(400, "出访类型不能为空"));
            }
            // 人员ID列表
            if (string.IsNullOrEmpty(outUsers))
            {
                return(ResponseUtil.Error(400, "出访人员不能为空"));
            }
            // 申请附件ID不能为空
            if (string.IsNullOrEmpty(applyAtt))
            {
                return(ResponseUtil.Error(400, "申请附件不能为空"));
            }

            /*
             * 查询申请
             */
            using (var db = new YGSDbContext())
            {
                var apply = db.Apply.Where(n => n.ID == aid).FirstOrDefault();
                if (apply == null)
                {
                    return(ResponseUtil.Error(400, "申请不存在"));
                }
                else
                {
                    apply.OutName  = outName;
                    apply.Desc     = descn;
                    apply.CredType = credType;
                    apply.OutUsers = outUsers;
                    apply.ApplyAtt = applyAtt;
                    if (!string.IsNullOrEmpty(afterAtt))
                    {
                        apply.AfterAtt = afterAtt;
                    }
                    else
                    {
                        apply.AfterAtt = null;
                    }
                    // 如果当前申请是被拒绝,则重新到待审核中
                    if (apply.ApplyStatus == WHConstants.Apply_Status_Rejected)
                    {
                        apply.ApplyStatus = WHConstants.Apply_Status_Examing;

                        var notifyUserIdList = NotificationUtil.GetNotificationUsers();
                        foreach (var user in notifyUserIdList)
                        {
                            NotificationUtil.SendNotification(user, "您有新的出国申请审核", "/Apps/YGS/Home/Check");
                        }
                    }
                    db.SaveChanges();

                    return(ResponseUtil.OK(200, "申请更新成功"));
                }
            }
        }