예제 #1
0
 public void Stop()
 {
     try
     {
         TextFileLogger.Log(string.Format("{0}Service Started at {1}.", System.Environment.NewLine, DateTime.Now.ToString()));
         _scheduler.Shutdown();
     }
     catch (Exception ex)
     {
         ExceptionHandler.HandleException(ex);
     }
 }
예제 #2
0
        static public void HandleException(System.Exception ex, string message = "An errror occured in scheduler", bool ignoreException = true)
        {
            // Format the exception message.
            ExceptionFormatter formater          = new ExceptionFormatter();
            string             formatedException = formater.Format(message, ex);

            // Log error message in production category.
            // If severity is critical then it also send error to config mail address.
            TextFileLogger.Log(formatedException, ErrorLogFileName);

            if (!ignoreException)
            {
                throw ex;
            }
        }
예제 #3
0
 public void Start()
 {
     try
     {
         ISchedulerFactory scf = new StdSchedulerFactory();
         _scheduler = scf.GetScheduler();
         if (!_scheduler.IsStarted)
         {
             TextFileLogger.Log(string.Format("{0}Service Started at {1}.", System.Environment.NewLine, DateTime.Now.ToString()));
         }
         _scheduler.Start();
     }
     catch (Exception ex)
     {
         ExceptionHandler.HandleException(ex);
     }
 }
예제 #4
0
        public bool PostTickets()
        {
            try
            {
                string errorMsg = string.Empty;
                int    errorCode;
                if (!CheckLogin(out errorMsg))
                {
                    throw new Exception(errorMsg);
                }
                IEnumerable <Scale> scales = _rsmartService.GetPendingTickets();
                try
                {
                    foreach (var scale in scales)
                    {
                        IEnumerable <ScaleDetails>     scaleDetails     = _rsmartService.GetTicketItemsByTicketId(scale.ID);
                        IEnumerable <ScaleAttachments> scaleAttachments = _rsmartService.GetTicketAttachmentsByTicketId(scale.ID);
                        AddressBook partyPrimaryAddress = _rsmartService.GetAddressByPartyId(scale.Party_ID.ID);

                        Ticket t = new Ticket();
                        t = _rsmartService.MapTicketFromRsmartTicket(scale, scaleDetails, scaleAttachments, partyPrimaryAddress, t);


                        // Start transaction.
                        using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions
                        {
                            IsolationLevel = IsolationLevel.Serializable
                        }))
                        {
                            string            statusRemarks = string.Empty;
                            EnumPostingStatus status        = EnumPostingStatus.Failed;
                            string            action        = "add";


                            SubmitTransaction(t, out errorMsg, out errorCode);

                            if (errorCode == 13)
                            {
                                action = "update";
                                TicketKey ticketKey = new TicketKey();
                                ticketKey.ticketnumber   = scale.Scale_Ticket_No;
                                ticketKey.ticketDateTime = scale.Created_Date.ToString();
                                UpdateTransaction(ticketKey, t, out errorMsg, out errorCode);
                            }

                            if (errorCode == 0)
                            {
                                status = EnumPostingStatus.Succeed;
                                _rsmartService.UpdateTicketStatus(scale);
                                statusRemarks = string.Format("Successfully {0} ticket# {1}", action, scale.Scale_Ticket_No);
                            }
                            else
                            {
                                statusRemarks = string.Format("Failed to {0} ticket# {1} due to '{2}'", action, scale.Scale_Ticket_No, errorMsg);
                            }

                            _rsmartService.AddLeadLog(scale.Scale_Ticket_No, status, statusRemarks);
                            scope.Complete();
                        }
                    }
                    TextFileLogger.Log(string.Format("{0}{1} ticket(s) posted on leads at {2}.", System.Environment.NewLine, scales.Count(), DateTime.Now.ToString()));
                }
                catch (Exception ex)
                {
                    ExceptionHandler.HandleException(ex, errorMsg);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
            }
            return(true);
        }