private void button1_Click(object sender, EventArgs e) { if (this.textBox1.Text != "" && this.textBox2.Text != "") { if (ValidateInt()) { using (var context = new db_sqlceEntities()) { try { var objct = new impulse() { weight = Convert.ToInt32(this.textBox1.Text), code = Convert.ToInt32(this.textBox2.Text) }; context.impulse.Add(objct); context.SaveChanges(); editImpulse.LoadData(); this.Close(); } catch (DbEntityValidationException ex) { MessageBox.Show(ex.ToString()); } } } } }
private void toolStripButton1_Click(object sender, EventArgs e) { if (ownersDataGridView.SelectedCells.Count > 0) { DialogResult dialogResult = MessageBox.Show("Вы действительно хотите удалить выбранный пункт?", "Подтвердите удаление!", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { int i = (int)ownersDataGridView.CurrentRow.Cells[0].Value; using (var context = new db_sqlceEntities()) { try { var obPlc = context.owners.FirstOrDefault(p => p.id == i); if (obPlc != null) { context.owners.Remove(obPlc); context.SaveChanges(); LoadData(); //loadTree(); } } catch (EntitySqlException ex) { MessageBox.Show(ex.Message); } } } else if (dialogResult == DialogResult.No) { return; } } }
private void button1_Click(object sender, EventArgs e) { if (this.textBox1.Text != "" && this.textBox2.Text != "" && this.textBox3.Text != "") { using (var context = new db_sqlceEntities()) { try { var objct = new owners() { name = this.textBox1.Text, surname = this.textBox2.Text, patronymic = this.textBox3.Text, tel = this.textBox4.Text, category_pay_id = (int?)this.comboBox1.SelectedValue }; context.owners.Add(objct); context.SaveChanges(); mEditOwners.LoadData(); this.Close(); } catch (DbEntityValidationException ex) { MessageBox.Show(ex.ToString()); } } } }
private void button1_Click(object sender, EventArgs e) { if (this.textBox1.Text != "") { using (var context = new db_sqlceEntities()) { var q = context.counters.FirstOrDefault(c => c.serial_amspi == textBox2.Text); if (q == null) { var cnt = new counters() { objects_place_id = _treeNodeId, serial_amspi = textBox2.Text, date_init_calibration_r1 = dateTimePicker1.Value.Date, date_init_calibration_r2 = dateTimePicker2.Value.Date, date_calibration_r1 = dateTimePicker3.Value.Date, date_calibration_r2 = dateTimePicker4.Value.Date, date_calibration_amspi = dateTimePicker5.Value.Date, diameter_r1 = Convert.ToInt32(textBox5.Text), diameter_r2 = Convert.ToInt32(textBox6.Text), date_start = dateTimePicker6.Value.Date }; context.counters.Add(cnt); context.SaveChanges(); this.Close(); } else { MessageBox.Show("ППУ-РМ с таким серийным номером уже установлен!"); } } } }
private void удалитьОбъектToolStripMenuItem_Click(object sender, EventArgs e) { using (var context = new db_sqlceEntities()) { try { var ttt = context.objects_place.LongCount(p => p.objects_place_id == _treeNodeId); if (ttt > 0) { MessageBox.Show("У объекта есть вложенные объекты!"); } else { var obPlc = context.objects_place.FirstOrDefault(p => p.id == _treeNodeId); if (obPlc != null) { context.objects_place.Remove(obPlc); context.SaveChanges(); loadTree(); } } } catch (EntitySqlException ex) { MessageBox.Show(ex.Message); } } }
private void button1_Click(object sender, EventArgs e) { using (var context = new db_sqlceEntities()) { try { var war = context.warning_conditions.FirstOrDefault(); if (war != null) { war.gprs_sig_min = float.Parse(this.gprs_sig_min.Text, CultureInfo.InvariantCulture.NumberFormat); war.gprs_sig_max = float.Parse(this.gprs_sig_max.Text, CultureInfo.InvariantCulture.NumberFormat); war.gprs_mod_min = float.Parse(this.gprs_mod_min.Text, CultureInfo.InvariantCulture.NumberFormat); war.gprs_mod_max = float.Parse(this.gprs_mod_max.Text, CultureInfo.InvariantCulture.NumberFormat); war.controller_voltage_min = float.Parse(this.cont_min.Text, CultureInfo.InvariantCulture.NumberFormat); war.controller_voltage_max = float.Parse(this.cont_max.Text, CultureInfo.InvariantCulture.NumberFormat); context.SaveChanges(); this.Close(); } else { var wr = new warning_conditions() { gprs_sig_min = float.Parse(this.gprs_sig_min.Text, CultureInfo.InvariantCulture.NumberFormat), gprs_sig_max = float.Parse(this.gprs_sig_max.Text, CultureInfo.InvariantCulture.NumberFormat), gprs_mod_min = float.Parse(this.gprs_mod_min.Text, CultureInfo.InvariantCulture.NumberFormat), gprs_mod_max = float.Parse(this.gprs_mod_max.Text, CultureInfo.InvariantCulture.NumberFormat), controller_voltage_min = float.Parse(this.cont_min.Text, CultureInfo.InvariantCulture.NumberFormat), controller_voltage_max = float.Parse(this.cont_max.Text, CultureInfo.InvariantCulture.NumberFormat) }; context.warning_conditions.Add(wr); context.SaveChanges(); this.Close(); } } catch (EntitySqlException ex) { MessageBox.Show(ex.Message); } } }
private void button1_Click(object sender, EventArgs e) { if (this.textBox1.Text != "") { using (var context = new db_sqlceEntities()) { var objct = new object_type() { name = this.textBox1.Text, comment = this.textBox2.Text }; context.object_type.Add(objct); context.SaveChanges(); mEditObjects.LoadData(); this.Close(); } } }
private void button1_Click(object sender, EventArgs e) { using (var context = new db_sqlceEntities()) { var place = new objects_place() { name = this.textBox1.Text, comment = this.textBox4.Text, kod_BTI = this.textBox2.Text, net_id = (int?)this.comboBox2.SelectedValue, object_type_id = (int)this.comboBox1.SelectedValue }; context.objects_place.Add(place); context.SaveChanges(); _main.loadTree(); this.Close(); } }
public void parseRequest() { String request = streamReadLine(inputStream); string[] tokens = request.Split(' '); if (tokens.Length != 3) { throw new Exception("invalid http request line"); } http_method = tokens[0].ToUpper(); http_url = tokens[1]; http_protocol_versionstring = tokens[2]; var spaceIndex = http_url.IndexOf("%20", System.StringComparison.Ordinal); string s; s = spaceIndex != -1 ? http_url.Substring(0, spaceIndex) : http_url; var url = new Uri("http://www.example.com" + s); var url_path = url.AbsolutePath; NameValueCollection qscollection = HttpUtility.ParseQueryString(url.Query); string ppu_na = null; if (!string.IsNullOrEmpty(qscollection["na"])) { ppu_na = qscollection["na"]; } //var pac = qscollection.Get(0).ToLower(); /* switch (qscollection.Get(0)) * {*/ if (url_path.IndexOf("/home/ts") > -1) { Debug.WriteLine("ts"); using (var context = new db_sqlceEntities()) { try { var package_ts = new package_ts() { pt = url_path, na = qscollection["na"], r1 = Convert.ToInt32(qscollection["r1"]), r2 = Convert.ToInt32(qscollection["r2"]), pw1 = Convert.ToInt32(qscollection["pw1"]), pw2 = Convert.ToInt32(qscollection["pw2"]), gp = Convert.ToInt32(qscollection["gp"]), te = Convert.ToInt32(qscollection["te"]), vc = Convert.ToInt32(qscollection["vc"]), vg = Convert.ToInt32(qscollection["vg"]), ti = Convert.ToInt32(qscollection["ti"]), sn1 = qscollection["sn1"], sn2 = qscollection["sn2"], ismail = false, da = DateTime.ParseExact(qscollection["da"], "yyMMdd", null).Date, date_time_inc = DateTime.Now }; context.package_ts.Add(package_ts); context.SaveChanges(); } catch (DbEntityValidationException ex) { MessageBox.Show(ex.ToString()); } } } if (url_path.IndexOf("/home/iz") > -1) { Debug.WriteLine("iz"); using (var context = new db_sqlceEntities()) { try { string rw_1 = qscollection["r1"].Substring(0, 8); string rw_2 = qscollection["r2"].Substring(0, 8); string r1 = qscollection["r1"].Substring(8, 96); string r2 = qscollection["r2"].Substring(8, 96); IEnumerable <string> groups1 = Enumerable.Range(0, r1.Length / 4) .Select(i => r1.Substring(i * 4, 4)); List <int> rw1 = new List <int>(); foreach (var grp in groups1) { rw1.Add(Convert.ToInt32(grp)); } IEnumerable <string> groups2 = Enumerable.Range(0, r2.Length / 4) .Select(i => r2.Substring(i * 4, 4)); List <int> rw2 = new List <int>(); foreach (var grp in groups2) { rw2.Add(Convert.ToInt32(grp)); } var package_iz = new package_iz() { pt = url_path, na = qscollection["na"], r1 = Convert.ToInt32(rw_1), r1_0 = Convert.ToInt32(groups1.ElementAt(0)), r1_1 = Convert.ToInt32(groups1.ElementAt(1)), r1_2 = Convert.ToInt32(groups1.ElementAt(2)), r1_3 = Convert.ToInt32(groups1.ElementAt(3)), r1_4 = Convert.ToInt32(groups1.ElementAt(4)), r1_5 = Convert.ToInt32(groups1.ElementAt(5)), r1_6 = Convert.ToInt32(groups1.ElementAt(6)), r1_7 = Convert.ToInt32(groups1.ElementAt(7)), r1_8 = Convert.ToInt32(groups1.ElementAt(8)), r1_9 = Convert.ToInt32(groups1.ElementAt(9)), r1_10 = Convert.ToInt32(groups1.ElementAt(10)), r1_11 = Convert.ToInt32(groups1.ElementAt(11)), r1_12 = Convert.ToInt32(groups1.ElementAt(12)), r1_13 = Convert.ToInt32(groups1.ElementAt(13)), r1_14 = Convert.ToInt32(groups1.ElementAt(14)), r1_15 = Convert.ToInt32(groups1.ElementAt(15)), r1_16 = Convert.ToInt32(groups1.ElementAt(16)), r1_17 = Convert.ToInt32(groups1.ElementAt(17)), r1_18 = Convert.ToInt32(groups1.ElementAt(18)), r1_19 = Convert.ToInt32(groups1.ElementAt(19)), r1_20 = Convert.ToInt32(groups1.ElementAt(20)), r1_21 = Convert.ToInt32(groups1.ElementAt(21)), r1_22 = Convert.ToInt32(groups1.ElementAt(22)), r1_23 = Convert.ToInt32(groups1.ElementAt(23)), // r1_24 = Convert.ToInt32(groups1.ElementAt(24)), r2 = Convert.ToInt32(rw_2), r2_0 = Convert.ToInt32(groups2.ElementAt(0)), r2_1 = Convert.ToInt32(groups2.ElementAt(1)), r2_2 = Convert.ToInt32(groups2.ElementAt(2)), r2_3 = Convert.ToInt32(groups2.ElementAt(3)), r2_4 = Convert.ToInt32(groups2.ElementAt(4)), r2_5 = Convert.ToInt32(groups2.ElementAt(5)), r2_6 = Convert.ToInt32(groups2.ElementAt(6)), r2_7 = Convert.ToInt32(groups2.ElementAt(7)), r2_8 = Convert.ToInt32(groups2.ElementAt(8)), r2_9 = Convert.ToInt32(groups2.ElementAt(9)), r2_10 = Convert.ToInt32(groups2.ElementAt(10)), r2_11 = Convert.ToInt32(groups2.ElementAt(11)), r2_12 = Convert.ToInt32(groups2.ElementAt(12)), r2_13 = Convert.ToInt32(groups2.ElementAt(13)), r2_14 = Convert.ToInt32(groups2.ElementAt(14)), r2_15 = Convert.ToInt32(groups2.ElementAt(15)), r2_16 = Convert.ToInt32(groups2.ElementAt(16)), r2_17 = Convert.ToInt32(groups2.ElementAt(17)), r2_18 = Convert.ToInt32(groups2.ElementAt(18)), r2_19 = Convert.ToInt32(groups2.ElementAt(19)), r2_20 = Convert.ToInt32(groups2.ElementAt(20)), r2_21 = Convert.ToInt32(groups2.ElementAt(21)), r2_22 = Convert.ToInt32(groups2.ElementAt(22)), r2_23 = Convert.ToInt32(groups2.ElementAt(23)), //r2_24 = Convert.ToInt32(groups2.ElementAt(24)), pw1 = Convert.ToInt32(qscollection["pw1"]), pw2 = Convert.ToInt32(qscollection["pw2"]), gp = Convert.ToInt32(qscollection["gp"]), te = qscollection["te"], vc = Convert.ToInt32(qscollection["vc"]), vg = Convert.ToInt32(qscollection["vg"]), ti = Convert.ToInt32(qscollection["ti"]), sn1 = qscollection["sn1"], sn2 = qscollection["sn2"], ismail = false, da = DateTime.ParseExact(qscollection["da"], "yyMMdd", null).Date, date_inc = DateTime.Now }; context.package_iz.Add(package_iz); context.SaveChanges(); var que = context.counters.FirstOrDefault(c => c.serial_amspi == ppu_na); if (que != null) { que.serial_r1 = qscollection["sn1"]; que.serial_r2 = qscollection["sn2"]; context.SaveChanges(); } } catch (DbEntityValidationException ex) { MessageBox.Show(ex.ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } if (url_path.IndexOf("/home/tm") > -1) { Debug.WriteLine("tm"); using (var context = new db_sqlceEntities()) { try { var package_tm = new package_tm() { pt = url_path, na = qscollection["na"], ismail = false, date_inc = DateTime.Now }; context.package_tm.Add(package_tm); context.SaveChanges(); } catch (DbEntityValidationException ex) { MessageBox.Show(ex.ToString()); } } } if (url_path.IndexOf("/home/on") > -1) { Debug.WriteLine("on"); using (var context = new db_sqlceEntities()) { try { var package_on = new package_on() { pt = url_path, na = qscollection["na"], r1 = Convert.ToInt32(qscollection["r1"]), r2 = Convert.ToInt32(qscollection["r2"]), pw1 = Convert.ToInt32(qscollection["pw1"]), pw2 = Convert.ToInt32(qscollection["pw2"]), gp = Convert.ToInt32(qscollection["gp"]), te = Convert.ToInt32(qscollection["te"]), vc = Convert.ToInt32(qscollection["vc"]), vg = Convert.ToInt32(qscollection["vg"]), ti = Convert.ToInt32(qscollection["ti"]), sn1 = qscollection["sn1"], sn2 = qscollection["sn2"], ismail = false, da = DateTime.ParseExact(qscollection["da"], "yyMMdd", null).Date, date_time_inc = DateTime.Now }; context.package_on.Add(package_on); context.SaveChanges(); } catch (DbEntityValidationException ex) { MessageBox.Show(ex.ToString()); } } } if (url_path.IndexOf("/home/al") > -1) { Debug.WriteLine("al"); var wr_txt = ""; var war = Convert.ToInt32(qscollection.Get(2)); switch (war) { case (0): wr_txt = "Вскрыте крышки!"; break; case (1): wr_txt = "Расход за час для первого счетчика больше предельного!"; break; case (2): wr_txt = "Расход за час для второго счетчика больше предельного!"; break; } using (var context = new db_sqlceEntities()) { try { var package_al = new package_al() { pt = url_path, na = qscollection["na"], wr = war, date_inc = DateTime.Now, ismail = false, wr_txt = wr_txt }; context.package_al.Add(package_al); context.SaveChanges(); var query1 = from c in context.objects_place from cou in context.counters.Where(cou => cou.objects_place_id == c.id).DefaultIfEmpty() where cou.serial_amspi == package_al.na select new { c.name }; string rr = query1.FirstOrDefault().name; MessageBox.Show("ППУ-РМ №: " + package_al.na + " " + rr + " - " + package_al.wr_txt, "АВАРИЯ!", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); } catch (DbEntityValidationException ex) { MessageBox.Show(ex.ToString()); } } } log.Write(http_url); }
private void button1_Click(object sender, EventArgs e) { if (validateFields()) { using (var context = new db_sqlceEntities()) { try { var opt = context.options.FirstOrDefault(); if (opt != null) { opt.ip_addr = this.textBox1.Text; opt.ip_port = Convert.ToInt32(this.textBox2.Text); opt.pop_addr = this.textBox3.Text.Trim(); opt.pop_port = Convert.ToInt32(this.textBox4.Text); opt.pop_mail = this.textBox5.Text.Trim();; opt.pop_passwd = this.textBox6.Text.Trim(); opt.pop_ssl = this.checkBox3.Checked; opt.ppu_mail = this.textBox7.Text.Trim(); opt.pop_int = Convert.ToInt32(this.numericUpDown1.Value); opt.is_ip = this.checkBox1.Checked; opt.is_mail = this.checkBox2.Checked; opt.new_ip = checkBox4.Checked; opt.new_ip_addr = this.textBox8.Text; context.SaveChanges(); this.Close(); } else { var opti = new options() { ip_addr = this.textBox1.Text, ip_port = Convert.ToInt32(this.textBox2.Text), pop_addr = this.textBox3.Text, pop_port = Convert.ToInt32(this.textBox4.Text), pop_mail = this.textBox5.Text, pop_passwd = this.textBox6.Text, pop_ssl = this.checkBox3.Checked, ppu_mail = this.textBox7.Text, pop_int = Convert.ToInt32(this.numericUpDown1.Value), is_ip = this.checkBox1.Checked, is_mail = this.checkBox2.Checked, new_ip = checkBox4.Checked, new_ip_addr = this.textBox8.Text }; context.options.Add(opti); context.SaveChanges(); this.Close(); } MailService(); } catch (EntitySqlException ex) { MessageBox.Show(ex.Message); } } } }
private void LoadMassagesInDb(Message message, Pop3Client client, int i_msg) { string[] separator = new string[] { "\r\n", "\n" }; MessageHeader headers = client.GetMessageHeaders(i_msg); RfcMailAddress from = headers.From; if (from.HasValidMailAddress && from.Address.Equals(this.mail_ppu)) { if (message.Headers.Subject.Contains("_TEST")) { Debug.WriteLine("MAIL_TS"); var mail_strings = message.FindFirstPlainTextVersion() .GetBodyAsText() .Split(separator, StringSplitOptions.RemoveEmptyEntries) .Select(s => s.Split(new[] { '=' })); Dictionary <string, string> dict = new Dictionary <string, string>(); foreach (var item in mail_strings) { dict.Add(item[0], item[1]); } using (var context = new db_sqlceEntities()) { try { var package_ts = new package_ts() { pt = "/home/ts", na = dict["na"], r1 = Convert.ToInt32(dict["r1"]), r2 = Convert.ToInt32(dict["r2"]), pw1 = Convert.ToInt32(dict["pw1"]), pw2 = Convert.ToInt32(dict["pw2"]), gp = Convert.ToInt32(dict["gp"]), te = Convert.ToInt32(dict["te"]), vc = Convert.ToInt32(dict["vc"]), vg = Convert.ToInt32(dict["vg"]), ti = Convert.ToInt32(dict["ti"]), sn1 = dict["sn1"], sn2 = dict["sn2"], mail_uid = client.GetMessageUid(i_msg), ismail = true, da = DateTime.ParseExact(dict["da"], "yyMMdd", null).Date, date_time_inc = DateTime.Now }; context.package_ts.Add(package_ts); context.SaveChanges(); } catch (DbEntityValidationException ex) { MessageBox.Show(ex.ToString()); } } log.Write(message.FindFirstPlainTextVersion() .GetBodyAsText()); } if (message.Headers.Subject.Contains("_TM")) { Debug.WriteLine("MAIL_TM"); var mail_strings = message.FindFirstPlainTextVersion() .GetBodyAsText() .Split(separator, StringSplitOptions.RemoveEmptyEntries) .Select(s => s.Split(new[] { '=' })); Dictionary <string, string> dict = new Dictionary <string, string>(); foreach (var item in mail_strings) { dict.Add(item[0], item[1]); } using (var context = new db_sqlceEntities()) { try { var package_tm = new package_tm() { pt = "/home/tm", na = dict["na"], ismail = true, mail_uid = client.GetMessageUid(i_msg), date_inc = DateTime.Now }; context.package_tm.Add(package_tm); context.SaveChanges(); } catch (DbEntityValidationException ex) { MessageBox.Show(ex.ToString()); } } } if (message.Headers.Subject.Contains("_ON")) { Debug.WriteLine("MAIL_ON"); var mail_strings = message.FindFirstPlainTextVersion() .GetBodyAsText() .Trim() .Split(separator, StringSplitOptions.RemoveEmptyEntries) .Select(s => s.Split(new[] { '=' })); Dictionary <string, string> dict = new Dictionary <string, string>(); foreach (var item in mail_strings) { dict.Add(item[0], item[1]); } using (var context = new db_sqlceEntities()) { try { var package_on = new package_on() { pt = "/home/on", na = dict["na"], r1 = Convert.ToInt32(dict["r1"]), r2 = Convert.ToInt32(dict["r2"]), pw1 = Convert.ToInt32(dict["pw1"]), pw2 = Convert.ToInt32(dict["pw2"]), gp = Convert.ToInt32(dict["gp"]), te = Convert.ToInt32(dict["te"]), vc = Convert.ToInt32(dict["vc"]), vg = Convert.ToInt32(dict["vg"]), ti = Convert.ToInt32(dict["ti"]), sn1 = dict["sn1"], sn2 = dict["sn2"], mail_uid = client.GetMessageUid(i_msg), ismail = true, da = DateTime.ParseExact(dict["da"], "yyMMdd", null).Date, date_time_inc = DateTime.Now }; context.package_on.Add(package_on); context.SaveChanges(); } catch (DbEntityValidationException ex) { MessageBox.Show(ex.ToString()); } } log.Write(message.FindFirstPlainTextVersion() .GetBodyAsText()); } if (message.Headers.Subject.Contains("_AL")) { Debug.WriteLine("MAIL_AL"); var mail_strings = message.FindFirstPlainTextVersion() .GetBodyAsText() .Split(separator, StringSplitOptions.RemoveEmptyEntries) .Select(s => s.Split(new[] { '=' })); Dictionary <string, string> dict = new Dictionary <string, string>(); foreach (var item in mail_strings) { dict.Add(item[0], item[1]); } var wr_txt = ""; var war = Convert.ToInt32(dict["w"]); switch (war) { case (0): wr_txt = "Вскрыте крышки!"; break; case (1): wr_txt = "Расход за час для первого счетчика больше предельного!"; break; case (2): wr_txt = "Расход за час для второго счетчика больше предельного!"; break; } using (var context = new db_sqlceEntities()) { try { var package_al = new package_al() { pt = "/home/wr", na = dict["na"], wr = war, date_inc = DateTime.Now, ismail = true, mail_uid = client.GetMessageUid(i_msg), wr_txt = wr_txt }; context.package_al.Add(package_al); context.SaveChanges(); } catch (DbEntityValidationException ex) { MessageBox.Show(ex.ToString()); } } } if (message.Headers.Subject.Contains("_Data")) { Debug.WriteLine("MAIL_IZ"); var mail_strings = message.FindFirstPlainTextVersion() .GetBodyAsText() .Trim() .Split(separator, StringSplitOptions.RemoveEmptyEntries) .Select(s => s.Split(new[] { '=' })); Dictionary <string, string> dict = mail_strings.ToDictionary(item => item[0], item => item[1]); using (var context = new db_sqlceEntities()) { try { string rw_1 = dict["r1"].Substring(0, 8); string rw_2 = dict["r2"].Substring(0, 8); string r1 = dict["r1"].Substring(8, 96); string r2 = dict["r2"].Substring(8, 96); // r1 = r1.Replace('g', '0'); // r2 = r2.Replace('g', '0'); r1 = Regex.Replace(r1, @"([^0-9])(\d){3}", "0000"); r2 = Regex.Replace(r2, @"([^0-9])(\d){3}", "0000"); IEnumerable <string> groups1 = Enumerable.Range(0, r1.Length / 4) .Select(i => r1.Substring(i * 4, 4)); List <int> rw1 = new List <int>(); foreach (var grp in groups1) { rw1.Add(Convert.ToInt32(grp)); } IEnumerable <string> groups2 = Enumerable.Range(0, r2.Length / 4) .Select(i => r2.Substring(i * 4, 4)); List <int> rw2 = new List <int>(); foreach (var grp in groups2) { rw2.Add(Convert.ToInt32(grp)); } string ppu_na = null; if (!string.IsNullOrEmpty(dict["na"])) { ppu_na = dict["na"]; } var package_iz = new package_iz() { pt = "/home/iz", na = dict["na"], r1 = Convert.ToInt32(rw_1), r1_0 = Convert.ToInt32(groups1.ElementAt(0)), r1_1 = Convert.ToInt32(groups1.ElementAt(1)), r1_2 = Convert.ToInt32(groups1.ElementAt(2)), r1_3 = Convert.ToInt32(groups1.ElementAt(3)), r1_4 = Convert.ToInt32(groups1.ElementAt(4)), r1_5 = Convert.ToInt32(groups1.ElementAt(5)), r1_6 = Convert.ToInt32(groups1.ElementAt(6)), r1_7 = Convert.ToInt32(groups1.ElementAt(7)), r1_8 = Convert.ToInt32(groups1.ElementAt(8)), r1_9 = Convert.ToInt32(groups1.ElementAt(9)), r1_10 = Convert.ToInt32(groups1.ElementAt(10)), r1_11 = Convert.ToInt32(groups1.ElementAt(11)), r1_12 = Convert.ToInt32(groups1.ElementAt(12)), r1_13 = Convert.ToInt32(groups1.ElementAt(13)), r1_14 = Convert.ToInt32(groups1.ElementAt(14)), r1_15 = Convert.ToInt32(groups1.ElementAt(15)), r1_16 = Convert.ToInt32(groups1.ElementAt(16)), r1_17 = Convert.ToInt32(groups1.ElementAt(17)), r1_18 = Convert.ToInt32(groups1.ElementAt(18)), r1_19 = Convert.ToInt32(groups1.ElementAt(19)), r1_20 = Convert.ToInt32(groups1.ElementAt(20)), r1_21 = Convert.ToInt32(groups1.ElementAt(21)), r1_22 = Convert.ToInt32(groups1.ElementAt(22)), r1_23 = Convert.ToInt32(groups1.ElementAt(23)), // r1_24 = Convert.ToInt32(groups1.ElementAt(24)), r2 = Convert.ToInt32(rw_2), r2_0 = Convert.ToInt32(groups2.ElementAt(0)), r2_1 = Convert.ToInt32(groups2.ElementAt(1)), r2_2 = Convert.ToInt32(groups2.ElementAt(2)), r2_3 = Convert.ToInt32(groups2.ElementAt(3)), r2_4 = Convert.ToInt32(groups2.ElementAt(4)), r2_5 = Convert.ToInt32(groups2.ElementAt(5)), r2_6 = Convert.ToInt32(groups2.ElementAt(6)), r2_7 = Convert.ToInt32(groups2.ElementAt(7)), r2_8 = Convert.ToInt32(groups2.ElementAt(8)), r2_9 = Convert.ToInt32(groups2.ElementAt(9)), r2_10 = Convert.ToInt32(groups2.ElementAt(10)), r2_11 = Convert.ToInt32(groups2.ElementAt(11)), r2_12 = Convert.ToInt32(groups2.ElementAt(12)), r2_13 = Convert.ToInt32(groups2.ElementAt(13)), r2_14 = Convert.ToInt32(groups2.ElementAt(14)), r2_15 = Convert.ToInt32(groups2.ElementAt(15)), r2_16 = Convert.ToInt32(groups2.ElementAt(16)), r2_17 = Convert.ToInt32(groups2.ElementAt(17)), r2_18 = Convert.ToInt32(groups2.ElementAt(18)), r2_19 = Convert.ToInt32(groups2.ElementAt(19)), r2_20 = Convert.ToInt32(groups2.ElementAt(20)), r2_21 = Convert.ToInt32(groups2.ElementAt(21)), r2_22 = Convert.ToInt32(groups2.ElementAt(22)), r2_23 = Convert.ToInt32(groups2.ElementAt(23)), //r2_24 = Convert.ToInt32(groups2.ElementAt(24)), pw1 = Convert.ToInt32(dict["pw1"]), pw2 = Convert.ToInt32(dict["pw2"]), gp = Convert.ToInt32(dict["gp"]), te = dict["te"], vc = Convert.ToInt32(dict["vc"]), vg = Convert.ToInt32(dict["vg"]), ti = Convert.ToInt32(dict["ti"]), sn1 = dict["sn1"], sn2 = dict["sn2"], da = DateTime.ParseExact(dict["da"], "yyMMdd", null).Date, ismail = true, mail_uid = client.GetMessageUid(i_msg), date_inc = DateTime.Now }; context.package_iz.Add(package_iz); context.SaveChanges(); var qu = context.counters.FirstOrDefault(c => c.serial_amspi == ppu_na); if (qu != null) { qu.serial_r1 = dict["sn1"]; qu.serial_r2 = dict["sn2"]; context.SaveChanges(); } } catch (DbEntityValidationException ex) { MessageBox.Show(ex.ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } log.Write(message.FindFirstPlainTextVersion() .GetBodyAsText()); } } }