예제 #1
0
        private bool IsCurrentUserReviewer(List<Model.DTO.Appraisal.Reviewer> reviewers)
        {
            bool boo_is_reviewer = false;

            if (!Lib.Utility.Common.IsNullOrEmptyList(reviewers))
            {
                var var_approvers = reviewers.Where(rec => rec.EmployeeId == CurrentUser.Id);

                if (!Lib.Utility.Common.IsNullOrEmptyList(var_approvers))
                {
                    boo_is_reviewer = true;
                }
            }
            return boo_is_reviewer;
        }
        //
        // 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");
            }
        }
예제 #3
0
        public JsonResult SaveProfile(string reviewers, int apprid)
        {
            string message = string.Empty;
            List<Model.DTO.Appraisal.Reviewer> lst_reviewers = null;
            Model.DTO.Appraisal.Appraisal obj_appraisal = Model.PMSModel.GetAppraisalById(apprid);
            if (!string.IsNullOrEmpty(reviewers))
            {
                string[] reviewarray = reviewers.Split('|');

                if (!Lib.Utility.Common.IsNullOrEmptyList(reviewarray))
                {
                    List<string> lst_temp = new List<string>();
                    lst_reviewers = new List<Model.DTO.Appraisal.Reviewer>();
                    foreach(string str_reviewer in reviewarray)
                    {
                        if (Lib.Utility.Common.IsNullOrEmptyList(lst_temp.Where(rec=>rec.Equals(str_reviewer))))
                        {
                            lst_temp.Add(str_reviewer);
                        }
                    }

                    foreach (string str_reviewer_id in lst_temp)
                    {

                        // 1. add GetEmployeeById in model
                        // 2. add MapEmployeeDTOToReviewerDTO in pmsmapper

                        Model.DTO.Appraisal.Reviewer obj_reviewer = Model.Mappers.PMSMapper.MapEmployeeDTOToReviewerDTO(Model.PMSModel.GetEmployeeById(Convert.ToInt32(str_reviewer_id)));
                        obj_reviewer.Appraisal = new Model.DTO.Appraisal.Appraisal() { Id = apprid };
                        obj_reviewer.SMT = false;

                        lst_reviewers.Add(obj_reviewer);
                    }
                }
            }
            if (!Business.AppraisalManager.ManageChangeReviewerMember(obj_appraisal, lst_reviewers, out message))
            {
                return Json(message);
            }

            return Json(message);
        }
        public ActionResult editFootnoteMaps(Int16 fiscalYear, Int16? indicatorID)
        {
            List<Indicator_Footnote_Maps> footnoteMaps = new List<Indicator_Footnote_Maps>();
            foreach (var footnote in db.Indicator_Footnote_Maps.Where(x => x.Fiscal_Year == fiscalYear).OrderBy(e => e.Map_ID).ToList())
            {
                footnoteMaps.Add(footnote);
            }

            var allIndicator = new List<Indicators>();
            if (indicatorID.HasValue)
            {
                allIndicator = db.Indicators.Where(x => x.Indicator_ID == indicatorID).OrderBy(x => x.Indicator_ID).ToList();
            }
            else
            {
                allIndicator = db.Indicators.OrderBy(x => x.Indicator_ID).ToList();
            }

            var viewModel = allIndicator.Select(x => new Indicator_Footnote_MapsViewModel
            {
                Indicator_ID = x.Indicator_ID,
                Indicator = x.Indicator,
                Fiscal_Year = fiscalYear,
            }).ToList();

            viewModel.FirstOrDefault().allFootnotes = new List<string>();

            viewModel.FirstOrDefault().allFootnotes.AddRange(db.Footnotes.Select(x => x.Footnote_Symbol + ", " + x.Footnote).ToList());

            foreach (var Indicator in viewModel)
            {
                if (footnoteMaps.Count(e => e.Indicator_ID == Indicator.Indicator_ID) > 0)
                {
                    Indicator.Footnote_ID_1 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).First().Footnote_ID;
                    Indicator.Map_ID_1 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).First().Map_ID;
                    Indicator.Footnote_Symbol_1 = db.Footnotes.FirstOrDefault(e => e.Footnote_ID == Indicator.Footnote_ID_1).Footnote_Symbol;
                }
                if (footnoteMaps.Count(e => e.Indicator_ID == Indicator.Indicator_ID) > 1)
                {
                    Indicator.Footnote_ID_2 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(1).First().Footnote_ID;
                    Indicator.Map_ID_2 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(1).First().Map_ID;
                    Indicator.Footnote_Symbol_2 = db.Footnotes.FirstOrDefault(e => e.Footnote_ID == Indicator.Footnote_ID_2).Footnote_Symbol;
                }
                if (footnoteMaps.Count(e => e.Indicator_ID == Indicator.Indicator_ID) > 2)
                {
                    Indicator.Footnote_ID_3 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(2).First().Footnote_ID;
                    Indicator.Map_ID_3 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(2).First().Map_ID;
                    Indicator.Footnote_Symbol_3 = db.Footnotes.FirstOrDefault(e => e.Footnote_ID == Indicator.Footnote_ID_3).Footnote_Symbol;
                }
                if (footnoteMaps.Count(e => e.Indicator_ID == Indicator.Indicator_ID) > 3)
                {
                    Indicator.Footnote_ID_4 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(3).First().Footnote_ID;
                    Indicator.Map_ID_4 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(3).First().Map_ID;
                    Indicator.Footnote_Symbol_4 = db.Footnotes.FirstOrDefault(e => e.Footnote_ID == Indicator.Footnote_ID_4).Footnote_Symbol;
                }
                if (footnoteMaps.Count(e => e.Indicator_ID == Indicator.Indicator_ID) > 4)
                {
                    Indicator.Footnote_ID_5 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(4).First().Footnote_ID;
                    Indicator.Map_ID_5 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(4).First().Map_ID;
                    Indicator.Footnote_Symbol_5 = db.Footnotes.FirstOrDefault(e => e.Footnote_ID == Indicator.Footnote_ID_5).Footnote_Symbol;
                }
                if (footnoteMaps.Count(e => e.Indicator_ID == Indicator.Indicator_ID) > 5)
                {
                    Indicator.Footnote_ID_6 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(5).First().Footnote_ID;
                    Indicator.Map_ID_6 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(5).First().Map_ID;
                    Indicator.Footnote_Symbol_6 = db.Footnotes.FirstOrDefault(e => e.Footnote_ID == Indicator.Footnote_ID_6).Footnote_Symbol;
                }
                if (footnoteMaps.Count(e => e.Indicator_ID == Indicator.Indicator_ID) > 6)
                {
                    Indicator.Footnote_ID_7 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(6).First().Footnote_ID;
                    Indicator.Map_ID_7 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(6).First().Map_ID;
                    Indicator.Footnote_Symbol_7 = db.Footnotes.FirstOrDefault(e => e.Footnote_ID == Indicator.Footnote_ID_7).Footnote_Symbol;
                }
                if (footnoteMaps.Count(e => e.Indicator_ID == Indicator.Indicator_ID) > 7)
                {
                    Indicator.Footnote_ID_8 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(7).First().Footnote_ID;
                    Indicator.Map_ID_8 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(7).First().Map_ID;
                    Indicator.Footnote_Symbol_8 = db.Footnotes.FirstOrDefault(e => e.Footnote_ID == Indicator.Footnote_ID_8).Footnote_Symbol;
                }
                if (footnoteMaps.Count(e => e.Indicator_ID == Indicator.Indicator_ID) > 8)
                {
                    Indicator.Footnote_ID_9 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(8).First().Footnote_ID;
                    Indicator.Map_ID_9 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(8).First().Map_ID;
                    Indicator.Footnote_Symbol_9 = db.Footnotes.FirstOrDefault(e => e.Footnote_ID == Indicator.Footnote_ID_9).Footnote_Symbol;
                }
                if (footnoteMaps.Count(e => e.Indicator_ID == Indicator.Indicator_ID) > 9)
                {
                    Indicator.Footnote_ID_10 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(9).First().Footnote_ID;
                    Indicator.Map_ID_10 = footnoteMaps.Where(e => e.Indicator_ID == Indicator.Indicator_ID).OrderBy(e => e.Map_ID).Skip(9).First().Map_ID;
                    Indicator.Footnote_Symbol_10 = db.Footnotes.FirstOrDefault(e => e.Footnote_ID == Indicator.Footnote_ID_10).Footnote_Symbol;
                }
            }

            return View(viewModel);
        }
        private void TeamScoreBoard(List<MultiDogEntry> multiTeams, ShowClasses showClass, PdfPTable callingListTbl)
        {
            var teamsForClass = multiTeams.Where(t => t.ClassId == showClass.ID).OrderBy(t => t.RO);
            var teamCnt = 0;
            foreach (var team in teamsForClass)
            {
                var altColor = (teamCnt%2 == 0 ? Color.WHITE : Color.LIGHT_GRAY);
                callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk(team.RO.ToString(), _normal10Black)))
                {
                    BorderWidth = 0,
                    FixedHeight = 20f
                });

                if (TeamPairsManager.isTeam(showClass.EntryType))
                {
                    callingListTbl.AddCell(new PdfPCell(
                            new Phrase(new Chunk(team.TeamDetails.TeamName.Replace("&#39;", "'"), _normal10Black)))
                    {
                        Colspan = 2,
                        BackgroundColor = altColor,
                        BorderWidth = 0
                    });
                }
                else
                {
                    var dogCnt = 0;
                    var handlerPara = new Paragraph();
                    var dogPara = new Paragraph();
                    foreach (var member in team.Members)
                    {
                        if (dogCnt < team.DogCount)
                        {
                            if (dogCnt > 0)
                            {
                                handlerPara.Add(new Phrase(Chunk.NEWLINE));
                                dogPara.Add(new Phrase(Chunk.NEWLINE));
                            }

                            handlerPara.Add(new Phrase(new Chunk(Fpp.Core.Utils.TitleCaseString(member.HandlerName), _normal10Black)));
                            dogPara.Add(new Phrase(new Chunk(Fpp.Core.Utils.TitleCaseString(member.DogName), _normal10Black)));
                        }
                        dogCnt++;
                    }
                    callingListTbl.AddCell(new PdfPCell(handlerPara)
                    {
                        BackgroundColor = altColor,
                        BorderWidth = 0,
                        BorderWidthTop = 0
                    });
                    callingListTbl.AddCell(new PdfPCell(dogPara)
                    {
                        BackgroundColor = altColor,
                        BorderWidth = 0,
                        BorderWidthTop = 0
                    });
                }

                callingListTbl.AddCell(new PdfPCell(new Phrase(""))
                {
                    BorderWidth = 1,
                    BorderWidthRight = 0,
                    BorderWidthTop = (teamCnt > 0 ? 0 : 1)
                });

                callingListTbl.AddCell(new PdfPCell(new Phrase(""))
                {
                    BackgroundColor = Color.WHITE,
                    BorderWidth = 1,
                    BorderWidthRight = 0,
                    BorderWidthTop = (teamCnt > 0 ? 0 : 1)
                });

                callingListTbl.AddCell(new PdfPCell(new Phrase(""))
                {
                    BackgroundColor = Color.WHITE,
                    BorderWidth = 1,
                    BorderWidthRight = 1,
                    BorderWidthTop = (teamCnt > 0 ? 0 : 1)
                });

                teamCnt++;
            }
        }
        public ActionResult viewPR(Int16 fiscalYear, Int16? analystID, Int16? coeID)
        {
            var allMaps = new List<Indicator_CoE_Maps>();

            if (analystID.HasValue)
            {
                allMaps = db.Indicator_CoE_Maps.Where(x => x.Indicator.Analyst_ID == analystID).ToList();
            }
            else
            {
                allMaps = db.Indicator_CoE_Maps.ToList();
            }

            var allCoEs = new List<CoEs>();
            if (coeID.HasValue)
            {
                allCoEs = db.CoEs.Where(x => x.CoE_ID == coeID).ToList();
                allMaps = allMaps.Where(x => x.CoE.CoE_ID == coeID || x.CoE_ID == 0).ToList();
            }
            else
            {
                allCoEs = db.CoEs.Where(x=>x.CoE_ID != 0).ToList();
            }
            ModelState.Clear();

            var obj = allCoEs.FirstOrDefault();
            var type = obj.GetType();
            //var test = type.GetProperty(FiscalYear.FYStrFull("FY_", fiscalYear) + "Draft").GetValue(obj, null) == null;
            var isDraft = (bool)(type.GetProperty(FiscalYear.FYStrFull("FY_",fiscalYear) + "Draft").GetValue(obj,null) ?? false);

            var viewModel = new PRViewModel
            {
                //allCoEs = db.CoEs.ToList(),
                allAnalysts = db.Analysts.ToList(),
                allCoEs = allCoEs,
                allMaps = allMaps,
                allFootnoteMaps = db.Indicator_Footnote_Maps.ToList(),
                allFootnotes = db.Footnotes.ToList(),
                allAreas = db.Areas.ToList(),
                Fiscal_Year = fiscalYear,
                Analyst_ID = analystID,
                allColors = db.Color_Types.ToList(),
                allDirections = db.Color_Directions.ToList(),
                allThresholds = db.Color_Thresholds.ToList(),
                allFormats = db.Formats.ToList(),
                allIndicators = null,
                isDraft = isDraft
            };

            return View(viewModel);
        }
        public ActionResult viewPRdbl(Int16 fiscalYear, Int16? analystID, Int16 coeID, Int16 coeID2)
        {
            var allMaps = new List<Indicator_CoE_Maps>();

            if (analystID.HasValue)
            {
                allMaps = db.Indicator_CoE_Maps.Where(x => x.Indicator.Analyst_ID == analystID).ToList();
            }
            else
            {
                allMaps = db.Indicator_CoE_Maps.ToList();
            }

            var allCoEs = db.CoEs.Where(x => x.CoE_ID == coeID).ToList();
            allMaps = allMaps.Where(x => x.CoE.CoE_ID == coeID || x.CoE_ID == 0).ToList();

            ModelState.Clear();
            var viewModel = new PRViewModel
            {
                //allCoEs = db.CoEs.ToList(),
                allAnalysts = db.Analysts.ToList(),
                allCoEs = allCoEs,
                allMaps = allMaps,
                allIndicators = db.Indicators.ToList(),
                allFootnoteMaps = db.Indicator_Footnote_Maps.ToList(),
                allFootnotes = db.Footnotes.ToList(),
                allAreas = db.Areas.ToList(),
                Fiscal_Year = fiscalYear,
                Analyst_ID = analystID,
                allColors = db.Color_Types.ToList(),
                allDirections = db.Color_Directions.ToList(),
                allThresholds = db.Color_Thresholds.ToList(),
                allFormats = db.Formats.ToList(),

                coeID2= coeID2
            };

            return View(viewModel);
        }
예제 #8
0
        static void Main(string[] args)
        {
            WebRequest.DefaultWebProxy = null;
            string[] books;
            using (var client = new WebClient()) {
                books = client.DownloadString(@"http://ieeexplore.ieee.org/otherfiles/OPACBookListMIT.txt")
                                           .Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            }
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Ukupno knjiga: {0}", books.Count() - 1);

            var ebooksDirectory = Path.Combine((Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName)), "ebooks");
            if (!Directory.Exists(ebooksDirectory))
                Directory.CreateDirectory(ebooksDirectory);

            Directory.GetFiles(ebooksDirectory).Where(i => Regex.IsMatch(i, @"\d{13}-\d{1,3}.pdf")).ToList().ForEach(File.Delete);

            var alreadyDownloaded = new DirectoryInfo(ebooksDirectory).GetFiles().Length;
            var timeout = 5;
            foreach (var book in books.Skip(1 + alreadyDownloaded).Select((title, no) => new { no, title })) {
                string[] stopMessages = { "All Online Seats Are in Use", "All Online Seats Are Currently Occupied.",
                                          "URL Error (110)", "IEEE Xplore is Under Maintenance", "This document you requested has moved temporarily" };
                while (true) {
                    try {
                        using (var client = new WebClient()) {
                            if (stopMessages.Any(client.DownloadString(@"http://ieeexplore.ieee.org").Contains)) {
                                Console.ForegroundColor = ConsoleColor.Blue;
                                Console.WriteLine("  Previse korisnika je spojeno na web server - pauziram {0} sekundi...", timeout);
                                Thread.Sleep(timeout * 1000);
                            }
                            else {
                                break;
                            }
                        }
                    }
                    catch { }
                }
                Console.ForegroundColor = ConsoleColor.Green;

                var isbn = book.title.Split(new string[] { "\",\"" }, StringSplitOptions.None)[1];
                var book_url = book.title.Split(',')[book.title.Split(',').Length - 2].TrimEnd('"');
                var book_number = book_url.Split('=')[1];
                var book_name = new string(new string(book.title.Split(new string[] { "\",\"" }, StringSplitOptions.None)[0].Skip(1).ToArray())
                                           .Replace("\"", "'").Replace(":", "-").Trim().TrimEnd('-')
                                           .Where(ch => !Path.GetInvalidFileNameChars().Contains(ch)).ToArray());

                Console.Write("* Ekstrahiram poglavlja trenutne knjige..");
                IEnumerable<string> chapters;
                using (var client = new WebClient()) {
                    var r = new Regex(String.Format("{0}(.*?){1}", Regex.Escape(@"/xpl/ebooks/bookPdfWithBanner.jsp?fileName="), Regex.Escape(".pdf")));
                    chapters = from Match match in r.Matches(client.DownloadString(book_url))
                               select String.Format("http://ieeexplore.ieee.org/ebooks/{0}/{1}.pdf?bkn={0}", book_number, match.Groups[1].Value);
                }

                Console.Write("\r{0}\r", new string(' ', Console.WindowWidth));
                Console.WriteLine("#{0}, ISBN={1}, poglavlja={2}, naziv={3}", alreadyDownloaded + book.no + 1, isbn, chapters.Count(), book_name);

                var fileList = new List<string>();
                var ok = true;
                for (int j = 0; j < chapters.Count(); ++j) {
                    var chapter_url = chapters.ToArray()[j];
                    Console.WriteLine(" --> Skidam poglavlje #{0}/{1} ({2} KB)", j + 1, chapters.Count(), GetUrlFileSize(chapter_url));
                    var currentFile = String.Format("{0}\\{1}-{2}.pdf", ebooksDirectory, isbn, j);
                    fileList.Add(currentFile);
                    try {
                        using (var client = new WebClientWithCookies()) {
                            client.DownloadFile(chapter_url, currentFile);
                        }
                    }
                    catch { }

                    while (!File.Exists(currentFile) || stopMessages.Any(File.ReadAllText(currentFile).Contains)) {
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine("  Previse korisnika je spojeno na web server - pauziram {0} sekundi...", timeout);
                        Thread.Sleep(timeout * 1000);
                        try {
                            using (var client = new WebClientWithCookies()) {
                                client.DownloadFile(chapter_url, currentFile);
                            }
                        }
                        catch { }
                    }
                    Console.ForegroundColor = ConsoleColor.Green;

                    if (new FileInfo(currentFile).Length < 100 * 1024 && File.ReadAllText(currentFile).Contains("Page Not Found")) {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("\tGreska prilikom dohvata datoteke - provjeri prava pristupa!");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("\tPrelazim na sljedecu knjigu...");
                        ok = false;
                        break;
                    }
                }
                if (ok)
                    MergePDFs(fileList, String.Format("{0}\\{1}.pdf", ebooksDirectory, book_name));
                fileList.Where(file => File.Exists(file)).ToList().ForEach(File.Delete);
            }
        }
        public ActionResult editInventory(String indicatorID, Int16? analystID, int fiscalYear, Int16? Link_ID)
        {
            //}
            //var viewModelItems = db.Indicators.Where(x => x.Area_ID.Equals(1)).Where(y => y.Indicator_CoE_Map.Any(x => x.CoE_ID.Equals(10) || x.CoE_ID.Equals(27) || x.CoE_ID.Equals(30) || x.CoE_ID.Equals(40) || x.CoE_ID.Equals(50))).ToArray();
            var allLinks = db.Indicator_Links.ToList();
            var viewModelItems = new List<Indicators>();
            if (analystID.HasValue && analystID.Value > 0)
            {
                //viewModelItems = db.Indicators.Where(x => x.Analyst_ID == analystID).ToList();
                var analystName = db.Analysts.FirstOrDefault(x=>x.Analyst_ID == analystID).First_Name;
                viewModelItems = db.Indicators.Where(x =>
                    x.FY_13_14_Data_Source_Benchmark.Contains(analystName) ||
                    x.FY_13_14_Data_Source_MSH.Contains(analystName) ||
                    x.FY_14_15_Data_Source_Benchmark.Contains(analystName) ||
                    x.FY_14_15_Data_Source_MSH.Contains(analystName)
                    ).ToList();
            }
            else
            {
                viewModelItems = db.Indicators.ToList();
            }
            if (indicatorID != null)
            {
                viewModelItems = viewModelItems.Where(x => x.Indicator_ID == Int16.Parse(indicatorID)).ToList();
            }
            if (Link_ID.HasValue && Link_ID > 0)
            {
                viewModelItems = db.Indicator_Links.FirstOrDefault(x => x.Link_ID == Link_ID).Indicator_Link_Indicators.Select(x => x.Indicator).ToList();
            }
            var allFootnotes = db.Indicator_Footnote_Maps.ToList();

            var viewModel = viewModelItems.Where(x=>x.Indicator_N_Value != true).OrderBy(x => x.Indicator_ID).Select(x => new InventoryViewModel
            {
                Indicator_ID = x.Indicator_ID,
                Area_ID = x.Area_ID,
                CoE = x.Indicator_CoE_Map != null ?
                        (x.Indicator_CoE_Map.Where(y => y.Fiscal_Year == fiscalYear).FirstOrDefault() != null ? x.Indicator_CoE_Map.Where(y => y.Fiscal_Year == fiscalYear).FirstOrDefault().CoE.CoE : "")
                      : "",
                Indicator = x.Indicator,
                Indicator_Type = x.Indicator_Type,
                Identifier = x.Identifier,
                Area = x.Area.Area,
                //Footnote = string.Join(",", allFootnotes.Where(y=>y.Indicator.Indicator_ID == x.Indicator_ID).ToList()),
                Footnote = string.Join(",", x.Indicator_Footnote_Map.Select(z=>z.Footnote.Footnote_Symbol).ToList()),
                FY_3 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 3) + "_YTD").GetValue(x, null),
                FY_3_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 3) + "_YTD_Sup").GetValue(x, null),
                FY_2 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 2) + "_YTD").GetValue(x, null),
                FY_2_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 2) + "_YTD_Sup").GetValue(x, null),
                FY_1 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 1) + "_YTD").GetValue(x, null),
                FY_1_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 1) + "_YTD_Sup").GetValue(x, null),
                FY_Q1 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q1").GetValue(x, null),
                FY_Q1_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q1_Sup").GetValue(x, null),
                FY_Q2 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q2").GetValue(x, null),
                FY_Q2_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q2_Sup").GetValue(x, null),
                FY_Q3 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q3").GetValue(x, null),
                FY_Q3_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q3_Sup").GetValue(x, null),
                FY_Q4 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q4").GetValue(x, null),
                FY_Q4_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q4_Sup").GetValue(x, null),
                FY_YTD = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_YTD").GetValue(x, null),
                FY_YTD_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_YTD_Sup").GetValue(x, null),
                FY_Target = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Target").GetValue(x, null),
                FY_Target_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Target_Sup").GetValue(x, null),
                FY_Comparator = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator").GetValue(x, null),
                FY_Comparator_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Sup").GetValue(x, null),
                FY_Comparator_Q1 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Q1").GetValue(x, null),
                FY_Comparator_Q2 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Q2").GetValue(x, null),
                FY_Comparator_Q3 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Q3").GetValue(x, null),
                FY_Comparator_Q4 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Q4").GetValue(x, null),
                FY_Performance_Threshold = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Performance_Threshold").GetValue(x, null),
                FY_Performance_Threshold_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Performance_Threshold_Sup").GetValue(x, null),

                FY_Color_ID = (Int16)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Color_ID").GetValue(x, null),
                FY_YTD_Custom_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_YTD_Custom_Color").GetValue(x, null),
                FY_Q1_Custom_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q1_Custom_Color").GetValue(x, null),
                FY_Q2_Custom_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q2_Custom_Color").GetValue(x, null),
                FY_Q3_Custom_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q3_Custom_Color").GetValue(x, null),
                FY_Q4_Custom_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q4_Custom_Color").GetValue(x, null),

                FY_Definition_Calculation = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Definition_Calculation").GetValue(x, null),
                FY_Target_Rationale = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Target_Rationale").GetValue(x, null),
                FY_Comparator_Source = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Source").GetValue(x, null),

                FY_Data_Source_MSH = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Data_Source_MSH").GetValue(x, null),
                FY_Data_Source_Benchmark = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Data_Source_Benchmark").GetValue(x, null),
                FY_OPEO_Lead = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_OPEO_Lead").GetValue(x, null),

                FY_Q1_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q1_Color").GetValue(x, null),
                FY_Q2_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q2_Color").GetValue(x, null),
                FY_Q3_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q3_Color").GetValue(x, null),
                FY_Q4_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q4_Color").GetValue(x, null),
                FY_YTD_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_YTD_Color").GetValue(x, null),

                FY_Comment = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comment").GetValue(x, null),

                Format_Code = x.Format == null ? "" : (string)x.Format.GetType().GetProperty("Format_Code").GetValue(x.Format, null),
                N_Value = x.Indicator_N_Value.HasValue ? x.Indicator_N_Value.Value : false,
                N_Value_ID = x.Indicator_N_Value_ID == null ? "" : x.Indicator_N_Value_ID.ToString(),

                Fiscal_Year = fiscalYear,
                Analyst_ID = analystID.HasValue ? analystID.Value : 0,
                Link_ID = Link_ID.HasValue ? Link_ID.Value : 0

            }).ToList();

            for (var link_counter = 2; link_counter <= db.CoEs.Count(); link_counter++)
            {
                viewModel.AddRange(viewModelItems.Where(x => x.Indicator_CoE_Map.Where(y => y.Fiscal_Year == fiscalYear).Count() == link_counter).OrderBy(x => x.Indicator_ID).Select(x => new InventoryViewModel
                {
                    Indicator_ID = x.Indicator_ID,
                    Area_ID = x.Area_ID,
                    CoE = x.Indicator_CoE_Map != null ?
                            (x.Indicator_CoE_Map.Where(y => y.Fiscal_Year == fiscalYear).Skip(link_counter - 1).FirstOrDefault() != null ? x.Indicator_CoE_Map.Where(y => y.Fiscal_Year == fiscalYear).Skip(link_counter - 1).FirstOrDefault().CoE.CoE : "")
                          : "",
                    Indicator = x.Indicator,
                    Indicator_Type = x.Indicator_Type,
                    Identifier = x.Identifier,
                    Area = x.Area.Area,
                    //Footnote = string.Join(",", allFootnotes.Where(y=>y.Indicator.Indicator_ID == x.Indicator_ID).ToList()),
                    Footnote = string.Join(",", x.Indicator_Footnote_Map.Select(z => z.Footnote.Footnote_Symbol).ToList()),
                    FY_3 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 3) + "_YTD").GetValue(x, null),
                    FY_3_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 3) + "_YTD_Sup").GetValue(x, null),
                    FY_2 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 2) + "_YTD").GetValue(x, null),
                    FY_2_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 2) + "_YTD_Sup").GetValue(x, null),
                    FY_1 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 1) + "_YTD").GetValue(x, null),
                    FY_1_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 1) + "_YTD_Sup").GetValue(x, null),
                    FY_Q1 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q1").GetValue(x, null),
                    FY_Q1_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q1_Sup").GetValue(x, null),
                    FY_Q2 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q2").GetValue(x, null),
                    FY_Q2_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q2_Sup").GetValue(x, null),
                    FY_Q3 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q3").GetValue(x, null),
                    FY_Q3_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q3_Sup").GetValue(x, null),
                    FY_Q4 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q4").GetValue(x, null),
                    FY_Q4_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q4_Sup").GetValue(x, null),
                    FY_YTD = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_YTD").GetValue(x, null),
                    FY_YTD_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_YTD_Sup").GetValue(x, null),
                    FY_Target = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Target").GetValue(x, null),
                    FY_Target_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Target_Sup").GetValue(x, null),
                    FY_Comparator = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator").GetValue(x, null),
                    FY_Comparator_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Sup").GetValue(x, null),
                    FY_Comparator_Q1 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Q1").GetValue(x, null),
                    FY_Comparator_Q2 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Q2").GetValue(x, null),
                    FY_Comparator_Q3 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Q3").GetValue(x, null),
                    FY_Comparator_Q4 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Q4").GetValue(x, null),
                    FY_Performance_Threshold = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Performance_Threshold").GetValue(x, null),
                    FY_Performance_Threshold_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Performance_Threshold_Sup").GetValue(x, null),

                    FY_Color_ID = (Int16)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Color_ID").GetValue(x, null),
                    FY_YTD_Custom_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_YTD_Custom_Color").GetValue(x, null),
                    FY_Q1_Custom_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q1_Custom_Color").GetValue(x, null),
                    FY_Q2_Custom_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q2_Custom_Color").GetValue(x, null),
                    FY_Q3_Custom_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q3_Custom_Color").GetValue(x, null),
                    FY_Q4_Custom_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q4_Custom_Color").GetValue(x, null),

                    FY_Definition_Calculation = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Definition_Calculation").GetValue(x, null),
                    FY_Target_Rationale = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Target_Rationale").GetValue(x, null),
                    FY_Comparator_Source = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Source").GetValue(x, null),

                    FY_Data_Source_MSH = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Data_Source_MSH").GetValue(x, null),
                    FY_Data_Source_Benchmark = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Data_Source_Benchmark").GetValue(x, null),
                    FY_OPEO_Lead = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_OPEO_Lead").GetValue(x, null),

                    FY_Q1_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q1_Color").GetValue(x, null),
                    FY_Q2_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q2_Color").GetValue(x, null),
                    FY_Q3_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q3_Color").GetValue(x, null),
                    FY_Q4_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q4_Color").GetValue(x, null),
                    FY_YTD_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_YTD_Color").GetValue(x, null),

                    FY_Comment = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comment").GetValue(x, null),

                    Format_Code = x.Format == null ? "" : (string)x.Format.GetType().GetProperty("Format_Code").GetValue(x.Format, null),
                    N_Value = x.Indicator_N_Value.HasValue ? x.Indicator_N_Value.Value : false,
                    N_Value_ID = x.Indicator_N_Value_ID == null ? "" : x.Indicator_N_Value_ID.ToString(),

                    Fiscal_Year = fiscalYear,
                    Analyst_ID = analystID.HasValue ? analystID.Value : 0,
                    Link_ID = Link_ID.HasValue ? Link_ID.Value : 0

                }).ToList());
            }
            viewModel = viewModel.OrderBy(x=>x.Indicator_ID).ToList();

            ModelState.Clear();
            var viewModelNValues = db.Indicators.ToList().Where(x => x.Indicator_N_Value == true).OrderBy(x => x.Indicator_ID).Select(x => new InventoryViewModel
            {
                Indicator_ID = x.Indicator_ID,
                Area_ID = x.Area_ID,
                CoE = x.Indicator_CoE_Map != null ?
                        (x.Indicator_CoE_Map.Where(y => y.Fiscal_Year == fiscalYear).FirstOrDefault() != null ? x.Indicator_CoE_Map.Where(y => y.Fiscal_Year == fiscalYear).FirstOrDefault().CoE.CoE : "")
                      : "",
                Indicator = x.Indicator,
                Indicator_Type = x.Indicator_Type,
                Identifier = x.Identifier,
                Area = x.Area.Area,
                FY_3 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 3) + "_YTD").GetValue(x, null),
                FY_3_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 3) + "_YTD_Sup").GetValue(x, null),
                FY_2 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 2) + "_YTD").GetValue(x, null),
                FY_2_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 2) + "_YTD_Sup").GetValue(x, null),
                FY_1 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 1) + "_YTD").GetValue(x, null),
                FY_1_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 1) + "_YTD_Sup").GetValue(x, null),
                FY_Q1 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q1").GetValue(x, null),
                FY_Q1_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q1_Sup").GetValue(x, null),
                FY_Q2 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q2").GetValue(x, null),
                FY_Q2_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q2_Sup").GetValue(x, null),
                FY_Q3 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q3").GetValue(x, null),
                FY_Q3_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q3_Sup").GetValue(x, null),
                FY_Q4 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q4").GetValue(x, null),
                FY_Q4_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q4_Sup").GetValue(x, null),
                FY_YTD = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_YTD").GetValue(x, null),
                FY_YTD_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_YTD_Sup").GetValue(x, null),
                FY_Target = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Target").GetValue(x, null),
                FY_Target_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Target_Sup").GetValue(x, null),
                FY_Comparator = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator").GetValue(x, null),
                FY_Comparator_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Sup").GetValue(x, null),
                FY_Comparator_Q1 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Q1").GetValue(x, null),
                FY_Comparator_Q2 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Q2").GetValue(x, null),
                FY_Comparator_Q3 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Q3").GetValue(x, null),
                FY_Comparator_Q4 = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Q4").GetValue(x, null),
                FY_Performance_Threshold = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Performance_Threshold").GetValue(x, null),
                FY_Performance_Threshold_Sup = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Performance_Threshold_Sup").GetValue(x, null),

                FY_Color_ID = (Int16)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Color_ID").GetValue(x, null),
                FY_Threshold_ID = (Int16)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Threshold_ID").GetValue(x, null),
                FY_Direction_ID = (Int16)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Direction_ID").GetValue(x, null),
                FY_YTD_Custom_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_YTD_Custom_Color").GetValue(x, null),
                FY_Q1_Custom_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q1_Custom_Color").GetValue(x, null),
                FY_Q2_Custom_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q2_Custom_Color").GetValue(x, null),
                FY_Q3_Custom_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q3_Custom_Color").GetValue(x, null),
                FY_Q4_Custom_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q4_Custom_Color").GetValue(x, null),

                FY_Definition_Calculation = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Definition_Calculation").GetValue(x, null),
                FY_Target_Rationale = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Target_Rationale").GetValue(x, null),
                FY_Comparator_Source = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comparator_Source").GetValue(x, null),

                FY_Data_Source_MSH = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Data_Source_MSH").GetValue(x, null),
                FY_Data_Source_Benchmark = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Data_Source_Benchmark").GetValue(x, null),
                FY_OPEO_Lead = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_OPEO_Lead").GetValue(x, null),

                FY_Q1_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q1_Color").GetValue(x, null),
                FY_Q2_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q2_Color").GetValue(x, null),
                FY_Q3_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q3_Color").GetValue(x, null),
                FY_Q4_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Q4_Color").GetValue(x, null),
                FY_YTD_Color = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_YTD_Color").GetValue(x, null),

                FY_Comment = (string)x.GetType().GetProperty(FiscalYear.FYStr(fiscalYear, 0) + "_Comment").GetValue(x, null),

                Format_Code = x.Format == null ? "" : (string)x.Format.GetType().GetProperty("Format_Code").GetValue(x.Format, null),
                N_Value = x.Indicator_N_Value.HasValue ? x.Indicator_N_Value.Value : false,
                N_Value_ID = x.Indicator_N_Value_ID == null ? "" : x.Indicator_N_Value_ID.ToString(),

                Fiscal_Year = fiscalYear,
                Analyst_ID = analystID.HasValue ? analystID.Value : 0,
                Link_ID = Link_ID.HasValue ? Link_ID.Value : 0

            }).ToList();

            foreach (var nValue in viewModelNValues)
            {
                if (nValue.N_Value_ID != null)
                {
                    var indicatorIndex = viewModel.FirstOrDefault(x => x.Indicator_ID == Int16.Parse(nValue.N_Value_ID));
                    if (indicatorIndex != null)
                    {
                        var position = viewModel.IndexOf(indicatorIndex);
                        viewModel.Insert(position + 1, nValue);
                    }
                }
            }

            if (viewModel.Count == 0)
            {
                viewModel.Add(new InventoryViewModel());
            }
            viewModel.FirstOrDefault().allAnalysts = db.Analysts.ToList();
            viewModel.FirstOrDefault().allDirections = db.Color_Directions.ToList();
            viewModel.FirstOrDefault().allColors = db.Color_Types.ToList();
            viewModel.FirstOrDefault().allThresholds = db.Color_Thresholds.ToList();
            if (Request.IsAjaxRequest())
            {
                return Json(viewModel.Where(x => x.Indicator_ID.ToString().Contains(indicatorID == null ? "" : indicatorID)), JsonRequestBehavior.AllowGet);
            }
            else
            {
                return View(viewModel);
            }
        }
        //
        // 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");
            }
        }
예제 #11
0
        public ActionResult RetornaCredores(string credor)
        {
            var result = new List<KeyValuePair<string, string>>();
            IList<SelectListItem> List = new List<SelectListItem>();

            var lista = new Dados().RetornaDados("Select distinct PRC_CREDOR as NOMECREDOR from processos where PRC_CREDOR like '" + credor + "%' and PRC_CREDOR is not null order by PRC_CREDOR");
            foreach (System.Data.DataRow item in lista.Rows)
            {
                result.Add(new KeyValuePair<string, string>(item["NOMECREDOR"].ToString(), item["NOMECREDOR"].ToString()));
            }
            var result3 = result.Where(s => s.Value.ToLower().Contains(credor.ToLower())).Select(w => w).ToList();

            return Json(result3, JsonRequestBehavior.AllowGet);
        }
예제 #12
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            CleanDestination();

            _fileList = new List<string>();
            btnStart.Enabled = false;

            if (string.IsNullOrEmpty(txtExcelFile.Text) || string.IsNullOrEmpty(txtFirstPDF.Text) ||
                string.IsNullOrEmpty(txtSecondPDF.Text) || string.IsNullOrEmpty(txtDestinationFolder.Text))
            {
                MessageBox.Show("One or more files not specified.");
                return;
            }

            var pathToExcelFile = txtExcelFile.Text;
            var excelFile = new ExcelQueryFactory(pathToExcelFile);
            var columnValues = from a in excelFile.WorksheetNoHeader(0) select a;

            var listRows = new List<ExcelRow>();

            var setNumber = 1;
            var increment = 1;
            foreach (var a in columnValues)
            {
                listRows.Add(
                    new ExcelRow
                    {
                        Index = increment,
                        SetNumber = setNumber,
                        ColumnValue = a[1].Value.ToString(),
                        FileName = string.IsNullOrWhiteSpace(a[0].Value.ToString()) ? "" : a[0].Value.ToString()
                    }
                );

                if (!a[1].Value.ToString().EndsWith(","))
                    setNumber++;

                increment++;
            }

            for (var i = 1; i < increment - 1; i++)
            {
                var sbSearch = new StringBuilder();
                _searchValues.Clear();

                foreach (var item in from item in listRows.Where(item => item.SetNumber == i) let index = item.Index let text = item.ColumnValue select item)
                {
                    sbSearch.Append(item.ColumnValue);

                    _searchValues.Add(new KeyValuePair<int, string>(item.Index, item.ColumnValue));

                    if (!string.IsNullOrEmpty(item.FileName))
                    {
                        _currentFile = item.FileName;
                        _actualRow = item.SetNumber;
                    }
                }

                if (!string.IsNullOrEmpty(sbSearch.ToString()))
                    ProcessPdf(StringComparison.Ordinal, txtFirstPDF.Text, txtDestinationFolder.Text + "\\" + GetFileName(_currentFile, txtFirstPDF.Text) + ".pdf", sbSearch.ToString(), i, _searchValues);

                if (!string.IsNullOrEmpty(txtSecondPDF.Text) && !string.IsNullOrEmpty(sbSearch.ToString()))
                    ProcessPdf(StringComparison.Ordinal, txtSecondPDF.Text, txtDestinationFolder.Text + "\\" + GetFileName(_currentFile, txtSecondPDF.Text) + ".pdf", sbSearch.ToString(), i, _searchValues);

            }

            #region Update Excel...

            lblMsg.Visible = true;
            foreach (var item in _foundValuesInFirstPdf)
            {
                var myCommand = new OleDbCommand();
                string sqlUpdate = null;
                var count = item.Value.Split(',').Count();

                var cnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + txtExcelFile.Text + ";Extended Properties='Excel 8.0;HDR=NO;'";
                var myConnection = new OleDbConnection(cnn);
                myConnection.Open();
                myCommand.Connection = myConnection;
                sqlUpdate = "UPDATE [Sheet1$H" + item.Key + ":H" + item.Key + "] SET F1='" + item.Value + "'";
                myCommand.CommandText = sqlUpdate;
                myCommand.ExecuteNonQuery();

                sqlUpdate = "UPDATE [Sheet1$J" + item.Key + ":J" + item.Key + "] SET F1='" + count + "'";
                myCommand.CommandText = sqlUpdate;
                myCommand.ExecuteNonQuery();

                myConnection.Close();

            }

            foreach (var item in _foundValuesInSecindPdf)
            {
                var myCommand = new OleDbCommand();
                string sqlUpdate = null;
                var count = item.Value.Split(',').Count();

                var cnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + txtExcelFile.Text + ";Extended Properties='Excel 8.0;HDR=NO;'";
                var myConnection = new OleDbConnection(cnn);
                myConnection.Open();
                myCommand.Connection = myConnection;
                sqlUpdate = "UPDATE [Sheet1$I" + item.Key + ":I" + item.Key + "] SET F1='" + item.Value + "'";
                myCommand.CommandText = sqlUpdate;
                myCommand.ExecuteNonQuery();

                sqlUpdate = "UPDATE [Sheet1$K" + item.Key + ":K" + item.Key + "] SET F1='" + count + "'";
                myCommand.CommandText = sqlUpdate;
                myCommand.ExecuteNonQuery();

                myConnection.Close();

            }

            #endregion Update Excel...

            MessageBox.Show("Pdf highlighted successfully!");
            lblMsg.Visible = false;
            btnStart.Enabled = true;

            if (chkOpenPdfs.Checked)
            {

                if (_fileList.Count != 0)
                {
                    foreach (var file in _fileList)
                    {
                        System.Diagnostics.Process.Start(file);
                    }
                }
            }
        }
예제 #13
0
        public static Blob.Blob MergePdfBlobsToC(List<Blob.Blob> blobsParam, ref Dictionary<string, int> pages)
        {
            blobsParam = blobsParam
                .Where(el => el != null && el.Data != null)
                .ToList();

            //Dictionary of file names (for display purposes) and their page numbers
            //var pages = new Dictionary<string, int>();

            //PDFs start at page 1
            var lastPageNumber = 1;

            //Will hold the final merged PDF bytes
            byte[] mergedBytes;

            //Most everything else below is standard
            using (var ms = new MemoryStream())
            {
                using (var document = new Document())
                {
                    using (var writer = new PdfCopy(document, ms))
                    {
                        document.Open();

                        foreach (var blob in blobsParam)
                        {

                            //Add the current page at the previous page number
                            pages.Add(blob.Name, lastPageNumber);

                            using (var reader = new PdfReader(blob.Data))
                            {
                                writer.AddDocument(reader);

                                //Increment our current page index
                                lastPageNumber += reader.NumberOfPages;
                            }
                        }
                        document.Close();
                    }
                }
                mergedBytes = ms.ToArray();
            }

            //Will hold the final PDF
            //            byte[] finalBytes;
            //            using (var ms = new MemoryStream())
            //            {
            //                using (var reader = new PdfReader(mergedBytes))
            //                {
            //                    using (var stamper = new PdfStamper(reader, ms))
            //                    {
            //
            //                        //The page number to insert our TOC into
            //                        var tocPageNum = reader.NumberOfPages + 1;
            //
            //                        //Arbitrarily pick one page to use as the size of the PDF
            //                        //Additional logic could be added or this could just be set to something like PageSize.LETTER
            //                        var tocPageSize = reader.GetPageSize(1);
            //
            //                        //Arbitrary margin for the page
            //                        var tocMargin = 20;
            //
            //                        //Create our new page
            //                        stamper.InsertPage(tocPageNum, tocPageSize);
            //
            //                        //Create a ColumnText object so that we can use abstractions like Paragraph
            //                        var ct = new ColumnText(stamper.GetOverContent(tocPageNum));
            //
            //                        //Set the working area
            //                        ct.SetSimpleColumn(tocPageSize.GetLeft(tocMargin), tocPageSize.GetBottom(tocMargin),
            //                            tocPageSize.GetRight(tocMargin), tocPageSize.GetTop(tocMargin));
            //
            //                        //Loop through each page
            //                        foreach (var page in pages)
            //                        {
            //                            var link = new Chunk(page.Key);
            //                            var action = PdfAction.GotoLocalPage(page.Value, new PdfDestination(PdfDestination.FIT),
            //                                stamper.Writer);
            //                            link.SetAction(action);
            //                            ct.AddElement(new Paragraph(link));
            //                        }
            //
            //                        ct.Go();
            //                    }
            //                }
            //                finalBytes = ms.ToArray();
            //            }

            var toReturn = new Blob.Blob { Data = mergedBytes/*finalBytes*/ };
            return toReturn;
        }
예제 #14
0
        public static Blob.Blob MergePdfBlobs(List<Blob.Blob> blobsParam, bool isHorizontal)
        {
            var pdfReaders = blobsParam
                .Where(el => el != null && el.Data != null)
                .Select(el => new PdfReader(el.Data))
                .ToList();

            var document = isHorizontal
                ? new Document(PageSize.A4.Rotate(), 0, 0, 0, 0)
                : new Document(PageSize.A4, 0, 0, 0, 0);

            using (var outputStream = new MemoryStream())
            {
                using (var writer = PdfWriter.GetInstance(document, outputStream))
                {
                    document.Open();

                    foreach (var reader in pdfReaders)
                    {
                        for (int i = 1; i <= reader.NumberOfPages; i++)
                        {
                            var page = writer.GetImportedPage(reader, i);
                            document.Add(iTextSharp.text.Image.GetInstance(page));
                        }
                    }
                    document.Close();

                    var toReturn = new Blob.Blob {Data = outputStream.GetBuffer()};
                    return toReturn;
                }
            }
        }
        public JsonResult getKeyupSearch(string mysearch, int BuildingID, string aptNumber)
      {

            var Search = new List<TenantSearch>();

            if (mysearch != null || mysearch != "")
            {
                string FN = string.Empty;
                string LN = string.Empty;
                string[] m = mysearch.Split(null);//if the splitting char is null it is assume that the delimiter is a whie space
                var mymanagement = new managementVM();
                if (m.Length > 1)
                {
                    FN = m[0];
                    LN = m[1];

                    Search = db.Tenant
                   .Join(db.Apartment,
                           c => c.aptID,
                           a => a.ID,
                           (c, a) => new { c, a })
                           .Join(db.Buildings,
                           ca => ca.a.BuildingID,
                           b => b.ID,
                           (ca, b) => new TenantSearch
                           {
                               FirstName = ca.c.FirstName,
                               LastName = ca.c.LastName,
                               Apt = ca.a.ApartmentNumber,
                               Address = b.Address,
                               city = b.City,
                               State = b.State,
                               zipcode = b.Zipcode,
                               ApartmentID = ca.a.ID,
                               TenantID = ca.c.ID,
                               Userkey = ca.c.AspNetUsers.Id,
                               Phone = ca.c.Phone,
                               BuildingID = b.ID
                           })
                   .Where(c => c.FirstName.Contains(mysearch) ||
                               c.LastName.Contains(mysearch) ||
                               c.FirstName.Contains(FN) &&
                               c.LastName.Contains(LN)
                          ).Where(c => c.BuildingID == BuildingID)
                    .OrderByDescending(c => c.FirstName)
                   .Take(10)
                   .ToList();
                       if (aptNumber != "")
                    {
                        Search = Search.Where(c => c.Apt == aptNumber).ToList();
                   
                    }

                    return new JsonResult { Data = Search, JsonRequestBehavior = JsonRequestBehavior.AllowGet };

                }
                else
                {

                    Search = db.Tenant
                       .Join(db.Apartment,
                         c => c.aptID,
                         a => a.ID,
                         (c, a) => new { c, a })
                         .Join(db.Buildings,
                         ca => ca.a.BuildingID,
                         b => b.ID,
                         (ca, b) => new TenantSearch
                         {
                             FirstName = ca.c.FirstName,
                             LastName = ca.c.LastName,
                             Apt = ca.a.ApartmentNumber,
                             Address = b.Address,
                             city = b.City,
                             State = b.State,
                             zipcode = b.Zipcode,
                             ApartmentID = ca.a.ID,
                             TenantID = ca.c.ID,
                             Userkey = ca.c.AspNetUsers.Id,
                              Phone = ca.c.Phone,
                             BuildingID = b.ID
                         })
                   .Where(c => c.FirstName.Contains(mysearch) || c.LastName.Contains(mysearch))
                   .Where(c => c.BuildingID == BuildingID)
                   .OrderByDescending(c => c.FirstName)
                   .Take(10)
                   .ToList();
                    if (aptNumber != "")
                    {
                        Search = Search.Where(c => c.Apt == aptNumber).ToList();

                    }

                    return new JsonResult { Data = Search, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
                }

            }
            return new JsonResult { Data = Search, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
        }
        List<GridViewModel> GetInterpolationsList()
        {
            try
            {
                int customer = 0;
                int farm = 0;

                if (cbSearchCustomers.SelectedIndex >= 0)
                {
                    customer = Convert.ToInt32(cbSearchCustomers.SelectedValue);
                }

                if (cbFarm.SelectedIndex >= 0)
                {
                    farm = Convert.ToInt32(cbFarm.SelectedValue);
                }

                var result = new List<GridViewModel>();

                foreach (var item in _farmRepository.FilterFarms(customer, farm, dateTimePicker1.Value, dateTimePicker2.Value))
                {
                    if (item.Interpolations != null)
                    {
                        item.Interpolations.ToList().ForEach(c =>
                        {
                            result.Add(new GridViewModel
                            {
                                ID = c.CustomerInterpolationId,
                                FarmId = c.CustomerFarmId,
                                Farm = item.Name,
                                Customer = item.Customer != null ? item.Customer.Name : string.Empty,
                                Name = c.Name,
                                ProjectFile = c.ProjectFiles,
                                Date = c.Created,
                                isChecked = false
                            });
                        });
                    }
                }

                if (result.Count() > 0 && !string.IsNullOrEmpty(txtSearchInterpolationName.Text))
                {
                    result = result.Where(c => c.Name.Contains(txtSearchInterpolationName.Text)).ToList();
                }

                return result;
            }
            catch (Exception)
            {
                throw;
            }
        }