Пример #1
0
        public bool RequestAccess(string userid, string username)
        {
            Sec_User dbuser = null;

            try
            {
                userid = userid.Split('\\').Last();
                if (username.Length <= 0)
                {
                    username = userid;
                }
                dbuser = DbCtx.UManager.FindUser(userid);
            }
            catch
            { }
            if (dbuser != null)
            {
                throw new Exception("Error! User already exist.");
            }

            dbuser = new Sec_User {
                Created            = DateTime.Now,
                Alias              = username,
                UserName           = userid,
                AuthorizationLevel = Security_Enums.UserRole.Role_Reco3_Pending
            };
            DbCtx.Sec_Users.Add(dbuser);
            return(DbCtx.SaveChanges() > 0);
        }
Пример #2
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);
        }
Пример #3
0
        public string GetRolesForUser(string username)
        {
            try
            {
                int nIndex = username.IndexOf("GLOBAL\\");
                if (nIndex == -1)
                {
                    nIndex = 0;
                }
                else
                {
                    nIndex = 7;
                }
                string strSSSpart = username.Substring(nIndex);

                Sec_User user = FindUser(strSSSpart);
                if (user != null)
                {
                    return(EnumExtensions.GetDisplayName(user.AuthorizationLevel));
                }
            }
            catch
            {
                //int n = 0;
            }
            throw new Exception("Unkown User");
        }
Пример #4
0
        private List <Sec_User> DataTableToList(DataTable dt)
        {
            List <Sec_User> lstUsers = new List <Sec_User>();

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Sec_User User = new Sec_User();
                    User.UserId = DataType.ToInt64(dt.Rows[i]["UserId"].ToString());
                    // User.CompanyId = DataType.ToInt64(dt.Rows[i]["CompanyId"].ToString());
                    User.CompanyId = (dt.Columns.Contains("CompanyId")) ? DataType.ToInt64(dt.Rows[i]["CompanyId"].ToString()) : 0;
                    User.Id        = DataType.ToInt32(dt.Rows[i]["UserId"].ToString());
                    User.FirstName = dt.Rows[i]["FirstName"].ToString();
                    User.LastName  = dt.Rows[i]["LastName"].ToString();
                    if (dt.Columns.Contains("ModifyDate") && !string.IsNullOrEmpty(dt.Rows[i]["ModifyDate"].ToString()))
                    {
                        User.Update_at = DateTime.Parse(dt.Rows[i]["ModifyDate"].ToString());
                    }
                    User.Picture      = dt.Columns.Contains("Picture") ? dt.Rows[i]["Picture"].ToString() : null;
                    User.UserName     = dt.Columns.Contains("UserName") ? dt.Rows[i]["UserName"].ToString() : null;
                    User.Email        = dt.Columns.Contains("Email") ? dt.Rows[i]["Email"].ToString() : null;
                    User.Address      = dt.Columns.Contains("Address") ? dt.Rows[i]["Address"].ToString() : null;
                    User.Contact      = dt.Columns.Contains("Contact") ? dt.Rows[i]["Contact"].ToString() : null;
                    User.ActiveStatus = dt.Columns.Contains("IsActive") ? bool.Parse(dt.Rows[i]["IsActive"].ToString()) : false;
                    User.RoleId       = (dt.Columns.Contains("RoleId")) ? Convert.ToInt32(dt.Rows[i]["RoleId"].ToString()) : 0;
                    User.RoleName     = (dt.Columns.Contains("RoleName")) ? dt.Rows[i]["RoleName"].ToString() : "";
                    User.ClientName   = (dt.Columns.Contains("ClientName")) ? dt.Rows[i]["ClientName"].ToString() : "";
                    User.ReportTo     = (dt.Columns.Contains("ReportTo")) ? dt.Rows[i]["ReportTo"].ToString() : "";
                    User.Designation  = (dt.Columns.Contains("Designation")) ? dt.Rows[i]["Designation"].ToString() : "";
                    lstUsers.Add(User);
                }
            }
            return(lstUsers);
        }
Пример #5
0
 public Sec_UserModel(Sec_User entity, bool encodeHtml = false)
 {
     if (entity != null)
     {
         var configMapper = new MapperConfiguration(cfg =>
         {
             cfg.CreateMap <Sec_User, Sec_UserModel>();
         });
         configMapper.CreateMapper().Map(entity, this);
     }
 }
Пример #6
0
        public Sec_User GetEntity()
        {
            var configMapper = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Sec_UserModel, Sec_User>();
            });

            Sec_User entity = configMapper.CreateMapper().Map <Sec_UserModel, Sec_User>(this);

            return(entity);
        }
Пример #7
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());
        }
Пример #8
0
        public List <Sec_User> GetUsers(string filter, Int64 projectId, Int64 TaskId)
        {
            DataTable dt = dal.ToList(filter, projectId, TaskId);

            List <Sec_User> lst = new List <Sec_User>();

            foreach (DataRow item in dt.Rows)
            {
                Sec_User user = new Sec_User();
                user.UserId   = Convert.ToInt64(item["UserId"]);
                user.UserName = item["Username"].ToString();
                lst.Add(user);
            }

            return(lst);
        }
Пример #9
0
        private void mySession(Sec_User user)
        {
            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);
                Session["user"] = null;
                //System.Web.HttpContext.Current.Application["UserId"] = user.UserId.ToString();
                //System.Web.HttpContext.Current.Application.Add(user.UserId.ToString(), user.UserId.ToString());
                System.Web.HttpContext.Current.Application["User"] = li.set_user_data(user, per, Pper);
                Session.Add("user", li.set_user_data(user, per, Pper));
            }
        }
Пример #10
0
 public JsonResult GetUser(string userId)
 {
     try
     {
         DatabaseContext dbx  = new DatabaseContext();
         Sec_User        user = dbx.UManager.FindUser(Convert.ToInt32(userId));
         if (user != null)
         {
             string json = JsonConvert.SerializeObject(user);
             return(Json(new { success = true, message = "", data = json }, JsonRequestBehavior.AllowGet));
         }
     }
     catch
     {
     }
     return(Json(new { success = false, message = "Failed to retrieve the user." }, JsonRequestBehavior.AllowGet));
 }
Пример #11
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;
            }
        }
Пример #12
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));
        }
Пример #13
0
        public ActionResult SaveUserModel(UserModel model)
        {
            try
            {
                Sec_User user = new Sec_User();
                user.Alias              = model.Alias;
                user.UserId             = model.UserId;
                user.UserName           = model.UserName;
                user.AuthorizationLevel = model.Role;

                DatabaseContext dbx = new DatabaseContext();
                dbx.UManager.UpdateUser(user);
            }
            catch (Exception ex)
            {
                Response.AppendToLog(string.Format("<== SaveUserModel : ex {0}", ex.Message));
            }
            return(Json("Success"));
        }
Пример #14
0
 public bool UpdateUser(Sec_User user)
 {
     if (user.UserId == -1)
     {
         user.Created            = DateTime.Now;
         user.AuthorizationLevel = Security_Enums.UserRole.Role_Reco3_Pending;
         DbCtx.Sec_Users.Add(user);
     }
     else
     {
         Sec_User dbuser = DbCtx.UManager.FindUser(Convert.ToInt32(user.UserId));
         if (dbuser != null)
         {
             dbuser.Alias              = user.Alias;
             dbuser.UserName           = user.UserName;
             dbuser.AuthorizationLevel = user.AuthorizationLevel;
             DbCtx.Entry(dbuser).State = System.Data.Entity.EntityState.Modified;
         }
     }
     return(DbCtx.SaveChanges() > 0);
 }
Пример #15
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);
            }
        }
Пример #16
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));
        }
Пример #17
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());
        }
Пример #18
0
        public Sec_User Single(string filter, string Value1 = null, string Value2 = null, string Value3 = null)
        {
            try
            {
                DataTable dt = ud.Get(filter, Value1, Value2, Value3);

                Sec_User User = new Sec_User();
                if (dt != null && dt.Rows.Count > 0)
                {
                    int i = 0;
                    User.Id         = DataType.ToInt32(dt.Rows[i]["UserId"].ToString());
                    User.UserId     = (dt.Columns.Contains("UserId")) ? !(dt.Rows[i]["UserId"].ToString().Trim().ToLower() == "null" || dt.Rows[i]["UserId"].ToString().Trim() == String.Empty) ? Int64.Parse(dt.Rows[i]["UserId"].ToString().Replace(",", "")) : 0 : 0;
                    User.CompanyId  = (dt.Columns.Contains("CompanyId")) ? !(dt.Rows[i]["CompanyId"].ToString().Trim().ToLower() == "null" || dt.Rows[i]["CompanyId"].ToString().Trim() == String.Empty) ? Int64.Parse(dt.Rows[i]["CompanyId"].ToString().Replace(",", "")) : 0 : 0;
                    User.ReportToId = (dt.Columns.Contains("ReportToId")) ? !(dt.Rows[i]["ReportToId"].ToString().Trim().ToLower() == "null" || dt.Rows[i]["ReportToId"].ToString().Trim() == String.Empty) ? Int64.Parse(dt.Rows[i]["ReportToId"].ToString().Replace(",", "")) : 0 : 0;
                    // User.UserId = (dt.Columns.Contains("UserId")) ?  Convert.ToInt64(dt.Rows[i]["UserId"].ToString()) : 0;
                    // User.CompanyId = (dt.Columns.Contains("CompanyId")) ? 1 * Convert.ToInt64(dt.Rows[i]["CompanyId"].ToString()) : 0;
                    // User.ReportToId = (dt.Columns.Contains("ReportToId")) ? 1 * Convert.ToInt64(dt.Rows[i]["ReportToId"].ToString()) : 0;
                    User.FirstName = dt.Rows[i]["FirstName"].ToString();

                    User.LastName = dt.Rows[i]["LastName"].ToString();
                    User.Email    = dt.Rows[i]["Email"].ToString();
                    User.Picture  = dt.Rows[i]["Picture"].ToString();
                    User.UserName = dt.Rows[i]["UserName"].ToString();
                    User.Password = dt.Rows[i]["Password"].ToString();
                    User.Address  = dt.Rows[i]["Address"].ToString();
                    if ((dt.Columns.Contains("MAC")))
                    {
                        User.MAC = dt.Rows[i]["MAC"].ToString();
                    }
                    if ((dt.Columns.Contains("IMEI")))
                    {
                        User.IMEI = dt.Rows[i]["IMEI"].ToString();
                    }

                    User.Designation = (dt.Columns.Contains("Designation")) ? dt.Rows[i]["Designation"].ToString() : "";
                    User.Gender      = (dt.Columns.Contains("Gender")) ? dt.Rows[i]["Gender"].ToString() : "";
                    User.Title       = (dt.Columns.Contains("Title")) == true ? dt.Rows[i]["Title"].ToString() : "";

                    User.Contact = dt.Rows[i]["Contact"].ToString();
                    User.IsAdmin = DataType.ToBoolean(dt.Rows[i]["IsAdmin"].ToString());
                    if ((dt.Columns.Contains("IsManager")))
                    {
                        User.IsManager = DataType.ToBoolean(dt.Rows[i]["IsManager"].ToString());
                    }
                    User.homeLatitude = (dt.Columns.Contains("homeLatitude")) == true?DataType.ToDouble(dt.Rows[i]["homeLatitude"].ToString()) : 0;

                    User.homeLongitude = (dt.Columns.Contains("homeLongitude")) == true?DataType.ToDouble(dt.Rows[i]["homeLongitude"].ToString()) : 0;

                    User.RoleId = (dt.Columns.Contains("RoleId")) == true?int.Parse(dt.Rows[i]["RoleId"].ToString()) : 0;

                    User.RoleName   = (dt.Columns.Contains("RoleName")) == true ? dt.Rows[i]["RoleName"].ToString() : "";
                    User.DefaultUrl = (dt.Columns.Contains("DefaultUrl")) == true ? dt.Rows[i]["DefaultUrl"].ToString() : "";
                    if ((dt.Columns.Contains("DaysBack")))
                    {
                        User.DaysBack = DataType.ToInt32(dt.Rows[i]["DaysBack"].ToString());
                    }
                    if ((dt.Columns.Contains("CompanyId")))
                    {
                        User.CompanyId = DataType.ToInt32(dt.Rows[i]["CompanyId"].ToString());
                    }
                    if ((dt.Columns.Contains("DaysForward")))
                    {
                        User.DaysForward = DataType.ToInt32(dt.Rows[i]["DaysForward"].ToString());
                    }
                    return(User);
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #19
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));
        }
Пример #20
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"));
            }
        }
Пример #21
0
        public ActionResult New(Sec_User u, FormCollection dt, string type, string back)
        {
            Response res = new Response();

            try
            {
                string Password = string.Empty;
                if (u.Password != null)
                {
                    Password = Encryption.Encrypt(u.Password, true);
                }

                Sec_UserDL ud = new Sec_UserDL();
                int        Id = ud.SaveNew_Update(Convert.ToInt64(u.UserId), Convert.ToInt64(u.RoleId), u.FirstName, u.LastName, u.UserName, Password, u.Email, u.Address, u.Contact, u.homeLatitude, u.homeLongitude, u.Title, u.Gender, u.CompanyId, u.Designation, u.HiringDate, u.ReportToId, u.Color, u.IsManager);

                if (Id > 0)
                {
                    string Picture = null;
                    Picture = UploadImg("/Content/Images/Profile/", "u-" + Id, 150, 150);
                    string Thumb = (!string.IsNullOrEmpty(Picture)) ? UploadImg("/Content/Images/Profile/", "thumb-" + Id, 32, 32) : null;

                    // check if image not uploaded
                    //if (back == "New")
                    //{
                    //    if (Picture == null) { Picture = "/Content/Images/Profile/Default.svg"; }
                    //}

                    if (!string.IsNullOrEmpty(Picture))
                    {
                        ud.Manage("UpdatePicture", Id.ToString(), Picture);
                    }

                    // for home location
                    if (!string.IsNullOrEmpty(Thumb))
                    {
                        Image    img = Image.FromFile(Server.MapPath("~" + Thumb));
                        Graphics g   = Graphics.FromImage(img);
                        g.DrawImage(Image.FromFile(Server.MapPath("~/Content/Images/Profile/home.png")), 20, 1, 13, 13);//new Point(-50, -50)
                        g.Dispose();
                        img.Save(Server.MapPath("~/Content/Images/Profile/home-" + Id + ".png"), ImageFormat.Png);
                    }
                }

                //TempData["msg_success"] = "Save successfully";
                //if (back == "New" || back == "Edit")
                //{
                //    return RedirectToAction("All");
                //}

                //return RedirectToAction("All");
                res.Status  = "success";
                res.Message = "Save Successfully !";
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                res.Status  = "danger";
                res.Message = ex.ToString();
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
        }