05.08.2008, 12:52
|
#12
|
Участник
Регистрация: 30.07.2008
Адрес: Киев
|
//Create a new annotation object, which represents the notes you see in CRM.
annotation newsgroupsNote = newannotation();
//The annotation's body. It is displayed in the notes view.
newsgroupsNote.notetext = "Document"; // - \r\n
//The objectid specifies to which business object the annotation belongs.
newsgroupsNote.objectid = newLookup();
newsgroupsNote.objectid.type = EntityName.account.ToString();
newsgroupsNote.objectid.Value = newGuid(context.OutputParameters.Properties["id"].ToString());
//The objecttypecode specifies the type of the parent entity.
newsgroupsNote.objecttypecode = newEntityNameReference();
newsgroupsNote.objecttypecode.Value = EntityName.account.ToString();
//The subject.
newsgroupsNote.subject = "You should look ready document";
//Create the annotation
ICrmService service = context.CreateCrmService(true);
Guid annotID = service.Create(newsgroupsNote);
account ent = (account)service.Retrieve(EntityName.account.ToString(),newGuid(context.OutputParameters.Properties["id"].ToString()), newAllColumns());
annotation oAnnotation = newannotation();
XmlDocument doc = newXmlDocument();
doc.Load(@"...");
... что то делаем (кому что надо )
//
doc.Save(@"..." + name); // .doc
StreamReader reader = newStreamReader(@"..." + name);
string input = GetBase64StringFromFile(@"..." + name);
TargetUpdateAnnotation tua = newTargetUpdateAnnotation();
Key oKey = newKey();
oKey.Value = annotID;
oAnnotation.annotationid = oKey;
oAnnotation.filename =
oAnnotation.filename = name;
oAnnotation.mimetype = "application/xml";
oAnnotation.documentbody = input;
CrmNumber oNumber = newCrmNumber();
oNumber.Value = 4;
oAnnotation.filesize = oNumber;
tua.Annotation = oAnnotation;
UpdateRequest req = newUpdateRequest();
req.Target = tua;
UpdateResponse resp = (UpdateResponse)service.Execute(req);
|
|