예제 #1
0
    protected void ButtonAddTask_Click(object sender, EventArgs e)
    {
        var     request = new AddOrUpdateTaskRequest();
        CrmLead crmLead = JsonConvert.DeserializeObject <CrmLead>(HiddenFieldLeadJson.Value);

        request.Update = new List <AddOrUpdateCrmTask>();
        request.Add    = new List <AddOrUpdateCrmTask>();
        {
            var _task = new AddOrUpdateCrmTask();
            _task.ElementId         = crmLead.Id;
            _task.ElementType       = 2;
            _task.Text              = TextBoxText.Text;
            _task.IsCompleted       = CheckBoxIsCompleted.Checked;
            _task.ResponsibleUserId = Convert.ToInt64(DropDownListResponsibleUserId.SelectedValue);
            _task.TaskType          = Convert.ToInt32(DropDownListTaskType.SelectedValue);
            if (TextBoxCompleteTillAt.Text != "")
            {
                _task.CompleteTillAt = DateTime.Parse(TextBoxCompleteTillAt.Text);
            }
            request.Add.Add(_task);
        }


        _service.AddOrUpdateTask(request);

        TextBoxText.Text            = "";
        CheckBoxIsCompleted.Checked = false;


        LabelMsg.Visible  = true;
        LabelMsg.CssClass = "alert alert-success";
        LabelMsg.Text     = "Задача создана";
    }
예제 #2
0
        public async Task ContactNumberHandler(IDialogContext context, IAwaitable <string> argument)
        {
            var contactNumber = await argument;

            testDriveDetail.PhoneNumber = contactNumber;

            await context.PostAsync($@"Thank you for your interest, your request has been logged. Our sales team will get back to you shortly.
                                    {Environment.NewLine}Your test drive request summary:
                                    {Environment.NewLine}Car Make: {testDriveDetail.CarMake},
                                    {Environment.NewLine}Car Model: {testDriveDetail.CarModel},
                                    {Environment.NewLine}Requested Time: {testDriveDetail.RequestedTime},
                                    {Environment.NewLine}Customer Name: {testDriveDetail.CustomerName},
                                    {Environment.NewLine}Phone Number: {testDriveDetail.PhoneNumber}");

            //CrmLead.CreateTestDrive(testDriveDetail, CrmDataConnection.GetAPI());

            CrmLead.CreateTestDrive(testDriveDetail, CrmDataConnection.GetOrgService());

            PromptDialog.Confirm(
                context: context,
                resume: AnythingElseHandler,
                prompt: "Is there anything else that I could help?",
                retry: "Sorry, I don't understand that."
                );
        }
예제 #3
0
        //45	UnQualified By Marketing	NULL
        //51	Quote Request	NULL
        //52	AE Assigned	NULL
        //81	UnQualified By Sales	NULL
        /// <summary>
        ///
        /// </summary>
        /// <param name="newLead"></param>
        private void RecordLeadStatusChangdTime(CrmLead newLead)
        {
            var eventID = 0;

            switch (newLead.StageID)
            {
            case (int)LeadENumber.NStage.UnQualifiedBySales:
                eventID = (int)LeadENumber.NHistoryEvent.UnQualifiedBySales;
                break;

            case (int)LeadENumber.NStage.UnQualifiedByMarketing:
                eventID = (int)LeadENumber.NHistoryEvent.UnQualifiedByMarketing;
                break;

            case (int)LeadENumber.NStage.QuoteRequest:
                eventID = (int)LeadENumber.NHistoryEvent.QuoteRequest;
                break;

            default:
                break;
            }

            if (eventID != 0)
            {
                UpdateHistory(newLead.LeadID, newLead.LastUpdatedBy, eventID);
            }
            LogMethods.Log.Debug("RecordLeadStatusChangdTime:Debug:" + "Done");
        }
예제 #4
0
    protected void ButtonAddNote_Click(object sender, EventArgs e)
    {
        var     request = new AddOrUpdateNoteRequest();
        CrmLead crmLead = JsonConvert.DeserializeObject <CrmLead>(HiddenFieldLeadJson.Value);

        request.Update = new List <AddOrUpdateCrmNote>();
        request.Add    = new List <AddOrUpdateCrmNote>();
        {
            var _note = new AddOrUpdateCrmNote();
            _note.ElementId         = crmLead.Id;
            _note.ElementType       = 2;
            _note.Text              = TextBoxTextNote.Text;
            _note.ResponsibleUserId = Convert.ToInt64(3160069);
            _note.NoteType          = 4;
            request.Add.Add(_note);
        }


        _service.AddOrUpdateNote(request);


        Response.Redirect("~/avgis.aspx?IdLead=" + crmLead.Id);

        TextBoxTextNote.Text = "";


        LabelMsg.Visible  = true;
        LabelMsg.CssClass = "alert alert-success";
        LabelMsg.Text     = "Примечание добавлено";
    }
예제 #5
0
        public static async Task GetListContents(string webUrl, string listName, int count, ITurnContext <IMessageActivity> turnContext, IConfiguration ConfigurationManager)
        {
            List <string> titles = new List <string>
            {
                $"{listName} contains the following top {count} list ITEMS"
            };
            var userName = ConfigurationManager["CrmUsername"].ToString();
            var password = ConfigurationManager["CrmPassword"].ToString();

            await Task.Run(async() =>
            {
                try
                {
                    using (var context = new ClientContext(webUrl))
                    {
                        context.Credentials = new SharePointOnlineCredentials(userName, password);
                        Web web             = context.Web;

                        // Assume the web has a list named "Announcements".
                        List statusReports = context.Web.Lists.GetByTitle(listName);

                        // This creates a CamlQuery that has a RowLimit of 100, and also specifies Scope="RecursiveAll"
                        // so that it grabs all list items, regardless of the folder they are in.
                        CamlQuery query          = CamlQuery.CreateAllItemsQuery(count, new string[] { "Name", "Title", "Client", "Project" });
                        ListItemCollection items = statusReports.GetItems(query);

                        // Retrieve all items in the ListItemCollection from List.GetItems(Query).
                        context.Load(items);
                        await context.ExecuteQueryAsync();
                        foreach (ListItem listItem in items)
                        {
                            if (listName.ToLower().Contains("reports"))
                            {
                                var client        = listItem["Client"] as FieldLookupValue;
                                var project       = listItem["Project"] as FieldLookupValue;
                                var fileReference = listItem["FileLeafRef"];
                                // We have all the list item data. For example, Title.
                                var title = client?.LookupValue + ", " + project?.LookupValue + ", " + fileReference + Environment.NewLine;
                                titles.Add(title);
                            }
                            else
                            {
                                titles.Add((string)listItem["FileRef"]);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error is: " + ex.Message + "   " + ex.StackTrace);
                    Console.ReadLine();
                }

                var card = new HeroCard
                {
                    Buttons = CrmLead.CreateButtons(titles)
                };
                await CrmLead.DisplayMessage(card, turnContext);
            });
        }
예제 #6
0
    protected void ButtonUpdateMainContact_Click(object sender, EventArgs e)
    {
        var     request = new AddOrUpdateContactRequest();
        CrmLead crmLead = JsonConvert.DeserializeObject <CrmLead>(HiddenFieldLeadJson.Value);

        request.Update = new List <AddOrUpdateCrmContact>();
        request.Add    = new List <AddOrUpdateCrmContact>();
        {
            var _contact = new AddOrUpdateCrmContact();
            _contact.Id           = crmLead.MainContactId;
            _contact.Name         = TextBoxMainContactName.Text;
            _contact.CustomFields = GetCustomFieldsValues <AddContactCustomField>(TypeField.Lead, "MainContact");
            request.Update.Add(_contact);
        }

        var countContact = 0;

        //а теперь обойдем дополнительные контакты
        foreach (Control c in PanelContacts.Controls)
        {
            if (c is Table)
            {
                countContact++;
                var tableContact = c as Table;
                if (tableContact.ID != "TableMainContact")
                {
                    var _contact = new AddOrUpdateCrmContact();
                    foreach (Control cc in tableContact.Rows[1].Cells[1].Controls)
                    {
                        if (cc is TextBox)
                        {
                            _contact.Name = (cc as TextBox).Text;
                        }
                        if (cc is HiddenField)
                        {
                            _contact.Id = Convert.ToInt64((cc as HiddenField).Value);
                        }
                    }
                    _contact.LeadsId      = crmLead.Id.ToString();
                    _contact.CustomFields = GetCustomFieldsValues <AddContactCustomField>(TypeField.Contact, tableContact.ID.Replace("Table", ""));
                    if (_contact.Id != null && _contact.Id > 0)
                    {
                        request.Update.Add(_contact);
                    }
                    else
                    {
                        request.Add.Add(_contact);
                    }
                }
            }
        }

        _service.AddOrUpdateContact(request);

        LabelMsg.Visible  = true;
        LabelMsg.CssClass = "alert alert-success";
        LabelMsg.Text     = "Данные по контактам обновлены";
    }
예제 #7
0
 private void UpdateCrmLeadContactID(CrmLead lead, int contactID)
 {
     try
     {
         lead.ContactID        = contactID;
         _db.Entry(lead).State = EntityState.Modified;
         _db.SaveChanges();
         LogMethods.Log.Debug("UpdateCrmLeadContactID:Debug:" + "Done");
     }
     catch (Exception ex)
     {
         LogMethods.Log.Error("UpdateCrmLeadContactID:Error:" + ex.Message);
     }
 }
예제 #8
0
        public static async Task GetTopLists(string webUrl, int count, ITurnContext <IMessageActivity> turnContext, string siteName, IConfiguration ConfigurationManager)
        {
            List <string> titles = new List <string>
            {
                $"{siteName} contains the following top {count} lists"
            };

            var userName = ConfigurationManager["CrmUsername"].ToString();
            var password = ConfigurationManager["CrmPassword"].ToString();

            await Task.Run(async() =>
            {
                try
                {
                    using (var context = new ClientContext(webUrl))
                    {
                        context.Credentials = new SharePointOnlineCredentials(userName, password);
                        Web web             = context.Web;
                        context.Load(web.Lists,
                                     lists => lists.Include(list => list.Title,
                                                            list => list.Id));
                        await context.ExecuteQueryAsync();
                        Console.ForegroundColor = ConsoleColor.White;
                        int runningCount        = 0;
                        foreach (List list in web.Lists.ToList())
                        {
                            runningCount++;
                            titles.Add($"List title is: {list.Title}");
                            if (runningCount >= count)
                            {
                                break;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error is: " + ex.Message + "   " + ex.StackTrace);
                    Console.ReadLine();
                }

                var card = new HeroCard
                {
                    Buttons = CrmLead.CreateButtons(titles)
                };
                await CrmLead.DisplayMessage(card, turnContext);
            });
        }
예제 #9
0
 protected void ButtonUpdateAddLead_Click(object sender, EventArgs e)
 {
     if (HiddenFieldLeadJson.Value != "")
     {
         var     request = new AddOrUpdateLeadRequest();
         CrmLead crmLead = JsonConvert.DeserializeObject <CrmLead>(HiddenFieldLeadJson.Value);
         var     lead    = new AddOrUpdateCrmLead();
         lead.Id                  = crmLead.Id;
         lead.Name                = TextBoxLeadName.Text;
         lead.StatusId            = DropDownListStatuses.SelectedValue;
         lead.PipelineId          = DropDownListPipeline.SelectedValue;
         lead.Tags                = TextBoxTags.Text;
         lead.ResponsibleUserId   = Convert.ToInt64(DropDownListResponsibleUsers.SelectedValue);
         lead.DateCreateTimestamp = crmLead.DateCreateTimestamp;
         lead.Tags                = TextBoxTags.Text;
         lead.StatusId            = crmLead.StatusId.ToString();
         lead.CustomFields        = GetCustomFieldsValues <AddLeadCustomField>(TypeField.Lead, "Lead");
         request.Update           = new List <AddOrUpdateCrmLead>();
         request.Update.Add(lead);
         _service.AddOrUpdateLead(request);
     }
     else
     {
         var request = new AddOrUpdateLeadRequest();
         var lead    = new AddOrUpdateCrmLead();
         lead.Name = TextBoxLeadName.Text;
         lead.ResponsibleUserId = Convert.ToInt64(DropDownListResponsibleUsers.SelectedValue);
         lead.DateCreate        = DateTime.Now;
         lead.Tags       = TextBoxTags.Text;
         lead.StatusId   = DropDownListStatuses.SelectedValue;
         lead.PipelineId = DropDownListPipeline.SelectedValue;
         // lead.MainContact = new CrmMainContact() { id = IdContact };
         //   lead.StatusId = crmLead.StatusId.ToString();
         lead.CustomFields = GetCustomFieldsValues <AddLeadCustomField>(TypeField.Lead, "Lead");
         request.Add       = new List <AddOrUpdateCrmLead>();
         request.Add.Add(lead);
         var newLead = _service.AddOrUpdateLead(request);
         if (newLead.Count > 0)
         {
             var IdContact = CreateContacts(newLead.FirstOrDefault().Id);
             Response.Redirect("~/HotWiFi.aspx?IdLead=" + newLead.FirstOrDefault().Id);
         }
     }
     LabelMsg.Visible  = true;
     LabelMsg.CssClass = "alert alert-success";
     LabelMsg.Text     = "Данные по лиду обновлены";
 }
예제 #10
0
        public static async Task AddTask(string webUrl, ITurnContext <IMessageActivity> turnContext, IConfiguration ConfigurationManager, RecognizerResult luisResult)
        {
            var           taskId = Guid.NewGuid();
            List <string> titles = new List <string>
            {
                $"A task with Id {taskId} added to Tasks List"
            };

            var userName = ConfigurationManager["CrmUsername"].ToString();
            var password = ConfigurationManager["CrmPassword"].ToString();

            var currentDate = GetTaskDate(luisResult);

            await Task.Run(async() =>
            {
                try
                {
                    using (var context = new ClientContext(webUrl))
                    {
                        context.Credentials = new SharePointOnlineCredentials(userName, password);
                        Web web             = context.Web;
                        var oList           = context.Web.Lists.GetByTitle("Tasks");

                        ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
                        ListItem oListItem     = oList.AddItem(itemCreateInfo);
                        oListItem["Title"]     = $"A New Task with Id of {taskId} added!";
                        oListItem["Body"]      = "Hello Razor Tech!";
                        oListItem["Status"]    = "Started";
                        oListItem["StartDate"] = currentDate.AddDays(1).ToLongDateString();
                        oListItem["DueDate"]   = currentDate.AddDays(3).ToLongDateString();

                        oListItem.Update();
                        await context.ExecuteQueryAsync();
                    }
                }
                catch (Exception ex)
                {
                    titles.Add(ex.Message);
                }

                var card = new HeroCard
                {
                    Buttons = CrmLead.CreateButtons(titles)
                };
                await CrmLead.DisplayMessage(card, turnContext);
            });
        }
예제 #11
0
    protected void ButtonUpdateLead_Click(object sender, EventArgs e)
    {
        var     request = new AddOrUpdateLeadRequest();
        CrmLead crmLead = JsonConvert.DeserializeObject <CrmLead>(HiddenFieldLeadJson.Value);
        var     lead    = new AddOrUpdateCrmLead();

        lead.Id   = crmLead.Id;
        lead.Name = TextBoxLeadName.Text;
        lead.ResponsibleUserId   = Convert.ToInt64(DropDownListResponsibleUsers.SelectedValue);
        lead.DateCreateTimestamp = crmLead.DateCreateTimestamp;
        lead.Tags         = String.Join(",", crmLead.Tags);
        lead.StatusId     = crmLead.StatusId.ToString();
        lead.CustomFields = GetCustomFieldsValues <AddLeadCustomField>(TypeField.Lead, "Lead");
        request.Update    = new List <AddOrUpdateCrmLead>();
        request.Update.Add(lead);
        _service.AddOrUpdateLead(request);
        LabelMsg.Visible  = true;
        LabelMsg.CssClass = "alert alert-success";
        LabelMsg.Text     = "Данные по лиду обновлены";
    }
예제 #12
0
        public async Task ContactNumberHandler(IDialogContext context, IAwaitable <string> argument)
        {
            var contactNumber = await argument;

            testDriveDetail.PhoneNumber = contactNumber;

            await context.PostAsync($@"Thank you for your interest, your request has been logged. Our sales team will get back to you shortly.
                                    {Environment.NewLine}Your test drive request summary:
                                    {Environment.NewLine}Car Make: {testDriveDetail.CarMake},
                                    {Environment.NewLine}Car Model: {testDriveDetail.CarModel},
                                    {Environment.NewLine}Requested Time: {testDriveDetail.RequestedTime},
                                    {Environment.NewLine}Customer Name: {testDriveDetail.CustomerName},
                                    {Environment.NewLine}Phone Number: {testDriveDetail.PhoneNumber}");

            //CrmLead.CreateTestDrive(testDriveDetail, CrmDataConnection.GetAPI());

            CrmLead.CreateTestDrive(testDriveDetail, CrmDataConnection.GetOrgService());

            context.Done <string>("Test drive has been logged");
        }
예제 #13
0
        public object Create(string values)
        {
            var crmLead = new CrmLead();

            JsonConvert.PopulateObject(values, crmLead);

            if (!TryValidateModel(crmLead))
            {
                return(BadRequest(ModelState.IsValid));
            }

            try
            {
                appUnitOfWork.crmLeadRepo.Add(crmLead);
                appUnitOfWork.SaveChanges();
                return(Json(new { status = 1, count = 1 }));
            }
            catch (Exception ex)
            {
                //TODO - nlog.e.Message!
                return(BadRequest(ex.Message));
            }
        }
예제 #14
0
        public static IForm <CarInquiryFormFlow> BuildForm()
        {
            OnCompletionAsyncDelegate <CarInquiryFormFlow> processRequest = async(context, state) =>
            {
                await context.PostAsync($@"Your test drive request summary:
                                    {Environment.NewLine}Car Make: {state.CarMake.ToString()},
                                    {Environment.NewLine}Car Model: {state.CarModel.ToString()},
                                    {Environment.NewLine}Requested Time: {state.PreferredTime},
                                    {Environment.NewLine}Customer Name: {state.Name},
                                    {Environment.NewLine}Phone Number: {state.ContactNumber}");

                var testDriveDetail = new TestDriveDetail
                {
                    CarMake       = state.CarMake.ToString(),
                    CarModel      = state.CarModel.ToString(),
                    RequestedTime = state.PreferredTime,
                    CustomerName  = state.Name,
                    PhoneNumber   = state.ContactNumber
                };

                // save the data to CRM
                CrmLead.CreateTestDrive(testDriveDetail, CrmDataConnection.GetOrgService());
            };

            return(new FormBuilder <CarInquiryFormFlow>()
                   .Message("Welcome to the car test drive bot!")
                   .Field(nameof(CarMake))
                   .Field(nameof(CarModel))
                   .Field(nameof(PreferredTime))
                   .Field(nameof(Name))
                   .Field(nameof(ContactNumber))
                   .AddRemainingFields()
                   .Message("Thank you for your interest, your request has been logged. Our sales team will get back to you shortly.")
                   .OnCompletion(processRequest)
                   .Build());
        }
예제 #15
0
    private Int64 CreateContacts(long LeadId = 0)
    {
        var     request = new AddOrUpdateContactRequest();
        CrmLead crmLead = JsonConvert.DeserializeObject <CrmLead>(HiddenFieldLeadJson.Value);

        request.Update = new List <AddOrUpdateCrmContact>();
        request.Add    = new List <AddOrUpdateCrmContact>();
        {
            var _contact = new AddOrUpdateCrmContact();
            if (crmLead != null && crmLead.MainContactId > 0)
            {
                _contact.Id = crmLead.MainContactId;
            }
            _contact.Name = TextBoxMainContactName.Text;
            if (LeadId > 0)
            {
                _contact.LeadsId = LeadId.ToString();
            }
            _contact.CompanyName  = TextBoxMainCampaignName.Text;
            _contact.CustomFields = GetCustomFieldsValues <AddContactCustomField>(TypeField.Lead, "MainContact");
            if (crmLead != null && crmLead.MainContactId > 0)
            {
                request.Update.Add(_contact);
            }
            else
            {
                request.Add.Add(_contact);
            }
        }

        var countContact = 0;

        //а теперь обойдем дополнительные контакты
        foreach (Control c in PanelContacts.Controls)
        {
            if (c is Table)
            {
                countContact++;
                var tableContact = c as Table;
                if (tableContact.ID != "TableMainContact")
                {
                    var _contact = new AddOrUpdateCrmContact();
                    foreach (Control cc in tableContact.Rows[1].Cells[1].Controls)
                    {
                        if (cc is TextBox)
                        {
                            _contact.Name = (cc as TextBox).Text;
                        }
                        if (cc is HiddenField)
                        {
                            _contact.Id = Convert.ToInt64((cc as HiddenField).Value);
                        }
                    }
                    foreach (Control cc in tableContact.Rows[2].Cells[1].Controls)
                    {
                        if (cc is TextBox)
                        {
                            _contact.CompanyName = (cc as TextBox).Text;
                        }
                        if (cc is HiddenField)
                        {
                            _contact.Id = Convert.ToInt64((cc as HiddenField).Value);
                        }
                    }
                    _contact.LeadsId      = crmLead.Id.ToString();
                    _contact.CustomFields = GetCustomFieldsValues <AddContactCustomField>(TypeField.Contact, tableContact.ID.Replace("Table", ""));
                    if (_contact.Id != null && _contact.Id > 0)
                    {
                        request.Update.Add(_contact);
                    }
                    else
                    {
                        request.Add.Add(_contact);
                    }
                }
            }
        }

        var rslt = _service.AddOrUpdateContact(request);

        if (rslt.FirstOrDefault() != null)
        {
            HiddenFieldMainContactId.Value = rslt.FirstOrDefault().Id.ToString();
            return(rslt.FirstOrDefault().Id);
        }

        return(0);
    }
예제 #16
0
 private void RecordLeadAeChangdTime(CrmLead newLead)
 {
     UpdateHistory(newLead.LeadID, newLead.LastUpdatedBy, (int)LeadENumber.NHistoryEvent.AEAssigned);
     LogMethods.Log.Debug("RecordLeadAeChangdTime:Debug:" + "Done");
 }
예제 #17
0
        private async Task ProcessLuisIntent(CRMLuisModel.Intent intent, ITurnContext turnContext, RecognizerResult luisResult0, CancellationToken cancellationToken = default(CancellationToken))
        {
            var msgContext = turnContext as ITurnContext <IMessageActivity>;

            switch (intent)
            {
            case CRMLuisModel.Intent.Greet_Welcome:
                var usrState = await _userProfileStateAccessor.GetAsync(turnContext);

                if (usrState == null)
                {
                    usrState = new UserProfileState();
                }
                usrState.CurrentDialog = "mainDialog";
                await _userProfileStateAccessor.SetAsync(turnContext, usrState);

                if (msgContext != null)
                {
                    Logger.LogInformation($"[Inside the Greet.Welcome Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                }
                var dialogResult = await Dialog.Run(turnContext, _mainDialogStateAccessor, cancellationToken);

                if (dialogResult.Result != null && !string.IsNullOrWhiteSpace(dialogResult.Result.ToString()))
                {
                    turnContext.Activity.Text = dialogResult.Result.ToString();
                    var luisResult = await _recognizer.RecognizeAsync <CRMLuisModel>(turnContext, cancellationToken);

                    var luisResultRaw = await _recognizer.RecognizeAsync(turnContext, cancellationToken);
                    await ProcessLuisIntent(luisResult.TopIntent().intent, turnContext, luisResultRaw, cancellationToken);
                }
                break;

            case CRMLuisModel.Intent.Accounts_Total:
                Logger.LogInformation($"[Inside the Accounts.Total Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                await CrmLead.GetAccountCounts(await CrmDataConnection.GetAPI2(msgContext, _configuration, _userProfileStateAccessor), msgContext);

                break;

            case CRMLuisModel.Intent.Accounts_AllAccounts:
                Logger.LogInformation($"[Inside the Accounts.AllAccounts Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                await CrmLead.GetAllAccountCounts(await CrmDataConnection.GetAPI2(msgContext, _configuration, _userProfileStateAccessor), msgContext);

                break;

            case CRMLuisModel.Intent.Accounts_Top5:
                Logger.LogInformation($"[Inside the Accounts.Top5 Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                var count = GetNumber(luisResult0.Text);
                await CrmLead.GetTopAccounts(await CrmDataConnection.GetAPI2(msgContext, _configuration, _userProfileStateAccessor), msgContext, count);

                break;

            case CRMLuisModel.Intent.Products_Top5:
                Logger.LogInformation($"[Inside the Products.Top5 Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                await CrmLead.GetTopProducts(await CrmDataConnection.GetAPI2(msgContext, _configuration, _userProfileStateAccessor), msgContext);

                break;

            case CRMLuisModel.Intent.Calendar_Event:
                var usrState1 = await _userProfileStateAccessor.GetAsync(turnContext);

                if (usrState1 == null)
                {
                    usrState1 = new UserProfileState();
                }
                usrState1.CurrentDialog = "graphDialog";
                await _userProfileStateAccessor.SetAsync(turnContext, usrState1);

                var dialogResult1 = await CalDialog.Run(turnContext, _calDialogStateAccessor, cancellationToken);

                if (dialogResult1 != null && dialogResult1.Status == DialogTurnStatus.Complete && luisResult0.GetTopScoringIntent().intent.ToLower() != "none")
                {
                    var crmCalendar = new CRMCalendar();
                    Logger.LogInformation($"[Inside the Calendar.Event Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                    await crmCalendar.AddEventToCalendar(luisResult0, msgContext, cancellationToken, _userProfileStateAccessor, Logger);
                }
                break;

            case CRMLuisModel.Intent.Greet_Farewell:
                Logger.LogInformation($"[Inside the Greet.Farewell Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                var botAdapter = (BotFrameworkAdapter)turnContext.Adapter;
                await botAdapter.SignOutUserAsync(turnContext, "crm", null, cancellationToken);

                await botAdapter.SignOutUserAsync(turnContext, "graph", null, cancellationToken);

                await turnContext.SendActivityAsync(MessageFactory.Text("b'bye \U0001F44B Take care"), cancellationToken);

                await turnContext.SendActivityAsync(MessageFactory.Text("You have been signed out."), cancellationToken);

                break;

            case CRMLuisModel.Intent.QueryProduct:
                var product = luisResult0.GetEntity <string>("Product_Name");
                Logger.LogInformation($"[Inside the QueryProduct Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                await CrmLead.GetProductInfo(await CrmDataConnection.GetAPI2(msgContext, _configuration, _userProfileStateAccessor), msgContext, product);

                break;

            case CRMLuisModel.Intent.Lead_Registration:
                var leadDialogState = await _leadDialogStateAccessor.GetAsync(turnContext);

                if (leadDialogState == null || leadDialogState.DialogStack.Count == 0)
                {
                    await turnContext.SendActivityAsync(MessageFactory.Text($"A new Lead is now being registered in the system."), cancellationToken);
                }
                Logger.LogInformation($"[Inside the Lead.Registration Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                var dialogResult2 = await MakeRootDialog(msgContext.Activity.ChannelId).Run(turnContext, _leadDialogStateAccessor, cancellationToken);

                if (dialogResult2 != null && dialogResult2.Result != null)
                {
                    if (dialogResult2.Result is LeadRegisterForm completedForm)
                    {
                        CrmLead.CreateNewLead(CrmDataConnection.GetAPIStaging(_configuration), completedForm);
                        await turnContext.SendActivityAsync(MessageFactory.Text($"The Lead has been registered in the System"), cancellationToken);
                    }
                }
                break;

            case CRMLuisModel.Intent.Report_ActiveCases:
                Logger.LogInformation($"[Inside the Report.ActiveCases Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                var actionUrl3 = "https://app.powerbi.com/view?r=eyJrIjoiODk3ODQxNDgtMzU2Ni00YTRkLThjMGMtOTliMzNiMDBhMjc4IiwidCI6Ijc0YzNhNGIxLWEyYTUtNGU0OC05ZDdiLTQzNGYzNmQzMzVlZCIsImMiOjF9";
                await CrmLead.ShowReport(msgContext, actionUrl3, "Active Cases");

                break;

            case CRMLuisModel.Intent.Report_PerformanceKpi:
                Logger.LogInformation($"[Inside the Report.PerformanceKpi Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                var actionUrl2 = "https://app.powerbi.com/view?r=eyJrIjoiZWVjODlhNjktZTcwYy00ZDU3LTllYjAtOTRlMjY1MTk0NGQwIiwidCI6Ijc0YzNhNGIxLWEyYTUtNGU0OC05ZDdiLTQzNGYzNmQzMzVlZCIsImMiOjF9";
                await CrmLead.ShowReport(msgContext, actionUrl2, "Org Performance KPIs");

                break;

            case CRMLuisModel.Intent.Report_SalesAnalytics:
                Logger.LogInformation($"[Inside the Report.SalesAnalytics Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                var actionUrl1 = "https://app.powerbi.com/view?r=eyJrIjoiZTljNDg5MjctNjljYi00MTQ2LWJiMTktM2M1OTBkMzQ0OWVkIiwidCI6Ijc0YzNhNGIxLWEyYTUtNGU0OC05ZDdiLTQzNGYzNmQzMzVlZCIsImMiOjF9";
                await CrmLead.ShowReport(msgContext, actionUrl1, "Sales Analytics Reports");

                break;

            case CRMLuisModel.Intent.Report_SalesLeaderboard:
                Logger.LogInformation($"[Inside the Report.SalesLeaderboard Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                var actionUrl = "https://app.powerbi.com/view?r=eyJrIjoiNzMxZmRlNjEtYmFkMy00NDMyLThlY2MtMzI3ZDc2ODE5MTdiIiwidCI6Ijc0YzNhNGIxLWEyYTUtNGU0OC05ZDdiLTQzNGYzNmQzMzVlZCIsImMiOjF9";
                await CrmLead.ShowReport(msgContext, actionUrl, "Sales Leaderboard Reports");

                break;

            case CRMLuisModel.Intent.SharePoint_TopLists:
                Logger.LogInformation($"[Inside the SharePoint.TopLists Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                var count2   = GetNumber(luisResult0.Text);
                var siteName = luisResult0.GetEntity <string>("Site_Name");
                if (string.IsNullOrEmpty(siteName))
                {
                    siteName = "DBS";
                }
                string siteUrl = "https://atidan2.sharepoint.com/sites/myrazor";
                if (siteName.ToLower().Contains("dbs"))
                {
                    siteUrl += "/" + siteName;
                }
                if (siteName.ToLower().Contains("elwyn"))
                {
                    siteUrl += "/RazorPMO/Elwyn/ElwynCRM";
                }
                if (siteName.ToLower().Contains("elwyncrm"))
                {
                    siteUrl += "/RazorPMO/Elwyn/ElwynCRM";
                }
                await QuerySharePoint.GetTopLists(siteUrl, count2, msgContext, siteName, _configuration);

                break;

            case CRMLuisModel.Intent.SharePoint_ListItems:
                Logger.LogInformation($"[Inside the SharePoint.ListItems Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                var count1   = GetNumber(luisResult0.Text);
                var listName = luisResult0.GetEntity <string>("List_Name");
                if (string.IsNullOrEmpty(listName))
                {
                    listName = "Documents";
                }
                if (listName.ToLower() == "status" || listName.ToLower() == "statusreports")
                {
                    listName = "Status Reports";
                }
                if (listName.ToLower() == "billing" || listName.ToLower() == "billingreports")
                {
                    listName = "Billing Reports";
                }
                await QuerySharePoint.GetListContents("https://atidan2.sharepoint.com/sites/myrazor/DBS", listName, count1, msgContext, _configuration);

                break;

            case CRMLuisModel.Intent.SharePoint_AddTask:
                Logger.LogInformation($"[Inside the SharePoint.AddTask Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                await QuerySharePoint.AddTask("https://atidan2.sharepoint.com/sites/ManufacturingICS1", msgContext, _configuration, luisResult0);

                break;

            case CRMLuisModel.Intent.None:
            default:
                Logger.LogInformation($"[Inside the None Intent] " + msgContext.Activity.AsMessageActivity()?.Text, msgContext.Activity.Conversation.Id);
                await turnContext.SendActivityAsync(MessageFactory.Text($"Sorry, I did not understand you. \U0001F44D"), cancellationToken);

                await turnContext.SendActivityAsync(MessageFactory.Text($"I don't know what you want to do"), cancellationToken);

                break;
            }
        }
예제 #18
0
 //Create, Get
 public LeadModifyViewMode()
 {
     Lead            = new CrmLead();
     Address         = new CrmLeadAddress();
     Address.Country = "Canada";
 }
예제 #19
0
 //Create, Post
 public LeadModifyViewMode(CrmLeadAddress address)
 {
     Lead    = new CrmLead();
     Address = address;
 }