Example #1
0
        private Address determineCoord(ArrayList mbrs)
        {
            if (mbrs == null || mbrs.Count < 1)
            {
                return(null);
            }

            Address   winner       = null;
            int       max_votecast = 0;
            Hashtable votes        = Hashtable.Synchronized(new Hashtable(11));

            for (int i = 0; i < mbrs.Count; i++)
            {
                PingRsp mbr = (PingRsp)mbrs[i];
                if (mbr.CoordAddress != null)
                {
                    if (!votes.ContainsKey(mbr.CoordAddress))
                    {
                        votes[mbr.CoordAddress] = mbr.HasJoined ? 1000 : 1;
                    }
                    else
                    {
                        int count = ((int)votes[mbr.CoordAddress]);
                        votes[mbr.CoordAddress] = (int)(count + 1);
                    }

                    /// Find the maximum vote cast value. This will be used to resolve a
                    /// tie later on.
                    if (((int)votes[mbr.CoordAddress]) > max_votecast)
                    {
                        max_votecast = ((int)votes[mbr.CoordAddress]);
                    }


                    if ((mbr.OwnAddress.IpAddress.Equals(gms.local_addr.IpAddress)) && (mbr.OwnAddress.Port < gms.local_addr.Port))
                    {
                        gms.Stack.NCacheLog.Debug("pb.ClientGmsImpl.determineCoord()", "WINNER SET TO ACTIVE NODE's Coord = " + Convert.ToString(mbr.CoordAddress));
                        winner = mbr.CoordAddress;
                        break;
                    }
                }
            }

            if (winner == null)
            {
                return(null);
            }
            else
            {
                return(winner);
            }
        }
        protected void TestButton_Click(object sender, EventArgs e)
        {
            TaxCloudProvider provider = (TaxCloudProvider)_TaxGateway.GetProviderInstance();
            PingRsp          result   = provider.Ping(_TaxProvider.ApiId, _TaxProvider.ApiKey);

            TestResultPanel.Visible = true;
            TestResultCode.Text     = result.ResponseType.ToString();
            if (result.Messages != null && result.Messages.Length > 0)
            {
                TestResultMessageLine.Visible = true;
                TestResultMessage.Text        = result.Messages[0].Message;
            }
        }
        static void Main(string[] args)
        {
            //
            // PING REQUEST
            //
            String payload     = "this my payload; there are many like it but this one is mine";
            String someTraceId = "doesntmatter-8176";
            String originApp   = "UAPI";

            //set up the request parameters into a PingReq object
            PingReq req = new PingReq();

            req.Payload = payload;
            req.TraceId = someTraceId;

            BillingPointOfSaleInfo billSetInfo = new BillingPointOfSaleInfo();

            billSetInfo.OriginApplication = originApp;

            req.BillingPointOfSaleInfo = billSetInfo;
            Console.WriteLine(req);



            try {
                //run the ping request
                //WSDLService.sysPing.showXML(true);
                SystemPingPortTypeClient client = new SystemPingPortTypeClient("SystemPingPort1", WsdlService.SYSTEM_ENDPOINT);
                //Console.WriteLine(client.Endpoint);
                client.ClientCredentials.UserName.UserName = Helper.RetrunUsername();
                client.ClientCredentials.UserName.Password = Helper.ReturnPassword();



                var httpHeaders = Helper.ReturnHttpHeader();
                client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));

                PingRsp rsp = client.service(req);
                //print results.. payload and trace ID are echoed back in response
                //Console.WriteLine(rsp.Payload);
                //Console.WriteLine(rsp.TraceId);
                //Console.WriteLine(rsp.TransactionId);

                AirSvcTest airTest = new AirSvcTest();
                airTest.Availability();
            } catch (Exception e) {
                //usually only the error message is useful, not the full stack
                //trace, since the stack trace in is your address space...
                Console.WriteLine("Error : " + e.Message);
            }
        }
Example #4
0
 /// <summary>
 /// In case of PartitionOfReplica this will verify that all the initial memebrs are completely up and running, It will also verify that
 /// the replica of a POR and its phycsical Active counterpart has the same coordinator.
 /// </summary>
 /// <returns>True if ClusterHealth 'seems' ok otherwise false, True also in cas of everyother TOPOLOGY other than POR </returns>
 private bool VerifyInitialembers()
 {
     if (initial_mbrs != null && initial_mbrs.Count > 1)
     {
         for (int i = 0; i < initial_mbrs.Count; i++)
         {
             PingRsp mbr = (PingRsp)initial_mbrs[i];
             for (int j = i + 1; j <= initial_mbrs.Count - (i + 1); j++)
             {
                 PingRsp ReplicaMbr = (PingRsp)initial_mbrs[j];
                 if (mbr.OwnAddress.IpAddress.Equals(ReplicaMbr.OwnAddress.IpAddress) && !mbr.CoordAddress.Equals(ReplicaMbr.CoordAddress))
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
Example #5
0
        /// <summary> Joins this process to a group. Determines the coordinator and sends a unicast
        /// handleJoin() message to it. The coordinator returns a JoinRsp and then broadcasts the new view, which
        /// contains a message digest and the current membership (including the joiner). The joiner is then
        /// supposed to install the new view and the digest and starts accepting mcast messages. Previous
        /// mcast messages were discarded (this is done in PBCAST).<p>
        /// If successful, impl is changed to an instance of ParticipantGmsImpl.
        /// Otherwise, we continue trying to send join() messages to	the coordinator,
        /// until we succeed (or there is no member in the group. In this case, we create our own singleton group).
        /// <p>When GMS.disable_initial_coord is set to true, then we won't become coordinator on receiving an initial
        /// membership of 0, but instead will retry (forever) until we get an initial membership of > 0.
        /// </summary>
        /// <param name="mbr">Our own address (assigned through SET_LOCAL_ADDRESS)
        /// </param>
        public override void  join(Address mbr, bool isStartedAsMirror)
        {
            Address coord            = null;
            Address last_tried_coord = null;
            JoinRsp rsp        = null;
            Digest  tmp_digest = null;

            leaving = false;
            int join_retries = 1;



            join_promise.Reset();
            while (!leaving)
            {
                findInitialMembers();


                gms.Stack.NCacheLog.Debug("pb.ClientGmsImpl.join()", "initial_mbrs are " + Global.CollectionToString(initial_mbrs));
                if (initial_mbrs.Count == 0)
                {
                    if (gms.disable_initial_coord)
                    {
                        gms.Stack.NCacheLog.Debug("pb.ClientGmsImpl.join()", "received an initial membership of 0, but cannot become coordinator (disable_initial_coord=" + gms.disable_initial_coord + "), will retry fetching the initial membership");
                        continue;
                    }
                    gms.Stack.NCacheLog.CriticalInfo("pb.ClientGmsImpl.join()", "no initial members discovered: creating group as first member");

                    becomeSingletonMember(mbr);
                    return;
                }

                coord = determineCoord(initial_mbrs);
                if (coord == null)
                {
                    gms.Stack.NCacheLog.Error("pb.ClientGmsImpl.join()", "could not determine coordinator from responses " + Global.CollectionToString(initial_mbrs));
                    continue;
                }
                if (coord.CompareTo(gms.local_addr) == 0)
                {
                    gms.Stack.NCacheLog.Error("pb.ClientGmsImpl.join()", "coordinator anomaly. More members exist yet i am the coordinator " + Global.CollectionToString(initial_mbrs));

                    ArrayList members = new ArrayList();
                    for (int i = 0; i < initial_mbrs.Count; i++)
                    {
                        PingRsp ping_rsp = (PingRsp)initial_mbrs[i];
                        if (ping_rsp.OwnAddress != null && gms.local_addr != null && !ping_rsp.OwnAddress.Equals(gms.local_addr))
                        {
                            members.Add(ping_rsp.OwnAddress);
                        }
                    }

                    gms.InformOthersAboutCoordinatorDeath(members, coord);

                    if (last_tried_coord == null)
                    {
                        last_tried_coord = coord;
                    }
                    else
                    {
                        if (last_tried_coord.Equals(coord))
                        {
                            join_retries++;
                        }
                        else
                        {
                            last_tried_coord = coord;
                            join_retries     = 1;
                        }
                    }

                    Util.Util.sleep(gms.join_timeout);
                    continue;
                    //becomeSingletonMember(mbr);
                    //return ;
                }

                try
                {
                    gms.Stack.NCacheLog.Debug("pb.ClientGmsImpl.join()", "sending handleJoin(" + mbr + ") to " + coord);

                    if (last_tried_coord == null)
                    {
                        last_tried_coord = coord;
                    }
                    else
                    {
                        if (last_tried_coord.Equals(coord))
                        {
                            join_retries++;
                        }
                        else
                        {
                            last_tried_coord = coord;
                            join_retries     = 1;
                        }
                    }



                    sendJoinMessage(coord, mbr, gms.subGroup_addr, isStartedAsMirror);
                    rsp = (JoinRsp)join_promise.WaitResult(gms.join_timeout);


                    gms._doReDiscovery = false; //block the re-discovery of members as we have found initial members

                    if (rsp == null)
                    {
                        if (join_retries >= gms.join_retry_count)
                        {
                            gms.Stack.NCacheLog.Error("ClientGmsImpl.Join", "received no joining response after " + join_retries + " tries, so becoming a singlton member");
                            becomeSingletonMember(mbr);

                            return;
                        }
                        else
                        {
                            //I did not receive join response, so there is a chance that coordinator is down
                            //Lets verifiy it.
                            if (gms.VerifySuspect(coord, false))
                            {
                                if (gms.Stack.NCacheLog.IsErrorEnabled)
                                {
                                    gms.Stack.NCacheLog.CriticalInfo("ClientGmsImpl.Join()", "selected coordinator " + coord + " seems down; Lets inform others");
                                }
                                //Coordinator is not alive;Lets inform the others
                                ArrayList members = new ArrayList();
                                for (int i = 0; i < initial_mbrs.Count; i++)
                                {
                                    PingRsp ping_rsp = (PingRsp)initial_mbrs[i];

                                    if (ping_rsp.OwnAddress != null && gms.local_addr != null && !ping_rsp.OwnAddress.Equals(gms.local_addr))
                                    {
                                        members.Add(ping_rsp.OwnAddress);
                                    }
                                }
                                gms.InformOthersAboutCoordinatorDeath(members, coord);
                            }
                        }
                        gms.Stack.NCacheLog.Error("ClientGmsImpl.Join()", "handleJoin(" + mbr + ") failed, retrying; coordinator:" + coord + " ;No of retries : " + (join_retries + 1));
                    }
                    else
                    {
                        if (rsp.JoinResult == JoinResult.Rejected)
                        {
                            gms.Stack.NCacheLog.Error("ClientGmsImpl.Join", "joining request rejected by coordinator");
                            becomeSingletonMember(mbr);

                            return;
                        }

                        if (rsp.JoinResult == JoinResult.MembershipChangeAlreadyInProgress)
                        {
                            gms.Stack.NCacheLog.CriticalInfo("Coord.CheckOwnClusterHealth", "Reply: JoinResult.MembershipChangeAlreadyInProgress");
                            Util.Util.sleep(gms.join_timeout);
                            continue;
                        }

                        gms.Stack.NCacheLog.Debug("pb.ClientGmsImpl.join()", "Join successfull");

                        // 1. Install digest
                        tmp_digest = rsp.Digest;
                        if (tmp_digest != null)
                        {
                            tmp_digest.incrementHighSeqno(coord);                             // see DESIGN for an explanantion
                            gms.Stack.NCacheLog.Debug("pb.ClientGmsImpl.join()", "digest is " + tmp_digest);
                            gms.Digest = tmp_digest;
                        }
                        else
                        {
                            gms.Stack.NCacheLog.Error("pb.ClientGmsImpl.join()", "digest of JOIN response is null");
                        }

                        // 2. Install view
                        gms.Stack.NCacheLog.Debug("pb.ClientGmsImpl.join()", "[" + gms.local_addr + "]: JoinRsp=" + rsp.View + " [size=" + rsp.View.size() + "]\n\n");

                        if (rsp.View != null)
                        {
                            if (!installView(rsp.View))
                            {
                                gms.Stack.NCacheLog.Error("pb.ClientGmsImpl.join()", "view installation failed, retrying to join group");
                                continue;
                            }
                            gms.Stack.IsOperational = true;
                            return;
                        }
                        else
                        {
                            gms.Stack.NCacheLog.Error("pb.ClientGmsImpl.join()", "view of JOIN response is null");
                        }
                    }
                }
                catch (System.Exception e)
                {
                    gms.Stack.NCacheLog.Error("ClientGmsImpl.join()", e.Message + ", retrying");
                }

                Util.Util.sleep(gms.join_retry_timeout);
            }
        }
Example #6
0
        /// <summary>The coordinator is determined by a majority vote.
        /// If there are an equal number of votes for more than 1 candidate, we determine the winner randomly.
        ///
        /// This is bad!. I've changed the election process altogether. I guess i'm the new pervez musharaf here
        /// Let everyone cast a vote and unlike the non-deterministic coordinator selection process of jgroups. Ours
        /// is a deterministic one. First we find members with most vote counts. If there is a tie member with lowest
        /// IP addres wins, if there is tie again member with low port value wins.
        ///
        /// This algortihm is determistic and ensures same results on every node icluding the coordinator. (shoaib)
        /// </summary>
        internal virtual Address determineCoord(ArrayList mbrs)
        {
            if (mbrs == null || mbrs.Count < 1)
            {
                return(null);
            }

            Address   winner       = null;
            int       max_votecast = 0;
            Hashtable votes        = Hashtable.Synchronized(new Hashtable(11));

            for (int i = 0; i < mbrs.Count; i++)
            {
                PingRsp mbr = (PingRsp)mbrs[i];
                if (mbr.CoordAddress != null)
                {
                    if (!votes.ContainsKey(mbr.CoordAddress))
                    {
                        votes[mbr.CoordAddress] = mbr.HasJoined ? 1000:1;
                    }
                    else
                    {
                        int count = ((int)votes[mbr.CoordAddress]);
                        votes[mbr.CoordAddress] = (int)(count + 1);
                    }

                    /// Find the maximum vote cast value. This will be used to resolve a
                    /// tie later on.
                    if (((int)votes[mbr.CoordAddress]) > max_votecast)
                    {
                        max_votecast = ((int)votes[mbr.CoordAddress]);
                    }

                    gms.Stack.NCacheLog.CriticalInfo("pb.ClientGmsImpl.determineCoord()", "Owner " + mbr.OwnAddress + " -- CoordAddress " + mbr.CoordAddress + " -- Vote " + (int)votes[mbr.CoordAddress]);

                    if ((mbr.OwnAddress.IpAddress.Equals(gms.local_addr.IpAddress)) && (mbr.OwnAddress.Port < gms.local_addr.Port))
                    {
                        gms.Stack.NCacheLog.Debug("pb.ClientGmsImpl.determineCoord()", "WINNER SET TO ACTIVE NODE's Coord = " + Convert.ToString(mbr.CoordAddress));
                        winner = mbr.CoordAddress;
                    }
                }
            }



            /// Collect all the candidates with the highest but similar vote count.
            /// Ideally there should only be one.
            ArrayList candidates = new ArrayList(votes.Count);

            for (IDictionaryEnumerator e = votes.GetEnumerator(); e.MoveNext();)
            {
                if (((int)e.Value) == max_votecast)
                {
                    candidates.Add(e.Key);
                }
            }

            candidates.Sort();
            if (winner == null)
            {
                winner = (Address)candidates[0];
            }

            if (candidates.Count > 1)
            {
                gms.Stack.NCacheLog.Warn("pb.ClientGmsImpl.determineCoord()", "there was more than 1 candidate for coordinator: " + Global.CollectionToString(candidates));
            }
            gms.Stack.NCacheLog.CriticalInfo("pb.ClientGmsImpl.determineCoord()", "election winner: " + winner + " with votes " + max_votecast);



            return(winner);
        }
Example #7
0
        static void Main(string[] args)
        {
            //
            // PING REQUEST
            //
            String payload     = "this my payload; there are many like it but this one is mine";
            String someTraceId = "doesntmatter-8176";
            String originApp   = "UAPI";

            //set up the request parameters into a PingReq object
            PingReq req = new PingReq();

            req.Payload = payload;
            req.TraceId = someTraceId;

            UAPIConsumptionSamples.SystemService.BillingPointOfSaleInfo billSetInfo = new UAPIConsumptionSamples.SystemService.BillingPointOfSaleInfo();
            billSetInfo.OriginApplication = originApp;

            req.BillingPointOfSaleInfo = billSetInfo;
            req.TargetBranch           = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH);
            Console.WriteLine(req);



            try
            {
                //run the ping request
                //WSDLService.sysPing.showXML(true);
                SystemPingPortTypeClient client = new SystemPingPortTypeClient("SystemPingPort", WsdlService.SYSTEM_ENDPOINT);
                //Console.WriteLine(client.Endpoint);
                client.ClientCredentials.UserName.UserName = Helper.RetrunUsername();
                client.ClientCredentials.UserName.Password = Helper.ReturnPassword();

                /*var httpHeaders = new Dictionary<string, string>();
                 * httpHeaders.Add("Username", "travelportsuperadmin");
                 * httpHeaders.Add("Password", "abc123");
                 * client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));*/

                /*HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
                 * httpRequestProperty.Headers[HttpRequestHeader.Authorization] = "Basic " +
                 *  Convert.ToBase64String(Encoding.ASCII.GetBytes(client.ClientCredentials.UserName.UserName +
                 *  ":" + client.ClientCredentials.UserName.Password));
                 *
                 * using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                 *  {
                 *      OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] =
                 *          httpRequestProperty;
                 *      return client.processRequest(castRequest) as TSRsp;
                 *  }
                 *
                 *
                 * OperationContext.Current.OutgoingMessageProperties*/



                var httpHeaders = Helper.ReturnHttpHeader();
                client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));
                //String soapMsg = Helper.ObjectToSOAP(req);
                PingRsp rsp = client.service(req);
                //print results.. payload and trace ID are echoed back in response
                Console.WriteLine(rsp.Payload);
                //Console.WriteLine(rsp.TraceId);
                //Console.WriteLine(rsp.TransactionId);
            }
            catch (Exception e)
            {
                //usually only the error message is useful, not the full stack
                //trace, since the stack trace in is your address space...
                Console.WriteLine("Error : " + e.Message);
            }

            VehicleSvcTest vehicleTest = new VehicleSvcTest();

            vehicleTest.ProcessVehicleFlow();

            RailSvcTest railtest = new RailSvcTest();
            RailAvailabilitySearchRsp railSearchRsp = railtest.ProcessRailFlow();

            if (railSearchRsp != null)
            {
                RailPricingSolution lowestPrice = new RailPricingSolution()
                {
                    TotalPrice = "0"
                };

                List <RailJourney> journey = new List <RailJourney>();

                List <RailSegment> selectedSegmentList = new List <RailSegment>();

                List <RailFare> railFareList = new List <RailFare>();

                List <RailBookingInfo> bookingInfoList = new List <RailBookingInfo>();

                if (railSearchRsp.RailPricingSolution != null && railSearchRsp.RailPricingSolution.Count <RailPricingSolution>() > 0)
                {
                    IEnumerator <RailPricingSolution> railPricingSoltionList = railSearchRsp.RailPricingSolution.ToList().GetEnumerator();
                    while (railPricingSoltionList.MoveNext())
                    {
                        RailPricingSolution railPriceSol = railPricingSoltionList.Current;

                        if (Helper.ReturnValue(lowestPrice.TotalPrice) == 0)
                        {
                            lowestPrice = railPriceSol;
                        }
                        else if (Helper.ReturnValue(railPriceSol.TotalPrice) < Helper.ReturnValue(lowestPrice.TotalPrice))
                        {
                            lowestPrice = railPriceSol;
                        }
                    }


                    if (Helper.ReturnValue(lowestPrice.TotalPrice) > 0)
                    {
                        IEnumerator <RailJourney> journeyList = railSearchRsp.RailJourneyList.ToList().GetEnumerator();
                        IEnumerator journeyRefList            = lowestPrice.Items.GetEnumerator();

                        while (journeyRefList.MoveNext())
                        {
                            RailJourneyRef j = (RailJourneyRef)journeyRefList.Current;

                            while (journeyList.MoveNext())
                            {
                                RailJourney currJourney = journeyList.Current;
                                if (j.Key.CompareTo(currJourney.Key) == 0)
                                {
                                    journey.Add(currJourney);
                                }
                            }
                        }
                    }

                    IEnumerator <RailJourney> railJourneyList = journey.GetEnumerator();
                    IEnumerator <RailSegment> railSegmentList = railSearchRsp.RailSegmentList.ToList().GetEnumerator();

                    while (railJourneyList.MoveNext())
                    {
                        RailJourney railJourney = railJourneyList.Current;

                        IEnumerator segmentRefList = railJourney.Items.GetEnumerator();
                        while (segmentRefList.MoveNext())
                        {
                            RailSegmentRef segRef = (RailSegmentRef)segmentRefList.Current;

                            while (railSegmentList.MoveNext())
                            {
                                RailSegment segment = railSegmentList.Current;
                                if (segRef.Key.CompareTo(segment.Key) == 0)
                                {
                                    selectedSegmentList.Add(segment);
                                }
                            }
                        }
                    }

                    IEnumerator <RailPricingInfo> railPriceInfoList = lowestPrice.RailPricingInfo.ToList().GetEnumerator();
                    IEnumerator <RailFare>        railFares         = railSearchRsp.RailFareList.ToList().GetEnumerator();

                    while (railPriceInfoList.MoveNext())
                    {
                        RailPricingInfo priceInfo = railPriceInfoList.Current;

                        IEnumerator fareList = priceInfo.Items.ToList().GetEnumerator();

                        while (fareList.MoveNext())
                        {
                            RailFareRef fareRef = (RailFareRef)fareList.Current;

                            while (railFares.MoveNext())
                            {
                                RailFare fare = railFares.Current;

                                if (fareRef.Key.CompareTo(fare.Key) == 0)
                                {
                                    railFareList.Add(fare);
                                }
                            }
                        }

                        IEnumerator <RailBookingInfo> infoList = priceInfo.RailBookingInfo.ToList().GetEnumerator();
                        while (infoList.MoveNext())
                        {
                            RailBookingInfo bookingInfo = infoList.Current;
                            bookingInfoList.Add(bookingInfo);
                        }
                    }
                }

                railtest.ProcessRailBookFlow(lowestPrice, journey, selectedSegmentList, railFareList, bookingInfoList);
            }
        }
        static void Main(string[] args)
        {
            //
            // PING REQUEST
            //
            String payload     = "this my payload; there are many like it but this one is mine";
            String someTraceId = "doesntmatter-8176";
            String originApp   = "UAPI";

            //set up the request parameters into a PingReq object
            PingReq req = new PingReq();

            req.Payload = payload;
            req.TraceId = someTraceId;

            BillingPointOfSaleInfo billSetInfo = new BillingPointOfSaleInfo();

            billSetInfo.OriginApplication = originApp;

            req.BillingPointOfSaleInfo = billSetInfo;
            req.TargetBranch           = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH);
            Console.WriteLine(req);



            try
            {
                //run the ping request
                //WSDLService.sysPing.showXML(true);
                SystemPingPortTypeClient client = new SystemPingPortTypeClient("SystemPingPort", WsdlService.SYSTEM_ENDPOINT);
                //Console.WriteLine(client.Endpoint);
                client.ClientCredentials.UserName.UserName = Helper.RetrunUsername();
                client.ClientCredentials.UserName.Password = Helper.ReturnPassword();

                /*var httpHeaders = new Dictionary<string, string>();
                 * httpHeaders.Add("Username", "travelportsuperadmin");
                 * httpHeaders.Add("Password", "abc123");
                 * client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));*/

                /*HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
                 * httpRequestProperty.Headers[HttpRequestHeader.Authorization] = "Basic " +
                 *  Convert.ToBase64String(Encoding.ASCII.GetBytes(client.ClientCredentials.UserName.UserName +
                 *  ":" + client.ClientCredentials.UserName.Password));
                 *
                 * using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                 *  {
                 *      OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] =
                 *          httpRequestProperty;
                 *      return client.processRequest(castRequest) as TSRsp;
                 *  }
                 *
                 *
                 * OperationContext.Current.OutgoingMessageProperties*/



                var httpHeaders = Helper.ReturnHttpHeader();
                client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));

                PingRsp rsp = client.service(req);
                //print results.. payload and trace ID are echoed back in response
                Console.WriteLine(rsp.Payload);
                //Console.WriteLine(rsp.TraceId);
                //Console.WriteLine(rsp.TransactionId);
            }
            catch (Exception e)
            {
                //usually only the error message is useful, not the full stack
                //trace, since the stack trace in is your address space...
                Console.WriteLine("Error : " + e.Message);
            }
        }
Example #9
0
        static void Main(string[] args)
        {
            //
            // PING REQUEST
            //
            String payload     = "this my payload; there are many like it but this one is mine";
            String someTraceId = "doesntmatter-8176";
            String originApp   = "UAPI";

            //set up the request parameters into a PingReq object
            PingReq req = new PingReq();

            req.Payload = payload;
            req.TraceId = someTraceId;

            ConsoleApplication1.SystemService.BillingPointOfSaleInfo billSetInfo = new ConsoleApplication1.SystemService.BillingPointOfSaleInfo();
            billSetInfo.OriginApplication = originApp;

            req.BillingPointOfSaleInfo = billSetInfo;
            req.TargetBranch           = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH);
            Console.WriteLine(req);



            try {
                //run the ping request
                //WSDLService.sysPing.showXML(true);
                SystemPingPortTypeClient client = new SystemPingPortTypeClient("SystemPingPort", WsdlService.SYSTEM_ENDPOINT);
                //Console.WriteLine(client.Endpoint);
                client.ClientCredentials.UserName.UserName = Helper.RetrunUsername();
                client.ClientCredentials.UserName.Password = Helper.ReturnPassword();

                /*var httpHeaders = new Dictionary<string, string>();
                 * httpHeaders.Add("Username", "travelportsuperadmin");
                 * httpHeaders.Add("Password", "abc123");
                 * client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));*/

                /*HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
                 * httpRequestProperty.Headers[HttpRequestHeader.Authorization] = "Basic " +
                 *  Convert.ToBase64String(Encoding.ASCII.GetBytes(client.ClientCredentials.UserName.UserName +
                 *  ":" + client.ClientCredentials.UserName.Password));
                 *
                 * using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                 *  {
                 *      OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] =
                 *          httpRequestProperty;
                 *      return client.processRequest(castRequest) as TSRsp;
                 *  }
                 *
                 *
                 * OperationContext.Current.OutgoingMessageProperties*/



                var httpHeaders = Helper.ReturnHttpHeader();
                client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));


                PingRsp rsp = client.service(req);
                //print results.. payload and trace ID are echoed back in response
                Console.WriteLine(rsp.Payload);
                //Console.WriteLine(rsp.TraceId);
                //Console.WriteLine(rsp.TransactionId);

                AirportDetails airports = new AirportDetails();
                //Here we are getting the list of airports, we can use it anyway we want
                IDictionary <String, String> airportsList = airports.AllAirportsList();


                //Here we are getting the list of airports in a particular city, we are harcoding the city as New York here
                IDictionary <String, String> airportInCityList = airports.GetAllAiportsFromParticualrCity("New York");


                AirSvcTest airTest = new AirSvcTest();
                airTest.Availability();

                AirLFSTest lfsTest        = new AirLFSTest();
                Boolean    solutionResult = false; //Change it to true if you want AirPricingSolution, by default it is false
                                                   //and will send AirPricePoint in the result
                LowFareSearchRsp lowFareRsp = lfsTest.LowFareShop(solutionResult);

                if (lowFareRsp != null)
                {
                    typeBaseAirSegment[]      airSegments     = lowFareRsp.AirSegmentList;
                    List <typeBaseAirSegment> pricingSegments = new List <typeBaseAirSegment>();

                    IEnumerator        items      = lowFareRsp.Items.GetEnumerator();
                    AirPricingSolution lowestFare = null;
                    AirPricePoint      lowest     = null;

                    while (items.MoveNext())
                    {
                        if (solutionResult)
                        {
                            AirPricingSolution airPricingSolution = (AirPricingSolution)items.Current;
                            if (lowestFare == null)
                            {
                                lowestFare = airPricingSolution;
                            }
                            else
                            {
                                if (Helper.ConvertToDecimal(lowestFare.TotalPrice) > Helper.ConvertToDecimal(airPricingSolution.TotalPrice))
                                {
                                    lowestFare = airPricingSolution;
                                }
                            }
                        }
                        else
                        {
                            AirPricePointList airPricePointList = (AirPricePointList)items.Current;

                            if (airPricePointList != null)
                            {
                                foreach (var airPricePoint in airPricePointList.AirPricePoint)
                                {
                                    if (lowest == null)
                                    {
                                        lowest = airPricePoint;
                                    }
                                    else
                                    {
                                        if (Helper.ConvertToDecimal(lowest.TotalPrice) > Helper.ConvertToDecimal(airPricePoint.TotalPrice))
                                        {
                                            lowest = airPricePoint;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (lowestFare != null)
                    {
                        IEnumerator journeys = lowestFare.Journey.GetEnumerator();
                        while (journeys.MoveNext())
                        {
                            Journey journeyDetails = (Journey)journeys.Current;
                            if (journeyDetails != null)
                            {
                                AirSegmentRef[] segmentRef     = journeyDetails.AirSegmentRef;
                                string          refKey         = segmentRef[0].Key;
                                IEnumerator     airSegmentList = airSegments.GetEnumerator();
                                while (airSegmentList.MoveNext())
                                {
                                    typeBaseAirSegment airSeg = (typeBaseAirSegment)airSegmentList.Current;
                                    if (airSeg.Key.CompareTo(refKey) == 0)
                                    {
                                        pricingSegments.Add(airSeg);
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    if (lowest != null)
                    {
                        IEnumerator pricingInfos = lowest.AirPricingInfo.GetEnumerator();

                        while (pricingInfos.MoveNext())
                        {
                            AirPricingInfo priceInfo = (AirPricingInfo)pricingInfos.Current;
                            if (priceInfo != null)
                            {
                                foreach (var flightOption in priceInfo.FlightOptionsList)
                                {
                                    FlightOption option  = flightOption;
                                    IEnumerator  options = option.Option.GetEnumerator();
                                    if (options.MoveNext())
                                    {
                                        Option opt = (Option)options.Current;
                                        if (opt != null)
                                        {
                                            IEnumerator bookingInfoList = opt.BookingInfo.GetEnumerator();
                                            if (bookingInfoList.MoveNext())
                                            {
                                                BookingInfo bookingInfo = (BookingInfo)bookingInfoList.Current;
                                                if (bookingInfo != null)
                                                {
                                                    String      key            = bookingInfo.SegmentRef;
                                                    IEnumerator airSegmentList = airSegments.GetEnumerator();
                                                    while (airSegmentList.MoveNext())
                                                    {
                                                        typeBaseAirSegment airSeg = (typeBaseAirSegment)airSegmentList.Current;
                                                        if (airSeg.Key.CompareTo(key) == 0)
                                                        {
                                                            pricingSegments.Add(airSeg);
                                                            break;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }

                                    break;
                                }
                            }
                        }
                    }

                    AirPriceRsp        priceRsp    = AirReq.AirPrice(pricingSegments);
                    AirPricingSolution lowestPrice = null;
                    if (priceRsp != null)
                    {
                        if (priceRsp.AirPriceResult != null)
                        {
                            IEnumerator priceResults = priceRsp.AirPriceResult.GetEnumerator();
                            if (priceResults.MoveNext())//We would take  the first Price Result and will Search for the lowest Price
                            {
                                AirPriceResult result = (AirPriceResult)priceResults.Current;
                                if (result.AirPricingSolution != null)
                                {
                                    IEnumerator priceingSolutions = result.AirPricingSolution.GetEnumerator();
                                    while (priceingSolutions.MoveNext())
                                    {
                                        AirPricingSolution priceSol = (AirPricingSolution)priceingSolutions.Current;
                                        if (lowestPrice == null)
                                        {
                                            lowestPrice = priceSol;
                                        }
                                        else
                                        {
                                            if (Helper.ConvertToDecimal(lowestPrice.TotalPrice) > Helper.ConvertToDecimal(priceSol.TotalPrice))
                                            {
                                                lowestPrice = priceSol;
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        if (lowestPrice != null && priceRsp.AirItinerary != null)
                        {
                            AirBookTest book = new AirBookTest();
                            ConsoleApplication1.UniversalService.AirCreateReservationRsp bookResponse = book.AirBook(lowestPrice, priceRsp.AirItinerary);

                            if (bookResponse != null)
                            {
                                var urLocatorCode = bookResponse.UniversalRecord.LocatorCode;
                                Console.WriteLine("Universal Record Locator Code :" + urLocatorCode);
                                UniversalRetrieveTest univ = new UniversalRetrieveTest();
                                univ.RetrieveRecord(urLocatorCode);
                            }
                        }
                    }
                }
            } catch (Exception e) {
                //usually only the error message is useful, not the full stack
                //trace, since the stack trace in is your address space...
                Console.WriteLine("Error : " + e.Message);
            }
        }