public void Execute(IServiceProvider serviceProvider) { var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); ITracingService trace = (ITracingService)serviceProvider.GetService(typeof(ITracingService)); IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = serviceFactory.CreateOrganizationService(null); try { trace.Trace("MessageName: {0}", context.MessageName); switch (Util.Utilitario.ConverterEnum <Domain.Enum.Plugin.MessageName>(context.MessageName)) { case Domain.Enum.Plugin.MessageName.Create: var entidade = (Entity)context.InputParameters["Target"]; Domain.Model.ArquivoDeSellOut ArquivoDeSellOut = entidade.Parse <Domain.Model.ArquivoDeSellOut>(context.OrganizationName, context.IsExecutingOffline); if (ArquivoDeSellOut != null && !string.IsNullOrEmpty(ArquivoDeSellOut.Nome)) { SharepointServices sharepointServices = new SharepointServices(context.OrganizationName, context.IsExecutingOffline, service); sharepointServices.CriarDiretorio <Domain.Model.ArquivoDeSellOut>(ArquivoDeSellOut.Nome, ArquivoDeSellOut.ID.Value); trace.Trace(sharepointServices.Trace.StringTrace.ToString()); } break; } } catch (Exception ex) { Intelbras.CRM2013.Util.Utilitario.TratarErro(ex); throw ex; } }
public void TestarSellOut() { //4457b34c-b1c8-e411-bfbc-00155d013e80 Guid arquivoGuid; string GuidEntidade = "4457b34c-b1c8-e411-bfbc-00155d013e80"; int status = 993520001; string resposta; try { if (!Guid.TryParse(GuidEntidade, out arquivoGuid)) { throw new ArgumentException("Guid em formato inválido."); } Domain.Model.ArquivoDeSellOut arquivoSellout = new Domain.Model.ArquivoDeSellOut(ConfigurationManager.GetSettingValue("OrganizacaoIntelbras"), false); arquivoSellout.Status = status; arquivoSellout.ID = arquivoGuid; arquivoSellout.DataDeProcessamento = DateTime.Now; arquivoSellout = new Intelbras.CRM2013.Domain.Servicos.ArquivoDeSellOutServices(ConfigurationManager.GetSettingValue("OrganizacaoIntelbras"), false).Persistir(arquivoSellout); if (arquivoSellout == null) { throw new ArgumentException("Não foi possível atualizar o status do SellOut"); } resposta = ""; } catch (Exception e) { resposta = e.Message; } }