public async System.Threading.Tasks.Task ExecuteWithResult()
        {
            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();

                string[] departments = { "Sales", "Marketing", "R&D", "IT", "Warehouse", "Planning", "Accounting" };
                string[] teams       = { "Team A", "Team B", "Team C", "Team D", "Team E", "Team F" };

                for (int i = 0; i < 20; i++)
                {
                    Console.WriteLine("Importing resource " + i + 1);
                    Import.Resource resourceRequest = ResourceFactory.Create();
                    ImportSet       resourceImport  = await importEndpoint.ProcessAsync(resourceRequest, TransactionType.Append);
                }

                Console.WriteLine("All done!");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Beispiel #2
0
        public async t.Task Execute()
        {
            try
            {
                IAuthenticator authenticator = new FormsAuthenticator
                                                   (DimeSchedulerCredentials.Uri,
                                                   DimeSchedulerCredentials.User,
                                                   DimeSchedulerCredentials.Password);

                DimeSchedulerClient client = new(DimeSchedulerCredentials.Uri, authenticator);

                Notification notificationRequest = new Faker <Notification>()
                                                   .RuleFor(x => x.SourceApp, f => "IMPORT")
                                                   .RuleFor(x => x.SourceType, f => "IMPORT")
                                                   .RuleFor(x => x.Text, f => f.Rant.Review("Dime.Scheduler").ClampLength())
                                                   .RuleFor(x => x.Code, f => f.Finance.AccountName())
                                                   .RuleFor(x => x.Date, f => f.Date.Soon(10))
                                                   .RuleFor(x => x.Type, f => f.PickRandom <NotificationType>())
                                                   .Generate();

                IImportEndpoint importEndpoint = await client.Import.Request();

                await importEndpoint.ProcessAsync(notificationRequest, TransactionType.Append);
            }
            catch (WebException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Beispiel #3
0
        public async System.Threading.Tasks.Task ExecuteWithResult()
        {
            try
            {
                IAuthenticator authenticator = new FormsAuthenticator
                                                   (DimeSchedulerCredentials.Uri,
                                                   DimeSchedulerCredentials.User,
                                                   DimeSchedulerCredentials.Password);

                DimeSchedulerClient client         = new(DimeSchedulerCredentials.Uri, authenticator);
                IImportEndpoint     importEndpoint = await client.Import.Request();

                Job       jobRequest = CreateJobRequest();
                ImportSet jobImport  = await importEndpoint.ProcessAsync(jobRequest, TransactionType.Append);

                for (int i = 0; i < 10; i++)
                {
                    Task taskRequest = CreateTaskRequest(jobRequest, i);

                    Console.WriteLine($"Importing task {taskRequest.TaskNo} to DS");
                    ImportSet taskImport = await importEndpoint.ProcessAsync(taskRequest, TransactionType.Append);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
        public async System.Threading.Tasks.Task Execute()
        {
            try
            {
                Console.WriteLine("Running appointment import sample");

                IAuthenticator authenticator = new FormsAuthenticator
                                                   (DimeSchedulerCredentials.Uri,
                                                   DimeSchedulerCredentials.User,
                                                   DimeSchedulerCredentials.Password);

                DimeSchedulerClient client         = new(DimeSchedulerCredentials.Uri, authenticator);
                IImportEndpoint     importEndpoint = await client.Import.Request();

                Appointment appointmentRequest = new Faker <Appointment>()
                                                 .RuleFor(x => x.SourceApp, f => "CRONUSBE")
                                                 .RuleFor(x => x.SourceType, f => "JOB")
                                                 .RuleFor(x => x.JobNo, f => "J00001")
                                                 .RuleFor(x => x.TaskNo, f => "00001")
                                                 .RuleFor(x => x.ResourceNo, f => "BULENS")
                                                 .RuleFor(x => x.Start, f => DateTime.Now)
                                                 .RuleFor(x => x.End, f => DateTime.Now.AddHours(4))
                                                 .RuleFor(x => x.Subject, f => f.Lorem.Paragraph().ClampLength(1, 100))
                                                 .RuleFor(x => x.Body, f => f.Lorem.Paragraph().ClampLength(1, 100))
                                                 .Generate();

                ImportSet appointmentImport = await importEndpoint.ProcessAsync(appointmentRequest, TransactionType.Append);

                Console.WriteLine("All done!");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Beispiel #5
0
        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);
            }
        }
Beispiel #6
0
        public async System.Threading.Tasks.Task Endpoint_Request_InvalidUrl_WithMockAuthenticator_ShouldConstruct()
        {
            const string        faultyUrl = "https://dimescheduler.io/doesnotexist";
            DimeSchedulerClient client    = new(faultyUrl, new MockAuthenticator());

            IImportEndpoint importEndpoint = await client.Import.Request();

            Assert.NotNull(importEndpoint);
        }
Beispiel #7
0
        public async System.Threading.Tasks.Task Endpoint_ProcessAsync_InvalidUrl_ShouldThrowException()
        {
            const string        faultyUrl = "https://dimescheduler.io/doesnotexist";
            DimeSchedulerClient client    = new(faultyUrl, new MockAuthenticator());

            IImportEndpoint importEndpoint = await client.Import.Request();

            await Assert.ThrowsAsync <WebException>(
                async() => await importEndpoint.ProcessAsync(new ExchangeAppointment(), TransactionType.Append));
        }
        public async Task DimeSchedulerClient_ImportEndpoint_ShouldCreate()
        {
            const string        uri           = "http://mydimescheduler.io";
            IAuthenticator      authenticator = new MockAuthenticator();
            DimeSchedulerClient client        = new(uri, authenticator);

            IImportEndpoint endpoint = await client.Import.Request();

            Assert.NotNull(endpoint);
        }
        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());
            }
        }