Esempio n. 1
0
        public static StatusCode GetStatusCode(long status_info_id)
        {
            if (status_info_id == 0)
            {
                return(StatusCode.SUCCEED_STATUS);
            }

            Models.StatusInfo statusInfo = Common.GyomuDataAccess.SelectStatusInfo(status_info_id);
            if (statusInfo == null)
            {
                return(null);
            }
            StatusCode retVal = new StatusCode
            {
                _statuc_info_id = status_info_id
            };


            if (string.IsNullOrEmpty(statusInfo.summary))
            {
                retVal._internalSummary = "";
            }
            else
            {
                retVal._internalSummary = statusInfo.summary;
            }
            if (string.IsNullOrEmpty(statusInfo.description))
            {
                retVal._internalDescription = "";
            }
            else
            {
                retVal._internalDescription = statusInfo.description;
            }
            if (string.IsNullOrEmpty(statusInfo.developer_info))
            {
                retVal._internalStackTrace = "";
            }
            else
            {
                retVal._internalStackTrace = statusInfo.developer_info;
            }
            retVal._error_id = statusInfo.error_id;
            return(retVal);
        }
Esempio n. 2
0
        private void _doRegister()
        {
            try
            {
                Models.ApplicationInfo applicationInformation = null;

                short  application_id        = _application_id == 0 ? AppCode : _application_id;
                string information           = Message;
                string developer_information = GetCallerInfo();
                short  status_type           = StatusType;
                short  status_code           = getCode();
                string title = getTitle();
                List <Models.StatusHandler> lstMailHandler = null;

                try
                {
                    using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.RequiresNew))
                    {
                        applicationInformation = Common.GyomuDataAccess.SelectApplicationInfo(application_id);
                        Models.StatusInfo statusInfo = new Models.StatusInfo()
                        {
                            application_id = application_id,
                            entry_author   = Common.User.CurrentUser.UserID,
                            status_type    = status_type,
                            error_id       = status_code,
                            instance_id    = _instance_id,
                            hostname       = System.Environment.MachineName,
                            summary        = title,
                            description    = information,
                            developer_info = developer_information
                        };
                        _statuc_info_id = Common.GyomuDataAccess.InsertStatusInfo(statusInfo);
                        lstMailHandler  = Common.GyomuDataAccess.SelectStatusHandlers(application_id);

                        scope.Complete();
                    }
                    if (applicationInformation != null && lstMailHandler != null && lstMailHandler.Count > 0 && (string.IsNullOrEmpty(Common.Net.Email.SmtpServerPortSplitWithColon) == false))
                    {
                        Common.Net.Email email  = new Common.Net.Email(application_id, _config);
                        string[]         to     = lstMailHandler.Where(s => s.recipient_type.Equals("TO")).Select(h => h.recipient_address).ToArray();
                        string[]         cc     = lstMailHandler.Where(s => s.recipient_type.Equals("CC")).Select(h => h.recipient_address).ToArray();
                        StringBuilder    strBuf = new StringBuilder("<HTML><BODY><pre>");
                        strBuf.Append(getMailBody());
                        strBuf.Append("</pre></BODY></HTML>");

                        string subject = applicationInformation.description + " " + getTitle();
                        subject = subject.Replace('\r', ' ').Replace('\n', ' ');

                        StatusCode retVal = email.Send(applicationInformation.mail_from_address, applicationInformation.mail_from_name,
                                                       to, cc, subject, strBuf.ToString(), null);
                    }
                }
                catch (Exception)
                {
                }
                finally
                {
                    _db_registered.Set();
                }
            }
            catch (Exception) { }
        }