Exemplo n.º 1
0
        public ActionResult SubSection(int DocumentID = 0)
        {
            var DB  = new ExponentPortalEntities();
            var Doc = DB.DroneDocuments.Find(DocumentID);

            return(View(Doc));
        }
Exemplo n.º 2
0
    }//function Parts()

    private String toJSon(String SQL) {
      bool isFirstRow = true;
      StringBuilder Data = new StringBuilder();

      using (var ctx = new ExponentPortalEntities())
      using (var cmd = ctx.Database.Connection.CreateCommand()) {
        ctx.Database.Connection.Open();
        cmd.CommandText = SQL;
        using (var reader = cmd.ExecuteReader()) {
          Data.AppendLine("[");
          //For each row
          while (reader.Read()) {
            if (!isFirstRow) Data.Append(",");
            Data.AppendLine("{");
            for (int i = 0; i < reader.FieldCount; i++) {
              if (i > 0) Data.AppendLine(",");
              Data.Append("\"" + reader.GetName(i) + "\"");
              Data.Append(" : ");
              Data.Append("\"" + reader.GetValue(i).ToString() + "\"");
            }//for
            Data.Append("\n}");
            isFirstRow = false;
          }//while
          Data.AppendLine("]");

        }//using ctx.Database.Connection.CreateCommand
      }//using ExponentPortalEntities

      return Data.ToString();

    }//function toJSon
Exemplo n.º 3
0
    private String getRFID(
      ExponentPortalEntities DB,
      String FlightUniqueID, 
      String sRow, String sCol) {
      int Row = -100;  
      int Col = -100;
      int.TryParse(sRow, out Row);
      int.TryParse(sCol, out Col);
      

      String SQL = "SELECT RFID From PayLoadMapData WHERE\n" +
      "  FlightUniqueID='" + FlightUniqueID + "' AND\n" +
      "  RowNumber='" + Row + "' AND\n" +
      "  ColumnNumber='" + Col + "'";
      String RFID = "";
      using (var cmd = DB.Database.Connection.CreateCommand()) {
        //DB.Database.Connection.Open();
        cmd.CommandText = SQL;
        using (var reader = cmd.ExecuteReader()) {
          while (reader.Read()) {
            if (RFID != "") RFID += ",";
            RFID += reader["RFID"].ToString().Substring(4,6);
          }//while
        }//using reader
      }//using ctx.Database.Connection.CreateCommand

      return RFID;
    }
Exemplo n.º 4
0
    public List<BlackBoxCostCalucation> getBlackBoxCost(int NumOfDays = 0) {
      int ID = 0;
      var TheCost = new List<BlackBoxCostCalucation>();
      using (var ctx = new ExponentPortalEntities()) {
        var BlackBoxItems = (from n in ctx.BlackBoxCosts select n).ToList();
        foreach(var Item in BlackBoxItems) {
          BlackBoxCostCalucation ThisItem = new BlackBoxCostCalucation {
            CostID = ID++,
            RentType = Item.RentType,
            RentAmount = Item.RentAmount,
            RentDays = Item.RentDays,
            isSelected = false
          };
          ThisItem.getItemCost(NumOfDays);
          TheCost.Add(ThisItem);
        }//foreach
      }//using (var ctx = new ExponentPortalEntities())

      //-- now sort the list by cost to get the minimum amount on first
      var SortedList = TheCost.OrderBy(n => n.CalcuatedCost);
            //-- get the First Item, the marked it as selected
            if (SortedList.Count() > 0)
            {
                SortedList.FirstOrDefault().isSelected = true;
                //totalAmt =Convert.ToDecimal(SortedList.FirstOrDefault().CalcuatedCost);
            }
                //Return the list sorted by ID, to get the order from database
                return SortedList.OrderBy(n => n.RentAmount).ToList();
    }
Exemplo n.º 5
0
        public bool Assign(ExponentPortalEntities ctx)
        {
            //get the DroneID from path
            DroneID   = GetDroneID();
            VideoDate = GetVideoDate();
            if (DroneID < 0 || VideoDate <= DateTime.MinValue)
            {
                return(false);
            }
            ctx.Database.Connection.Open();
            FlightID = GetFlightID(ctx);
            if (FlightID <= 0)
            {
                int?fid = ctx.MSTR_Drone.Where(x => x.DroneId == DroneID).Select(x => x.LastFlightID).FirstOrDefault();
                FlightID = fid == null ? 0 : Util.toInt(fid);
            }
            if (FlightID > 0)
            {
                SetFlightID(ctx);
                AssignStatus = true;
                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
        public async System.Threading.Tasks.Task <ActionResult> DynamicZone()
        {
            var Path = new List <DynamicZone>();

            using (ExponentPortalEntities db = new ExponentPortalEntities()) {
                DateTime Today = DateTime.UtcNow.Date;
                //Convert the Time specifed to GMP
                //It is in UAE (Dubai) Time zone in table
                TimeSpan nowTime = DateTime.UtcNow.AddHours(+4).TimeOfDay;
                var      AllZone =
                    from m in db.MSTR_NoFlyZone
                    where
                    m.DisplayType == "Dynamic" &&
                    m.StartDate <= Today &&
                    m.EndDate >= Today &&
                    m.StartTime <= nowTime &&
                    m.EndTime >= nowTime &&
                    m.IsDeleted != true
                    select m;
                foreach (var Row in await AllZone.ToListAsync())
                {
                    var Zone = new DynamicZone()
                    {
                        ID = Row.ID
                    };
                    Zone.setPath(Row.Coordinates);
                    Path.Add(Zone);
                }
            }
            return(Json(Path, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 7
0
        public static int EmailExist(String EmailID)
        {
            try
            {

                int result = 0;
                using (var ctx = new ExponentPortalEntities())
                {
                    var _objuserdetail = (from data in ctx.MSTR_User
                                          where data.EmailId == EmailID


                                          select data);

                    result = _objuserdetail.Count();
                }

                return result;

            }
            catch (Exception ex)
            {
                Util.ErrorHandler(ex);
                System.Web.HttpContext.Current.Response.Write("<script>alert('Please Check Database Connection');</script>");
                return -1;
            }
        }
Exemplo n.º 8
0
        private bool SetFlightID(ExponentPortalEntities ctx)
        {
            String SQL;
            String VideoURL = path.Substring(path.LastIndexOf('/') + 1);

            SQL = $@"DELETE FROM DroneFlightVideo        
      WHERE
        VideoURL='{VideoURL}' AND
        FlightID={FlightID}";
            DoSQL(SQL, ctx);

            SQL = $@"UPDATE DroneFlight SET
        RecordedVideoURL='{VideoURL}'
      WHERE
        ID={FlightID}";
            DoSQL(SQL, ctx);

            SQL = $@"INSERT INTO DroneFlightVideo(
        DroneID, FlightID, VideoURL, CreatedDate, VideoDateTime
      ) VALUES (
        {DroneID}, {FlightID}, '{VideoURL}', GETDATE(), '{VideoDate.ToString("yyyy-MM-dd HH:mm:ss")}'
      )";
            DoSQL(SQL, ctx);

            return(true);
        }
Exemplo n.º 9
0
 public qView(String sSQL = "", bool isFilterByTop = true) {
   if (sSQL != "") SQL = sSQL;
   _TotalRecords = 0;
   ctx = new ExponentPortalEntities();
   _isFilterByTop = isFilterByTop;
   if (!String.IsNullOrEmpty(SQL)) setColumDef();
 } //qView
Exemplo n.º 10
0
        public static int SMSQue(
            int UserID,
            String ToAddress,
            String Body)
        {
            int QueID = 0;

            using (var ctx = new ExponentPortalEntities()) {
                var Email = new PortalAlertEmail {
                    EmailSubject = "SMS to " + ToAddress,
                    EmailURL     = null,
                    Body         = Body,
                    FromAddress  = "*****@*****.**",
                    ToAddress    = ToAddress,
                    UserID       = UserID,
                    //default values set for items
                    CreatedOn  = DateTime.Now,
                    IsSend     = 0,
                    SendOn     = null,
                    SendStatus = "In Queue",
                    SendType   = "SMS"
                };
                ctx.PortalAlertEmails.Add(Email);
                ctx.SaveChanges();
                QueID = Email.EmailID;
            }

            return(QueID);
        }
Exemplo n.º 11
0
        public static IEnumerable <SelectListItem> GetRAPSDroneList()
        {
            List <SelectListItem> SelectList = new List <SelectListItem>();

            SelectList.Add(new SelectListItem {
                Text = "Please Select...", Value = ""
            });
            String SQL = "SELECT 0 as Value, 'Not Available' as Name";

            using (var ctx = new ExponentPortalEntities()) {
                using (var cmd = ctx.Database.Connection.CreateCommand()) {
                    ctx.Database.Connection.Open();

                    SQL  = "SELECT [DroneId] as Value, [RPASSerialNo] as Name FROM [MSTR_Drone] where IsActive=1";
                    SQL += "\n" +
                           " AND\n " +
                           "  MSTR_Drone.CreatedBy =" + Util.getLoginUserID();

                    SQL            += "\n ORDER BY [DroneName]";
                    cmd.CommandText = SQL;
                    using (var reader = cmd.ExecuteReader()) {
                        while (reader.Read())
                        {
                            SelectList.Add(new SelectListItem {
                                Text  = reader["Name"].ToString(),
                                Value = reader["Value"].ToString()
                            });
                        } //while
                    }     //using

                    ctx.Database.Connection.Close();
                } //using Database.Connection
            }     //using ExponentPortalEntities;
            return(SelectList); //return the list objects
        }         //function GetDropDowntList
Exemplo n.º 12
0
    }//getDataTable()


    public StringBuilder getTableRows() {

      StringBuilder Rows = new StringBuilder();
      bool isEven = false;

      using (var ctx = new ExponentPortalEntities())
      using (var cmd = ctx.Database.Connection.CreateCommand()) {
        ctx.Database.Connection.Open();
        cmd.CommandText = SQL;
        using (var reader = cmd.ExecuteReader()) {
          //For each row
          while (reader.Read()) {
            Rows.AppendLine("<tr class=\"" + (isEven ? "even" : "odd") + "\">");
            for (int i = 0; i < reader.FieldCount; i++) {
              String DisplayValue = getFieldVal(reader, i);
              switch (reader.GetName(i).ToLower()) {
              case "_pkey":
              Rows.AppendLine("<td class=\"menu\"><img data-pkey=\"" + DisplayValue + "\" class=\"row-button\" src=\"/images/drop-down.png\"></td>");
              break;
              default:
              Rows.AppendLine("<td>" + DisplayValue + "</td>");
              break;
              }//switch
            }//for
            Rows.AppendLine("</tr>");
            isEven = !isEven;
          } //while
        }
      }
      return Rows;
    }
Exemplo n.º 13
0
        public static IEnumerable <SelectListItem> GetBlackBox()
        {
            List <SelectListItem> SelectList = new List <SelectListItem>();

            using (var ctx = new ExponentPortalEntities()) {
                using (var cmd = ctx.Database.Connection.CreateCommand()) {
                    ctx.Database.Connection.Open();

                    cmd.CommandText = "SELECT BlackBoxID,BlackBoxName,BlackBoxSerial from MSTR_BlackBox where CurrentStatus='OUT' and IsActive = 1";
                    cmd.CommandType = CommandType.Text;


                    using (var reader = cmd.ExecuteReader()) {
                        while (reader.Read())
                        {
                            SelectList.Add(new SelectListItem {
                                Text = reader["BlackBoxSerial"].ToString() + "-" + reader["BlackBoxName"].ToString(), Value = reader["BlackBoxID"].ToString()
                            });
                        }
                    }
                    DropDownList1 = SelectList.ToList();
                    ctx.Database.Connection.Close();
                    return(DropDownList1); //return the list objects
                }
            }
        }
Exemplo n.º 14
0
    public String getPlayList(int FlightID) {
      String SQL = "select VideoURL from DroneFlightVideo WHERE FlightID=" + FlightID;

      StringBuilder JSon = new StringBuilder();
      using (var ctx = new ExponentPortalEntities()) {
        ctx.Database.Connection.Open();
        using (var cmd = ctx.Database.Connection.CreateCommand()) {
          cmd.CommandText = SQL;
          using (var reader = cmd.ExecuteReader()) {
            while (reader.Read()) {
              if (JSon.Length > 0) JSon.AppendLine(",");
              JSon.Append("{");
              JSon.Append("\"file\":\"");
              JSon.Append(reader["VideoURL"].ToString());
              JSon.Append("\",\n");
              JSon.Append("\"title\":\"");
              JSon.Append("https://exponent-s3.s3-us-west-2.amazonaws.com/VOD/" + reader["VideoURL"].ToString());
              JSon.Append("\"}\n");
            }//if
          }//using reader
        }//using ctx.Database.Connection.CreateCommand
      }//using (var ctx = new ExponentPortalEntities())

      return JSon.ToString();
    }
Exemplo n.º 15
0
    public async Task GenerateFields() {
      Dictionary<String, Decimal> FieldValues = new Dictionary<String, Decimal>();
      String SQL = $@"  
      SELECT
        dbo.PeakMinutes(
          '{this.StartDate.ToString("yyyy-MM-dd")}', '{this.EndDate.ToString("yyyy-MM-dd")}',
          '{this.StartTime.ToString()}', '{this.EndTime.ToString()}'
        ) as BillingPeakMinutes,
        geography::STGeomFromText(
        	'POLYGON((' + dbo.ToogleGeo('{this.Coordinates}') + '))', 4326
        ).STArea() as TotalArea";

      using (var ctx = new ExponentPortalEntities()) {
        using (var cmd =  ctx.Database.Connection.CreateCommand()) {
          await ctx.Database.Connection.OpenAsync();
          cmd.CommandText = SQL;
          using (var reader = await cmd.ExecuteReaderAsync()) {
            if (await reader.ReadAsync()) {
              for (int i = 0; i < reader.FieldCount; i++) {
                FieldValues.Add(reader.GetName(i), Decimal.Parse(reader.GetValue(i).ToString()));
              }//for
            }//if
          }//using reader
        }//using ctx.Database.Connection.CreateCommand
      }//using ExponentPortalEntities

      this.BillingArea = FieldValues["TotalArea"];
      this.BillingPeakMinutes = (int)FieldValues["BillingPeakMinutes"];
      this.BillingDays = (int) (this.EndDate - this.StartDate).TotalDays + 1;
      this.BillingTotalMinutes = (int)(this.EndTime - this.StartTime).TotalMinutes * this.BillingDays;
      this.BillingOffPeakMinutes = this.BillingTotalMinutes - this.BillingPeakMinutes;
      this.BillingVolume = this.BillingArea * this.MaxAltitude;

    }//public async Task GenerateFields
Exemplo n.º 16
0
        public static List <Dictionary <string, object> > jsonRS(String SQL)
        {
            List <Dictionary <string, object> > list = new List <Dictionary <string, object> >();

            using (var ctx = new ExponentPortalEntities()) {
                ctx.Database.Connection.Open();
                using (var cmd = ctx.Database.Connection.CreateCommand()) {
                    //ctx.Database.Connection.Open();
                    cmd.CommandText = SQL;
                    using (var reader = cmd.ExecuteReader()) {
                        while (reader.Read())
                        {
                            Dictionary <string, object> dict = new Dictionary <string, object>();
                            for (int i = 0; i < reader.FieldCount; i++)
                            {
                                dict[reader.GetName(i)] = reader.GetValue(i);
                            }
                            list.Add(dict);
                        } //while
                    }     //using reader
                }         //using ctx.Database.Connection.CreateCommand
            }

            return(list);
        }
Exemplo n.º 17
0
 public ActionResult UASSummary()
 {
     using (var ctx = new ExponentPortalEntities())
     {
         List <Summary> oList = new List <Summary>();
         Summary        odata = new Summary();
         //Count
         var UASCount  = ctx.Database.SqlQuery <int>("select count(DroneId) from MSTR_Drone").ToList();
         var value     = Convert.ToInt16((from p in UASCount select p).Single());
         int UAS_count = value;
         odata.UASCount = value;
         //FlightTime
         var HighestFlightTime = ctx.Database.SqlQuery <int>("select Max(TotalFlightTime) from BlackBoxData ");
         var value1            = Convert.ToInt16((from p in HighestFlightTime select p).Single());
         int FlightTime        = value1;
         odata.HighestFlightTime = value1;
         //Last10daysCount
         var Last10days = ctx.Database.SqlQuery <int>("SELECT COUNT(DroneId) FROM  DroneFlight WHERE Flightdate >= DATEADD(day, -10, getdate())and   Flightdate <= getdate()").ToList();
         var data       = Convert.ToInt32((from p in Last10days select p).Single());
         int day        = data;
         odata.Last10days = data;
         //Last30days
         var Last30days = ctx.Database.SqlQuery <int>("SELECT COUNT(DroneId) FROM  DroneFlight WHERE Flightdate >= DATEADD(day, -30, getdate())and   Flightdate <= getdate()").ToList();
         var data1      = Convert.ToInt32((from p in Last30days select p).Single());
         int day1       = data1;
         odata.Last30days = data1;
         //TotalFlightTime
         var TotalFlightTime = ctx.Database.SqlQuery <int>("select sum(TotalFlightTime) from BlackBoxData");
         var value4          = Convert.ToInt32((from p in TotalFlightTime select p).Single());
         int TFT             = value4;
         odata.TotalFlightTime = value4;
         oList.Add(odata);
         return(View(oList));
     }
 }
Exemplo n.º 18
0
 public static List <Dictionary <String, Object> > getDBRows(String SQL)
 {
     using (var ctx = new ExponentPortalEntities()) {
         ctx.Database.Connection.Open();
         return(getDBRows(SQL, ctx));
     }
 }
Exemplo n.º 19
0
        public ActionResult FlightHistorySummary()
        {
            using (var ctx = new ExponentPortalEntities())
            {
                List <Summary>  FHList = new List <Summary>();
                Summary         fhdata = new Summary();
                List <DateTime> dlist  = new List <DateTime>();
                //count
                var Total_Flight_count = ctx.Database.SqlQuery <int>("select count(distinct(FlightID)) from FLIGHTMAPDATA").ToList();
                var value       = Convert.ToInt16((from p in Total_Flight_count select p).Single());
                int Flightcount = value;
                fhdata.Total_Flight_count = value;
                //TotalFlightHour
                var Total_Flight_Hour = ctx.Database.SqlQuery <int>("select sum(flightHour) from MSTR_DroneService").ToList();
                var value1            = Convert.ToInt16((from p in Total_Flight_Hour select p).Single());
                int TotalHour         = value1;
                fhdata.Total_Flight_Hour = value1;
                //last flight date

                var      Last_Flight_Date = ctx.Database.SqlQuery <DateTime>("select  top 1 (FlightDate)  from DroneFlight order by FlightDate desc  ").ToList();
                DateTime value2           = Convert.ToDateTime((from p in Last_Flight_Date select p).Single());
                DateTime flightdate       = value2;
                fhdata.Last_Flight_Date = flightdate;

                //last UAS ID USED BASED on FightDate
                var Last_UAS_ID = ctx.Database.SqlQuery <int>("select top 1(droneId)from droneflight order by   flightdate desc").ToList();
                var value3      = Convert.ToInt16((from p in Last_UAS_ID select p).Single());
                int UASID       = value3;
                fhdata.Last_UAS_ID = value3;


                FHList.Add(fhdata);
                return(View(FHList));
            }
        }
Exemplo n.º 20
0
        public JsonResult GeoTag([Bind(Prefix = "ID")]  int FlightID)
        {
            if (!exLogic.User.hasAccess("FLIGHT.MAP"))
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }
            ExponentPortalEntities db = new ExponentPortalEntities();
            var thisDrone             = new Drones();
            var DroneName             = thisDrone.getDroneNameForFlight(FlightID);
            var Records = (
                from n in db.DroneDocuments
                where n.DocumentType == "Geo Tag" &&
                n.FlightID == FlightID
                select new GeoTagReport {
                ID = n.ID,
                DocumentName = n.DocumentName,
                FlightID = FlightID,
                Altitude = n.Altitude,
                DroneName = DroneName,
                Latitude = n.Latitude,
                Longitude = n.Longitude,
                UpLoadedDate = n.UploadedDate
            }
                ).ToList();

            return(Json(Records, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 21
0
        public ActionResult Create(MSTR_Pilot_Log PilotLog)
        {
            if (!exLogic.User.hasAccess("PILOTLOG.CREATE"))
            {
                return(RedirectToAction("NoAccess", "Home"));
            }
            if (PilotLog.DroneId < 1 || PilotLog.DroneId == null)
            {
                ModelState.AddModelError("DroneID", "You must select a UAS.");
            }


            if (ModelState.IsValid)
            {
                ExponentPortalEntities db = new ExponentPortalEntities();
                db.MSTR_Pilot_Log.Add(PilotLog);
                db.SaveChanges();

                db.Dispose();
                return(RedirectToAction("UserDetail", "User", new { ID = PilotLog.PilotId }));
            }
            else
            {
                ViewBag.Title = "Create Drone Flight";
                return(View(PilotLog));
            }
        }
Exemplo n.º 22
0
    public static int UserValidation(String UserName, String Password) {
           
            string PasswordCrypto = Util.GetEncryptedPassword(Password);
      int result = 0;
      using (var ctx = new ExponentPortalEntities()) {
        var query = from data in ctx.MSTR_User
                    where ((data.UserName.Equals(UserName)
                    && (data.Password.Equals(PasswordCrypto)))
                    || (data.GeneratedPassword.Equals(PasswordCrypto)))
                    select data;
        var _objuserdetail = query.ToList();


                if (_objuserdetail.Count > 0)
                {
                    if (_objuserdetail[0].GeneratedPassword == PasswordCrypto)
                    {
                        string updatesql = "update MSTR_User set Password='******',GeneratedPassword='' where UserId=" + _objuserdetail[0].UserId;
                        Util.doSQL(updatesql);
                    }
                    else { }
                }
                result = _objuserdetail.Count;
      }
      return result;


    }
Exemplo n.º 23
0
        public static IEnumerable <SelectListItem> GetDdListNationality(string TypeField, string NameField, string ValueField, string SPName)
        {
            List <SelectListItem> SelectList = new List <SelectListItem>();

            SelectList.Add(new SelectListItem {
                Text = "Please Select...", Value = ""
            });


            using (var cotx = new ExponentPortalEntities()) {
                using (var cmd = cotx.Database.Connection.CreateCommand()) {
                    cotx.Database.Connection.Open();


                    cmd.CommandText = "usp_Portal_GetDroneDropDown";
                    DbParameter Param = cmd.CreateParameter();
                    Param.ParameterName = "@Type";
                    Param.Value         = TypeField;
                    cmd.Parameters.Add(Param);
                    cmd.CommandType = CommandType.StoredProcedure;
                    using (var reader = cmd.ExecuteReader()) {
                        while (reader.Read())
                        {
                            SelectList.Add(new SelectListItem {
                                Text = reader["Name"].ToString(), Value = reader["Code"].ToString()
                            });
                        }
                    }
                    DropDownList = SelectList.ToList();
                    cotx.Database.Connection.Close();
                    return(DropDownList); //return the list objects
                }
            }
        }
Exemplo n.º 24
0
 private void DoSQL(String SQL, ExponentPortalEntities ctx)
 {
     using (var cmd = ctx.Database.Connection.CreateCommand()) {
         cmd.CommandText = SQL;
         cmd.ExecuteNonQuery();
     }
 }
Exemplo n.º 25
0
        private int GetFlightID(ExponentPortalEntities ctx)
        {
            int    iFlightID  = 0;
            String sVideoDate = VideoDate.ToString("yyyy-MM-dd HH:mm:ss");
            String SQL        = String.Empty;

            SQL = $@"Select TOP 1 
        FlightID 
      FROM 
        FlightMapData
      WHERE 
        CreatedTime BETWEEN DATEADD(MINUTE, -10, '{sVideoDate}')  AND DATEADD(MINUTE,10, '{sVideoDate}') AND
        DroneID={DroneID}
      ORDER BY
        ABS(DATEDIFF(SECOND, CreatedTime, '{sVideoDate}')) ASC";
            using (var cmd = ctx.Database.Connection.CreateCommand()) {
                cmd.CommandText = SQL;
                var oFlightID = cmd.ExecuteScalar();
                if (oFlightID == null)
                {
                    return(iFlightID);
                }
                int.TryParse(oFlightID.ToString(), out iFlightID);
            }
            return(iFlightID);
        }
Exemplo n.º 26
0
        }                     //function

        public static String getDBRowsJson(String SQL)
        {
            using (var ctx = new ExponentPortalEntities()) {
                ctx.Database.Connection.Open();
                return(getDBRowsJson(SQL, ctx));
            }
        }
Exemplo n.º 27
0
 public ActionResult Edit([Bind(Prefix = "ID")] int FlightID = 0) {
   if (!exLogic.User.hasAccess("FLIGHT.EDIT"))
     return RedirectToAction("NoAccess", "Home");
   ViewBag.Title = "Edit RPAS Flight";
   ExponentPortalEntities db = new ExponentPortalEntities();
   DroneFlight InitialData = db.DroneFlight.Find(FlightID);
   return View(InitialData);
 }
Exemplo n.º 28
0
 }//MoveUploadFileTo
 public ActionResult UASFiles(int FlightID = 0) {
   ExponentPortalEntities db = new ExponentPortalEntities();
   List<DroneDocument> Docs = (from r in db.DroneDocuments
                               where (int)r.FlightID == FlightID &&
                               r.DocumentType == "Regulator Approval"
                               select r).ToList();
   return View(Docs);
 }
Exemplo n.º 29
0
        public String getDataJson()
        {
            int x = 0;

            StringBuilder Row = new StringBuilder();

            Data = new StringBuilder();

            using (var ctx = new ExponentPortalEntities())
                using (var cmd = ctx.Database.Connection.CreateCommand())
                {
                    ctx.Database.Connection.Open();
                    cmd.CommandText = setOrderFilterPaging(SQL);
                    using (var reader = cmd.ExecuteReader())
                    {
                        //For each row
                        while (reader.Read())
                        {
                            if (x > 0)
                            {
                                Row.AppendLine(",");
                            }
                            else
                            {
                                _TotalRecords = Int32.Parse(reader["_TotalRecords"].ToString());
                            }
                            StringBuilder Columns = new StringBuilder();
                            for (int i = 0; i < reader.FieldCount; i++)
                            {
                                String DisplayValue = getFieldVal(reader, i);
                                if (i > 0)
                                {
                                    Columns.AppendLine(",");
                                }
                                Columns.Append("\"" + reader.GetName(i) + "\"");
                                Columns.Append(" : ");
                                Columns.Append("\"" + Util.toSQL(DisplayValue) + "\"");
                            }
                            Row.Append("{");
                            Row.Append(Columns);
                            Row.Append("}");
                            x = x + 1;
                        }//while
                    }
                }

            Data.AppendLine("{");
            Data.AppendLine("\"recordsTotal\" : " + _TotalRecords + ",");
            Data.AppendLine("\"recordsFiltered\" : " + _TotalRecords + ",");
            Data.AppendLine("\"searchDelay\" : 1000,");
            Data.AppendLine("\"data\" : [");
            Data.Append(Row);
            Data.AppendLine("]");
            Data.AppendLine("}");


            return(Data.ToString());
        }//getData
Exemplo n.º 30
0
 public String Update(ViewModel.ListViewModel ListView)
 {
     try {
         ListView.TypeCopy = ListView.TypeCopy.Replace(" ", "");
         ExponentPortalEntities db = new ExponentPortalEntities();
         int    TypeId             = Util.GetTypeId(ListView.TypeCopy);
         string BinaryCode         = Util.DecToBin(TypeId);
         //checking for upadation or new record creation
         if (ListView.Id == 0)
         {
             if (!exLogic.User.hasAccess("lOOKUP.CREATE"))
             {
                 return(Util.jsonStat("error", "Access Denied"));
             }
             string SQL = "INSERT INTO LUP_DRONE(\n" +
                          "  Type,\n" +
                          "  Code,\n" +
                          "  TypeId,\n" +
                          "  BinaryCode,\n" +
                          "  Name,\n" +
                          "  CreatedBy,\n" +
                          "  CreatedOn,\n" +
                          "  IsActive\n" +
                          ") VALUES(\n" +
                          "  '" + ListView.TypeCopy + "',\n" +
                          "  '" + ListView.Code + "',\n" +
                          "  " + TypeId + ",\n" +
                          "  '" + BinaryCode + "',\n" +
                          "  '" + ListView.Name + "',\n" +
                          "  " + Util.getLoginUserID() + ",\n" +
                          "  GETDATE(),\n" +
                          "  'True'" +
                          ")";
             int ListId = Util.InsertSQL(SQL);
             return(JSonData(ListView));
         }
         else
         {
             if (!exLogic.User.hasAccess("lOOKUP.EDIT"))
             {
                 return(Util.jsonStat("error", "Access Denied"));
             }
             string SQL = "UPDATE LUP_DRONE SET\n" +
                          "  Type='" + ListView.TypeCopy + "',\n" +
                          "  Code='" + ListView.Code + "',\n" +
                          "  Name='" + ListView.Name + "',\n" +
                          "  ModifiedBy=" + Util.getLoginUserID() + ",\n" +
                          "  ModifiedOn=GETDATE()\n" +
                          "where\n" +
                          "  Id=" + ListView.Id;
             int ListId = Util.doSQL(SQL);
             return(JSonData(ListView));
         }
         // return RedirectToAction("Listnames");
     } catch (Exception ex) {
         return(Util.jsonStat("error", ex.Message));
     }
 }