Example #1
0
        public ActionResult Edit(int Id = 0, int ProjectSiteId = 0)
        {
            if (Id > 0)
            {
                var oob = Permission.AllowProject(Convert.ToInt64(Id));
                if (oob == null)
                {
                    TempData["msg_error"] = "This Project is not assigned to you. Please contact administrator for project assignment.";
                    return(RedirectToAction("index", "error", new { Area = "Project" }));
                }
                else
                {
                    TempData["ProjectEntity"] = oob; TempData.Keep("ProjectEntity");
                }
            }
            AD_DefinationBL    db  = new AD_DefinationBL();
            Sec_UserSettingsDL udl = new Sec_UserSettingsDL();

            ViewBag.FormType = (TempData["FormType"] != null) ? "Edit" : "New";

            ViewBag.Id = Id;

            ViewBag.Bands = db.ToList("Bands");

            ViewBag.ProjectSiteId = ProjectSiteId;
            ViewBag.ProjectSite   = ub.ToList("Get_By_Id", ProjectSiteId.ToString()).FirstOrDefault();
            if (ViewBag.ProjectSite == null)
            {
                TempData["msg_error"] = "Record Not Exist or You Are Not Authorize to access !";
                return(RedirectToAction("All"));
            }
            ViewBag.Carriers = db.ToList("Carriers");

            ViewBag.Regions = db.ToList("UserRegions", Convert.ToString(ViewBag.UserId));
            DataTable Table = udl.GetDataTable("UserProjects", Convert.ToString(ViewBag.UserId), null, null);

            ViewBag.Projects     = Table.ToList <PM_Projects>().Where(x => x.ProjectId == Id).ToList();
            ViewBag.Cities       = db.ToList("UserCities", Convert.ToString(ViewBag.UserId));
            ViewBag.SubCheckList = db.ToList("byDefinationType", "Sub CheckList");

            SWI.AirView.Common.SelectedList sl = new SWI.AirView.Common.SelectedList();
            ViewBag.NetworkModes = db.SelectedList("NetworkModes", null, "-NetworkMode-");
            var hjh = db.MultiSelecet("NetworkModes", null, "-NetworkMode-");

            ViewBag.NetworkModesm = hjh;
            ViewBag.States        = sl.Definations("UserStates", Convert.ToString(ViewBag.UserId), "-State-"); //sl.States();
            TSS_SurveyDocumentBL sdb = new TSS_SurveyDocumentBL();

            ViewBag.Surveys     = sdb.ToList("GetAll_byIsActive", true.ToString());;
            ViewBag.Scopes      = sl.Definations("UserScopes", Convert.ToString(ViewBag.UserId));// sl.Scopes();
            ViewBag.Clients     = sl.Clients("UserClients", Convert.ToString(ViewBag.UserId));
            ViewBag.SiteTypes   = sl.Definations("SiteTypes");
            ViewBag.SiteClasses = sl.Definations("SiteClasses");
            ViewBag.CheckList   = sl.Definations("byDefinationType", "CheckList", "-CheckList-");
            ViewBag.Sectors     = sl.Sectors();
            return(View());
        }
Example #2
0
 public DataTable DownloadAppBundle(Int64 UserId, string AppId, string EPin, string TPin)
 {
     try
     {
         Sec_UserSettingsDL udl = new Sec_UserSettingsDL();
         return(udl.GetDataTable("Download_App_Bundle", AppId, UserId.ToString(), EPin, TPin));
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #3
0
        public static void UpdateEntity(long Id)
        {
            Sec_UserSettingsDL udl = new Sec_UserSettingsDL();
            var login_data         = HttpContext.Current.Session["user"] as LoginInformation;
            LoginInformation li    = login_data;
            var Pper = udl.GetDataTable("UserProjects", Id.ToString(), null, null);
            List <Sec_UserProjects> UserProjects = Pper.ToList <Sec_UserProjects>();

            li.ProjectPermissions = UserProjects;
            HttpContext.Current.Session["user"] = null;
            HttpContext.Current.Session["user"] = li;
        }
Example #4
0
 public DataTable UserApplications(Int64 UserId)
 {
     try
     {
         Sec_UserSettingsDL udl = new Sec_UserSettingsDL();
         return(udl.GetDataTable("UserApplications", UserId.ToString()));
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #5
0
        public DataTable PendingNotifications(Int64 UserId)
        {
            try
            {
                Sec_UserSettingsDL udl = new Sec_UserSettingsDL();

                return(udl.GetDataTable("Pending_Notifications", UserId.ToString(), null, null));
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #6
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));
            }
        }
Example #7
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;
            }
        }
Example #8
0
        public Response ApproveAppRequest(Int64 AppId, Int64 UserId)
        {
            Response r = new Response();

            try
            {
                FireBase           fb          = new FireBase();
                WebConfig          wc          = new WebConfig();
                string             FirebaseKey = wc.AppSettings("AirViewStore");
                Sec_UserSettingsDL usd         = new Sec_UserSettingsDL();
                bool Result = usd.Manage("Set_IsRequestApproved", UserId, AppId, AppId.ToString(), null);

                if (Result)
                {
                    var dt = usd.GetDataTable("Get_UserAppToken", UserId.ToString(), AppId.ToString());
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        dynamic result = fb.SendNotification(FirebaseKey, dt.Rows[0]["Token"].ToString(), "{ \"EmailPIN\": \"" + dt.Rows[0]["EmailPIN"].ToString() + "\", \"MobilePIN\": \"" + dt.Rows[0]["MobilePIN"].ToString() + "\"}");

                        r.Status  = "success";
                        r.Message = "success";
                        r.Value   = result;
                    }
                    else
                    {
                        r.Status  = "error";
                        r.Message = "Device not found.";
                    }
                }
                else
                {
                    r.Status  = "error";
                    r.Message = "Request not fund.";
                }
            }
            catch (Exception ex)
            {
                r.Status  = "error";
                r.Message = ex.Message;
            }

            return(r);
        }
Example #9
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));
        }
Example #10
0
        public ActionResult Workorder(Int64 Id = 0)
        {
            AD_DefinationBL    db  = new AD_DefinationBL();
            Sec_UserSettingsDL udl = new Sec_UserSettingsDL();

            ViewBag.FormType = (TempData["FormType"] != null) ? "Edit" : "New";

            ViewBag.Bands = db.ToList("Bands");

            ViewBag.Id = Id;

            ViewBag.Carriers = db.ToList("Carriers");


            DataTable Table = udl.GetDataTable("UserProjects", Convert.ToString(ViewBag.UserId), null, null);

            ViewBag.Projects     = Table.ToList <PM_Projects>();
            ViewBag.Cities       = db.ToList("UserCities", Convert.ToString(ViewBag.UserId));
            ViewBag.SubCheckList = db.ToList("byDefinationType", "Sub CheckList");

            Common.SelectedList sl = new Common.SelectedList();
            ViewBag.NetworkModes = db.SelectedList("NetworkModes", null, "-NetworkMode-");
            var hjh = db.MultiSelecet("NetworkModes", null, "-NetworkMode-");

            ViewBag.NetworkModesm = hjh;
            ViewBag.States        = sl.Definations("UserStates", Convert.ToString(ViewBag.UserId), "-State-"); //sl.States();
            ViewBag.Regions       = db.ToList("UserRegions", Convert.ToString(ViewBag.UserId));
            TSS_SurveyDocumentBL sdb = new TSS_SurveyDocumentBL();

            ViewBag.Surveys     = sdb.ToList("GetAll_byIsActive", true.ToString());;
            ViewBag.Scopes      = sl.Definations("UserScopes", Convert.ToString(ViewBag.UserId));// sl.Scopes();
            ViewBag.Clients     = sl.Clients("UserClients", Convert.ToString(ViewBag.UserId));
            ViewBag.SiteTypes   = sl.Definations("SiteTypes");
            ViewBag.SiteClasses = sl.Definations("SiteClasses");
            ViewBag.CheckList   = sl.Definations("byDefinationType", "CheckList", "-CheckList-");
            ViewBag.Sectors     = sl.Sectors();
            WorkorderEdit we = new WorkorderEdit();

            return(View("Workorder", we));
        }
Example #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));
        }
Example #12
0
        public ActionResult UploadSites(string id)
        {
            var oob = Permission.AllowProject(Convert.ToInt64(id));

            if (oob == null)
            {
                TempData["msg_error"] = "This Project is not assigned to you. Please contact administrator for project assignment.";
                return(RedirectToAction("index", "error", new { Area = "Project" }));
            }
            else
            {
                TempData["ProjectEntity"] = oob; TempData.Keep("ProjectEntity");
            }

            Response response = new Response();

            response.Status  = "Unsuccessfull";
            response.Message = "Site(s) not Imported. Please try again!";
            try
            {
                AD_DefinationBL    defination      = new AD_DefinationBL();
                Sec_UserSettingsDL usrSetting      = new Sec_UserSettingsDL();
                DataTable          Table           = usrSetting.GetDataTable("UserProjects", Convert.ToString(ViewBag.UserId), null, null);
                var           ProjectsList         = Table.ToList <PM_Projects>().Where(x => x.ProjectId == long.Parse(id)).ToList();
                bool          isProjectNotEExist   = false;
                List <string> ErrorFile            = new List <string>();
                PM_ProjectBL  projectBL            = new PM_ProjectBL();
                var           ProjectFACodeList    = projectBL.ProjectFACode("ProjectFACodeList", Convert.ToInt64(id));
                SWI.AirView.Common.SelectedList sl = new SWI.AirView.Common.SelectedList();
                string   FileNamePrefix            = DateTime.Now.ToString("Error_File_ddMMhhmmss_");
                string   FileName     = null;
                bool     IsFileExist  = false;
                string[] DataInTable  = null;
                string   path         = null;
                Int64    ProjectIdOut = 0;
                if (isProjectNotEExist)
                {
                    Table        = usrSetting.GetDataTable("UserProjects", Convert.ToString(ViewBag.UserId), null, null);
                    ProjectsList = Table.ToList <PM_Projects>().Where(x => x.ProjectId == long.Parse(id)).ToList();
                }
                if (string.IsNullOrEmpty(id) || string.IsNullOrWhiteSpace(id))
                {
                    response.Status  = "InvalidProjectID";
                    response.Message = "Project ID is Empty. Please close the tab and reopen it.";
                    return(Json(response));
                }
                else
                {
                    if (!Int64.TryParse(id, out ProjectIdOut))
                    {
                        response.Status  = "InvalidProjectID";
                        response.Message = "Project ID is Invalid. Please close the tab and reopen it.";
                        return(Json(response));
                    }
                }
                if (ProjectsList?.Count <= 0)
                {
                    response.Status  = "ProjectPermissionIssue";
                    response.Message = "Sorry, You don't have permission for this Project.";
                    return(Json(response));
                }
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var file     = Request.Files[i];
                    var fileName = Path.GetFileName(file.FileName);
                    FileName = FileNamePrefix + fileName;
                    path     = Path.Combine(Server.MapPath("~/files/Raw"), FileName);
                    if (Path.GetExtension(path) != ".csv")
                    {
                        response.Status  = "Unsuccessfull";
                        response.Message = "Invalid file format, Only CSV file supported.";
                        return(Json(response));
                    }
                    file.SaveAs(path);
                    IsFileExist = true;
                }
                if (IsFileExist)
                {
                    List <SelectListItem> Scopes = sl.Definations("UserScopes", Convert.ToString(ViewBag.UserId));
                    var SiteTypes = sl.Definations("SiteTypes");
                    List <SWI.Libraries.AD.Entities.AD_Defination> Cities = defination.ToList("UserCities", Convert.ToString(ViewBag.UserId));
                    DataInTable = System.IO.File.ReadAllLines(path);
                    List <ProjectSites> Sites = new List <ProjectSites>();
                    string FileHeader         = string.Empty;
                    if (DataInTable?.Count() == 1)
                    {
                        response.Status  = "EmptyFile";
                        response.Message = "File is empty!";
                        return(Json(response));
                    }
                    if (DataInTable?.Count() > 0)
                    {
                        FileHeader = string.Join(",", DataInTable[0].Split(',').Take(20).ToArray()) + ",Error(s)";
                    }
                    ErrorFile.Add(FileHeader);
                    string        InValidInput       = string.Empty;
                    string        RequiredFileds     = string.Empty;
                    string        InvalidLength      = string.Empty;
                    string        InvalidDataType    = string.Empty;
                    string        FACodeAlreadyExist = string.Empty;
                    List <string> FACodeInFile       = new List <string>();
                    foreach (var item in DataInTable.Skip(1))
                    {
                        var cols = item.Split(',');
                        if (cols?.Count() > 0)
                        {
                            FACodeInFile.Add(cols[3]);
                        }
                    }
                    foreach (var row in DataInTable.Skip(1))
                    {
                        InValidInput       = string.Empty;
                        RequiredFileds     = string.Empty;
                        InvalidLength      = string.Empty;
                        InvalidDataType    = string.Empty;
                        FACodeAlreadyExist = string.Empty;
                        ProjectSites site = new ProjectSites();
                        site.ProjectId = Convert.ToInt64(id);
                        var Cols = row.Split(',');

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 0)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 0)))
                        {
                            var Market = Cities?.FirstOrDefault(x => x.DefinationName.ToLower() == Cols[0].ToLower());
                            if (Market != null)
                            {
                                site.Market = Convert.ToString(Market.DefinationId);
                            }
                            else
                            {
                                InValidInput += "[Market]";
                            }
                        }
                        else
                        {
                            RequiredFileds += "[Market]";
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 1)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 1)))
                        {
                            var Scope = Scopes?.FirstOrDefault(x => x.Text.ToLower() == Cols[1].ToLower());
                            if (Scope != null)
                            {
                                site.Scope = Convert.ToString(Scope.Value);
                            }
                            else
                            {
                                InValidInput += "[Scope]";
                            }
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 2)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 2)))
                        {
                            if (Cols[2].Length > 50)
                            {
                                InvalidLength += "[Cluster Code > 50]";
                            }
                            else
                            {
                                site.ClusterCode = Cols[2];
                                site.clusterId   = Cols[2];
                            }
                        }
                        else
                        {
                            RequiredFileds += "[Cluster Code]";
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 3)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 3)))
                        {
                            if (Cols[3].Length > 25)
                            {
                                InvalidLength += "[Site Code > 25]";
                            }
                            else
                            {
                                var  IsFACodeExist       = ProjectFACodeList?.Where(x => x.FACode.Trim().ToLower() == Cols[3].Trim().ToLower())?.Count() > 0 ? true : false;
                                bool IsFACodeExistInFile = FACodeInFile?.Where(x => x.Trim().ToLower() == Cols[3].Trim().ToLower())?.Count() > 1 ? true : false;
                                if (IsFACodeExist == false && IsFACodeExistInFile == false)
                                {
                                    site.SiteCode = Cols[3];
                                    site.FACode   = Cols[3];
                                }
                                else
                                {
                                    FACodeAlreadyExist += "[Site Code]";
                                }
                            }
                        }
                        else
                        {
                            RequiredFileds += "[Site Code]";
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 4)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 4)))
                        {
                            if (Cols[4].Length > 500)
                            {
                                InvalidLength += "[Site Name > 500]";
                            }
                            else
                            {
                                site.SiteName = Cols[4];
                            }
                        }
                        else
                        {
                            RequiredFileds += "[Site Name]";
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 5)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 5)))
                        {
                            double Out = 0;
                            if (!double.TryParse(Cols[5], out Out))
                            {
                                InvalidDataType += "[Latitude]";
                            }
                            if (Cols[5].Length > 500)
                            {
                                InvalidLength += "[Latitude > 500]";
                            }
                            else
                            {
                                site.siteLatitude = Cols[5];
                            }
                        }
                        else
                        {
                            RequiredFileds += "[Latitude]";
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 6)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 6)))
                        {
                            double Out = 0;
                            if (!double.TryParse(Cols[6], out Out))
                            {
                                InvalidDataType += "[Longitude]";
                            }
                            if (Cols[6].Length > 500)
                            {
                                InvalidLength += "[Longitude > 500]";
                            }
                            else
                            {
                                site.siteLongitude = Cols[6];
                            }
                        }
                        else
                        {
                            RequiredFileds += "[Longitude]";
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 7)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 7)))
                        {
                            var siteTypes = SiteTypes?.FirstOrDefault(x => x.Text.ToLower() == Cols[7].ToLower());
                            if (siteTypes != null)
                            {
                                site.SiteTypeId = Convert.ToString(siteTypes.Value);
                            }
                            else
                            {
                                InValidInput += "[Site Type]";
                            }
                        }
                        else
                        {
                            RequiredFileds += "[Site Type]";
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 8)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 8)))
                        {
                            if (Cols[8].Length > 7)
                            {
                                InvalidLength += "[Color > 7]";
                            }
                            else
                            {
                                site.Color = Cols[8];
                            }
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 9)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 9)))
                        {
                            if (Cols[9].Length > 500)
                            {
                                InvalidLength += "[Description > 500]";
                            }
                            else
                            {
                                site.Description = Cols[9];
                            }
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 10)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 10)))
                        {
                            if (Cols[10].Length > 25)
                            {
                                InvalidLength += "[USID > 25]";
                            }
                            else
                            {
                                site.USID = Cols[10];
                            }
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 11)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 11)))
                        {
                            if (Cols[11].Length > 150)
                            {
                                InvalidLength += "[Sub Market > 150]";
                            }
                            else
                            {
                                site.SubMarket = Cols[11];
                            }
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 12)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 12)))
                        {
                            bool Out = false;
                            if (!bool.TryParse(Cols[12], out Out))
                            {
                                InvalidDataType += "[vMME]";
                            }
                            else
                            {
                                site.vMME = Convert.ToBoolean(Cols[12]);
                            }
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 13)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 13)))
                        {
                            bool Out = false;
                            if (!bool.TryParse(Cols[13], out Out))
                            {
                                InvalidDataType += "[Controlled Intro]";
                            }
                            else
                            {
                                site.ControlledIntro = Convert.ToBoolean(Cols[13]);
                            }
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 14)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 14)))
                        {
                            bool Out = false;
                            if (!bool.TryParse(Cols[14], out Out))
                            {
                                InvalidDataType += "[Super Bowl]";
                            }
                            else
                            {
                                site.SuperBowl = Convert.ToBoolean(Cols[14]);
                            }
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 15)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 15)))
                        {
                            if (Cols[15].Length > 50)
                            {
                                InvalidLength += "[isDASInBuild > 50]";
                            }
                            else
                            {
                                site.isDASInBuild = Convert.ToString(Cols[15]);
                            }
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 16)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 16)))
                        {
                            if (Cols[16].Length > 50)
                            {
                                InvalidLength += "[FirstNetRAN > 50]";
                            }
                            else
                            {
                                site.FirstNetRAN = Convert.ToString(Cols[16]);
                            }
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 17)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 17)))
                        {
                            if (Cols[17].Length > 50)
                            {
                                InvalidLength += "[IPlan Job > 50]";
                            }
                            else
                            {
                                site.IPlanJob = Convert.ToString(Cols[17]);
                            }
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 18)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 18)))
                        {
                            if (Cols[18].Length > 50)
                            {
                                InvalidLength += "[PaceNo > 50]";
                            }
                            else
                            {
                                site.PaceNo = Convert.ToString(Cols[18]);
                            }
                        }

                        if (!string.IsNullOrEmpty(Utilities.ElementAtOrDefault(Cols, 19)) && !string.IsNullOrWhiteSpace(Utilities.ElementAtOrDefault(Cols, 19)))
                        {
                            DateTime Out = DateTime.Now;
                            if (!DateTime.TryParse(Cols[19], out Out))
                            {
                                InvalidDataType += "[Invalid IPlanIssueDate]";
                            }

                            if (Cols[19].Length > 10)
                            {
                                InvalidLength += "[IPlanIssueDate > 10]";
                            }
                            else
                            {
                                site.IPlanIssueDate = Convert.ToString(Cols[19]);
                            }
                        }

                        if (string.IsNullOrEmpty(RequiredFileds) && string.IsNullOrEmpty(InValidInput) && string.IsNullOrEmpty(InvalidDataType) && string.IsNullOrEmpty(InvalidLength) && string.IsNullOrEmpty(FACodeAlreadyExist))
                        {
                            Sites.Add(site);
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(RequiredFileds))
                            {
                                RequiredFileds += (RequiredFileds?.TrimEnd(',')?.Split(',')?.Count() >= 2) ? " are required." : " is required.";
                            }

                            if (!string.IsNullOrEmpty(InvalidLength))
                            {
                                InvalidLength += " has Invalid Length.";
                            }

                            if (!string.IsNullOrEmpty(InvalidDataType))
                            {
                                InvalidDataType += " have invalid data type.";
                            }

                            if (!string.IsNullOrEmpty(InValidInput))
                            {
                                InValidInput += " have invalid input.";
                            }

                            if (!string.IsNullOrEmpty(FACodeAlreadyExist))
                            {
                                FACodeAlreadyExist += " already exist.";
                            }

                            string NewRowWithErrors = $"{string.Join(",", Cols.Take(20).ToArray()).TrimEnd(',')},{RequiredFileds} {FACodeAlreadyExist} {InValidInput} {InvalidDataType} {InvalidLength} ";
                            ErrorFile.Add(NewRowWithErrors);
                        }
                    }

                    if (Sites?.Count > 0 && ErrorFile.Count <= 1)
                    {
                        var IsInserted = ub.Insert("Insert", Sites, Convert.ToInt64(ViewBag.UserId), 0, Sites[0].SiteName);
                        if (IsInserted)
                        {
                            response.Status  = "Ok";
                            response.Message = "Site(s) imported successfully!";
                        }
                        else
                        {
                            response.Status  = "Unsuccessfull";
                            response.Message = "There is an unexpected error. Please try again!";
                        }
                    }
                    else if (ErrorFile.Count > 1)
                    {
                        System.IO.File.WriteAllLines(Path.Combine(Server.MapPath("~/files/Raw"), FileName), ErrorFile);
                        response.Status  = "OkWithErrorFile";
                        response.Value   = $"/files/Raw/{FileName}";
                        response.Message = "File could not be uploaded due to errors in file.";
                    }
                    else
                    {
                        response.Status  = "Unsuccessfull";
                        response.Message = "There is an unexpected error. Please try again!";
                    }
                }
            }
            catch (Exception e)
            {
                return(Json(response));
            }
            return(Json(response));
        }
Example #13
0
        public ActionResult Edit(int Id = 0)
        {
            ViewBag.FormType = "Edit";
            AV_SitesBL       sb      = new AV_SitesBL();
            AV_Site          Site    = new AV_Site();
            List <AV_Sector> Sectors = new List <AV_Sector>();

            sb.SiteWithSectors(Id, ref Site, ref Sectors);
            ViewBag.Site = Site;
            Common.SelectedList sl = new Common.SelectedList();
            AD_DefinationBL     db = new AD_DefinationBL();

            ViewBag.NetworkModes = db.SelectedList("NetworkModes", null, "-NetworkMode-");
            ViewBag.Bands        = db.ToList("Bands");
            ViewBag.Carriers     = db.ToList("Carriers");
            ViewBag.Scopes       = sl.Scopes();
            ViewBag.Sectors      = sl.Sectors();
            List <SWI.Libraries.Common.SelectedList> Markets = new List <SelectedList>();

            if (ViewBag.IsAdmin)
            {
                ViewBag.UserMarkets = db.SelectedList("AllCities");
                Markets             = ViewBag.UserMarkets;
            }
            else
            {
                ViewBag.UserMarkets = db.SelectedList("UserCities", Convert.ToString(ViewBag.UserId));
                Markets             = ViewBag.UserMarkets;
            }


            //bands network mode etc dropdowns
            WorkorderEdit      we  = new WorkorderEdit();
            Sec_UserSettingsDL udl = new Sec_UserSettingsDL();

            we.Site           = Site;
            we.Site.StateId   = we.Site.State;
            we.Site.RegionId  = we.Site.Region;
            we.Site.MarketId  = we.Site.Market;
            we.Site.SiteType  = we.Site.SiteTypeId;
            we.Site.SiteClass = we.Site.SiteClassId;
            we.Bands          = ViewBag.Bands;
            ViewBag.Id        = Id;

            we.Carriers = ViewBag.Carriers;

            DataTable Table = udl.GetDataTable("UserProjects", Convert.ToString(ViewBag.UserId), null, null);

            we.Projects     = Table.ToList <PM_Projects>();
            we.Cities       = db.ToList("UserCities", Convert.ToString(ViewBag.UserId));
            we.SubCheckList = db.ToList("byDefinationType", "Sub CheckList");

            we.NetworkModes = ViewBag.NetworkModes;
            var hjh = db.MultiSelecet("NetworkModes", null, "-NetworkMode-");

            we.NetworkModesm = hjh;
            we.States        = sl.Definations("UserStates", Convert.ToString(ViewBag.UserId), "-State-"); //sl.States();
            we.Regions       = db.ToList("UserRegions", Convert.ToString(ViewBag.UserId));
            // we.Regions = we.Regions.Where(x => x.PDefinationId ==we.State).ToList();
            we.UserMarkets = Markets;
            //   we.UserMarkets = we.UserMarkets;    //.Where(x=>x.Value==Convert.ToString(we.Region)).ToList();
            TSS_SurveyDocumentBL sdb = new TSS_SurveyDocumentBL();

            we.Surveys             = sdb.ToList("GetAll_byIsActive", true.ToString());
            we.Clients             = sl.Clients("UserClients", Convert.ToString(ViewBag.UserId));
            we.Scopes              = sl.Definations("UserScopes", Convert.ToString(ViewBag.UserId));// sl.Scopes();
            we.SiteTypes           = sl.Definations("SiteTypes");
            we.SiteClasses         = sl.Definations("SiteClasses");
            we.CheckList           = sl.Definations("byDefinationType", "CheckList", "-CheckList-");
            we.Sectors             = Sectors;
            we.Sectors[0].Bands    = we.Bands;
            we.Sectors[0].Carriers = we.Carriers;

            return(View("Workorder", we)); // return View(Sectors);
        }
Example #14
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());
        }