0
我需要使用Web API將現有活動的附件更新到Acumatica Partner's Portal中的現有案例。使用附件更新現有活動
我已經爲此編寫了代碼,但它始終更新爲第一個活動,而不是用於傳遞noteid的活動。
我這樣做是通過檢索創建的活動的noteid,然後發送相同的noteid以及caseid來更新附件。
下面是用附件更新現有活動的代碼,請建議。
var origActivities = context1.Export
\t (
\t \t new SP203010WS.Command[]
\t \t {
\t \t \t \t new SP203010WS.Value
\t \t \t \t {
\t \t \t \t \t Value = currentAcumaticaCaseNo,
\t \t \t \t \t LinkedCommand = content.Case.CaseID
\t \t \t \t },
\t \t \t \t content.Activities.Type,
\t \t \t \t content.Activities.Summary,
\t \t \t \t new SP203010WS.Field
\t \t \t \t {
\t \t \t \t \t FieldName = "NoteID",
\t \t \t \t \t ObjectName = content.Activities.Summary.ObjectName
\t \t \t \t },
\t \t \t \t content.Activities.CreatedAt,
\t \t },
\t \t null, 0, false, false
\t);
Guid?[] origActivityNoteID = null;
DateTime?[] origActivityCreatedDate = null;
if (origActivities != null && origActivities.Count() > 0)
{
\t origActivityNoteID = new Guid?[origActivities.Count()];
\t origActivityCreatedDate = new DateTime?[origActivities.Count()];
\t int i = 0;
\t foreach (string[] activity in origActivities)
\t {
\t \t origActivityNoteID[i] = new Guid(activity[2].ToString());
\t \t origActivityCreatedDate[i] = Convert.ToDateTime(activity[3]);
\t \t i++;
\t }
}
*****Adding new activity*****
var newActivities = context.Export
\t (
\t \t new SP203010WS.Command[]
\t \t {
\t \t \t \t new SP203010WS.Value
\t \t \t \t {
\t \t \t \t \t Value = currentAcumaticaCaseNo,
\t \t \t \t \t LinkedCommand = content.Case.CaseID
\t \t \t \t },
\t \t \t \t content.Activities.Type,
\t \t \t \t content.Activities.Summary,
\t \t \t \t new SP203010WS.Field
\t \t \t \t {
\t \t \t \t \t FieldName = "NoteID",
\t \t \t \t \t ObjectName = content.Activities.Summary.ObjectName
\t \t \t \t },
\t \t \t \t content.Activities.CreatedAt,
\t \t },
\t \t null, 0, false, false
\t);
Guid? newActivityNoteID = null;
for (var i = 1; i <= newActivities.GetUpperBound(0); i++)
{
\t if(origActivityNoteID != null && origActivityCreatedDate != null)
\t {
\t \t if((Array.IndexOf<Guid?>(origActivityNoteID, new Guid(newActivities[i][2])) <= 0) &&
\t \t \t \t (Array.IndexOf<DateTime?>(origActivityCreatedDate, Convert.ToDateTime(newActivities[i][3])) <= 0))
\t \t {
\t \t \t newActivityNoteID = new Guid(newActivities[i][2]);
\t \t \t break;
\t \t }
\t }
}
*****getting a list of all attachments*****
foreach (FileInfo fi in fileInfo)
{
\t SP203010WS.Content[] content1 = context.Submit
\t (
\t \t new SP203010WS.Command[]
\t \t \t {
\t \t \t \t new SP203010WS.Value
\t \t \t \t {
\t \t \t \t \t //Value = actiPartner.AcumaticaCaseID,
\t \t \t \t \t Value = currentAcumaticaCaseNo,
\t \t \t \t \t LinkedCommand = CR306000.Case.CaseID
\t \t \t \t },
\t \t \t \t new SP203010WS.Value
\t \t \t \t {
\t \t \t \t \t Value = newActivityNoteID.ToString(),
\t \t \t \t \t LinkedCommand = new SP203010WS.Field { FieldName="NoteID", ObjectName="Activities" }
\t \t \t \t },
\t \t \t \t new SP203010WS.Value
\t \t \t \t {
\t \t \t \t \t FieldName = fi.Name,
\t \t \t \t \t Value = Convert.ToBase64String(fi.BinData),
\t \t \t \t \t LinkedCommand = CR306000.Activities.ServiceCommands.Attachment
\t \t \t \t },
\t \t \t \t CR306000.Actions.Save
\t \t \t }
\t);
}
仍然無法正常工作並更新第一個活動。 – Krunal
你能解釋一下你爲什麼混合來自SP203010WS和CR306000命名空間的類嗎?不知道這應該如何工作... – RuslanDev
對不起,混亂。 CR306000不過是一個對象名稱。它已經在工作,但進行錯誤的活動。以下是供您參考的代碼 SP203010WS.Screen context = new SP203010WS.Screen(); context.CookieContainer = new System.Net.CookieContainer(); context.AllowAutoRedirect = true; context.EnableDecompression = true; context.Timeout = 1000000; context.Url =「https://sso.acumatica.com/Soap/SP203010.asmx」; SP203010WS.LoginResult result = context.Login(username,password); SP203010WS.Content CR306000 = context.GetSchema(); – Krunal