private RegionTotals GetData(string prjAccount, ProlianceController prj, ProlianceConnection conn) { RegionTotals rtrn = null; rtrn = HttpContext.Current.Cache.Get(prjAccount + "cacheKey") as RegionTotals; if (rtrn == null) { rtrn = new RegionTotals(); DataSet data = prj.GetPreProjectList(conn, prjAccount); if (data.Tables != null && data.Tables.Count > 0) { //rtrn.TotalRevenueCollected = 0; //int val = int.MinValue; //foreach (DataRow row in data.Tables[0].Rows) //{ // string textVal = row["SmallProjectDocument_ApproximateValueText"] as string; // if (!string.IsNullOrEmpty(textVal)) // { // textVal = textVal.Replace("$", string.Empty).Replace(",", string.Empty); // MatchCollection mc = Regex.Matches(textVal, "\\d+"); // if (mc.Count > 0) // { // if (int.TryParse(mc[0].Value, out val)) // rtrn.TotalRevenueCollected += val; // } // } //} string appVal = null; DataSet ds = prj.GetProjectApproxValues(conn, prjAccount); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { appVal = ds.Tables[0].Rows[0]["ProjectDocument_ProjectApproximateValueText"] as string; } if (!string.IsNullOrEmpty(appVal)) { appVal = appVal.Replace("$", string.Empty).Replace(",", string.Empty); MatchCollection mc = Regex.Matches(appVal, "\\d+"); if (mc.Count > 0) { int val = int.MinValue; if (int.TryParse(mc[0].Value, out val)) rtrn.TotalRevenueCollected = val; } } rtrn.ApproximateRevenueCollected = appVal; rtrn.TotalProjects = data.Tables[0].Rows.Count; rtrn.ProjectAccount = prjAccount; } HttpContext.Current.Cache.Add(prjAccount + "cacheKey", rtrn, null, DateTime.Now.AddMinutes(5), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, null); } return rtrn; }
private void FillData(string prjAccount, ProlianceController prj, ProlianceConnection conn, Literal revenue, Literal projects, string appVal) { RegionTotals tot = null; tot = HttpContext.Current.Cache.Get(prjAccount + "cacheKey") as RegionTotals; if (tot == null) { tot = new RegionTotals(); DataSet data = prj.GetPreProjectList(conn, prjAccount); if (data.Tables != null && data.Tables.Count > 0) { //tot.TotalRevenueCollected = 0; //int val = int.MinValue; //foreach (DataRow row in data.Tables[0].Rows) //{ // string textVal = row["SmallProjectDocument_ApproximateValueText"] as string; // if (!string.IsNullOrEmpty(textVal)) // { // textVal = textVal.Replace("$", string.Empty).Replace(",", string.Empty); // MatchCollection mc = Regex.Matches(textVal, "\\d+"); // if (mc.Count > 0) // { // if (int.TryParse(mc[0].Value, out val)) // tot.TotalRevenueCollected += val; // } // } //} if (!string.IsNullOrEmpty(appVal)) { appVal = appVal.Replace("$", string.Empty).Replace(",", string.Empty); MatchCollection mc = Regex.Matches(appVal, "\\d+"); if (mc.Count > 0) { int val = int.MinValue; if (int.TryParse(mc[0].Value, out val)) tot.TotalRevenueCollected = val; } } tot.ApproximateRevenueCollected = appVal; tot.TotalProjects = data.Tables[0].Rows.Count; tot.ProjectAccount = prjAccount; } HttpContext.Current.Cache.Add(prjAccount + "cacheKey", tot, null, DateTime.Now.AddMinutes(5), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, null); } projects.Text = tot.TotalProjects.ToString(); revenue.Text = tot.TotalRevenueCollected.ToString("C0"); }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { var b = Request.QueryString["id"]; if (b != null) ((TIA)(this.Master)).accordion_selectedIndexChanged(System.Convert.ToInt16(b)); ProlianceController prj = new ProlianceController(); ProlianceConnection conn = new ProlianceConnection("https://na2.agpmis.com", "na", "admin", "?aecom"); string prjAccount = "pgmprj://na/tia/rvly"; List<County> theCountites = prj.GetCounties(conn, prjAccount, "rvly").ToList(); foreach (County cty in theCountites) { ListItem li = new ListItem { Enabled = true, Text = cty.Description, Value = cty.FullCode }; this.DropDownListCounty.Items.Add(li); } List<Band> theBands = prj.GetBands(conn, prjAccount).ToList(); foreach (Band bnd in theBands) { ListItem li = new ListItem { Enabled = true, Text = bnd.Description, Value = bnd.FullCode }; this.DropDownListBand.Items.Add(li); } List<ProjectTypes> theProjectTypes = prj.GetProjectTypes(conn, prjAccount).ToList(); foreach (ProjectTypes pt in theProjectTypes) { ListItem li = new ListItem { Enabled = true, Text = pt.Description, Value = pt.FullCode }; this.DropDownListProjectType.Items.Add(li); } List<ProjectStatus> theProjectStatus = prj.GetProjectStatus(conn, prjAccount).ToList(); foreach (ProjectStatus st in theProjectStatus) { ListItem li = new ListItem { Enabled = true, Text = st.Description, Value = st.FullCode }; this.DropDownListProjectStatus.Items.Add(li); } //List<Status> theStatusTypes = prj.GetStatusTypes(conn, prjAccount).ToList(); //foreach (Status pt in theStatusTypes) //{ // ListItem li = new ListItem { Enabled = true, Text = pt.Description, Value = pt.FullCode }; // this.DropDownListActive.Items.Add(li); //} theData = prj.GetPreProjectList(conn, prjAccount); Cache["PrjData"] = theData; this.RepeaterProjectList.DataSource = theData; this.RepeaterProjectList.DataBind(); if (!(theData.Tables[0].Rows.Count > 0)) this.Label1.Visible = true; } }
private DataSet GetPrjCache() { ProlianceController prj = new ProlianceController(); ProlianceConnection conn = new ProlianceConnection("https://na2.agpmis.com", "na", "admin", "?aecom"); string prjAccount = "pgmprj://na/tia/rvly"; string cacheKey = "PRjData"; object cacheItem = Cache[cacheKey] as DataSet; if( (cacheItem == null)) { cacheItem = prj.GetPreProjectList(conn, prjAccount); } return (DataSet)cacheItem; }