Ejemplo n.º 1
0
 }//getBulkInsertHeader()
 private String getBulkInsertRow(String Line, int DroneID, int FlightID, int BBFlightID) {
   String[] Data = Line.Split(',');
   return "(\n" +
     "  " + DroneID + ",\n" +                    //[DroneId],\n" +     
     "  " + FlightID + ",\n" +                   //[FlightID],\n" +    
     "  " + BBFlightID + ",\n" +                 //[BBFlightID],\n" +  
     "  " + Util.toInt(Data[0]) + ",\n" +        //[RecordNumber],\n" +
     "  " + Util.toInt(Data[1]) + ",\n" +        //[DroneSerialID],\n" 
     "  " + Util.toDecimal(Data[2]) + ",\n" +    //[Latitude],\n" +    
     "  " + Util.toDecimal(Data[3]) + ",\n" +    //[Longitude],\n" +   
     "  " + Util.toDecimal(Data[4]) + ",\n" +    //[Altitude],\n" +    
     "  " + Util.toDecimal(Data[5]) + ",\n" +    //[Speed],\n" +       
     "  " + Util.toDecimal(Data[6]) + ",\n" +    //[FixQuality],\n" +  
     "  " + Util.toInt(Data[7]) + ",\n" +        //[Satellites],\n" +  
     "  '" + Util.toDate(Data[8]) + "',\n" +      //[ReadTime],\n" +    
     "  " + Util.toDecimal(Data[9]) + ",\n" +    //[Pitch],\n" +       
     "  " + Util.toDecimal(Data[10]) + ",\n" +   //[Roll],\n" +        
     "  " + Util.toDecimal(Data[11]) + ",\n" +   //[Heading],\n" +     
     "  " + Util.toDecimal(Data[12]) + "\n" +    //[TotalFlightTime]\n"
     ")";
 }//getBulkInsertRow()
Ejemplo n.º 2
0
    }//getFlights()

    public void saveTechnicalLog(HttpRequestBase Request) {
      String SQL;
      String[] Index = Request["theFlight.Index"].Split(',');
      foreach (String RowID in Index) {
        if (RowID == "SLNO") continue;
        String FlightID = Request["theFlight[" + RowID + "].ID"];
        String LogTakeOffTime = Request["theFlight[" + RowID + "].FlightDate"] + " " +
                         Request["theFlight[" + RowID + "].LogTakeOffTime"];
        String LogLandingTime = Request["theFlight[" + RowID + "].FlightDate"] + " " +
                         Request["theFlight[" + RowID + "].LogLandingTime"];

        if (FlightID == "0") {
          //create new flight for drone
          SQL =
          "INSERT INTO DroneFlight (\n" +
          "  DroneID,\n" +
          "  PilotID,\n" +
          "  FlightDate,\n" +
          "  CreatedOn,\n" +
          "  CreatedBy,\n" +
          "  [LogFrom],\n" +
          "  [LogTo],\n" +
          "  [LogTakeOffTime],\n" +
          "  [LogLandingTime],\n" +
          "  [LogBattery1ID],\n" +
          "  [LogBattery1StartV],\n" +
          "  [LogBattery1EndV],\n" +
          "  [LogBattery2ID],\n" +
          "  [LogBattery2StartV],\n" +
          "  [LogBattery2EndV],\n" +
          "  [isLogged],\n" +
          "  [LogDateTime],\n" +
          "  [LogCreatedBy],\n" +
          "  [Descrepency],\n" +
          "  [ActionTaken]\n" +
          ") VALUES (" +
          "  " + Util.toInt(Request["DroneID"]) + ",\n" +
          "  " + Util.getLoginUserID() + ",\n" +
          "  '" + Util.toSQLDate(LogTakeOffTime) + "',\n" +
          "  GETDATE(),\n" +
          "  " + Util.getLoginUserID() + ",\n" +
          "  '" + Request["theFlight[" + RowID + "].LogFrom"] + "',\n" +
          "  '" + Request["theFlight[" + RowID + "].LogTo"] + "',\n" +
          "  '" + Util.toSQLDate(LogTakeOffTime) + "',\n" +
          "  '" + Util.toSQLDate(LogLandingTime) + "',\n" +
          "  '" + Request["theFlight[" + RowID + "].LogBattery1ID"] + "',\n" +
          "  " + Util.toDecimal(Request["theFlight[" + RowID + "].LogBattery1StartV"]) + ",\n" +
          "  " + Util.toDecimal(Request["theFlight[" + RowID + "].LogBattery1EndV"]) + ",\n" +
          "  '" + Request["theFlight[" + RowID + "].LogBattery2ID"] + "',\n" +
          "  " + Util.toDecimal(Request["theFlight[" + RowID + "].LogBattery2StartV"]) + ",\n" +
          "  " + Util.toDecimal(Request["theFlight[" + RowID + "].LogBattery2EndV"]) + ",\n" +
          "  1,\n" +
          "  GETDATE(),\n" +
          "  " + Util.getLoginUserID() + ",\n" +
          "  '" + Request["theFlight[" + RowID + "].Descrepency"] + "',\n" +
          "  '" + Request["theFlight[" + RowID + "].ActionTaken"] + "'\n" +
          ")";
          Util.doSQL(SQL);
        } else { //if(FlightID == "0")
                 //Update flight information for technical Log
          SQL =
         "UPDATE\n" +
         "  DroneFlight\n" +
         "SET\n" +
         "  [LogFrom] = '" + Request["theFlight[" + RowID + "].LogFrom"] + "',\n" +
         "  [LogTo] = '" + Request["theFlight[" + RowID + "].LogTo"] + "',\n" +
         "  [LogTakeOffTime] = '" + Util.toSQLDate(LogTakeOffTime) + "',\n" +
         "  [LogLandingTime] = '" + Util.toSQLDate(LogLandingTime) + "',\n" +
         "  [LogBattery1ID] = '" + Request["theFlight[" + RowID + "].LogBattery1ID"] + "',\n" +
         "  [LogBattery1StartV] = " + Util.toDecimal(Request["theFlight[" + RowID + "].LogBattery1StartV"]) + ",\n" +
         "  [LogBattery1EndV] = " + Util.toDecimal(Request["theFlight[" + RowID + "].LogBattery1EndV"]) + ",\n" +
         "  [LogBattery2ID] = '" + Request["theFlight[" + RowID + "].LogBattery2ID"] + "',\n" +
         "  [LogBattery2StartV] = " + Util.toDecimal(Request["theFlight[" + RowID + "].LogBattery2StartV"]) + ",\n" +
         "  [LogBattery2EndV] = " + Util.toDecimal(Request["theFlight[" + RowID + "].LogBattery2EndV"]) + ",\n" +
         "  [isLogged] = 1,\n" +
         "  [LogDateTime] = GETDATE(),\n" +
         "  LogCreatedBy=" + Util.getLoginUserID() + ",\n" +
         "  Descrepency = '" + Request["theFlight[" + RowID + "].Descrepency"] + "',\n" +
         "  ActionTaken = '" + Request["theFlight[" + RowID + "].ActionTaken"] + "'\n" +
         "WHERE\n" +
         "  ID=" + FlightID;
          Util.doSQL(SQL);
        }//if(FlightID == "0")

      }//foreach(Index)
    }//saveTechnicalLog()
Ejemplo n.º 3
0
    public List<DroneFlight> getLogFlights(List<DroneFlight> Flights, int FlightID = 0) {
      String SQL = FlightID == 0 ?
        "SELECT\n" +
        "  DroneFlight.ID,\n" +
        "  LogFrom,\n" +
        "  LogTo,\n" +
        "  Convert(Varchar, Min(FlightMapData.ReadTime), 111) as 'FlightDate(UTC)',\n" +
        "  Convert(Varchar, Min(FlightMapData.ReadTime), 108) as LogTakeOffTime,\n" +
        "  Convert(Varchar, Max(FlightMapData.ReadTime), 108) as LogLandingTime,\n" +
        "  Convert(Varchar, DATEADD(\n" +
        "     Minute,\n" +
        "     DATEDIFF(MINUTE, Min(FlightMapData.ReadTime), Max(FlightMapData.ReadTime)),\n" +
        "     '2000-01-01 00:00:00'), 108) as Duration,\n" +
        "  FlightMapData.BBFlightID,\n" +
        "  '' as LogBattery1ID,\n" +
        "  '' as   LogBattery1StartV,\n" +
        "  '' as   LogBattery1EndV,\n" +
        "  '' as   LogBattery2ID,\n" +
        "  '' as   LogBattery2StartV,\n" +
        "  '' as   LogBattery2EndV,\n" +
        "  '' as   Descrepency,\n" +
        "  '' as   ActionTaken\n" +
        "From\n" +
        "  DroneFlight\n" +
        "LEFT JOIN FlightMapData On\n" +
        "  FlightMapData.FlightID = DroneFlight.ID\n" +
        "WHERE\n" +
        "  DroneFlight.DroneID = " + DroneID.ToString() + " AND\n" +
        "    (isLogged IS NULL OR isLogged = 0)\n" +
        "GROUP BY\n" +
        "  DroneFlight.ID,\n" +
        "  DroneFlight.DroneID,\n" +
        "  FlightMapData.BBFlightID,\n" +
        "  LogFrom,\n" +
        "  LogTo\n"
        :
        "SELECT\n" +
        "  DroneFlight.ID,\n" +
        "  LogFrom,\n" +
        "  LogTo,\n" +
        "  Convert(Varchar(11), FlightDate, 111) as 'FlightDate(UTC)',\n" +
        "  Convert(Varchar, LogTakeOffTime, 108) as LogTakeOffTime,\n" +
        "  Convert(Varchar, LogLandingTime, 108) as LogLandingTime,\n" +
        "  Convert(Varchar, DATEADD(\n" +
        "     Minute,\n" +
        "     DATEDIFF(MINUTE, LogTakeOffTime, LogLandingTime),\n" +
        "     '2000-01-01 00:00:00'), 104) as Duration,\n" +
        "  LogBattery1ID,\n" +
        "  LogBattery1StartV,\n" +
        "  LogBattery1EndV,\n" +
        "  LogBattery2ID,\n" +
        "  LogBattery2StartV,\n" +
        "  LogBattery2EndV,\n" +
        "  Descrepency,\n" +
        "  ActionTaken,\n" +
        "  '0' as BBFlightID\n" +
        "From\n" +
        "  DroneFlight\n" +
        "WHERE\n" +
        "  ID=" + FlightID;

      var Rows = Util.getDBRows(SQL);
      foreach (var Row in Rows) {
        DroneFlight Flight = new DroneFlight() {
          ID = Util.toInt(Row["ID"].ToString()),
          LogFrom = Row["LogFrom"].ToString(),
          LogTo = Row["LogFrom"].ToString(),
          LogTakeOffTime = Util.toDate(Row["FlightDate"].ToString() + " " + Row["LogTakeOffTime"].ToString()),
          LogLandingTime = Util.toDate(Row["FlightDate"].ToString() + " " + Row["LogLandingTime"].ToString()),
          FlightDate = Util.toDate(Row["FlightDate"].ToString()),
          LogBattery1ID = Row["LogBattery1ID"].ToString(),
          LogBattery1StartV = Util.toDecimal(Row["LogBattery1StartV"].ToString()),
          LogBattery1EndV = Util.toDecimal(Row["LogBattery1EndV"].ToString()),
          LogBattery2ID = Row["LogBattery2ID"].ToString(),
          LogBattery2StartV = Util.toDecimal(Row["LogBattery2StartV"].ToString()),
          LogBattery2EndV = Util.toDecimal(Row["LogBattery2EndV"].ToString()),
          Descrepency = Row["Descrepency"].ToString(),
          ActionTaken = Row["ActionTaken"].ToString()
        };
        Flights.Add(Flight);
      }
      return Flights;
    }//getFlights()