示例#1
0
文件: Program.cs 项目: aakashptl/WSDL
        static void Main(string[] args)
        {
            /************************************Login***************************************************/
            WsLoginClient bOSLogin2 = new WsLoginClient();

            UserLogin2Request loginRequest = new UserLogin2Request
            {
                AWorkstationAK = "VTA.WKS19",
                AUserName      = "******",
                APassword      = "******"
            };

            UserLogin2Response response = bOSLogin2.UserLogin2(loginRequest);

            string login_response = response.@return;

            Console.WriteLine(login_response);


            goto Event;
            //goto Performance;
            //goto Save;
            //goto B2B;
            //goto Checkout;
            //goto Close;
            //goto Print;
            //goto Logout;

            /************************************Event***************************************************/

Event:

            WsAPIEventClient bosEvent = new WsAPIEventClient();

            FindAllEventsRequest  eventsRequest  = new FindAllEventsRequest();
            FindAllEventsResponse eventsResponse = bosEvent.FindAllEvents(eventsRequest);

            FINDALLEVENTSRESP fINDALLEVENTSRESP = eventsResponse.@return;

            string event_response = fINDALLEVENTSRESP.EVENTLIST.ToString();



            /************************************Performance***************************************************/

Performance:

            WsAPIPerformanceClient wsAPIPerformanceClient = new WsAPIPerformanceClient();

            SEARCHPERFORMANCEREQ sEARCHPERFORMANCEREQ = new SEARCHPERFORMANCEREQ();

            sEARCHPERFORMANCEREQ.EVENTAK  = "VTA.EVN3";
            sEARCHPERFORMANCEREQ.SELLABLE = true;
            SearchPerformanceRequest searchPerformanceRequest = new SearchPerformanceRequest(sEARCHPERFORMANCEREQ);

            SearchPerformanceResponse searchPerformanceResponse = wsAPIPerformanceClient.SearchPerformance(searchPerformanceRequest);

            SEARCHPERFORMANCERESP sEARCHPERFORMANCERESP = searchPerformanceResponse.@return;

            string performance_response = sEARCHPERFORMANCERESP.PERFORMANCELIST.ToString();


            /************************************Save account***************************************************/

Save:
            WsAPIAccountClient wsAPIAccountClient = new WsAPIAccountClient();


            Accounts.FIELDLISTFIELD[] fIELDLISTFIELDs = new Accounts.FIELDLISTFIELD[3];

            Accounts.FIELDLISTFIELD fIELDLISTFIELD1 = new Accounts.FIELDLISTFIELD();
            fIELDLISTFIELD1.OBJTYPE = 1;
            fIELDLISTFIELD1.VALUE   = "ironman";//firstname

            Accounts.FIELDLISTFIELD fIELDLISTFIELD2 = new Accounts.FIELDLISTFIELD();
            fIELDLISTFIELD2.OBJTYPE = 548;
            fIELDLISTFIELD2.VALUE   = "tony1234";//firstname


            Accounts.FIELDLISTFIELD fIELDLISTFIELD3 = new Accounts.FIELDLISTFIELD();
            fIELDLISTFIELD3.OBJTYPE = 549;
            fIELDLISTFIELD3.VALUE   = "avengers";//firstname



            fIELDLISTFIELDs[0] = fIELDLISTFIELD1;
            fIELDLISTFIELDs[1] = fIELDLISTFIELD2;
            fIELDLISTFIELDs[2] = fIELDLISTFIELD3;

            SAVEACCOUNTREQ sAVEACCOUNTREQ = new SAVEACCOUNTREQ
            {
                FIELDLIST     = fIELDLISTFIELDs,
                DMGCATEGORYAK = "VTA.DMGCAT29"
            };
            SaveAccountRequest saveAccountRequest = new SaveAccountRequest(sAVEACCOUNTREQ);

            SaveAccountResponse saveAccountResponse = wsAPIAccountClient.SaveAccount(saveAccountRequest);

            SAVEACCOUNTRESP sAVEACCOUNTRESP = saveAccountResponse.@return;

            string save_response = sAVEACCOUNTRESP.BASICINFO.ACCOUNTAK;

            /************************************B2B Login***************************************************/


B2B:
            B2BAccountLogInRequest b2BAccountLogInRequest = new B2BAccountLogInRequest
            {
                ADmgCatCode = "Guests",
                AUsername   = "******",
                APsw        = "Iambatma"
            };

            B2BAccountLogInResponse b2BAccountLogInResponse = wsAPIAccountClient.B2BAccountLogIn(b2BAccountLogInRequest);

            /************************************Checkout***************************************************/

Checkout:
            WsAPIOrderClient wsAPIOrderClient = new WsAPIOrderClient();


            CHECKOUTREQ cHECKOUTREQ = new CHECKOUTREQ();


            ITEMLISTITEM[] iTEMLISTITEMs = new ITEMLISTITEM[1];

            ITEMLISTITEMPERFORMANCE[] iTEMLISTITEMPERFORMANCEs = new ITEMLISTITEMPERFORMANCE[1];

            iTEMLISTITEMPERFORMANCEs[1].AK = "VTA.EVN4.PRF100";

            iTEMLISTITEMs[1].AK              = "VTA.EVN1.MCC28";
            iTEMLISTITEMs[1].QTY             = "1";
            iTEMLISTITEMs[1].PERFORMANCELIST = iTEMLISTITEMPERFORMANCEs;


            Orders.ACCOUNTSAVEBASE aCCOUNTSAVEBASE = new Orders.ACCOUNTSAVEBASE
            {
                AK = "99901920000019"
            };

            ORDERSTATUS oRDERSTATUS = new ORDERSTATUS
            {
                APPROVED  = true,
                PAID      = true,
                ENCODED   = true,
                VALIDATED = true,
                COMPLETED = true
            };


            RESERVATIONBASE rESERVATIONBASE = new RESERVATIONBASE
            {
                RESERVATIONOWNER = aCCOUNTSAVEBASE
            };

            cHECKOUTREQ.SHOPCART = new SHOPCART
            {
                ITEMLIST    = iTEMLISTITEMs,
                RESERVATION = rESERVATIONBASE,
                FLAG        = oRDERSTATUS
            };


            CheckOutRequest checkOutRequest = new CheckOutRequest(cHECKOUTREQ);

            CheckOutResponse checkOutResponse = wsAPIOrderClient.CheckOut(checkOutRequest);

            CHECKOUTRESP cHECKOUTRESP = checkOutResponse.@return;

            string checkout_response_sale_ak    = cHECKOUTRESP.SALE.AK;
            float  checkout_response_sale_gross = cHECKOUTRESP.SALE.TOTAL.GROSS;



            /************************************Close_order***************************************************/


Close:
            Orders.PAYMENTLISTBASEPAYMENTINFO[] pAYMENTLISTBASEPAYMENTINFOs = new Orders.PAYMENTLISTBASEPAYMENTINFO[1];

            pAYMENTLISTBASEPAYMENTINFOs[1].CODE   = "";
            pAYMENTLISTBASEPAYMENTINFOs[1].AMOUNT = checkout_response_sale_gross;



            CLOSEORDERREQ cLOSEORDERREQ = new CLOSEORDERREQ {
                AK = checkout_response_sale_ak,
                PAYMENTINFOLIST = pAYMENTLISTBASEPAYMENTINFOs,
            };

            CloseOrderRequest  closeOrderRequest  = new CloseOrderRequest(cLOSEORDERREQ);
            CloseOrderResponse closeOrderResponse = wsAPIOrderClient.CloseOrder(closeOrderRequest);

            CLOSEORDERRESP cLOSEORDERRESP = closeOrderResponse.@return;

            string close_order_sale_ak = cLOSEORDERRESP.SALE.AK;


            /************************************Print Ticket***************************************************/

Print:
            WsAPITicketClient wsAPITicketClient = new WsAPITicketClient();



            PrintPdfTicketRequest printPdfTicketRequest = new PrintPdfTicketRequest {
                ASaleAk = "VTA.WKS19.200527.SAL1" //VTA.WKS19.200527.SAL1
            };

            PrintPdfTicketResponse printPdfTicketResponse = wsAPITicketClient.PrintPdfTicket(printPdfTicketRequest);

            PRINTPDFTICKETRESP pRINTPDFTICKETRESP = printPdfTicketResponse.@return;

            byte[] pdf_string = pRINTPDFTICKETRESP.PDF;


            /************************************Logout***************************************************/

Logout:
            UserLogoutRequest userLogoutRequest = new UserLogoutRequest();

            UserLogoutResponse userLogoutResponse = bOSLogin2.UserLogout(userLogoutRequest);
        }
示例#2
0
        public SaveAccountResponse SaveAccount(SaveAccountRequest request)
        {
            var response = new SaveAccountResponse();

            #region Validation

            if (request.User == null || request.User is AgentUser || request.User is ContactUser)
            {
                response.IsSuccessful = false;
                response.Message = Constants.Messages.NO_PERMISSIONS;
                return response;
            }
            System.Threading.Thread.CurrentPrincipal = request.User.GetUserPrincipal();

            var contact = _contactRepository.GetContactEntity(request.Account.ContactId);
            if (contact == null)
            {
                response.Message = "A valid Contact must be given for this Account";
                return response;
            }

            if (request.Account.Id != null && string.IsNullOrEmpty(request.Account.AccountNumber))
            {
                response.Message = "An Account Number must be given for this Account";
                return response;
            }
            else if (request.Account.Id == null)
            {
                // get account number
                request.Account.AccountNumber = _generator.NextAccountNumber();
                if (string.IsNullOrEmpty(request.Account.AccountNumber))
                {
                    response.Message = "Failed to generate Account Number";
                    return response;
                }
            }

            if (string.IsNullOrEmpty(request.Account.Password))
            {
                response.Message = "A Passwod must be given for this Account";
                return response;
            }

            // Master Accounts Don't need to have Companies.
            //if (request.Account is MasterAccount)
            //{
            //    var master = (MasterAccount)request.Account;
            //    if (!master.CompanyId.HasValue)
            //    {
            //        response.Message = "A Company must be given for this Master Account";
            //        return response;
            //    }
            //    var company = _companyRepository.GetCompany(master.CompanyId.Value);
            //    if (company == null)
            //    {
            //        response.Message = "A valid Company must be given for this Master Account";
            //        return response;
            //    }
            //}

            if (request.Account is SubAccount)
            {
                var sub = (SubAccount)request.Account;
                if (sub.MasterAccountId == 0)
                {
                    response.Message = "This Sub Account must be associated with a parent Master Account";
                    return response;
                }
                else
                {
                    MasterAccount master = (MasterAccount)_accountRepository.GetAccount(sub.MasterAccountId);
                    if (master == null)
                    {
                        response.Message = "A valid Master Account must be given for this Account";
                        return response;
                    }
                }
            }

            // Cannot allow emailing of bill if no email provided on Account Contact
            if (string.IsNullOrEmpty(contact.Email) && (request.Account.EmailBill || request.Account.EmailBillDataFile))
            {
                response.Message = "A contact email must be supplied if recieving paperless bills";
                return response;
            }

            // IF SELECTING PAPERLESS INVOICING/BILLING, AN EMAIL ADDRESS MUST BE SUPPLIED
            if (request.Account.EmailBill && string.IsNullOrEmpty(contact.Email))
            {
                response.Message = "Please ensure an email address is supplied when requesting Invoices to be emailed";
                return response;
            }

            if (request.Account.EmailBillDataFile && string.IsNullOrEmpty(contact.Email))
            {
                response.Message = "Please ensure an email address is supplied when requesting Invoice data to be emailed";
                return response;
            }

            #endregion

            // Ensure HasRequestedInvoice is false.
            // Invoice Requesting is only valid when creating a new contract.
            request.Account.HasRequestedInvoicing = false;

            try
            {
                using (var ts = new TransactionScope())
                {
                    if (request.Account.Id == null)
                    {
                        _accountRepository.InsertAccount(request.Account);
                        if (request.Account.Id != null)
                        {
                            request.Account.LogActivity("New Account Addded");
                            response.IsSuccessful = true;
                            ts.Complete();
                        }
                        else
                        {
                            response.Message = Constants.Messages.INTERNAL_ERROR;
                        }
                    }
                    else
                    {
                        if (_accountRepository.UpdateAccount(request.Account))
                        {
                            request.Account.LogActivity("Account Updated");
                            response.IsSuccessful = true;
                            ts.Complete();
                        }
                        else
                        {
                            response.Message = Constants.Messages.INTERNAL_ERROR;
                        }
                    }
                }
            }
            catch (Exception)
            {
                // TODO: Log the exception
                response.Message = Constants.Messages.INTERNAL_ERROR;
                response.IsSuccessful = false;
            }

            return response;
        }