Пример #1
0
        public Sec_User DeviceLogin(string username, string password, string imei)
        {
            Sec_User rec = new Sec_User();

            try
            {
                Sec_UserBL ubl = new Sec_UserBL();
                rec = ubl.Single("DeviceLogin", username, imei);
                if (rec != null)
                {
                    Sec_PermissionBL pl = new Sec_PermissionBL();
                    rec.Permissions = pl.ToList("byUserId_ModuleId", rec.UserId.ToString(), "AIRVIEW_ANDROID");
                    string TempPass = Encryption.Decrypt(rec.Password, true);
                    rec.Message = true;
                    if (password != TempPass)
                    {
                        rec         = new Sec_User();
                        rec.Message = false;
                    }
                }
                else
                {
                    rec.Message = false;
                }
            }
            catch (Exception ex)
            {
                rec         = new Sec_User();
                rec.Message = false;
            }

            return(rec);
        }
Пример #2
0
        public ActionResult GetSummryByDate(string currentDate, string id, string[] Markets)
        {
            List <Summary> res = new List <Summary>();

            try
            {
                List <Summary> rs = new List <Summary>();
                ViewBag.UserId = id;

                Sec_UserBL obj = new Sec_UserBL();
                var        u   = obj.Single("ById", id);
                ViewBag.UserName = u.FirstName + " " + u.LastName;
                var    a         = currentDate.Split('-');
                int    i         = 0;
                string StartDate = "";
                string EndDate   = "";
                foreach (var item in a)
                {
                    if (i == 0)
                    {
                        StartDate = item;
                        i++;
                    }
                    else
                    {
                        EndDate = item;
                    }
                }
                ViewBag.Defultdate = StartDate;
                rs = obj.SummaryList("GetUserSummary", StartDate, EndDate, id);
                if (Markets.Length != 0 || Markets != null)
                {
                    foreach (var item in rs)
                    {
                        foreach (var itm in Markets)
                        {
                            if (int.Parse(itm) == item.DefinationId)
                            {
                                res.Add(item);
                            }
                        }
                    }
                }
                else
                {
                    res = rs;
                }

                return(PartialView("~\\Views\\User\\_PartialCalender.cshtml", res));
            }
            catch (Exception ex)
            {
                res = null;
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
            // return Json(true, JsonRequestBehavior.AllowGet);
        }
Пример #3
0
        //GET: Login
        public ActionResult Index(string tctl, string tact)
        {
            TempData["msg_error"] = null;
            ActionResult temp = null;

            try
            {
                HttpCookie myCookie = Request.Cookies["AirView"];
                if (myCookie != null)
                {
                    Sec_User   user = new Sec_User();
                    Sec_UserBL ubl  = new Sec_UserBL();
                    user = ubl.Single("Login", Encryption.DecryptSHA256(myCookie.Value));

                    if (user != null)
                    {
                        mySession(user);

                        if (Session["PrevUrl"] != null)
                        {
                            string url = Session["PrevUrl"].ToString();
                            Session["PrevUrl"] = null;
                            return(Redirect(url));
                        }
                        else if (!string.IsNullOrEmpty(tctl) && !string.IsNullOrEmpty(tact))
                        {
                            return(RedirectToAction(tact, tctl));
                        }
                        else
                        {
                            temp = Redirect(user.DefaultUrl);
                        }

                        return(temp);
                    }
                }
            }
            catch (Exception ex)
            {
                TempData["msg_error"] = ex.Message;
            }


            ViewBag.TController = tctl;
            ViewBag.TAction     = tact;

            return(View());
        }
Пример #4
0
        public ActionResult Details(int id = 0)
        {
            if (ViewBag.IsAdmin)
            {
                goto data;
            }

            if (ViewBag.UserId != id)
            {
                TempData["msg_error"] = "You have not permission to this panel..";
                return(View());
            }
data:
            Sec_UserBL ud = new Sec_UserBL();
            var data = ud.Single("ById", id.ToString());

            return(View(data));
        }
Пример #5
0
        public static void UpdateSession(string Username)
        {
            Sec_User   user = new Sec_User();
            Sec_UserBL ubl  = new Sec_UserBL();

            user = ubl.Single("Login", Username);
            if (user != null)
            {
                LoginInformation li = new LoginInformation();

                Sec_PermissionBL   pl  = new Sec_PermissionBL();
                Sec_UserSettingsDL udl = new Sec_UserSettingsDL();
                var per  = pl.ToList("byUserId_ModuleId", user.UserId.ToString(), "AIRIVEW_PORTAL");
                var Pper = udl.GetDataTable("UserProjects", user.UserId.ToString(), null, null);
                var obj  = li.set_user_data(user, per, Pper);
                HttpContext.Current.Session["user"] = null;
                HttpContext.Current.Session["user"] = obj;
            }
        }
Пример #6
0
        public ActionResult Index(Int64 ProjectId = 0)
        {
            Sec_UserSettingsDL udl          = new Sec_UserSettingsDL();
            DataTable          UserProjects = udl.GetDataTable("UserProjects", ViewBag.UserId.ToString(), null, null);

            if (ProjectId == 0 || UserProjects.ToList <PM_Projects>().Where(x => x.ProjectId == ProjectId).Count() == 0)
            {
                return(RedirectToAction("all", "Defination"));
            }

            //DataTable Table = udl.GetDataTable("All_Projects", null, null, null);



            Sec_UserBL ud   = new Sec_UserBL();
            Sec_User   user = ud.Single("ById", ViewBag.UserId.ToString());

            return(View(user));
        }
Пример #7
0
        public ActionResult Summary(int Id)
        {
            List <Summary> res = new List <Summary>();
            Sec_UserBL     obj = new Sec_UserBL();
            var            u   = obj.Single("ById", Id.ToString());

            ViewBag.UserName = u.FirstName + " " + u.LastName;
            int thisWeekNumber = GetIso8601WeekOfYear(DateTime.Today);
            // 11/11/2013
            DateTime firstDayOfWeek = FirstDateOfWeek(DateTime.Now.Year, thisWeekNumber, CultureInfo.CurrentCulture);
            // 11/12/2012
            DateTime firstDayOfLastYearWeek = FirstDateOfWeek(DateTime.Now.Year, thisWeekNumber, CultureInfo.CurrentCulture);
            var      StartDate = firstDayOfLastYearWeek.ToString();
            var      EndDate   = firstDayOfLastYearWeek.AddDays(7).ToString();

            res = obj.SummaryList("GetUserSummary", StartDate, EndDate, Id.ToString());
            ViewBag.Defultdate = StartDate;
            ViewBag.UserId     = Id;
            return(View(res));
        }
Пример #8
0
        public bool IsExist(string filter, string value)
        {
            Sec_UserBL ud   = new Sec_UserBL();
            Sec_User   data = ud.Single(filter, value);

            if (data != null)
            {
                if (data.UserId > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #9
0
        public ActionResult Login(FormCollection frm, string tctl, string tact)
        {
            try
            {
                string Remember = frm["Remember"];

                Sec_User   user = new Sec_User();
                Sec_UserBL ubl  = new Sec_UserBL();
                user = ubl.Single("Login", frm["UserName"]);
                string Password = Encryption.Encrypt(frm["Password"].ToString(), true);

                if (user != null)
                {
                    if (user.Password != Password)
                    {
                        TempData["msg_error"] = "Wrong Password Entered.";
                        return(RedirectToAction("index"));
                    }
                    else
                    {
                        if (Remember != "false")
                        {
                            HttpCookie c = new HttpCookie("AirView");
                            c.Expires = DateTime.Today.AddDays(7);
                            c.Value   = Convert.ToString(Encryption.EncryptSHA256(user.UserName));
                            //c.Values.Add("UserName", user.UserName);

                            //c.Value = Convert.ToString(user.UserId);
                            //c.Values.Add("UserName", user.UserName);
                            Response.SetCookie(c);
                        }

                        mySession(user);

                        if (Session["PrevUrl"] != null)
                        {
                            string url = Session["PrevUrl"].ToString();
                            Session["PrevUrl"] = null;
                            return(Redirect(url));
                        }
                        else if (!string.IsNullOrEmpty(tctl) && !string.IsNullOrEmpty(tact))
                        {
                            return(RedirectToAction(tact, tctl));
                        }
                        else
                        {
                            return(Redirect(user.DefaultUrl));
                        }
                    }
                }
                else
                {
                    TempData["msg_error"] = "Wrong Username Entered.";
                    return(RedirectToAction("index"));
                }
            }
            catch (Exception ex)
            {
                TempData["msg_error"] = ex.Message;
                return(RedirectToAction("index"));
            }
        }
Пример #10
0
        public JsonResult Movement(List <AD_UEMovement> mov, string UEStatus)
        {
            Response res = new Response();

            try
            {
                AD_UEMovementBL ueb = new AD_UEMovementBL();

                foreach (var item in mov)
                {
                    ueb.Manage(UEStatus, item);
                }

                //------------------------------
                if (UEStatus == "Issue")
                {
                    long UEId   = mov.Select(x => x.UEId).Single();
                    long UserId = mov.Select(x => x.UserId).Single();

                    AD_UserEquipmentsBL uebl = new AD_UserEquipmentsBL();
                    AD_UserEquipment    uEqu = uebl.ToSingle("ById", UEId.ToString());

                    Sec_UserBL u            = new Sec_UserBL();
                    Sec_User   usr          = u.Single("ById", UserId.ToString());
                    WebConfig  wc           = new WebConfig();
                    string     UeModel      = uEqu.Model;
                    string     Manufacturer = uEqu.Manufacturer;
                    string     SerialNo     = uEqu.SerialNo;

                    string AVStoreURL = wc.AppSettings("AVStoreURL");

                    string Url = "<a href=" + AVStoreURL + ">AirView Store</a>";

                    string UserName = usr.UserName;
                    string ToEmail  = usr.Email;

                    string Subject = "UE Device Issued";
                    string Body    = "<h1>Hi, " + UserName + "</h1>" +
                                     "<p>A new device is issued to your account.</p>" +
                                     "<table border=" + 1 + " cellpadding=" + 2 + " cellspacing=" + 0 + " width = " + 400 + ">" +
                                     "<tr bgcolor='#F5F5F5'><td><strong>Model</strong></td><td>" + UeModel + "</td></tr>" +
                                     "<tr bgcolor='#F5F5F5'><td><strong>Manufacturer</strong></td><td>" + Manufacturer + "</td></tr>" +
                                     "<tr bgcolor='#F5F5F5'><td><strong>SerialNo</strong></td><td>" + SerialNo + "</td></tr>" +
                                     "</table>" +
                                     "<p>Please download and install AirView Store by clicking here: " + Url + "</p>";


                    Thread thread = new Thread(() => SendEmail(Subject, ToEmail, Body));
                    thread.Start();

                    //-----------------------------
                }


                res.Status  = "success";
                res.Message = "save successfully";
            }
            catch (Exception ex)
            {
                res.Status  = "danger";
                res.Message = ex.Message;
            }
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Пример #11
0
        public ActionResult Edit(string Id = "")
        {
            ClientsBL       cb   = new ClientsBL();
            UserClientsBL   uchb = new UserClientsBL();
            UserCityBL      ucb  = new UserCityBL();
            AD_DefinationBL db   = new AD_DefinationBL();
            Sec_User        user = new Sec_User();

            Sec_UserBL               ubl = new Sec_UserBL();
            Sec_UserSettingsDL       udl = new Sec_UserSettingsDL();
            Sec_PermissionBL         pl  = new Sec_PermissionBL();
            Sec_UserDefinationTypeBL udt = new Sec_UserDefinationTypeBL();

            ViewBag.Titles = new List <SelectListItem> {
                new SelectListItem {
                    Text = "Mr.", Value = "1"
                },
                new SelectListItem {
                    Text = "Mrs.", Value = "2"
                },
                new SelectListItem {
                    Text = "Miss.", Value = "3"
                },
                new SelectListItem {
                    Text = "Ms.", Value = "4"
                },
                new SelectListItem {
                    Text = "Sir.", Value = "5"
                },
                new SelectListItem {
                    Text = "DR", Value = "6"
                }
            };
            ViewBag.Hide = false;
            ViewBag.Team = false;
            if (Id == Convert.ToString(ViewBag.UserId))
            {
                ViewBag.Hide = true;
                List <OrgChart> rec   = ubl.hierarchy("ByCompanyId", Convert.ToString(ViewBag.CompId));
                List <Chart>    Data2 = FlatToHierarchy(rec, ViewBag.UserId);
                if (Data2.Count > 0)
                {
                    ViewBag.Team = true;
                }
                else
                {
                    ViewBag.Team = false;
                }
            }
            SWI.AirView.Common.SelectedList sl = new SWI.AirView.Common.SelectedList();
            Sec_UserBL ud   = new Sec_UserBL();
            Sec_User   User = ud.Single("ById", Id.ToString());

            ViewBag.UserTitle = User.Title;
            ViewBag.Hide2     = true;
            if (User.ReportToId.ToString() == Convert.ToString(ViewBag.UserId))
            {
                ViewBag.Hide2 = false;
            }
            if (Id == Convert.ToString(ViewBag.UserId))
            {
                ViewBag.Hide2 = false;
            }
            ViewBag.User = User;
            if (User == null)
            {
            }
            if (User.IsAdmin == true)
            {
                ViewBag.Hide  = false;
                ViewBag.Hide2 = false;
                ViewBag.Team  = true;
            }
            NewData();
            ViewBag.Id       = User.CompanyId;
            ViewBag.RoleId   = User.RoleId;
            ViewBag.Reports  = sl.User("All");
            ViewBag.ReportTo = ud.ToList("All");
            ViewBag.Clients2 = sl.Clients("AllRecords");
            /////permissions
            user = ubl.Single("ById", Id.ToString());
            ///Project
            DataTable Table = udl.GetDataTable("All_Projects", User.ReportToId.ToString(), null, null);

            ViewBag.Projects = Table.ToList <PM_Projects>();
            DataTable Table1 = udl.GetDataTable("UserProjects", Id.ToString(), null, null);

            ViewBag.UserProjects = Table1.ToList <PM_Projects>();
            var    r          = pl.ToList("byUserId", Id.ToString());
            var    d          = udt.ToList("GetByUserId", Id.ToString());
            string UDSelected = null;

            foreach (var item in d)
            {
                UDSelected += item.DefinationTypeId + ",";
            }
            ViewBag.DIds = UDSelected;
            string Selected = null;

            foreach (var item in r)
            {
                Selected += item.Id + ",";
            }
            ViewBag.PIds = Selected;
            ViewBag.UId  = Id;

            #region user Permissions on tab
            //Clients
            //ViewBag.Clients = cb.ToList("byStatus", User.ReportToId.ToString());
            ViewBag.Clients     = cb.ToList("byStatus", "True", User.ReportToId.ToString());
            ViewBag.UserClients = uchb.ToList("byUserId", Id.ToString());
            //Cities

            ViewBag.Cities = db.ToList("AllCities");
            //db.ToList("UserCities",User.ReportToId.ToString());
            ViewBag.UserCities = ucb.ToList("byUserId", Id.ToString());

            ViewBag.Region = db.RegionsToList(User.ReportToId.ToString());
            //scope
            ViewBag.Scopes = db.ToList("Scopes", User.ReportToId.ToString());
            //ViewBag.Scopes = db.ToList("Scopes");
            ViewBag.UserScopes = db.ToList("UserScopes", Id.ToString());

            ViewBag.Permissions = pl.ToList("byRoleId", user.RoleId.ToString(), User.ReportToId.ToString());

            #endregion
            AD_DefinationTypesBL dtd = new AD_DefinationTypesBL();
            ViewBag.DefinationTypes = dtd.ToList("All", User.ReportToId.ToString());

            //User.RoleName = ViewBag.RoleName;
            return(View("edit", User));
        }
Пример #12
0
        public ActionResult ByUser(int id = 0)
        {
            Sec_User   user = new Sec_User();
            Sec_UserBL ubl  = new Sec_UserBL();

            user = ubl.Single("ById", id.ToString());
            if (user != null)
            {
                Sec_UserSettingsDL       udl = new Sec_UserSettingsDL();
                Sec_PermissionBL         pl  = new Sec_PermissionBL();
                Sec_UserDefinationTypeBL ud  = new Sec_UserDefinationTypeBL();
                ///Projects and User projects
                DataTable Table = udl.GetDataTable("All_Projects", null, null, null);
                ViewBag.Projects = Table.ToList <PM_Projects>();
                DataTable Table1 = udl.GetDataTable("UserProjects", id.ToString(), null, null);
                ViewBag.UserProjects = Table1.ToList <PM_Projects>();
                var    r          = pl.ToList("byUserId", id.ToString());
                var    d          = ud.ToList("GetByUserId", id.ToString());
                string UDSelected = null;
                foreach (var item in d)
                {
                    UDSelected += item.DefinationTypeId + ",";
                }
                ViewBag.DIds = UDSelected;
                string Selected = null;
                foreach (var item in r)
                {
                    Selected += item.Id + ",";
                }
                ViewBag.PIds = Selected;
                ViewBag.UId  = id;


                // User Clients
                ClientsBL cb = new ClientsBL();
                ViewBag.Clients = cb.ToList("byStatus", "True");

                // get selected user Clients
                UserClientsBL uchb = new UserClientsBL();
                ViewBag.UserClients = uchb.ToList("byUserId", id.ToString());


                // get selected user Cities
                UserCityBL ucb = new UserCityBL();

                ViewBag.UserCities = ucb.ToList("byUserId", id.ToString());

                // get Regions
                AD_DefinationBL db = new AD_DefinationBL();
                ViewBag.Region = db.RegionsToList();

                ViewBag.Cities = db.ToList("AllCities");

                ViewBag.Scopes     = db.ToList("Scopes");
                ViewBag.UserScopes = db.ToList("UserScopes", id.ToString());
                // ViewBag.UserScopes = string.Join(",", Scopes.Select(n => n.DefinationId.ToString()).ToArray());

                var Permissions = pl.ToList("byRoleId", user.RoleId.ToString());
                return(View(Permissions));
            }
            else
            {
                TempData["msg_error"] = "User not Found.";
            }

            return(View());
        }