// // GET: /StoreVist/ public ActionResult Index(string id = "", string customerid = "", string FromDate = "", string ToDate = "", string Date = "", string selection = "", string LastModifiedDate = "", string Visit_RowCount = "", string NonVisit_RowCount = "", int page = 1, string Visit_Search = "", string NonVisit_Search = "", string hdnrecordsize="") { Logger.Debug("Inside CustomerView Controller- Index"); try { ViewBag.CustomerID = customerid; ViewBag.FromDate = FromDate; ViewBag.ToDate = ToDate; ViewBag.Date = Date; int visit_TotalPage = 0; int visit_TotalRecord = 0; int visit_pCount = 0; int nonvisit_TotalPage = 0; int nonvisit_TotalRecord = 0; int nonvisit_pCount = 0; if (Session["OrganizationGUID"] != null) { if (!string.IsNullOrEmpty(Visit_RowCount)) { int.TryParse(Visit_RowCount, out visit_pCount); pageVisitCountList(visit_pCount); } else { pageVisitCountList(visit_pCount); } if (!string.IsNullOrEmpty(NonVisit_RowCount)) { int.TryParse(NonVisit_RowCount, out nonvisit_pCount); pageNonVisitCountList(nonvisit_pCount); } else { pageNonVisitCountList(nonvisit_pCount); } if (!string.IsNullOrEmpty(Date)) { ViewBag.DateValue = HttpUtility.HtmlDecode(Date); Session["DateValue"] = Date; } else if (!string.IsNullOrEmpty(LastModifiedDate)) { Logger.Debug("Inside Last Modfied dislay"); if (!string.IsNullOrEmpty(FromDate) && !string.IsNullOrEmpty(ToDate)) { DateTime pFrom = new DateTime(), pTo = new DateTime(); if (ParseExact(FromDate, "dd-MM-yyyy", out pFrom)) { ParseExact(ToDate, "dd-MM-yyyy", out pTo); Logger.Debug("Inside"); string datevalue = pFrom.ToString("MMMM d, yyyy") + " - " + pTo.ToString("MMMM d, yyyy"); ViewBag.DateValue = datevalue; Session["DateValue"] = datevalue; } else { Logger.Debug("OutSide"); string datevalue = DateTime.Now.AddDays(-29).ToString("MMMM d, yyyy") + " - " + DateTime.Now.ToString("MMMM d, yyyy"); ViewBag.DateValue = datevalue; Session["DateValue"] = datevalue; } Logger.Debug("From Parst : " + pFrom); Logger.Debug("To Parse : " + pTo); } else { Logger.Debug("OutSide1"); string datevalue = DateTime.Now.AddDays(-29).ToString("MMMM d, yyyy") + " - " + DateTime.Now.ToString("MMMM d, yyyy"); ViewBag.DateValue = datevalue; Session["DateValue"] = datevalue; } } else { Logger.Error("OutSide2"); string datevalue = DateTime.Now.AddDays(-29).ToString("MMMM d, yyyy") + " - " + DateTime.Now.ToString("MMMM d, yyyy"); ViewBag.DateValue = datevalue; Session["DateValue"] = datevalue; } StoreVisitReports pStoreVisitReports = new StoreVisitReports(); pStoreVisitReports.StoreVisitList = new List<StoreVisit>(); pStoreVisitReports.StoreNonVisitList = new List<MarketModel>(); Session["CustomerGUID"] = customerid; if (!string.IsNullOrEmpty(id)) { TempData["TabName"] = id; } else { TempData["TabName"] = "Visits"; } StringBuilder sb = new StringBuilder(); StringBuilder sb1 = new StringBuilder(); sb.Append("<div class='actions'>"); sb.Append("<div class='btn-group'>"); sb1.Append("<div class='actions'>"); sb1.Append("<div class='btn-group'>"); if (!string.IsNullOrEmpty(customerid)) { Place pplace = _IPlaceRepository.GetPlaceByID(new Guid(customerid)); if (pplace != null) { Session["ClientCompanyName"] = pplace.PlaceName; sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i>" + pplace.PlaceName + " <i class='icon-angle-down'></i></a>"); sb1.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i>" + pplace.PlaceName + " <i class='icon-angle-down'></i></a>"); } } else { if (!string.IsNullOrEmpty(selection) && selection == "All") { sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i>All <i class='icon-angle-down'></i></a>"); sb1.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i>All <i class='icon-angle-down'></i></a>"); } else { sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i>Select Client <i class='icon-angle-down'></i></a>"); sb1.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i>Select Client <i class='icon-angle-down'></i></a>"); } } sb.Append("<ul id='ulworkgroup' style='height:100px;overflow-y:scroll' class='dropdown-menu pull-right'>"); sb1.Append("<ul id='ulworkgroup' style='height:100px;overflow-y:scroll' class='dropdown-menu pull-right'>"); if (string.IsNullOrEmpty(selection) || selection != "All") { //sb.Append("<li><a href=" + Url.Action("Index", new { id = "Visits", selection = "All" }) + ">All</a></li>"); //sb1.Append("<li><a href=" + Url.Action("Index", new { id = "Non-Visits", selection = "All" }) + ">All</a></li>"); sb.Append("<li><a onclick=\"RedirectAction('Visits','');\">All</a></li>"); sb1.Append("<li><a onclick=\"RedirectAction('NonVisits','');\">All</a></li>"); } List<Place> PlaceList = _IPlaceRepository.GetPlaceByOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).ToList(); foreach (Place item in PlaceList) { //sb.Append("<li><a href=" + Url.Action("Index", new { id = "Visits", customerid = item.PlaceGUID.ToString() }) + " data-groupguid=" + item.PlaceGUID + ">" + item.PlaceName + "</a></li>"); //sb1.Append("<li><a href=" + Url.Action("Index", new { id = "Non-Visits", customerid = item.PlaceGUID.ToString() }) + " data-groupguid=" + item.PlaceGUID + ">" + item.PlaceName + "</a></li>"); sb.Append("<li><a onclick=\"RedirectAction('Visits','" + item.PlaceGUID.ToString() + "');\" data-groupguid=" + item.PlaceGUID + ">" + item.PlaceName + "</a></li>"); sb1.Append("<li><a onclick=\"RedirectAction('NonVisits','" + item.PlaceGUID.ToString() + "');\" data-groupguid=" + item.PlaceGUID + ">" + item.PlaceName + "</a></li>"); } sb.Append("</ul>"); sb.Append("</div>"); sb.Append("</div>"); sb1.Append("</ul>"); sb1.Append("</div>"); sb1.Append("</div>"); ViewBag.CustomerListVisit = sb.ToString(); ViewBag.CustomerListNonVisit = sb1.ToString(); Market _market = new Market(); Job ljob = new Job(); ljob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); _market.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); if (!string.IsNullOrEmpty(customerid)) { _market.OwnerGUID = new Guid(customerid); ljob.CustomerGUID = new Guid(customerid); } DateTime From, To, Datecontent, LModifiedDate; //LastModifiedDate = _IUserRepository.DecodeFrom64(LastModifiedDate); if (!string.IsNullOrEmpty(LastModifiedDate) && ParseExact(LastModifiedDate, "dd-MM-yyyy", out LModifiedDate)) { ljob.LastModifiedDate = LModifiedDate; _market.LastStoreVisitedDate = LModifiedDate; } else if (!string.IsNullOrEmpty(FromDate) && ParseExact(FromDate, "dd-MM-yyyy", out From)) _market.LastStoreVisitedDate = From; else _market.LastStoreVisitedDate = DateTime.Now.AddDays(-29); if (!string.IsNullOrEmpty(FromDate) && ParseExact(FromDate, "dd-MM-yyyy", out From)) { ljob.ActualStartTime = From; } else { Logger.Error("From Else"); ljob.ActualStartTime = DateTime.Now.AddDays(-29); } if (!string.IsNullOrEmpty(ToDate) && ParseExact(ToDate, "dd-MM-yyyy", out To)) { ljob.ActualEndTime = To; } else { Logger.Error("To Else"); ljob.ActualEndTime = DateTime.Now; } ljob.JobName = "Store Visit"; Logger.Debug("Job Object" + Newtonsoft.Json.JsonConvert.SerializeObject(ljob)); //FOr Regional Manager if (Session["UserType"] != null && !string.IsNullOrEmpty(Session["UserType"].ToString()) && Session["UserType"].ToString() == "ENT_U_RM" && Session["UserGUID"] != null) { OrganizationUsersMap OrgUserMap = _IOrganizationRepository.GetOrganizationUserMapByUserGUID(new Guid(Session["UserGUID"].ToString()), ljob.OrganizationGUID); if (OrgUserMap != null) { ljob.RegionGUID = OrgUserMap.RegionGUID; _market.RegionGUID = OrgUserMap.RegionGUID; } } //check the current user is Field Manager or not if (Session["UserType"] != null && !string.IsNullOrEmpty(Session["UserType"].ToString()) && Session["UserType"].ToString() == "ENT_U" && Session["UserGUID"] != null) { GlobalUser globalUser = _IGlobalUserRepository.GetGlobalUserByID(new Guid(Session["UserGUID"].ToString())); if (globalUser != null) { ljob.AssignedUserGUID = globalUser.UserGUID; _market.FMUserID = globalUser.USERID; } } List<Job> lstorevisit = _IJobRepository.GetStoreVisitJobs(ljob); List<Market> lstorenonvisit = new List<Market>(); lstorenonvisit = _IMarketRepository.GetStoreNonVisit(_market); if (lstorevisit != null && lstorevisit.Count > 0) { ViewBag.Visit_Search = Visit_Search; if (!string.IsNullOrEmpty(Visit_Search)) { Visit_Search = Visit_Search.ToLower(); lstorevisit = lstorevisit.Where( p => (!String.IsNullOrEmpty(_IRegionRepository.GetRegionNameByRegionGUID(new Guid(p.RegionGUID.ToString()))) && _IRegionRepository.GetRegionNameByRegionGUID(new Guid(p.RegionGUID.ToString())).ToLower().Contains(Visit_Search)) || (!String.IsNullOrEmpty(p.CustomerStopGUID.ToString()) && _IMarketRepository.GetMarketByID(new Guid(p.CustomerStopGUID.ToString())).MarketID.ToLower().Contains(Visit_Search)) || (!String.IsNullOrEmpty(p.PONumber) && _IMarketRepository.GetMarketByCustomerID(p.OrganizationGUID, _IPORepository.GetPObyPoNumber(p.PONumber).PlaceID, _IPORepository.GetPObyPoNumber(p.PONumber).MarketID).MarketID.ToLower().Contains(Visit_Search)) || (!String.IsNullOrEmpty(p.CustomerStopGUID.ToString()) && _IMarketRepository.GetMarketByID(new Guid(p.CustomerStopGUID.ToString())).MarketName.ToLower().Contains(Visit_Search)) || (!String.IsNullOrEmpty(p.PONumber) && _IMarketRepository.GetMarketByCustomerID(p.OrganizationGUID, _IPORepository.GetPObyPoNumber(p.PONumber).PlaceID, _IPORepository.GetPObyPoNumber(p.PONumber).MarketID).MarketName.ToLower().Contains(Visit_Search)) || (!String.IsNullOrEmpty(_IJobRepository.GetStatusName((int)p.StatusCode)) && _IJobRepository.GetStatusName((int)p.StatusCode).ToLower().Contains(Visit_Search)) || (!String.IsNullOrEmpty(_IUserProfileRepository.GetUserProfileByUserID(_IGlobalUserRepository.GetGlobalUserByID(new Guid(p.ManagerUserGUID.ToString())).UserGUID, p.OrganizationGUID).ToString()) && _IUserProfileRepository.GetUserProfileByUserID(_IGlobalUserRepository.GetGlobalUserByID(new Guid(p.ManagerUserGUID.ToString())).UserGUID, p.OrganizationGUID).ToString().ToLower().Contains(Visit_Search))).ToList(); } visit_TotalRecord = lstorevisit.ToList().Count; visit_TotalPage = (visit_TotalRecord / (int)ViewBag.pageVisitCountValue) + ((visit_TotalRecord % (int)ViewBag.pageVisitCountValue) > 0 ? 1 : 0); ViewBag.Visit_TotalRows = visit_TotalRecord; lstorevisit = lstorevisit.OrderBy(a => a.OrganizationGUID).Skip(((page - 1) * (int)ViewBag.pageVisitCountValue)).Take((int)ViewBag.pageVisitCountValue).ToList(); foreach (Job job in lstorevisit) { StoreVisit storevisit = ConvertToStoreVisit(job); if (storevisit != null) { pStoreVisitReports.StoreVisitList.Add(storevisit); } } } // Logger.Debug("Store Non Visit Count : " + lstorenonvisit.Count); if (lstorenonvisit != null && lstorenonvisit.Count > 0) { ViewBag.NonVisit_Search = NonVisit_Search; if (!string.IsNullOrEmpty(NonVisit_Search)) { NonVisit_Search = NonVisit_Search.ToLower(); lstorenonvisit = lstorenonvisit.Where( p => (!String.IsNullOrEmpty(p.RegionName) && p.RegionName.ToLower().Contains(NonVisit_Search)) || (!String.IsNullOrEmpty(p.MarketID) && p.MarketID.ToLower().Contains(NonVisit_Search)) || (!String.IsNullOrEmpty(p.MarketName) && p.MarketName.ToLower().Contains(NonVisit_Search))).ToList(); } nonvisit_TotalRecord = lstorenonvisit.ToList().Count; nonvisit_TotalPage = (nonvisit_TotalRecord / (int)ViewBag.pageNonCountValue) + ((nonvisit_TotalRecord % (int)ViewBag.pageNonCountValue) > 0 ? 1 : 0); ViewBag.NonVisit_TotalRows = nonvisit_TotalRecord; lstorenonvisit = lstorenonvisit.OrderBy(a => a.OrganizationGUID).Skip(((page - 1) * (int)ViewBag.pageNonCountValue)).Take((int)ViewBag.pageNonCountValue).ToList(); foreach (Market market in lstorenonvisit) { MarketModel _marketModel = ConvertToStoreNonVisit(market); if (_marketModel != null) { pStoreVisitReports.StoreNonVisitList.Add(_marketModel); } } } Session["StoreVisit"] = pStoreVisitReports.StoreVisitList; Session["StoreNonVisit"] = pStoreVisitReports.StoreNonVisitList; if (!string.IsNullOrEmpty(Visit_RowCount)) ViewBag.pageVisitCountValue = int.Parse(Visit_RowCount); else ViewBag.pageVisitCountValue = 5; if (!string.IsNullOrEmpty(NonVisit_RowCount)) ViewBag.pageNonCountValue = int.Parse(NonVisit_RowCount); else ViewBag.pageNonCountValue = 5; bool visit = false; bool nonvisit = false; if (null != Request && System.Text.RegularExpressions.Regex.IsMatch(Request.Url.ToString().Replace("-", ""), string.Format(@"\b{0}\b", "Visits"))) visit = true; if (null != Request && System.Text.RegularExpressions.Regex.IsMatch(Request.Url.ToString().Replace("-", ""), string.Format(@"\b{0}\b", "NonVisits"))) nonvisit = true; if (visit) TempData["TabName"] = "Visits"; else if(nonvisit) TempData["TabName"] = "Non-Visits"; return View(pStoreVisitReports); } else { return RedirectToAction("SessionTimeOut", "User"); } } catch (Exception ex) { Logger.Error(ex.Message); return RedirectToAction("Login", "User"); } }
// // GET: /JobStatus/ public ActionResult Index(string FromDate = "", string ToDate = "", string assigneduserguid = "", string jobindexguid = "", string Date = "", string selection = "", string ponumber = "", string RowCount = "", int page = 1, string search = "") { Logger.Debug("Inside AssignJob Controller- Index"); try { ViewBag.AssignedUserID = assigneduserguid; ViewBag.FromDate = FromDate; ViewBag.ToDate = ToDate; ViewBag.Date = Date; int totalPage = 0; int totalRecord = 0; int pCount = 0; if (Session["OrganizationGUID"] != null) { if (!string.IsNullOrEmpty(RowCount)) { int.TryParse(RowCount, out pCount); pageCountList(pCount); } else { pageCountList(pCount); } if (!string.IsNullOrEmpty(Date)) { ViewBag.DateValue = HttpUtility.HtmlDecode(Date); } var jobStatus = new JobStatusViewModel(); jobStatus.JobStatusModel = new List<JobStatusModel>(); var jobGroup = new List<Job>(); //Job ljob = new Job(); DateTime pFrom = new DateTime(), pTo = new DateTime(); OrganizationUsersMap pOrganizationUsersMap = _IUserRepository.GetUserByID(new Guid(Session["UserGUID"].ToString())); Logger.Debug("UserGUID:" + Session["UserGUID"].ToString()); if (pOrganizationUsersMap != null) { StringBuilder sb = new StringBuilder(); sb.Append("<div class='actions'>"); sb.Append("<div class='btn-group'>"); if (!string.IsNullOrEmpty(assigneduserguid)) { ViewBag.AssignedUserID = assigneduserguid; Logger.Debug("Inside AssignedUSerGUID" + assigneduserguid.ToString()); UserProfile _userprofile = _IUserProfileRepository.GetUserProfileByUserID(new Guid(assigneduserguid), pOrganizationUsersMap.OrganizationGUID); if (_userprofile != null) { sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> " + _userprofile.FirstName + " " + _userprofile.LastName + " <i class='icon-angle-down'></i></a>"); } } else { if (!string.IsNullOrEmpty(selection) && selection == "All") { sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> All <i class='icon-angle-down'></i></a>"); } else { sb.Append("<a href='#' id='ulaworkergroup' class='btn green' data-toggle='dropdown'><i class='icon-map-marker'></i> Select User <i class='icon-angle-down'></i></a>"); } } sb.Append("<ul id='ulworkgroup' style='height:200px;overflow-y:scroll' class='dropdown-menu pull-right'>"); if (Session["UserType"] != null && Session["UserType"].ToString() != "ENT_U" && pOrganizationUsersMap != null) { if (string.IsNullOrEmpty(selection) || selection != "All") { //sb.Append("<li><a href=" + Url.Action("Index", "UserActivities", new { selection = "All" }) + ">All</a></li>"); sb.Append("<li><a onclick=\"RedirectAction('');\">All</a></li>"); } List<UserProfile> pUserProfile = _IUserProfileRepository.GetUserProfilesbyOrganizationGUID(new Guid(Session["OrganizationGUID"].ToString())).ToList(); if (pUserProfile != null && pUserProfile.Count > 0) { pUserProfile = pUserProfile.OrderBy(x => x.FirstName).ToList(); foreach (UserProfile item in pUserProfile) { //sb.Append("<li><a href=" + Url.Action("Index", "UserActivities", new { assigneduserguid = item.UserGUID.ToString() }) + " data-groupguid=" + item.UserGUID + ">" + item.FirstName + " " + item.LastName + "</a></li>"); sb.Append("<li><a onclick=\"RedirectAction('" + item.UserGUID.ToString() + "');\" data-groupguid=" + item.UserGUID + ">" + item.FirstName + " " + item.LastName + "</a></li>"); Logger.Debug("Inside User foreach"); } } } sb.Append("</ul>"); sb.Append("</div>"); sb.Append("</div>"); ViewBag.UserList = sb.ToString(); Job mjob = new Job(); if (!string.IsNullOrEmpty(ponumber)) { mjob.PONumber = ponumber; TempData["PoNumber"] = ponumber; } //FOr Regional Manager if (Session["UserType"] != null && !string.IsNullOrEmpty(Session["UserType"].ToString()) && Session["UserType"].ToString() == "ENT_U_RM" && Session["UserGUID"] != null) { OrganizationUsersMap OrgUserMap = _IOrganizationRepository.GetOrganizationUserMapByUserGUID(new Guid(Session["UserGUID"].ToString()), new Guid(Session["OrganizationGUID"].ToString())); if (OrgUserMap != null) { mjob.RegionGUID = OrgUserMap.RegionGUID; } } if (!string.IsNullOrEmpty(FromDate) && !string.IsNullOrEmpty(ToDate) && !string.IsNullOrEmpty(assigneduserguid)) { //ViewBag.FromDate = FromDate; //ViewBag.ToDate = ToDate; Logger.Debug("Inside 1"); if (Session["UserType"] != null && Session["UserType"].ToString() == "ENT_U") { mjob.AssignedUserGUID = new Guid(assigneduserguid); if (ParseExact(FromDate, "dd-MM-yyyy", out pFrom)) { mjob.ActualStartTime = pFrom; } else { Logger.Debug("From else"); mjob.ActualStartTime = DateTime.Now.AddDays(-29); } if (ParseExact(ToDate, "dd-MM-yyyy", out pTo)) { mjob.ActualEndTime = pTo; } else { Logger.Debug("To else"); mjob.ActualEndTime = DateTime.Now; } mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); jobGroup = _IJobRepository.GetJobs(mjob); } else { Logger.Debug("Inside 1 else"); mjob.AssignedUserGUID = new Guid(assigneduserguid); if (ParseExact(FromDate, "dd-MM-yyyy", out pFrom)) { mjob.ActualStartTime = pFrom; } else { Logger.Debug("From else 1"); mjob.ActualStartTime = DateTime.Now.AddDays(-29); } if (ParseExact(ToDate, "dd-MM-yyyy", out pTo)) { mjob.ActualEndTime = pTo; } else { Logger.Debug("To Else 1"); mjob.ActualEndTime = DateTime.Now; } // mjob.PreferedEndTime = _IUserRepository.GetLocalDateTime(mjob.PreferedEndTime, Session["TimeZoneID"].ToString()); mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); jobGroup = _IJobRepository.GetJobs(mjob); } } else if (!string.IsNullOrEmpty(FromDate) && !string.IsNullOrEmpty(ToDate)) { Logger.Debug("Inside 2"); if (Session["UserType"] != null && Session["UserType"].ToString() == "ENT_U") { if (ParseExact(FromDate, "dd-MM-yyyy", out pFrom)) { mjob.ActualStartTime = pFrom; } else { Logger.Debug("From else"); mjob.ActualStartTime = DateTime.Now.AddDays(-29); } if (ParseExact(ToDate, "dd-MM-yyyy", out pTo)) { mjob.ActualEndTime = pTo; } else { Logger.Debug("To else"); mjob.ActualEndTime = DateTime.Now; } mjob.AssignedUserGUID = new Guid(Session["UserGUID"].ToString()); mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); jobGroup = _IJobRepository.GetJobs(mjob); } else { Logger.Debug("Inside 3"); if (ParseExact(FromDate, "dd-MM-yyyy", out pFrom)) { mjob.ActualStartTime = pFrom; } else { Logger.Debug("From Else"); mjob.ActualStartTime = DateTime.Now.AddDays(-29); } if (ParseExact(ToDate, "dd-MM-yyyy", out pTo)) { mjob.ActualEndTime = pTo; } else { Logger.Debug("To Else"); mjob.ActualEndTime = DateTime.Now; } mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); jobGroup = _IJobRepository.GetJobs(mjob); } } else if (!string.IsNullOrEmpty(assigneduserguid)) { mjob.ActualStartTime = DateTime.Now.AddDays(-29); mjob.ActualEndTime = DateTime.Now; mjob.AssignedUserGUID = new Guid(assigneduserguid); mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); jobGroup = _IJobRepository.GetJobs(mjob); } else { mjob.ActualStartTime = DateTime.Now.AddDays(-29); mjob.ActualEndTime = DateTime.Now; if (Session["UserType"] != null && Session["UserType"].ToString() == "ENT_U") { mjob.AssignedUserGUID = new Guid(Session["UserGUID"].ToString()); mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); jobGroup = _IJobRepository.GetJobs(mjob); } else { mjob.OrganizationGUID = new Guid(Session["OrganizationGUID"].ToString()); jobGroup = _IJobRepository.GetJobs(mjob); } } if (jobGroup != null && jobGroup.Count > 0) { ViewBag.Search = search; if (!string.IsNullOrEmpty(search)) { search = search.ToLower(); jobGroup = jobGroup.Where(x => (x.CustomerGUID != null ? GetCompanyName(x.CustomerGUID).ToLower() : GetCompanyNameByPO(x.PONumber).ToLower()).Contains(search) || (!String.IsNullOrEmpty(x.JobName) && x.JobName.ToLower().Contains(search)) || (!String.IsNullOrEmpty(x.PONumber) && x.PONumber.ToLower().Contains(search)) || (!string.IsNullOrEmpty(x.CustomerGUID.ToString()) ? getStoreID(x.CustomerStopGUID.ToString()) : "").Contains(search) || (_IJobRepository.GetStatusName(Convert.ToInt32(x.StatusCode)).ToLower().Contains(search)) ).ToList(); } totalRecord = jobGroup.ToList().Count; totalPage = (totalRecord / (int)ViewBag.pageCountValue) + ((totalRecord % (int)ViewBag.pageCountValue) > 0 ? 1 : 0); ViewBag.TotalRows = totalRecord; jobGroup = jobGroup.OrderBy(a => a.OrganizationGUID).Skip(((page - 1) * (int)ViewBag.pageCountValue)).Take((int)ViewBag.pageCountValue).ToList(); foreach (var job in jobGroup.ToList()) { JobStatusModel js = new JobStatusModel(); js.JobName = job.JobName; js.JobIndexGUID = job.JobGUID.ToString(); // js.JobLogicalID = job.JobFormGUID.ToString(); js.UserGUID = job.AssignedUserGUID.ToString(); js.PreferredStartTime = job.PreferedStartTime != null ? Session["TimeZoneID"] != null ? _IUserRepository.GetLocalDateTime(job.PreferedStartTime, Session["TimeZoneID"].ToString()) : job.PreferedStartTime.ToString() : ""; js.PreferredStartTime = !string.IsNullOrEmpty(js.PreferredStartTime) ? _IUserRepository.GetLocalDateTime(job.PreferedStartTime, Session["TimeZoneID"].ToString()) : ""; js.PreferredStartTime = !string.IsNullOrEmpty(js.PreferredStartTime) ? Convert.ToDateTime(js.PreferredStartTime).ToString("MM/dd/yy HH:mm") : ""; js.PreferredEndTime = job.PreferedEndTime != null ? Session["TimeZoneID"] != null ? _IUserRepository.GetLocalDateTime(job.PreferedEndTime, Session["TimeZoneID"].ToString()) : job.PreferedEndTime.ToString() : ""; js.PreferredEndTime = !string.IsNullOrEmpty(js.PreferredEndTime) ? _IUserRepository.GetLocalDateTime(job.PreferedEndTime, Session["TimeZoneID"].ToString()) : ""; js.PreferredEndTime = !string.IsNullOrEmpty(js.PreferredEndTime) ? Convert.ToDateTime(js.PreferredEndTime).ToString("MM/dd/yy HH:mm") : ""; js.ActualStartTime = job.ActualStartTime != null ? Session["TimeZoneID"] != null ? _IUserRepository.GetLocalDateTime(job.ActualStartTime, Session["TimeZoneID"].ToString()) : job.ActualStartTime.ToString() : ""; js.ActualStartTime = !string.IsNullOrEmpty(js.ActualStartTime) ? _IUserRepository.GetLocalDateTime(job.ActualStartTime, Session["TimeZoneID"].ToString()) : ""; js.ActualStartTime = !string.IsNullOrEmpty(js.ActualStartTime) ? Convert.ToDateTime(js.ActualStartTime).ToString("MM/dd/yy HH:mm") : ""; js.ActualEndTime = job.PreferedEndTime != null ? Session["TimeZoneID"] != null ? _IUserRepository.GetLocalDateTime(job.ActualEndTime, Session["TimeZoneID"].ToString()) : job.ActualEndTime.ToString() : ""; js.ActualEndTime = !string.IsNullOrEmpty(js.ActualEndTime) ? _IUserRepository.GetLocalDateTime(job.ActualEndTime, Session["TimeZoneID"].ToString()) : ""; js.ActualEndTime = !string.IsNullOrEmpty(js.ActualEndTime) ? Convert.ToDateTime(js.ActualEndTime).ToString("MM/dd/yy HH:mm") : ""; js.LastModifiedDate = job.PreferedEndTime != null ? Session["TimeZoneID"] != null ? _IUserRepository.GetLocalDateTime(job.LastModifiedDate, Session["TimeZoneID"].ToString()) : job.LastModifiedDate.ToString() : ""; js.LastModifiedDate = !string.IsNullOrEmpty(js.LastModifiedDate) ? _IUserRepository.GetLocalDateTime(job.LastModifiedDate, Session["TimeZoneID"].ToString()) : ""; js.LastModifiedDate = !string.IsNullOrEmpty(js.LastModifiedDate) ? Convert.ToDateTime(js.LastModifiedDate).ToString("MM/dd/yy HH:mm") : ""; // ActualStartTime = job.ActualStartTime.ToString() != "" ? Convert.ToDateTime(job.ActualStartTime).ToString("yyyy/MM/dd HH:mm") : "",//, Session["TimeZoneID"].ToString() js.EstimatedStartTime = job.ActualStartTime != null ? Session["TimeZoneID"] != null ? _IUserRepository.GetLocalDateTime(job.ActualStartTime, Session["TimeZoneID"].ToString()) : job.ActualStartTime.ToString() : ""; js.EstimatedStartTime = !string.IsNullOrEmpty(js.EstimatedStartTime) ? _IUserRepository.GetLocalDateTime(job.ActualStartTime, Session["TimeZoneID"].ToString()) : ""; js.EstimatedStartTime = !string.IsNullOrEmpty(js.EstimatedStartTime) ? Convert.ToDateTime(js.EstimatedStartTime).ToString("MM/dd/yy HH:mm") : ""; //js.AssignedTo = _IGlobalUserRepository.GetGlobalUserByID(new Guid(job.AssignedUserGUID.ToString())) != null ? _IGlobalUserRepository.GetGlobalUserByID(new Guid(job.AssignedUserGUID.ToString())).UserName : ""; js.EstimatedDuration = Convert.ToDouble(job.EstimatedDuration); js.Status = _IJobRepository.GetStatusName(Convert.ToInt32(job.StatusCode)); // js.CustomerName = !string.IsNullOrEmpty(job.CustomerGUID.ToString()) ? GetCompanyName(new Guid(job.CustomerGUID.ToString())) : ""; js.CustomerName = job.CustomerGUID != null ? GetCompanyName(job.CustomerGUID) : GetCompanyNameByPO(job.PONumber); js.StoreID = !string.IsNullOrEmpty(job.CustomerGUID.ToString()) ? getStoreID(job.CustomerStopGUID.ToString()) : ""; js.PONumber = job.PONumber; js.statuscode = job.StatusCode != null ? Convert.ToInt32(job.StatusCode) : 0; js.RegionGUID = job.RegionGUID != null ? job.RegionGUID.ToString() : ""; js.TerritoryGUID = job.TerritoryGUID != null ? job.TerritoryGUID.ToString() : ""; js.SiteAddress = job.ServiceAddress; JobProgress pJobProgress = _IJobRepository.GetJobProgressMismatch(job.JobGUID, js.statuscode); bool mismatch; if (pJobProgress != null && bool.TryParse(pJobProgress.LocationMismatch.ToString(), out mismatch)) { js.locationmismatch = mismatch; } if (job.StatusCode >= 2 && job.AssignedUserGUID != null) { js.Email = GetEmails(new Guid(job.AssignedUserGUID.ToString()), pOrganizationUsersMap.OrganizationGUID); js.AssociateContactNumber = GetContactNumber(new Guid(job.AssignedUserGUID.ToString()), pOrganizationUsersMap.OrganizationGUID); GlobalUser _globaluser = _IGlobalUserRepository.GetGlobalUserByID(new Guid(job.AssignedUserGUID.ToString())); if (_globaluser != null) { js.AssociateName = _globaluser.UserName; js.AssignedTo = _globaluser.UserName; } else { js.AssignedTo = ""; js.AssociateName = ""; } } else { js.Email = ""; js.AssignedTo = ""; js.AssociateName = ""; js.AssociateContactNumber = ""; } if (job.CustomerStopGUID != null && job.CustomerStopGUID != Guid.Empty) { Market _Market = _IMarketRepository.GetMarketByID(new Guid(job.CustomerStopGUID.ToString())); if (_Market != null) { if (!string.IsNullOrEmpty(_Market.RMUserID)) { GlobalUser _globalUser = _IGlobalUserRepository.GetGlobalUserByUserID(_Market.RMUserID, Session["OrganizationGUID"].ToString()); if (_globalUser != null) { UserProfile _userprofile = _IUserProfileRepository.GetUserProfileByUserID(_globalUser.UserGUID, job.OrganizationGUID); if (_userprofile != null) { js.RegionalManager = _userprofile.FirstName + " " + _userprofile.LastName; } else { js.RegionalManager = ""; } } } else { js.RegionalManager = ""; } } else { js.RegionalManager = ""; // js.FieldManager = ""; } } else if (!string.IsNullOrEmpty(job.PONumber)) { POs _po = _IPORepository.GetPObyPoNumber(job.PONumber); if (_po != null) { Market _Market = _IMarketRepository.GetMarketByCustomerID(job.OrganizationGUID, _po.PlaceID, _po.MarketID); if (_Market != null) { if (!string.IsNullOrEmpty(_Market.RMUserID)) { GlobalUser _globalUser = _IGlobalUserRepository.GetGlobalUserByUserID(_Market.RMUserID, Session["OrganizationGUID"].ToString()); if (_globalUser != null) { UserProfile _userprofile = _IUserProfileRepository.GetUserProfileByUserID(_globalUser.UserGUID, pOrganizationUsersMap.OrganizationGUID); if (_userprofile != null) { js.RegionalManager = _userprofile.FirstName + " " + _userprofile.LastName; } else { js.RegionalManager = ""; } } } else { js.RegionalManager = ""; } } else { js.RegionalManager = ""; //js.FieldManager = ""; } } else { js.RegionalManager = ""; //js.FieldManager = ""; } } else { js.RegionalManager = ""; // js.FieldManager = ""; } if (job.ManagerUserGUID != null && job.ManagerUserGUID != Guid.Empty) { GlobalUser _globalUser = _IGlobalUserRepository.GetGlobalUserByID(new Guid(job.ManagerUserGUID.ToString())); if (_globalUser != null) { UserProfile _userprofile = _IUserProfileRepository.GetUserProfileByUserID(_globalUser.UserGUID, pOrganizationUsersMap.OrganizationGUID); if (_userprofile != null) { js.FieldManager = _userprofile.FirstName + " " + _userprofile.LastName; } else { js.FieldManager = ""; } } } else { js.FieldManager = ""; } jobStatus.JobStatusModel.Add(js); } } else { ViewBag.TotalRows = 0; } if (!string.IsNullOrEmpty(assigneduserguid) && !string.IsNullOrEmpty(jobindexguid)) { GlobalUser _GlobalUser = _IGlobalUserRepository.GetGlobalUserByID(new Guid(assigneduserguid)); jobStatus.GlobalUsers = new List<GlobalUserModel>(); if (_GlobalUser != null) { jobStatus.GlobalUsers.Add(new GlobalUserModel { UserGUID = _GlobalUser.UserGUID, UserName = _GlobalUser.UserName }); } if (!string.IsNullOrEmpty(jobindexguid)) { jobStatus.JobModel = new JobModel(); jobStatus.JobModel.JobName = _IJobRepository.GetJobByID(new Guid(jobindexguid)).JobName; jobStatus.JobModel.JobIndexGUID = new Guid(jobindexguid); } } } if (jobStatus.JobStatusModel != null && jobStatus.JobStatusModel.Count > 0) { if (Session["JobStatusModel"] != null) { Session["JobStatusModel"] = null; Session["JobStatusModel"] = jobStatus.JobStatusModel.ToList(); } else { Session["JobStatusModel"] = jobStatus.JobStatusModel.ToList(); } } else { Session["JobStatusModel"] = null; } if (!string.IsNullOrEmpty(RowCount)) ViewBag.pageCountValue = int.Parse(RowCount); else ViewBag.pageCountValue = 5; return View(jobStatus); } else { return RedirectToAction("SessionTimeOut", "User"); } } catch (Exception ex) { Logger.Error(ex.Message); return RedirectToAction("Login", "User"); } }
public ActionResult FiltersPartial(int? param) { List<AllOptionsModel> readyList = new List<AllOptionsModel>(); AllOptionsModel readyModel = new AllOptionsModel(); List<string> list = new List<string>(); var producers = from x in db.ProdutcsToCategories where x.CatId == param select x.Product.Producer; foreach (var producer in producers) { if (producer != null) { if (!list.Contains(producer)) list.Add(producer); } } readyModel.listString = list.ToList(); var option = from x in db.Options where x.categoryId == param select x; List<OptionModel> om = new List<OptionModel>(); foreach (var opt in option) { OptionModel model = new OptionModel(); model.option = opt; var option2 = from x in db.OptionValues where x.ValueId == opt.ValuesId select x; List<OptionValue> ovl = new List<OptionValue>(); foreach (var optionValue in option2) { if (optionValue != null) { //model.optionValueList.Add(optionValue); ovl.Add(optionValue); } } model.optionValueList = ovl; om.Add(model); //readyModel.optionList.Add(model); } readyModel.optionList = om; readyList.Add(readyModel); return View("FiltersPartial", readyModel); }
public List<GoalFull> GetAllGoals(int? SelectedEmp, string YearEnding) { List<GoalFull> AllGoals = new List<GoalFull>(); if (SelectedEmp != null) { TempData["SelectedEmp"] = SelectedEmp; var emp = (from e in db.tblHOTP_Employees where e.EmployeeID == SelectedEmp select e).First(); var empGoals = from eg in db.tblHOTP_EmployeeGoals join g in db.tblHOTP_Goals on eg.GoalID equals g.GoalID into goal from subGoal in goal.DefaultIfEmpty() join c in db.tblHOTP_Codes on subGoal.Pillar equals c.Code into code from subCode in code.DefaultIfEmpty() where eg.EmployeeID == SelectedEmp && subGoal.YearEnding == YearEnding orderby subCode.Sequence, subGoal.PillarGoalName select eg; foreach (tblHOTP_EmployeeGoals eg in empGoals.ToList()) { PopulatePlan(eg.EmployeeGoalID); } foreach (tblHOTP_EmployeeGoals eg in empGoals) { List<Plan90Full> gPlans = new List<Plan90Full>(); var goalPlans = from plan in db.tblHOTP_Plan90 where plan.EmployeeGoalID == eg.EmployeeGoalID select plan; foreach (tblHOTP_Plan90 plan in goalPlans) { gPlans.Add(new Plan90Full() { Plan = plan, ActionSteps = db.tblHOTP_ActionSteps.Where(a => a.PlanID == plan.PlanID).ToList() }); } AllGoals.Add(new GoalFull() { EmployeeName = emp.FirstName + " " + emp.LastName, Goal = db.tblHOTP_Goals.Find(eg.GoalID), EmployeeGoal = eg, Plans = gPlans }); } } return AllGoals.ToList(); }