Ir para conteúdo

POWERED BY:

ghlevin

Members
  • Total de itens

    74
  • Registro em

  • Última visita

Reputação

0 Comum

Sobre ghlevin

  1. Possuo uma Console Application em C# que faz a extração de dados do Dynamics 365 Customer Voice, da Microsoft. O código abaixo pega dados de tabelas de Projetos, Pesquisas, Perguntas e Respostas respectivamente. Os dados extraídos vão para arquivos JSON que ficam salvos no meu HD. using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Query; using System; using System.Collections.Generic; using System.Linq; using System.Text; using UmbracoMVC.App_Code.Infrastructure.CRMIntegration.Business; using System.IO; using Microsoft.Crm.Sdk.Messages; using System.Globalization; using E2BWorkflow.Classes; using System.Web.Management; using System.ServiceModel; using System.Drawing; using System.Web.UI.WebControls; using System.Web.Script.Serialization; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { GetCustomerVoice(); } public static void GetCustomerVoice() { IOrganizationService crmServiceTo; crmServiceTo = Connect.Crm("myemail@e-mail.com", "mypassword", "https://mydynamics.crm4.dynamics.com/XRMServices/2011/Organization.svc"); // Get Projects QueryExpression qP = new QueryExpression("msfp_project"); qP.ColumnSet = new ColumnSet(true); var projects = crmServiceTo.RetrieveMultiple(qP); foreach (var p in projects.Entities) { msfp_project project = p.ToEntity<msfp_project>(); } var projectsList = projects.Entities.Select( s => new { msfp_projectId = s.Attributes["msfp_projectid"], msfp_name = s.Attributes["msfp_name"] } ).ToList(); var jsonSerialiser = new JavaScriptSerializer(); var json = jsonSerialiser.Serialize(projectsList); System.IO.File.WriteAllText(@"C:\MyDirectory\projects.json", json); // Get Surveys QueryExpression qS = new QueryExpression("msfp_survey"); qS.ColumnSet = new ColumnSet(true); var surveys = crmServiceTo.RetrieveMultiple(qS); foreach (var s in surveys.Entities) { msfp_survey survey = s.ToEntity<msfp_survey>(); } var surveysList = surveys.Entities.Select( s => new { msfp_surveyId = s.Attributes["msfp_surveyid"], msfp_name = s.Attributes.Contains("msfp_name") ? s.GetAttributeValue<string>("msfp_questiontext") : "", msfp_anonymousurl = s.Attributes.Contains("msfp_anonymousurl") ? s.GetAttributeValue<string>("msfp_anonymousurl") : "", msfp_friendlyname = s.Attributes.Contains("msfp_friendlyname") ? s.GetAttributeValue<string>("msfp_friendlyname") : "", msfp_surveyurl = s.Attributes.Contains("msfp_surveyurl") ? s.GetAttributeValue<string>("msfp_surveyurl") : "", msfp_projectId = s.Attributes.Contains("msfp_project") && s.GetAttributeValue<EntityReference>("msfp_project").Id != null ? s.GetAttributeValue<EntityReference>("msfp_project").Id : Guid.Empty } ).ToList(); jsonSerialiser = new JavaScriptSerializer(); json = jsonSerialiser.Serialize(surveysList); System.IO.File.WriteAllText(@"C:\MyDirectory\surveys.json", json); // Get Questions QueryExpression qQ = new QueryExpression("msfp_question"); qQ.ColumnSet = new ColumnSet(true); var questions = crmServiceTo.RetrieveMultiple(qQ); foreach (var q in questions.Entities) { msfp_question question = q.ToEntity<msfp_question>(); } var questionsList = questions.Entities.Select( s => new { msfp_questionId = s.Attributes["msfp_questionid"], msfp_questionText = s.Attributes.Contains("msfp_questiontext") ? s.GetAttributeValue<string>("msfp_questiontext") : "", msfp_surveyId = s.Attributes.Contains("msfp_survey") && s.GetAttributeValue<EntityReference>("msfp_survey").Id != null ? s.GetAttributeValue<EntityReference>("msfp_survey").Id : Guid.Empty } ).ToList(); jsonSerialiser = new JavaScriptSerializer(); json = jsonSerialiser.Serialize(questionsList); System.IO.File.WriteAllText(@"C:\MyDirectory\questions.json", json); //Get Question Responses QueryExpression qR = new QueryExpression("msfp_questionresponse"); qR.ColumnSet = new ColumnSet(true); var responses = crmServiceTo.RetrieveMultiple(qR); foreach (var r in responses.Entities) { msfp_questionresponse response = r.ToEntity<msfp_questionresponse>(); } var responsesList = responses.Entities.Select( s => new { msfp_questionresponseId = s.Attributes["msfp_questionresponseid"], msfp_questionresponse = s.Attributes["msfp_name"], msfp_questionId = s.GetAttributeValue<EntityReference>("msfp_questionid").Id } ).ToList(); jsonSerialiser = new JavaScriptSerializer(); json = jsonSerialiser.Serialize(responsesList); System.IO.File.WriteAllText(@"C:\MyDirectory\responses.json", json); Console.WriteLine("END"); Console.ReadKey(); } } } Agora o que eu preciso é que esses JSONs sejam salvos dentro de um contêiner de um blob em uma Conta de Armazenamento Azure. Procurei várias soluções na Internet, mas não estou bem certo do que deveria usar em uma Console Application.
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.