예제 #1
0
        public ActionResult Output2(int id)
        {
       
            MySqlConnection myConn = new MySqlConnection(TaqtiController.connectionString);
            myConn.Open();
            MySqlCommand cmd = new MySqlCommand(TaqtiController.connectionString);
            cmd = myConn.CreateCommand();
            MySqlDataReader dataReader;
            string text = "";
            string meters = "";
            int type = -1;
            List<int> met = new List<int>();
            bool isChecked = false;
            if (id > 0)
            {
                cmd = myConn.CreateCommand();
                cmd.CommandText = "select * from InputData where id = @id;";
                cmd.Parameters.AddWithValue("@id", id);
                dataReader = cmd.ExecuteReader();


                while (dataReader.Read())
                {
                    text = dataReader.GetString(1);
                    isChecked = (bool)dataReader.GetBoolean(2);
                }
            }
            else
            {
                cmd = myConn.CreateCommand();
                cmd.CommandText = "select * from poetry where id = @id;";
                cmd.Parameters.AddWithValue("@id", id + 65536);

                dataReader = cmd.ExecuteReader();
                while (dataReader.Read())
                {
                    text = dataReader.GetString(4);
                    meters = dataReader.GetString(5);
                    type = dataReader.GetInt32(3);
                }
                char[] delimiters = new[] { ',', '،' };  // List of delimiters
                var subStrings = meters.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                foreach (var m in subStrings)
                {
                    List<int> a = Meters.meterIndex(m);
                    if (a.Count != 0)
                    {
                        foreach (var v in a)
                        {
                            met.Add(v);
                        }
                    }
                    else
                    {
                        met.Add(-1);
                    }
                }
            }
            myConn.Close();

            List<scanPath> sp = new List<scanPath>();
            Scansion scn = new Scansion();
            scn.fuzzy = true;
            scn.freeVerse = false;
            scn.meter = met;
            scn.isChecked = isChecked;
            scn.errorParam = 2;
            foreach (string line in text.Split('\n'))
            {
                if (!string.IsNullOrWhiteSpace(line))
                    scn.addLine(new Lines(line.Trim()));
            }
            List<scanOutputFuzzy> lst = new List<scanOutputFuzzy>();
            lst = scn.scanLinesFuzzy();

            if (lst.Count == 0)
            {
                scanOutputFuzzy sc = new scanOutputFuzzy();
                sc.identifier = id;
                lst.Add(sc);
            }
            else
            {
                lst[0].identifier = id;
            }

           //return RedirectToAction("Error", "Home");
            return PartialView("_PartialOutput", lst);
        }
예제 #2
0
        public ActionResult Result2(Input inp)
        {
            string text = "";
            List<int> met = new List<int>();
            bool isChecked = false;
           
            text = inp.text;
            isChecked = inp.isChecked;
               
            List<scanPath> sp = new List<scanPath>();
            Scansion scn = new Scansion();
            scn.fuzzy = true;
            scn.freeVerse = false;
            scn.meter = met;
            scn.isChecked = isChecked;
            scn.errorParam = 2;
            foreach (string line in text.Split('\n'))
            {
                if (!string.IsNullOrWhiteSpace(line))
                    scn.addLine(new Lines(line.Trim()));
            }
            if(scn.numLines < 4)
            {
                scn.errorParam = 4;
            }
            List<scanOutputFuzzy> lst = new List<scanOutputFuzzy>();
            lst = scn.scanLinesFuzzy();

            if (lst.Count == 0)
            {
                scanOutputFuzzy sc = new scanOutputFuzzy();
                sc.identifier = -1;
                lst.Add(sc);
            }
            else
            {
                lst[0].identifier = -1;
            }

            //return RedirectToAction("Error", "Home");
            return PartialView("_PartialOutput", lst);
        }