Esempio n. 1
0
        // Named by @ShawnWildermuth via twitter
        public void DoIt(string xmlFromGoogleCart)
        {
            // Pull out the serial number
            XDocument doc = XDocument.Load(new StringReader(xmlFromGoogleCart));
            var query = from elems in doc.Elements().Attributes("serial-number") select elems;
            string serial = query.First().Value;

            // Now check to see if that serial exists..
            PgpEntities entities = new PgpEntities();

            var cards = from c in entities.ProcessedCards
                        where c.Serial == serial
                        select new { c.Serial };

            if (cards.Count() > 0)
            {
                logger.Log("The serial number " + cards.First().Serial + " already exists.. Stopping");
                return;
            }

            ProcessedCard card = new ProcessedCard { RawData = xmlFromGoogleCart, Serial = serial };
            entities.AddToProcessedCards(card);
            entities.SaveChanges();

            GetIdsFromCartXml(card.RawData);
        }
Esempio n. 2
0
        private void ProcessCards(List<string> ids)
        {
            try
            {
                // Can this be Parrell.For?
                foreach (string item in ids)
                {
                    int i = int.Parse(item);

                    PgpEntities svc = new PgpEntities();

                    var query = (from card in svc.Cards where card.CardId == i select card).ToList();

                    foreach (var card in query)
                    {
                        SendMail(card);

                        card.IsSent = true;
                        svc.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Log(ex.Source, ex.Message, ex.Data.ToString(), ex.StackTrace, ex.TargetSite.ToString(), Logger.ErrorLevels.ERROR,
                    "--Exception occured in ProcessCards()");
            }
        }