예제 #1
0
        public IActionResult TextToTestConverter(String Utterance)
        {
            Intent        userIntent    = new Intent();
            CodeConverter codeConverter = new CodeConverter();

            userIntent.Utterance = Utterance;
            string[] lines = Utterance.Split(new[] { "\r\n" }, StringSplitOptions.None);
            if (lines != null && lines.Count() > 0)
            {
                String codeResult = String.Empty;
                foreach (var item in lines)
                {
                    Task <String> intentTask = IntentManager.GetIntent(item);
                    codeResult += codeConverter.ConvertToCode(intentTask.Result);
                }
                userIntent.IntentValue = codeResult;
            }
            else
            {
                Task <String> intentTask = IntentManager.GetIntent(Utterance);
                String        codeResult = codeConverter.ConvertToCode(intentTask.Result);
                userIntent.IntentValue = codeResult;
            }


            return(View(userIntent));
        }
예제 #2
0
        public TableData GetCodes(int campaignID, int pageNumber, int pageSize, CodeConverter codeConverter)
        {
            int         campaignSize = 0;
            int         codeIDStart  = 0;
            int         codeIDEnd    = 0;
            var         td           = new TableData(pageSize, pageNumber);
            List <Code> codes        = new List <Code>();

            Connection.Open();

            var transaction = Connection.BeginTransaction();
            var command     = Connection.CreateCommand();

            command.Transaction = transaction;

            try
            {
                // Get information about the campaign
                command.CommandText = @"
                    SELECT [Size], CodeIDStart, CodeIDEnd FROM Campaigns
                    WHERE ID = @campaignID
                ";
                command.Parameters.AddWithValue("@campaignID", campaignID);
                using (var reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        campaignSize = (int)reader["Size"];
                        codeIDStart  = (int)reader["CodeIDStart"];
                        codeIDEnd    = (int)reader["CodeIDEnd"];
                    }
                }

                // Set page count
                td.SetPageCount(campaignSize);

                // Get a page of codes from the campaign
                command.CommandText = @"
                    SELECT * FROM Codes
                    WHERE ID BETWEEN @codeIDStart AND @codeIDEnd
                    ORDER BY ID OFFSET @rowOffset ROWS
                    FETCH NEXT @pageSize ROWS ONLY
                ";
                command.Parameters.AddWithValue("@codeIDStart", codeIDStart);
                command.Parameters.AddWithValue("@codeIDEnd", codeIDEnd);
                command.Parameters.AddWithValue("@rowOffset", td.RowOffset);
                command.Parameters.AddWithValue("@pageSize", pageSize);

                // Read codes
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var code = new Code
                        {
                            StringValue = codeConverter.ConvertToCode((int)reader["SeedValue"]),
                            State       = States.ConvertToString((byte)reader["State"])
                        };
                        codes.Add(code);
                    }
                }

                transaction.Commit();

                // Add codes to the table data
                td.Codes = codes;
            }
            catch (Exception e)
            {
                transaction.Rollback();
            }

            Connection.Close();
            return(td);
        }