Ejemplo n.º 1
0
        /// <summary>
        ///  Verify the Member is registered for given segment
        /// </summary>
        /// <returns></returns>
        public bool VerifyMemberIsAuthorized(string loyaltyCardNumber, List <int> segmentsList)
        {
            try
            {
                bool isMemberAuthorized = false;

                HouseHold objHousehold = objGetMemberDemographicsManager.GetDemographicData(loyaltyCardNumber).Result;

                MemberSegments memberSegments = objHousehold?.Members?.MemberMain.FirstOrDefault().MemberSegments;

                var houseHoldSegment = objHousehold?.HouseHoldSegments;

                foreach (int segmentId in segmentsList)
                {
                    if ((memberSegments != null && memberSegments.Segment.Any(x => x.Id == Convert.ToInt32(segmentId))) ||
                        (houseHoldSegment != null && houseHoldSegment.Segment.Count > 0 && houseHoldSegment.Segment.Any(x => x.Id == Convert.ToInt32(segmentId))))
                    {
                        isMemberAuthorized = true;
                        break;
                    }
                }

                return(isMemberAuthorized);
            }catch (Exception ex)
            {
                DBLogging.Error("Validate Register Promotion", ex);

                throw;
            }
        }
Ejemplo n.º 2
0
        public harvestData()
        {
            //List<Sites> siteList = db.getSiteList();
            List <sitedata> siteList = db.getSiteList();
            int             count    = 1;

            db.updateSeriesCatalag();
            //foreach (Sites site in siteList)
            foreach (sitedata site in siteList)
            {
                DBLogging.WriteLog(projectName, "Log", "harvestData" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("Requesting data for Site:{1}, {0}. {2}/{3}", site.SiteName, site.SiteCode, count, siteList.Count));
                //string data = requestData("ACW00011604");
                try
                {
                    string    data  = requestData(site.SiteCode);
                    DataTable table = createTable(data);
                    getNeededData(table, site);
                    count++;
                }
                catch (Exception ex)
                {
                    DBLogging.WriteLog(projectName, "Error", "harvestData" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("Error on Site:{1}, {0}. {2}", site.SiteName, site.SiteCode, ex.Message));
                }
            }
            DBLogging.WriteLog(projectName, "Log", "harvestData" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Done requesting data from NCDC ftp site");

            DBLogging.WriteLog(projectName, "Log", "harvestData" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Building Series Catalog");
            db.updateSeriesCatalag();
        }
Ejemplo n.º 3
0
        //private void getNeededData(DataTable table, Sites site)
        private void getNeededData(DataTable table, sitedata site)
        {//get a list of all the variables in the table
            var x = (from r in table.AsEnumerable()
                     select r["Element"]).Distinct().ToList();

            //loop through all of the variables
            foreach (var variable in x)
            {
                if (variable.ToString() == "PRCP")
                {
                    Variables vari     = db.getVariableID(variable.ToString());
                    int       seriesID = db.getSeriesID(site.SiteID, vari.VariableID);
                    DateTime  startdate;
                    if (seriesID >= 0)
                    {
                        //get the end date for the current variable
                        startdate = db.getSeriesLastDate(seriesID);
                    }
                    else
                    {
                        //if series is not in table set start date
                        startdate = new DateTime(1900, 01, 01);
                    }
                    if (Math.Abs(startdate.Subtract(DateTime.Today).Days) > 3)
                    {
                        string    expression   = "Date > '" + startdate.ToString() + "' AND Date <= '" + DateTime.Today.Add(new TimeSpan(-1, 0, 0, 0)).ToString() + "' AND Element = '" + variable + "'";
                        DataRow[] selectedrows = table.Select(expression);
                        int       rows         = db.saveDataValues(selectedrows, vari, site);
                        DBLogging.WriteLog(projectName, "Log", "harvestData" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{0} rows saved. Date > {1}, Site:{2}, Variable:{3} ", rows, startdate, site.SiteCode, variable.ToString()));
                    }
                }
            }
        }
Ejemplo n.º 4
0
 //insert site
 public void insertSite(string siteCode, string siteName, double latitude, double longitude, int latLongDatumID, double Elevation_m, string VerticulDatum, string LocalX, string LocalY, string LocalProjectionID, string PosAccuracy_m, string State, string County, string Comments, double TimeZone, string Status)
 {
     if (siteCode != null)
     {
         try
         {
             Sites s = new Sites();
             s.SiteCode          = siteCode.Trim();
             s.SiteName          = siteName.Trim();
             s.Latitude          = latitude;
             s.Longitude         = longitude;
             s.LatLongDatumID    = latLongDatumID;
             s.Elevation_m       = Elevation_m;
             s.VerticalDatum     = null;
             s.LocalX            = null;
             s.LocalY            = null;
             s.LocalProjectionID = null;
             s.PosAccuracy_m     = null;
             s.State             = State;
             s.County            = County;
             s.Comments          = null;
             s.TimeZone          = Convert.ToInt32(TimeZone);
             s.Status            = Status;
             this.AddToSites(s);
             this.SaveChanges();
         }
         catch (Exception e)
         {
             DBLogging.WriteLog(Properties.Settings.Default.projectName, "Error", "clsDatabase" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name, e.Message + "()" + " \nstate: " + State + ", siteName: " + siteName);
         }
     }
 }
Ejemplo n.º 5
0
 public FillUSBR()
 {
     DBLogging.WriteLog(projectName, "Log", "FillUSBR" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "USBRHarvester Has Begun Running");
     fillDatabase();
     DBLogging.WriteLog(projectName, "Log", "FillUSBR" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "USBRHarvester Has Completed Running");
     Thread.Sleep(30);
     SendEmail.SendMessage("USBR Reservoir Harvester Completed", "USBR Reservoir Harvester has completed running, view the attached file for details", projectName, new TimeSpan(12, 0, 0));
 }
Ejemplo n.º 6
0
        private void fillMeta()
        {
            //getStates
            clsSnoTelStateList l = new clsSnoTelStateList("http://www.wcc.nrcs.usda.gov/snow/sntllist.html");

            DBLogging.WriteLog(projectName, "Log", "UpdateDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("Updating Sites Table using Method 1: {0} states found.", l.stateList.Count));

            //getSites
            for (int i = 0; i < l.stateList.Count; i++)
            {
                clsSnoTelStateTable h = new clsSnoTelStateTable(l.stateList[i].URL);

                //Console.WriteLine(l.stateList[i].state);
                foreach (SnoTelRecord sr in h.Records)
                {
                    //Console.WriteLine("\t" + sr.SiteName);
                    char[] splitters = { '\r', '\n' };
                    string siteCode  = sr.SiteIds.Split(splitters)[0];

                    if (siteCode != "")
                    {
                        double lat = format.ConvertLatLong(sr.Latitude);
                        double lng = format.ConvertLatLong(sr.Longitude);
                        if (db.isNewSite(siteCode))
                        {
                            DBLogging.WriteLog(projectName, "Log", "UpdateDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "inserting site: " + sr.SiteName);

                            db.insertSite(siteCode, sr.SiteName, lat, lng, 0, format.feetToMeters(Convert.ToDouble(sr.Elevation.Split('\'')[0])), null, null, null, null, null, l.stateList[i].state, sr.County, null, format.getTimeZone(lat, lng), sr.Status);
                        }
                        else
                        {
                            db.updateSite(db.getSiteID(siteCode), siteCode, sr.SiteName, l.stateList[i].state, lat, lng, /*format.getTimeZone(lat, lng),*/ format.feetToMeters(Convert.ToDouble(sr.Elevation.Split('\'')[0])));
                        }
                    }
                }
            }
            clsSnoTelSiteTable st = new clsSnoTelSiteTable("http://www.wcc.nrcs.usda.gov/nwcc/sitelist.jsp");

            DBLogging.WriteLog(projectName, "Log", "UpdateDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Updating Sites Table using Method 2");
            foreach (clsSnoTelSiteTable.SnoTelSiteRecord ssr in st.Records)
            {
                double lat = format.ConvertLatLong(ssr.Latitude);
                double lng = format.ConvertLatLong(ssr.Longitude);
                if (ssr.SiteCode != "")
                {
                    if (db.isNewSite(ssr.SiteCode))
                    {
                        DBLogging.WriteLog(projectName, "Log", "UpdateDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "inserting site: " + ssr.SiteName);
                        db.insertSite(ssr.SiteCode, ssr.SiteName, lat, lng, 0, format.feetToMeters(Convert.ToDouble(ssr.Elevation.Split('\'')[0])), null, null, null, null, null, format.getFullState(ssr.State), ssr.County, null, format.getTimeZone(lat, lng), ssr.Status);
                    }
                    else
                    {
                        db.updateSite(db.getSiteID(ssr.SiteCode), ssr.SiteCode, ssr.SiteName, format.getFullState(ssr.State), lat, lng, /* format.getTimeZone(lat, lng),*/ format.feetToMeters(Convert.ToDouble(ssr.Elevation.Split('\'')[0])));
                    }
                }
            }
            DBLogging.WriteLog(projectName, "Log", "UpdateDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Updating Sites Table Completed");
        }
Ejemplo n.º 7
0
        public IndexValues()
        {
            db = new ClsSummaryDB();
            DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "IndexValues" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Level 4 Calculations Has Begun Running");

            L4xreflist = db.getL4List();
            CalcIndexValues();
            DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "IndexValues" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Level 4 Calculations Has Completed Running");
        }
Ejemplo n.º 8
0
        public IndexVariables(string[] siteTypes)
        {
            db = new ClsSummaryDB();
            DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "IndexVariables" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Level 3 Spatial Aggregation Has Begun Running");

            xreflist  = db.getL3List(siteTypes);
            wxreflist = db.getL3wList(siteTypes);
            CalcIndexVariables();
            CalcIndexVariablesWatershed();

            DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "IndexVariables" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Level 3 Spatial Aggregation Has Completed Running");
        }
Ejemplo n.º 9
0
        private string generateURL(Site s, Variable v, DateTime startDate, DateTime endDate)
        {
            Match  URL;
            string url = string.Format("http://www.usbr.gov/uc/crsp/GetDataSet?l={0}&c={1}&strSDate={2}&strEDate={3}", s.URLName, v.VariableCode, startDate.ToString("d-MMM-yyyy"), endDate.ToString("d-MMM-yyyy"));

            try
            {
                WebRequest request = WebRequest.Create(url);
                //WebRequest request= WebRequest.Create(@"http://www.usbr.gov/uc/crsp/GetDataSet?l=JOES+VALLEY+RESERVOIR&c=1881&strSDate=22-SEP-2010&strEDate=1-NOV-2010");

                request.Timeout = Timeout.Infinite;
                WebResponse  response           = request.GetResponse();
                Stream       dataStream         = response.GetResponseStream();
                StreamReader reader             = new StreamReader(dataStream);
                string       responseFromServer = reader.ReadToEnd();
                Regex        r = new Regex("(?<=<a href=').*(?='>Plain Text)");
                URL = r.Match(responseFromServer);
            }
            catch (Exception ex) {
                DBLogging.WriteLog(projectName, "Error", "FillUSBR" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Error generating URL: (" + url + ")");

                throw ex;
            }
            URLstring = URL.Value;
            int count = 0;

            while (true)
            {
                try
                {
                    WebRequest   request            = WebRequest.Create(URL.Value);
                    WebResponse  response           = request.GetResponse();
                    Stream       dataStream         = response.GetResponseStream();
                    StreamReader reader             = new StreamReader(dataStream);
                    string       responseFromServer = reader.ReadToEnd();
                    return(responseFromServer);
                }
                catch (Exception ex)
                {
                    if (count >= 10)
                    {
                        DBLogging.WriteLog(projectName, "Error", "FillUSBR" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Error accessing Data URL: (" + URL.Value + ")");
                        throw ex;
                    }
                    else
                    {
                        //DBLogging.WriteLog(projectName, "Error", "FillUSBR" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", " Attempt to access URL(" + URL.Value + ")");
                        count++;
                        Thread.Sleep(1000);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        static void Main()
        {
            string projectName = Properties.Settings.Default.projectName;

            DBLogging.WriteLog(projectName, "Log", "" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", projectName + " has begun Running");

            harvestData h = new harvestData();

            DBLogging.WriteLog(projectName, "Log", "" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", projectName + " Completed Running");
            System.Threading.Thread.Sleep(30);
            SendEmail.SendMessage(projectName + " Completed", projectName + " has completed running, view the attached file for details", Properties.Settings.Default.projectName, new TimeSpan(7, 0, 0, 0));
        }
Ejemplo n.º 11
0
 public void CalcIndexVariables()
 {
     foreach (string siteType in xreflist)
     {
         DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "IndexVariables" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{0} Level 3 Spatial Aggregating Has Begun Running .", siteType));
         try
         {
             int rows = this.db.CreateIndexVariableTable(1, siteType);
             DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "IndexVariables" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{1} rows saved. {0} Level 3 Spatial Aggregating Has Completed Running.", siteType, rows));
         }
         catch (Exception ex)
         {
             DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "IndexVariables" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{1}:{2}. {0} Level 3 Spatial Aggregating Has Completed Running.", siteType, ex.Message, ex.InnerException.Message));
         }
     }
 }
Ejemplo n.º 12
0
 public void CalcIndexVariablesWatershed()
 {
     foreach (WatershedSeries watershed in wxreflist)
     {
         DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "IndexVariables" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{0} Level 3 {1} Watershed Spatial Aggregating Has Begun Running .", watershed.SiteType, watershed.DataTimePeriod));
         try
         {
             int rows = this.db.CreateIndexVariableWatershed(watershed);
             DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "IndexVariables" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{1} rows saved. {0} Level 3 {2} Watershed Spatial Aggregating Has Completed Running.", watershed.SiteType, rows, watershed.DataTimePeriod));
         }
         catch (Exception ex)
         {
             DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "IndexVariables" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{1}:{2} {0} Level 3 {3} Watershed Spatial Aggregating Has Completed Running.", watershed.SiteType, ex.Message, ex.InnerException.Message, watershed.DataTimePeriod));
         }
     }
 }
Ejemplo n.º 13
0
        public void CalculatesAggregates()
        {
            DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "AggregateDataTable" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Monthly/BiMonthly Aggregation Has Begun Running");

            foreach (AggregateSeries variable in aggregatelist)
            {
                ClsDBAccessor dba = new ClsDBAccessor(variable, db);
                try
                {
                    if (variable.DataTimePeriod == "Monthly")
                    {
                        //MonthlyAggregate
                        DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "AggregateDataTable" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{0} Monthly Aggregation Has Begun Running .", variable.SiteType));
                        int rows = dba.SummaryDB.monthlyAggregate(variable);
                        DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "AggregateDataTable" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{1} rows saved. {0} Monthly Aggregation Has Completed Running.", variable.SiteType, rows));
                    }
                    else
                    {
                        //BiMonthlyAggregate
                        DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "AggregateDataTable" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{0} BiMonthly Aggregation Has Begun Running.", variable.SiteType));
                        int rows = dba.SummaryDB.biMonthlyAggregate(variable);
                        DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "AggregateDataTable" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{1} rows saved. {0} BiMonthly Aggregation Has Completed Running.", variable.SiteType, rows));
                    }
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("See the InnerException"))
                    {
                        DBLogging.WriteLog(this.projectName, "Error", ex.StackTrace, String.Format("{0}. {1}, {2}. ", ex.InnerException.Message, variable.SiteType, variable.DataTimePeriod));
                    }
                    else
                    {
                        try
                        {
                            DBLogging.WriteLog(this.projectName, "Error", ex.StackTrace, String.Format("{1}: {0}.  {2}, {3}. ", ex.Message, ex.InnerException.Message, variable.SiteType, variable.DataTimePeriod));
                        }
                        catch
                        {
                            DBLogging.WriteLog(this.projectName, "Error", ex.StackTrace, String.Format("{0}.  {1}, {2}. ", ex.Message, variable.SiteType, variable.DataTimePeriod));
                        }
                    }
                }
                Thread.Sleep(10);
            }
            DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "AggregateDataTable" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Monthly/BiMonthly Aggregation Completed Running");
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Get all segment id's which are configured for the promotion
        /// </summary>
        /// <param name="promotionId"></param>
        /// <returns></returns>
        public List <int> GetSegmentsForPromotion(string promotionId)
        {
            _logMsg.MethodName = MethodBase.GetCurrentMethod().Name;
            List <int> segmentList = null;

            using (DBConnection conn = new DBConnection())
            {
                BackOfficeAdminData backOfficeAdminData = new BackOfficeAdminData(conn);
                segmentList = backOfficeAdminData.GetSegmentsForPromotion(promotionId);
            }
            if (segmentList == null)
            {
                DBLogging.Warn(_logMsg, "GetSegmentsForPromotion", "Promotion Id :" + promotionId, segmentList);
            }

            return(segmentList);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Add given item to OPC items group
        /// </summary>
        /// <param name="itemName"></param>
        private void AddItemToGroup(string itemName)
        {
            try
            {
                int rtc;
                rtc = AsyncRefrGroup.Add(itemName);

                if (HRESULTS.Failed(rtc))
                {
                    DBLogging.InsertLogs("Exception: AddItemToGroup", false, "ReadWriteGroup.GetErrorString(rtc)    " + itemName, _connStr);
                }
            }
            catch (Exception ex)
            {
                DBLogging.InsertLogs("Exception: AddItemToGroup", false, "ReadWriteGroup.GetErrorString(rtc)    " + ex.Message, _connStr);
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="promotionHeaderId"></param>
        /// <returns></returns>
        public bool CheckPromotionInOPE(string promotionHeaderId)
        {
            _logMsg.MethodName = MethodBase.GetCurrentMethod().Name;
            MobilaPromotion mobPromotion = null;

            using (DBConnection conn = new DBConnection())
            {
                BackOfficeAdminData backOfficeAdminData = new BackOfficeAdminData(conn);
                mobPromotion = backOfficeAdminData.ValidatePromotion(promotionHeaderId);
            }
            if (mobPromotion == null)
            {
                DBLogging.Warn(_logMsg, "Validate Promotion Failed", "Promotion Id :" + promotionHeaderId, "Promotion Not Found in OPE");
                return(false);
            }
            return(true);
        }
Ejemplo n.º 17
0
        private bool AddNotes()
        {
            AddNoteToHouseholdManager          addNoteToHouseholdManager = new AddNoteToHouseholdManager();
            ProcessRedemptionOrReversalManager redeemMgr = new ProcessRedemptionOrReversalManager();
            DynamicNote dynamicNote = new DynamicNote();
            string      subFunction = string.Empty;

            ProductDetails productData;

            //To get the Redeemed subcategory in the notes instead of the bonus subcategory #5446 fix
            productData = redeemMgr.GetProduct(Action.ProductId);
            if (Action.BonusType == "ReloadBonus")
            {
                //productData = redeemMgr.GetProductByBonus(Action.ProductId); This method is returning the Bonus product details
                subFunction = AppConstants.ManageHouseholdNoteCodes.ReloadBonus;
            }
            else
            {
                //productData = redeemMgr.GetProduct(Action.ProductId);
                subFunction = AppConstants.ManageHouseholdNoteCodes.LinkBonus;
            }

            dynamicNote.CardNumber        = Action.LinkedCardNumber;
            dynamicNote.LoyaltyCardNumber = Action.LoyaltyCardNumber;
            dynamicNote.CardType          = Action.CardType;
            PromotionBonusAward promotionBonusAward = new PromotionBonusAward();

            if (HttpContext.Current.Session["PromotionBonusAward"] != null)
            {
                promotionBonusAward     = (PromotionBonusAward)HttpContext.Current.Session["PromotionBonusAward"];
                dynamicNote.TotalPoints = Convert.ToInt32(promotionBonusAward.EarnValue);
            }
            else
            {
                dynamicNote.TotalPoints = Convert.ToInt32(productData.UnitsPointsRedemptionCost);
            }

            dynamicNote.ProductSubCategory = productData?.ProductSubCategoryDescription;
            dynamicNote.ProductDescription = productData?.EnglishDescriptionBackOffice;
            var noteResult = addNoteToHouseholdManager.AddDynamicNoteToHousehold(StaticData.OPEFunction, subFunction, dynamicNote);

            DBLogging.Info(_logMsg, "1 to 1 Bonus - AddDynamicNoteToHousehold", "Function :" + StaticData.OPEFunction + "SubFunction : " + subFunction + _objIFormatXmlUtility.FormatXMLRequest(dynamicNote), noteResult);

            return(true);
        }
Ejemplo n.º 18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="registerPromotionRequest"></param>
        /// <returns></returns>
        public MemberPromotion RegisterPromotion(MemberPromotion registerPromotionRequest)
        {
            try
            {
                RegisterPromotion registerPromoBS = new RegisterPromotion();

                this.iRegisterPromotion = registerPromoBS.CreateRegisterPromotion(registerPromotionRequest);

                var memberPromotion = this.iRegisterPromotion.RegisterPromotion(registerPromotionRequest);

                return(memberPromotion);
            }
            catch (Exception ex)
            {
                DBLogging.Error("Register Promotion", ex);
                throw;
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// gather and save Original Agency data from webservice to database
        /// </summary>
        /// <param name="variable">object from the database that contains all the details of the series we are trying to gather data for</param>
        /// <param name="start">date at the beginning of the interval</param>
        /// <param name="end">date at end of interval</param>1
        public void AgencyDataFill(L1HarvestList variable, string start, string end, int count)
        {
            DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "Level1Data1_0" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", String.Format("{0} {1} {2}-{3} {4}\t{5}-{6} {7}/{8}", "Level1", variable.SiteName, start.Replace('-', '/'), end.Replace('-', '/'), variable.SiteCode, variable.VariableCode, "Level1", count, db.SummaryDB.Count));

            TimeSeriesType dataVals = this.GetData(variable, start, end);

            if (dataVals != null)
            {
                if (Convert.ToInt32(dataVals.values.count) >= 1)
                {
                    int siteID = this.SiteData(variable);
                    if (variable.SiteID == 0)
                    {
                        this.db.SummaryDB.UpdateHarvestSite(variable, siteID);
                    }
                    this.noDataValue = Convert.ToDouble(dataVals.variable.NoDataValue);
                    TsValuesSingleVariableType vals = dataVals.values;
                    DateTime startDate = (from n in vals.value select Convert.ToDateTime(n.dateTime)).Min();
                    DateTime endDate   = (from n in vals.value select Convert.ToDateTime(n.dateTime)).Max();

                    var data = from n in vals.value select n;

                    foreach (ValueSingleVariable member in data)
                    {
                        TimeSpan utcoffset = member.dateTime - member.dateTime.ToUniversalTime();

                        // site, Method, variable, Source
                        this.values.Rows.Add(SqlInt32.Null, Convert.ToDouble(member.Value), (member.accuracyStdDev == 0 ? SqlDouble.Null : member.accuracyStdDev), member.dateTime, utcoffset.Hours /*utcoffset*/, member.dateTime.ToUniversalTime(), siteID, variable.VariableID, (member.offsetValue == 0 ? SqlDouble.Null : member.offsetValue), (Convert.ToInt32(member.offsetTypeID) == 0 ? SqlInt32.Null : Convert.ToInt32(member.offsetTypeID)), this.CensorCodeToString(member), SqlInt32.Null, variable.MethodID, variable.SourceID, (Convert.ToInt32(member.sampleID) == 0 ? SqlInt32.Null : Convert.ToInt32(member.sampleID)), SqlInt32.Null, variable.QualityControlLevelID);
                    }

                    this.db.TooDB.InsertBulk(this.values);
                    DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "Level1Data1_0" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", values.Rows.Count + " Rows Saved. " + "Level1" + " " + variable.SiteName + " " + variable.SiteCode + "\t" + variable.VariableCode + "-" + "Level1");
                    this.db.TooDB.SaveSeries(siteID, variable);
                }
                else
                {
                    //DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "Level1Data1_0" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "No Values Found. " + variable.DataTimePeriod + " " + variable.SiteName + " " + variable.SiteCode + "\t" + variable.VariableCode + "-" + variable.DataTimePeriod);
                }
            }
            else
            {
                DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "Level1Data1_0" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", 0 + " Rows Saved. " + "Level1" + " " + variable.SiteName + " " + variable.SiteCode + "\t" + variable.VariableCode + "-" + "Level1");
            }
        }
Ejemplo n.º 20
0
        public UpdateDB()
        {
            DBLogging.WriteLog(projectName, "Log", "UpdateDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "SNOTEL Harvester Has Begun Running");

            try
            {
                fillMeta();
                fillData();
                DBLogging.WriteLog(projectName, "Log", "UpdateDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "SNOTEL Harvester Has Completed Running");
                System.Threading.Thread.Sleep(20);
                SendEmail.SendMessage("SNOTELHarvester Completed", "SNOTEL Harvester has completed running, view the attached file for details", projectName, new TimeSpan(12, 0, 0));
            }
            catch (Exception ex)
            {
                DBLogging.WriteLog(projectName, "Log", "UpdateDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "SNOTEL Harvester Has Completed Running");
                System.Threading.Thread.Sleep(20);
                SendEmail.SendMessage("SNOTELHarvester error", string.Format("SNOTEL Harvester has encountered an error and is shutting down. The error is {0} and occured in:  \n{1}", ex.Message, ex.StackTrace), projectName, new TimeSpan(12, 0, 0));
            }
        }
Ejemplo n.º 21
0
        public void CalcIndexValues()
        {
            //DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "IndexVariables" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Level 3 Spatial Aggregation Has Begun Running");

            foreach (IndexValuexRef siteType in L4xreflist)
            {
                DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "IndexValues" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{0} {1} Level 4 Calculations Has Begun Running. MethodID: {2}", siteType.SiteType, siteType.DataTimePeriod, siteType.MethodID));
                try
                {
                    int rows = this.db.CalcIndexValues(siteType);
                    DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "IndexValues" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{1} rows saved. {0} {2} Level  4 Calculations Aggregating Has Completed Running. MethodID: {3}", siteType.SiteType, rows, siteType.DataTimePeriod, siteType.MethodID));
                }
                catch (Exception ex)
                {
                    DBLogging.WriteLog(Properties.Settings.Default.projectName, "Error", "IndexValues" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("{1}: {2}. {0} {3} Level  4 Calculations Aggregating Has Completed Running. MethodID: {4}", siteType.SiteType, ex.Message, ex.InnerException.Message, siteType.DataTimePeriod, siteType.MethodID));
                }
            }
            //DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "IndexVariables" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Level 3 Spatial Aggregation Has Completed Running");
        }
Ejemplo n.º 22
0
        public double getTimeZone(double lat, double lng)
        {
            try
            {
                string url = string.Format("http://ws.geonames.org/timezone?lat={0}&lng={1}", Math.Round(lat, 4), Math.Round(lng, 4));

                WebRequest   req                = WebRequest.Create(url);
                WebResponse  response           = req.GetResponse();
                Stream       dataStream         = response.GetResponseStream();
                StreamReader reader             = new StreamReader(dataStream);
                string       responseFromServer = reader.ReadToEnd();
                Regex        tzreg              = new Regex(@"(?<=<dstOffset>).*(?=</dstOffset>)");
                string       timez              = tzreg.Match(responseFromServer).ToString();
                return(Convert.ToDouble(timez));
            }
            catch (Exception ex)
            {
                DBLogging.WriteLog(Properties.Settings.Default.projectName, "Error", "clsFormatForDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", ex.Message);
                return(0);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool Run()
        {
            if (Action == null)
            {
                throw new ArgumentException("No loyalty action found");
            }

            DBLogging.Info(_logMsg, "1 to 1 Bonus - Input", "LoyaltyCardNumber :" + Action.LoyaltyCardNumber + "LinkedCard : " + Action.LinkedCardNumber + "Product Id: " + Action.ProductId.ToString() + "BonusType : " + Action.BonusType + "CardType: " + Action.CardType, "");

            bool qualify = Action.QualifyForBonus();

            DBLogging.Info(_logMsg, "1 to 1 Bonus - QualifyForBonus", "LoyaltyCardNumber :" + Action.LoyaltyCardNumber + "LinkedCard : " + Action.LinkedCardNumber + "CardType: " + Action.CardType, qualify);

            bool result = false;

            if (qualify)
            {
                // call Retalix to trigger the bonus
                var    redeemMgr = new ProcessRedemptionOrReversalManager();
                string productId = Action.ProductId.ToString();
                ServiceResponse <string> serviceResp = redeemMgr.Redeem(Action.LoyaltyCardNumber, productId, "1", null, Action.BonusType);
                DBLogging.Info(_logMsg, "1 to 1 Bonus - Redeem", "LoyaltyCardNumber :" + Action.LoyaltyCardNumber + "LinkedCard : " + Action.LinkedCardNumber + "Product Id: " + productId + "CardType: " + Action.CardType, serviceResp);

                // Add Note
                if (serviceResp.IsSuccess)
                {
                    result = true;
                    //Update BonusGivenDate
                    bool updateBonusResult = Action.UpdateBonusGivenDate();
                    DBLogging.Info(_logMsg, "1 to 1 Bonus - UpdateBonusGivenDate", "LoyaltyCardNumber :" + Action.LoyaltyCardNumber + "LinkedCard : " + Action.LinkedCardNumber + "CardType: " + Action.CardType, updateBonusResult);

                    var noteResult = AddNotes();
                }
            }

            DBLogging.Info(_logMsg, "1 to 1 Bonus - Result", "LoyaltyCardNumber :" + Action.LoyaltyCardNumber + "LinkedCard : " + Action.LinkedCardNumber + "Product Id: " + Action.ProductId.ToString() + "BonusType : " + Action.BonusType + "CardType: " + Action.CardType, result);

            return(result);
        }
Ejemplo n.º 24
0
        private string AddMyRefreshGroup1(OpcServer OpcSrv)
        {
            float deadBand = 90.0F;

            try
            {      // create group with 2 sec update rate
                oGrp = OpcSrv.AddGroup("Line1", true, UpdateRate, ref deadBand, 0, 0);
            }
            catch
            {
                DBLogging.InsertLogs("Exception: AddMyRefreshGroup1", false, "Group could not be added", _connStr);
                return("Group could not be added");
            }

            oGrp.DataChanged += new DataChangeEventHandler(DataChangedHandler);
            oGrp.AdviseIOPCDataCallback();


            //client handle as item index
            items1[0] = new OPCItemDef(TagLPG_Bay01_RFID_Puched, true, 0, VarEnum.VT_BOOL);
            items1[1] = new OPCItemDef(TagLPG_WB_RFIDPunched, true, 1, VarEnum.VT_BOOL);
            items1[2] = new OPCItemDef(TagLPG_Bay01_LPGBatchComplete, true, 2, VarEnum.VT_BOOL);

            int rtc;

            rtc = oGrp.AddItems(items1, out addRslt1);

            if (HRESULTS.Failed(rtc))
            {
                return("Error at AddItem");
            }
            for (int i = 0; i < addRslt1.Length; ++i)
            {
                ItemValues1[i] = new OPCItemState();
            }

            return("");
        }
Ejemplo n.º 25
0
        private void fillDatabase()
        {
            //DBLogging.WriteLog(projectName, "Log", "FillUSBR" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format(""));
            List <Site> sites = clsUSBRList.createSiteList();
            int         count = 0;

            foreach (Site s in sites)
            {
                count++;
                foreach (Variable v in s.variables)
                {
                    try
                    {
                        DateTime startDate;
                        int      SID = db.SeriesExists(v.VariableName, s.SiteCode);
                        //if (SID > 0)
                        //    startDate = db.getEndDate(SID).Add(new TimeSpan(1, 0, 0, 0));
                        //else
                        startDate = new DateTime(1938, 01, 01);
                        DateTime endDate = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0));
                        if (endDate >= startDate)
                        {
                            DBLogging.WriteLog(projectName, "Log", "FillUSBR" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("Gathering data for {1} {0}, {4}/{5} {2}-{3}", v.VariableName, s.SiteName, startDate, endDate, count, sites.Count));

                            string data = generateURL(s, v, startDate, endDate);
                            //MessageBox.Show(data);
                            //DBLogging.WriteLog(projectName, "Log", "FillUSBR" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("\tdata recieved for {0} {1}", s.SiteName, v.VariableName));
                            createTable(v.VariableName, data);
                            saveSeries(s, v);
                        }
                    }
                    catch (Exception ex)
                    {
                        DBLogging.WriteLog(projectName, "Error", "FillUSBR" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", s.SiteName + " " + v.VariableName + " " + ex.Message);
                    }
                }
            }
        }
Ejemplo n.º 26
0
        //update series
        public void updateSeries(int siteID, int varID, DateTime beginDateTime, DateTime endDateTime, DateTime beginDateTimeUTC, DateTime endDateTimeUTC, int valueCount)
        {
            try
            {
                SeriesCatalog sc = (from r in this.SeriesCatalog where r.SiteID == siteID && r.VariableID == varID select r).First();

                Sites s = (from S in this.Sites where S.SiteID == siteID select S).First();
                //sc.SiteID = s.SiteID;
                sc.SiteCode = s.SiteCode;
                sc.SiteName = s.SiteName;

                sc.BeginDateTime    = beginDateTime;
                sc.EndDateTime      = endDateTime;
                sc.BeginDateTimeUTC = beginDateTimeUTC;
                sc.EndDateTimeUTC   = endDateTimeUTC;
                sc.ValueCount       = valueCount;
                this.SaveChanges();
            }
            catch (Exception e)
            {
                DBLogging.WriteLog(Properties.Settings.Default.projectName, "Error", "clsDatabase" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", e.Message);
            }
        }
Ejemplo n.º 27
0
        private bool fillTable(WebRequest[] request)
        {
            int count = 0;

            while (count < 5 && keepgoing)
            {
                count++;
                try
                {
                    WebResponse[]  response           = new WebResponse[request.Length];
                    Stream[]       dataStream         = new Stream[request.Length];
                    StreamReader[] reader             = new StreamReader[request.Length];
                    string[]       responseFromServer = new string[request.Length];

                    for (int i = 0; i < request.Length; i++)
                    {
                        response[i]           = request[i].GetResponse();
                        dataStream[i]         = response[i].GetResponseStream();
                        reader[i]             = new StreamReader(dataStream[i]);
                        responseFromServer[i] = reader[i].ReadToEnd();
                    }

                    Regex[] regex = new Regex[request.Length + 1];
                    Match[] oM    = new Match[request.Length + 1];

                    //get the columns of the Dataset
                    regex[0] = new Regex("-.*\n");
                    oM[0]    = regex[0].Match(responseFromServer[0]);

                    createColumns(oM[0]);

                    if (request.Length < 2)
                    {
                        regex[1] = new Regex("\n(.|\n)*", RegexOptions.IgnoreCase);
                    }
                    else
                    {
                        regex[1] = new Regex("\n(.|\n)*", RegexOptions.IgnoreCase);
                        regex[2] = new Regex("\n(.|\n)*" + DateTime.Now.ToString("MMddyy"), RegexOptions.IgnoreCase);
                    }
                    for (int i = 0; i < request.Length; i++)
                    {
                        //Here we apply our regular expression to our string using the Match object.
                        oM[i + 1] = regex[i + 1].Match(responseFromServer[i]);

                        reader[i].Close();
                        response[i].Close();
                        createRows(oM[i + 1]);
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("Unable to read data"))
                    {
                        keepgoing = false;
                    }
                    if (count == 5)
                    {
                        DBLogging.WriteLog(projectName, "Error", "UpdateDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", ex.Message + ". " + request[0].RequestUri.AbsoluteUri + " StackTrace:" + ex.StackTrace);
                        return(false);
                        //throw new Exception("SNOTEL Website is Offline");
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 28
0
        private void fillData()
        {
            numOfSites = db.getNumOfSites();

            DBLogging.WriteLog(projectName, "Log", "UpdateDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("Updating Series Catalog Table: {0} sites", numOfSites));

            //loop through all of the sites and pull down the information from the website
            for (siteID = beginSite; siteID <= numOfSites && keepgoing; siteID++)
            {
                string siteName = db.getSiteName(siteID);
                string state    = db.getState(siteID);
                string siteCode = db.getSiteCode(siteID);
                int    timeZone = Convert.ToInt16(db.getTimeZone(siteID));

                if (getVariables(siteCode, state))
                {
                    //attach variables to columns
                    //for every variable
                    numOfVars = numOfCols - 1;
                    //check to see if there is information in the database about the variable if true continue, if false skip
                    for (int i = 1; i <= numOfVars; i++)
                    {
                        //int i = 1;
                        int variableID;
                        try
                        {
                            variableID = (int)db.getVariableID(oDS.Tables[0].Columns[i].ColumnName.Trim().ToUpper());
                        }
                        catch { variableID = -9999; }


                        if (variableID > 0)
                        {
                            int startIndex = 0;
                            int endIndex   = 0;

                            //calculate begin and end time
                            String endDT   = FindEnd(oDS, i, ref endIndex);
                            String beginDT = FindStart(oDS, i, ref startIndex);


                            DateTime beginDateTimeUTC = format.toDateTime(beginDT, timeZone);
                            DateTime endDateTimeUTC   = format.toDateTime(endDT, timeZone);
                            DateTime endDateTime      = format.toDateTime(endDT, 0);
                            DateTime beginDateTime    = format.toDateTime(beginDT, 0);
                            //endDateTimeUTC = endDateTime.ToUniversalTime();

                            int valueCount = calcValues(startIndex, endIndex, i);

                            if (db.isNewSeries(siteID, variableID))
                            {
                                DBLogging.WriteLog(projectName, "Log", "UpdateDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("Adding New Series. Site:{0}/{1} SiteName: {2}  Variable ID:{3}, {4} {5}/{6}", siteID + 1, numOfSites, siteName, state, variableID, i, numOfVars));

                                Variables v  = db.getVariableInfo(variableID);
                                Units     vu = db.getUnits(Convert.ToInt32(v.UnitsReference.EntityKey.EntityKeyValues[0].Value));
                                Units     tu = db.getUnits(Convert.ToInt32(v.Units1Reference.EntityKey.EntityKeyValues[0].Value));
                                Methods   m  = db.getMethod(variableID);
                                Sources   s  = db.getSourceData(1);

                                int    qualityControlLevelID   = 1;
                                string qualityControlLevelCode = qualityControlLevelID.ToString();

                                if (siteName.Contains('\''))
                                {
                                    string[] list = siteName.Split('\'');
                                    siteName = list[0] + "\'\'" + list[1];
                                }
                                db.insertSeries(siteID, siteCode, siteName, v.VariableID, v.VariableCode, v.VariableName, v.Speciation, vu.UnitsID, vu.UnitsName, v.SampleMedium, v.ValueType, v.TimeSupport, tu.UnitsID, tu.UnitsName, v.DataType, v.GeneralCategory, m.MethodID, m.MethodDescription, s.SourceID, s.Organization, s.SourceDescription, s.Citation, qualityControlLevelID, qualityControlLevelCode, beginDateTime, endDateTime, beginDateTimeUTC, endDateTimeUTC, valueCount);
                            }
                            else
                            {
                                DBLogging.WriteLog(projectName, "Log", "UpdateDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("Updating Series. Site:{0}/{1} SiteName: {2}  Variable ID:{3}, {4}  {5}/{6}", siteID, numOfSites, siteName, state, variableID, i, numOfVars));
                                //DBLogging.WriteLog(projectName, "Log", "UpdateDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("Updating Series. Site:{0}/{1} SiteName: {2}  Variable ID:{3}, {4}/{5}", siteID, numOfSites, siteName,, variableID, i, numOfVars));
                                db.updateSeries(siteID, variableID, beginDateTime, endDateTime, beginDateTimeUTC, endDateTimeUTC, valueCount);
                            }
                        }
                    }
                }
                else
                {
                    DBLogging.WriteLog(projectName, "Error", "UpdateDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("No Data Found. Site:{0}/{1} SiteName: {2}, {3}  ", siteID, numOfSites, siteName, state));
                }
                numOfCols = 0;
            }
        }
Ejemplo n.º 29
0
        public int SaveSite(
            string siteCode,
            string siteName,
            double lng,
            double lat,
            int lldatumID,
            double elev,
            string vertDatum,
            int localx,
            int localy,
            int lprojid,
            int posAcc,
            string state,
            string county,
            string comments,
            string siteType)
        {
            Site s;

            try
            {
                s = (from S in this.Sites where S.SiteCode == siteCode /*&& S.SiteType == siteType/* && S.SiteName == siteName && S.Longitude == lng*/ select S).First();
            }
            catch
            {
                DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "clsTooDB" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", string.Format("Saving new Site: {0}", siteName));

                s                = new Site();
                s.SiteCode       = siteCode;
                s.SiteName       = siteName;
                s.Longitude      = lng;
                s.Latitude       = lat;
                s.LatLongDatumID = lldatumID;
                s.Elevation_m    = this.TestInput(elev);
                s.VerticalDatum  = this.TestInput(vertDatum);

                if (localx != 0)
                {
                    s.LocalX = localx;
                }

                if (localy != 0)
                {
                    s.LocalY = localy;
                }

                if (lprojid != 0)
                {
                    s.LocalProjectionID = lprojid;
                }

                if (posAcc != 0)
                {
                    s.PosAccuracy_m = posAcc;
                }

                s.State    = this.TestInput(state);
                s.County   = this.TestInput(county);
                s.Comments = this.TestInput(comments);
                // s.SiteType = siteType;
                this.AddToSites(s);
                this.SaveChanges();
            }

            return(s.SiteID);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>

        static void Main(string[] args)
        {
            ClsDBAccessor dba = new ClsDBAccessor();

            DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "DataSummary Running" + listAgencies(args));


            var options = new Options();

            if (CommandLineParser.Default.ParseArguments(args, options))
            {
                // consume Options type properties
                if (options.Levels == null)
                {
                    options.Levels = new List <string>();
                    options.Levels.Add("1");
                    options.Levels.Add("2");
                    options.Levels.Add("3");
                    options.Levels.Add("4");
                }
            }

            foreach (string level in options.Levels)
            {
                switch (level)
                {
                case "1":
                    if (options.Agency == null)
                    {
                        new getOriginalAgency();
                    }
                    else
                    {
                        new getOriginalAgency(options.Agency.ToArray());
                    }
                    // dba.SummaryDB.updateSeriesCatalag();
                    break;

                case "2":
                    if (options.Agency == null)
                    {
                        new TimeAggregated();
                    }
                    else
                    {
                        new TimeAggregated(options.Agency.ToArray());
                    }
                    // dba.SummaryDB.updateSeriesCatalag();
                    break;

                case "3":
                    if (options.Agency == null)
                    {
                        new IndexVariables();
                    }
                    else
                    {
                        new IndexVariables(options.Agency.ToArray());
                    }
                    // dba.SummaryDB.updateSeriesCatalag();
                    break;

                case "4":
                    if (options.Agency == null)
                    {
                        new IndexValues();
                    }

                    else
                    {
                        new IndexValues(options.Agency.ToArray());
                    }
                    // dba.SummaryDB.updateSeriesCatalag();
                    break;
                }
            }


            DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "Updating SeriesCatalog of Summary Database");
            dba.SummaryDB.updateSeriesCatalag();

            DBLogging.WriteLog(Properties.Settings.Default.projectName, "Log", "" + "." + (new StackTrace(true)).GetFrame(0).GetMethod().Name + "()", "DataSummary Completed Running" + listAgencies(args));
            SendEmail.SendMessage("DataSummary Completed", "DataSummary has completed running, view the attached file for details", Properties.Settings.Default.projectName, new TimeSpan(7, 0, 0, 0));
        }