Hey Guys Please suggest me whats going wrong with my nav code or C# code anything I am missing in thisintegration scenario.
In NAV -
VariableUsed-
Name-
SharePointG
DataType-
DotNet
Subtype-
SharepointIntegrationClass.SharepointIntegrationClass.‘SharepointIntegrationClass,Version=1.0.0.0, Culture=neutral, PublicKeyToken=1c6224add99e76a0’
CODE-
SharePointG := SharePointG.SharepointIntegrationClass();
SharePointG.MoveScanDocFromNav(‘xyz’,‘xvghty’,‘aaaaaaaaa’);
C# code-
public bool MoveScanDocFromNav(string ListName, string ScanID,string DealNo)
{
SPList.Lists lists = new SPList.Lists();
lists.Url = _SiteUrl + “/_vti_bin/Lists.asmx”;
lists.Credentials = new System.Net.NetworkCredential(_UserID, _Password, _Domain);
XmlDocument xmlDoc = new XmlDocument();
XmlNode query = xmlDoc.CreateNode(XmlNodeType.Element, “Query”, “”);
XmlNode viewFields = xmlDoc.CreateNode(XmlNodeType.Element, “ViewFields”, “”);
XmlNode queryOptions = xmlDoc.CreateNode(XmlNodeType.Element, “QueryOptions”, “”);
queryOptions.InnerXml = @“TRUE
TRUE”;
viewFields.InnerXml = “”;
query.InnerXml = @"";
XmlNode ndListItems = lists.GetListItems(“RTN”, null, null, null, null, queryOptions, null);
xmlDoc.LoadXml(ndListItems.OuterXml);
XmlNodeList folders = xmlDoc.GetElementsByTagName(“z:row”);
string folderDetails = “”;
foreach (XmlNode folder in folders)
{
folderDetails += “Title: " + folder.Attributes[“ows_FileRef”].Value + “\n” + “”;
if (folderDetails.Contains(ScanID))
{
if (folderDetails.Contains(”.pdf"))
{
CopyDocuments(folder.Attributes[“ows_FileRef”].Value, DealNo, ScanID);
}
}
}
return true;
}
public string CopyDocuments(string url, string DealNo, string ScanID)
{
try
{
string srtDealNo = DealNo;
string Year = “2016”;
string RegionNo = srtDealNo.Substring(0, 3);
string StoreNo = srtDealNo.Substring(0, 6);
string CycleNo = srtDealNo.Substring(0, 9);
CreateSubFolderFolder(“RTN”, Year, RegionNo, StoreNo, CycleNo, DealNo);
SPCopy.Copy myCopyService = new SPCopy.Copy();
myCopyService.Credentials =
System.Net.CredentialCache.DefaultCredentials;
myCopyService.Credentials = new System.Net.NetworkCredential(_UserID, _Password, _Domain);
string[] copySource = url.Split(’#’);
string finalURL = _SiteUrl + copySource[1];
string DocumentType = “”;
if (finalURL.Contains(“Contract”))
{
DocumentType = “Contract”;
}
if (finalURL.Contains(“AdCopy”))
{
DocumentType = “AdCopy”;
}
string strDesUR = _SiteUrl + “RTN/” + Year + “/” + RegionNo + “/” + StoreNo + “/” + CycleNo + “/” + DealNo + “/” + DocumentType + “/” + DocumentType + “.pdf”;
string[] copyDest = { strDesUR, strDesUR };
SPCopy.FieldInformation myFieldInfo = new
SPCopy.FieldInformation();
SPCopy.FieldInformation[] myFieldInfoArray = { myFieldInfo };
byte[] myByteArray;
uint myGetUint = myCopyService.GetItem(finalURL,
out myFieldInfoArray, out myByteArray);
SPCopy.CopyResult myCopyResult1 = new SPCopy.CopyResult();
SPCopy.CopyResult myCopyResult2 = new SPCopy.CopyResult();
SPCopy.CopyResult[] myCopyResultArray = { myCopyResult1, myCopyResult2 };
try
{
uint myCopyUint = myCopyService.CopyIntoItems(finalURL, copyDest,
myFieldInfoArray, myByteArray, out myCopyResultArray);
if (myCopyUint == 0)
{
int idx = 0;
foreach (SPCopy.CopyResult myCopyResult in myCopyResultArray)
{
string opString = (idx + 1).ToString();
if (myCopyResultArray[idx].ErrorMessage == null)
{
return “Copy operation complete”;
}
else
{
return “Error!!!”;
}
idx++;
}
}
return “Copy operation complete”;
}
catch (Exception exc)
{
return exc.Message;
}
}
catch (Exception ex)
{
return ex.Message;
}
}