Example #1
0
 /// <summary>
 /// gets a scan request via app or website, tries to start the scan and returns a status string
 /// </summary>
 /// <param name="EventArgs">the app request package</param>
 /// <returns>if request successful or not</returns>
 string _Webservice_OnAppScanrequestEvent(AppRequestObject EventArgs)
 {
     try
     {
         return(this.StartScanAll(Config.ServerConfigManager._ServerConfigObject.serverAlgorithmConfig.amountOfFrames, RequestType.scan));
     }
     catch (Exception ex) { return(ex.Message); }
 }
        /// <summary>
        /// gets fired when the server recieves a scan request from a mobile client
        /// </summary>
        /// <param name="message">the input stream</param>
        /// <returns>status string wether succeeded or not</returns>
        public String responseAppRequest(Stream message)
        {
            XmlSerializer    serializer = new XmlSerializer(typeof(AppRequestObject));
            AppRequestObject aro        = (AppRequestObject)serializer.Deserialize(message);

            LogManager.writeLogDebug("[Webservice] App Request recieved from " + aro.clientAddress);

            String s = OnAppScanrequestEvent(aro);

            return(s);
        }
Example #3
0
        /// <summary>
        /// starts an apprequest towards the server
        /// </summary>
        /// <param name="pTargetIP">target ip</param>
        /// <param name="pAppRequestObject">app request object</param>
        public String startAppRequest(String pTargetIP, AppRequestObject pAppRequestObject)
        {
            Task <String> t = new Task <string>(() => sendRequestThreadARO(@"http://" + pTargetIP + @"/APPREQUEST", pAppRequestObject, 5000));

            t.ContinueWith(TaskFaultedHandler, TaskContinuationOptions.OnlyOnFaulted);
            t.Start();

            t.Wait();
            if (t.IsCompleted)
            {
                return(t.Result);
            }
            else
            {
                return(t.Exception.InnerException.Message);
            }
        }
Example #4
0
        String sendRequestThreadARO(String pTargetIP, AppRequestObject pAro, int timeout)
        {
            try
            {
                WebRequest request = WebRequest.Create(pTargetIP);
                request.Method  = "POST";
                request.Timeout = timeout;

                XmlSerializer serializer    = new XmlSerializer(typeof(AppRequestObject));
                Stream        requestStream = request.GetRequestStream();
                serializer.Serialize(requestStream, pAro);
                requestStream.Close();

                WebResponse  response = request.GetResponse();
                StreamReader reader   = new StreamReader(response.GetResponseStream());
                String       s        = reader.ReadToEnd();

                requestStream.Close();
                return(s);
            }
            catch (Exception ex) { throw; }
        }
Example #5
0
 /// <summary>
 /// gets called when a mobile app requests a scan
 /// </summary>
 /// <param name="EventArgs">app request object for remote requesting</param>
 /// <returns>a status string if request was successful or not</returns>
 String ServerDefinition_OnAppScanrequestEvent(AppRequestObject EventArgs)
 {
     return(OnAppScanrequestEvent(EventArgs));
 }