public static void NewActivity(EtiAplicacao etiApp, string subject, string notes, int customerCode, string activityType, int nature, Byte[] bytesToWrite) { AutomaticActivityInfo obj = new AutomaticActivityInfo(); List <RelationInfo> myRelationInfo = new List <RelationInfo>(); AttachmentInfo Attach = new AttachmentInfo(); if (bytesToWrite != null) { Attach.Name = "Test.pdf"; Attach.File = System.Convert.ToBase64String(bytesToWrite); } myRelationInfo.Add(new RelationInfo((int)CodTabelas.Clientes, customerCode.ToString(), "", "", "")); obj.CodExercise = ""; obj.CodSection = ""; obj.AbrevTpDoc = ""; obj.Number = customerCode; obj.Natureza = nature; obj.CodTableDoc = -1; obj.CodActivityType = activityType; obj.Integration = false; obj.Message = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(notes)); obj.CodTableEntity = -1; obj.CodEntity = new List <int>(); obj.Relations = myRelationInfo; obj.Subject = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(subject)); obj.Contacts = new List <ContactInfo>(); if (bytesToWrite != null) { obj.Attachments = new List <AttachmentInfo>(); if (bytesToWrite != null) { obj.Attachments.Add(Attach); } } Uri url = new Uri(new Uri(etiApp.Ambiente.ServerUrl), "api/Crm/AutomaticActivity"); EtiWebClient wc = new EtiWebClient(); wc.Headers.Add("Content-Type", "application/json"); string reply = wc.UploadString(url, "POST", obj.Serialize()); }
/// <summary> /// Obtem uma tabela com as categorias da entidade, de um webservice embutido no ERP /// </summary> /// <returns></returns> private List <EntitiesCategory> GetEntitiesCategoryByWebservice() { var entitiesCategory = new List <EntitiesCategory>(); //EtiWebClient já faz a gestão dos cookies pois estamos dentro do ERP EtiWebClient web = new EtiWebClient(); NameValueCollection param = new NameValueCollection(); var serverUrl = myEtiApp.Ambiente.ServerUrl; try { var resultWS = web.DownloadData(serverUrl + "api/EntitiesCategoryTA/GetEntitiesCategory"); entitiesCategory = Newtonsoft.Json.JsonConvert.DeserializeObject <List <EntitiesCategory> >(System.Text.Encoding.UTF8.GetString(resultWS)); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(entitiesCategory); }