示例#1
0
 public HomeController()
 {
     _model = new Models.DemoDataModel
     {
         DocumentLibraryName = DEFAULT_LIBNAME,
         ViewName            = DEFAULT_VIEWNAME,
         PageName            = DEFAULT_PAGENAME
     };
     // Register events.
     helper.SPAppHelper.Instance.CreatedDocLib      += Instance_CreatedDocLib;
     helper.SPAppHelper.Instance.DocLibExists       += Instance_DocLibExists;
     helper.SPAppHelper.Instance.FileUploaded       += Instance_FileUploaded;
     helper.SPAppHelper.Instance.ViewExists         += Instance_ViewExists;
     helper.SPAppHelper.Instance.CreatedView        += Instance_CreatedView;
     helper.SPAppHelper.Instance.PageExists         += Instance_PageExists;
     helper.SPAppHelper.Instance.CreatedPage        += Instance_CreatedPage;
     helper.SPAppHelper.Instance.ContentAddedToPage += Instance_ContentAddedToPage;
 }
示例#2
0
 public ActionResult Submit(Models.DemoDataModel model)
 {
     _model = model;
     if (string.IsNullOrEmpty(model.DocumentLibraryName))
     {
         model.DocumentLibraryName = DEFAULT_LIBNAME;
     }
     if (string.IsNullOrEmpty(model.ViewName))
     {
         model.ViewName = DEFAULT_VIEWNAME;
     }
     if (string.IsNullOrEmpty(model.PageName))
     {
         model.PageName = DEFAULT_PAGENAME;
     }
     helper.Logger.LogInfo("Home Controller - Submit", () =>
     {
         User spUser = null;
         ExecuteWithContext(clientContext =>
         {
             spUser = clientContext.Web.CurrentUser;
             clientContext.Load(spUser, user => user.Title);
             clientContext.ExecuteQuery();
             ViewBag.UserName    = spUser.Title;
             ViewBag.UserIsAdmin = helper.SPAppHelper.Instance.CurrentUserIsAdmin(clientContext);
             if (ModelState.IsValid)
             {
                 // Process
                 helper.SPAppHelper.Instance.CreateDocumentLibrary(clientContext, model.DocumentLibraryName);
                 helper.SPAppHelper.Instance.CreateListView(clientContext, model.DocumentLibraryName, model.ViewName);
                 helper.SPAppHelper.Instance.CreateSitePage(clientContext, model.PageName, model.DocumentLibraryName);
                 helper.SPAppHelper.Instance.UploadDocumentToSharePoint(clientContext, model.file1, model.DocumentLibraryName);
                 helper.SPAppHelper.Instance.UploadDocumentToSharePoint(clientContext, model.file2, model.DocumentLibraryName);
                 helper.SPAppHelper.Instance.UploadDocumentToSharePoint(clientContext, model.file3, model.DocumentLibraryName);
             }
         });
     });
     return(View("Index", model));
 }