public void AddIssueToList(IssueFound issue) { if (this.InvokeRequired) { this.Invoke((MethodInvoker)delegate { lvIssues.Items.Add(issue.LocalFilePath); lvIssues.Items[lvIssues.Items.Count - 1].SubItems.Add(issue.IssueTitle); lvIssues.Items[lvIssues.Items.Count - 1].SubItems.Add(issue.ConflictTimeStamp.ToString("M/d/yyyy h:mm tt")); lvIssues.Items[lvIssues.Items.Count - 1].Tag = issue; }); } else { lvIssues.Items.Add(issue.LocalFilePath); lvIssues.Items[lvIssues.Items.Count - 1].SubItems.Add(issue.IssueTitle); lvIssues.Items[lvIssues.Items.Count - 1].SubItems.Add(issue.ConflictTimeStamp.ToString("M/d/yyyy h:mm tt")); lvIssues.Items[lvIssues.Items.Count - 1].Tag = issue; } }
public List<IssueFound> GetConflicts() { string query = "SELECT * FROM " + CONFLICT_TABLE_NAME + ";"; LogWrapper.LogMessage("DBHandler - GetConflicts", "Running query: " + query); List<IssueFound> issues = new List<IssueFound>(); SQLiteDataReader sqlDataReader = null; SQLiteConnection sqlConnection = OpenConnection(); SQLiteCommand sqlCommand = new SQLiteCommand(); sqlCommand.CommandText = query; sqlCommand.Connection = sqlConnection; try { sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read()) { IssueFound item = new IssueFound(); PopulateConflictFromReader(ref item, ref sqlDataReader); issues.Add(item); } } catch (Exception ex) { LogWrapper.LogMessage("DbHandler - GetConflicts", "Caught exception: " + ex.Message); } if (null != sqlDataReader) sqlDataReader.Close(); sqlConnection.Close(); return issues; }
public int StoreConflict(IssueFound issue) { int result = -1; string query = "insert into " + CONFLICT_TABLE_NAME + " (" + CONFLICT_LOCAL_FILE_PATH + ", " + CONFLICT_ISSUE_TITLE + ", " + CONFLICT_ISSUE_DESC + ", " + CONFLICT_TYPE + ", " + CONFLICT_LOCAL_DATE + ", " + CONFLICT_LOCAL_SIZE + ", " + CONFLICT_SERVER_FILE_INFO + ", " + CONFLICT_SERVER_DATE + ", " + CONFLICT_SERVER_SIZE + ", " + CONFLICT_TIME_STAMP + ", '" + CONFLICT_OR_ERROR + "', " + CONFLICT_EVENT_INDEX + ", " + CONFLICT_URI + ") values ('" + EscapeString(issue.LocalFilePath) + "','" + EscapeString(issue.IssueTitle) + "','" + EscapeString(issue.IssueDescripation) + "','" + issue.cType + "'," + issue.LocalIssueDT.Ticks + ",'" + issue.LocalSize + "','" + EscapeString(issue.ServerFileInfo) + "'," + issue.ServerIssueDT.Ticks + ",'" + issue.ServerSize + "'," + issue.ConflictTimeStamp.Ticks + ",'" + 'C' + "'," + '0'+",'" + issue.ServerFileUri + "');"; SQLiteConnection sqlConnection = OpenConnection(); SQLiteCommand sqlCommand = new SQLiteCommand(query, sqlConnection); LogWrapper.LogMessage("DBHandler - StoreConflict", "Running query: " + query); result = sqlCommand.ExecuteNonQuery(); sqlConnection.Close(); // A result of 1 is success (# of rows affected and we should // only have 1), not the index of the newly created entry. return result; }
public void PopulateConflictFromReader(ref IssueFound issue, ref SQLiteDataReader sqlDataReader) { issue.ConflictDbId = (Int64)sqlDataReader[CONFLICT_INDEX]; issue.LocalFilePath = (string)sqlDataReader[CONFLICT_LOCAL_FILE_PATH]; issue.IssueTitle = (string)sqlDataReader[CONFLICT_ISSUE_TITLE]; issue.IssueDescripation = (string)sqlDataReader[CONFLICT_ISSUE_DESC]; issue.LocalIssueDT = issue.LocalIssueDT.AddTicks((Int64)sqlDataReader[CONFLICT_LOCAL_DATE]); issue.LocalSize = (string)sqlDataReader[CONFLICT_LOCAL_SIZE]; issue.ServerFileInfo = (string)sqlDataReader[CONFLICT_SERVER_FILE_INFO]; issue.ServerIssueDT = issue.ServerIssueDT.AddTicks((Int64)sqlDataReader[CONFLICT_SERVER_DATE]); issue.ServerSize = (string)sqlDataReader[CONFLICT_SERVER_SIZE]; issue.ConflictTimeStamp = issue.ConflictTimeStamp.AddTicks((Int64)sqlDataReader[CONFLICT_TIME_STAMP]); issue.ServerFileUri = (string)sqlDataReader[CONFLICT_URI]; switch ((string)sqlDataReader[CONFLICT_TYPE]) { case "CONFLICT_UPLOAD": issue.cType = IssueFound.ConflictType.CONFLICT_UPLOAD; break; case "CONFLICT_MODIFIED": issue.cType = IssueFound.ConflictType.CONFLICT_MODIFIED; break; } }
private void UpdateInfoLabels(IssueFound issue) { if (this.InvokeRequired) { this.Invoke((MethodInvoker)delegate { lblUpdateStatus.Text = issue.IssueTitle; lblDescription.Text = issue.IssueDescripation; /*As file placed in deep directory structure contains backslashes, we need to replace them in to forward slashes to open the file in browser.*/ lnkFileInfo.Text = BasicInfo.ServiceUrl + "/#info/" + issue.ServerFileInfo.Replace('\\', '/'); lblFileSize.Text = issue.ServerSize; lblModified.Text = issue.ServerIssueDT.ToString("M/d/yyyy h:mm tt"); lblLocalFileSize.Text = issue.LocalSize; lblLocalModifiedDate.Text = issue.LocalIssueDT.ToString("M/d/yyyy h:mm tt"); lnkLocalFile.Text = issue.LocalFilePath; lnkLocalFile.Visible = true; lnkFileInfo.Visible = true; if (issue.cType == IssueFound.ConflictType.CONFLICT_MODIFIED) btnIgnoreConflict.Visible = true; else btnIgnoreConflict.Visible = false; }); } else { lblUpdateStatus.Text = issue.IssueTitle; lblDescription.Text = issue.IssueDescripation; /*As file placed in deep directory structure contains backslashes, we need to replace them in to forward slashes to open the file in browser.*/ lnkFileInfo.Text = BasicInfo.ServiceUrl + "/#info/" + issue.ServerFileInfo.Replace('\\', '/'); lblFileSize.Text = issue.ServerSize; lblModified.Text = issue.ServerIssueDT.ToString("M/d/yyyy h:mm tt"); lblLocalFileSize.Text = issue.LocalSize; lblLocalModifiedDate.Text = issue.LocalIssueDT.ToString("M/d/yyyy h:mm tt"); lnkLocalFile.Text = issue.LocalFilePath; lnkLocalFile.Visible = true; lnkFileInfo.Visible = true; if (issue.cType == IssueFound.ConflictType.CONFLICT_MODIFIED) btnIgnoreConflict.Visible = true; else btnIgnoreConflict.Visible = false; } }
private void ReportConflict(LocalEvents lEvent, IssueFound.ConflictType cType) { //LogWrapper.LogMessage("SyncManager - ReportConflict", "Enter"); FileInfo fInfo = new FileInfo(lEvent.FullPath); IssueFound iFound = new IssueFound(); iFound.LocalFilePath = lEvent.FullPath; iFound.LocalIssueDT = fInfo.LastWriteTime; iFound.LocalSize = FormatSizeString(fInfo.Length); iFound.ConflictTimeStamp = DateTime.Now; iFound.cType = cType; string Description = ""; switch (cType) { case IssueFound.ConflictType.CONFLICT_MODIFIED: { iFound.IssueTitle = LanguageTranslator.GetValue("ConflictDetectedModified"); Description += LanguageTranslator.GetValue("ErrorBlurbConflict1"); Description += LanguageTranslator.GetValue("ErrorBlurbConflict2") + "\n"; Description += LanguageTranslator.GetValue("ErrorBlurbConflict3") + "\n"; Description += LanguageTranslator.GetValue("ErrorBlurbConflict4"); Description += LanguageTranslator.GetValue("ErrorBlurbConflict5"); iFound.IssueDescripation = Description; } break; case IssueFound.ConflictType.CONFLICT_UPLOAD: { iFound.IssueTitle = LanguageTranslator.GetValue("ConflictDetectedError"); Description += LanguageTranslator.GetValue("ErrorBlurbUpload1"); Description += LanguageTranslator.GetValue("ErrorBlurbUpload2"); Description += LanguageTranslator.GetValue("ErrorBlurbUpload3"); iFound.IssueDescripation = Description; } break; } // cMezeoFileCloud.AppEventViewer(AboutBox.AssemblyTitle, Description, 3); int nStatusCode = 0; string strContentURi = GetContentURI(lEvent.FileName); if (strContentURi.Substring(strContentURi.Length - 9).Equals("/contents") || strContentURi.Substring(strContentURi.Length - 8).Equals("/content")) { strContentURi = strContentURi.Substring(0, strContentURi.LastIndexOf("/")); } ItemDetails iDetails = cMezeoFileCloud.GetContinerResult(strContentURi, ref nStatusCode); iFound.ServerSize = FormatSizeString(iDetails.dblSizeInBytes); iFound.ServerIssueDT = iDetails.dtModified; iFound.ServerFileInfo = lEvent.FileName; iFound.ServerFileUri = iDetails.szContentUrl; // frmIssuesFound.AddIssueToList(iFound); dbHandler.StoreConflict(iFound); // Issue Fix for Conflicts IssueFoundBalloonMessage(); //LogWrapper.LogMessage("SyncManager - ReportConflict", "Leave"); }