public void ImportOldDatabase(string filename) { if (!File.Exists(filename)) { return; } DataTable imported_call_log = CallLog.GetCallLog(999999999, filename); FrmTimerMsgBox msg = new FrmTimerMsgBox("Importing Call Log", "Importing", 500000, true); msg.Show(); foreach (DataRow call in imported_call_log.Rows) { Application.DoEvents(); string date_string = call["time"].ToString(); DateTime date = DateTime.ParseExact(date_string, "yyyyMMddHHmmss", null); CallLog.AddCall(call["line"].ToString(), call["type"].ToString(), call["io"].ToString(), call["dur"].ToString(), call["checksum"].ToString(), call["rings"].ToString(), date, call["number"].ToString(), call["name"].ToString(), call["uid"].ToString()); } if (msg.Visible) { msg.Close(); } if (!DO_NOT_UPDATE) { Program.fMain.RefreshCallLog(); } GC.Collect(); GC.WaitForPendingFinalizers(); File.Move(filename, filename.Replace(".db3", "-imported-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + "-" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Hour.ToString() + "-" + DateTime.Now.Minute.ToString() + ".db3")); }
private void btnExportRecords_Click(object sender, EventArgs e) { int records_to_export = (int)ndRecordCount.Value; DataTable records = CallLog.GetCallLog(records_to_export); string export_string = "Date And Time,Number,Name,Duration,Line,IO,Rings" + Environment.NewLine; SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = "Call_Log"; sfd.Filter = "Comma Seperated File|*.csv"; DialogResult r = sfd.ShowDialog(); if (r != DialogResult.Cancel && r != DialogResult.Abort && r != DialogResult.None) { FrmTimerMsgBox fExporting = new FrmTimerMsgBox("Exporting", "Please wait...", 60000 * 10, true); fExporting.Show(); if (File.Exists(sfd.FileName)) { File.Delete(sfd.FileName); } foreach (DataRow record in records.Rows) { Application.DoEvents(); DateTime the_date = Common.GetDateTimeFromSQLiteDate(record["time"].ToString()); // Export into CVS file format export_string += Common.FormatDateToExportCSVFormat(the_date) + ","; export_string += record["number"].ToString() + ","; export_string += "\"" + Common.GetUnsafeSqlString(record["name"].ToString()) + "\","; export_string += "\"" + Common.ConvertDurationToTime(int.Parse(record["dur"].ToString())).Replace(":", ".") + "\","; export_string += record["line"].ToString() + ","; export_string += record["io"].ToString() + ","; export_string += record["rings"].ToString(); export_string += Environment.NewLine; } File.WriteAllText(sfd.FileName, export_string); if (fExporting.Visible) { fExporting.Close(); } } }
private void PopulateCallLog() { dgvCallLog.Rows.Clear(); DataTable call_data; if (string.IsNullOrEmpty(cbSearch.Text)) { call_data = CallLog.GetCallLog((int)ndDisplayCount.Value); } else { call_data = CallLog.FilterCallLog(cbSearch.Text, (int)ndDisplayCount.Value); } foreach (DataRow call in call_data.Rows) { DateTime the_date = Common.GetDateTimeFromSQLiteDate(call["time"].ToString()); dgvCallLog.Rows.Add(); string name_str = call["name"].ToString(); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_NAME].Value = Common.GetUnsafeSqlString(name_str); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_NUMBER].Value = call["number"].ToString(); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_DATE].Value = GetDateTimeWithoutSeconds(the_date); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_DUR].Value = Common.ConvertDurationToTime(int.Parse(call["dur"].ToString())); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_LINE].Value = call["line"].ToString(); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_IO].Value = call["io"].ToString(); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].DefaultCellStyle.ForeColor = call["io"].ToString() == "I" ? Program.C_INCOMING_CALL_FOREGROUND : Program.C_OUTGOING_CALL_FOREGROUND; dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_RINGS].Value = call["rings"].ToString(); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_SORT_DATE].Value = the_date; dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_ID].Value = call["uid"].ToString(); dgvCallLog.Rows[dgvCallLog.Rows.Count - 1].Cells[DGV_LOG_CK].Value = call["ck"]; } dgvCallLog.ClearSelection(); }
public void RefreshLogCount() { int log_records = CallLog.GetCallLog(999999999).Rows.Count; lbTotalLogCount.Text = "Total of: " + log_records + " records in log"; }