Example #1
0
        public string GetCredit()
        {
            var identityName = System.Web.HttpContext.Current.User.Identity.Name;
            var res          = new ReportBlo().GetName_Bid_Balance(identityName);

            return(res.BalanceAmount.ToString());
        }
Example #2
0
        private bool FinallAddToJournal(PaymentTransactions paymentResponse)
        {
            //successfull Transaction now insert to main DB
            var    claims = (ClaimsIdentity)HttpContext.Current.User.Identity;
            var    sid    = claims.FindFirst(ClaimTypes.Sid);
            string title  = "افزایش اعتبار از طریق پنل مشتریان ";

            title += "با رسید دیجیتال ";
            title += paymentResponse.DigitalReceipt;

            StringBuilder details = new StringBuilder();

            details.Append("<ROOT>");
            details.AppendFormat("<JournalDetail AccountID=\"{0}\" TransactionAmount=\"{1}\"></JournalDetail>", "9", paymentResponse.Amount);
            long tt;

            long.TryParse("-" + paymentResponse.Amount.ToString(), out tt);
            details.AppendFormat("<JournalDetail AccountID=\"{0}\" TransactionAmount=\"{1}\"></JournalDetail></ROOT>", "7", tt);
            try
            {
                var finalInsert = new ReportBlo().JournalInsert(title, details.ToString());
                if (finalInsert > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        public async Task <HttpResponseMessage> SendEmail(ParametersofContactUs contactUs, IDictionary <string, Stream> attachedFiles)
        {
            const string EmailSubject = "پنل مشتریان";

            try
            {
                MailMessage mail = new MailMessage()
                {
                    IsBodyHtml = true,
                    From       = new MailAddress("*****@*****.**"),
                    Subject    = EmailSubject,
                    //  mail.CC.Add(model.Email);
                };
                SmtpClient SmtpServer = new SmtpClient();
                SmtpServer.Port                  = 25;
                SmtpServer.Host                  = "smtp.mobtakerancell.ir";
                SmtpServer.DeliveryMethod        = SmtpDeliveryMethod.Network;
                SmtpServer.UseDefaultCredentials = false;
                SmtpServer.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "123456");
                // SmtpServer.EnableSsl = false;
                SmtpServer.EnableSsl = true;

                if (attachedFiles.Count > 0)
                {
                    foreach (var attachedFile in attachedFiles)
                    {
                        mail.Attachments.Add(new Attachment(attachedFile.Value, attachedFile.Key));
                    }
                }

                var userName    = System.Web.HttpContext.Current.User.Identity.Name;
                var companyname = "unknown";
                if (userName != null)
                {
                    companyname = new ReportBlo().GetName_Bid_Balance(userName).CompanyName;
                }

                //setting new line
                contactUs.Message = contactUs.Message.Replace("\n", "<br />");
                mail.Body         = "<div style=\"font-family:B Yekan;text-align: right;font-size: 14px;\" dir=\"rtl\" >" + "موضوع: " + contactUs.Subject + "<br />" +
                                    "نام کاربری: " + userName + "<br />" + "نام مشتری: " + companyname + "<br />" +
                                    " واحد: " + contactUs.Unit + "<br />" + "اولویت: " + contactUs.Priority + "<br /> </div><div style=\"font-family:B Yekan;text-align: right;direction:rtl\" dir=\"rtl\">" +
                                    contactUs.Message + "</div>";

                mail.To.Add("*****@*****.**");
                await SmtpServer.SendMailAsync(mail);
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
        public IEnumerable <DataAccess.ChargeReport> ChargeReport([FromBody] ParametersofCharges parameters)
        {
            //if (System.Web.HttpContext.Current.User.Identity.Name != "admin")
            //    beentitylist = new usermanage().getbid(System.Web.HttpContext.Current.User.Identity.Name);

            var claims = (ClaimsIdentity)HttpContext.Current.User.Identity;
            var bid    = claims.FindFirst(ClaimTypes.Sid);

            parameters.AccountId = bid.Value;
            var result = new ReportBlo().GetChargeReport(parameters.FromDate, parameters.ToDate, parameters.AccountId);

            return(result);
        }
        public IEnumerable <Txn_SystemInfoD> GetDashboardData([FromBody] ParametersofDashboard parameters)
        {
            IEnumerable <Txn_SystemInfoD> result = null;
            var claims       = (ClaimsIdentity)HttpContext.Current.User.Identity;
            var bid          = claims.FindFirst(ClaimTypes.Sid);
            var identityName = System.Web.HttpContext.Current.User.Identity.Name;

            //if (identityName != null)
            //{
            //    var res = new ReportBlo().GetName_Bid_Balance(identityName);
            //    if(res!=null)
            result = new ReportBlo().GetChart(parameters.Date, long.Parse(bid.Value));
            //}
            return(result);
        }
        public IEnumerable <RepCheckDTO> QueryRepCheck([FromBody] ParametersofTransactions parameters)
        {
            //if (System.Web.HttpContext.Current.User.Identity.Name != "admin")
            //    beentitylist = new usermanage().getbid(System.Web.HttpContext.Current.User.Identity.Name);

            var claims = (ClaimsIdentity)HttpContext.Current.User.Identity;
            var bid    = claims.FindFirst(ClaimTypes.Sid);

            short  tbl = 1;
            string responsecode = null, id = null, refnum = null, beentitylist = bid.Value;

            if (parameters.TransactionStatus.ToString().Count() > 0)
            {
                int yy = (int)parameters.TransactionStatus;
                parameters.TransactionStatus = yy.ToString().ToCharArray().First();
            }

            var result = new ReportBlo().Sp_Rep_Check(tbl, parameters.PhoneNumber, responsecode, parameters.TransactionType, id, refnum,
                                                      parameters.SystemTransactionId, parameters.CustomerTransactionId, beentitylist, parameters.TransactionDate, parameters.TransactionStatus,
                                                      null, parameters.MobileCellOperator, parameters.PageIndex, parameters.PageSize);

            List <RepCheckDTO> finalResult = new List <RepCheckDTO>();

            if (result.Count() > 0)
            {
                foreach (var el in result)
                {
                    finalResult.Add(new RepCheckDTO
                    {
                        OperatorTitle  = el.OperatorTitle,
                        prcode         = el.Prcode,
                        OriginalAmount = el.OriginalAmount,
                        TxStatus       = el.TxStatus,
                        AddData1       = el.AddData1,
                        CreatedOn      = el.CreatedOn,
                        ModifiedOn     = el.ModifiedOn,
                        ReserveNumber_RequestSerial = el.ReserveNumber_RequestSerial.ToString(),
                        LocalSerial    = el.LocalSerial,
                        ResponseMsg    = el.ResponseMsg,
                        ResponseCode   = el.ResponseCode,
                        CustomerResMsg = ReturnProperResMsg(el.CURSPMSG)
                    });
                }
            }
            return(finalResult);
        }
Example #7
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });

            using (AuthRepository _repo = new AuthRepository())
            {
                IdentityUser user = await _repo.FindUser(context.UserName, context.Password);


                if (user == null)
                {
                    context.SetError("invalid_grant", "The user name or password is incorrect.");
                    return;
                }
                else
                {
                    var res = new ReportBlo().GetName_Bid_Balance(user.UserName);
                    if (res == null)
                    {
                        context.SetError("عدم ثبت مشتری", "مشتری با این مشخصات هنوز ثبت نشده است.");
                        return;
                    }

                    var identity = new ClaimsIdentity(context.Options.AuthenticationType);
                    identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));
                    identity.AddClaim(new Claim("role", "user"));

                    identity.AddClaim(new Claim(ClaimTypes.GivenName, res.CompanyName));
                    identity.AddClaim(new Claim(ClaimTypes.Sid, res.Id.ToString()));
                    identity.AddClaim(new Claim(ClaimTypes.UserData, res.BalanceAmount.ToString()));
                    var props = new AuthenticationProperties(new Dictionary <string, string>
                    {
                        {
                            "companyName", identity.FindFirst(ClaimTypes.GivenName).Value
                        },
                        {
                            "credit", identity.FindFirst(ClaimTypes.UserData).Value
                        },
                    });

                    context.Validated(new AuthenticationTicket(identity, props));
                }
            }
        }