public string UploadContactPicture string contactId string name Int32

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
public string UploadContactPicture(string contactId, string name , Int32 fileLen )//, byte[] uploadFile)
{
//contactId = "C082C314-7DF3-DD11-83FF-0003FFFB7389";
contactId = "30B02DC9-EEB1-DB11-BB12-0003FFFB7389";
byte[] uploadFile = new byte[] {1,1,1,1,1,1,1};
string fileExt = ".jpeg";
// a0bf2d28-ce5b-de11-a38b-0003ffe07389
// 00886f19-cf5b-de11-a38b-0003ffe07389
string status = "OK";
annotation ContactPicture = null;
contactId.Remove(1, 1);
contactId.Remove(35, 1);
fileExt = fileExt.Remove(0,1);
try
{
CrmService crmService = new CrmService();
#if DEBUG
crmService.Credentials = new System.Net.NetworkCredential("administrator","123456","sitcrm4");
#else
crmService.Credentials = System.Net.CredentialCache.DefaultCredentials;
#endif
ColumnSet cs = new ColumnSet();
cs.Attributes = new string[] { "contactid", "new_pictureid" };
contact cont = (contact)crmService.Retrieve(EntityName.contact.ToString(), new Guid(contactId), cs);
if (cont.contactid != null)
{
if (cont.new_pictureid == null || cont.new_pictureid == String.Empty)
{
ContactPicture = new annotation();
ContactPicture.objectid = new Lookup();
ContactPicture.objectid.Value = cont.contactid.Value;
ContactPicture.objectid.type = EntityName.contact.ToString();
ContactPicture.isdocument = new CrmBoolean();
ContactPicture.isdocument.Value = true;
ContactPicture.objecttypecode = new EntityNameReference();
ContactPicture.objecttypecode.Value = EntityName.contact.ToString();
ContactPicture.subject = CONTACT_PICTURE;
}
else
{
try
{
ContactPicture = (annotation)crmService.Retrieve(EntityName.annotation.ToString(), new Guid(cont.new_pictureid), new AllColumns());
}