protected override void OnStop() { var serviceStopTime = new ServiceStopTime { ScheduleEndTime = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture) }; try { var schedulerExportPath = GlobalAppSettings.GetSchedulerExportPath(); if (Directory.Exists(schedulerExportPath) == false) { Directory.CreateDirectory(schedulerExportPath); } new SchedulerJob().SerializeTime(serviceStopTime, GlobalAppSettings.GetSchedulerExportPath() + "config.xml"); LogExtension.LogInfo("Service stopped", MethodBase.GetCurrentMethod()); } catch (Exception e) { LogExtension.LogError("Exception is thrown while stopping service", e, MethodBase.GetCurrentMethod()); } finally { base.OnStop(); } }
public Result ExecuteReaderQuery(string query, string connectionString) { var result = new Result(); if (!string.IsNullOrWhiteSpace(connectionString)) { var connection = new SqlCeConnection(connectionString); var adapter = new SqlCeDataAdapter(query, connection); try { adapter.Fill(result.DataTable); } catch (Exception e) { result.Status = false; result.Exception = e; LogExtension.LogError("Exception on ExecuteReaderQuery", e, MethodBase.GetCurrentMethod(), " Query - " + query + " ConnectionString - " + connection); } finally { adapter.Dispose(); connection.Close(); } } else { var exception = new Exception("Invalid Connection string"); result.Status = false; result.Exception = exception; throw exception; } result.Status = true; return(result); }
public bool UpdateSystemSetting(string value, string whereConditionColumnname) { try { var whereColumns = new List <ConditionColumn> { new ConditionColumn { ColumnName = GlobalAppSettings.DbColumns.DB_SystemSettings.Key, Condition = Conditions.LIKE, Value = whereConditionColumnname } }; var updateColumns = new List <UpdateColumn> { new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_SystemSettings.Value, Value = value } }; var result = _dataProvider.ExecuteNonQuery( _queryBuilder.UpdateRowInTable(GlobalAppSettings.DbColumns.DB_SystemSettings.DB_TableName, updateColumns, whereColumns)); return(result.Status); } catch (Exception e) { LogExtension.LogError("Error while updating system settings", e, MethodBase.GetCurrentMethod(), "WhereConditionColumnname - " + whereConditionColumnname + " Value - " + value); return(false); } }
public bool SetData(string key, string itemId, ItemInfo itemData, out string errMsg) { errMsg = string.Empty; try { if (itemData.Data != null) { File.WriteAllBytes(this.GetFilePath(itemId, key), itemData.Data); } else if (itemData.PostedFile != null) { var fileName = itemId; if (string.IsNullOrEmpty(itemId)) { fileName = Path.GetFileName(itemData.PostedFile.FileName); } itemData.PostedFile.SaveAs(this.GetFilePath(fileName, key)); } } catch (Exception ex) { LogExtension.LogError(ex.Message, ex, MethodBase.GetCurrentMethod()); errMsg = ex.Message; return(false); } return(true); }
public bool DeleteUserFromGroup(int userId, int groupId) { try { var whereColumns = new List <ConditionColumn> { new ConditionColumn { ColumnName = GlobalAppSettings.DbColumns.DB_UserGroup.UserId, Condition = Conditions.Equals, Value = userId }, new ConditionColumn { ColumnName = GlobalAppSettings.DbColumns.DB_UserGroup.GroupId, Condition = Conditions.Equals, LogicalOperator = LogicalOperators.AND, Value = groupId } }; var result = _dataProvider.ExecuteNonQuery( _queryBuilder.DeleteRowFromTable(GlobalAppSettings.DbColumns.DB_UserGroup.DB_TableName, whereColumns)); return(result.Status); } catch (Exception e) { LogExtension.LogError("Error while removing user from group", e, MethodBase.GetCurrentMethod(), " UserId - " + userId + " GroupId - " + groupId); return(false); } }
public int?AddGroup(Group group) { try { var values = new Dictionary <string, object> { { GlobalAppSettings.DbColumns.DB_Group.Name, group.GroupName }, { GlobalAppSettings.DbColumns.DB_Group.Description, group.GroupDescription }, { GlobalAppSettings.DbColumns.DB_Group.Color, group.GroupColor }, { GlobalAppSettings.DbColumns.DB_Group.IsActive, true }, { GlobalAppSettings.DbColumns.DB_Group.ModifiedDate, DateTime.UtcNow.ToString(GlobalAppSettings.GetDateTimeFormat()) } }; var output = new List <string> { GlobalAppSettings.DbColumns.DB_Group.GroupId }; var result = _dataProvider.ExecuteScalarQuery(_queryBuilder.AddToTable( GlobalAppSettings.DbColumns.DB_Group.DB_TableName, values, output)); if (result.Status) { return(Convert.ToInt32(result.ReturnValue)); } return(null); } catch (Exception e) { LogExtension.LogError("Error while adding group", e, MethodBase.GetCurrentMethod(), " GroupName - " + group.GroupName + " GroupDescription - " + group.GroupDescription + " GroupColor - " + group.GroupColor); return(null); } }
public Result ExecuteNonQuery(string query, string connectionString) { var result = new Result(); result.DataTable = new DataTable(); if (!string.IsNullOrWhiteSpace(connectionString)) { var connection = new SqlConnection(connectionString); var command = new SqlCommand(query, connection); try { connection.Open(); result.ReturnValue = command.ExecuteNonQuery(); } catch (Exception e) { result.Status = false; result.Exception = e; try { var userOptions = ExecuteReaderQuery("dbcc useroptions"); var dbFormat = userOptions.DataTable.AsEnumerable() .Select(a => new { Key = a.Field <string>("Set Option"), Value = a.Field <string>("Value") }).ToDictionary(a => a.Key, a => a.Value); var dbOptions = string.Empty; foreach (var data in dbFormat) { dbOptions = dbOptions + data.Key + ":" + data.Value + ";"; } LogExtension.LogError("Exception on ExecuteNonQuery", e, MethodBase.GetCurrentMethod(), "Query - " + query + " ConnectionString - " + connection + "\nSql server user options:" + dbOptions); } catch (Exception ex) { LogExtension.LogError("Exception on ExecuteNonQuery - Error in getting user options", ex, MethodBase.GetCurrentMethod()); return(result); } } finally { connection.Close(); command.Dispose(); } } else { var exception = new Exception("Invalid Connection string"); result.Status = false; result.Exception = exception; throw exception; } result.Status = true; return(result); }
private bool CheckDatabaseExists(string connectionString, string databaseName) { LogExtension.LogInfo("Testing database existance of SQL server", MethodBase.GetCurrentMethod()); bool result; try { var tmpConn = new SqlConnection(connectionString); var sqlCreateDbQuery = string.Format("SELECT database_id FROM sys.databases WHERE Name = '{0}'", databaseName); using (tmpConn) { using (var sqlCmd = new SqlCommand(sqlCreateDbQuery, tmpConn)) { tmpConn.Open(); var databaseId = (int)sqlCmd.ExecuteScalar(); tmpConn.Close(); result = (databaseId > 0); } } } catch (Exception ex) { LogExtension.LogError("Error in checking whether a database exists", ex, MethodBase.GetCurrentMethod()); result = false; } LogExtension.LogInfo("Is database with the name exists?:" + result.ToString(), MethodBase.GetCurrentMethod()); return(result); }
public bool DeleteGroup(int groupId) { try { var whereColumns = new List <ConditionColumn> { new ConditionColumn { ColumnName = GlobalAppSettings.DbColumns.DB_Group.GroupId, Condition = Conditions.Equals, Value = groupId } }; var updateColumns = new List <UpdateColumn> { new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_Group.IsActive, Value = 0 } }; var result = _dataProvider.ExecuteNonQuery(_queryBuilder.UpdateRowInTable( GlobalAppSettings.DbColumns.DB_Group.DB_TableName, updateColumns, whereColumns)); return(result.Status); } catch (Exception e) { LogExtension.LogError("Error while deleting group", e, MethodBase.GetCurrentMethod(), " GroupId - " + groupId); return(false); } }
public bool AddUserInGroup(int userId, int groupId) { try { var values = new Dictionary <string, object> { { GlobalAppSettings.DbColumns.DB_UserGroup.GroupId, groupId }, { GlobalAppSettings.DbColumns.DB_UserGroup.UserId, userId }, { GlobalAppSettings.DbColumns.DB_UserGroup.IsActive, true }, { GlobalAppSettings.DbColumns.DB_UserGroup.ModifiedDate, DateTime.UtcNow.ToString(GlobalAppSettings.GetDateTimeFormat()) } }; var result = _dataProvider.ExecuteNonQuery( _queryBuilder.AddToTable(GlobalAppSettings.DbColumns.DB_UserGroup.DB_TableName, values)); return(result.Status); } catch (Exception e) { LogExtension.LogError("Error while add user in group", e, MethodBase.GetCurrentMethod(), " UserId - " + userId + " GroupId - " + groupId); return(false); } }
public static bool RunScript(string scriptName, string version, string installedVersion) { try { if (String.IsNullOrWhiteSpace(scriptName)) { return(true); } var scriptFileInfo = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + WebConfigurationManager.AppSettings["SystemConfigurationPath"] + "\\VersionedScripts\\" + scriptName); var script = scriptFileInfo.OpenText().ReadToEnd(); if (GlobalAppSettings.DbSupport == DataBaseType.MSSQLCE) { var splitter = new[] { ";" }; var commandTexts = script.Split(splitter, StringSplitOptions.RemoveEmptyEntries); foreach (var commandText in commandTexts) { GlobalAppSettings.DataProvider.ExecuteNonQuery(commandText); } } else { GlobalAppSettings.DataProvider.ExecuteNonQuery(script); } UpdateLaterversionToServerVersion(version); return(true); } catch (Exception ex) { LogExtension.LogError("Error while running script", ex, MethodBase.GetCurrentMethod()); return(false); } }
/// <summary> /// If schedule start time is equal to UTC time then the current datetime value is skipped and the next recurrence is calculated. /// </summary> /// <param name="currentScheduleDate"></param> /// <param name="recurrenceInfo"></param> /// <returns></returns> public DateTime?GetNextScheduleDate(DateTime currentScheduleDate, string recurrenceInfo) { LogExtension.LogInfo("Next schedule date calculation started", MethodBase.GetCurrentMethod(), " CurrentScheduleDate - " + currentScheduleDate + " recurrenceInfo - " + recurrenceInfo); DateTime?nextScheduleDate = new DateTime(); var scheduleInfo = ScheduleHelper.XMLDeserializer(recurrenceInfo); try { if (scheduleInfo != null) { switch (scheduleInfo.Type) { case TaskScheduleType.Daily: var daily = new DailyRecurrence(); nextScheduleDate = daily.GetNextDailyScheduleDate(scheduleInfo, currentScheduleDate); break; case TaskScheduleType.DailyWeekDay: var dailyWeekDay = new DailyRecurrence(); nextScheduleDate = dailyWeekDay.GetNextDailyWeekDayScheduleDate(scheduleInfo, currentScheduleDate); break; case TaskScheduleType.Weekly: var weekly = new WeeklyRecurrence(); nextScheduleDate = weekly.GetNextWeeklyScheduleDate(scheduleInfo, currentScheduleDate); break; case TaskScheduleType.Monthly: var monthly = new MonthlyRecurrence(); nextScheduleDate = monthly.GetNextMonthlyScheduleDate(scheduleInfo, currentScheduleDate); break; case TaskScheduleType.MonthlyDOW: var monthlyDOW = new MonthlyRecurrence(); nextScheduleDate = monthlyDOW.GetNextMonthlyDOWScheduleDate(scheduleInfo, currentScheduleDate); break; case TaskScheduleType.Yearly: var yearly = new YearlyRecurrence(); nextScheduleDate = yearly.GetNextYearlyScheduleDate(scheduleInfo, currentScheduleDate); break; case TaskScheduleType.YearlyDOW: var yearlyDOW = new YearlyRecurrence(); nextScheduleDate = yearlyDOW.GetNextYearlyDOWScheduleDate(scheduleInfo, currentScheduleDate); break; } } } catch (Exception e) { LogExtension.LogError("Exception is thrown in next date calculation", e, MethodBase.GetCurrentMethod(), " CurrentScheduleDate - " + currentScheduleDate + " recurrenceInfo - " + recurrenceInfo + " ScheduleInfoType - " + scheduleInfo.Type + " NextScheduleDate - " + nextScheduleDate); return(nextScheduleDate); } LogExtension.LogInfo("Next schedule date calculation successfull", MethodBase.GetCurrentMethod(), " CurrentScheduleDate - " + currentScheduleDate + " recurrenceInfo - " + recurrenceInfo + " ScheduleInfoType - " + scheduleInfo.Type + " NextScheduleDate - " + nextScheduleDate); return(nextScheduleDate); }
public static void ExtractZipToDirectory(string sourceFilePath, string destinationDirectoryPath) { sourceFilePath = sourceFilePath.Replace("\\\\", "\\"); destinationDirectoryPath = destinationDirectoryPath.Replace("\\\\", "\\"); try { ZipFile.ExtractToDirectory(sourceFilePath, destinationDirectoryPath); } catch (Exception exception) { LogExtension.LogError("Unable to extract zip to directory", exception, MethodBase.GetCurrentMethod(), " SourceFilePath - " + sourceFilePath + " DestinationDirectoryPath - " + destinationDirectoryPath); } }
private List <string> GetDataExtension(string ExtAssemblies) { var extensions = !string.IsNullOrEmpty(ExtAssemblies) ? ExtAssemblies : string.Empty; try { return(new List <string>(extensions.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))); } catch (Exception ex) { LogExtension.LogError("Failed to Load Data Extension", ex, MethodBase.GetCurrentMethod()); } return(null); }
private List <string> GetDataExtension() { var extensions = !string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["ExtAssemblies"]) ? System.Configuration.ConfigurationManager.AppSettings["ExtAssemblies"] : string.Empty; try { return(new List <string>(extensions.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))); } catch (Exception ex) { LogExtension.LogError("Failed to Load Data Extension", ex, MethodBase.GetCurrentMethod()); } return(null); }
public static void CreateZipFromDirectory(string sourceDirectoryPath, string destinationFilePath) { sourceDirectoryPath = sourceDirectoryPath.Replace("\\\\", "\\"); destinationFilePath = destinationFilePath.Replace("\\\\", "\\"); try { ZipFile.CreateFromDirectory(sourceDirectoryPath, destinationFilePath, CompressionLevel.Fastest, false); } catch (Exception exception) { LogExtension.LogError("Unable to create zip from directory", exception, MethodBase.GetCurrentMethod(), " SourceDirectoryPath - " + sourceDirectoryPath + " DestinationFilePath - " + destinationFilePath); } }
public ResourceInfo GetData(string key, string itemId) { var resource = new ResourceInfo(); try { resource.Data = File.ReadAllBytes(this.GetFilePath(itemId, key)); } catch (Exception ex) { LogExtension.LogError(ex.Message, ex, MethodBase.GetCurrentMethod()); resource.ErrorMessage = ex.Message; } return(resource); }
public static void UpdateLaterversionToServerVersion(string version) { try { var query = new StringBuilder(); var installedVersion = GetReportServerVersionOfInstalledMachine(); if (String.IsNullOrWhiteSpace(installedVersion)) { return; } if (installedVersion == "1.1.0.24") { var values = new Dictionary <string, object> { { GlobalAppSettings.DbColumns.DB_ApplicationVersion.VersionNumber, version } }; query.Append(GlobalAppSettings.QueryBuilder.AddToTable(GlobalAppSettings.DbColumns.DB_ApplicationVersion.DB_TableName, values)); } else { var updateColumns = new List <UpdateColumn> { new UpdateColumn { ColumnName = GlobalAppSettings.DbColumns.DB_ApplicationVersion.VersionNumber, Value = version } }; var whereColumns = new List <ConditionColumn> { new ConditionColumn { ColumnName = GlobalAppSettings.DbColumns.DB_ApplicationVersion.VersionNumber, Condition = Conditions.Equals, Value = installedVersion } }; query.Append(GlobalAppSettings.QueryBuilder.UpdateRowInTable(GlobalAppSettings.DbColumns.DB_ApplicationVersion.DB_TableName, updateColumns, whereColumns)); } GlobalAppSettings.DataProvider.ExecuteNonQuery(query.ToString()); } catch (Exception ex) { LogExtension.LogError("Error while updatig the version to server version table", ex, MethodBase.GetCurrentMethod()); } }
public DataResponse IsUserExistInGroup(int userId, int groupId) { var dataResponse = new DataResponse(); try { var whereColumns = new List <ConditionColumn> { new ConditionColumn { ColumnName = GlobalAppSettings.DbColumns.DB_UserGroup.UserId, Condition = Conditions.Equals, Value = userId }, new ConditionColumn { ColumnName = GlobalAppSettings.DbColumns.DB_UserGroup.GroupId, Condition = Conditions.Equals, LogicalOperator = LogicalOperators.AND, Value = groupId }, new ConditionColumn { ColumnName = GlobalAppSettings.DbColumns.DB_UserGroup.IsActive, Condition = Conditions.Equals, LogicalOperator = LogicalOperators.AND, Value = true } }; var result = _dataProvider.ExecuteReaderQuery( _queryBuilder.SelectAllRecordsFromTable( GlobalAppSettings.DbColumns.DB_UserGroup.DB_TableName, whereColumns)); dataResponse.Success = result.Status; if (result.Status) { dataResponse.Value = (result.DataTable.Rows.Count != 0); } return(dataResponse); } catch (Exception e) { dataResponse.Success = false; LogExtension.LogError("Error while validating user existance in group", e, MethodBase.GetCurrentMethod(), " UserId - " + userId + " GroupId - " + groupId); return(dataResponse); } }
public void SerializeTime(ServiceStopTime serviceStopTime, string path) { try { var xmlserializer = new XmlSerializer(typeof(ServiceStopTime)); using (var writer = new StreamWriter(path)) { xmlserializer.Serialize(writer, serviceStopTime); writer.Close(); } } catch (Exception ex) { LogExtension.LogError("Exception while serializing service stop time", ex, MethodBase.GetCurrentMethod()); } }
public Group GetGroupById(int groupId) { var groupDetail = new Group(); try { var whereColumns = new List <ConditionColumn> { new ConditionColumn { ColumnName = GlobalAppSettings.DbColumns.DB_Group.GroupId, Condition = Conditions.Equals, Value = groupId }, new ConditionColumn { ColumnName = GlobalAppSettings.DbColumns.DB_Group.IsActive, Condition = Conditions.Equals, LogicalOperator = LogicalOperators.AND, Value = true } }; var result = _dataProvider.ExecuteReaderQuery( _queryBuilder.SelectAllRecordsFromTable(GlobalAppSettings.DbColumns.DB_Group.DB_TableName, whereColumns)); if (result.Status) { groupDetail = result.DataTable.AsEnumerable() .Select(row => new Group { GroupId = row.Field <int>(GlobalAppSettings.DbColumns.DB_Group.GroupId), GroupName = row.Field <string>(GlobalAppSettings.DbColumns.DB_Group.Name), GroupDescription = row.Field <string>(GlobalAppSettings.DbColumns.DB_Group.Description), GroupColor = row.Field <string>(GlobalAppSettings.DbColumns.DB_Group.Color) }).FirstOrDefault(); } return(groupDetail); } catch (Exception e) { LogExtension.LogError("Error while getting group details from groupid", e, MethodBase.GetCurrentMethod(), " GroupId - " + groupId + " GroupName - " + groupDetail.GroupName + " GroupDescription - " + groupDetail.GroupDescription + " GroupColor - " + groupDetail.GroupColor); return(groupDetail); } }
private List <string> GetDataExtension() { var extensions = !string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["ExtAssemblies"]) ? System.Configuration.ConfigurationManager.AppSettings["ExtAssemblies"] : string.Empty; try { var ExtNames = new List <string>(extensions.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries)); List <string> ExtCollections = new List <string>(); ExtNames.ForEach(Extension => ExtCollections.Add(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "bin", Extension + ".dll"))); return(ExtCollections); } catch (Exception ex) { LogExtension.LogError("Failed to Load Data Extension", ex, MethodBase.GetCurrentMethod()); } return(null); }
private BoldReports.Web.MapSetting GetMapSettings() { try { string basePath = HttpContext.Current.Server.MapPath("~/Scripts"); return(new MapSetting() { ShapePath = basePath + "\\ShapeData\\", MapShapes = JsonConvert.DeserializeObject <List <MapShape> >(System.IO.File.ReadAllText(basePath + "\\ShapeData\\mapshapes.txt")) }); } catch (Exception ex) { LogExtension.LogError("Failed to Load Map Settings", ex, MethodBase.GetCurrentMethod()); } return(null); }
public DataResponse IsActiveGroup(int groupId) { var dataResponse = new DataResponse(); try { var whereColumns = new List <ConditionColumn> { new ConditionColumn { ColumnName = GlobalAppSettings.DbColumns.DB_Group.GroupId, Condition = Conditions.Equals, Value = groupId } }; var requiredColumns = new List <SelectedColumn> { new SelectedColumn { ColumnName = GlobalAppSettings.DbColumns.DB_Group.IsActive, } }; var result = _dataProvider.ExecuteReaderQuery( _queryBuilder.SelectRecordsFromTable(GlobalAppSettings.DbColumns.DB_Group.DB_TableName, requiredColumns, whereColumns)); dataResponse.Success = result.Status; if (result.Status) { dataResponse.Value = result.DataTable.AsEnumerable() .Select(s => s.Field <bool>(GlobalAppSettings.DbColumns.DB_Group.IsActive)) .FirstOrDefault(); } return(dataResponse); } catch (Exception e) { dataResponse.Success = false; LogExtension.LogError("Error while validating group", e, MethodBase.GetCurrentMethod(), " GroupId - " + groupId); return(dataResponse); } }
/// <summary> /// Get all the system setting properties from database. /// </summary> /// <returns></returns> public Result GetSystemSettings() { var result = new Result(); try { result = DataProvider.ExecuteReaderQuery( QueryBuilder.SelectAllRecordsFromTable(DbColumns.DB_SystemSettings.DB_TableName)); } catch (SqlException e) { LogExtension.LogError("Error while getting system settings properties", e, MethodBase.GetCurrentMethod()); return(result); } return(result); }
public List <Group> GetAllActiveGroups() { var result = new Result(); var groupList = new List <Group>(); try { var whereColumns = new List <ConditionColumn> { new ConditionColumn { ColumnName = GlobalAppSettings.DbColumns.DB_Group.IsActive, Condition = Conditions.Equals, Value = true } }; result = _dataProvider.ExecuteReaderQuery( _queryBuilder.SelectAllRecordsFromTable(GlobalAppSettings.DbColumns.DB_Group.DB_TableName, whereColumns)); if (result.Status) { groupList = result.DataTable.AsEnumerable() .Select(row => new Group { GroupId = row.Field <int>(GlobalAppSettings.DbColumns.DB_Group.GroupId), GroupName = row.Field <string>(GlobalAppSettings.DbColumns.DB_Group.Name), GroupDescription = row.Field <string>(GlobalAppSettings.DbColumns.DB_Group.Description), GroupColor = row.Field <string>(GlobalAppSettings.DbColumns.DB_Group.Color), CanDelete = (row.Field <int>(GlobalAppSettings.DbColumns.DB_Group.GroupId) == 1) ? false : true }).ToList(); } return(groupList); } catch (Exception e) { LogExtension.LogError("Error while getting group list", e, MethodBase.GetCurrentMethod(), " Status - " + result.Status); return(groupList); } }
public static void CreateZipFromFile(string sourceFilePath, string outputFilePath) { sourceFilePath = sourceFilePath.Replace("\\\\", "\\"); outputFilePath = outputFilePath.Replace("\\\\", "\\"); try { using (ZipArchive zipArchive = ZipFile.Open(outputFilePath, ZipArchiveMode.Create)) { zipArchive.CreateEntryFromFile(sourceFilePath, new FileInfo(sourceFilePath).Name, CompressionLevel.Fastest); } } catch (Exception exception) { LogExtension.LogError("Unable to create zip from file", exception, MethodBase.GetCurrentMethod(), " SourceFilePath - " + sourceFilePath + " OutputFilePath - " + outputFilePath); } }
protected override void OnStart(string[] args) { LogExtension.LogInfo("Service started", MethodBase.GetCurrentMethod()); try { timer.Interval = 180000; timer.Elapsed += RecurringTrigger; timer.Start(); base.OnStart(args); ProcessStartTime = DateTime.UtcNow; ProcessEndTime = DateTime.UtcNow.AddMinutes(3); new Task(() => new SchedulerJob().ProcessInitSchedules(ProcessStartTime, ProcessEndTime)).Start(); } catch (Exception e) { LogExtension.LogError("Exception is thrown while starting service", e, MethodBase.GetCurrentMethod()); } }
public List <Group> SearchUserInGroupwithGroupId(int userId, int groupId) { var groupList = new List <Group>(); var whereColumns = new List <ConditionColumn> { new ConditionColumn { ColumnName = GlobalAppSettings.DbColumns.DB_UserGroup.UserId, Condition = Conditions.Equals, Value = userId }, new ConditionColumn { ColumnName = GlobalAppSettings.DbColumns.DB_UserGroup.GroupId, Condition = Conditions.Equals, LogicalOperator = LogicalOperators.AND, Value = groupId } }; try { var result = _dataProvider.ExecuteReaderQuery( _queryBuilder.SelectAllRecordsFromTable(GlobalAppSettings.DbColumns.DB_UserGroup.DB_TableName, whereColumns)); if (result.Status) { groupList = result.DataTable.AsEnumerable() .Select(r => new Group { GroupId = r.Field <int>(GlobalAppSettings.DbColumns.DB_UserGroup.GroupId) }).ToList(); } return(groupList); } catch (Exception e) { LogExtension.LogError("Error while getting group list with whereConditionColumns", e, MethodBase.GetCurrentMethod(), " UserId - " + userId + " GroupId - " + groupId); return(groupList); } }
public Result ExecuteBulkQuery(string query, string connectionString) { var result = new Result(); if (!string.IsNullOrWhiteSpace(connectionString)) { using (var connection = new SqlCeConnection(connectionString)) { string[] splitter = new string[] { ";" }; var querySplit = query.Split(splitter, StringSplitOptions.RemoveEmptyEntries); for (var a = 0; a < querySplit.Length; a++) { using (var command = new SqlCeCommand(querySplit[a], connection)) { try { command.Connection.Open(); result.ReturnValue = command.ExecuteNonQuery(); } catch (Exception e) { result.Status = false; result.Exception = e; LogExtension.LogError("Exception on ExecuteBulkQuery", e, MethodBase.GetCurrentMethod(), " Query - " + query + " ConnectionString - " + connection); } finally { command.Connection.Close(); command.Dispose(); } } } } } else { var exception = new Exception("Invalid Connection string"); result.Status = false; result.Exception = exception; throw exception; } result.Status = true; return(result); }