// update fields of specified record - all fields except lastSuccess (left alone) and nextExecTime (made null) which are updated later. // -1 for an int or DateTime field means make it null public static bool UpdateRecord(int TaskScheduleIid, TableData data) { bool Retval = true; string ScheduleString = MakeSchedString(data.TimeUnit, data.IntervalNum, data.StartTime, data.DayOfWeekMask, data.MonthOfYearMask, data.DayOfMonth, data.FirstLast); string sql = "UPDATE TASK_SCHEDULE SET taskId=" + data.TaskId + ", taskName=" + "'" + MainClass.FixStringForSingleQuote(data.TaskName) + "'" + ", argId=" + MainClass.IntToDBString(data.ArgId) + ", userName="******"'" + MainClass.FixStringForSingleQuote(data.UserName) + "'" + ", enabled=" + MainClass.BoolToInt(data.Enabled) + ", timeUnit=" + (int)data.TimeUnit + ", intervalNum=" + MainClass.IntToDBString(data.IntervalNum) + ", startTime=" + MainClass.DateTimeToTimestamp(data.StartTime) + ", endTime=" + MainClass.DateTimeToTimestamp(data.EndTime) + ", dayOfWeekMask=" + MainClass.IntToDBString(data.DayOfWeekMask) + ", monthOfYearMask=" + MainClass.IntToDBString(data.MonthOfYearMask) + ", dayOfMonth=" + MainClass.IntToDBString(data.DayOfMonth) + ", firstLast=" + MainClass.IntToDBString((int)data.FirstLast) + ", deleteWhenDone=" + MainClass.BoolToInt(data.DeleteWhenDone) + ", taskComment=" + "'" + MainClass.FixStringForSingleQuote(data.TaskComment) + "'" + ", execMissedTasks=" + MainClass.BoolToInt(data.ExecMissedTasks) + ", schedString=" + "'" + ScheduleString + "'" + ", nextExecTime=NULL" + " WHERE taskScheduleIid=" + TaskScheduleIid; Retval = MainClass.ExecuteSql(sql, true, TableName, "TaskSchedule", "UpdateRecord"); return(Retval); }
public static bool UpdateDefaultDomain(int domainIid, bool defaultFlag) { bool retVal = false; string SqlStatement = "Update USER_DOMAINS Set IsDefault = " + MainClass.BoolToInt(defaultFlag) + "where DomainIid = " + domainIid; retVal = MainClass.ExecuteSql(SqlStatement, true, TableName, ModuleName, "UpdateDefault"); return(retVal); }
// update enabled field of specified record public static bool UpdateEnabled(int Iid, bool bEnabled) { bool Retval = true; int nEnabled = MainClass.BoolToInt(bEnabled); string sql = "UPDATE TASK_SCHEDULE SET ENABLED = " + nEnabled + " WHERE taskScheduleIid = " + Iid; Retval = MainClass.ExecuteSql(sql, true, TableName, "TaskSchedule", "UpdateEnabled"); return(Retval); }
public static bool InsertRecord(TableData data, out int newId) { bool retVal = false; string SqlStatement = "INSERT INTO USER_DOMAINS (DomainName, SystemAccountName, DataBlock, CreatorID, IsDefault) VALUES (" + "'" + MainClass.FixStringForSingleQuote(data.domainName) + "', " + "'" + MainClass.FixStringForSingleQuote(data.systemAccountName) + "', " + "'" + MainClass.FixStringForSingleQuote(data.encryptedBlock) + "', " + "'" + MainClass.FixStringForSingleQuote(data.creatorId) + "', " + MainClass.BoolToInt(data.isDefault) + ")"; retVal = MainClass.ExecuteSql(SqlStatement, true, TableName, ModuleName, "InsertRecord", out newId); return(retVal); }
public static bool UpdateDomain(TableData data, int domainIid) { bool retVal = false; string SqlStatement = string.Format("Update USER_DOMAINS Set DomainName = ?, SystemAccountName = ?, DataBlock = ?, CreatorID = ?, IsDefault = ? where DomainIid = {0}", domainIid); retVal = MainClass.ExecuteSql(SqlStatement, false, new SAParameter("", MainClass.FixStringForSingleQuote(data.domainName)), new SAParameter("", MainClass.FixStringForSingleQuote(data.systemAccountName)), new SAParameter("", MainClass.FixStringForSingleQuote(data.encryptedBlock)), new SAParameter("", MainClass.FixStringForSingleQuote(data.creatorId)), new SAParameter("", MainClass.BoolToInt(data.isDefault))); return(retVal); }
// insert record - all fields except lastSuccess and nextExecTime which are updated later. // MakeASchedString - if true, generate a string for the SchedString field. If false, use the schedString argument for the field. // -1 for an int arg means that DB field should be NULL // DateTime.MinTime for a DateTime arg means that DB field should be NULL // OUTPUT: NewIid - IID of inserted record public static bool InsertRecord(bool MakeASchedString, TableData data, out int NewIid) { bool RetVal = false; string FieldString = "taskId, taskName, argId, userName, enabled, timeUnit, intervalNum, startTime, endTime, dayOfWeekMask, monthOfYearMask, dayOfMonth, firstLast, deleteWhenDone, taskComment, execMissedTasks, schedString"; string ValueString; string ScheduleString; NewIid = -1; ValueString = MainClass.IntToDBString(data.TaskId) + ", "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.TaskName) + "', "; ValueString += MainClass.IntToDBString(data.ArgId) + ", "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.UserName) + "', "; ValueString += "'" + MainClass.BoolToInt(data.Enabled) + "', "; ValueString += MainClass.IntToDBString((int)data.TimeUnit) + ", "; ValueString += MainClass.IntToDBString(data.IntervalNum) + ", "; ValueString += MainClass.DateTimeToTimestamp(data.StartTime) + ", "; ValueString += MainClass.DateTimeToTimestamp(data.EndTime) + ", "; ValueString += MainClass.IntToDBString(data.DayOfWeekMask) + ", "; ValueString += MainClass.IntToDBString(data.MonthOfYearMask) + ", "; ValueString += MainClass.IntToDBString(data.DayOfMonth) + ", "; ValueString += MainClass.IntToDBString((int)data.FirstLast) + ", "; ValueString += MainClass.BoolToInt(data.DeleteWhenDone) + ", "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.TaskComment) + "', "; ValueString += MainClass.BoolToInt(data.ExecMissedTasks) + ", "; if (MakeASchedString) { ScheduleString = MakeSchedString(data.TimeUnit, data.IntervalNum, data.StartTime, data.DayOfWeekMask, data.MonthOfYearMask, data.DayOfMonth, data.FirstLast); } else { ScheduleString = data.SchedString; } ValueString += "'" + ScheduleString + "'"; string strSqlStatement = "INSERT INTO TASK_SCHEDULE (" + FieldString + ") VALUES (" + ValueString + ")"; RetVal = MainClass.ExecuteSql(strSqlStatement, true, TableName, "TaskSchedule", "InsertRec", out NewIid); return(RetVal); }
// insert record // -1 for an int or enum arg means that DB field should be NULL // OUTPUT: NewPathId - pathId of inserted record public static bool InsertRecord(TableData data, out int NewPathId) { bool RetVal = false; string FieldString = ""; string ValueString = ""; NewPathId = -1; if (data.PathId != -1) { FieldString += "pathId, "; ValueString += "'" + data.PathId + "', "; } FieldString += "dirDescription, "; ValueString += "'" + data.Directory + "', "; FieldString += "dirPath, "; ValueString += "'" + data.Path + "', "; FieldString += "isBatch, "; ValueString += "'" + MainClass.BoolToInt(data.IsBatch) + "', "; if (data.ParentId != -1) { FieldString += "parentId, "; ValueString += "'" + data.ParentId + "', "; } FieldString += "purge, "; ValueString += "'" + MainClass.BoolToInt(data.Purge) + "', "; FieldString += "isNetworkDrive"; ValueString += "'" + MainClass.BoolToInt(data.IsNetwork) + "'"; string strSqlStatement = "INSERT INTO DIR_PATH_TREE (" + FieldString + ") VALUES (" + ValueString + ")"; RetVal = MainClass.ExecuteSql(strSqlStatement, true, TableName, "DirPathTree", "InsertRec", out NewPathId); return(RetVal); }
// insert record // -1 for an int or enum arg means that DB field should be NULL // DateTime.MinTime for a DateTime arg means that DB field should be NULL // OUTPUT: NewIid - IID of inserted record public static bool InsertRec(TableData data, out int NewIid) { bool RetVal = false; string FieldString = ""; string ValueString = ""; string tempString = ""; NewIid = -1; if (data.ReportIid != -1) { FieldString += "ReportIid, "; ValueString += "'" + data.ReportIid + "', "; } FieldString += "reportFile, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.ReportFile) + "', "; FieldString += "recordFilter, "; tempString = MainClass.FixStringForSingleQuote(data.RecordFilter); ValueString += "'" + tempString + "', "; if (data.NumCopy != -1) { FieldString += "numCopy, "; ValueString += "'" + data.NumCopy + "', "; } FieldString += "sendMessage, "; ValueString += "'" + MainClass.BoolToInt(data.SendMessage) + "', "; FieldString += "dateFrom, "; ValueString += "'" + data.DateFrom + "', "; FieldString += "dateTo, "; ValueString += "'" + data.DateTo + "', "; FieldString += "dateRange, "; ValueString += "'" + data.DateRange + "', "; if (data.GroupDirection1 != SortDirectionEnum.NullValue) { FieldString += "groupDirection1, "; ValueString += "'" + (int)data.GroupDirection1 + "', "; } if (data.GroupDirection2 != SortDirectionEnum.NullValue) { FieldString += "groupDirection2, "; ValueString += "'" + (int)data.GroupDirection2 + "', "; } if (data.GroupDirection3 != SortDirectionEnum.NullValue) { FieldString += "groupDirection3, "; ValueString += "'" + (int)data.GroupDirection3 + "', "; } FieldString += "groupHeader1, "; ValueString += "'" + data.GroupHeader1 + "', "; FieldString += "groupHeader2, "; ValueString += "'" + data.GroupHeader2 + "', "; FieldString += "groupHeader3, "; ValueString += "'" + data.GroupHeader3 + "', "; FieldString += "groupTable1, "; ValueString += "'" + data.GroupTable1 + "', "; FieldString += "groupTable2, "; ValueString += "'" + data.GroupTable2 + "', "; FieldString += "groupTable3, "; ValueString += "'" + data.GroupTable3 + "', "; if (data.SortDirection1 != SortDirectionEnum.NullValue) { FieldString += "sortDirection1, "; ValueString += "'" + (int)data.SortDirection1 + "', "; } if (data.SortDirection2 != SortDirectionEnum.NullValue) { FieldString += "sortDirection2, "; ValueString += "'" + (int)data.SortDirection2 + "', "; } if (data.SortDirection3 != SortDirectionEnum.NullValue) { FieldString += "sortDirection3, "; ValueString += "'" + (int)data.SortDirection3 + "', "; } FieldString += "sortHeader1, "; ValueString += "'" + data.SortHeader1 + "', "; FieldString += "sortHeader2, "; ValueString += "'" + data.SortHeader2 + "', "; FieldString += "sortHeader3, "; ValueString += "'" + data.SortHeader3 + "', "; FieldString += "sortTable1, "; ValueString += "'" + data.SortTable1 + "', "; FieldString += "sortTable2, "; ValueString += "'" + data.SortTable2 + "', "; FieldString += "sortTable3, "; ValueString += "'" + data.SortTable3 + "', "; FieldString += "filterText1, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.FilterText1) + "', "; FieldString += "filterText2, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.FilterText2) + "', "; FieldString += "filterText3, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.FilterText3) + "', "; FieldString += "filterText4, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.FilterText4) + "', "; FieldString += "filterText5, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.FilterText5) + "', "; FieldString += "filterText6, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.FilterText6) + "', "; FieldString += "filterText7, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.FilterText7) + "', "; FieldString += "filterText8, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.FilterText8) + "', "; FieldString += "filterText9, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.FilterText9) + "', "; FieldString += "filterText10, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.FilterText10) + "', "; FieldString += "filterText11, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.FilterText11) + "', "; FieldString += "filterText12, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.FilterText12) + "', "; FieldString += "filterText13, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.FilterText13) + "', "; FieldString += "filterText14, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.FilterText14) + "', "; FieldString += "filterText15, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.FilterText15) + "', "; FieldString += "batchName, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.BatchName) + "', "; FieldString += "reportDelete"; ValueString += "'" + MainClass.BoolToInt(data.ReportDelete) + "'"; string strSqlStatement = "INSERT INTO REPORTS (" + FieldString + ") VALUES (" + ValueString + ")"; RetVal = MainClass.ExecuteSql(strSqlStatement, true, TableName, "Reports", "InsertRec", out NewIid); return(RetVal); }
// update fields of specified record public static bool UpdateRecord(TableData data) { bool Retval = true; string sql = "UPDATE " + TableName + " SET "; sql += "reportFile=" + "'" + MainClass.FixStringForSingleQuote(data.ReportFile) + "'"; if ((int)data.ReportType != -1) { sql += ", reportType=" + "'" + (int)data.ReportType + "'"; } if ((int)data.PrintStatus != -1) { sql += ", printStatus=" + (int)data.PrintStatus; } sql += ", PrintPathIid=" + (int)data.PrintPathIid; if (data.NumCopy != -1) { sql += ", numCopy=" + "'" + data.NumCopy + "'"; } sql += ", sendMessage=" + "'" + MainClass.BoolToInt(data.SendMessage) + "'"; sql += ", graph=" + "'" + MainClass.BoolToInt(data.Graph) + "'"; if (data.GroupDirection1 != SortDirectionEnum.NullValue) { sql += ", groupDirection1=" + (int)data.GroupDirection1; } if (data.GroupDirection2 != SortDirectionEnum.NullValue) { sql += ", groupDirection2=" + (int)data.GroupDirection2; } if (data.GroupDirection3 != SortDirectionEnum.NullValue) { sql += ", groupDirection3=" + (int)data.GroupDirection1; } sql += ", groupHeader1='" + MainClass.FixStringForSingleQuote(data.GroupHeader1) + "'"; sql += ", groupHeader2='" + MainClass.FixStringForSingleQuote(data.GroupHeader2) + "'"; sql += ", groupHeader3='" + MainClass.FixStringForSingleQuote(data.GroupHeader3) + "'"; sql += ", groupTable1='" + MainClass.FixStringForSingleQuote(data.GroupTable1) + "'"; sql += ", groupTable2='" + MainClass.FixStringForSingleQuote(data.GroupTable2) + "'"; sql += ", groupTable3='" + MainClass.FixStringForSingleQuote(data.GroupTable3) + "'"; if (data.SortDirection1 != SortDirectionEnum.NullValue) { sql += ", sortDirection1=" + (int)data.SortDirection1; } if (data.SortDirection2 != SortDirectionEnum.NullValue) { sql += ", sortDirection2=" + (int)data.SortDirection2; } if (data.SortDirection3 != SortDirectionEnum.NullValue) { sql += ", sortDirection3=" + (int)data.SortDirection3; } sql += ", sortHeader1='" + MainClass.FixStringForSingleQuote(data.SortHeader1) + "'"; sql += ", sortHeader2='" + MainClass.FixStringForSingleQuote(data.SortHeader2) + "'"; sql += ", sortHeader3='" + MainClass.FixStringForSingleQuote(data.SortHeader3) + "'"; sql += ", sortTable1='" + MainClass.FixStringForSingleQuote(data.SortTable1) + "'"; sql += ", sortTable2='" + MainClass.FixStringForSingleQuote(data.SortTable2) + "'"; sql += ", sortTable3='" + MainClass.FixStringForSingleQuote(data.SortTable3) + "'"; if (data.BulletinNumber != -1) { sql += ", bulletinNumber=" + data.BulletinNumber; } sql += ", batchName=" + "'" + MainClass.FixStringForSingleQuote(data.BatchName) + "'";; sql += ", batchUser="******"'" + data.BatchUser + "'";; if (data.BatchPathId != -1) { sql += ", batchPathId=" + data.BatchPathId; } if (data.EmailId != -1) { sql += ", emailId=" + data.EmailId; } if (data.OutputType != OutputEnum.NullValue) { sql += ", outputType=" + (int)data.OutputType; } if (data.DirPathId != -1) { sql += ", dirPathId=" + data.DirPathId; } sql += ", completedReportFile=" + "'" + MainClass.FixStringForSingleQuote(data.CompletedReportFile) + "'"; if ((int)data.CopyStatus != -1) { sql += ", copyStatus=" + (int)data.CopyStatus; } if ((int)data.EmailStatus != -1) { sql += ", emailStatus=" + (int)data.EmailStatus; } if ((int)data.RunStatus != -1) { sql += ", runStatus=" + (int)data.RunStatus; } sql += ", eMailType=" + data.EmailType; sql += " WHERE reportIid=" + data.ReportIid; Retval = MainClass.ExecuteSql(sql, true, TableName, "Report", "UpdateRecord"); return(Retval); }
// insert record // -1 for an int or enum arg means that DB field should be NULL // DateTime.MinTime for a DateTime arg means that DB field should be NULL // OUTPUT: NewIid - IID of inserted record public static bool InsertRecord(TableData data, out int NewIid) { bool RetVal = false; string FieldString = ""; string ValueString = ""; NewIid = -1; if (data.ReportIid != -1) { FieldString += "ReportIid, "; ValueString += data.ReportIid + ", "; } FieldString += "reportFile, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.ReportFile) + "', "; if ((int)data.ReportType != -1) { FieldString += "reportType, "; ValueString += (int)data.ReportType + ", "; } if ((int)data.PrintStatus != -1) { FieldString += "printStatus, "; ValueString += (int)data.PrintStatus + ", "; } FieldString += "PrintPathIid, "; ValueString += (int)data.PrintPathIid + ", "; if (data.NumCopy != -1) { FieldString += "numCopy, "; ValueString += data.NumCopy + ", "; } FieldString += "sendMessage, "; ValueString += MainClass.BoolToInt(data.SendMessage) + ", "; FieldString += "graph, "; ValueString += MainClass.BoolToInt(data.Graph) + ", "; if (data.GroupDirection1 != SortDirectionEnum.NullValue) { FieldString += "groupDirection1, "; ValueString += (int)data.GroupDirection1 + ", "; } if (data.GroupDirection2 != SortDirectionEnum.NullValue) { FieldString += "groupDirection2, "; ValueString += (int)data.GroupDirection2 + ", "; } if (data.GroupDirection3 != SortDirectionEnum.NullValue) { FieldString += "groupDirection3, "; ValueString += (int)data.GroupDirection3 + ", "; } FieldString += "groupHeader1, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.GroupHeader1) + "', "; FieldString += "groupHeader2, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.GroupHeader2) + "', "; FieldString += "groupHeader3, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.GroupHeader3) + "', "; FieldString += "groupTable1, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.GroupTable1) + "', "; FieldString += "groupTable2, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.GroupTable2) + "', "; FieldString += "groupTable3, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.GroupTable3) + "', "; if (data.SortDirection1 != SortDirectionEnum.NullValue) { FieldString += "sortDirection1, "; ValueString += (int)data.SortDirection1 + ", "; } if (data.SortDirection2 != SortDirectionEnum.NullValue) { FieldString += "sortDirection2, "; ValueString += (int)data.SortDirection2 + ", "; } if (data.SortDirection3 != SortDirectionEnum.NullValue) { FieldString += "sortDirection3, "; ValueString += (int)data.SortDirection3 + ", "; } FieldString += "sortHeader1, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.SortHeader1) + "', "; FieldString += "sortHeader2, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.SortHeader2) + "', "; FieldString += "sortHeader3, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.SortHeader3) + "', "; FieldString += "sortTable1, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.SortTable1) + "', "; FieldString += "sortTable2, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.SortTable2) + "', "; FieldString += "sortTable3, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.SortTable3) + "', "; if (data.BulletinNumber != -1) { FieldString += "bulletinNumber, "; ValueString += data.BulletinNumber + ", "; } FieldString += "batchName, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.BatchName) + "', "; FieldString += "batchUser, "; ValueString += "'" + data.BatchUser + "', "; if (data.BatchPathId != -1) { FieldString += "batchPathId, "; ValueString += (int)data.BatchPathId + ", "; } if (data.EmailId != -1) { FieldString += "emailId, "; ValueString += (int)data.EmailId + ", "; } if (data.OutputType != OutputEnum.NullValue) { FieldString += "outputType, "; ValueString += (int)data.OutputType + ", "; } if (data.DirPathId != -1) { FieldString += "dirPathId, "; ValueString += data.DirPathId + ", "; } FieldString += "completedReportFile, "; ValueString += "'" + MainClass.FixStringForSingleQuote(data.CompletedReportFile) + "', "; if ((int)data.CopyStatus != -1) { FieldString += "copyStatus, "; ValueString += (int)data.CopyStatus + ", "; } if ((int)data.EmailStatus != -1) { FieldString += "emailStatus, "; ValueString += (int)data.EmailStatus + ", "; } if ((int)data.RunStatus != -1) { FieldString += "runStatus, "; ValueString += (int)data.RunStatus + ", "; } FieldString += "eMailType, "; ValueString += (int)data.EmailType + ""; string strSqlStatement = "INSERT INTO REPORT (" + FieldString + ") VALUES (" + ValueString + ")"; RetVal = MainClass.ExecuteSql(strSqlStatement, true, TableName, "Report", "InsertRec", out NewIid); return(RetVal); }