예제 #1
0
        public ActionResult AddEdit(int id, Users usr, string LinkedLoc, string UnlinkedLoc)
        {
            if (base.IsAutoPostback() || !ModelState.IsValid)
            {
                doAddEditPopulate(id, usr);
                #region Use if using Users.Location -at present its aAJAXified
                /*if (locations != null)
                {
                    //HT:CAUTION: Using or assigning to User.UserLocations will create issues
                    locations = locations.Where(l => l != null && l.LocID > Defaults.Integer);
                    usr.UserLocations.Clear(); usr.UserLocations.AddRange(locations);//Pour in location data for View
                }*/
                #endregion
                //In case there's an invalid postback
                ViewData["LinkedLoc"] = LinkedLoc; ViewData["UnlinkedLoc"] = UnlinkedLoc;
                return View(usr);//Request.Form["chkDone"] must be present
            }
            if (usr.isSalesperson) usr.SalespersonCode = "";
            int result = new UserService().AddEdit(usr, LinkedLoc, UnlinkedLoc);
            //Log Activity
            new ActivityLogService((id > Defaults.Integer) ? ActivityLogService.Activity.UserEdit :
                ActivityLogService.Activity.UserAdd).Add();

            TempData["oprSuccess"] = true;
            return RedirectToAction("List");
        }
예제 #2
0
        public ActionResult AddEdit(int id)
        {
            Users usr = new UserService().GetUserById(id, _SessionUsr.OrgID);

            if (id > Defaults.Integer && usr.ID == Defaults.Integer && usr.OrgID == Defaults.Integer)
            { ViewData["Message"] = "User not found"; return View("DataNotFound"); /* deleted claim accessed from Log*/}

            doAddEditPopulate(id, usr);

            return View(usr);
        }
예제 #3
0
        public ActionResult Login(LogInModel model, string ReturnUrl, bool? IsForgotPassword, string UserEmail)
        {
            if (IsForgotPassword.HasValue && IsForgotPassword.Value)
                return SendPassword(UserEmail, model);//SPECIAL CASE PROCESSING for Forgot password

            if (ModelState.IsValid)
            {
                vw_Users_Role_Org usr = new UserService().Login(model.Email, model.Password);
                //If the returned User object is not null or empty login is successfull
                if (usr != null && usr.ID > 0 && usr != new UserService().emptyView)
                {
                    Config.ConfigSettings = new SettingService().FetchSettings();//Initialize settings
                    FormsAuthentication.SetAuthCookie(usr.Email, model.RememberMe);//Set forms authentication!

                    #region Remember Me (add or remove cookie)

                    SetCookie(model);

                    #endregion

                    //Set session
                    _SessionUsr.setUserSession(usr);
                    _Session.RoleRights = new UserService().GetRoleRights(usr.RoleID);
                    //Log Activity
                    new ActivityLogService(ActivityLogService.Activity.Login).Add();

                    //Redirect to return url - if its valid
                    if (RedirectFromLogin(ref ReturnUrl))
                        return Redirect(ReturnUrl);
                    else//Go to the default url -  Dashboard?from=login
                        return RedirectToAction("List", "Dashboard");
                }
                else // Login failed
                    ModelState.AddModelError("", "The email and/or password provided is incorrect.");
            }

            LogOff();// To make sure no session is set until Login (or it'll go in Login HttpGet instead of Post)
            // If we got this far, something failed, redisplay form
            return View(model);
        }
예제 #4
0
        public static bool SendEmail(int ClaimID, int AssignTo, string PONumber, Comment CommentObj, ref string Err)
        {
            bool isSelfNotification = (AssignTo == _SessionUsr.ID);
            bool sendMail = (ClaimID > Defaults.Integer && !isSelfNotification);// No need to send mail if its current user
            Err = isSelfNotification ? "Self notification : No email queued" : Err;
            try
            {
                #region Check and send email
                if (sendMail)
                {// No need to send mail if its current user
                    string UserEmail = new UserService().GetUserEmailByID(AssignTo);
                    MailManager.AssignToMail(PONumber, CommentObj.Comment1, ClaimID, UserEmail, (_SessionUsr.UserName), true);
                }
                #endregion
            }
            catch (Exception ex)
            {
                sendMail = false; Err = ex.Message + "<br/>" +
            (ex.InnerException ?? new Exception()).Message;
            }

            return sendMail;
        }
예제 #5
0
 // Indexer declaration.
 // If index is out of range, the array will throw the exception.
 public object this[Enum filterID]
 {
     get
     {
         object filterData = HttpContext.Current.Session[prefix + filterID.ToString()];
         try
         {
             if (filterData == null || filterData == empty)
             {
                 switch (_Enums.ParseEnum<list>(filterID))
                 {
                     case list.Dashboard: filterData = new DashboardService().emptyView; break;
                     case list.ActivityLog: filterData = new ActivityLogService(ActivityLogService.Activity.Login).emptyView; break;
                     case list.User: filterData = new UserService().emptyView; break;
                 }
             }
             return filterData;
         }
         catch { return null; }
     }
     set
     {
         HttpContext.Current.Session[prefix + filterID.ToString()] = value;
     }
 }
예제 #6
0
        public ActionResult SendPassword(string Email, LogInModel model)
        {
            //Unable to get any other action to skip security check - nor can we have another view\page as we're using dialog
            ViewData["showSendPWD"] = true;
            ModelState.Clear();//clear any Login issues

            if (string.IsNullOrEmpty(Email))// ModelState.IsValid) - validate data explicitly
                ModelState.AddModelError("UserEmail", "Email is required field.");

            #region If data is valid and email is found, send email and set result viewstate
            else
            {
                string Pwd = new UserService().GetUserPWDByEmail(Email);
                bool oprSuccess = !string.IsNullOrEmpty(Pwd);

                ViewData["oprSuccess"] = oprSuccess;//Err msg handled in View
                if(oprSuccess)//Send email
                    MailManager.ForgotPwdMail(Email,Pwd, new SettingService().GetContactEmail());
            }
            #endregion

            LogOff();// To make sure no session is set until Login (or it'll go in Login HttpGet instead of Post)
            return View(model);
        }
예제 #7
0
        /*
        public int AddEdit(vw_Claim_Master_User_Loc vwObj, int StatusIDold)
        {
            if (!IsAsync)// Do Async add/edit
                return new ClaimService().AddEdit(ClaimService.GetClaimObjFromVW(vwObj), StatusIDold, true);
            else
            {
                #region Refresh Session claim Object with latest Claim data
                Claim claimObj = _Session.Claims[vwObj.ClaimGUID];

                //sessionClaimObj.ID = vwObj.ID;
                //sessionClaimObj.AssignedTo = vwObj.AssignedTo; //HT? : CAUTION: Handled in Comments or not changed
                claimObj.BrandID = vwObj.BrandID;
                claimObj.ClaimDate = vwObj.ClaimDate; // Worst case handling when or anyreason the data was 1/1/1 ???
                //ClaimNo = vwObj.ClaimNo, HT: NOT needed because its an auto-generted field
                claimObj.CustID = vwObj.CustID;
                claimObj.CustRefNo = vwObj.CustRefNo;
                claimObj.SalespersonID = vwObj.SalespersonID;
                claimObj.ShipToLocationID = vwObj.ShipToLocationID;
                claimObj.StatusID = vwObj.StatusID;
                //sessionClaimObj.VendorID = vwObj.VendorID;

                _Session.Claims[vwObj.ClaimGUID] = claimObj;
                #endregion
                return AsyncBulkAddEditDel(claimObj, StatusIDold);//_Session.Claims[vwObj.ClaimGUID]
            }
        }

        public int AsyncBulkAddEditDel(Claim claimObj, int StatusIDold)
        {
            using (dbc)//Make sure this dbc is passed and persisted
            {
                bool isNewClaim = (claimObj.ID <= Defaults.Integer);
                bool doSubmit = true;
                string Progress = "";
                #region Set Transaction
                dbc.Connection.Open();
                //System.Data.Common.DbTransaction
                var txn = dbc.Connection.BeginTransaction();
                dbc.Transaction = txn;
                //ExecuteReader requires the command to have a transaction when the connection assigned to the
                //command is in a pending local transaction. The Transaction property of the command has not been initialized.
                #endregion
                try
                {

                    Progress = "Claim (" + claimObj.ID + ", " + claimObj.ClaimGUID + ", " + claimObj.ClaimDate.ToString() +")";//Update claim
                    new ClaimService(dbc).AddEdit(claimObj, StatusIDold, true);//doSubmit must be TRUE
                    //IMP: Note: The above addedit will return updated ClaimObj which will have Claim Id

                    Progress = "Comments";//Process comments
                    new CommentService(dbc).BulkAddEditDel(claimObj.aComments, claimObj.ID, doSubmit);
                    Progress = "HeaderFiles";//Process files (header) and files
                    new FileHeaderService(dbc).BulkAddEditDel(claimObj.aFiles, claimObj, doSubmit, dbc);
                    Progress = "Claimdetails";//Process items (and internally also process files(details)
                    new ClaimDetailService(dbc).BulkAddEditDel(claimObj.aItems, claimObj, doSubmit, isNewClaim, dbc);
                    //NOTE: For Async the Details files will have to be handled internally in the above function
                    //EXTRA : Delete D_Temp folder ?
                    if (claimObj.ID.ToString() != claimObj.ClaimGUID &&
                        !string.IsNullOrEmpty(claimObj.ClaimGUID))//ensure there's NO confusion
                        FileIO.EmptyDirectory(System.IO.Path.Combine(Config.UploadPath, claimObj.ClaimGUID.ToString()));

                    if (!doSubmit) dbc.SubmitChanges();//Make a FINAL submit instead of periodic updates
                    txn.Commit();//Commit
                }
                #region  Rollback if error
                catch (Exception ex)
                {
                    txn.Rollback();
                    Exception exMore = new Exception(ex.Message + " After " + Progress);
                    throw exMore;
                }
                finally
                {
                    if (dbc.Transaction != null)
                        dbc.Transaction.Dispose();
                    dbc.Transaction = null;
                }
                #endregion
            }

            #region Check and send email to the final Claim Assignee!

            if (Config.NofityAssignToEveryTime && claimObj.ID > Defaults.Integer && (claimObj.AssignedTo != _SessionUsr.ID))//Make sure "_Session.Claim" is available
            {
                string UserEmail = new UserService().GetUserEmailByID(claimObj.AssignedTo);
                MailManager.AssignToMail(claimObj.ClaimNo.ToString(), claimObj.AssignToComment, claimObj.ID, UserEmail, (_SessionUsr.UserName), false);
            }

            #endregion

            return claimObj.ID;//Return updated claimobj
        }
        */
        public int AsyncBulkAddEditDelKO(vw_Claim_Master_User_Loc vwObj, int StatusIDold, 
            IEnumerable<ClaimDetail> items, IEnumerable<Comment> comments, IEnumerable<FileHeader> files)
        {
            Claim claimObj = ClaimService.GetClaimObjFromVW(vwObj);
            using (dbc)//Make sure this dbc is passed and persisted
            {
                bool isNewClaim = (claimObj.ID <= Defaults.Integer);
                bool doSubmit = true;
                string Progress = "";

                #region Set Transaction

                dbc.Connection.Open();
                //System.Data.Common.DbTransaction
                var txn = dbc.Connection.BeginTransaction();
                dbc.Transaction = txn;
                //ExecuteReader requires the command to have a transaction when the connection assigned to the
                //command is in a pending local transaction. The Transaction property of the command has not been initialized.
                #endregion

                try
                {
                    Progress =
                        "Claim (" + claimObj.ID + ", " + claimObj.ClaimGUID + ", " + claimObj.ClaimDate.ToString() + ")";
                    //Update claim
                    new ClaimService(dbc).AddEdit(claimObj, StatusIDold, true);//doSubmit must be TRUE
                    //IMP: Note: The above addedit will return updated ClaimObj which will have Claim Id

                    Progress = "Comments";//Process comments
                    if(comments != null && comments.Count() > 0)
                        new CommentService(dbc).BulkAddEditDel(comments.ToList(), claimObj.ID, doSubmit);
                    Progress = "HeaderFiles";//Process files (header) and files
                    if (files != null && files.Count() > 0)
                        new FileHeaderService(dbc).BulkAddEditDel(files.ToList(), claimObj, doSubmit, dbc);
                    Progress = "Claimdetails";//Process items (and internally also process files(details)
                    if (items != null && items.Count() > 0)
                        new ClaimDetailService(dbc).BulkAddEditDel(items.ToList(), claimObj, doSubmit, isNewClaim, dbc);
                    //NOTE: For Async the Details files will have to be handled internally in the above function
                    //EXTRA : Delete D_Temp folder ?
                    if (claimObj.ID.ToString() != claimObj.ClaimGUID &&
                        !string.IsNullOrEmpty(claimObj.ClaimGUID))//ensure there's NO confusion
                        FileIO.EmptyDirectory(System.IO.Path.Combine(Config.UploadPath, claimObj.ClaimGUID.ToString()));

                    if (!doSubmit) dbc.SubmitChanges();//Make a FINAL submit instead of periodic updates
                    txn.Commit();//Commit
                }
                #region  Rollback if error
                catch (Exception ex)
                {
                    txn.Rollback();
                    Exception exMore = new Exception(ex.Message + " After " + Progress);
                    throw exMore;
                }
                finally
                {
                    if (dbc.Transaction != null)
                        dbc.Transaction.Dispose();
                    dbc.Transaction = null;
                }
                #endregion
            }

            #region Check and send email to the final Claim Assignee!

            if (Config.NofityAssignToEveryTime && claimObj.ID > Defaults.Integer && (claimObj.AssignedTo != _SessionUsr.ID))//Make sure "_Session.Claim" is available
            {
                string UserEmail = new UserService().GetUserEmailByID(claimObj.AssignedTo);
                MailManager.AssignToMail(claimObj.ClaimNo.ToString(), claimObj.AssignToComment, claimObj.ID, UserEmail, (_SessionUsr.UserName), false);
            }

            #endregion

            return claimObj.ID;//Return updated claimobj
        }
예제 #8
0
 public UserRoleProvider(UserService usrService)
     : base()
 {
     usrServiceObj = usrService ?? new UserService();
 }
예제 #9
0
 public UserMemberProvider(UserService usrService)
     : base()
 {
     usrServiceObj = usrService ?? new UserService();
 }