Skip to content

Commit

Permalink
Merge pull request #990 from SubPointSolutions/beta
Browse files Browse the repository at this point in the history
beta -> dev -> Sergei Snitko, fixed ListItemAllFields error for WebPart Pages not in lists
  • Loading branch information
SubPointSupport authored Mar 29, 2017
2 parents 438bb44 + f35899c commit 7022a43
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions SPMeta2/SPMeta2.CSOM/ModelHandlers/ModuleFileModelHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ private void ProcessWebFolder(FolderModelHost folderHost, ModuleFileDefinition m
}
else
{
#if NET35
throw new SPMeta2Exception(string.Format("SP2010 CSOM implementation does no support file more than {0}. Checkout FileCreationInformation and avialabe Content size.", ContentStreamFileSize));
#if NET35
throw new SPMeta2Exception(string.Format("SP2010 CSOM implementation does no support file more than {0}. Checkout FileCreationInformation and avialabe Content size.", ContentStreamFileSize));
#endif

#if !NET35
Expand Down Expand Up @@ -191,8 +191,8 @@ private void ProcessContentTypeFolder(FolderModelHost folderHost, ModuleFileDefi
}
else
{
#if NET35
throw new SPMeta2Exception(string.Format("SP2010 CSOM implementation does no support file more than {0}. Checkout FileCreationInformation and avialabe Content size.", ContentStreamFileSize));
#if NET35
throw new SPMeta2Exception(string.Format("SP2010 CSOM implementation does no support file more than {0}. Checkout FileCreationInformation and avialabe Content size.", ContentStreamFileSize));
#endif

#if !NET35
Expand Down Expand Up @@ -327,7 +327,13 @@ public static void WithSafeFileOperation(List list, File file,
if (file != null)
{
context.Load(file, f => f.Exists);
context.Load(file, f => f.ListItemAllFields); //SergeiSnitko. Need to be loaded to get if object is null
context.ExecuteQueryWithTrace();
//SergeiSnitko. I don't know all logic based on doesFileHasListItem. So I fill doesFileHasListItem by the real value
//of ListItem existing only if doesFileHasListItem is true. This action helps to prevent exceptions on web part provision
//on the page without ListItem not only under Forms folder (for example Forms/ContentTypeName/videoplayerpage.aspx fires exception)
doesFileHasListItem = doesFileHasListItem ? !(bool)file.ListItemAllFields.ServerObjectIsNull : doesFileHasListItem;


if (file.Exists)
{
Expand Down Expand Up @@ -449,9 +455,9 @@ public static void WithSafeFileOperation(List list, File file,
if (list != null && spFile != null && (list.EnableModeration))
{

#if NET35
// TODO, Approve() method is not exposed
throw new SPMeta2NotImplementedException("Not implemented for SP2010 - https://github.com/SubPointSolutions/spmeta2/issues/771");
#if NET35
// TODO, Approve() method is not exposed
throw new SPMeta2NotImplementedException("Not implemented for SP2010 - https://github.com/SubPointSolutions/spmeta2/issues/771");
#endif

#if !NET35
Expand Down Expand Up @@ -558,8 +564,8 @@ private File ProcessFile(FolderModelHost folderHost, ModuleFileDefinition defini

#endif

#if NET35
var doesFileHasListItem = true;
#if NET35
var doesFileHasListItem = true;
#endif

WithSafeFileOperation(list, file, f =>
Expand All @@ -580,8 +586,8 @@ private File ProcessFile(FolderModelHost folderHost, ModuleFileDefinition defini
}
else
{
#if NET35
throw new SPMeta2Exception(string.Format("SP2010 CSOM implementation does no support file more than {0}. Checkout FileCreationInformation and avialabe Content size.", ContentStreamFileSize));
#if NET35
throw new SPMeta2Exception(string.Format("SP2010 CSOM implementation does no support file more than {0}. Checkout FileCreationInformation and avialabe Content size.", ContentStreamFileSize));
#endif
#if !NET35
Expand Down

0 comments on commit 7022a43

Please sign in to comment.