Пример #1
0
        public static void Run()
        {
            cookieCont = new CookieContainer();
            using (server = new ImportServerSoapClient())
            {
                var behave = new CookieBehavior(cookieCont);
                server.Endpoint.EndpointBehaviors.Add(behave);

                if (!Login())
                {
                    Log("Login failed");
                    return;
                }
                Log("Logged in as " + brokerId);

                //The list of all objects
                var listOfObjects = server.GetAdvertList().ToList();
                Log("Number of objects: " + listOfObjects.Count);

                Log();
                //The leads for this customer, from the beginning of time (2000-01-01)
                var leads = server.GetAdvertImpressionsList(new DateTime(2000, 1, 1), DateTime.MaxValue).ToList();
                foreach (var l in leads)
                {
                    Log("Estate: " + l.ServerID);
                    Log("Number of leads: " + l.Site[0].Impressions.Length);
                }

                Console.ReadLine();

                //Try and validate the estate to see what errors we get (if any)
                //Validate(GetEstate(listOfObjects[0].ServerID));
                //Log();

                //Get the estate, change a field, save it, get it again, read the field and see that it is changed, change it again and save again.
                //TestUpdate(listOfObjects[0].ServerID);

                Log();

                var estate = CreateNew();
                Validate(estate);

                var updateMessage = server.Update(estate);
                Log();
                Log("Saving estate");
                Log("Save successfully: " + updateMessage.Success);
                Log("Is new estate: " + updateMessage.NewEstate);
                Log("Server ID: " + updateMessage.ServerID);
                if (updateMessage.Success)
                {
                    Log("Estate objectpage can be found at: http://www.tnext.test.objektvision.se/Description/" +
                        updateMessage.ServerID);
                }
                else
                {
                    Log("Something broke when saving");
                    Log(updateMessage.Message);
                }

                Log("Press any key to delete the newly created object");
                Console.ReadLine();
                Log("Deleted successfully: " + server.DeleteByServerID(updateMessage.ServerID));
                Console.ReadLine();
            }
        }
Пример #2
0
        public static void Run()
        {
            using (server = new ImportServerSoapClient())
            {
                if (!Login())
                {
                    Log("Login failed");
                    Console.ReadLine();
                    return;
                }
                Log("Logged in as " + brokerId);

                //The list of all objects
                var listOfObjects = server.GetAdvertList().ToList();
                Log("Number of objects: " + listOfObjects.Count);

                Log();
                //The leads for this customer
                //This function returns all new leads for all objects since the last time the function was run.
                //To get a nice popup in the recieving system it might be a good idea to run this function every 10-15 minutes or so,
                //otherwise once per day. Remember to store the data locally, as it will not be sent again once it has been sent.
                var leads = server.GetLeads().ToList();
                Log("Number of leads since last get: " + leads.Count);
                foreach (var l in leads)
                {
                    Log();
                    Log("Estate: " + l.ServerID);
                    Log("Errand: " + l.Errand);
                    Log("Message: " + l.Message);
                }


                //The impressions (visitor statistics) for the user/client
                var impressions = server.GetAdvertImpressionsList(new DateTime(2000, 1, 1), DateTime.MaxValue).ToList();
                foreach (var l in impressions)
                {
                    Log("Estate: " + l.ServerID);
                    Log("Number of leads: " + l.Site[0].Impressions.Length);
                }

                Console.ReadLine();

                //Try and validate the estate to see what errors we get (if any)
                //Validate(GetEstate(listOfObjects[0].ServerID));
                //Log();

                //Get the estate, change a field, save it, get it again, read the field and see that it is changed, change it again and save again.
                //TestUpdate(listOfObjects[0].ServerID);

                Log();

                var estate = CreateNew();
                Validate(estate);

                var updateMessage = server.Update(estate);
                Log();
                Log("Saving estate");
                Log("Save successfully: " + updateMessage.Success);
                Log("Is new estate: " + updateMessage.NewEstate);
                Log("Server ID: " + updateMessage.ServerID);
                if (updateMessage.Success)
                {
                    Log("Estate objectpage can be found at: http://www.tnext.test.objektvision.se/Description/" +
                        updateMessage.ServerID);
                }
                else
                {
                    Log("Something broke when saving");
                    Log(updateMessage.Message);
                }

                Log("Press any key to delete the newly created object");
                Console.ReadLine();
                Log("Deleted successfully: " + server.DeleteByServerID(updateMessage.ServerID));
                Console.ReadLine();
            }
        }