Example #1
0
        public static bool RequestHandles(string[] ids, string serverName, string groupName, string userName, string password)
        {
            bool isSuccessful = true;

            var binding = CreateBasicHttpBinding();
            var address = new EndpointAddress(serverName);
            var client  = new PersistentLinkingClient(binding, address);

            try
            {
                Logger.Instance.Log.Debug("Requesting Handles for " + ids.Length + " items");

                var map = client.createBatch(ids, groupName, userName, password);

                // Handle any failures.
                if (map.failMap.Length > 0)
                {
                    isSuccessful = false;
                    foreach (var item in map.failMap)
                    {
                        string msg = string.Format("{0}: {1}", item.key, item.value);
                        this.messages.Add(msg);
                        Logger.Instance.Log.Warn(msg);
                    }
                }

                //// Assign the Handles to the CatalogRecord and files.
                foreach (var item in map.successMap)
                {
                    string id     = item.key;
                    string handle = item.value;

                    if (record.Id.ToString() == id)
                    {
                        record.PersistentId = handle;
                    }
                    else
                    {
                        var file = record.Files.Where(x => x.Id.ToString() == id).FirstOrDefault();
                        if (file != null)
                        {
                            file.PersistentLink     = handle;
                            file.PersistentLinkDate = DateTime.UtcNow;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.messages.Add("Could not connect to handle server");
                Logger.Instance.Log.Warn("Could not connect to handle server", ex);
                return(false);
            }

            return(isSuccessful);
        }
Example #2
0
        public void ResolveHandleTest()
        {
            var binding = CreateBasicHttpBinding();
            var address = new EndpointAddress("http://linktest.odai.yale.edu/ypls-ws/PersistentLinking");
            var client  = new PersistentLinkingClient(binding, address);

            string[] ids = new string[]
            {
                "10079.1.test", "test2", "test3"
            };

            var result = client.resolveBatch(ids, "TODO", "TODO");

            Console.WriteLine("test");
        }
Example #3
0
        public void RequestHandleTest()
        {
            var binding = CreateBasicHttpBinding();

            string[] ids = new string[]
            {
                "http://example.org/test1", "test2", "asdf asdf", "test2", "cb340d03-67a3-47c1-bec5-f25df1d6cd87"
            };

            //string username = Environment.GetEnvironmentVariable("Handle_Username");
            //string password = Environment.GetEnvironmentVariable("Handle_Password");

            bool isNew = true;

            if (isNew)
            {
                var address = new EndpointAddress("https://linktest.its.yale.edu/ypls/webservices");
                var client  = new YaleIsps.HandleService.YalePersistentLinkingService3.PersistentLinkingClient(binding, address);

                string username = "******";
                string password = "******";

                var result = client.createBatch(ids, username, username, password);
            }
            else
            {
                var address = new EndpointAddress("https://link.its.yale.edu/ypls-ws/PersistentLinking");
                var client  = new PersistentLinkingClient(binding, address);

                string username = "******";
                string password = "******";
                var    result   = client.createBatch(ids, username, username, password);
            }

            Console.WriteLine("test");
        }