Ok
I've already found this source
my problem in an other
I have to add an activity with attachmnets, my code is the follow it create the activity but doesn't attach anyting. Can you help me? Thanks
oAct = (SAPbobsCOM.Activity)oActivityServ.GetDataInterface(SAPbobsCOM.ActivitiesServiceDataInterfaces.asActivity);
//oAct.CardCode = oBP.CardCode;
//oAct.HandledByEmployee = 2;
//oAct.ActivityDate = DateTime.Parse("28/11/2012");
//lClgCode = lClgCode + 1;
//oAct.ActivityCode = lClgCode;
oAct.ActivityDate = dttm;
oAct.StartDate = dttm;
oAct.StartTime = dttm;
oAct.EndTime = dttm;
oAct.Activity = SAPbobsCOM.BoActivities.cn_Other;
oAct.ActivityType = iIDTipo;
oAct.Subject = iIDOggetto;
sVal = Left(sOggetto, 100);
oAct.Details = sVal;
oAct.Notes = sVal;
iVal = 4;
oAct.DocType = iVal.ToString().Trim();
oAct.DocEntry = sKeyItem;
/*oActParams = oActivityServ.AddActivity(oAct);
lAggiunti = lAggiunti + 1;
if (oCompany.InTransaction)
{
//oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
}
else
{
throw new Exception("ERROR: Transaction closed before EndTransaction");
}
oCompany.StartTransaction();
*/
oAttach = (SAPbobsCOM.Attachments2)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2);
int iAttchEntry = oAct.AttachmentEntry;
if (oAttach.GetByKey(iAttchEntry))
{
b_TestNewTMP = true;
iMax = oAttach.Lines.Count - 1;
b_TestFirst = true;
if (b_TestExist)
{ //never enter here
for (i = 0; i <= iMax; i++)
{
oAttach.Lines.SetCurrentLine(i);
sVal = oAttach.Lines.FileName.Trim();
if (sVal != "")
{
....
}
}
}
sVal = Path.GetFileNameWithoutExtension(sFilePath);
oAttach.Lines.FileName = sVal;
sVal = Path.GetExtension(sFilePath);
sVal = sVal.Replace(".", "");
oAttach.Lines.FileExtension = sVal;
sVal = Path.GetDirectoryName(sFilePath);
oAttach.Lines.SourcePath = sVal;
sDestinationFile = path + Path.GetFileName(sFilePath);
oAttach.Lines.Override = SAPbobsCOM.BoYesNoEnum.tYES;
if (File.Exists(sDestinationFile))
{
System.IO.File.Delete(sDestinationFile);
}
lRetCode = oAttach.Add();
if (lRetCode != 0)
{
oCompany.GetLastError(out lErrCode, out sErrMsg);
sVal = "(Art." + sKeyItem + ")";
textErrors.AppendText(sVal + ": " + sErrMsg + " (" + lErrCode + ")\r\n");
return;
}