Esempio n. 1
0
        /// <summary>
        /// The function DOES NOT save changes into database, it just returns true if a meber 
        /// has been successfully processed and the 'save' operation is allowed.
        /// </summary>
        /// <param name="context">EF context</param>
        /// <param name="member">WebResource instance</param>
        /// <returns>true if success, false otherwise</returns>
        public bool TryProcessMember(SmartModelContainer context, WebResource member)
        {
            bool success = false;
            try
            {
                // do all parsing here
                member.Status = (int)MemberStatus.Done;
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(member.Url);
                request.Headers.Add("Accept-Encoding", "gzip, deflate");
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                // use an appropriate web resource handler to process the member

                // allow to commit changes
                success = true;
            }
            catch (Exception e)
            {
                RegisterException(member.Id, e);
            }
            return success;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the WebResourceSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToWebResourceSet(WebResource webResource)
 {
     base.AddObject("WebResourceSet", webResource);
 }