示例#1
0
        /// <summary>
        /// ویرایش پرسنل
        /// </summary>
        /// <param name="Personel">کارمند مورد نظر</param>
        /// <param name="HaveImage">عکس تغییر کرده ؟</param>
        public void Edit(M_Personels Personel)
        {
            Validate(Personel);
            if (!Personel.IsActive)
            {
                Personel.DeactiveDate = DateTime.Now;
            }
            DatabaseContext db = new DatabaseContext();

            db.Personels.Where(c => c.Id == Personel.Id).Load();
            db.Personels.Local[0].BirthDate        = Personel.BirthDate;
            db.Personels.Local[0].DeactiveDate     = Personel.DeactiveDate;
            db.Personels.Local[0].DeletedDate      = Personel.DeletedDate;
            db.Personels.Local[0].FirstName        = Personel.FirstName;
            db.Personels.Local[0].ImageName        = Personel.ImageName;
            db.Personels.Local[0].IsActive         = Personel.IsActive;
            db.Personels.Local[0].IsDeleted        = Personel.IsDeleted;
            db.Personels.Local[0].LastName         = Personel.LastName;
            db.Personels.Local[0].LastOnline       = Personel.LastOnline;
            db.Personels.Local[0].MobileNumber     = Personel.MobileNumber;
            db.Personels.Local[0].Password         = Personel.Password;
            db.Personels.Local[0].PersonelRoleId   = Personel.PersonelRoleId;
            db.Personels.Local[0].UserName         = Personel.UserName;
            db.Personels.Local[0].Gender           = Personel.Gender;
            db.Personels.Local[0].PersonelType     = Personel.PersonelType;
            db.Personels.Local[0].VehicleType      = Personel.VehicleType;
            db.Personels.Local[0].VehiclePlaq      = Personel.VehiclePlaq;
            db.Personels.Local[0].VehicleDesc      = Personel.VehicleDesc;
            db.Personels.Local[0].SumCenterAddress = Personel.SumCenterAddress;
            db.Personels.Local[0].SumCenterTell    = Personel.SumCenterTell;
            db.SaveChanges();
        }
示例#2
0
 public ActionResult LoginRequest(string UName, string Pass, string Captcha)
 {
     try
     {
         string res = "Sussess";
         if (Captcha.ToLower() != ((MFCaptcha)Session[MFSessions.CAPTCHA_KEY]).TextValue.ToLower())
         {
             res = "کد امنیتی صحیح نیست";
         }
         else
         {
             B_Personels bPersonel = new B_Personels();
             M_Personels us        = bPersonel.GetPersonels(UName, Pass);
             if (us == null)
             {
                 res = "نام کاربری یا گذرواژه صحیح نیست";
             }
             else
             {
                 HttpCookie Coki = new HttpCookie(MFCookies.USER_KEY);
                 Coki.Value   = us.UnicKey.ToString();
                 Coki.Expires = DateTime.Now.AddYears(1);
                 Response.Cookies.Add(Coki);
             }
         }
         return(Content(res));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#3
0
        public ActionResult Add(M_Personels Personel, M_CarInfo CareInfo, M_BoothInfo BoothInfo)
        {
            object result = "";

            try
            {
                B_Personels bPersonel = new B_Personels();
                var         personel  = bPersonel.Add(Personel);

                if (Personel.PersonelType == E_PublicCategory.PERSONEL_TYPE.DRIVER)
                {
                    CareInfo.PersonelId = personel.Id;
                    new B_CarInfo().Add(CareInfo);
                }
                else if (Personel.PersonelType == E_PublicCategory.PERSONEL_TYPE.INTEGRATION_CENTER || Personel.PersonelType == E_PublicCategory.PERSONEL_TYPE.SUM_CENER)
                {
                    BoothInfo.PersonelId = personel.Id;
                    new B_Booth().Add(BoothInfo);
                }
                result = "Success";
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }
示例#4
0
        public ActionResult Modify(M_Personels Personel, M_CarInfo CareInfo, M_BoothInfo BoothInfo)
        {
            object result = "";

            try
            {
                B_Personels bPersonel   = new B_Personels();
                var         oldPersonel = bPersonel.GetPersonelById(Personel.Id);
                if (oldPersonel.ImageName.ToLower() != "default.jpg" && oldPersonel.ImageName.ToLower() != Personel.ImageName)
                {
                    System.IO.File.Delete(Server.MapPath("~/Areas/Admin/Images/Profile") + "/" + oldPersonel.ImageName);
                }
                bPersonel.Edit(Personel);
                if (CareInfo != null)
                {
                    if (CareInfo.Id == 0)
                    {
                        CareInfo.PersonelId = Personel.Id;
                        new B_CarInfo().Add(CareInfo);
                    }
                    else
                    {
                        new B_CarInfo().Edit(CareInfo);
                    }
                }
                if (BoothInfo != null)
                {
                    if (BoothInfo.Id == 0)
                    {
                        BoothInfo.PersonelId = Personel.Id;
                        new B_Booth().Add(BoothInfo);
                    }
                    else
                    {
                        new B_Booth().Edit(BoothInfo);
                    }
                }
                result = "Success";
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }
示例#5
0
 public BaseController()
 {
     if (System.Web.HttpContext.Current.Request.Cookies[MFCookies.BOOTH_RIDER_KEY] != null)
     {
         string key = System.Web.HttpContext.Current.Request.Cookies[MFCookies.BOOTH_RIDER_KEY].Value;
         try
         {
             CurrentUser = new B_Personels().GetPersonels(key);
         }
         catch { }
     }
     ViewBag.SignalRUrl     = SignalRUrl;
     ViewBag.CurrentUser    = CurrentUser;
     ViewBag.MasterIsDriver = CurrentUser == null ? "false" : CurrentUser.PersonelType == E_PublicCategory.PERSONEL_TYPE.DRIVER ? "true" : "false";
 }
示例#6
0
        /// <summary>
        /// افزودن کارمند جدید
        /// </summary>
        /// <param name="Personel">کارمند مورد نظر</param>
        /// <returns>کارمند اضافه شده</returns>
        public M_Personels Add(M_Personels Personel)
        {
            Validate(Personel);
            if (!Personel.IsActive)
            {
                Personel.DeactiveDate = DateTime.Now;
            }
            DatabaseContext db  = new DatabaseContext();
            var             max = db.Personels.Max(c => c.ReagentCode);

            if (max < 100000)
            {
                max = 100000;
            }
            Personel.ReagentCode = max + 1;
            db.Personels.Add(Personel);
            db.SaveChanges();
            return(Personel);
        }
示例#7
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.HttpContext.Request.Cookies[MFCookies.BOOTH_RIDER_KEY] != null)
            {
                string      key  = filterContext.HttpContext.Request.Cookies[MFCookies.BOOTH_RIDER_KEY].Value;
                M_Personels user = null;
                var         ub   = new B_Personels();
                try
                {
                    user = ub.GetPersonels(key);
                }
                catch { }

                if (user != null)
                {
                    return;
                }
            }
            filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Default", action = "Login", area = "Booth" }));
            filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext);
        }
示例#8
0
        /// <summary>
        /// آدرس اتصال به SignalR
        /// </summary>
        // protected string SignalRUrl = System.Configuration.ConfigurationManager.AppSettings["SignalRUrl"];

        public BaseController()
        {
            if (System.Web.HttpContext.Current.Request.Cookies[MFCookies.USER_KEY] != null)
            {
                M_PersonelRoles role = null;
                string          key  = System.Web.HttpContext.Current.Request.Cookies[MFCookies.USER_KEY].Value;
                B_Personels     ub   = new B_Personels();
                CurrentUser = ub.GetPersonels(key);
                if (CurrentUser == null)
                {
                    return;
                }
                B_PersonelRoles ru = new B_PersonelRoles();
                role = ru.GetPersonelRoles(CurrentUser.PersonelRoleId);
                if (role == null)
                {
                    return;
                }
                ViewBag.LayoutPersonel         = CurrentUser;
                ViewBag.LayoutPersonelRole     = role;
                ViewBag.LayoutNewRequestCount  = new B_ServicesRequests().GetServicesRequestsCount(E_PublicCategory.REQUEST_STATUS.NEW_REQUEST);
                ViewBag.LayoutNewRedrawalCount = new B_UserPayment().GetPaymentCuontByStatus(E_PublicCategory.PAYMENT_STATUS.NEW);
            }
        }
示例#9
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            M_Personels                 user      = null;
            M_PersonelRoles             role      = null;
            List <M_PersonelRoleValues> roleValue = null;

            if (filterContext.HttpContext.Request.Cookies[MFCookies.USER_KEY] != null)
            {
                string      key = filterContext.HttpContext.Request.Cookies[MFCookies.USER_KEY].Value;
                B_Personels ub  = new B_Personels();
                try
                {
                    user = ub.GetPersonels(key);
                }
                catch { }

                if (user == null)
                {
                    filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Login", action = "Index", area = "Admin" }));
                    filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext);
                }
                else
                {
                    B_PersonelRoles ru = new B_PersonelRoles();
                    role = ru.GetPersonelRoles(user.PersonelRoleId);
                    if (role == null)
                    {
                        filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Dashboard", action = "NoPermission", area = "Admin" }));
                        filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext);
                    }

                    if (role.HasFullControl == true)
                    {
                        return;
                    }

                    B_PersonelRoleValues bRoleValue = new B_PersonelRoleValues();
                    roleValue = bRoleValue.GetPersonelRoleValues(role.Id);
                    if (roleValue == null || roleValue.Count == 0)
                    {
                        if (role == null)
                        {
                            filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Dashboard", action = "NoPermission", area = "Admin" }));
                            filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext);
                        }
                    }

                    var    rd                = filterContext.HttpContext.Request.RequestContext.RouteData;
                    string currentAction     = rd.GetRequiredString("action");
                    string currentController = rd.GetRequiredString("controller") + "Controller";


                    Assembly asm    = Assembly.GetAssembly(typeof(Global));
                    var      action = asm.GetTypes()
                                      .Where(type => typeof(System.Web.Mvc.Controller).IsAssignableFrom(type) && type.Namespace.Contains("Shahrdari.WebApplication.Areas.Admin.Controllers"))
                                      .SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public))
                                      .Where(m => !m.GetCustomAttributes(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute), true).Any() &&
                                             m.DeclaringType.Name == currentController && m.Name == currentAction)
                                      .Select(x => new { Attributes = x.GetCustomAttributes().ToList() }).FirstOrDefault();
                    if (action != null && action.Attributes.Where(c => c.GetType().Name.ToUpper().IndexOf("HTTPPOST") != -1).Count() > 0)
                    {
                        return;
                    }

                    if (roleValue.Where(c => c.AccessName.ToUpper() == (currentController + " | " + currentAction).ToUpper()).Count() == 0)
                    {
                        filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Dashboard", action = "NoPermission", area = "Admin" }));
                        filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext);
                    }
                }
            }
            else
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Login", action = "Index", area = "Admin" }));
                filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext);
            }
        }