I have these two code snippets:
- public void AddDocumentSet(string siteUrl, string libName, string docSetName, string mSISDN, string accountNumber, string hardCopyLocation, string verifiedBy, DateTime veriDate)
- {
- ClientContext clientContext = new ClientContext(siteUrl);
- Web web = clientContext.Web;
- List byTitle = clientContext.Web.Lists.GetByTitle(libName);
- clientContext.Load
(clientContext.Site); - ContentTypeCollection contentTypes = byTitle.ContentTypes;
- clientContext.Load
(contentTypes, (Expression >>) (types => ClientObjectQueryableExtension.Includeobject (types, new Expressionobject>>[] - {
- (Expression
object >>) (type => type.Id), - (Expression
object >>) (type => type.Name), - (Expression
object >>) (type => type.Parent) - })));
- IEnumerable
source = clientContext.LoadQuery >>) (c => c.Name == "Earchive document")));(Queryable.Where ((IQueryable ) contentTypes, (Expression bool - clientContext.ExecuteQuery();
- ContentType contentType = Enumerable.FirstOrDefault
(source); - ListItem listItem = byTitle.AddItem(new ListItemCreationInformation()
- {
- UnderlyingObjectType = FileSystemObjectType.Folder,
- LeafName = docSetName
- });
- listItem["ContentTypeId"] = (object) contentType.Id.ToString();
- listItem["Title"] = (object) "Documents for account ";
- listItem["MSISDN"] = (object) mSISDN;
- listItem["Account_x0020_Number"] = (object) accountNumber;
- listItem["Hard_x0020_Copy_x0020_Location"] = (object) hardCopyLocation;
- listItem["Verified by"] = (object) verifiedBy;
- listItem["Date of verification"] = (object) veriDate;
- listItem.Update();
- clientContext.Load
- (byTitle);
- clientContext.ExecuteQuery();
- }
- public void AddDocument(string siteUrl, string libName, string docListUrl, string docName, byte[] docStream, string mSISDN, string accountNumber, string hardCopyLocation, string documentName, string verifiedBy, DateTime veriDate)
- {
- ClientContext clientContext = new ClientContext(siteUrl);
- File file = clientContext.Web.Lists.GetByTitle(libName).RootFolder.Files.Add(new FileCreationInformation()
- {
- Content = docStream,
- Overwrite = false,
- Url = siteUrl + docListUrl + docName
- });
- file.ListItemAllFields["MSISDN"] = (object) mSISDN;
- file.ListItemAllFields["Account_x0020_Number"] = (object) accountNumber;
- file.ListItemAllFields["Hard_x0020_Copy_x0020_Location"] = (object) hardCopyLocation;
- file.ListItemAllFields["Document_x0020_Name"] = (object) documentName;
- file.ListItemAllFields["Verified by"] = (object) verifiedBy;
- file.ListItemAllFields["Date of Verification"] = (object) veriDate;
- file.ListItemAllFields.Update();
- clientContext.ExecuteQuery();
And I am calling them from another script C# script inside program.
- r.AddDocumentSet(XXX +
- Document.Field("Document Section 1\\Account").Value,
- Document.Field("Document Section 1\\MSISDN").Value.ToString(),
- Document.Field("Document Section 1\\Account").Value.ToString(),
- Document.Field("Document Section 1\\Hard Copy Location").Value.ToString(),
- Document.Field("Document Section 1\\Verified by").Value.ToString(),
- Document.Field("Document Section 1\\Date of Verifica00tion").Value.ToString());
- Processing.ReportMessage("Document Set created. ");
- }catch(System.Exception e){
- Processing.ReportMessage("Document Set already exists. ");
- }
- r1.AddDocument(XXX +Document.Field("Document Section 1\\Account").Value+"/",
- "contract_"+
- Document.Field("Document Section 1\\Account").Value + "(" +
- Document.Field("Document Section 1\\MSISDN").Value + ").pdf", bytes
- , Document.Field("Document Section 1\\MSISDN").Value.ToString()
- , Document.Field("Document Section 1\\Account").Value.ToString()
- , Document.Field("Document Section 1\\Hard Copy Location").Value.ToString()
- , Document.Field("Document Section 1\\Document Name").Value.ToString()
- , Document.Field("Document Section 1\\Verified by").Value.ToString()
- , Document.Field("Document Section 1\\Date of Verifica00tion").Value.ToString());
- }
And I get these errors:
No overload for method 'AddDocumentSet' takes '8' arguments (line 6, pos 1) No overload for method 'AddDocument' takes '11' arguments (line 69, pos 1)
I am not a C# rockstar but I have tried everything. rebuilt dll, rewriten the snippets again, but nothing helped. I hope someone could show me the right code.
Cassie ModPosted Feb 25, 2016, 11:28 AM