private async Task abc(IDialogContext context, IAwaitable <object> result)
        {
            var empid    = await result as Activity;
            var activity = await result as Activity;

            employee_id = int.Parse(empid.Text);
            StateClient stateClient = activity.GetStateClient();
            BotData     userData    = await stateClient.BotState.GetUserDataAsync(activity.ChannelId, activity.From.Id);

            var obj   = JObject.Parse(userData.Data.ToString());
            var token = (string)obj["token"];

            if (token == null)
            {
                await context.PostAsync("Need to Login to access data");

                context.Call(new UserLogin(), ResumeAfteNullToken);
            }
            if (token != null)
            {
                var    probation_period          = new ProbationPeriodClient();
                string probation_period_response = await probation_period.ProbationPeroid(token, employee_id);

                await context.PostAsync($"Response is {probation_period_response}");

                context.Done(true);
            }
        }
        public async Task Experience(IDialogContext context, IAwaitable <object> results, LuisResult result)
        {
            GetEmployeeId(context);
            var activity = await results as Activity;


            try
            {
                var probation_period          = new ProbationPeriodClient();
                var probation_period_response = await probation_period.ProbationPeroid(token, empID);

                if (probation_period_response != null && probation_period_response.ResponseJSON != null)
                {
                    await context.PostAsync($"Your Experience in Cygnet is {probation_period_response.ResponseJSON.Experience} years");

                    context.Call(new ResumeAfter(), this.ResumeAfterTaskDialog);
                }
                else
                {
                    await context.PostAsync("Data not found ");
                }
            }
            catch (Exception ex)
            {
                string        filePath = AppDomain.CurrentDomain.BaseDirectory;
                StringBuilder sb       = new StringBuilder();
                sb.Append("InnerException : " + ex.InnerException);
                sb.Append("Experience");
                sb.Append(Environment.NewLine);
                sb.Append("Message : " + ex.Message);
                sb.Append(Environment.NewLine);
                System.IO.File.AppendAllText(System.IO.Path.Combine(filePath, "Exception_log.txt"), sb.ToString());
                sb.Clear();
                await context.PostAsync("Data not found");

                context.Done(true);
            }
        }
Ejemplo n.º 3
0
        private async Task ProfileSelection(IDialogContext context, IAwaitable <ProfileFormFlow> result)
        {
            try
            {
                var selection = await result;
                if (selection.profileType.ToString().Equals("Probation_Period"))
                {
                    try
                    {
                        var token                     = "ok";
                        var empID                     = context.UserData.GetValue <int>("empID");
                        var probation_period          = new ProbationPeriodClient();
                        var probation_period_response = await probation_period.ProbationPeroid(token, empID);

                        {
                            await context.PostAsync($"Your Probation is of  {probation_period_response.ResponseJSON.ProbationPeriod} months");
                        }
                    }
                    catch (Exception ex)
                    {
                        string        filePath = AppDomain.CurrentDomain.BaseDirectory;
                        StringBuilder sb       = new StringBuilder();
                        sb.Append("InnerException : " + ex.InnerException);
                        sb.Append("Probation_Period");
                        sb.Append(Environment.NewLine);
                        sb.Append("Message : " + ex.Message);
                        sb.Append(Environment.NewLine);
                        System.IO.File.AppendAllText(System.IO.Path.Combine(filePath, "Exception_log.txt"), sb.ToString());
                        sb.Clear();
                        await context.PostAsync("Data not found");

                        context.Done(true);
                    }
                }
                else if (selection.profileType.ToString().Equals("Joining_Date"))
                {
                    try
                    {
                        var token                     = "ok";
                        var empID                     = context.UserData.GetValue <int>("empID");
                        var probation_period          = new ProbationPeriodClient();
                        var probation_period_response = await probation_period.ProbationPeroid(token, empID);

                        if (probation_period_response != null && probation_period_response.ResponseJSON != null)
                        {
                            await context.PostAsync($"Your Joining date is {probation_period_response.ResponseJSON.JoinDate.Value.ToLongDateString()} ");
                        }
                        else
                        {
                            await context.PostAsync("Data not found ");
                        }
                    }
                    catch (Exception ex)
                    {
                        string        filePath = AppDomain.CurrentDomain.BaseDirectory;
                        StringBuilder sb       = new StringBuilder();
                        sb.Append("InnerException : " + ex.InnerException);
                        sb.Append("Join_date");
                        sb.Append(Environment.NewLine);
                        sb.Append("Message : " + ex.Message);
                        sb.Append(Environment.NewLine);
                        System.IO.File.AppendAllText(System.IO.Path.Combine(filePath, "Exception_log.txt"), sb.ToString());
                        sb.Clear();
                        await context.PostAsync("Data not found");

                        context.Done(true);
                    }
                }
                else if (selection.profileType.ToString().Equals("Experience"))
                {
                    try
                    {
                        var token                     = "ok";
                        var empID                     = context.UserData.GetValue <int>("empID");
                        var probation_period          = new ProbationPeriodClient();
                        var probation_period_response = await probation_period.ProbationPeroid(token, empID);

                        if (probation_period_response != null && probation_period_response.ResponseJSON != null)
                        {
                            await context.PostAsync($"Your Experience in Cygnet is {probation_period_response.ResponseJSON.Experience} years");
                        }
                        else
                        {
                            await context.PostAsync("Data not found ");
                        }
                    }
                    catch (Exception ex)
                    {
                        string        filePath = AppDomain.CurrentDomain.BaseDirectory;
                        StringBuilder sb       = new StringBuilder();
                        sb.Append("InnerException : " + ex.InnerException);
                        sb.Append("Experience");
                        sb.Append(Environment.NewLine);
                        sb.Append("Message : " + ex.Message);
                        sb.Append(Environment.NewLine);
                        System.IO.File.AppendAllText(System.IO.Path.Combine(filePath, "Exception_log.txt"), sb.ToString());
                        sb.Clear();
                        await context.PostAsync("Data not found");

                        context.Done(true);
                    }
                }
                context.Done(true);
            }
            catch (Exception ex)
            {
                string        filePath = AppDomain.CurrentDomain.BaseDirectory;
                StringBuilder sb       = new StringBuilder();
                sb.Append("InnerException : " + ex.InnerException);
                sb.Append("Apply Leave");
                sb.Append(Environment.NewLine);
                sb.Append("Message : " + ex.Message);
                sb.Append(Environment.NewLine);
                System.IO.File.AppendAllText(System.IO.Path.Combine(filePath, "Exception_log.txt"), sb.ToString());
                sb.Clear();
                await context.PostAsync("Data not found");

                context.Done(true);
            }
        }