/// <summary> /// saving the data of the datarow, /// saves new entrys if the timestamp is not existingClassification, otherwise existingClassification data will be changed /// </summary> /// <param name="ChangedData">row with data to save</param> public void SaveEvent(DateTime EventDate, String System, String Station, String Cargo, String CargoAction, int CargoVolume, Int32 CreditsTransAction, Int32 Credits_Total, String EventType, String Notes, double? Distance=null) { try { dsEliteDB.vilogDataTable TempTable; dsEliteDB.vilogRow TempRow; TempTable = new dsEliteDB.vilogDataTable(); TempRow = (dsEliteDB.vilogRow)TempTable.NewRow(); TempRow.time = EventDate; TempRow.systemname = System; TempRow.stationname = Station; TempRow.loccommodity = Cargo; TempRow.action = CargoAction; TempRow.cargovolume = CargoVolume; TempRow.credits_transaction = CreditsTransAction; TempRow.credits_total = Credits_Total; TempRow.eevent = EventType; TempRow.notes = Notes; if(Distance.HasValue) TempRow.distance = Distance.Value; SaveEvent(TempRow); } catch (Exception ex) { throw new Exception("Error while preparing save data (single params)", ex); } }
/// <summary> /// returns a single log entry identified by its timestamp /// </summary> /// <param name="timeStamp"></param> /// <returns></returns> public dsEliteDB.vilogRow GetLogByTimestamp(DateTime timeStamp) { try { dsEliteDB.vilogDataTable data = new dsEliteDB.vilogDataTable(); // the query is the vilog, but with the added 'where' clause to improve the query speed String sqlString = "select `l`.`time` AS `time`,`s`.`systemname` AS `systemname`,`st`.`stationname` AS `stationname`,`e`.`eventtype` AS `eevent`,`c`.`cargoaction`" + " AS `action`,`co`.`loccommodity` AS `loccommodity`,`l`.`cargovolume` AS `cargovolume`,`l`.`credits_transaction` " + " AS `credits_transaction`,`l`.`credits_total` AS `credits_total`, `l`.`distance` AS `distance`, `l`.`notes` AS `notes` from (((((`tblog` `l` " + " left join `tbeventtype` `e` on((`l`.`event_id` = `e`.`id`))) left join `tbcargoaction` `c` on((`l`.`cargoaction_id` = `c`.`id`))) " + " left join `tbsystems` `s` on((`l`.`system_id` = `s`.`id`))) left join `tbstations` `st` on((`l`.`station_id` = `st`.`id`))) " + " left join `tbcommodity` `co` on((`l`.`commodity_id` = `co`.`id`))) " + " where time = " + DBConnector.SQLDateTime(timeStamp); if(Program.DBCon.Execute(sqlString, data) > 0) return (dsEliteDB.vilogRow)data.Rows[0]; else return null; } catch (Exception ex) { throw new Exception("Error while getting a stationname from a station id", ex); } }
/// <summary> /// saving the data of the datarow, /// saves new entrys if the timestamp is not existingClassification, otherwise existingClassification data will be changed /// </summary> /// <param name="ChangedData">row with data to save</param> public void SaveEvent(CommandersLogEvent Event) { try { dsEliteDB.vilogDataTable TempTable; dsEliteDB.vilogRow TempRow; TempTable = new dsEliteDB.vilogDataTable(); TempRow = (dsEliteDB.vilogRow)TempTable.NewRow(); TempRow.time = Event.EventDate; TempRow.systemname = Event.System; TempRow.stationname = Event.Station; TempRow.loccommodity = Event.Cargo; TempRow.action = Event.CargoAction; TempRow.cargovolume = (Int32)Event.CargoVolume; TempRow.credits_transaction = (Int32)Event.TransactionAmount; TempRow.credits_total = (Int32)Event.Credits; TempRow.eevent = Event.EventType; TempRow.notes = Event.Notes; SaveEvent(TempRow); } catch (Exception ex) { throw new Exception("Error while preparing save data (Event class)", ex); } }