Пример #1
0
        //# __________ PROTOCOL :: CONSANTS (ERRORS) __________ #//
        //# __________ PROTOCOL :: PUBLIC __________ #//
        public static bool ValidateLogin()
        {
            VmMessageHttpResponse res;
            res = RegisterDevice();
            if( res.HasError() )
            {
                int errorCode = JwUtility.ParseInteger(res.GetErrorCode());
                if(
                   errorCode == VmMessageHttpResponse.ERROR_INVALID_LOGIN ||
                   errorCode == VmMessageHttpResponse.ERROR_INVALID_PASSWORD)
                    return false;
                else
                    res.RaiseError();
            }

            VmMessageHttpRequest req = new VmMessageHttpRequest();
            req.Mappings["command"] = "login";
            try
            {
                res = req.Send();
            }
            catch(VmMessageHttpError x)
            {
                x.GetType();
                return false;
            }
            return true;
        }
Пример #2
0
 public static VmMessageHttpResponse RegisterDevice()
 {
     VmMessageHttpRequest req = new VmMessageHttpRequest();
     req.Mappings["command"] = "registerDevice";
     req.Mappings["profileName"] = VmAccountData.Default.Account.Profile;
     VmMessageHttpResponse response = req.Send(false);
     if( ! response.HasError() )
     {
         String deviceName = response.Mappings["deviceName"];
         if( ! JwUtility.IsEmpty(deviceName) )
             VmAccountData.Default.WriteDeviceName(deviceName);
     }
     return response;
 }
Пример #3
0
 public void UploadFileBasedEntry(
     VmUploadDirectoryManager manager,
     String sessionId,
     VmSessionManifestEntry entry,
     int index,
     int maxIndex)
 {
     VmMessageHttpRequest req = new VmMessageHttpRequest();
     req.Mappings["command"] = "upload";
     req.Mappings["sessionId"] = sessionId;
     req.Mappings["fileName"] = entry.FileName;
     req.Mappings["fileType"] = entry.FileType;
     req.Mappings["airportCode"] = entry.AirportCode;
     byte[] ba = manager.ReadFile( entry.AirportCode, entry.FileType, entry.FileName);
     req.Mappings["data"] = JwUtility.ToString(ba);
     MonitorBeginFile(
         entry.AirportCode,
         entry.FileName,
         index,
         maxIndex);
     VmMessageHttpResponse res  = req.Send();
 }
Пример #4
0
 public VmMessageHttpResponse GetFileBasedSessionStatus(String sessionId)
 {
     Monitor("Getting Status: " + sessionId);
     VmMessageHttpRequest req = new VmMessageHttpRequest();
     req.Mappings["command"] = "getSessionStatus";
     req.Mappings["sessionId"] = sessionId;
     return req.Send();
 }
Пример #5
0
 public void CreateFileModeUploadSession(VmUploadDirectoryManager manager)
 {
     VmMessageHttpRequest req = new VmMessageHttpRequest();
     req.Mappings["command"] = "createSession";
     req.Mappings["data"] = manager.GetSessionManifest();
     VmMessageHttpResponse res  = req.Send();
     String sessionId = res.Mappings["sessionId"];
     manager.WriteSessionCookie(sessionId);
 }
Пример #6
0
 public void CreateChunkedModeUploadSession(VmUploadDirectoryManager manager)
 {
     VmMessageHttpRequest req = new VmMessageHttpRequest();
     req.Mappings["command"] = "createSession";
     req.Mappings[TRANSMISSION_MODE_KEY] = TRASNMISSION_MODE_CHUNKED;
     req.Mappings["data"] = manager.GetChunkedSessionManifest();
     VmMessageHttpResponse res  = req.Send();
     String sessionId = res.Mappings["sessionId"];
     manager.WriteSessionCookie(sessionId);
 }
Пример #7
0
 /**
  * Get Planned Route Close Out Times
  *
  * Purpose:
  *      Get the close out times of the domestic planned routes for the specified dates.
  *
  * Expected parameters:
  *      accountCode     the account code must must reference an active account
  *      login           the login must be an active user with the cargoWorker role
  *      password        the password must match the user'
  s password
  *      deviceName      the name of a registered device.
  *      airportCode     must be active
  *      startDate       formatted as ISO
  *      endDate         formatted as ISO
  *
  * Returned values:
  *      {response header}
  *      data: list planned routes and close out time, separated by a carriage
  *      return, line feed. The data will be concatenated together into a fixed length
  *      string of length 9. The control number will be padded with spaces to 4
  *      characters. The time will be formated in 24 hour clock (military) without
  *      seconds.
  *      The data is as follows:
  *          planned route control number (route index number)
  *          close out time
  */
 public String GetPlannedRouteCloseOutData(VmPlannedRouteConfiguration configuration)
 {
     VmMessageHttpRequest req2 = new VmMessageHttpRequest();
     req2.Mappings["command"] = "getPlannedRouteCloseOutTimes";
     req2.Mappings["airportCode"] = AirportInputData.AirportCode;
     req2.Mappings["startDate"] = JwDatePolicyIso.FormatAsIsoDate( configuration.EffectiveStartDate);
     req2.Mappings["endDate"] = JwDatePolicyIso.FormatAsIsoDate( configuration.EffectiveEndDate);
     VmMessageHttpResponse res2  = req2.Send();
     return res2.GetData();
 }
Пример #8
0
        //# __________ PROTOCOL :: PROTECTED  __________ #//
        public void DownloadData(
            String monitorName,
            String command,
            String fileName)
        {
            MonitorBeginFile(monitorName);

            VmMessageHttpRequest req = new VmMessageHttpRequest();
            req.Mappings["command"] = command;
            req.Mappings["airportCode"] = GetAirportCode();
            VmMessageHttpResponse res  = req.Send();
            JwUtility.WriteToFile(
                fileName,
                res.GetData());
        }
Пример #9
0
        public void GetPlannedRoutes()
        {
            /*
            bool shouldGetPlannedRoutes =
                VmProperties.Default.ShouldAllowUsDomesticTag()
                && VmProperties.Default.ShouldUsePlannedRoutes();
            if( ! shouldGetPlannedRoutes ) return;
            */

            MonitorBeginFile(AirportInputData.AirportCode, "Planned Routes");

            VmMessageHttpRequest req = new VmMessageHttpRequest();
            req.Mappings["command"] = "getCurrentPlannedRouteDates";
            req.Mappings["airportCode"] = AirportInputData.AirportCode;
            VmMessageHttpResponse res  = req.Send();

            AirportInputData.PlannedRoutes.UpdateDurations(res.GetData());
            JwList<VmPlannedRouteConfiguration> configurations = AirportInputData.PlannedRoutes.GetPlannedRouteConfigurations();

            foreach( VmPlannedRouteConfiguration configuration in configurations )
            {
                GetPlannedRouteConfiguration(configuration);
            }
        }
Пример #10
0
        //# __________ PROTOCOL :: PROTECTED __________ #//
        public bool ShouldGetUserFile()
        {
            if( ! AirportInputData.Properties.ShouldCacheUserFile() )
            {
                AirportInputData.UserInputData.DeleteAll();
                return true;
            }

            MonitorBeginFile("Checking for User Updates");

            VmMessageHttpRequest req = new VmMessageHttpRequest();
            req.Mappings["command"] = "getLastUserModificationTimeForAirport";
            req.Mappings["airportCode"] = GetAirportCode();
            VmMessageHttpResponse res  = req.Send();
            String value = res.GetMapping("lastModificationUtcTs");
            JwTimestamp currentLastUpdateTs = JwTimestampParser.ParseTimestamp(value);
            JwTimestamp previousLastUpdateTs = AirportInputData.UserInputData.GetLastUpdateUtcTs();
            if( JwUtility.IsEqual( currentLastUpdateTs, previousLastUpdateTs) )
            {
                MonitorBeginFile("User file is cached.");
                return false;
            }

            AirportInputData.UserInputData.DeleteAll();
            AirportInputData.UserInputData.WriteLastUpdateTimestamp(value);
            return true;
        }
Пример #11
0
 public void GetAirportProfileProperties(VmAirportProfileInputData airportProfileInputData)
 {
     VmMessageHttpRequest req = new VmMessageHttpRequest();
     req.Mappings["command"] = "getAirportProfileProperties";
     req.Mappings["airportCode"] = GetAirportCode();
     req.Mappings["airportProfileName"] = airportProfileInputData.ProfileName;
     VmMessageHttpResponse res  = req.Send();
     JwUtility.WriteToFile(
         airportProfileInputData.GetPropertyFileName(),
         res.GetData());
 }
Пример #12
0
        public VmMessageHttpResponse GetSessionStatus()
        {
            String sessionId = _manager.GetSessionCookie();

            Monitor("...Getting Status");
            VmMessageHttpRequest req = new VmMessageHttpRequest();
            req.Mappings["command"] = "getSessionStatus";
            req.Mappings["sessionId"] = sessionId;
            return req.Send();
        }
Пример #13
0
        public void Upload(StringBuilder sb)
        {
            int thisPacketLength = sb.Length;
            JwTimestamp beginUtcTs = JwTimestamp.CreateNowUtc();

            MonitorNextBytes(thisPacketLength);

            VmMessageHttpRequest req = new VmMessageHttpRequest();
            req.Mappings["command"] = "upload";
            req.Mappings["sessionId"] = _manager.GetSessionCookie();
            req.Mappings[TRANSMISSION_MODE_KEY] = TRASNMISSION_MODE_CHUNKED;

            // (err) - kludge: the data value as obtained from the server appears to trim
            // leading / trailing white space.  The padding below is coordinated with the
            // server to work around this problem.

            String dataValue = sb.ToString();
            dataValue = "x" + dataValue + "x";

            req.Mappings["data"] = dataValue;
            req.Mappings["beginByte"] = (_lastByteSent + 2) + "";
            req.Mappings["bytesSent"] = thisPacketLength + "";

            String hack = "last byte sent = " + (_lastByteSent+2 ) + " .... bytesSent = " + thisPacketLength;
            JwUtility.WriteToFile("temp/debug.txt",hack);

            JwUtility.WriteToFile("temp/peterPrettyCool.txt",dataValue);
            JwUtility.DebugOutputStringAsByteArray("temp/peterCool.txt",dataValue);
            JwUtility.WriteToFile("temp/peterPrettyCool.txt",dataValue);

            VmMessageHttpResponse res  = req.Send();

            _lastByteSent += thisPacketLength;

            JwTimestamp endUtcTs = JwTimestamp.CreateNowUtc();
            JwDuration transmitDuration =  endUtcTs.Difference(beginUtcTs);
            MonitorTransmitDuration(transmitDuration);
        }
Пример #14
0
        public void DownloadAccountData(
            String monitorName,
            String command,
            String returnDataVariableName,
            IDictionary<String,String> otherArguments,
            String fileName)
        {
            MonitorBeginFile(monitorName);

            VmMessageHttpRequest req = new VmMessageHttpRequest();

            req.Mappings["command"] = command;
            foreach( String key in otherArguments.Keys) req.Mappings[key] = otherArguments[key];

            VmMessageHttpResponse res  = req.Send();
            JwUtility.WriteToFile(
                fileName,
                res.GetMapping(returnDataVariableName));
        }