public ActionResult Result2(Input inp) { string poet = ""; int type = -1; List <int> met = new List <int>(); Scansion scn = new Scansion(); if (type == 4) { scn.fuzzy = false; scn.freeVerse = true; scn.isChecked = true; scn.errorParam = 2; scn.meter = met; } else { scn.fuzzy = false; scn.freeVerse = inp.isChecked; scn.isChecked = false; scn.errorParam = 2; scn.meter = met; } foreach (string line in inp.text.Split('\n')) { if (!string.IsNullOrWhiteSpace(line)) { scn.addLine(new Lines(line.Trim())); } } List <scanOutput> lst = new List <scanOutput>(); lst = scn.scanLines(); if (lst.Count == 0) { scanOutput sc = new scanOutput(); sc.identifier = -2; sc.poet = poet; lst.Add(sc); } else { lst[0].identifier = -2; lst[0].poet = poet; lst[0].numLines = scn.numLines; } return(PartialView("_PartialOutputTaqti", lst)); }
public ActionResult PartialOutputExamples(Input inp) { string text = inp.text; bool isChecked = inp.isChecked; List <scanPath> sp = new List <scanPath>(); Scansion scn = new Scansion(); scn.fuzzy = false; scn.freeVerse = isChecked; scn.errorParam = 0; scn.isChecked = isChecked; List <int> mets = new List <int>(); char[] delimiters = new[] { ',', '،' }; // List of delimiters var subStrings = inp.meter.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); foreach (var m in subStrings) { List <int> a = Meters.meterIndex(m.Trim()); if (a.Count != 0) { foreach (var v in a) { mets.Add(v); } } else { mets.Add(-1); } } scn.meter = mets; foreach (string line in text.Split(new[] { '\n', '-' }, StringSplitOptions.RemoveEmptyEntries)) { if (!string.IsNullOrWhiteSpace(line)) { scn.addLine(new Lines(line.Trim())); } } return(PartialView("_AjaxPartialExamples", scn.scanOneLine(inp.id))); }
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)); }
public IHttpActionResult GetTaqti(string text) { //string text1 = "نقش فریادی ہے کس کی شوخی تحریر کا"; // try { string referrer = "*&SDSD&*&*"; try { referrer = HttpContext.Current.Request.UrlReferrer.ToString(); } catch { } MySqlConnection myConn = new MySqlConnection(TaqtiController.connectionString); myConn.Open(); MySqlCommand cmd = new MySqlCommand(TaqtiController.connectionString); cmd = myConn.CreateCommand(); cmd.CommandText = "select max(id) as id from InputDataAPI;"; MySqlDataReader dataReader = cmd.ExecuteReader(); int id3 = 0; while (dataReader.Read()) { id3 = dataReader.GetInt32(0); } myConn.Close(); myConn.Open(); cmd = myConn.CreateCommand(); cmd.CommandText = "INSERT into InputDataAPI(ID,text,isChecked,ip,referrer) VALUES (@id,@text,@ischecked,@ip,@referrer)"; cmd.Parameters.AddWithValue("@id", id3 + 1); cmd.Parameters.AddWithValue("@text", (string)text); cmd.Parameters.AddWithValue("@ischecked", false); cmd.Parameters.AddWithValue("@ip", HttpContext.Current.Request.UserHostAddress); cmd.Parameters.AddWithValue("@referrer", referrer); cmd.ExecuteNonQuery(); myConn.Close(); List<int> met = new List<int>(); List<scanOutput> lst = new List<scanOutput>(); Scansion scn = new Scansion(); scn.fuzzy = false; scn.freeVerse = false; scn.isChecked = false; scn.errorParam = 2; scn.freeVerse = false; scn.meter = met; foreach (string line in text.Split('\n')) { if (!string.IsNullOrWhiteSpace(line)) { scn.addLine(new Lines(line.Trim())); break; } } lst = scn.scanLines(); if (lst.Count == 0) { return Json(new { Result = "ERROR", Message = "کوئی مانوس بحر نہیں ملی" }); } else { List<scanOutputApi> list = TaqtiController.convert(lst); if (list.Count > 1) { return Json(list); } else { return Json(list.First()); } } // return (new JavaScriptSerializer().Serialize(TaqtiController.convert(lst).ToArray())); } /* catch { return NotFound(); }*/ }
public IHttpActionResult GetTaqti(string text) { //string text1 = "نقش فریادی ہے کس کی شوخی تحریر کا"; // try { string referrer = "*&SDSD&*&*"; try { referrer = HttpContext.Current.Request.UrlReferrer.ToString(); } catch { } MySqlConnection myConn = new MySqlConnection(TaqtiController.connectionString); myConn.Open(); MySqlCommand cmd = new MySqlCommand(TaqtiController.connectionString); cmd = myConn.CreateCommand(); cmd.CommandText = "select max(id) as id from InputDataAPI;"; MySqlDataReader dataReader = cmd.ExecuteReader(); int id3 = 0; while (dataReader.Read()) { id3 = dataReader.GetInt32(0); } myConn.Close(); myConn.Open(); cmd = myConn.CreateCommand(); cmd.CommandText = "INSERT into InputDataAPI(ID,text,isChecked,ip,referrer) VALUES (@id,@text,@ischecked,@ip,@referrer)"; cmd.Parameters.AddWithValue("@id", id3 + 1); cmd.Parameters.AddWithValue("@text", (string)text); cmd.Parameters.AddWithValue("@ischecked", false); cmd.Parameters.AddWithValue("@ip", HttpContext.Current.Request.UserHostAddress); cmd.Parameters.AddWithValue("@referrer", referrer); cmd.ExecuteNonQuery(); myConn.Close(); List <int> met = new List <int>(); List <scanOutput> lst = new List <scanOutput>(); Scansion scn = new Scansion(); scn.fuzzy = false; scn.freeVerse = false; scn.isChecked = false; scn.errorParam = 2; scn.freeVerse = false; scn.meter = met; foreach (string line in text.Split('\n')) { if (!string.IsNullOrWhiteSpace(line)) { scn.addLine(new Lines(line.Trim())); break; } } lst = scn.scanLines(); if (lst.Count == 0) { return(Json(new { Result = "ERROR", Message = "کوئی مانوس بحر نہیں ملی" })); } else { List <scanOutputApi> list = TaqtiController.convert(lst); if (list.Count > 1) { return(Json(list)); } else { return(Json(list.First())); } } // return (new JavaScriptSerializer().Serialize(TaqtiController.convert(lst).ToArray())); } /* catch * { * return NotFound(); * * }*/ }
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)); }
public ActionResult Output2(int id) { myConn = new MySqlConnection(connectionString); myConn.Open(); bool isChecked = false; MySqlCommand cmd = new MySqlCommand(connectionString); string text = ""; string meters = ""; string poet = ""; string taqtiObject = ""; int type = -1; List <int> met = new List <int>(); 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); poet = dataReader.GetString(1); type = dataReader.GetInt32(3); try { taqtiObject = dataReader.GetString(7); } catch { } } char[] delimiters = new[] { ',', '،' }; // List of delimiters var subStrings = meters.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); foreach (var m in subStrings) { List <int> a = Meters.meterIndex(m.Trim()); if (a.Count != 0) { foreach (var v in a) { met.Add(v); } } else { met.Add(-1); } } } myConn.Close(); Scansion scn = new Scansion(); if (type == 4) { scn.fuzzy = false; scn.freeVerse = true; scn.isChecked = true; scn.errorParam = 2; scn.meter = met; } else { scn.fuzzy = false; scn.freeVerse = isChecked; scn.isChecked = false; scn.errorParam = 2; scn.meter = met; } List <scanOutput> lst = new List <scanOutput>(); if (string.IsNullOrEmpty(taqtiObject)) { foreach (string line in text.Split('\n')) { if (!string.IsNullOrWhiteSpace(line)) { scn.addLine(new Lines(line.Trim())); } } lst = scn.scanLines(); if (lst.Count == 0) { scanOutput sc = new scanOutput(); sc.identifier = id; sc.poet = poet; lst.Add(sc); } else { lst[0].identifier = id; lst[0].poet = poet; } XmlSerializer ser = new XmlSerializer(typeof(List <scanOutput>)); StringWriter textWriter = new StringWriter(); ser.Serialize(textWriter, lst); MySqlConnection myConn2 = new MySqlConnection(connectionString); myConn2.Open(); MySqlCommand cmd2 = new MySqlCommand(connectionString); cmd2 = myConn2.CreateCommand(); cmd2.CommandText = "update poetry set taqtiObject = @object where id = @id;"; cmd2.Parameters.AddWithValue("@id", id + 65536); cmd2.Parameters.AddWithValue("@object", (string)textWriter.ToString()); cmd2.ExecuteNonQuery(); myConn2.Close(); } else { XmlSerializer ser = new XmlSerializer(typeof(List <scanOutput>)); StringReader reader = new StringReader(taqtiObject); lst = (List <scanOutput>)ser.Deserialize(reader); } return(PartialView("_PartialOutputTaqti", lst)); }
public ActionResult PartialOutputExamples(Input inp) { string text = inp.text; bool isChecked = inp.isChecked; List<scanPath> sp = new List<scanPath>(); Scansion scn = new Scansion(); scn.fuzzy = false; scn.freeVerse = isChecked; scn.errorParam = 0; scn.isChecked = isChecked; List<int> mets = new List<int>(); char[] delimiters = new[] { ',', '،' }; // List of delimiters var subStrings = inp.meter.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); foreach (var m in subStrings) { List<int> a = Meters.meterIndex(m.Trim()); if (a.Count != 0) { foreach (var v in a) { mets.Add(v); } } else { mets.Add(-1); } } scn.meter = mets; foreach (string line in text.Split(new[] { '\n', '-' }, StringSplitOptions.RemoveEmptyEntries)) { if (!string.IsNullOrWhiteSpace(line)) scn.addLine(new Lines(line.Trim())); } return PartialView("_AjaxPartialExamples", scn.scanOneLine(inp.id)); }
public ActionResult MyPoetry2(int id) { string taqtiObject = ""; MySqlConnection myConn; MySqlDataReader dataReader; myConn = new MySqlConnection(TaqtiController.connectionString); myConn.Open(); MySqlCommand cmd = new MySqlCommand(TaqtiController.connectionString); cmd = myConn.CreateCommand(); cmd.CommandText = "select * from mypoetry where id = @id"; cmd.Parameters.AddWithValue("@id", id); dataReader = cmd.ExecuteReader(); Publish p = new Publish(); while (dataReader.Read()) { p.id = dataReader.GetInt32(0); p.text = dataReader.GetString(4); p.name = dataReader.GetString(1); p.title = dataReader.GetString(3); try { taqtiObject = dataReader.GetString(5); } catch { } try { p.url = dataReader.GetString(2); } catch { } } myConn.Close(); List <int> met = new List <int>(); Scansion scn = new Scansion(); scn.fuzzy = false; scn.freeVerse = false; scn.isChecked = false; scn.errorParam = 2; scn.meter = met; List <scanOutput> lst = new List <scanOutput>(); if (string.IsNullOrEmpty(taqtiObject)) { foreach (string line in p.text.Split('\n')) { if (!string.IsNullOrWhiteSpace(line)) { scn.addLine(new Lines(line.Trim())); } } lst = scn.scanLines(); if (lst.Count == 0) { scanOutput sc = new scanOutput(); sc.identifier = id; sc.poet = p.name; sc.title = p.title; sc.text = p.text; sc.url = p.url; lst.Add(sc); } else { lst[0].identifier = id; lst[0].poet = p.name; lst[0].title = p.title; lst[0].text = p.text; lst[0].url = p.url; } XmlSerializer ser = new XmlSerializer(typeof(List <scanOutput>)); StringWriter textWriter = new StringWriter(); ser.Serialize(textWriter, lst); MySqlConnection myConn2 = new MySqlConnection(TaqtiController.connectionString); myConn2.Open(); MySqlCommand cmd2 = new MySqlCommand(TaqtiController.connectionString); cmd2 = myConn2.CreateCommand(); cmd2.CommandText = "update mypoetry set taqtiObject = @object where id = @id;"; cmd2.Parameters.AddWithValue("@object", (string)textWriter.ToString()); cmd2.Parameters.AddWithValue("@id", p.id); cmd2.ExecuteNonQuery(); myConn2.Close(); } else { XmlSerializer ser = new XmlSerializer(typeof(List <scanOutput>)); StringReader reader = new StringReader(taqtiObject); lst = (List <scanOutput>)ser.Deserialize(reader); lst[0].identifier = id; lst[0].poet = p.name; lst[0].title = p.title; lst[0].text = p.text; lst[0].url = p.url; } return(PartialView("_Poetry", crunch(lst))); }
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); }
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); }
public ActionResult Output2(int id) { myConn = new MySqlConnection(connectionString); myConn.Open(); bool isChecked = false; MySqlCommand cmd = new MySqlCommand(connectionString); string text = ""; string meters = ""; string poet = ""; string taqtiObject = ""; int type = -1; List<int> met = new List<int>(); 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); poet = dataReader.GetString(1); type = dataReader.GetInt32(3); try { taqtiObject = dataReader.GetString(7); } catch { } } char[] delimiters = new[] { ',','،'}; // List of delimiters var subStrings = meters.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); foreach(var m in subStrings) { List<int> a = Meters.meterIndex(m.Trim()); if(a.Count!=0) { foreach(var v in a) { met.Add(v); } } else { met.Add(-1); } } } myConn.Close(); Scansion scn = new Scansion(); if (type == 4) { scn.fuzzy = false; scn.freeVerse = true; scn.isChecked = true; scn.errorParam = 2; scn.meter = met; } else { scn.fuzzy = false; scn.freeVerse = isChecked; scn.isChecked = false; scn.errorParam = 2; scn.meter = met; } List<scanOutput> lst = new List<scanOutput>(); if (string.IsNullOrEmpty(taqtiObject)) { foreach (string line in text.Split('\n')) { if (!string.IsNullOrWhiteSpace(line)) scn.addLine(new Lines(line.Trim())); } lst = scn.scanLines(); if (lst.Count == 0) { scanOutput sc = new scanOutput(); sc.identifier = id; sc.poet = poet; lst.Add(sc); } else { lst[0].identifier = id; lst[0].poet = poet; } XmlSerializer ser = new XmlSerializer(typeof(List<scanOutput>)); StringWriter textWriter = new StringWriter(); ser.Serialize(textWriter, lst); MySqlConnection myConn2 = new MySqlConnection(connectionString); myConn2.Open(); MySqlCommand cmd2 = new MySqlCommand(connectionString); cmd2 = myConn2.CreateCommand(); cmd2.CommandText = "update poetry set taqtiObject = @object where id = @id;"; cmd2.Parameters.AddWithValue("@id", id + 65536); cmd2.Parameters.AddWithValue("@object",(string)textWriter.ToString()); cmd2.ExecuteNonQuery(); myConn2.Close(); } else { XmlSerializer ser = new XmlSerializer(typeof(List<scanOutput>)); StringReader reader = new StringReader(taqtiObject); lst = (List<scanOutput>)ser.Deserialize(reader); } return PartialView("_PartialOutputTaqti",lst); }
public ActionResult Result2(Input inp) { string poet = ""; int type = -1; List<int> met = new List<int>(); Scansion scn = new Scansion(); if (type == 4) { scn.fuzzy = false; scn.freeVerse = true; scn.isChecked = true; scn.errorParam = 2; scn.meter = met; } else { scn.fuzzy = false; scn.freeVerse = inp.isChecked; scn.isChecked = false; scn.errorParam = 2; scn.meter = met; } foreach (string line in inp.text.Split('\n')) { if (!string.IsNullOrWhiteSpace(line)) scn.addLine(new Lines(line.Trim())); } List<scanOutput> lst = new List<scanOutput>(); lst = scn.scanLines(); if (lst.Count == 0) { scanOutput sc = new scanOutput(); sc.identifier = -2; sc.poet = poet; lst.Add(sc); } else { lst[0].identifier = -2; lst[0].poet = poet; lst[0].numLines = scn.numLines; } return PartialView("_PartialOutputTaqti", lst); }
public ActionResult MyPoetry2(int id) { string taqtiObject = ""; MySqlConnection myConn; MySqlDataReader dataReader; myConn = new MySqlConnection(TaqtiController.connectionString); myConn.Open(); MySqlCommand cmd = new MySqlCommand(TaqtiController.connectionString); cmd = myConn.CreateCommand(); cmd.CommandText = "select * from mypoetry where id = @id"; cmd.Parameters.AddWithValue("@id", id); dataReader = cmd.ExecuteReader(); Publish p = new Publish(); while (dataReader.Read()) { p.id = dataReader.GetInt32(0); p.text = dataReader.GetString(4); p.name = dataReader.GetString(1); p.title = dataReader.GetString(3); try { taqtiObject = dataReader.GetString(5); } catch { } try { p.url = dataReader.GetString(2); } catch { } } myConn.Close(); List<int> met = new List<int>(); Scansion scn = new Scansion(); scn.fuzzy = false; scn.freeVerse = false; scn.isChecked = false; scn.errorParam = 2; scn.meter = met; List<scanOutput> lst = new List<scanOutput>(); if (string.IsNullOrEmpty(taqtiObject)) { foreach (string line in p.text.Split('\n')) { if (!string.IsNullOrWhiteSpace(line)) scn.addLine(new Lines(line.Trim())); } lst = scn.scanLines(); if (lst.Count == 0) { scanOutput sc = new scanOutput(); sc.identifier = id; sc.poet = p.name; sc.title = p.title; sc.text = p.text; sc.url = p.url; lst.Add(sc); } else { lst[0].identifier = id; lst[0].poet = p.name; lst[0].title = p.title; lst[0].text = p.text; lst[0].url = p.url; } XmlSerializer ser = new XmlSerializer(typeof(List<scanOutput>)); StringWriter textWriter = new StringWriter(); ser.Serialize(textWriter, lst); MySqlConnection myConn2 = new MySqlConnection(TaqtiController.connectionString); myConn2.Open(); MySqlCommand cmd2 = new MySqlCommand(TaqtiController.connectionString); cmd2 = myConn2.CreateCommand(); cmd2.CommandText = "update mypoetry set taqtiObject = @object where id = @id;"; cmd2.Parameters.AddWithValue("@object", (string)textWriter.ToString()); cmd2.Parameters.AddWithValue("@id", p.id); cmd2.ExecuteNonQuery(); myConn2.Close(); } else { XmlSerializer ser = new XmlSerializer(typeof(List<scanOutput>)); StringReader reader = new StringReader(taqtiObject); lst = (List<scanOutput>)ser.Deserialize(reader); lst[0].identifier = id; lst[0].poet = p.name; lst[0].title = p.title; lst[0].text = p.text; lst[0].url = p.url; } return PartialView("_Poetry", crunch(lst)); }