private int count_mismatches(int listIndexB, int listIndexR, int baseFieldIndex, int recentFieldIndex) { int mismatches = 0; if (eRules[listIndexR].RemoveValues[recentFieldIndex]) { return(-1); } if (baseFieldIndex >= eLC_base.Lists[listIndexB].elementFields.Length) { return(-1); //eLC_recent->Lists[listIndex]->elementValues->Length; } if (recentFieldIndex >= eLC_recent.Lists[listIndexR].elementFields.Length) { return(-1); //eLC_base->Lists[listIndex]->elementValues->Length; } for (int e = 0; e < eLC_recent.Lists[listIndexR].elementValues.Length; e++) { if (e >= eLC_base.Lists[listIndexB].elementValues.Length || e >= eLC_recent.Lists[listIndexR].elementValues.Length) { break; } if (eLC_base.GetValue(listIndexB, e, baseFieldIndex) != eLC_recent.GetValue(listIndexR, e, recentFieldIndex)) { mismatches++; } } return(mismatches); }
private void click_compare(object sender, EventArgs e) { if (eLCOther != null && comboBox_List.SelectedIndex > -1) { //progressBar_progress.Style = ProgressBarStyle.Continuous; int l = comboBox_List.SelectedIndex; int lo = l; ArrayList Fields = new ArrayList(); ArrayList Excludes = new ArrayList(); if (l != eLC.ConversationListIndex) { for (int i = 0; i < eLC.Lists[l].elementFields.Length; i++) { if (dataGridView_fields.Rows[i].Cells[1].Value.ToString() == "True") { Excludes.Add("\t#" + i + "\t- " + eLC.Lists[l].elementFields[i]); } else { Fields.Add(eLC.Lists[l].elementFields[i]); } } StreamWriter sw = new StreamWriter(textBox_LogDir.Text + "\\Field_Compare.txt", false, Encoding.Unicode); sw.Close(); File.AppendAllText(textBox_LogDir.Text + "\\Field_Compare.txt", "List: " + eLC.Lists[l].listName + "\r\n", Encoding.Unicode); if (Excludes.Count > 0) { File.AppendAllText(textBox_LogDir.Text + "\\Field_Compare.txt", "Fields Excluded:\r\n", Encoding.Unicode); for (int i = 0; i < Excludes.Count; i++) { File.AppendAllText(textBox_LogDir.Text + "\\Field_Compare.txt", Excludes[i] + "\r\n", Encoding.Unicode); } } if (eLC.Version < 191 && eLCOther.Version >= 191 && l >= eLCOther.ConversationListIndex) { lo--; } if (eLC.Version >= 191 && eLCOther.Version < 191 && l >= eLCOther.ConversationListIndex) { lo++; } cpb2.Maximum = eLC.Lists[l].elementValues.Length + 1; for (int i = 0; i < eLC.Lists[l].elementValues.Length && i < eLCOther.Lists[lo].elementValues.Length; i++) { for (int eo = 0; eo < eLCOther.Lists[lo].elementValues.Length; eo++) { if (eLC.GetValue(l, i, 0) == eLCOther.GetValue(lo, eo, 0)) { string log = ""; for (int fl = 0; fl < Fields.Count; fl++) { for (int fl1 = 0; fl1 < eLC.Lists[l].elementFields.Length; fl1++) { if (eLC.Lists[l].elementFields[fl1] == Fields[fl].ToString()) { for (int flo = 0; flo < eLCOther.Lists[lo].elementFields.Length; flo++) { if (eLCOther.Lists[lo].elementFields[flo] == Fields[fl].ToString()) { if (eLC.GetValue(l, i, fl1) != eLCOther.GetValue(lo, eo, flo)) { log += "Item ID: " + eLC.GetValue(l, i, 0) + "\tField: " + Fields[fl] + "\tOld Value: " + eLC.GetValue(l, i, fl1) + "\tNew Value: " + eLCOther.GetValue(lo, eo, flo) + "\r\n"; } break; } } break; } } } if (log != "") { File.AppendAllText(textBox_LogDir.Text + "\\Field_Compare.txt", "\r\n-------------------------------------------------------------------------\r\n" + log, Encoding.Unicode); } break; } } cpb2.Value++; Application.DoEvents(); } } else { /*StreamWriter sw = new StreamWriter(textBox_LogDir.Text + "\\Field_Compare.txt", false, Encoding.Unicode); * sw.Close(); * File.AppendAllText(textBox_LogDir.Text + "\\Field_Compare.txt", "List: " + eLC.Lists[l].listName + "\r\n", Encoding.Unicode); * if (eLC.Lists[eLC.ConversationListIndex].elementValues == eLCOther.Lists[eLCOther.ConversationListIndex].elementValues) * File.AppendAllText(textBox_LogDir.Text + "\\Field_Compare.txt", "\r\nMatched", Encoding.Unicode); * else * File.AppendAllText(textBox_LogDir.Text + "\\Field_Compare.txt", "\r\nNot Matched", Encoding.Unicode);*/ } cpb2.Value = 0; //progressBar_progress.Style = ProgressBarStyle.Continuous; } }
private void click_replace(object sender, EventArgs e) { if (eLCOther != null && comboBox_List.SelectedIndex > -1 && comboBox_Field.SelectedIndex > -1) { if (textBox_LogDir.Text != "") { StreamWriter sw = new StreamWriter(textBox_LogDir.Text + "\\Field_Replace.txt", false, Encoding.Unicode); sw.Close(); int l = comboBox_List.SelectedIndex; int lo = comboBox_List.SelectedIndex; int FieldIndex = comboBox_Field.SelectedIndex; int FieldIndexOther = -1; int ReplacedCount = 0; if (l != eLC.ConversationListIndex) { if (eLC.Version < 191 && eLCOther.Version >= 191 && comboBox_List.SelectedIndex >= eLC.ConversationListIndex) { l++; } if (eLC.Version >= 191 && eLCOther.Version < 191 && comboBox_List.SelectedIndex >= eLCOther.ConversationListIndex) { lo++; } if (l < eLC.Lists.Length && lo < eLCOther.Lists.Length) { cpb2.Maximum = eLCOther.Lists[lo].elementValues.Length; for (int i = 0; i < eLCOther.Lists[lo].elementFields.Length; i++) { if (eLC.Lists[l].elementFields[FieldIndex] == eLCOther.Lists[lo].elementFields[i]) { FieldIndexOther = i; break; } } if (FieldIndexOther > -1) { File.AppendAllText(textBox_LogDir.Text + "\\Field_Replace.txt", "List: " + eLC.Lists[l].listName + " | Field: " + FieldIndex + " - " + eLC.Lists[l].elementFields[FieldIndex] + "\r\n\r\n\r\n", Encoding.Unicode); for (int i = 0; i < eLC.Lists[l].elementValues.Length && i < eLCOther.Lists[lo].elementValues.Length; i++) { for (int io = 0; io < eLCOther.Lists[lo].elementValues.Length; io++) { if (eLC.GetValue(l, i, 0) == eLCOther.GetValue(lo, io, 0)) { if (eLC.GetValue(l, i, FieldIndex) != eLCOther.GetValue(lo, io, FieldIndexOther)) { File.AppendAllText(textBox_LogDir.Text + "\\Field_Replace.txt", "REPLACED\t\tID:" + eLC.GetValue(l, i, 0) + "\t\tValue: " + eLC.GetValue(l, i, FieldIndex) + "(by: " + eLCOther.GetValue(lo, io, FieldIndexOther) + ")\r\n", Encoding.Unicode); eLC.Lists[l].elementValues[i][FieldIndex] = eLCOther.Lists[lo].elementValues[io][FieldIndexOther]; ReplacedCount++; } else { File.AppendAllText(textBox_LogDir.Text + "\\Field_Replace.txt", "NO REPLACED\t\tID:" + eLC.GetValue(l, i, 0) + "\t\tValue: " + eLC.GetValue(l, i, FieldIndex) + "\r\n", Encoding.Unicode); } cpb2.Value++; Application.DoEvents(); } } } } } } else { cpb2.Maximum = conversationList.talk_proc_count; for (int t = 0; t < conversationList.talk_proc_count; t++) { for (int to = 0; to < conversationListOther.talk_proc_count; to++) { if (conversationList.talk_procs[t].id_talk == conversationListOther.talk_procs[to].id_talk) { for (int w = 0; w < conversationList.talk_procs[t].num_window; w++) { for (int wo = 0; wo < conversationListOther.talk_procs[to].num_window; wo++) { if (conversationList.talk_procs[t].windows[w].id == conversationListOther.talk_procs[to].windows[wo].id) { conversationList.talk_procs[t].windows[w].talk_text_len = conversationListOther.talk_procs[to].windows[wo].talk_text_len; conversationList.talk_procs[t].windows[w].talk_text = conversationListOther.talk_procs[to].windows[wo].talk_text; ReplacedCount++; for (int o = 0; o < conversationList.talk_procs[t].windows[w].num_option && o < conversationListOther.talk_procs[to].windows[wo].num_option; o++) { conversationList.talk_procs[t].windows[w].options[o].text = conversationListOther.talk_procs[to].windows[wo].options[o].text; ReplacedCount++; } } } } } } cpb2.Value++; Application.DoEvents(); } } cpb2.Value = 0; MessageBox.Show(ReplacedCount + " Values Replaced"); } } }
private void click_replace(object sender, EventArgs ea) { Cursor = Cursors.AppStarting; int replacementCount = 0; int l; int l_max; int e; int e_max; int v; int v_max; string oldValue = textBox_oldValue.Text; string newValue = textBox_newValue.Text; string operation = comboBox_operation.SelectedItem.ToString(); Decimal operand = numericUpDown_operand.Value; if (textBox_list.Text == "*") { l = 0; l_max = eLC.Lists.Length; } else { l = Convert.ToInt32(textBox_list.Text); l_max = Convert.ToInt32(textBox_list.Text) + 1; if (l < 0 || l_max > eLC.Lists.Length) { MessageBox.Show("List Index Out of Range"); return; } } for (int lf = l; lf < l_max; lf++) { if (textBox_item.Text == "*") { e = 0; e_max = eLC.Lists[lf].elementValues.Length; } else { e = Convert.ToInt32(textBox_item.Text); e_max = Convert.ToInt32(textBox_item.Text) + 1; if (e < 0 || e_max > eLC.Lists[lf].elementValues.Length) { MessageBox.Show("Item Index Out of Range"); return; } } for (int ef = e; ef < e_max; ef++) { if (textBox_field.Text == "*") { v = 0; v_max = eLC.Lists[lf].elementValues[ef].Length; } else { v = Convert.ToInt32(textBox_field.Text); v_max = Convert.ToInt32(textBox_field.Text) + 1; if (v < 0 || v_max > eLC.Lists[lf].elementValues[ef].Length) { MessageBox.Show("Field Index Out of Range"); return; } } for (int vf = v; vf < v_max; vf++) { if (radioButton_replace.Checked) { if (oldValue == "*" || oldValue == eLC.GetValue(lf, ef, vf).Trim(new char[] { Convert.ToChar(0) })) { eLC.SetValue(lf, ef, vf, newValue); replacementCount++; } } if (radioButton_recalculate.Checked) { string type = eLC.GetType(lf, vf); if (type == "int16") { short op1 = Convert.ToInt16(eLC.GetValue(lf, ef, vf)); short op2 = Convert.ToInt16(operand); string result = ""; if (operation == "*") { result = (op1 * op2).ToString(); } if (operation == "/") { result = (op1 / op2).ToString(); } if (operation == "+") { result = (op1 + op2).ToString(); } if (operation == "-") { result = (op1 - op2).ToString(); } eLC.SetValue(lf, ef, vf, result); replacementCount++; } if (type == "int32") { int op1 = Convert.ToInt32(eLC.GetValue(lf, ef, vf)); int op2 = Convert.ToInt32(operand); string result = ""; if (operation == "*") { result = (op1 * op2).ToString(); } if (operation == "/") { result = (op1 / op2).ToString(); } if (operation == "+") { result = (op1 + op2).ToString(); } if (operation == "-") { result = (op1 - op2).ToString(); } eLC.SetValue(lf, ef, vf, result); replacementCount++; } if (type == "int64") { long op1 = Convert.ToInt64(eLC.GetValue(lf, ef, vf)); long op2 = Convert.ToInt64(operand); string result = ""; if (operation == "*") { result = (op1 * op2).ToString(); } if (operation == "/") { result = (op1 / op2).ToString(); } if (operation == "+") { result = (op1 + op2).ToString(); } if (operation == "-") { result = (op1 - op2).ToString(); } eLC.SetValue(lf, ef, vf, result); replacementCount++; } if (type == "float") { float op1 = Convert.ToSingle(eLC.GetValue(lf, ef, vf)); float op2 = Convert.ToSingle(operand); string result = ""; if (operation == "*") { result = (op1 * op2).ToString("F3"); } if (operation == "/") { result = (op1 / op2).ToString("F3"); } if (operation == "+") { result = (op1 + op2).ToString("F3"); } if (operation == "-") { result = (op1 - op2).ToString("F3"); } eLC.SetValue(lf, ef, vf, result); replacementCount++; } if (type == "double") { double op1 = Convert.ToDouble(eLC.GetValue(lf, ef, vf)); double op2 = Convert.ToDouble(operand); string result = ""; if (operation == "*") { result = (op1 * op2).ToString("F3"); } if (operation == "/") { result = (op1 / op2).ToString("F3"); } if (operation == "+") { result = (op1 + op2).ToString("F3"); } if (operation == "-") { result = (op1 - op2).ToString("F3"); } eLC.SetValue(lf, ef, vf, result); replacementCount++; } } } } } Cursor = Cursors.Default; MessageBox.Show(replacementCount + " Values Replaced"); }