Exemplo n.º 1
0
    private void setReportMessages(IList<PortalAlert> Messages, GCA_Approval thisApproval) {

      foreach (var Message in Messages) {
        if (thisApproval != null) {
          var FlightInfo = (
            from f in db.FlightMapDatas
            where f.FlightMapDataID == Message.FlightDataID
            select f
          ).FirstOrDefault();
          switch (Message.AlertCategory) {
          case "Height":
            Message.AlertMessage = "RPAS is above proposed height of " + thisApproval.MaxAltitude + " Meter at " + Message.Altitude + " Meter";
            break;
          case "Boundary":
            Message.AlertCategory = "Perimeter";
            Message.AlertMessage = "RPAS is outside approved perimeter at " + fmtGPS((Double)Message.Latitude, (Double)Message.Longitude);
            break;
          case "Proximity":
            //Message.AlertMessage = getProximityMessage(FlightInfo.OtherFlightIDs, (int)FlightInfo.FlightID);
            Message.AlertMessage = "Proximity Error";
            break;

          }//switch
        } else {
          //nothing.
        }
      }//foreach
    }//private void setReportMessages
Exemplo n.º 2
0
        public string UploadGCA(GCA_Approval GCA)
        {
                //Doc.DocumentTitle = Doc.DocumentTitle.Trim();
                if (String.IsNullOrWhiteSpace(GCA.ApprovalName))
                {
                    GCA.ApprovalName = toTitle(GCA.ApprovalFileUrl);
                }

                string[] Coord = GCA.Coordinates.Split(',');
                string Poly = GCA.Coordinates + "," + Coord[0];

                if (string.IsNullOrEmpty(GCA.BoundaryInMeters.ToString().Trim()))
                    GCA.BoundaryInMeters = 0;

                string SQL = "SELECT Count(*) FROM [GCA_Approval] WHERE ApprovalID = " + GCA.ApprovalID;
                if (Util.getDBInt(SQL) != 0 && GCA.ApprovalID != 0)
                {
                    //string UpdateRingQuery = "Update [GCA_Approval] set Polygon=Polygon.ReorientObject().MakeValid()  where Polygon.STArea()>999999 and ApprovalID=" + GCA.ApprovalID;
                    //int res = Util.doSQL(SQL);
                    //UpdateRingQuery = @"Update [GCA_Approval]  set 
                    //        InnerBoundary=Polygon.STBuffer(BoundaryInMeters),
                    //        InnerBoundaryCoord = Polygon.STBuffer(BoundaryInMeters).ToString() where ApprovalID=" + GCA.ApprovalID;

                    string SQLQ = "Update [GCA_Approval]  set" +
                             "[ApprovalName] = '" + GCA.ApprovalName + "' " +
                            ",[ApprovalDate] = '" + Util.toSQLDate(Convert.ToDateTime(GCA.ApprovalDate)) + "' " +
                            ",[StartDate] = '" + Util.toSQLDate(Convert.ToDateTime(GCA.StartDate)) + "' " +
                            ",[EndDate] = '" + Util.toSQLDate(Convert.ToDateTime(GCA.EndDate)) + "' " +
                            ",[StartTime]= '" + GCA.StartTime + "' " +
                            ",[EndTime]= '" + GCA.EndTime + "' " +
                            ",[Coordinates]= '" + GCA.Coordinates + "' " +
                            ",[Polygon]= geography::STGeomFromText('POLYGON((" + Poly + @"))',4326).MakeValid()  " +
                            ",DroneID= '" + GCA.DroneID + "' " +
                            ",ApprovalFileUrl= '" + GCA.S3Url + "' " +
                            ",MinAltitude= '" + (GCA.MinAltitude == null ? 0 : GCA.MinAltitude) + "' " +
                            ",MaxAltitude= '" + (GCA.MaxAltitude == null ? 60 : GCA.MaxAltitude) + "' " +
                            ",BoundaryInMeters= '" + (GCA.BoundaryInMeters == null ? 0 : GCA.BoundaryInMeters) + "' " +
                            " WHERE ApprovalID = " + GCA.ApprovalID;
                    int res = Util.doSQL(SQLQ);
                }
                else
                {
                    SQL = @" insert into [GCA_Approval]
                         ([ApprovalName]
                        ,[ApprovalDate]
                        ,[StartDate]
                        ,[EndDate]
                        ,[StartTime]
                        ,[EndTime]
                        ,[Coordinates]
                        ,[Polygon]
                        ,DroneID
                        ,ApprovalFileUrl
                        ,MinAltitude
                        ,MaxAltitude
                        ,BoundaryInMeters)
                      values
                      ('" + GCA.ApprovalName + @"',
                      '" + Util.toSQLDate(Convert.ToDateTime(GCA.ApprovalDate)) + @"',
                      '" + Util.toSQLDate(Convert.ToDateTime(GCA.StartDate)) + @"',
                      '" + Util.toSQLDate(Convert.ToDateTime(GCA.EndDate)) + @"',
                      '" + GCA.StartTime + @"',
                      '" + GCA.EndTime + @"',
                      '" + GCA.Coordinates + @"',
                      geography::STGeomFromText('POLYGON((" + Poly + @"))',4326).MakeValid(),
                      " + GCA.DroneID + @",
                      '" + GCA.S3Url + @"',
                     " + (GCA.MinAltitude == null ? 0 : GCA.MinAltitude) + @",
                     " + (GCA.MaxAltitude == null ? 60 : GCA.MaxAltitude) + @",                      
                    -" + (GCA.BoundaryInMeters == null ? 0 : GCA.BoundaryInMeters) + @")";


                    GCA.ApprovalID = Util.InsertSQL(SQL);

                }

                return "../../Approval/Index";// RedirectToAction("Index","Approval");
           
        }
Exemplo n.º 3
0
        public ActionResult GCAApproval(int ID=0)

        {
            //to create gcaapproval
            if (!exLogic.User.hasAccess("FLIGHT.GCAAPPROVAL")) return RedirectToAction("NoAccess", "Home");
            var fileStorageProvider = new AmazonS3FileStorageProvider();

            var fileUploadViewModel = new S3Upload(
              fileStorageProvider.PublicKey,
              fileStorageProvider.PrivateKey,
              fileStorageProvider.BucketName,
              Url.Action("complete", "home", null, Request.Url.Scheme)
            );

            fileUploadViewModel.SetPolicy(
              fileStorageProvider.GetPolicyString(
                fileUploadViewModel.FileId,
                fileUploadViewModel.RedirectUrl
              )
            );


            ViewBag.FormAction = fileUploadViewModel.FormAction;
            ViewBag.FormMethod = fileUploadViewModel.FormMethod;
            ViewBag.FormEnclosureType = fileUploadViewModel.FormEnclosureType;
            ViewBag.AWSAccessKey = fileUploadViewModel.AWSAccessKey;
            ViewBag.Acl = fileUploadViewModel.Acl;
            ViewBag.Base64EncodedPolicy = fileUploadViewModel.Base64EncodedPolicy;
            ViewBag.Signature = fileUploadViewModel.Signature;

            var GCAApprovalDoc = new GCA_Approval();
            if (ID != 0)
            {
                GCAApprovalDoc.DroneID = ID;
            }

            if (ID != 0)
            {
                var olist = (from p in db.GCA_Approval where p.ApprovalID == ID select p).ToList();
                if (olist.Count > 0)
                {
                    GCAApprovalDoc.ApprovalID = olist[0].ApprovalID;
                    GCAApprovalDoc.DroneID = olist[0].DroneID;
                    GCAApprovalDoc.ApprovalName = olist[0].ApprovalName;
                    GCAApprovalDoc.Coordinates = olist[0].Coordinates;

                    GCAApprovalDoc.ApprovalDate = olist[0].ApprovalDate == null ? null : olist[0].ApprovalDate;
                    GCAApprovalDoc.StartDate = olist[0].StartDate == null ? null : olist[0].StartDate; 
                    GCAApprovalDoc.EndDate = olist[0].EndDate == null ? null : olist[0].EndDate;

                    GCAApprovalDoc.StartTime = olist[0].StartTime;
                    GCAApprovalDoc.EndTime = olist[0].EndTime;
                    GCAApprovalDoc.MinAltitude = olist[0].MinAltitude;

                    GCAApprovalDoc.MaxAltitude = olist[0].MaxAltitude;
                    GCAApprovalDoc.BoundaryInMeters = olist[0].BoundaryInMeters;
                }
            }
            return View(GCAApprovalDoc);

        }//ActionResult GCAApproval()