Exemplo n.º 1
0
        public Exception HandleException(Exception exception, Guid handlingInstanceId)
        {
            var entry = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry(exception.Message, logCategory, 0, 100, TraceEventType.Error, defaultTitle, null);

            foreach (DictionaryEntry dataEntry in exception.Data)
            {
                if (dataEntry.Key is string)
                {
                    entry.ExtendedProperties.Add(dataEntry.Key as string, dataEntry.Value);
                }
            }

            Type[]          types       = new Type[] { typeof(TextWriter), typeof(Exception), typeof(Guid) };
            ConstructorInfo constructor = formatterType.GetConstructor(types);

            using (StringWriter writer = new StringWriter())
            {
                var exceptionFormatter = (ExceptionFormatter)constructor.Invoke(new object[] { writer, exception, handlingInstanceId });
                exceptionFormatter.Format();
                entry.ExtendedProperties.Add("Exception", writer.GetStringBuilder().ToString());
            }

            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(entry);

            return(exception);
        }
Exemplo n.º 2
0
        //private bool Swipe(CreditCard cc)
        //{
        //    return (true); //***EAC This routine is no longer necessary

        //    if (this.cc.Cost > 0.0)
        //    {
        //        string APPROVED = "<ssl_result_message>APPROV";
        //        // string xmldata = "xmldata=<txn><ssl_merchant_ID>502928</ssl_merchant_ID><ssl_user_id>webform</ssl_user_id><ssl_pin>PK0GAL</ssl_pin><ssl_transaction_type>ccsale</ssl_transaction_type><ssl_card_number>5000300020003003</ssl_card_number><ssl_exp_date>1209</ssl_exp_date><ssl_amount>12.3</ssl_amount><ssl_salestax>0.00</ssl_salestax><ssl_cvv2cvc2_indicator>Present</ssl_cvv2cvc2_indicator><ssl_cvv2cvc2>123</ssl_cvv2cvc2><ssl_invoice_number></ssl_invoice_number><ssl_customer_code>0</ssl_customer_code><ssl_first_name></ssl_first_name><ssl_last_name></ssl_last_name><ssl_avs_address>123 mystreet</ssl_avs_address><ssl_address2></ssl_address2><ssl_city></ssl_city><ssl_state></ssl_state><ssl_avs_zip>90210</ssl_avs_zip><ssl_phone></ssl_phone><ssl_email></ssl_email></txn>";
        //        ASCIIEncoding encoding = new ASCIIEncoding();

        //        //***EAC had to do this next 2 lines because of a bug in billto.Addr1.Substring(0,20)
        //        string temp = billto.Addr1;
        //        if (temp.Length > 20) temp = temp.Substring(0, 20);

        //        string postData = "xmldata=<txn><ssl_merchant_ID>502928</ssl_merchant_ID><ssl_user_id>webform</ssl_user_id><ssl_pin>PK0GAL</ssl_pin><ssl_transaction_type>ccsale</ssl_transaction_type><ssl_card_number>" + this.cc.CCnum + "</ssl_card_number><ssl_exp_date>" + this.cc.ExpMon + this.cc.ExpYr + "</ssl_exp_date><ssl_amount>" + this.cc.Cost + "</ssl_amount><ssl_salestax>0.00</ssl_salestax><ssl_cvv2cvc2_indicator>Present</ssl_cvv2cvc2_indicator><ssl_cvv2cvc2>" + this.cc.CVV2 + "</ssl_cvv2cvc2><ssl_invoice_number></ssl_invoice_number><ssl_customer_code>0</ssl_customer_code><ssl_first_name></ssl_first_name><ssl_last_name></ssl_last_name><ssl_avs_address>" + temp + "</ssl_avs_address><ssl_address2></ssl_address2><ssl_city></ssl_city><ssl_state></ssl_state><ssl_avs_zip>" + billto.Zip5 + "</ssl_avs_zip><ssl_phone></ssl_phone><ssl_email></ssl_email></txn>";

        //        byte[] data = encoding.GetBytes(postData);

        //        // Prepare web request...
        //        HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("https://www.myvirtualmerchant.com/VirtualMerchant/processxml.do");
        //        myRequest.Method = "POST";
        //        myRequest.ContentType = "application/x-www-form-urlencoded";
        //        myRequest.ContentLength = data.Length;
        //        Stream newStream = myRequest.GetRequestStream();
        //        // Send the data.
        //        newStream.Write(data, 0, data.Length);
        //        newStream.Close();

        //        HttpWebResponse resp = (HttpWebResponse)myRequest.GetResponse();
        //        Encoding enc = System.Text.Encoding.GetEncoding(1252);
        //        StreamReader respstr = new StreamReader(resp.GetResponseStream(), enc);
        //        string RESP = respstr.ReadToEnd();
        //        resp.Close();
        //        respstr.Close();

        //        PubEnt.DAL.DAL.SaveCCResponse(RESP);
        //        if (RESP.Contains(APPROVED))
        //        {
        //            //***EAC get CC Transaction ID
        //            int i = RESP.IndexOf("<ssl_txn_id>");
        //            int j = RESP.IndexOf("</ssl_txn_id>");
        //            this.cc.TransID = RESP.Substring(i + 12, j - i - 12);

        //            //***EAC get CC Transaction ID
        //            i = RESP.IndexOf("<ssl_approval_code>");
        //            j = RESP.IndexOf("</ssl_approval_code>");
        //            this.cc.ApprovalCode = RESP.Substring(i + 19, j - i - 19);

        //            return (true);
        //        }
        //        else
        //        {
        //            return (false);
        //        }
        //    }
        //    else return (true); //free transaction
        //}
        #endregion

        public void USPS(Person p)
        {
            string    returnValue, XmlString;
            WebClient instance = new WebClient();

            XmlString = "<AddressValidateRequest USERID=\"USER\"><Address ID=\"0\"> <Address1>" + p.Addr2 + "</Address1> <Address2>" + p.Addr1 + "</Address2> <City>" + p.City + "</City> <State>" + p.State + "</State> <Zip5></Zip5> <Zip4></Zip4></Address> </AddressValidateRequest>";
            Uri        siteUri = new Uri("http://production.shippingapis.com/ShippingAPI.dll?API=Verify&XML=" + XmlString.Replace("&", "%20"));
            WebRequest wr      = WebRequest.Create(siteUri);

            //returnValue = instance.DownloadString(siteUri);
            btn2Submit.Enabled      = true;
            lblAVS_Shipping.Visible = false;
            try
            {
                returnValue = instance.DownloadString(siteUri);
                XmlDocument XmlDoc = new XmlDocument();
                XmlDoc.LoadXml(returnValue);

                if (returnValue.Contains("Error"))                                                                                                                                                                         //***EAC HITT 8227 overrode all previous tickets.
                {
                    lblAVS_Shipping.Text    = "We did not find this shipping address in the U.S. Postal Service’s database. To ensure proper delivery, please review the address carefully before submitting your order."; // node.InnerText;
                    lblAVS_Shipping.Visible = true;
                }
            }
            catch (Exception ex)
            {
                //***EAC ignore problems w/ AVS

                //Write to log
                Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry logEnt = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry();
                logEnt.Message = "\r\n" + "USPS Address Verification error." + "\r\n" + "Source: " + ex.Source + "\r\n" + "Description: " + ex.Message + "\r\n" + "Stack Trace: " + ex.StackTrace;
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(logEnt, "Logs");
            }
        }
Exemplo n.º 3
0
        public static void Start()
        {
            string configurationFilepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Quartz.config");

            var configurationFileMap = new ExeConfigurationFileMap {
                ExeConfigFilename = configurationFilepath
            };
            var configuration = ConfigurationManager.OpenMappedExeConfiguration(configurationFileMap, ConfigurationUserLevel.None);

            System.Xml.XmlDocument sectionXmlDocument = new System.Xml.XmlDocument();
            sectionXmlDocument.Load(new StringReader(configuration.GetSection("quartz").SectionInformation.GetRawXml()));
            NameValueSectionHandler handler = new NameValueSectionHandler();

            var quartzProperties = (NameValueCollection)handler.Create(null, null, sectionXmlDocument.DocumentElement);

            LogProvider.SetCurrentLogProvider(new Areas.CmsAdmin.Scheduler.EntLibLogProvider());

            var logEntiry = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry();

            logEntiry.Title    = "Scheduler Event";
            logEntiry.Severity = System.Diagnostics.TraceEventType.Start;
            logEntiry.Message  = "Restart the scheduler has been completed";
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(logEntiry);

            IUnityContainer unityContainer = new UnityContainer();

            ConfigUnityContainer(unityContainer);
            unityContainer.AddExtension(new QuartzUnityExtension(quartzProperties));
            unityContainer.Resolve <IScheduler>().Start();
        }
Exemplo n.º 4
0
        protected void UPS(Person p)
        {
            btn2Submit.Enabled      = true;
            lblAVS_Shipping.Visible = false;
            try
            {
                UPSAddressValidation.XAVService  xavSvc     = new UPSAddressValidation.XAVService();
                UPSAddressValidation.XAVRequest  xavRequest = new UPSAddressValidation.XAVRequest();
                UPSAddressValidation.UPSSecurity upss       = new UPSAddressValidation.UPSSecurity();
                UPSAddressValidation.UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSAddressValidation.UPSSecurityServiceAccessToken();
                upssSvcAccessToken.AccessLicenseNumber = ConfigurationManager.AppSettings["UPSAccessLicenseNumber"];
                upss.ServiceAccessToken = upssSvcAccessToken;
                UPSAddressValidation.UPSSecurityUsernameToken upssUsrNameToken = new UPSAddressValidation.UPSSecurityUsernameToken();
                upssUsrNameToken.Username = ConfigurationManager.AppSettings["UPSUserName"];
                upssUsrNameToken.Password = ConfigurationManager.AppSettings["UPSPassword"];
                upss.UsernameToken        = upssUsrNameToken;
                xavSvc.UPSSecurityValue   = upss;
                UPSAddressValidation.RequestType request = new UPSAddressValidation.RequestType();

                //Below code contains dummy data for reference. Please update as required.
                String[] requestOption = { "1" };//***EAC 1 - Address Validation 2 - Address Classification 3 - Address Validation and Address Classification.
                request.RequestOption = requestOption;
                xavRequest.Request    = request;
                UPSAddressValidation.AddressKeyFormatType addressKeyFormat = new UPSAddressValidation.AddressKeyFormatType();
                String[] addressLine = { p.Addr1, p.Addr2, "" };
                addressKeyFormat.AddressLine   = addressLine;
                addressKeyFormat.ConsigneeName = "dummy";                  //***EAC seems unused

                addressKeyFormat.PoliticalDivision2              = p.City;
                addressKeyFormat.PoliticalDivision1              = p.State;
                addressKeyFormat.PostcodePrimaryLow              = p.Zip5;
                addressKeyFormat.PostcodeExtendedLow             = p.Zip4;
                addressKeyFormat.CountryCode                     = "US";
                xavRequest.AddressKeyFormat                      = addressKeyFormat;
                System.Net.ServicePointManager.CertificatePolicy = new PubEnt.UPS.TrustAllCertificatePolicy();
                UPSAddressValidation.XAVResponse xavResponse = xavSvc.ProcessXAV(xavRequest);

                if (xavResponse.ItemElementName != UPSAddressValidation.ItemChoiceType.ValidAddressIndicator)   //***EAC TODO: if (xavResponse.says_address_is bad  ValidAddressIndicator, AmbiguousAddressIndicator
                {
                    lblAVS_Shipping.Text    = "Address Not Found (UPS)";
                    btn2Submit.Enabled      = false;
                    lblAVS_Shipping.Visible = true;
                }
                else
                {
                    lblAVS_Shipping.Text    = "SUCCESS";
                    btn2Submit.Enabled      = true;
                    lblAVS_Shipping.Visible = false;
                }
            }

            catch (Exception ex)
            {
                //Write to log
                Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry logEnt = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry();
                logEnt.Message = "\r\n" + "UPS Address Verification error." + "\r\n" + "Source: " + ex.Source + "\r\n" + "Description: " + ex.Message + "\r\n" + "Stack Trace: " + ex.StackTrace;
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(logEnt, "Logs");
            }
        }
Exemplo n.º 5
0
 public static void Error(string message)
 {
     if (_IsErrorEnabled)
     {
         LogEntry ev = new LogEntry(message, _Categories, 1, 100, TraceEventType.Error, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 6
0
 public static void Error(object obj)
 {
     if (_IsErrorEnabled)
     {
         LogEntry ev = new LogEntry(obj, _Categories, 1, 100, TraceEventType.Error, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 7
0
 public static void Trace(string message)
 {
     if (_IsTraceEnabled)
     {
         LogEntry ev = new LogEntry(message, _Categories, 5, 100, TraceEventType.Transfer, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 8
0
 public static void Warn(string message)
 {
     if (_IsWarnEnabled)
     {
         LogEntry ev = new LogEntry(message, _Categories, 2, 100, TraceEventType.Warning, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 9
0
 public static void Fatal(object obj)
 {
     if (_IsFatalEnabled)
     {
         LogEntry ev = new LogEntry(obj, _Categories, 0, 100, TraceEventType.Critical, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 10
0
 public static void Debug(string message)
 {
     if (_IsDebugEnabled)
     {
         LogEntry ev = new LogEntry(message, _Categories, 4, 100, TraceEventType.Verbose, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 11
0
 public static void Debug(object obj)
 {
     if (_IsDebugEnabled)
     {
         LogEntry ev = new LogEntry(obj, _Categories, 4, 100, TraceEventType.Verbose, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 12
0
 public static void Fatal(string message)
 {
     if (_IsFatalEnabled)
     {
         LogEntry ev = new LogEntry(message, _Categories, 0, 100, TraceEventType.Critical, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 13
0
 public static void Info(string message)
 {
     if (_IsInfoEnabled)
     {
         LogEntry ev = new LogEntry(message, _Categories, 3, 100, TraceEventType.Information, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 14
0
 public static void Trace(object obj)
 {
     if (_IsTraceEnabled)
     {
         LogEntry ev = new LogEntry(obj, _Categories, 5, 100, TraceEventType.Transfer, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 15
0
 public static void Info(object obj)
 {
     if (_IsInfoEnabled)
     {
         LogEntry ev = new LogEntry(obj, _Categories, 3, 100, TraceEventType.Information, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 16
0
 public static void Trace(string message, ulong argument)
 {
     if (_IsTraceEnabled)
     {
         string   msg = string.Format(message, argument);
         LogEntry ev  = new LogEntry(msg, _Categories, 5, 100, TraceEventType.Transfer, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 17
0
 public static void Error(string message, object arg1, object arg2)
 {
     if (_IsErrorEnabled)
     {
         string   msg = string.Format(message, arg1, arg2);
         LogEntry ev  = new LogEntry(msg, _Categories, 1, 100, TraceEventType.Error, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 18
0
 public static void Debug(string message, object arg1, object arg2, object arg3)
 {
     if (_IsDebugEnabled)
     {
         string   msg = string.Format(message, arg1, arg2, arg3);
         LogEntry ev  = new LogEntry(message, _Categories, 4, 100, TraceEventType.Verbose, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 19
0
 public static void Fatal(string message, bool argument)
 {
     if (_IsFatalEnabled)
     {
         string   msg = string.Format(message, argument);
         LogEntry ev  = new LogEntry(msg, _Categories, 0, 100, TraceEventType.Critical, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 20
0
 public static void Info(string message, params object[] args)
 {
     if (_IsInfoEnabled)
     {
         string   msg = string.Format(message, args);
         LogEntry ev  = new LogEntry(msg, _Categories, 3, 100, TraceEventType.Information, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 21
0
 public static void Warn(string message, object arg1, object arg2, object arg3)
 {
     if (_IsWarnEnabled)
     {
         string   msg = string.Format(message, arg1, arg2, arg3);
         LogEntry ev  = new LogEntry(msg, _Categories, 2, 100, TraceEventType.Warning, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 22
0
 public static void Create(string message, bool isSuccess)
 {
     Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry logEntry = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry();
     logEntry.Categories.Add("DataAccess");
     logEntry.Categories.Add(isSuccess ? "Sukces" : "B³¹d");
     logEntry.EventId  = 1;
     logEntry.Priority = 1;
     logEntry.Message  = message;
     Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(logEntry);
 }
Exemplo n.º 23
0
 public static void InfoException(string message, Exception exception)
 {
     if (_IsInfoEnabled)
     {
         ExceptionFormatter formater = new ExceptionFormatter();
         string             msg      = formater.GetMessage(new LoggingException(message, exception));
         LogEntry           ev       = new LogEntry(msg, _Categories, 3, 100, TraceEventType.Information, "", null);
         LoggerImp.Writer.Write(ev);
     }
 }
Exemplo n.º 24
0
        public static void Shutdown()
        {
            ServiceContainer.Current.Resolve <IScheduler>().Shutdown();

            var logEntiry = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry();

            logEntiry.Title    = "Scheduler Event";
            logEntiry.Severity = System.Diagnostics.TraceEventType.Stop;
            logEntiry.Message  = "The scheduler has stopped";
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(logEntiry);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Writes trace information, a data object and event information to the listener specific output.
        /// </summary>
        /// <param name="eventCache">A TraceEventCache object that contains the current process ID, thread ID, and stack trace information.</param>
        /// <param name="source">A name used to identify the output, typically the name of the application that generated the trace event.</param>
        /// <param name="eventType">One of the TraceEventType values specifying the type of event that has caused the trace.</param>
        /// <param name="id">A numeric identifier for the event.</param>
        /// <param name="data">The trace data to emit.</param>
        public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
        {
            // Extract log entry from data parameter
            LogEntry logEntry = data as LogEntry;

            if (logEntry != null)
            {
                TraceEvent(TraceEventRecord.Create(logEntry));
            }
            else
            {
                base.TraceData(eventCache, source, eventType, id, data);
            }
        }
Exemplo n.º 26
0
        private void tmrHeartBeat_Tick(object sender, EventArgs e)
        {
            try
            {
                //diagnosticClient.HeartBeat(this.TerminalId, "");
            }
            catch (Exception ex)
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry log = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry()
                {
                    Title   = "GeneralExceptions",
                    Message = ex.Message
                };

                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.ShouldLog(log);
            }
        }
Exemplo n.º 27
0
        public void GeneralExceptions(string Category, System.Diagnostics.TraceEventType Severity, Exception ErrorCondition)
        {
            try
            {
                diagnosticClient.ServiceError(TerminalId, Category, Severity, ErrorCondition.Message);
            }
            // Damage Control Damaged
            catch (FaultException ex)
            {
                Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry log = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry()
                {
                    Title   = "GeneralExceptions",
                    Message = ex.Message
                };

                //Microsoft.Practices.EnterpriseLibrary.Logging.Logger.ShouldLog(log);
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Writes a new entry to the system log
        /// Other methods are used as some sort of overload fro different logging usages
        /// </summary>
        /// <param name="logType"></param>
        /// <param name="methodName"></param>
        /// <param name="text"></param>
        /// <param name="objectType"></param>
        /// <param name="xml"></param>
        public static void AddNewLog(TraceEventType logType, string methodName, string text, string objectType, string xml)
        {
            Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry ent = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry();
            ent.ActivityId = BrokerContext.Current.ActivityId;
            ent.Categories.Add(Constants.Logging.Category);
            ent.Message           = text;
            ent.RelatedActivityId = null;
            ent.Severity          = logType;

            // Unused properties
            //ent.EventId = ;
            //ent.ManagedThreadName = ;
            //ent.Priority = ;
            //ent.Title = ;

            // TODO: Extended properties cause a problem

            Dictionary <string, object> extendedProperties = ent.ExtendedProperties as Dictionary <string, object>;

            extendedProperties[Constants.Logging.ApplicationId]    = BrokerContext.Current.ApplicationId;
            extendedProperties[Constants.Logging.ApplicationName]  = BrokerContext.Current.ApplicationName;
            extendedProperties[Constants.Logging.ApplicationToken] = BrokerContext.Current.ApplicationToken;
            extendedProperties[Constants.Logging.UserToken]        = BrokerContext.Current.UserToken;
            extendedProperties[Constants.Logging.UserName]         = BrokerContext.Current.UserName;
            extendedProperties[Constants.Logging.MethodName]       = methodName;
            extendedProperties[Constants.Logging.DataObjectType]   = objectType;
            extendedProperties[Constants.Logging.DataObjectXml]    = xml;

            var keys = extendedProperties.Keys.ToArray();

            foreach (var key in keys)
            {
                if (extendedProperties[key] == null)
                {
                    extendedProperties[key] = "";
                }
            }

            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(ent);
        }
Exemplo n.º 29
0
        // Methods
        static Logger()
        {
            if (LoggerImp.IsLoggingEnabled())
            {
                _Categories = new List <string>();
                _Categories.Add("General");

                LogEntry ev = new LogEntry();
                ev.EventId    = 100;
                ev.Categories = _Categories;

                ev.Severity     = TraceEventType.Critical;
                ev.Priority     = 0;
                _IsFatalEnabled = LoggerImp.ShouldLog(ev);

                ev.Severity     = TraceEventType.Error;
                ev.Priority     = 1;
                _IsErrorEnabled = LoggerImp.ShouldLog(ev);

                ev.Severity    = TraceEventType.Warning;
                ev.Priority    = 2;
                _IsWarnEnabled = LoggerImp.ShouldLog(ev);

                ev.Severity    = TraceEventType.Information;
                ev.Priority    = 3;
                _IsInfoEnabled = LoggerImp.ShouldLog(ev);

                ev.Severity     = TraceEventType.Verbose;
                ev.Priority     = 4;
                _IsDebugEnabled = LoggerImp.ShouldLog(ev);

                ev.Severity     = TraceEventType.Transfer;
                ev.Priority     = 5;
                _IsTraceEnabled = LoggerImp.ShouldLog(ev);
            }
        }
Exemplo n.º 30
0
        protected void FEDEX(Person p)
        {
            string straddress2 = p.Addr1;
            string strzipcode  = p.Zip5;
            string address     = string.Empty;
            string zipfour     = string.Empty;
            string ststate     = string.Empty;
            string zip         = string.Empty;

            string[] split    = null;
            string   delimStr = "-";

            char[] delimiter = delimStr.ToCharArray();
            btn2Submit.Enabled      = true;
            lblAVS_Shipping.Visible = false;

            AddressValidationRequest request = CreateAddressValidationRequest(straddress2, strzipcode);
            //
            AddressValidationService addressValidationService = new AddressValidationService();

            //
            try
            {
                // This is the call to the web service passing in an AddressValidationRequest and returning an AddressValidationReply
                AddressValidationReply reply = addressValidationService.addressValidation(request);
                //
                int score = Convert.ToInt32(reply.AddressResults[0].ProposedAddressDetails[0].Score);
                if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING)
                {
                    foreach (AddressValidationResult result in reply.AddressResults)
                    {
                        foreach (ProposedAddressDetail detail in result.ProposedAddressDetails)
                        {
                            address = detail.Address.StreetLines[0];
                            zip     = detail.Address.PostalCode;
                            split   = zip.Split(delimiter);
                            zip     = split[0];
                            //zipfour = split[1];
                        }
                        if (score < 20)//(split.Length<2) (zipfour == null || zipfour.Length < 4)
                        {
                            lblAVS_Shipping.Text    = "Address Not Found (FedEx)";
                            btn2Submit.Enabled      = false;
                            lblAVS_Shipping.Visible = true;
                        }
                        else
                        {
                            lblAVS_Shipping.Text    = "SUCCESS";
                            btn2Submit.Enabled      = true;
                            lblAVS_Shipping.Visible = false;
                        }
                    }
                }
                else
                {
                    foreach (Notification notification in reply.Notifications)
                    {
                        lblAVS_Shipping.Text = notification.Message;
                    }
                }
            }
            catch (Exception ex)
            {
                //yma add this since fedex return exception when no valid address found
                lblAVS_Shipping.Text    = "Address Not Found (FedEx)";
                btn2Submit.Enabled      = false;
                lblAVS_Shipping.Visible = true;

                //Write to log
                Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry logEnt = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry();
                logEnt.Message = "\r\n" + "FedEx Address Verification error." + "\r\n" + "Source: " + ex.Source + "\r\n" + "Description: " + ex.Message + "\r\n" + "Stack Trace: " + ex.StackTrace;
                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(logEnt, "Logs");
            }
        }