private void RecordError(string method, string message1, Exception ex)
 {
     using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
     {
         int    col_len = 2500;
         string msg     = ex.Message;
         if (msg.Length > col_len)
         {
             msg = msg.Substring(0, col_len);
         }
         string stack_trace = ex.StackTrace;
         if (stack_trace.Length > col_len)
         {
             stack_trace = stack_trace.Substring(0, col_len);
         }
         if (message1.Length > col_len)
         {
             message1 = message1.Substring(0, col_len);
         }
         string          message2 = string.Format("Exception Message: {0}", msg);
         string          message3 = string.Format("Exception Stack Trace: {0}", stack_trace);
         tbl_AppEventLog ael      = new tbl_AppEventLog();
         ael.aelAppName     = "CustomerWebService";
         ael.aelSection     = method;
         ael.aelSeverity    = "ERROR";
         ael.aelEvent       = "Unknown Error";
         ael.aelMessage1    = message1.Length > 2500 ? message1.Substring(0, 2499) : message1;
         ael.aelMessage2    = message2.Length > 2500 ? message2.Substring(0, 2499) : message2;
         ael.aelMessage3    = message3.Length > 2500 ? message3.Substring(0, 2499) : message3;
         ael.aelDateCreated = DateTime.Now;
         context.tbl_AppEventLogs.InsertOnSubmit(ael);
         context.SubmitChanges();
     }
 }
Ejemplo n.º 2
0
        public void LogAppEvent(string user, string app_name, string event_name, string message1, string message2, string message3,
                                string severity, string section)
        {
            try
            {
                SupportClasses.EventLogger logger = new SupportClasses.EventLogger();

                tbl_AppEventLog log_entry = new tbl_AppEventLog(user, app_name,
                                                                event_name, message1,
                                                                message2, message3,
                                                                severity, section);
                log_entry.Save();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void RecordLoginAttempt(string enc_username, string enc_password, ResponseObject response, CustomerResponseCode response_code)
        {
            string u = response.ResponseCode == (int)CustomerResponseCode.CANNOT_DECRYPT_INPUT ? string.Empty : Cryptography.Decrypt256FromHEX(enc_username);

            using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
            {
                tbl_AppEventLog ael = new tbl_AppEventLog();
                ael.aelUserName    = u;
                ael.aelSection     = "Login";
                ael.aelAppName     = "CustomerWebService";
                ael.aelSeverity    = response.ResponseCode > 0 ? "ERROR" : "INFO";
                ael.aelEvent       = response.ResponseCode == (int)CustomerResponseCode.SUCCESS ? "LOGIN_SUCCEEDED" : "LOGIN_FAILED";
                ael.aelMessage1    = string.Format("U:{0} P:{1}", new object[] { enc_username, enc_password });
                ael.aelMessage2    = string.Format(response_code.ToString());
                ael.aelDateCreated = DateTime.Now;
                context.tbl_AppEventLogs.InsertOnSubmit(ael);
                context.SubmitChanges();
            }
        }
        //string optin, string fax, string altcity,string giftoptin, string giftfax, string giftaltcity
        private object[] CreateSubscription(string subscriptionlength,
                                            string amountpaid, string verifoneroutingid,
                                            string publicationcode, string keycode,
                                            string renewingmemberid, string salutation, string firstname, string middleinitial, string lastname, string suffix,
                                            string professionaltitle, string email, string businessname, string address1, string address2, string address3,
                                            string city, string state, string postalcode, string country,
                                            string phone,
                                            string giftflag,
                                            string renewinggiftmemberid, string giftsalutation, string giftfirstname, string giftmiddleinitial, string giftlastname, string giftsuffix,
                                            string giftprofessionaltitle, string giftemail, string giftbusinessname, string giftaddress1, string giftaddress2, string giftaddress3,
                                            string giftcity, string giftstate, string giftpostalcode, string giftcountry,
                                            string giftphone,
                                            string iscomp)
        {
            int    response_code = 0;
            string member_id     = string.Empty;

            #region convert string input to correct types

            bool is_comp = false;
            if (!bool.TryParse(iscomp, out is_comp))
            {
                is_comp = false;
            }
            int   i_subscriptionlength = 0;
            float f_amountpaid         = 0.0f;
            bool  b_optin     = false;
            bool  b_giftflag  = false;
            bool  b_giftoptin = false;

            if (!int.TryParse(subscriptionlength, out i_subscriptionlength))
            {
                response_code = 401;
            }
            if (!float.TryParse(amountpaid, out f_amountpaid))
            {
                response_code = 402;
            }

            /*if (!bool.TryParse(optin, out b_optin))
             * {
             *  response_code = 403;
             * }*/
            if (!string.IsNullOrEmpty(giftflag))
            {
                if (!bool.TryParse(giftflag, out b_giftflag))
                {
                    response_code = 404;
                }

                /*if (!bool.TryParse(giftoptin, out b_giftoptin))
                 * {
                 *  response_code = 405;
                 * }*/
            }
            #endregion

            if (response_code == 0)
            {
                #region set member data
                Member memberData = new Member();
                memberData.MemberId          = renewingmemberid;
                memberData.Salutation        = salutation;
                memberData.FirstName         = firstname;
                memberData.MiddleInitial     = middleinitial;
                memberData.LastName          = lastname;
                memberData.Suffix            = suffix;
                memberData.ProfessionalTitle = professionaltitle;
                memberData.OptIn             = b_optin;
                memberData.Email             = email;

                memberData.Address = new Address();
                memberData.Address.BusinessName = businessname;
                memberData.Address.Address1     = address1;
                memberData.Address.Address2     = address2;
                memberData.Address.Address3     = address3;
                memberData.Address.City         = city;
                memberData.Address.State        = state;
                memberData.Address.PostalCode   = postalcode;
                memberData.Address.Country      = country;
                memberData.Address.Phone        = phone;
                //memberData.Address.Fax = fax;
                //memberData.Address.AltCity = altcity;

                Member giftData = new Member();
                if (b_giftflag)
                {
                    giftData.MemberId          = renewinggiftmemberid;
                    giftData.Salutation        = salutation;
                    giftData.FirstName         = firstname;
                    giftData.MiddleInitial     = middleinitial;
                    giftData.LastName          = lastname;
                    giftData.Suffix            = suffix;
                    giftData.ProfessionalTitle = professionaltitle;
                    giftData.OptIn             = b_giftoptin;
                    giftData.Email             = email;

                    giftData.Address = new Address();
                    giftData.Address.BusinessName = businessname;
                    giftData.Address.Address1     = address1;
                    giftData.Address.Address2     = address2;
                    giftData.Address.Address3     = address3;
                    giftData.Address.City         = city;
                    giftData.Address.State        = state;
                    giftData.Address.PostalCode   = postalcode;
                    giftData.Address.Country      = country;
                    giftData.Address.Phone        = phone;
                    //giftData.Address.Fax = fax;
                    //giftData.Address.AltCity = altcity;
                }
                #endregion

                #region set cc data
                CreditCard creditCardData = new CreditCard();
                creditCardData.Price             = f_amountpaid;
                creditCardData.AmountPaid        = f_amountpaid;
                creditCardData.VerifoneRoutingId = verifoneroutingid;

                if (is_comp)
                {
                    creditCardData.PaymentType = "F";
                }
                #endregion

                SubscriptionServiceRequest request = new SubscriptionServiceRequest(memberData, giftData,
                                                                                    creditCardData, publicationcode, keycode, b_giftflag, i_subscriptionlength);
                BaseResponse sub_response = SubOrderInsert.CreateSubscription(request);
                if (sub_response == null || sub_response.TypedResponse == null || sub_response.TypedResponse.Success == false)
                {
                    string msgs = string.Empty;
                    foreach (Message s in sub_response.Messages)
                    {
                        msgs += "[" + s.ToString() + "]";
                    }
                    tbl_AppEventLog logmsg = new tbl_AppEventLog();
                    logmsg.aelAppName     = "HarperSERVICE";
                    logmsg.aelDateCreated = DateTime.Now;
                    logmsg.aelEvent       = "406";
                    logmsg.aelMessage1    = "sub_response messages:" + msgs;
                    logmsg.aelMessage2    = "typed response:" + sub_response.TypedResponse.ToString();
                    logmsg.aelMessage3    = "success:" + sub_response.TypedResponse.Success;
                    logmsg.Save();
                    response_code = 406;
                }
                else
                {
                    member_id = ((SubscriptionServiceResponse)sub_response.TypedResponse).MemberId;
                }
            }
            return(new object[] { response_code, member_id });
        }
        //string optin,string fax,string altcity,
        private object[] ChargeCard(string memberid, string salutation, string firstname, string middleinitial, string lastname, string suffix,
                                    string professionaltitle, string email, string businessname, string address1, string address2, string address3,
                                    string city, string state, string postalcode, string country,
                                    string phone,
                                    string ccnumber, string expmonth, string expyear, string amount,
                                    string ccname, string ccaddr, string cccity,
                                    string ccstate, string cczip, string cccountry, string pubcode, string username, string password, string refreshcustomer)
        {
            int    response_code = 0;
            string routing_id    = string.Empty;
            string auth_code     = string.Empty;

            #region convert string input to correct types
            bool  b_optin           = false;
            short s_expmonth        = 0;
            short s_expyear         = 0;
            float f_amount          = 0.0f;
            bool  b_refreshcustomer = false;

            /*if (!bool.TryParse(optin, out b_optin))
             * {
             *  response_code = 301;
             * }*/
            if (!short.TryParse(expmonth, out s_expmonth))
            {
                response_code = 302;
            }
            if (!short.TryParse(expyear, out s_expyear))
            {
                response_code = 303;
            }
            if (!float.TryParse(amount, out f_amount))
            {
                response_code = 304;
            }
            if (!bool.TryParse(refreshcustomer, out b_refreshcustomer))
            {
                response_code = 305;
            }
            #endregion

            if (response_code == 0)
            {
                #region validate input
                Member memberData = new Member();
                memberData.MemberId          = memberid;
                memberData.Salutation        = salutation;
                memberData.FirstName         = firstname;
                memberData.MiddleInitial     = middleinitial;
                memberData.LastName          = lastname;
                memberData.Suffix            = suffix;
                memberData.ProfessionalTitle = professionaltitle;
                //memberData.OptIn = b_optin;
                memberData.Email = email;

                memberData.Address = new Address();
                memberData.Address.BusinessName = businessname;
                memberData.Address.Address1     = address1;
                memberData.Address.Address2     = address2;
                memberData.Address.Address3     = address3;
                memberData.Address.City         = city;
                memberData.Address.State        = state;
                memberData.Address.PostalCode   = postalcode;
                memberData.Address.Country      = country;
                memberData.Address.Phone        = phone;
                //memberData.Address.Fax = fax;
                //memberData.Address.AltCity = altcity;

                CreditCard ccData = new CreditCard();
                ccData.CCNumber     = ccnumber;
                ccData.CCExpMonth   = s_expmonth;
                ccData.CCExpYear    = s_expyear;
                ccData.AmountPaid   = f_amount;
                ccData.CCName       = ccname;
                ccData.CCAddress    = ccaddr;
                ccData.CCCity       = cccity;
                ccData.CCState      = ccstate;
                ccData.CCPostalCode = cczip;
                ccData.CCCountry    = cccountry;
                #endregion

                CreditCardServiceRequest request     = new CreditCardServiceRequest(ccData, memberData, pubcode, username, password, b_refreshcustomer);
                BaseResponse             cc_response = CreditCardProcessing.GetResponse(request);

                if (cc_response == null || cc_response.TypedResponse == null || cc_response.TypedResponse.Success == false)
                {
                    string msgs = string.Empty;
                    foreach (Message s in cc_response.Messages)
                    {
                        msgs += "[" + s.ToString() + "]";
                    }
                    tbl_AppEventLog logmsg = new tbl_AppEventLog();
                    logmsg.aelAppName     = "HarperSERVICE";
                    logmsg.aelDateCreated = DateTime.Now;
                    logmsg.aelEvent       = "306";
                    logmsg.aelMessage1    = "cc_response messages:" + msgs;
                    logmsg.aelMessage2    = "typed response:" + cc_response.TypedResponse.ToString();
                    logmsg.aelMessage3    = "success:" + cc_response.TypedResponse.Success;
                    logmsg.Save();
                    response_code = 306;
                }
                else
                {
                    routing_id = ((CreditCardServiceResponse)cc_response.TypedResponse).VerifoneRoutingId;
                    auth_code  = ((CreditCardServiceResponse)cc_response.TypedResponse).AuthorizationCode;
                }
            }

            return(new object[] { response_code, routing_id, auth_code });
        }