Exemplo n.º 1
0
        public bool BeforeRequest(TrimClient trimClient)
        {
            System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
            trimClient.Proxy = new WebProxy("http://localhost:8888");
            var sessionCookies = GessionCookies();

            if (sessionCookies.Count == 2)
            {
                trimClient.ServiceClient.CookieContainer.Add(sessionCookies[0]);
                trimClient.ServiceClient.CookieContainer.Add(sessionCookies[1]);
                return(true);
            }

            return(false);
        }
        static void Main(string[] args)
        {
            TrimClient trimClient = new TrimClient("http://localhost/HPRMServiceAPI");
            trimClient.Credentials = System.Net.CredentialCache.DefaultCredentials;
            //
            //Locations request = new Locations();
            //request.q = "me";
            //request.Properties = new List<string>() { "SortName" };
            //Locations Loc = trimClient.Get<LocationsResponse>(request);

            //Console.WriteLine("Logged onto Eddie as " + Loc.Results[0].SortName);
            //
            //Properties = new PropertyList(PropertyIds.RecordTitle, PropertyIds.RecordNumber, PropertyIds.Url)
          
            Record record = new Record();
            record.Properties = new List<string>() { "RecordNumber", "Url" , "Container"};
            record.RecordType = new RecordTypeRef() { Uri = 2 };
            record.Title = "EPL test" + " - " + DateTime.Now.ToString();
            record.Classification = new ClassificationRef() { Uri = 3763 };
            record.Container = new RecordRef() { Uri = 6110 };
            record.Assignee = new LocationRef() { Uri = 5503 };
            //record.AssigneeStatus = new TrimProperty<RecLocSubTypes>() { }
                //RecLocSubTypes() { RecLocSubTypes.AtLocation };
            //RecLocSubTypes.AtLocation 
            //record.Assignee
            //record.SetCustomField("PropertyNumber", t1.PropertyNumber);
            //record.SetCustomField("ApplicationNumber", t1.ApplicationNumber);
            //record.SetCustomField("PropertyAddress", t1.PropertyAddress);
            RecordsResponse response = trimClient.Post<RecordsResponse>(record);
            if (response.Results.Count == 1)
            {
                Console.WriteLine("New property container created in Eddie - RM Uri: " + response.Results.First().Url + " " + response.Results.First().Container.Uri);
            }
            //
            //Records request = new Records()
            //{
            //    q = "all"
            //    ,
            //    Properties = new PropertyList(PropertyIds.RecordTitle, PropertyIds.RecordNumber, PropertyIds.Url)
            //};

            //RecordsResponse response = trimClient.Get<RecordsResponse>(request);

            //foreach (Record record in response.Results)
            //{
            //    Console.WriteLine(record.Title + " " + record.Number + " " + record.Url);
            //}
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                TrimClient trimClient = new TrimClient("http://[IPaddress]/HPECMServiceAPI");  // Change [IPaddress] to match your ServiceAPI machine
                trimClient.Credentials = System.Net.CredentialCache.DefaultCredentials;

                long     PersonUri = 0;
                long     GroupUri  = 0;
                Location myloc     = new Location()
                {
                    Uri = PersonUri
                };                                                    // Change [PersonUri] to the person location you want to the member of a group location
                myloc.AddAction(
                    new AddRelationship()
                {
                    RelatedLocation = new LocationRef()
                    {
                        Uri = GroupUri
                    },                                                           // Change [GroupUri] to the group location you want to add the membership to
                    RelationshipType = LocRelationshipType.MemberOf,
                    MakeThisTheDefaultRelationship = false
                }
                    );
                LocationsResponse locresp1 = trimClient.Post <LocationsResponse>(myloc);

                if (locresp1.ResponseStatus.Message != null)
                {
                    MessageBox.Show(locresp1.ResponseStatus.Message);
                }
                else
                {
                    MessageBox.Show("Association Updated");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            string authority       = ConfigurationManager.AppSettings["ida:authority"];
            string resourceURI     = ConfigurationManager.AppSettings["ida:resourceUri"];
            string clientID        = ConfigurationManager.AppSettings["ida:clientId"];
            string clientReturnURI = ConfigurationManager.AppSettings["trim:ServiceLocation"];

            AuthenticationContext ac =
                new AuthenticationContext(authority, false, new FileCache());

            string authHeader = null;

            Task.Run(async() =>
            {
                AuthenticationResult ar =
                    await ac.AcquireTokenAsync(resourceURI, clientID, new Uri(clientReturnURI), new PlatformParameters(PromptBehavior.Auto));

                authHeader = ar.CreateAuthorizationHeader();
            }).Wait();



            TrimClient trimClient = new TrimClient(clientReturnURI);

            trimClient.ServiceClient.Headers.Add("Authorization", authHeader);

            LocationFind request = new LocationFind();

            request.Id         = "Me";
            request.Properties = new List <string>()
            {
                "SortName"
            };

            var response = trimClient.Get <LocationsResponse>(request);

            Console.WriteLine(response.Results[0].SortName);
        }
        static void ApplicationService(string Name)
        {

            try
            {
                TrimClient trimClient = new TrimClient(serviceapi);
                trimClient.Credentials = System.Net.CredentialCache.DefaultCredentials;
                //
                Locations request = new Locations();
                request.q = "me";
                request.Properties = new List<string>() { "SortName" };

                var Loc = trimClient.Get<LocationsResponse>(request);

                Console.WriteLine("Logged onto Eddie as " + Loc.Results[0].SortName);

                JsonSerializer s = new JsonSerializer();

                T1Application t1 = null;
                using (StreamReader sr = new StreamReader(Name))
                {
                    using (JsonTextReader reader = new JsonTextReader(sr))
                    {
                        //T1Integration t1 = new T1Integration();
                        t1 = (T1Application)s.Deserialize(reader, typeof(T1Application));
                    }
                }
                if (t1 != null)
                {
                    Console.WriteLine("T1 export file processed.");
                    if (t1.EddieUri == 0)
                    {
                        Record record = new Record();
                        
                        record.RecordType = new RecordTypeRef() { Uri = 1 };
                        record.Title = t1.PropertyTitle + " - " + DateTime.Now.ToString();
                        record.Classification = new ClassificationRef() { Uri=2598 };
                        record.SetCustomField("PropertyNumber", t1.PropertyNumber);
                        record.SetCustomField("ApplicationNumber", t1.ApplicationNumber);
                        record.SetCustomField("PropertyAddress", t1.PropertyAddress);
                        RecordsResponse response = trimClient.Post<RecordsResponse>(record);

                        if(response.Results.Count==1)
                        {
                            Console.WriteLine("New property container created in Eddie - RM Uri: " + response.Results.First().Uri.ToString());
                        }
                        //
                        FileInfo f = new FileInfo(t1.documentLoc);
                        if (f.Exists)
                        {
                            Record doc = new Record();
                            doc.Properties = new List<string>() { "Number" , "Url"};
                            doc.RecordType = new RecordTypeRef() { Uri = 2 };
                            doc.Container = new RecordRef() { Uri = response.Results.First().Uri };
                            doc.Title= t1.ApplicationTitle + " - " + DateTime.Now.ToString();
                            doc.SetCustomField("PropertyNumber", t1.PropertyNumber);
                            doc.SetCustomField("ApplicationNumber", t1.ApplicationNumber);

                            RecordsResponse response11= trimClient.PostFileWithRequest<RecordsResponse>(f, doc);
                            if(response11.Results.Count==1)
                            {
                                Record rr = response11.Results.First();
                                Console.WriteLine("New application document created in Eddie - RM Uri: " + rr.Uri.ToString());
                                t1.EddieUri = rr.Uri;
                                t1.EddieRecordNumber = rr.Number;
                                t1.EddieRecordUrl = rr.Url;
                            }
                        }
                    }
                    else
                    {
                        //Add amend function
                    }
                    using (StreamWriter sw = new StreamWriter(pathout + "T1 Application - " + t1.PropertyNumber.ToString() + ".txt"))
                    {
                        using (JsonWriter writer = new JsonTextWriter(sw))
                        {
                            s.Serialize(writer, t1);
                            Console.WriteLine("Application file returned");
                        }
                    };
                    FileInfo f2 = new FileInfo(Name);
                    if (f2.Exists)
                        f2.Delete();
                }
            }
            //catch (ServiceStack.ServiceClient.Web.WebServiceException ex)
            //{
            //    Console.WriteLine("Service stack error: "+ex.ErrorMessage);
            //}
            catch (Exception exp)
            {
                Console.WriteLine("General error: " + exp.Message.ToString());
                throw;
            }

        }