Esempio n. 1
0
        public async Task <ActionResult> ProvisionWorkflowPost()
        {
            var token = await O365Util.GetAccessToken(ServiceResources.Dashboard);

            var suiteLevelWebAppUrl = Regex.Match(Request.Url.AbsoluteUri, "https?://[^/]+?(?=/)", RegexOptions.Compiled).Value;

            using (var clientContext = TokenHelper.GetClientContextWithAccessToken(DemoSiteCollectionUrl, token))
            {
                var service       = new WorkflowProvisionService(clientContext);
                var incidentsList = CSOMUtil.getListByTitle(clientContext, "Incidents");

                service.Unsubscribe(incidentsList.Id, "Incident");
                service.DeleteDefinitions("Incident");
                service.DeleteList("Incident Workflow Tasks");
                service.DeleteList("Incident Workflow History");

                var workflow = System.IO.File.ReadAllText(Server.MapPath("~/Workflows/Incident.xaml"));

                workflow = workflow.Replace("(SuiteLevelWebAppUrlPlaceholder)", suiteLevelWebAppUrl)
                           .Replace("(dispatcherPlaceHolder)", ConfigurationManager.AppSettings["DispatcherName"]);
                workflow = WorkflowUtil.TranslateWorkflow(workflow);
                var definitionId  = service.SaveDefinitionAndPublish("Incident", workflow);
                var taskListId    = service.CreateTaskList("Incident Workflow Tasks");
                var historyListId = service.CreateHistoryList("Incident Workflow History");
                service.Subscribe("Incident Workflow", definitionId, incidentsList.Id, WorkflowSubscritpionEventType.ItemAdded, taskListId, historyListId);

                ViewBag.Message = "Incident Workflow, Incident Workflow Tasks list and Incident Workflow History list have been created successfully. Click the Create Sample Data menu item to proceed.";
            }
            return(View());
        }
Esempio n. 2
0
        public async Task <ActionResult> AuditRepair(string button, DashboardInspectionDetailsViewModel model)
        {
            var outlookToken = await O365Util.GetAccessToken(Capabilities.Mail);

            var sharePointToken = await O365Util.GetAccessToken(ServiceResources.DemoSite);

            var outlookClient = await O365Util.GetOutlookClient(Capabilities.Mail);

            Dashboard dashboardModel = new Dashboard(sharePointToken);

            var result = button == "Approve" ? ApprovalResult.Approved : ApprovalResult.Rejected;

            var tasksService = new TasksService(sharePointToken);
            await tasksService.CompleteRepairApprovalTask(model.incidentId, result);

            if (result == ApprovalResult.Approved)
            {
                await dashboardModel.ApproveRepair(model.incidentId);

                //This is the pattern you would use to send email from O365 APIs.  These emails are sent via the mobile apps.
                //var emailService = new EmailService(sharePointToken, Server.MapPath("/"));
                //var emailMessage = await emailService.ComposeRepairCompletedEmailMessage(model.incidentId);
                //await outlookClient.Me.SendMailAsync(emailMessage, true);
            }
            return(new RedirectResult("/Dashboard/Index"));
        }
Esempio n. 3
0
        public async Task <ActionResult> ProvisionWorkflow(string message)
        {
            await O365Util.GetAccessToken(ServiceResources.Dashboard); // Prepare token in advance.

            ViewBag.Message = message;
            return(View());
        }
Esempio n. 4
0
        public async Task <ActionResult> SendEmailTest(int incidentId)
        {
            var outlookToken = await O365Util.GetAccessToken(Capabilities.Mail);

            var sharePointToken = await O365Util.GetAccessToken(ServiceResources.DemoSite);

            return(await SendEmail(outlookToken, sharePointToken, incidentId));
        }
Esempio n. 5
0
        public async Task <ActionResult> Property(int Id)
        {
            var sharePointToken = await O365Util.GetAccessToken(ServiceResources.DemoSite);

            Dashboard dashboardModel = new Dashboard(sharePointToken);
            var       model          = await dashboardModel.GetDashboardPropertiesViewModel(Id);

            return(View(model));
        }
Esempio n. 6
0
        public async Task <ActionResult> ProvisionSiteComponents()
        {
            string token = await O365Util.GetAccessToken(ServiceResources.Dashboard);

            using (var clientContext = TokenHelper.GetClientContextWithAccessToken(DemoSiteCollectionUrl, token))
            {
                SiteProvisioning siteProvisioning = new SiteProvisioning(clientContext);
                siteProvisioning.AddSiteComponents();
                //siteProvisioning.RemoveSiteComponents();
                ViewBag.Message = "The demo site collection has been created successfully.  Click the Provision Workflow menu item to proceed.";
            }
            return(View());
        }
Esempio n. 7
0
        public async Task <ActionResult> Index()
        {
            string token = await O365Util.GetAccessToken(ServiceResources.Admin);

            //Determine if the site collection used for the demo is already created
            using (var adminClientContext = TokenHelper.GetClientContextWithAccessToken(AdminServiceResourceId, token))
            {
                switch (CSOMUtil.GetSiteCollectionStatusByUrl(adminClientContext, DemoSiteCollectionUrl))
                {
                case "Active":
                    ViewBag.refresh = string.Empty;
                    ViewBag.Message = "The demo site collection was successfully created.  Proceeding to provision information architecture and content.  This process may take several minutes, please be patient and do not refresh the page during this process.  If you are eager to see the progress you may browse to the new site collection in your browser and inspect the new components as they are provisioned.";

                    return(new RedirectResult("/O365SiteProvisioning/ProvisionSiteComponents"));

                case "Creating":
                    ViewBag.refresh  = "refresh";
                    ViewBag.Message += DateTime.Now.ToString() + " - The demo site collection is being created.  The page will be refreshed automatically to check status.  This operation can take up to 20 minutes to complete.";
                    break;

                case "None":
                    try
                    {
                        CSOMUtil.CreateSiteCollection(adminClientContext, new SiteCreationProperties
                        {
                            Url                  = DemoSiteCollectionUrl,
                            Owner                = DemoSiteCollectionOwner,
                            Template             = "BLANKINTERNETCONTAINER#0",
                            Title                = "Contoso Property Management Dashboard",
                            StorageMaximumLevel  = 1000,
                            StorageWarningLevel  = 750,
                            TimeZoneId           = 7,
                            UserCodeMaximumLevel = 1000,
                            UserCodeWarningLevel = 500
                        });

                        ViewBag.refresh           = "refresh";
                        ViewBag.Message           = "The demo site collection is being created, please wait a few minutes, and the page will be refreshed automatically to check status.";
                        ViewBag.serviceResourceId = AdminServiceResourceId;
                    }
                    catch (Exception el)
                    {
                        ViewBag.refresh = "";
                        ViewBag.Message = el.Message + " If the Site Collection still exists in the Recycle Bin use the SharePoint Online Management Shell to delete it completely. Remove-SPODeletedSite -Identity <Site Collection URL>";
                    }
                    break;
                }
            }

            return(View());
        }
        public async Task <ActionResult> Index(int Id)
        {
            var token = await O365Util.GetAccessToken(ServiceResources.DemoSite);

            MailAFOModel dashboardModel = new MailAFOModel(token);
            var          model          = await dashboardModel.GetMailAFOViewModel(Id);

            if (model == null)
            {
                return(new RedirectResult("/MailAFO/Index"));
            }

            return(View(model));
        }
Esempio n. 9
0
        public async Task <ActionResult> InspectionDetails(DashboardInspectionDetailsViewModel model)
        {
            var sharePointToken = await O365Util.GetAccessToken(ServiceResources.DemoSite);

            var service = new TasksService(sharePointToken);
            await service.CompleteRepairAssignmentTask(model.incidentId);

            var dashboardModel = new Dashboard(sharePointToken);
            var calendarEvent  = await dashboardModel.ScheduleRepair(model);

            await O365CalendarController.Create(calendarEvent);

            return(RedirectToAction("InspectionDetails", new { id = model.incidentId }));
        }
Esempio n. 10
0
        public async Task <ActionResult> CreateDemoData(SuiteLevelWebApp.Models.ProvisionDemoData model)
        {
            string token = await O365Util.GetAccessToken(ServiceResources.Dashboard);

            using (var clientContext = TokenHelper.GetClientContextWithAccessToken(DemoSiteCollectionUrl, token))
            {
                AuthenticationHelper adHelp = new AuthenticationHelper();
                await adHelp.CreateADUsersAndGroups();

                SiteProvisioning siteProvisioning = new SiteProvisioning(clientContext);
                siteProvisioning.AddSiteContents();
                siteProvisioning.UpdateInspectionListItem(model.dateDemo);

                model.Message        = "The AAD Groups, AAD Users, and demo data have been created successfully.  The initial password for all the users is: TempP@ssw0rd!";
                TempData["datetime"] = model;
                return(RedirectToAction("ProvisionDemoData"));
            }
        }
Esempio n. 11
0
        public async Task <ActionResult> InspectionDetails(int Id)
        {
            await O365Util.GetAccessToken(Capabilities.Mail); // Prepare Outlook token in advance.

            var sharePointToken = await O365Util.GetAccessToken(ServiceResources.DemoSite);

            Dashboard dashboardModel = new Dashboard(sharePointToken);
            var       model          = await dashboardModel.GetDashboardInspectionDetailsViewModel(Id);

            if (model == null)
            {
                return(new RedirectResult("/Dashboard/Index"));
            }
            else if (model.viewName == "schedule a repair")
            {
                ViewBag.RepairPeopleList = new SelectList(model.repairPeople, "sl_emailaddress", "Title");
            }
            return(View(model));
        }