public static ObservableCollection <CFile> GetFileData() { try { ObservableCollection <CFile> cFiles = new ObservableCollection <CFile>(); var connection = Connect(); if (connection != null) { string query = string.Format("SELECT ID,ProjectName, SourceDir, ReleaseDir, RelatievePath, LastHash, Date, Version FROM dbo.Friday"); SqlCommand command = connection.CreateCommand(); command.CommandText = query; SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { var cFile = new CFile() { Name = reader["RelatievePath"].ToString(), SourcePath = reader["SourceDir"].ToString(), ReleasePath = reader["ReleaseDir"].ToString(), ID = Convert.ToInt32(reader["ID"]), ProjectName = reader["ProjectName"].ToString() }; cFiles.Add(cFile); } } return(cFiles); } catch (Exception ex) { return(new ObservableCollection <CFile>()); } }
public static void AddFile(string name, string sourcePath, string releasePath, string projName) { CFile temp = new CFile() { Name = name, ProjectName = projName, SourcePath = sourcePath, ReleasePath = releasePath, ID = Files.Count + 1 }; temp.GetFileInfo(); DatabaseClass.AddCFile(temp); //GoogleScriptsClass.AddDataToSheet(temp); Files.Add(temp); }
public static void DeleteCFile(CFile file) { try { var connection = Connect(); if (connection != null) { string query = string.Format("DELETE FROM dbo.Friday WHERE ID={0}", file.ID); SqlCommand command = connection.CreateCommand(); command.CommandText = query; command.ExecuteNonQuery(); } } catch (Exception ex) { } }
public static void AddCFile(CFile file) { try { var connection = Connect(); if (connection != null) { string query = string.Format("INSERT INTO dbo.Friday (ID, SourceDir, ReleaseDir, RelatievePath, ProjectName) VALUES ({0},N'{1}',N'{2}',N'{3}',N'{4}')", file.ID, file.SourcePath, file.ReleasePath, file.Name, file.ProjectName); SqlCommand command = connection.CreateCommand(); command.CommandText = query; command.ExecuteNonQuery(); } } catch (Exception ex) { } }
public static void UpdateCFile(CFile file) { try { var connection = Connect(); if (connection != null) { string query = string.Format("UPDATE dbo.Friday SET ProjectName = N'{5}', SourceDir=N'{0}', ReleaseDir = N'{1}', RelatievePath = N'{2}' WHERE ID = {4}", file.SourcePath, file.ReleasePath, file.Name, file.SourceHash, file.ID, file.ProjectName); SqlCommand command = connection.CreateCommand(); command.CommandText = query; command.ExecuteNonQuery(); } } catch (Exception ex) { } }
public static void Refresh(CFile file) { file.RefreshProject(); UpdateFile(file); }
public static void UpdateFile(CFile file) { DatabaseClass.UpdateCFile(file); //GoogleScriptsClass.UpdateSheetsData(new CFile[] { file }); }