//private static SqlCeConnection ConnectDb() //{ // if (System.Configuration.ConfigurationManager.ConnectionStrings["LocalDbConnectionString"]==null) // { // if (log.IsErrorEnabled) log.Error("LocalDbConnectionString Key not configured"); // throw new Exception("LocalDbConnectionString Key not configured"); // Console.ReadLine(); // } // strConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["LocalDbConnectionString"].ToString(); // if (string.IsNullOrEmpty(strConnectionString)) // { // if (log.IsErrorEnabled) log.Error("The Local database connection string not found \n Please add the connectionstring key named (LocalDbConnectionString) in app.config file"); // throw new Exception("The Local database connection string not found \n Please add the connectionstring key named (LocalDbConnectionString) in app.config file"); // Console.ReadLine(); // } // if(_instance == null) // { // _instance = new SqlCeConnection(strConnectionString); // } // return _instance; //} private static SnapShotLogger getSnapShortDetails(string strSql) { if (log.IsInfoEnabled) log.Info("SelectTransaction started.."); SnapShotLogger objsnapshort = new SnapShotLogger(); try { Open(strConnectionString); SqlCeCommand command = new SqlCeCommand(strSql); SqlCeDataReader reader = ExecuteReader(command); while (reader.Read()) { objsnapshort.BillerServiceId = Convert.ToInt32(reader["BillerServiceId"]); objsnapshort.ChangedDate = Convert.ToDateTime(reader["ChangedDate"]); objsnapshort.SnapSortId = Convert.ToInt32(reader["SnapSortId"]); objsnapshort.Type = Convert.ToString(reader["Type"]); objsnapshort.Path = Convert.ToString(reader["Path"]); } } catch (SqlCeException ex) { if (log.IsErrorEnabled) log.Error("SqlCeException caught in DBLogger.SelectTransaction.." + ex.Message); Close(); //System.Environment.Exit(1); // exit } catch (Exception ex) { if (log.IsErrorEnabled) log.Error("Generic exception caught in SelectTransaction .." + ex.Message); } if (log.IsInfoEnabled) log.Info("SelectTransaction ended.."); return objsnapshort; }
public static int AddUpdatetblSnapshort(SnapShotLogger objSnapshort, string type) { int result = 0; StringBuilder strSql = new StringBuilder(); if (type == "Add") { strSql.AppendFormat("INSERT INTO tblSnapShort (BillerServiceId, ChangedDate, SnapSortId,Type, Path ) VALUES('{0}','{1}', '{2}','{3}','{4}')", objSnapshort.BillerServiceId, objSnapshort.ChangedDate, objSnapshort.SnapSortId, objSnapshort.Type, objSnapshort.Path); } else { strSql.AppendFormat("Update tblSnapShort SET ChangedDate = '{0}', SnapSortId = '{1}', Type= '{2}'", objSnapshort.ChangedDate, objSnapshort.SnapSortId, objSnapshort.Type); } try { Open(strConnectionString); SqlCeCommand command = new SqlCeCommand(strSql.ToString()); result = ExecuteNonQuery(command); if (result > 0) if (log.IsInfoEnabled) log.Info(" AddUpdatetblSnapshort successfull.. for tblSnapShort.." + objSnapshort.BillerServiceId); } catch (SqlCeException ex) { if (log.IsErrorEnabled) log.Error("SqlCeException caught in DBLogger.AddUpdatetblSnapshort.." + ex.Message); Close(); } catch (Exception ex) { if (log.IsErrorEnabled) log.Error("Generic Exception caught in DBLogger.AddUpdatetblSnapshort.." + ex.Message); } finally { Close(); } return result; }
public static int AddUpdatetblSnapshort(SnapShotLogger objSnapshort, string type) { return DBLogger.AddUpdatetblSnapshort(objSnapshort, type); }