public async t.Task <ImportSet> ExecuteWithResult() { try { IAuthenticator authenticator = new FormsAuthenticator (DimeSchedulerCredentials.Uri, DimeSchedulerCredentials.User, DimeSchedulerCredentials.Password); DimeSchedulerClient client = new(DimeSchedulerCredentials.Uri, authenticator); ExchangeAppointment importRequest = new() { AppointmentId = 0, Start = DateTime.Now.AddHours(1), End = DateTime.Now.AddHours(2), Subject = "Hello world", Body = "Lorem ipsum", Importance = "0", ResourceEmail = "*****@*****.**" }; IImportEndpoint importEndpoint = await client.Import.Request(); return(await importEndpoint.ProcessAsync(importRequest, TransactionType.Append)); } catch (Exception ex) { Console.WriteLine(ex.ToString()); return(null); } }
public async System.Threading.Tasks.Task ExecuteWithResult() { try { Console.WriteLine("Importing filter groups"); IAuthenticator authenticator = new FormsAuthenticator (DimeSchedulerCredentials.Uri, DimeSchedulerCredentials.User, DimeSchedulerCredentials.Password); DimeSchedulerClient client = new(DimeSchedulerCredentials.Uri, authenticator); List <string> groups = new() { "Department", "Skill", "Language", "Drivers License", "Region", "Contract Type" }; for (int i = 0; i < 3; i++) { FilterGroup filterGroup = new Faker <FilterGroup>() .RuleFor(x => x.Name, (f, u) => f.PickRandom(groups) + " " + i) .Generate(); IImportEndpoint importEndpoint = await client.Import.Request(); await importEndpoint.ProcessAsync(filterGroup, TransactionType.Append); for (int y = 0; y < 5; y++) { FilterValue filterValue = new Faker <FilterValue>() .RuleFor(x => x.Group, (f, u) => filterGroup.Name) .RuleFor(x => x.Value, (f, u) => filterGroup.Name + " " + y) .Generate(); await importEndpoint.ProcessAsync(filterValue, TransactionType.Append); } } Console.WriteLine("All done importing filter groups"); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public async System.Threading.Tasks.Task Execute() { try { Console.WriteLine("Running resource import sample"); IAuthenticator authenticator = new FormsAuthenticator (DimeSchedulerCredentials.Uri, DimeSchedulerCredentials.User, DimeSchedulerCredentials.Password); DimeSchedulerClient client = new(DimeSchedulerCredentials.Uri, authenticator); IImportEndpoint importEndpoint = await client.Import.Request(); // Ensure the resource exists Import.Resource resourceRequest = ResourceFactory.Create(); resourceRequest.ResourceGpsTrackingEnabled = true; Random random = new(); string color = $"#{random.Next(0x1000000):X6}"; Pin pin = new() { Name = "Pin for " + resourceRequest.ResourceNo, Color = color }; await importEndpoint.ProcessAsync(pin, TransactionType.Append); resourceRequest.Pin = pin.Name; ImportSet resourceImport = await importEndpoint.ProcessAsync(resourceRequest, TransactionType.Append); List <(decimal, decimal)> coordinates = new() { (40.779555M, -73.973577M), // Central Park West & W 77th (40.785286M, -73.969350M), // Central Park West & W 86th (40.794248M, -73.962958M), // Central Park West & W 100th (40.800398M, -73.958047M), // Central Park West & Central Park North (40.799518M, -73.955355M), // Central Park North & Adam Clayton Powell Jr Blvd (40.798223M, -73.952388M), // Central Park North & Malcolm X Blvd (40.796643M, -73.949432M), // Central Park North & 5th Ave (40.794328M, -73.951068M), // 5th Ave & E 106th St (40.794328M, -73.951068M), // 5th Ave & E 101th St (40.786605M, -73.956753M), // 5th Ave & E 94th St (40.780868M, -73.960957M), // 5th Ave & E 85th St (40.773795M, -73.966148M), // 5th Ave & E 74th St (40.769919M, -73.968967M), // 5th Ave & E 68th St (40.765517M, -73.972142M), // 5th Ave & E 61th St (40.764316M, -73.973075M), // 5th Ave & E 50th St }; for (int i = 0; i < coordinates.Count; i++) { Console.WriteLine("Updating GPS location " + (i + 1)); (decimal lat, decimal lng) = coordinates.ElementAt(i); ResourceGpsTracking resourceGpsTrackingRequest = new() { ResourceNo = resourceRequest.ResourceNo, Latitude = lat, Longitude = lng }; ImportSet resourceCoordinatesImport = await importEndpoint.ProcessAsync(resourceGpsTrackingRequest, TransactionType.Append); Thread.Sleep(5000); // Sleep 2 seconds } Console.WriteLine("All done!"); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }