コード例 #1
0
        public string AddToGoogleBase()
        {
            UpdateEntry();
            // try insert
            string gbaseId = "";
            bool hasError = false;
            try
            {
                entry = service.Insert(feed, entry);
                gbaseId = entry.Id.AbsoluteUri;
            }
            catch (WebException ex)
            {
                var resp = ex.Response;
                hasError = true;
                if (resp != null)
                {
                    using (var sr = new StreamReader(resp.GetResponseStream()))
                    {
                        var err = sr.ReadToEnd();
                        Syslog.Write(string.Concat("ADD: ", err, " ", hostName, " ", ProductId));
                    }
                }
            }
            catch (Exception ex)
            {
                Syslog.Write(ex);
                Syslog.Write(string.Concat("ADD: ", ex.Message, " ", hostName, " ", ProductId));
                hasError = true;
            }

            if (hasError && ownerid.HasValue)
            {
                using (var repository = new TradelrRepository())
                {
                    repository.AddActivity(ownerid.Value,
                                   new ActivityMessage(ProductId, ownerid,
                                               ActivityMessageType.AUTOPOST_GBASE_FAIL,
                                               string.Format("<a href='{0}'>{1}</a>", producturl, productname)),
                                               subdomainid);
                    repository.Save(); 
                }
                
            }

            return gbaseId;
        }
コード例 #2
0
        public bool UpdateToGoogleBase()
        {
            bool hasError = false;
            try
            {
                var atomid = service.Update(entry).Id.AbsoluteUri;
                if (AtomID != atomid)
                {
                    Syslog.Write(string.Format("Inserted GBASE not equal, productid {0} :{1} {2}", ProductId, AtomID, atomid));
                }
            }
            catch(WebException ex)
            {
                var resp = ex.Response;
                hasError = true;
                if (resp != null)
                {
                    using (var sr = new StreamReader(resp.GetResponseStream()))
                    {
                        var err = sr.ReadToEnd();
                        Syslog.Write(string.Format("Update err: {0}, hostname: {1}", err, hostName));
                    }
                }
            }
            catch (Exception ex)
            {
                Syslog.Write(ex);
                hasError = true;
            }

            if (hasError && ownerid.HasValue)
            {
                using (var repository = new TradelrRepository())
                {
                    repository.AddActivity(ownerid.Value,
                                   new ActivityMessage(ProductId, ownerid,
                                               ActivityMessageType.AUTOPOST_GBASE_FAIL,
                                               string.Format("<a href='{0}'>{1}</a>", producturl, productname)),
                                               subdomainid);
                    repository.Save();
                }
                
                return false;
            }
            return true;
        }
コード例 #3
0
        public int?PostEntry()
        {
            Debug.Assert(post != null);
            bool hasError = false;
            int? postid   = null;

            try
            {
#if DEBUG
                postid = wrapper.NewPost(post, false);
#else
                postid = wrapper.NewPost(post, true);
#endif
            }
            catch (WebException ex)
            {
                var resp = ex.Response;
                if (resp != null)
                {
                    using (var sr = new StreamReader(resp.GetResponseStream()))
                    {
                        var err = sr.ReadToEnd();
                        hasError = true;
                        Syslog.Write(string.Concat("Wordpress Post: ", err, " ", hostName, " ", postid));
                    }
                }
            }
            catch (Exception ex)
            {
                hasError = true;
                Syslog.Write(string.Concat("Wordpress Post: ", ex.Message, " ", hostName, " ", postid));
            }
            if (hasError)
            {
                using (var repository = new TradelrRepository())
                {
                    repository.AddActivity(ownerid.Value,
                                           new ActivityMessage(ProductId, ownerid,
                                                               ActivityMessageType.AUTOPOST_WORDPRESS_FAIL,
                                                               string.Format("<a href='{0}'>{1}</a>", producturl, productname)),
                                           subdomainid);
                    repository.Save();
                }
            }
            return(postid);
        }
コード例 #4
0
        public void GetBlogEntry(product p, int postid)
        {
            bool hasError = false;

            try
            {
                post = wrapper.GetPost(postid);
            }
            catch (WebException ex)
            {
                var resp = ex.Response;
                if (resp != null)
                {
                    using (var sr = new StreamReader(resp.GetResponseStream()))
                    {
                        var err = sr.ReadToEnd();

                        Syslog.Write(string.Concat("Wordpress Get entry: ", err, " ", hostName, " "));
                    }
                }
                hasError = true;
            }
            catch (Exception ex)
            {
                hasError = true;
                Syslog.Write(string.Concat("Wordpress Get entry: ", ex.Message, " ", hostName, " "));
            }

            if (hasError)
            {
                using (var repository = new TradelrRepository())
                {
                    repository.AddActivity(ownerid.Value,
                                           new ActivityMessage(ProductId, ownerid,
                                                               ActivityMessageType.AUTOPOST_WORDPRESS_FAIL,
                                                               string.Format("<a href='{0}'>{1}</a>", producturl, productname)),
                                           subdomainid);
                    repository.Save();
                }
            }

            FillBlogEntry(p);
        }
コード例 #5
0
 private void CheckInventoryLevel()
 {
     // log activity if is stock below or equals alarm level
     if (item.alarmLevel.HasValue &&
         item.available.HasValue &&
         item.product_variant != null &&
         item.inventoryLocation != null &&
         item.available <= item.alarmLevel)
     {
         using (var repository = new TradelrRepository())
         {
             repository.AddActivity(subdomainid,
                                    new ActivityMessage(item.product_variant.productid, subdomainid,
                                                        ActivityMessageType.PRODUCT_ALARM, item.inventoryLocation.name,
                                                        new HtmlLink(item.product_variant.product.title,
                                                                     item.product_variant.productid).
                                                        ToProductString()), subdomainid);
         }
     }
 }