Пример #1
0
        /// <summary>
        /// Automatically populates fields with exception information
        /// </summary>
        /// <param name="e"></param>
        public ErrorEntity(Exception e)
            : this()
        {
            this.Message = e.Message;
            this.StackTrace = e.StackTrace;
            this.ErrorDateTime = DateTime.Now;

            if (null != e.InnerException)
            {
                ErrorEntity errorEntity = new ErrorEntity(e.InnerException);
                this.ChildErrorCollection.Add(errorEntity);
            }
        }
Пример #2
0
        protected void Application_Error()
        {
            Exception exception = Server.GetLastError();

            try
            {
                DataAccessAdapterBase adapter = Helper.GetDataAccessAdapterFactory();
                ErrorEntity.LogException(adapter, exception);
            }
            catch (Exception ex)
            {
                ErrorEntity error = new ErrorEntity(exception);
                StringWriter stringWriter = new StringWriter();
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(ErrorEntity));
                xmlSerializer.Serialize(stringWriter, error);
                stringWriter.Close();

                StringBuilder xmlFilePath = new StringBuilder(HttpContext.Current.Request.MapPath(HttpContext.Current.Request.ApplicationPath));

                if (xmlFilePath.Length > 0 && xmlFilePath.ToString().Substring(xmlFilePath.Length - 1, 1) != @"\")
                {
                    xmlFilePath.Append(@"\");
                }

                xmlFilePath.Append("Errors.xml");

                File.AppendAllText(xmlFilePath.ToString(), stringWriter.ToString());
            }

            try
            {
                string emailFrom = ConfigurationManager.AppSettings["ErrorMailFrom"];
                string emailTo = ConfigurationManager.AppSettings["ErrorMailTo"];
                string subject = string.Format("Application {0} error", ConfigurationManager.AppSettings["ApplicationName"]);
                string body = string.Format("<strong>Username:</strong> {0} <br /><br /><strong>Exception:</strong> <br /><br /> {1}",
                    User.Identity.Name,
                    exception.ToString());

                System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage("*****@*****.**", emailTo, subject, body);
                mail.IsBodyHtml = true;

                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
                smtp.EnableSsl = true;
                smtp.Send(mail);
            }
            catch (Exception)
            {
                // Silent fail
            }
        }
Пример #3
0
 /// <summary> setups the sync logic for member _parentError</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncParentError(IEntityCore relatedEntity)
 {
     if(_parentError!=relatedEntity)
     {
         DesetupSyncParentError(true, true);
         _parentError = (ErrorEntity)relatedEntity;
         this.PerformSetupSyncRelatedEntity( _parentError, new PropertyChangedEventHandler( OnParentErrorPropertyChanged ), "ParentError", NinjaSoftware.TrzisteNovca.CoolJ.RelationClasses.StaticErrorRelations.ErrorEntityUsingErrorIdParentErrorIdStatic, true, new string[] {  } );
     }
 }
Пример #4
0
 /// <summary> Removes the sync logic for member _parentError</summary>
 /// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
 /// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param>
 private void DesetupSyncParentError(bool signalRelatedEntity, bool resetFKFields)
 {
     this.PerformDesetupSyncRelatedEntity( _parentError, new PropertyChangedEventHandler( OnParentErrorPropertyChanged ), "ParentError", NinjaSoftware.TrzisteNovca.CoolJ.RelationClasses.StaticErrorRelations.ErrorEntityUsingErrorIdParentErrorIdStatic, true, signalRelatedEntity, "ChildErrorCollection", resetFKFields, new int[] { (int)ErrorFieldIndex.ParentErrorId } );
     _parentError = null;
 }
Пример #5
0
 public static ErrorEntity FetchError(DataAccessAdapterBase adapter, PrefetchPath2 prefetchPath, long ErrorId)
 {
     ErrorEntity _ErrorEntity = new ErrorEntity(ErrorId);
     adapter.FetchEntity(_ErrorEntity, prefetchPath);
     return _ErrorEntity;
 }
Пример #6
0
 protected ErrorEntity(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     if(SerializationHelper.Optimization != SerializationOptimization.Fast)
     {
         _childErrorCollection = (EntityCollection<ErrorEntity>)info.GetValue("_childErrorCollection", typeof(EntityCollection<ErrorEntity>));
         _parentError = (ErrorEntity)info.GetValue("_parentError", typeof(ErrorEntity));
         if(_parentError!=null)
         {
             _parentError.AfterSave+=new EventHandler(OnEntityAfterSave);
         }
         this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance());
     }
     // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
     // __LLBLGENPRO_USER_CODE_REGION_END
 }
Пример #7
0
 public static void LogException(DataAccessAdapterBase adapter, Exception exception)
 {
     ErrorEntity error = new ErrorEntity(exception);
     error.Save(adapter, false, false);
 }