Exemplo n.º 1
0
        public JsonResult PersonEducationCertificationsYears()
        {
            List <DDlList> _SessionList = new List <DDlList>(); int ConfiguredYear = TMSHelper.PersonEducationCertificationsPreviousYear();

            _SessionList = Utility.FillDropDownRecentYears(ConfiguredYear);
            return(Json(_SessionList, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state)
        {
            string cultureName = null;

            // Attempt to read the culture cookie from Request
            HttpCookie cultureCookie = Request.Cookies["_cultureTMS"];

            if (cultureCookie != null)
            {
                cultureName = cultureCookie.Value;
            }
            else
            {
                cultureName = TMSHelper.PrimaryLanguageCode().ToLower();
            }
            //Request.UserLanguages != null && Request.UserLanguages.Length > 0 ? Request.UserLanguages[0] : null; // obtain it from HTTP header AcceptLanguages

            // Validate culture name
            cultureName = CultureHelper.GetImplementedCulture(cultureName); // This is safe

            // Modify current thread's cultures
            Thread.CurrentThread.CurrentCulture   = new System.Globalization.CultureInfo(cultureName);
            Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

            return(base.BeginExecuteCore(callback, state));
        }
Exemplo n.º 3
0
        public ActionResult Attachment_Update([DataSourceRequest] DataSourceRequest request, TMS_Attachments _TMS_Attachments, string parentFoldername, long aid)
        {
            if (ModelState.IsValid)
            {
                _TMS_Attachments.CompletedDate = DateTime.Now;
                _TMS_Attachments.UpdatedBy     = CurrentUser.NameIdentifierInt64;
                _TMS_Attachments.UpdatedDate   = DateTime.Now;
                int result;
                if (_TMS_Attachments.FileType == AttachmentsFileType.AttachmentsFileType_ProfilePicture)
                {
                    _TMS_Attachments.ValidTill = DateTime.Now.AddMonths(TMSHelper.AttachmentValidTillPeriodInMonths());
                    _TMS_Attachments.ID        = aid;
                    result = _AttachmentBAL.TMS_Attachment_CompletedProfileLogoBAL(_TMS_Attachments);
                }
                else
                {
                    result = _AttachmentBAL.TMS_Attachment_UpdateBAL(_TMS_Attachments);
                }
                if (result == -1)
                {
                    ModelState.AddModelError(lr.ErrorServerError, lr.ResourceUpdateValidationError);
                }
            }
            var resultData = new[] { _TMS_Attachments };

            return(Json(resultData.ToDataSourceResult(request, ModelState)));
        }
Exemplo n.º 4
0
 private void ExecuteClientMethod(Action<TMSHelper> method)
 {
     try
     {
         var client = new TMSHelper(ConnectionString, true);
         method(client);
     }
     finally
     {
         tickets.Clear();
     }
 }
Exemplo n.º 5
0
        public string GetGroupName(long GroupId)
        {
            var GroupData = this._Groups.TMS_Groups_GetbyGroupIdBAL(CurrentCulture, GroupId);

            if (CurrentCulture == TMSHelper.PrimaryLangName())
            {
                return(GroupData.PrimaryGroupName);
            }
            else
            {
                return(GroupData.PrimaryGroupName);
            }
        }
Exemplo n.º 6
0
        public JsonResult PersonEducationDegreeDuration()
        {
            List <DDlList> _SessionList = new List <DDlList>();
            int            Duration     = TMSHelper.PersonEducationDegreeTotolDuration(); for (int count = 1; count <= Duration; count++)

            {
                _SessionList.Add(new DDlList {
                    Text = count.ToString(), Value = count
                });
            }

            return(Json(_SessionList, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 7
0
        private bool HandleSendEmailToUser(LoginUsers _objUsers)
        {
            EmailUtil emutil    = new EmailUtil();
            bool      isPrimary = false;
            string    Subject   = null;

            if (CurrentCulture == TMSHelper.PrimaryLanguageCode())
            {
                isPrimary = true;
            }
            var EmailBody = emutil.GetBody(_objUsers.UserID, (isPrimary == true ? _objUsers.P_DisplayName : _objUsers.S_DisplayName), isPrimary, ref Subject);

            return(EmailSend.SendMail(_objUsers.Email, null, Subject, EmailBody, false, null, null));
        }
Exemplo n.º 8
0
        public ActionResult Attachment_Create([DataSourceRequest] DataSourceRequest request, TMS_Attachments _TMS_Attachments, string parentFoldername, long aid)
        {
            if (ModelState.IsValid)
            {
                _TMS_Attachments.CompletedDate = DateTime.Now;
                if (_TMS_Attachments.ValidTill == null)
                {
                    _TMS_Attachments.ValidTill = DateTime.Now.AddMonths(TMSHelper.AttachmentValidTillPeriodInMonths());
                }
                _TMS_Attachments.ID = aid;
                _TMS_Attachments.FileParentRootFolder = parentFoldername;
                _AttachmentBAL.TMS_Attachment_CompletedBAL(_TMS_Attachments);
            }
            var resultData = new[] { _TMS_Attachments };

            return(Json(resultData.ToDataSourceResult(request, ModelState)));
        }
Exemplo n.º 9
0
        public ActionResult Login(LoginModel infoOfData)
        {
            infoOfData.isOffice365Enabled = false;

            var json = new JavaScriptSerializer().Serialize(infoOfData);

            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", L("Invalidpassword"));
                return(View(infoOfData));
            }
            else
            {
                Users _objUser = new Users();
                if (infoOfData.OrgnizationId > 0)
                {
                    _objUser = this.BALUsers.LoginUserBALForTrainer(infoOfData.Email, infoOfData.OrgnizationId);
                }
                else
                {
                    _objUser = this.BALUsers.LoginUserBAL(infoOfData.Email);
                }

                if (_objUser != null) //check if the email is found
                {
                    DateTime startTime = Convert.ToDateTime(_objUser.LockedOutDate);
                    DateTime endTime   = DateTime.Now;
                    Logger.Info("User tried to login with email " + infoOfData.Email + " at " + DateTime.UtcNow);
                    TimeSpan span = endTime.Subtract(startTime);

                    if (_objUser.IsLockedOut && span.TotalMinutes <= 10)
                    {
                        BALUsers.LogInsert(DateTime.Now.ToString(), "10", Logs.Login_Locked.ToString(), System.Environment.MachineName, "User tried to login with email " + infoOfData.Email + " at " + DateTime.UtcNow, "", 0, "Home", "Login", json.ToString(), 0);
                        ModelState.AddModelError("", "User Locked Please try after " + ConfigurationManager.AppSettings["LockedTime"].ToString() + " minutes");
                        return(View(infoOfData));
                    }
                    if (_objUser.IsLockedOut)
                    {
                        BALUsers.LogInsert(DateTime.Now.ToString(), "10", Logs.Login_Locked.ToString(), System.Environment.MachineName, "User tried to login with email " + infoOfData.Email + " at " + DateTime.UtcNow, "", 0, "Home", "Login", json.ToString(), 0);
                        ModelState.AddModelError("", "User Locked Please try after " + ConfigurationManager.AppSettings["LockedTime"].ToString() + " minutes");
                        return(View(infoOfData));
                    }
                    //then verify the password
                    if (string.IsNullOrEmpty(_objUser.Password))
                    {
                        ModelState.AddModelError("", L("Invalidpassword"));
                    }
                    else
                    {
                        //  UserHistory userlogin = new UserHistory();
                        //if (_objUser.UserID > 0)
                        //{
                        //    Session["UserID"] = _objUser.UserID;
                        //    userlogin.UserID = _objUser.UserID;
                        //    userlogin.LoginDateTime = DateTime.Now;
                        //    this.BALUsers.Create_UserHistoryBAL(userlogin);
                        //}
                        if (Crypto.VerifyPassword(infoOfData.Password, _objUser.Password))
                        {
                            Logger.Info("User login with email " + infoOfData.Email + " at " + DateTime.UtcNow);
                            Session["CompanyID"]    = _objUser.CompanyID;
                            Session["UserID"]       = _objUser.UserID;
                            userlogin.UserID        = _objUser.UserID;
                            userlogin.LoginDateTime = DateTime.Now;
                            this.BALUsers.Create_UserHistoryBAL(userlogin);
                            IdentitySignin(_objUser, false);
                            BALUsers.LogInsert(DateTime.Now.ToString(), "10", Logs.Login_Susscess.ToString(), System.Environment.MachineName, "User tried to login with email " + infoOfData.Email + " at " + DateTime.UtcNow, "", 0, "Home", "Login", json.ToString(), 0);
                            return(Redirect(GetRedirectUrl(infoOfData.ReturnUrl)));
                        }
                        else
                        {
                            if (_objUser.LockedOutAttempt >= TMSHelper.FormAuthenticationLockedOutAttemptMax())
                            {
                                BALUsers.LogInsert(DateTime.Now.ToString(), "10", Logs.Login_Attempt.ToString(), System.Environment.MachineName, "User tried to login with email " + infoOfData.Email + " at " + DateTime.UtcNow, "", 0, "Home", "Login", json.ToString(), 0);
                                this.BALUsers.UpdateUserLockedOutBAL(infoOfData.Email, _objUser.UserID, _objUser.LockedOutAttempt + 1, true);
                                ModelState.AddModelError("", lr.UserLockedOutMessage);
                            }
                            else
                            {
                                this.BALUsers.UpdateUserLockedOutBAL(infoOfData.Email, _objUser.UserID, _objUser.LockedOutAttempt + 1, false);
                                BALUsers.LogInsert(DateTime.Now.ToString(), "10", Logs.Login_Attempt.ToString(), System.Environment.MachineName, "User tried to login with email " + infoOfData.Email + " at " + DateTime.UtcNow, "", 0, "Home", "Login", json.ToString(), 0);

                                if (_objUser.LockedOutAttempt >= TMSHelper.FormAuthenticationLockedOutAttemptNotifyUser())
                                {
                                    ModelState.AddModelError("", lr.InvalidpasswordWithAttempts + " " + (TMSHelper.FormAuthenticationLockedOutAttemptMax() - _objUser.LockedOutAttempt));
                                }
                                else
                                {
                                    ModelState.AddModelError("", L("Invalidpassword"));
                                }
                            }
                        }
                    }
                }
                else
                {//user is not found with form authentication.
                    BALUsers.LogInsert(DateTime.Now.ToString(), "10", Logs.Login_Attempt.ToString(), System.Environment.MachineName, "User tried to login with email " + infoOfData.Email + " at " + DateTime.UtcNow, "", 0, "Home", "Login", json.ToString(), 0);

                    ModelState.AddModelError("", L("Invalidpassword"));
                }
                return(View(infoOfData));
            }
        }
Exemplo n.º 10
0
        public ActionResult EmailAddress_Create([DataSourceRequest] DataSourceRequest request, string pid, EmailAddresses _objEmailAddresses)
        {
            if (ModelState.IsValid)
            {
                if (_UserBAL.LoginPerson_DuplicationCheckBAL(new Person {
                    Email = _objEmailAddresses.Email, CreatedBy = CurrentUser.NameIdentifierInt64
                }) > 0)
                {
                    ModelState.AddModelError(lr.UserEmailAlreadyExist, lr.UserEmailAlreadyExist);
                    // return Json(lr.UserEmailAlreadyExist, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    _objEmailAddresses.CreatedBy   = CurrentUser.NameIdentifierInt64;
                    _objEmailAddresses.CreatedDate = DateTime.Now;
                    if (_objPersonContactBAL.PersonEmailAddress_GetCountByPersonIDBAL(Convert.ToInt64(pid)) >= TMSHelper.GetPersonEmailLimit())
                    {
                        ModelState.AddModelError(lr.PersonContactEmail, string.Format(lr.PersonContactEmailLimit, TMSHelper.GetPersonEmailLimit().ToString()));
                    }
                    else if (_objPersonContactBAL.PersonEmailAddress_DuplicationCheckBAL(_objEmailAddresses, Convert.ToInt64(pid)) > 0)
                    {
                        ModelState.AddModelError(lr.PersonContactEmail, lr.PersonContactEmailDuplicationCheck);
                    }
                    else
                    {
                        _objEmailAddresses.ID = _objPersonContactBAL.PersonEmailAddress_CreateBAL(_objEmailAddresses, Convert.ToInt64(pid));
                    }
                }
            }
            var resultData = new[] { _objEmailAddresses };

            return(Json(resultData.ToDataSourceResult(request, ModelState)));
        }
Exemplo n.º 11
0
        public ActionResult Links_Create([DataSourceRequest] DataSourceRequest request, long oid, int type, Links _objLinks)
        {
            if (ModelState.IsValid)
            {
                _objLinks.CreatedBy   = CurrentUser.NameIdentifierInt64;
                _objLinks.CreatedDate = DateTime.Now;
                _objLinks.Description = "";
                if (type == 1)
                {
                    if (_objPersonContactBAL.PersonLinks_GetCountByPersonIDBAL(Convert.ToInt64(oid)) >= TMSHelper.GetPersonLinksLimit())
                    {
                        ModelState.AddModelError(lr.PersonContactLink, lr.PersonContactLinkMaxLimit);
                    }
                    else if (_objPersonContactBAL.PersonLinks_DuplicationCheckBAL(_objLinks, Convert.ToInt64(oid)) > 0)
                    {
                        ModelState.AddModelError(lr.PersonContactLink, lr.PersonContactLinkDuplicationCheck);
                    }
                    else
                    {
                        _objLinks.ID = _objPersonContactBAL.PersonLinks_CreateBAL(_objLinks, Convert.ToInt64(oid));
                    }
                }
                else
                {
                    if (_objIOrganizationBAL.OrganizationLinks_GetCountByOrganizationIDBAL(Convert.ToInt64(oid)) >= TMSHelper.GetPersonLinksLimit())
                    {
                        ModelState.AddModelError(lr.PersonContactLink, lr.OrganizationContactLinkMaxLimit);
                    }
                    else if (_objIOrganizationBAL.OrganizationLinks_DuplicationCheckBAL(_objLinks, Convert.ToInt64(oid)) > 0)
                    {
                        ModelState.AddModelError(lr.PersonContactLink, lr.OrganizationContactLinkDuplicationCheck);
                    }
                    else
                    {
                        _objLinks.ID = _objIOrganizationBAL.OrganizationLinks_CreateBAL(_objLinks, Convert.ToInt64(oid));
                    }
                }
            }
            var resultData = new[] { _objLinks };

            return(Json(resultData.ToDataSourceResult(request, ModelState)));
        }
Exemplo n.º 12
0
        public ActionResult Login(LoginModel infoOfData)
        {
            infoOfData.isOffice365Enabled = false;


            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", L("Invalidpassword"));
                return(View(infoOfData));
            }
            else
            {
                var _objUser = this.BALUsers.LoginUserBAL(infoOfData.Email);


                if (_objUser != null)//check if the email is found
                {
                    if (_objUser.IsLockedOut)
                    {
                        ModelState.AddModelError("", lr.UserLockedOutMessage);
                        return(View(infoOfData));
                    }
                    //then verify the password
                    if (string.IsNullOrEmpty(_objUser.Password))
                    {
                        ModelState.AddModelError("", L("Invalidpassword"));
                    }
                    else
                    {
                        //  UserHistory userlogin = new UserHistory();
                        //if (_objUser.UserID > 0)
                        //{
                        //    Session["UserID"] = _objUser.UserID;
                        //    userlogin.UserID = _objUser.UserID;
                        //    userlogin.LoginDateTime = DateTime.Now;
                        //    this.BALUsers.Create_UserHistoryBAL(userlogin);
                        //}
                        if (Crypto.VerifyPassword(infoOfData.Password, _objUser.Password))
                        {
                            Session["CompanyID"]    = _objUser.CompanyID;
                            Session["UserID"]       = _objUser.UserID;
                            userlogin.UserID        = _objUser.UserID;
                            userlogin.LoginDateTime = DateTime.Now;
                            this.BALUsers.Create_UserHistoryBAL(userlogin);
                            IdentitySignin(_objUser, false);
                            return(Redirect(GetRedirectUrl(infoOfData.ReturnUrl)));
                        }
                        else
                        {
                            if (_objUser.LockedOutAttempt >= TMSHelper.FormAuthenticationLockedOutAttemptMax())
                            {
                                this.BALUsers.UpdateUserLockedOutBAL(infoOfData.Email, _objUser.UserID, _objUser.LockedOutAttempt + 1, true);
                                ModelState.AddModelError("", lr.UserLockedOutMessage);
                            }
                            else
                            {
                                this.BALUsers.UpdateUserLockedOutBAL(infoOfData.Email, _objUser.UserID, _objUser.LockedOutAttempt + 1, false);

                                if (_objUser.LockedOutAttempt >= TMSHelper.FormAuthenticationLockedOutAttemptNotifyUser())
                                {
                                    ModelState.AddModelError("", lr.InvalidpasswordWithAttempts + " " + (TMSHelper.FormAuthenticationLockedOutAttemptMax() - _objUser.LockedOutAttempt));
                                }
                                else
                                {
                                    ModelState.AddModelError("", L("Invalidpassword"));
                                }
                            }
                        }
                    }
                }
                else
                {//user is not found with form authentication.
                    ModelState.AddModelError("", L("Invalidpassword"));
                }
                return(View(infoOfData));
            }
        }