public static void InsertIntoDE(CallCenterRequest request) { sfmc = new SFMCHelper(int.Parse(ConfigurationManager.AppSettings["SFMC.MID"].ToString())); Dictionary <string, string> values = new Dictionary <string, string>(); values.Add("ID", Guid.NewGuid().ToString()); values.Add("Data", JsonConvert.SerializeObject(request)); values.Add("Activa", true.ToString()); Task.Run(() => sfmc.CreateDataExtensionRow(ConfigurationManager.AppSettings["CallCenterDataEntry"], values)); }
public static RBResult SendActiveRecords() { int mid = int.Parse(ConfigurationManager.AppSettings["SFMC.MID"]); SFMCHelper sfmc = new SFMCHelper(mid); var deRows = sfmc.GetDataExtensionRows(mid, ConfigurationManager.AppSettings["CallCenterDataEntry"], new string[] { "ID", "Data", "Activa" }, new SimpleFilterPart { Property = "Activa", SimpleOperator = SimpleOperators.equals, Value = new string[] { "True" } }); if (deRows.Count == 0) { return(new RBResult()); } _logger.DebugFormat("[{0}] active records recovered from Data Extension.", deRows.Count); bpelregisterblasters_client_ep client = new bpelregisterblasters_client_ep(ConfigurationManager.AppSettings["RB.URL"]); List <processArrClientes> arrClients = new List <processArrClientes>(); foreach (var row in deRows) { var data = row.Properties.Where(p => p.Name == "Data").FirstOrDefault().Value; var id = row.Properties.Where(p => p.Name == "ID").FirstOrDefault().Value; try { arrClients.Add(DEtoClient(row)); } catch (Exception ex) { _logger.ErrorFormat("Error trying to deserialize object. ID:{0} Data:{1} Exception:{2}", id, data, ex); throw ex; } } _logger.DebugFormat("Updating status for [{0}] records on Data Extension", deRows.Count); //Upsert records into DE sfmc.UpdateBatch(deRows, mid, ConfigurationManager.AppSettings["CallCenterDataEntry"]); _logger.DebugFormat("[{0}] Records to be send to Register Blasters", arrClients.Count); processResponse response; try { response = client.process(new process { Login = new processLogin { User = ConfigurationManager.AppSettings["RB.User"], Password = ConfigurationManager.AppSettings["RB.Password"], Ip = ConfigurationManager.AppSettings["RB.IP"] }, arrClientes = arrClients.ToArray() }); _logger.DebugFormat("Send to Register Blasters complete with response: {0} ({1})", response.Result.Result, response.Result.ResultDescription); } catch (Exception ex) { _logger.ErrorFormat("Error sending request to Register Blaster. {0}", ex); return(new RBResult { ResponseResult = "UnknownError", Data = deRows }); } return(new RBResult { ResponseResult = response.Result.Result, Data = deRows }); }