Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        private static RuleHistoryInfo CreteRuleHistoryInfo(IDataReader reader)
        {
            try
            {
                string          value  = DataAccess.Helper.DataReaderHelper.GetValue <object>(reader, "OBJECTSNAPSHOT", true, string.Empty).ToString();
                PublishedObject pubObj = null;
                if (!string.IsNullOrEmpty(value))
                {
                    pubObj = (PublishedObject)ObjectSerializerHelper.Deserialize(value);
                }

                value = DataAccess.Helper.DataReaderHelper.GetValue <object>(reader, "MAILMESSAGESNAPSHOT", true, string.Empty).ToString();
                Subscriber.Dispatcher.CalendarMail.MailRequest mailRequest = null;
                if (!string.IsNullOrEmpty(value))
                {
                    mailRequest = (Subscriber.Dispatcher.CalendarMail.MailRequest)ObjectSerializerHelper.Deserialize(value);
                }

                return(new RuleHistoryInfo
                {
                    Id = Convert.ToInt32(DataAccess.Helper.DataReaderHelper.GetValue <object>(reader, "ID", false).ToString()),
                    IdRule = Convert.ToInt32(DataAccess.Helper.DataReaderHelper.GetValue <object>(reader, "RULEID", false).ToString()),
                    Published = (DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "COMPUTED", false) == "1"),
                    PublishDate = DataAccess.Helper.DataReaderHelper.GetValue <DateTime>(reader, "COMPUTEDATE", true, DateTime.MinValue),
                    ErrorInfo = new ErrorInfo
                    {
                        Id = DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "ERRORID", true, string.Empty),
                        Message = DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "ERRORDESCRIPTION", true, string.Empty),
                        Stack = DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "ERRORSTACK", true, string.Empty)
                    },
                    Author = new EventAuthorInfo
                    {
                        Id = DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "AUTHORID", true, string.Empty),
                        Name = DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "AUTHORNAME", true, string.Empty),
                        IdRole = DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "ROLEID", true, string.Empty),
                        RoleName = DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "ROLENAME", true, string.Empty)
                    },
                    ObjectSnapshot = pubObj,
                    MailMessageSnapshot = mailRequest
                });
            }
            catch (SubscriberException pubEx)
            {
                _logger.Error(pubEx.Message);

                throw pubEx;
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);

                throw new SubscriberException(ErrorCodes.UNHANDLED_ERROR,
                                              string.Format(ErrorDescriptions.UNHANDLED_ERROR, ex.Message),
                                              ex);
            }
            finally
            {
                _logger.Info("END");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        protected override void InternalExecute()
        {
            PublishedObject pubObj       = ListenerRequest.EventInfo.PublishedObject;
            string          IdDocument   = pubObj.IdObject;
            string          UserName     = FindProperty("UserName").Value.ToString();
            string          CodeRole     = FindProperty("RoleCode").Value.ToString();
            string          StateDiagram = FindProperty("Stato").Value.ToString().Trim().ToUpper();
            string          CodeAdm      = FindProperty("CodeAdm").Value.ToString();

            logger.DebugFormat("Dati: IdDoc {0}, User {1}, ruolo {2}, stateDiagram {3}, CodeAdm {4}", IdDocument, UserName, CodeRole, StateDiagram, CodeAdm);
            bool computed = false;

            try
            {
                //valido ed eventualmente notifico ad ALT che il documento è pronto per la PUBBLICAZIONE/REVOCA/ANNULLAMENTO
                computed = this.IsValidForNotify(IdDocument, UserName, CodeRole, StateDiagram, CodeAdm);
            }
            catch (Exception ex)
            {
                computed = false;
                this.Response.Rule.Error = new ErrorInfo
                {
                    Id      = Subscriber.ErrorCodes.UNHANDLED_ERROR,
                    Message = ex.Message,
                    Stack   = ex.ToString()
                };
            }
            finally
            {
                this.Response.Rule.Computed    = computed;
                this.Response.Rule.ComputeDate = DateTime.Now;
                this.WriteRuleHistory(this.Response.Rule);
            }
        }