コード例 #1
0
 /// <summary>
 /// LatLong
 /// </summary>
 /// <param name="minLat"></param>
 /// <param name="minLong"></param>
 /// <param name="maxLat"></param>
 /// <param name="maxLong"></param>
 public LatLong(string minLat, string minLong, string maxLat, string maxLong)
 {
     try
     {
         if (!string.IsNullOrEmpty(minLat))
         {
             m_minLat = decimal.Parse(minLat);
         }
         if (!string.IsNullOrEmpty(minLong))
         {
             m_minLong = decimal.Parse(minLong);
         }
         if (!string.IsNullOrEmpty(maxLat))
         {
             m_maxLat = decimal.Parse(maxLat);
         }
         if (!string.IsNullOrEmpty(maxLong))
         {
             m_maxLong = decimal.Parse(maxLong);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(string.Format("Latitude or longitude parameter could not be parsed: {0}",
                                           ExceptionUtils.GetDeepExceptionMessageOnly(ex)));
     }
 }
コード例 #2
0
 public static void ErrorMessageBox(IWin32Window owner, Exception exception, string messageFormat, params object[] args)
 {
     if (!CollectionUtils.IsNullOrEmpty(args))
     {
         messageFormat = string.Format(messageFormat, args);
     }
     if (exception != null)
     {
         messageFormat += Environment.NewLine + Environment.NewLine + ExceptionUtils.GetDeepExceptionMessageOnly(exception);
     }
     MessageBox.Show(owner, messageFormat, Application.ProductName + " Error",
                     MessageBoxButtons.OK, MessageBoxIcon.Error);
 }
コード例 #3
0
        public string CheckPasswords(UserAccount instance, string testNaasPassword, string prodNaasPassword, NodeVisit visit)
        {
            ValidateByRole(visit, SystemRoleType.Admin);

            if ((instance == null) || string.IsNullOrEmpty(instance.NaasAccount) ||
                string.IsNullOrEmpty(testNaasPassword) || string.IsNullOrEmpty(prodNaasPassword))
            {
                throw new ArgumentException("Input values are null.");
            }

            string testException = null;

            try
            {
                NAASManager.ValidateUsernameAndPassword(instance.NaasAccount, testNaasPassword, true);
            }
            catch (Exception e)
            {
                testException = ExceptionUtils.GetDeepExceptionMessageOnly(e);
            }
            string prodException = null;

            try
            {
                NAASManager.ValidateUsernameAndPassword(instance.NaasAccount, prodNaasPassword, false);
            }
            catch (Exception e)
            {
                prodException = ExceptionUtils.GetDeepExceptionMessageOnly(e);
            }

            string rtnMessage = string.Empty;

            if (!string.IsNullOrEmpty(testException))
            {
                rtnMessage = "The Test username and password failed to authenticate with message: " + testException;
            }
            if (!string.IsNullOrEmpty(prodException))
            {
                if (!string.IsNullOrEmpty(rtnMessage))
                {
                    rtnMessage += Environment.NewLine + Environment.NewLine;
                }
                rtnMessage += "The Prod username and password failed to authenticate with message: " + prodException;
            }
            return(rtnMessage);
        }
コード例 #4
0
            /// <summary>
            /// MinMaxDate
            /// </summary>
            /// <param name="minDate"></param>
            /// <param name="maxDate"></param>
            public MinMaxDate(string minDate, string maxDate)
            {
                try
                {
                    if (!string.IsNullOrEmpty(minDate))
                    {
                        m_minDate = DateTime.Parse(minDate);
                    }

                    if (!string.IsNullOrEmpty(maxDate))
                    {
                        m_maxDate = DateTime.Parse(maxDate);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("Date parameter could not be parsed: {0}",
                                                      ExceptionUtils.GetDeepExceptionMessageOnly(ex)));
                }
            }
コード例 #5
0
        protected virtual void CallPostprocessingStoredProc(string facDtlsId)
        {
            if (_storedProcName == null)
            {
                return;
            }
            IDbParameters parameters = _baseDao.AdoTemplate.CreateDbParameters();

            parameters.AddWithValue(p_fac_dtls_id, facDtlsId);

            AppendAuditLogEvent("Attempting to call database stored procedure \"{0}\" ...", _storedProcName);

            try
            {
                ExecStoredProc(_baseDao, _storedProcName, _storedProcTimeout, parameters);
                AppendAuditLogEvent("Successfully called database stored procedure \"{0}\"", _storedProcName);
            }
            catch (Exception ex)
            {
                AppendAuditLogEvent("The database stored procedure \"{0}\" returned an error: {1}",
                                    _storedProcName, ExceptionUtils.GetDeepExceptionMessageOnly(ex));
                throw;
            }
        }
コード例 #6
0
        public ScheduledItem ProcessScheduledItem(string scheduleId, bool forceRun, out Activity activity)
        {
            activity = null;
            using (INodeProcessorMutex mutex = GetMutex(scheduleId))
            {
                if (!mutex.IsAcquired)
                {
                    LOG.Debug("Exiting ProcessScheduleItem(), could not acquire mutex");
                    return(null);        // Another thread is already working on this transaction, get out of here
                }
                bool          isRunNow;
                ScheduledItem scheduledItem = ScheduleManager.GetScheduledItem(scheduleId, out isRunNow);
                /*************************************/
                var isDebugging        = DebugUtils.IsDebugging;
                var computerPrefix     = "COMPUTER: ";
                var allowScheduleToRun = !isDebugging;
                var hasComputerPrefix  = scheduledItem.Name.StartsWith(computerPrefix, StringComparison.OrdinalIgnoreCase);
                if (hasComputerPrefix)
                {
                    var specialPrefix    = computerPrefix + Environment.MachineName;
                    var hasSpecialPrefix = scheduledItem.Name.StartsWith(specialPrefix, StringComparison.OrdinalIgnoreCase);
                    allowScheduleToRun = hasSpecialPrefix;
                }
                if (!allowScheduleToRun)
                {
                    return(null);
                }
                /*************************************/
                DateTime startTime = DateTime.Now;
                // Make sure the transaction has not been processed yet
                if (!forceRun && ((scheduledItem.NextRunOn > startTime) && !isRunNow))
                {
                    LOG.Debug("Exiting ProcessScheduledItem(), schedule {0} has already run",
                              scheduledItem);
                    return(null);
                }

                string flowName = _flowManager.GetDataFlowNameById(scheduledItem.FlowId);
                activity = new Activity(NodeMethod.Schedule, flowName, scheduledItem.Name, ActivityType.Info,
                                        null, NetworkUtils.GetLocalIp(), "Start processing schedule: \"{0}\"",
                                        scheduledItem.Name);
                string transactionId = null;
                try
                {
                    // Make sure the user that created the schedule is still active
                    UserAccount userAccount = _accountManager.GetById(scheduledItem.ModifiedById);
                    if ((userAccount == null) || !userAccount.IsActive)
                    {
                        activity.AppendFormat("The user account that created the scheduled item \"{0}\" is no longer active.  Scheduled item cannot execute.",
                                              scheduledItem.Name);
                        return(null);
                    }
                    activity.ModifiedById = userAccount.Id;

                    scheduledItem.ExecuteStatus = ScheduleExecuteStatus.Running;
                    ScheduleManager.UpdateScheduleStatus(scheduledItem.Id, scheduledItem.ExecuteStatus);

                    transactionId =
                        _transactionManager.CreateTransaction(NodeMethod.Schedule, EndpointVersionType.Undefined,
                                                              scheduledItem.FlowId, scheduledItem.Name, userAccount.Id,
                                                              CommonTransactionStatusCode.Processing,
                                                              null, null, null, false);
                    activity.TransactionId = transactionId;

                    SchedulePostProcessingAction postProcessingAction = SchedulePostProcessingAction.ContinueNormally;

                    switch (scheduledItem.SourceType)
                    {
                    case ScheduledItemSourceType.LocalService:
                        postProcessingAction = ProcessLocalServiceSource(scheduledItem, activity, transactionId);
                        break;

                    case ScheduledItemSourceType.File:
                        ProcessFileSource(scheduledItem, activity, transactionId);
                        break;

                    case ScheduledItemSourceType.WebServiceQuery:
                        ProcessWebServiceQuerySource(scheduledItem, activity, transactionId);
                        break;

                    case ScheduledItemSourceType.WebServiceSolicit:
                        ProcessWebServiceSolicitSource(scheduledItem, activity, transactionId);
                        break;

                    default:
                        throw new ArgumentException(string.Format("Unrecognized scheduledItem.SourceType: {0}",
                                                                  scheduledItem.SourceType));
                    }

                    TransactionStatus transactionStatus = null;
                    if (postProcessingAction != SchedulePostProcessingAction.None)
                    {
                        if (scheduledItem.TargetType != ScheduledItemTargetType.None)
                        {
                            transactionStatus =
                                _transactionManager.SetTransactionStatus(transactionId, CommonTransactionStatusCode.Processed,
                                                                         null, false);
                            switch (scheduledItem.TargetType)
                            {
                            case ScheduledItemTargetType.LocalService:
                                ProcessLocalServiceTarget(transactionStatus, scheduledItem, activity);
                                break;

                            case ScheduledItemTargetType.Email:
                                ProcessEmailTarget(transactionStatus, scheduledItem, activity);
                                break;

                            case ScheduledItemTargetType.File:
                                ProcessFileTarget(transactionStatus, scheduledItem, activity);
                                break;

                            case ScheduledItemTargetType.Partner:
                                ProcessPartnerTarget(transactionStatus, scheduledItem, activity);
                                break;

                            case ScheduledItemTargetType.Schematron:
                                ProcessSchematronTarget(transactionStatus, scheduledItem, activity);
                                break;

                            default:
                                throw new ArgumentException(string.Format("Unrecognized scheduledItem.TargetType: {0}",
                                                                          scheduledItem.TargetType));
                            }
                        }
                    }

                    transactionStatus =
                        _transactionManager.SetTransactionStatus(transactionId, CommonTransactionStatusCode.Completed,
                                                                 null, true);

                    activity.AppendFormat("End processing schedule: \"{0}\", processing duration: {1}",
                                          scheduledItem.Name, TimeSpan.FromTicks(DateTime.Now.Ticks - startTime.Ticks).ToString());
                    activity.AppendFormat("Transaction \"{0}\" status set to \"{1}\"", transactionStatus.Id.ToString(),
                                          transactionStatus.Status.ToString());
                    _notificationManager.DoScheduleNotifications(transactionStatus, scheduledItem.FlowId,
                                                                 scheduledItem.Name);
                    scheduledItem.ExecuteStatus = ScheduleExecuteStatus.CompletedSuccess;
                }
                catch (Exception e)
                {
                    activity.Type = ActivityType.Error;
                    TransactionStatus transactionStatus = null;
                    if (transactionId != null)
                    {
                        transactionStatus =
                            _transactionManager.SetTransactionStatus(transactionId, CommonTransactionStatusCode.Failed,
                                                                     e.Message, true);
                        activity.AppendFormat("Transaction \"{0}\" status set to \"{1}\"", transactionStatus.Id.ToString(),
                                              transactionStatus.Status.ToString());
                    }
                    LogActivityError(activity, ExceptionUtils.ToShortString(e));
                    LOG.Error("ProcessTransactionRequest() threw an exception.", e);
                    if (transactionId != null)
                    {
                        _notificationManager.DoScheduleNotifications(transactionStatus, scheduledItem.FlowId,
                                                                     scheduledItem.Name,
                                                                     "Error: " + ExceptionUtils.GetDeepExceptionMessageOnly(e));
                    }
                    scheduledItem.ExecuteStatus = ScheduleExecuteStatus.CompletedFailure;
                }
                finally
                {
                    ActivityManager.Log(activity);
                    UpdateScheduleRunInfo(scheduledItem, activity);
                }
                return(scheduledItem);
            }
        }