Beispiel #1
0
        public JsonResult BatchLogOutUserByUserIdAction()
        {
            try
            {
                if (Request.Files.Count > 0)
                {
                    var file = Request.Files[0];
                    if (!file.FileName.Contains(".xlsx") && !file.FileName.Contains(".xls"))
                    {
                        return(Json(new { Status = -1, Error = "请上传.xlsx文件或者.xls文件!" }, "text/html"));
                    }

                    var excel = new Controls.ExcelHelper(file.InputStream, file.FileName);
                    var dt    = excel.ExcelToDataTable("sheet1", true);

                    foreach (DataRow dr in dt.Rows)
                    {
                        var userid = dr[0].ToString();
                        if (!string.IsNullOrWhiteSpace(userid))
                        {
                            LogOutUserByUserId(userid);
                        }
                    }
                }
                return(Json(new { Status = -1, Error = "请选择文件" }, "text/html"));
            }
            catch (Exception ex)
            {
                WebLog.LogException(ex);
                return(Json(new { Status = -2, Error = ex }, "text/html"));
            }
        }
Beispiel #2
0
        private void LogOutUserByUserId(string userId)
        {
            if (!string.IsNullOrWhiteSpace(userId))
            {
                Guid uId = new Guid(userId);
                try
                {
                    using (var client = new AccessTokenClient())
                    {
                        var result = client.RemoveAll(uId, "Setting站点工具登出");
                        result.ThrowIfException(true);
                    }

                    using (var useraccoutClient = new UserAccountClient())
                    {
                        var insertLog = useraccoutClient.LogUserAction(new UserLog
                        {
                            Action      = UserActionEnum.LogOut,
                            CreatedTime = DateTime.Now,
                            UserId      = uId,
                            ChannelIn   = nameof(ChannelIn.H5),
                            Content     = "Setting站点内手动登出该用户"
                        });
                        insertLog.ThrowIfException(true);
                    }
                }
                catch (Exception ex)
                {
                    WebLog.LogException(ex);
                }
            }
        }
Beispiel #3
0
        public List <getAllUserAndRoles> getAllUsersAndRoles()
        {
            //---- Create object of our entities class.
            try
            {
                LoanViewModel lvm  = new LoanViewModel();
                var           user = "******";
                users.Email = user;
                users.id    = DataReaders.selectUserID(users);

                var results = (from a in db.UserRoles
                               join c in db.Roles on a.RoleId equals c.RoleId
                               join b in db.Users on a.UserId equals b.id
                               //where a.UserId == users.id
                               select new Models.getAllUserAndRoles {
                    userid = b.id, roleid = c.RoleId, rolename = c.RoleName, email = b.Email, id = a.id
                }).ToList();
                var model = new LoanViewModel
                {
                    getAllUserAndRoless = results.ToList(),
                };
                lvm.getAllUserAndRoless = results;
                return(lvm.getAllUserAndRoless.ToList());
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
Beispiel #4
0
        public ActionResult Login(LoanViewModel lvm)
        {
            try
            {
                users.Email   = lvm.AccountsModel.Email;
                users.pasword = lvm.AccountsModel.pasword;
                var EncrypPassword = new CryptographyManager().ComputeHash(users.pasword, HashName.SHA256);
                users.pasword = EncrypPassword;

                var valid = DataReaders.loggedIn(users.Email, EncrypPassword);

                if (valid == true)
                {
                    if (users.Email != null)
                    {
                        Session["id"]   = users.Email;
                        Session["User"] = "******" + Session["id"];
                        var    LoggedInuser = new LogginHelper();
                        string user         = LoggedInuser.LoggedInUser();
                        return(View("index"));
                    }
                    else
                    {
                        ViewBag.Message = "Invalid Details ! Try Again";
                        return(View("Signin"));
                    }
                }
                return(View("Signin"));
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
Beispiel #5
0
        public JsonResult UploadImage()
        {
            var result = "";

            if (Request.Files.Count > 0)
            {
                var Imgfile = Request.Files[0];
                try
                {
                    var buffer = new byte[Imgfile.ContentLength];
                    Imgfile.InputStream.Read(buffer, 0, buffer.Length);
                    using (var client = new FileUploadClient())
                    {
                        var res = client.UploadImage(new ImageUploadRequest()
                        {
                            Contents      = buffer,
                            DirectoryName = "TaskConfig",
                            MaxHeight     = 1920,
                            MaxWidth      = 1920
                        });
                        if (res.Success && res.Result != null)
                        {
                            result = ImageHelper.GetImageUrl(res.Result);
                        }
                    }
                }
                catch (Exception exp)
                {
                    WebLog.LogException(exp);
                }
            }
            return(Json(result));
        }
Beispiel #6
0
        public ActionResult UserRole(LoanViewModel lvm, FormCollection form)
        {
            try
            {
                int roleid = Convert.ToInt16(form["roleid"]);
                int userid = Convert.ToInt16(form["id"]);
                userroles.RoleId = roleid;
                userroles.UserId = userid;
                userroles.RoleId = DataReaders.selectRolesByName(userroles);
                if (userroles.RoleId != 0)
                {
                    TempData["message"] = "User Already Have This Role";
                    return(View(""));
                }
                else

                {
                    userroles.RoleId     = roleid;
                    userroles.UserId     = userid;
                    userroles.IsVissible = 1;
                    userroles.dates      = DateTime.Now;

                    DataCreators.InsertUserRoles(userroles);
                    TempData["message"]     = "User n Roles Created Succesfully";
                    lvm.getAllUserAndRoless = getAllUsersAndRoles();
                }
                return(View(""));
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
Beispiel #7
0
        public int CreateUserRole(User users, int flag)
        {
            try
            {
                UserRole UserRoles = new UserRole();
                UserRoles.User_FK = users.ID;
                if (flag == 1)
                {
                    UserRoles.Role_FK = Convert.ToInt16(ConfigurationManager.AppSettings["NYSCAgentRole"]);
                }
                if (flag == 2)
                {
                    UserRoles.Role_FK = Convert.ToInt16(ConfigurationManager.AppSettings["NYSCApplicantRole"]);
                }

                UserRoles.IsVisible = 1;
                _DM.InsertUserRoles(UserRoles);
                return(users.ID);
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(0);
            }
        }
Beispiel #8
0
        public void SendEmail(User userObj, string password)
        {
            try
            {
                string referralLink = ConfigurationManager.AppSettings["ReferralLink"] + userObj.MyReferralCode;
                var    bodyTxt      = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailNotifications/ReferralWelcomeEmail.html"));

                string myname = userObj.Firstname;
                bodyTxt = bodyTxt.Replace("$firstName", myname);
                bodyTxt = bodyTxt.Replace("$UserName", userObj.EmailAddress);
                bodyTxt = bodyTxt.Replace("$passwordVal", password);
                bodyTxt = bodyTxt.Replace("$refferalCode", userObj.MyReferralCode);
                bodyTxt = bodyTxt.Replace("$referralLink", referralLink);
                //bodyTxt = bodyTxt.Replace("$RepaymentAmt", MyUtility.ConvertToCurrency(apObj.RepaymentAmount));
                //WebLog.Log(bodyTxt);
                // WebLog.Log("apObj.EmailAddress: " + apObj.EmailAddress);
                var msgHeader = $"Welcome to CashNowNow Referral Network";
                WebLog.Log("msgHeader " + msgHeader);
                var sendMail = NotificationService.SendMailOut(msgHeader, bodyTxt, userObj.EmailAddress, null, null);
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
            }
        }
Beispiel #9
0
    protected virtual void btnSave_Click(object sender, EventArgs e)
    {
        string ret, sql;

        ret = ControlWebValidator.Validate(this.Page, Session["TableName"].ToString());
        if (ret.Length > 0)
        {
            info.InnerText = ret;
            return;
        }
        ret = CustomControlSave.CustomControlSaveByTableNameReturnS(this.Page, Session["TableName"].ToString(), out sql);
        if (ret.Length > 0)
        {
            info.InnerText = ret;
            return;
        }
        else
        {
            info.InnerText = "";
            WebLog.InsertLog("", "成功", sql);
        }
        //JScript.CloseWin("refreshPage");

        Response.Redirect(Session["URL"].ToString());
    }
Beispiel #10
0
    /// <summary>
    /// 页面出错,记录出错的日志
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected virtual void Page_Error(object sender, EventArgs e)
    {
        string errMsg;
        //得到系统上一个异常
        Exception currentError = Server.GetLastError();

        errMsg  = "<link rel=\"stylesheet\" href=\"/default.css\">";
        errMsg += "<h1>" + (String)GetGlobalResourceObject("WebGlobalResource", "Error") + "</h1>" +
                  (String)GetGlobalResourceObject("WebGlobalResource", "ErrorPosition") + Request.Url.ToString() + "<br/><hr/>" +
                  (String)GetGlobalResourceObject("WebGlobalResource", "ErrorMessage") + " <font class=\"ErrorMessage\">" + currentError.Message.ToString() + "</font><hr/>" +
                  "<b>Stack Trace:</b><br/>" +
                  currentError.ToString();
        //如果发生致命应用程序错误
        //if (!(currentError is ApplicationException))
        //{
        //向Windows事件日志中写入错误日志
        // LogEvent(currentError.ToString(), EventLogEntryType.Error);
        //}
        //在页面中显示错误
        Response.Write(errMsg);
        //记录错误到日志中
        WebLog.InsertLog("错误", "", "网页名:" + Request.Url.ToString() + " ; 错误信息:" + currentError.Message.ToString() + "; 错误发生地点:" + currentError.StackTrace);
        //清除异常
        Server.ClearError();
    }
Beispiel #11
0
        public int UpdateLedger(string IDS, NYSCLoanLedger LoanLedger)
        {
            try
            {
                int ID = Convert.ToInt32(IDS);
                // LoanLedger.ID = ID;
                // var resp = uvDb.NYSCLoanLedgers.Find(LoanLedger.ID);

                var resp = uvDb.NYSCLoanLedgers.Find(ID);

                if (resp != null)
                {
                    // resp.Credit = resp.Debit;
                    resp.Debit       = LoanLedger.Credit;
                    resp.PaymentFlag = LoanLedger.PaymentFlag;
                    uvDb.SaveChanges();
                }
                return(resp.ID);
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(0);
            }
        }
Beispiel #12
0
        public string getDiscoName(string DiscoId)
        {
            try
            {
                string Disconame = "";
                switch (DiscoId)
                {
                case "1":
                    Disconame = "StarTimes";
                    break;

                case "2":
                    Disconame = "DSTV";
                    break;

                case "3":
                    Disconame = "GOTV";
                    break;

                case "4":
                    Disconame = "KWESE";
                    break;

                default:
                    break;
                }
                TempData["Disconame"] = Disconame;
                return(TempData["Disconame"].ToString());
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
Beispiel #13
0
 public ActionResult WalletReceipt()
 {
     try
     {
         Classes.Paytv.Receipt Receipt = new Classes.Paytv.Receipt();
         string RefNum = Request.QueryString["RefNum"];
         if (RefNum == null)
         {
             return(RedirectToAction("BuyAirtime", "Airtime"));
         }
         if (RefNum != null)
         {
             TempData["ErrMsg"] = "Transaction successful ! Thank You";
             var CusTransac = _dr.GetRecord(RefNum);
             Receipt.CustomerID     = CusTransac.CustomerID;
             Receipt.Amount         = Convert.ToDouble(CusTransac.Amount);
             TempData["Amount"]     = Receipt.Amount;
             Receipt.customerName   = CusTransac.CustomerName;
             Receipt.Phone          = CusTransac.CustomerPhone;
             Receipt.transactionlNo = CusTransac.ReferenceNumber;
             Receipt.Service        = CusTransac.ServiceDetails;
             Receipt.ErrorMsg       = TempData["ErrMsg"].ToString();
         }
         return(View(Receipt));
     }
     catch (Exception ex)
     {
         WebLog.Log(ex.Message.ToString());
         return(null);
     }
 }
Beispiel #14
0
        public PartialViewResult LogOutUserByMobileInfo(string mobileNumber)
        {
            User info = new Service.UserAccount.Models.User();

            if (!string.IsNullOrWhiteSpace(mobileNumber))
            {
                try
                {
                    using (var client = new UserAccountClient())
                    {
                        var result = client.GetUserByMobile(mobileNumber);
                        result.ThrowIfException(true);
                        if (result.Success && result.Result != null)
                        {
                            info = result.Result;
                        }
                    }
                }
                catch (Exception ex)
                {
                    WebLog.LogException(ex);
                }
            }
            return(PartialView(info));
        }
Beispiel #15
0
        public static string postNewXMLData(string destinationUrl, string requestXml)
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(destinationUrl);
                byte[]         bytes;
                bytes = System.Text.Encoding.ASCII.GetBytes(requestXml);
                request.ContentType   = "text/xml; encoding='utf-8'";
                request.ContentLength = bytes.Length;
                request.Method        = "POST";

                Stream requestStream = request.GetRequestStream();
                requestStream.Write(bytes, 0, bytes.Length);
                requestStream.Close();
                HttpWebResponse response;
                response = (HttpWebResponse)request.GetResponse();
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Stream responseStream = response.GetResponseStream();
                    string responseStr    = new StreamReader(responseStream).ReadToEnd();
                    return(responseStr);
                }
                return(null);
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message);
                return(null);
            }
        }
Beispiel #16
0
        public JsonResult UploadImage()
        {
            var result = "";

            if (Request.Files.Count > 0)
            {
                var Imgfile = Request.Files[0];
                try
                {
                    var buffer = new byte[Imgfile.ContentLength];
                    Imgfile.InputStream.Read(buffer, 0, buffer.Length);
                    using (var client = new FileUploadClient())
                    {
                        var res = client.UploadImage(new ImageUploadRequest()
                        {
                            Contents      = buffer,
                            DirectoryName = "BannerConfigImg",
                            MaxHeight     = 1920,
                            MaxWidth      = 1920
                        });
                        if (res.Success && res.Result != null)
                        {
                            result = WebConfigurationManager.AppSettings["DoMain_image"] + res.Result;
                        }
                    }
                }
                catch (Exception exp)
                {
                    WebLog.LogException(exp);
                }
            }
            return(Json(result));
        }
Beispiel #17
0
 public int LoanRepayment(int tenure, double RepayAmount, string ReferenceNum)
 {
     try
     {
         var i        = 0;
         var original = (from a in uvDb.LoanLedgers
                         where a.RefNumber == ReferenceNum && a.Credit == 0
                         select a).ToList();
         if (original.Count > 0)
         {
             for (i = 0; i <= tenure; i++)
             {
                 for (i = 0; i <= original.Count; i++)
                 {
                     original[i].Credit         = RepayAmount;
                     original[i].PaymentFlag_FK = 1;
                     uvDb.SaveChanges();
                 }
             }
         }
         return(original.Count);
     }
     catch (Exception ex)
     {
         WebLog.Log(ex.Message.ToString());
         return(0);
     }
 }
Beispiel #18
0
        public int UpdateLoanTenureAndInterestRate(string RefNum, double LoanAmount, int LoanTenure, int INST)
        {
            try
            {
                var InterestRate = (from a in uvDb.LoanInterestRates where a.Institution_FK == INST && a.LoanTenure == LoanTenure select a.InterestRate).FirstOrDefault();
                if (InterestRate == 0)
                {
                    return((int)InterestRate);
                }
                if (InterestRate != 0)
                {
                    var original = (from a in uvDb.LoanApplications
                                    where a.LoanRefNumber == RefNum
                                    select a).FirstOrDefault();

                    if (original != null)
                    {
                        original.ApprovedTenure     = LoanTenure;
                        original.ApprovedLoanAmount = LoanAmount;
                        original.ApprovedInterest   = InterestRate;

                        uvDb.SaveChanges();
                    }
                    return(original.ID);
                }
                return((int)InterestRate);
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(0);
            }
        }
Beispiel #19
0
        public int UpdateEmployeeInfo(EmployerLoanDetail LoanApp)
        {
            try
            {
                var EmpDetails = uvDb.EmployerLoanDetails.Find(LoanApp.LoanApplication_FK);
                if (EmpDetails != null)
                {
                    EmpDetails.Department           = LoanApp.Department;
                    EmpDetails.Designation          = LoanApp.Designation;
                    EmpDetails.EmployerID           = LoanApp.EmployerID;
                    EmpDetails.EmploymentStatus_FK  = LoanApp.EmploymentStatus_FK;
                    EmpDetails.NetMonthlyIncome     = LoanApp.NetMonthlyIncome;
                    EmpDetails.OfficialEmailAddress = LoanApp.OfficialEmailAddress;
                    EmpDetails.LengthOfServiceInMth = LoanApp.LengthOfServiceInMth;
                    EmpDetails.Occupation           = LoanApp.Occupation;

                    uvDb.SaveChanges();
                }
                return(EmpDetails.ID);
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(0);
            }
        }
Beispiel #20
0
        public List <LoanLedger> UpdateLoanLedger(string RefNum, double LoanAmt)
        {
            try
            {
                // var resp = (from a in uvDb.LoanLedgers where a.RefNumber == RefNum select a).ToList();
                var resp        = SelectLoanLedger(RefNum, LoanAmt);
                var Firstrecord = resp.First();
                if (Firstrecord != null)
                {
                    Firstrecord.Credit         = LoanAmt;
                    Firstrecord.PaymentFlag_FK = 1;
                    uvDb.SaveChanges();
                }

                var query = "UPDATE LoanLedger SET PaymentFlag_FK = 2 WHERE RefNumber = '" + RefNum + "' AND Credit = 0";
                using (var context = new UvlotEntities())
                {
                    context.Database.ExecuteSqlCommand(query);
                }


                if (resp == null)
                {
                    return(null);
                }
                return(resp.ToList());
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
Beispiel #21
0
        public int UpdateEmpInfo(EmployerLoanDetail EmpAp)
        {
            try
            {
                var original = (from a in uvDb.EmployerLoanDetails where a.LoanApplication_FK == EmpAp.ID select a).First();
                if (original.ID != 0)
                {
                    original.NetMonthlyIncome     = EmpAp.NetMonthlyIncome;
                    original.Occupation           = EmpAp.Occupation;
                    original.EmploymentStatus_FK  = EmpAp.EmploymentStatus_FK;
                    original.EmployerID           = EmpAp.EmployerID;
                    original.Department           = EmpAp.Department;
                    original.Designation          = EmpAp.Designation;
                    original.LengthOfServiceInYrs = EmpAp.LengthOfServiceInYrs;
                    original.OfficialEmailAddress = EmpAp.OfficialEmailAddress;
                    uvDb.SaveChanges();
                }
                return(original.ID);
            }


            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(0);
            }
        }
Beispiel #22
0
        public int UpdateLoanApplication(LoanApplication LoanApp)
        {
            try
            {
                var original = uvDb.LoanApplications.Find(LoanApp.LoanRefNumber);


                if (original != null)
                {
                    original.ApplicationStatus_FK = LoanApp.ApplicationStatus_FK;
                    // original.LoanComment = LoanApp.LoanComment;
                    original.DateModified = LoanApp.DateModified;

                    uvDb.SaveChanges();
                }
                return(original.ID);
            }


            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(0);
            }
        }
Beispiel #23
0
        public static int SaveBVNDetails(Helper.BVNC bvnc)
        {
            int i = 0;

            try
            {
                BanksManager bObj = new BanksManager
                {
                    BankName         = bvnc.EnrollmentBank,
                    ContactAddress   = bvnc.address,
                    DateOfBirth      = bvnc.Dateofbirth,
                    EnrollmentBranch = bvnc.EnrollmentBranch,
                    Firstname        = bvnc.FirstNAme,
                    Gender           = bvnc.gender,
                    IsVisible        = 1,
                    Lastname         = bvnc.LastName,
                    Marital_Status   = bvnc.marital_status,
                    Nationlaity      = bvnc.Nationality,
                    Othernames       = bvnc.MiddleName,
                    ValueDate        = MyUtility.getCurrentLocalDateTime().ToString("yyyy/MM/dd"),
                    VerifiedStatus   = bvnc.respCode == "00" ? 1 : 0,
                    ServiceResponse  = bvnc.respDescription
                };
                uvDb.BanksManagers.Add(bObj);
                uvDb.SaveChanges();
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message);
            }
            return(i);
        }
Beispiel #24
0
        public string UpdateEmp(string id)
        {
            try
            {
                var ids    = Convert.ToInt16(id);
                var i      = 0;
                var RefNum = (from a in uvDb.LoanApplications where a.ID == ids select a.LoanRefNumber).FirstOrDefault();
                if (RefNum != null)
                {
                    var original = (from a in uvDb.LoanLedgers where a.RefNumber == RefNum && a.PaymentFlag_FK == 0 select a).ToList();
                    if (original.Count > 0)
                    {
                        for (i = 1; i == original.Count; i++)
                        {
                            original[i].Institution_FK = 7;

                            uvDb.SaveChanges();
                        }
                    }
                }
                return(RefNum);
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
Beispiel #25
0
        public string UpdateProfile(User users)
        {
            try
            {
                var original = (from a in uvDb.Users
                                where a.ID == users.ID select a).FirstOrDefault();

                if (original != null)
                {
                    original.Firstname = users.Firstname;
                    original.Lastname  = users.Lastname;
                    //original.EmailAddress = users.EmailAddress;
                    original.PhoneNumber = users.PhoneNumber;
                    // original.PaswordVal = users.PaswordVal;


                    uvDb.SaveChanges();
                }
                return(original.ID.ToString());
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(ex.StackTrace.ToString());
            }
        }
Beispiel #26
0
        public int UpdateNYSCLoanReferalLeder(List <LoansLedger> Ln, double mode, double div)
        {
            try
            {
                var bn = 0;
                int nb = Ln.Count;
                for (var c = 0; c < nb; c++)
                {
                    int cv       = Ln[c].ID;
                    var original = (from a in Ln where a.ID == cv select a).SingleOrDefault();

                    if (c + 1 == div && mode != 0)
                    {
                        original.Credit = mode;
                    }

                    else
                    {
                        original.Credit = original.Debit;
                    }
                    uvDb.SaveChanges();

                    bn = original.ID;
                }



                return(bn);
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(0);
            }
        }
Beispiel #27
0
 public ActionResult SendMessage(string phone)
 {
     try
     {
         if (string.IsNullOrEmpty(phone) || !ValidatePhone(phone))
         {
             return(Json(new { isSuccess = false, status = EntryStatus.FormatError }, JsonRequestBehavior.AllowGet));
         }
         var vCode = GeneraCode();
         using (var client = new SmsClient())
         {
             client.SendVerificationCode(new SendVerificationCodeRequest
             {
                 Cellphone        = phone,
                 Host             = Request.Url.Host,
                 UserIp           = Request.UserIp(),
                 VerificationCode = vCode
             }).ThrowIfException(true);
         }
         var result = SetVcode(phone, vCode);
         return(Json(new { isSuccess = result }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         WebLog.LogException(ex);
         return(Json(new { isSuccess = false, status = EntryStatus.EntryError }, JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #28
0
 /// <summary>
 /// 报名参加
 /// </summary>
 /// <returns></returns>
 public static EntryStatus Entry(string phone)
 {
     try
     {
         //如果手机号已注册
         if (GetUserByPhone(phone) != null)
         {
             return(Insert(phone));
         }
         else
         {
             //如果手机号注册成功并且报名成功
             if (CreateUser(phone) != null && Insert(phone) == EntryStatus.Success)
             {
                 return(EntryStatus.RegisterASuccess);
             }
             else
             {
                 return(EntryStatus.EntryError);
             }
         }
     }
     catch (Exception ex)
     {
         WebLog.LogException(ex);
         return(EntryStatus.EntryError);
     }
 }
Beispiel #29
0
 /// <summary>
 /// 获取用户信息by phone
 /// </summary>
 /// <param name="Phone"></param>
 /// <returns></returns>
 public static User GetUserByPhone(string Phone)
 {
     try
     {
         using (var client = new UserAccountClient())
         {
             var clientResult = client.GetUserByMobile(Phone);
             if (clientResult.Success && clientResult.Result != null)
             {
                 Log(UserActionEnum.Login, clientResult.Result.UserId, "chexian_获取用户信息,GetUserByPhone:成功");
                 return(clientResult.Result);
             }
             else
             {
                 Log(UserActionEnum.Login, null, "chexian_获取用户信息,GetUserByMobileAsync:失败");
                 return(null);
             }
         }
     }
     catch (Exception ex)
     {
         WebLog.LogException(ex);
         return(null);
     }
 }
Beispiel #30
0
 private static void BuildLogHeaders(HttpClient client, string token = "")
 {
     try
     {
         //登录信息
         //client.DefaultRequestHeaders.Authorization = CreateBasicCredentials(Ticket.LoginName, Ticket.Id, Ticket.ChineseName);
         //填充日志所需头
         if (HttpContext.Current != null)
         {
             var rid = HttpContext.Current.Items["__RIO_RequestID"] as string;
             if (rid == null)
             {
                 rid = Guid.NewGuid().ToString("N");
                 HttpContext.Current.Items["__RIO_RequestID"] = rid;
             }
             client.DefaultRequestHeaders.Add("appkey", "M44NJ725jfnbT7PLkLfarvhpD2DZ7"); //TODO 可配置 appkey
             client.DefaultRequestHeaders.Add("token", token);                            //TODO 可配置 appkey
             client.DefaultRequestHeaders.Add("X-RIO-RequestID", rid.UrlEncode());
             client.DefaultRequestHeaders.Add("X-RIO-UserIP", ClientHelper.GetIP().UrlEncode());
             client.DefaultRequestHeaders.Add("X-RIO-LoginUserName", HttpContext.Current.User.Identity.Name.UrlEncode());
             client.DefaultRequestHeaders.Add("X-RIO-UserName", HttpContext.Current.User.Identity.Name.UrlEncode());
             client.DefaultRequestHeaders.Add("X-RIO-Url", HttpContext.Current.Request.Url.AbsoluteUri.UrlEncode());
             client.DefaultRequestHeaders.Add("X-RIO-UserAgent", HttpContext.Current.Request.UserAgent.UrlEncode());
             var referrer = HttpContext.Current.Request.UrlReferrer == null ? "" : HttpContext.Current.Request.UrlReferrer.AbsoluteUri;
             client.DefaultRequestHeaders.Add("X-RIO-Referer", referrer.UrlEncode());
         }
     }
     catch (Exception ex)
     {
         WebLog.Error(ex);
     }
 }
Beispiel #31
0
        public async Task<IHttpActionResult> AddLog(WebLog.Models.Log reg)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Logs.Add(reg);

            var i = await db.SaveChangesAsync();
            if(i>0)
            {
                return Ok();
            }
            else
            {
                return BadRequest("增加日志失败");
            }
        }
Beispiel #32
0
 public LogViewModel(WebLog entity)
 {
     this.MergeWithOtherType(entity);
     this.Id = entity.WebLogId;
     this.Source = "Web";
 }