Domanda

I have checked out couple of files in document library manually by right clicking on item and click on checkout. Then i am using following code to checked in files that i manually checked out, But after successfully running the code, i see that files are not checked in, whats wrong with this code. This code is running under timer job. To debug i first restart the timer service and then debug the code. I debug the code line by line and i can see all the checked out files during debug. This line Item.File.CheckIn("Checked in programatically!"); also executes successfully. Any thoughts whats wrong with this code

SPList MyList = web.Lists.TryGetList("Documents");
if (MyList != null)
{

SPDocumentLibrary MyDoc= (SPDocumentLibrary)MyList;
SPQuery checkedOutFiles = new SPQuery();

checkedOutFiles.ViewFields = "<FieldRef Name='ID' />";
checkedOutFiles.ViewFieldsOnly = true;
checkedOutFiles.ViewAttributes = "Scope=\"Recursive\"";

 SPListItemCollection items = MyDoc.GetItems(checkedOutFiles);
 foreach (SPListItem item in items)
 {
    if(item.File.ServerRelativeUrl.EndsWith(".pdf"))
    {
      if (Item.File.LockId != null)
       { 
         Item.File.CheckIn("Checked in programatically!");
       }
    }
} 
È stato utile?

Soluzione

I think you need to specify what type of CheckIn you're doing. Such as

Item.File.CheckIn("Checked in programatically!", SPCheckinType.MajorCheckIn);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top