示例#1
0
        private void InstallListsViewsWebPartsInstall(SPView spView, bool installGrid, AppStore appStore, int parentMessageId)
        {
            if (spView == null)
            {
                throw new ArgumentNullException(nameof(spView));
            }
            var fileView = oWeb.GetFile(spView.Url);

            if (fileView.Exists)
            {
                var fileUrl = $"{appDef.fullurl}/Lists/{spView.ParentList.Title}/{spView.Title}.txt";

                var hasViewFile = false;
                try
                {
                    byte[] fileBytes = appStore.GetFile(fileUrl);
                    if (fileBytes != null)
                    {
                        var folder = oWeb.GetFolder(TempViewStorage);

                        if (!folder.Exists)
                        {
                            folder = oWeb.Folders.Add(TempViewStorage);
                        }

                        if (!bVerifyOnly)
                        {
                            folder.Files.Add($"{spView.Title}.aspx", fileBytes);
                        }

                        hasViewFile = true;
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.ToString());
                }

                if (bVerifyOnly)
                {
                    if (hasViewFile || installGrid)
                    {
                        addMessage(0, spView.Title, string.Empty, parentMessageId);
                    }
                }
                else
                {
                    InstallListsViewsWebPartsInstall(spView.Title, installGrid, parentMessageId, fileView, hasViewFile);
                }
            }
        }
示例#2
0
        private void iInstallFile(string sFileName, string sParentFolder, string sFullFile, AppStore copy)
        {
            var oParentFolder = oWeb.GetFolder(sParentFolder);

            if (oParentFolder.Exists)
            {
                var sUrl = appDef.fullurl + "/Files/" + sFullFile;

                var fileBytes = copy.GetFile(sUrl);

                oParentFolder.Files.Add(sFileName, fileBytes, true);
            }
            else
            {
                throw new Exception("Parent folder does not exist");
            }
        }