Example #1
0
        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;
        }
Example #2
0
        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");
        }