Exemple #1
0
        /// <summary>
        /// if succesfull, creates draft with name and gps cordinates.
        /// </summary>
        /// <param name="wigig">wigig data</param>
        /// <param name="regJournal"> registration journal with information abou registration process</param>
        /// <returns></returns>
        private async Task WigigLocalisation(WigigPTMPUnitInfo wigig, RegistrationJournal regJournal)
        {
            HttpResponseMessage response = await httpClient.GetAsync(CtuUrlConstants.CreateWIGIGUrl);

            if (response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                regJournal.ThrownException = new Exceptions.WebServerException("Web ctu did not respond properly.", response.StatusCode);
                return;
            }

            frontEndToken = await ObtainFrontEndToken(response.Content.ReadAsStreamAsync());

            Dictionary <string, string> postContent = new Dictionary <string, string>()
            {
                { "_csrf-frontend", frontEndToken },
                { "list-stations", "my" },
                { "Station[name]", wigig.Name },
                { "Station[lng]", wigig.Longitude.ToString(CultureInfo.GetCultureInfo("en-US")) },
                { "Station[lat]", wigig.Latitude.ToString(CultureInfo.GetCultureInfo("en-US")) },
                { "StationWigig[direction]", wigig.Orientation.ToString() }
            };

            response = await httpClient.PostAsync(CtuUrlConstants.CreateWIGIGUrl, new FormUrlEncodedContent(postContent));

            if (response.StatusCode != HttpStatusCode.OK || !new Regex(@"^/en/station/[0-9]+/2$").IsMatch(response.RequestMessage.RequestUri.LocalPath))
            {
                regJournal.ThrownException = new Exceptions.WebServerException("Web ctu did not respond properly.", response.StatusCode);
            }
            regJournal.RegistrationId = response.RequestMessage.RequestUri.ToString().Split('/')[5];
        }
Exemple #2
0
        /// <summary>
        /// if succesfull, creates draft with name, gps cordinates and azimut.
        /// </summary>
        /// <param name="wigig">wigig data</param>
        /// <param name="regJournal"> registration journal with information abou registration process</param>
        /// <returns></returns>
        private async Task WigigTechnicalSpec(WigigPTMPUnitInfo wigig, RegistrationJournal regJournal)
        {
            string techSpecUrl           = $"{CtuUrlConstants.StationUrl}/{regJournal.RegistrationId}/2";
            HttpResponseMessage response = await httpClient.GetAsync(techSpecUrl);

            if (response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                regJournal.ThrownException = new Exceptions.WebServerException("Web ctu did not respond properly.", response.StatusCode);
                return;
            }
            frontEndToken = await ObtainFrontEndToken(response.Content.ReadAsStreamAsync());

            Dictionary <string, string> postContent = new Dictionary <string, string>()
            {
                { "_csrf-frontend", frontEndToken },
                { "Station[updateStep]", "2" },
                { "StationWigig[eirp_method]", (wigig.Eirp == null)?"auto":"manual" },
                { "StationWigig[eirp]", wigig.Eirp.ToString() },
                { "Station[antenna_volume]", wigig.Volume.ToString() },
                { "Station[power]", wigig.Power.ToString() },
                { "Station[channel_width]", wigig.ChannelWidth.ToString() },
                { "StationWigig[is_ptmp]", (int.Parse(wigig.Volume.ToString()) > 25)?"0":"1" },
                { "Station[hardware_identifier]", (wigig.SerialNumber == string.Empty)?"0":"1" },
                { String.Format("Station[{0}]", (wigig.SerialNumber == string.Empty)?"macAddress":"serialNumber"), (wigig.SerialNumber == string.Empty)?wigig.MAC:wigig.SerialNumber }
            };

            response = await httpClient.PostAsync(response.RequestMessage.RequestUri, new FormUrlEncodedContent(postContent));

            if (response.StatusCode != HttpStatusCode.OK)
            {
                regJournal.ThrownException = new Exceptions.WebServerException("Web ctu did not respond properly.", response.StatusCode);
                return;
            }
        }
Exemple #3
0
        /// <summary>
        ///  Attempts to publish wigig site
        /// </summary>
        /// <param name="wigig">wigig data</param>
        /// <returns>publication journal, marks if publication was succesful or where and why publication stopped</returns>
        public async Task <RegistrationJournal> AddWIGIG_PTP_PTMPConnectionAsync(WigigPTMPUnitInfo wigig)
        {
            RegistrationJournal regJournal = new RegistrationJournal();

            if (wigig == null)
            {
                regJournal.ThrownException = new Exceptions.MissingParameterException("Missing wigig station");
                return(regJournal);
            }
            regJournal.NextPhase();
            await WigigLocalisation(wigig, regJournal);

            if (regJournal.SuccessfullRegistration != RegistrationSuccesEnum.Pending)
            {
                return(regJournal);
            }
            regJournal.NextPhase();
            await WigigTechnicalSpec(wigig, regJournal);

            if (regJournal.SuccessfullRegistration != RegistrationSuccesEnum.Pending)
            {
                return(regJournal);
            }
            regJournal.NextPhase();
            await WigigCollisionAndPublishing(wigig, regJournal);

            if (regJournal.SuccessfullRegistration != RegistrationSuccesEnum.Pending)
            {
                return(regJournal);
            }
            regJournal.NextPhase();
            return(regJournal);
        }
Exemple #4
0
        /// <summary>
        /// updates already exisiting p2p record
        /// </summary>
        /// <param name="p2P">p2p data</param>
        /// <returns>publication journal, marks if publication was succesful or where and why publication stopped</returns>
        public async Task <RegistrationJournal> UpdatePTPConnectionAsync(P2PSite p2P)
        {
            RegistrationJournal regJournal = new RegistrationJournal();

            if (p2P == null)
            {
                regJournal.ThrownException = new Exceptions.MissingParameterException("Missing fixed p2p pair");
                return(regJournal);
            }
            regJournal.RegistrationId = p2P.StationB.CTUId.ToString();
            regJournal.NextPhase();
            HttpResponseMessage response = await httpClient.GetAsync("");

            if (response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                regJournal.ThrownException = new Exceptions.WebServerException("Web ctu did not respond properly.", response.StatusCode);
                return(regJournal);
            }
            frontEndToken = await ObtainFrontEndToken(response.Content.ReadAsStreamAsync());
            await PTPTechnicalSpec(p2P, regJournal);

            if (regJournal.SuccessfullRegistration != RegistrationSuccesEnum.Pending)
            {
                return(regJournal);
            }
            regJournal.NextPhase();
            await PTPCollisionAndPublishing(p2P, regJournal);

            if (regJournal.SuccessfullRegistration != RegistrationSuccesEnum.Pending)
            {
                return(regJournal);
            }
            regJournal.NextPhase();
            return(regJournal);
        }
Exemple #5
0
        /// <summary>
        /// attempts to publish new p2p wirelless site.
        /// </summary>
        /// <param name="p2P">p2p data</param>
        /// <returns>publication journal, marks if publication was succesful or where and why publication stopped</returns>
        public async Task <RegistrationJournal> AddPTPSiteAsync(P2PSite p2P)
        {
            RegistrationJournal regJournal = new RegistrationJournal();

            if (p2P == null)
            {
                regJournal.ThrownException = new Exceptions.MissingParameterException("Missing fixed p2p pair");
                return(regJournal);
            }
            regJournal.NextPhase();
            await PTPLocalisation(p2P, regJournal);

            if (regJournal.SuccessfullRegistration != RegistrationSuccesEnum.Pending)
            {
                return(regJournal);
            }
            regJournal.NextPhase();
            await PTPTechnicalSpec(p2P, regJournal);

            if (regJournal.SuccessfullRegistration != RegistrationSuccesEnum.Pending)
            {
                return(regJournal);
            }
            regJournal.NextPhase();
            await PTPCollisionAndPublishing(p2P, regJournal);

            if (regJournal.SuccessfullRegistration != RegistrationSuccesEnum.Pending)
            {
                return(regJournal);
            }
            regJournal.NextPhase();
            return(regJournal);
        }
Exemple #6
0
        /// <summary>
        /// if succesfull, then p2p is officialy published on ctu, otherwise saved as draft
        /// </summary>
        /// <param name="fpP2P"></param>
        /// <param name="regJournal"></param>
        /// <returns></returns>
        private async Task PTPCollisionAndPublishing(P2PSite fpP2P, RegistrationJournal regJournal)
        {
            string techSpecUrl           = $"{CtuUrlConstants.StationUrl}/{regJournal.RegistrationId}/3";
            HttpResponseMessage response = await httpClient.GetAsync(techSpecUrl);

            if (response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                regJournal.ThrownException = new Exceptions.WebServerException("Web ctu did not respond properly.", response.StatusCode);
                return;
            }
            frontEndToken = await ObtainFrontEndToken(response.Content.ReadAsStreamAsync());

            List <CollisionTableItem> closeStations = await GetFixedPTPStationsFromCollisionTable(await response.Content.ReadAsStringAsync());

            regJournal.CollisionStations = closeStations.Where(x => x.Collision == true).ToList();
            regJournal.CloseStations     = closeStations;

            Dictionary <string, string> postContent = new Dictionary <string, string>()
            {
                { "_csrf-frontend", frontEndToken }
            };

            if (regJournal.CollisionStations.Where((x) => x.Owned == true).Count() == regJournal.CollisionStations.Count && isolationConsent) //collision only with owned stations.
            {
                string declare = $"{CtuUrlConstants.DeclareUrl}/{regJournal.RegistrationId}";
                response = await httpClient.PostAsync(declare, new FormUrlEncodedContent(postContent));

                if (response.StatusCode != HttpStatusCode.OK)
                {
                    regJournal.ThrownException = new Exceptions.WebServerException("Web ctu did not respond properly.", response.StatusCode);
                }
            }
            else if (regJournal.CollisionStations.Count > 0) // collision list contains unowned stations
            {
                regJournal.ThrownException = new Exceptions.CollisionDetectedException();
                return;
            }
            else // no collision ocured
            {
                string publish = $"{CtuUrlConstants.PublishUrl}/{regJournal.RegistrationId}";
                response = await httpClient.PostAsync(publish, new FormUrlEncodedContent(postContent));

                if (response.StatusCode != HttpStatusCode.OK)
                {
                    regJournal.ThrownException = new Exceptions.WebServerException("Web ctu did not respond properly.", response.StatusCode);
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// if succesfull, updates draft with technical specs
        /// </summary>
        /// <param name="fpP2P">fixed p2p data</param>
        /// <param name="regJournal"> registration journal with information abou registration process</param>
        /// <returns></returns>
        private async Task PTPTechnicalSpec(P2PSite fpP2P, RegistrationJournal regJournal)
        {
            string techSpecUrl           = $"{CtuUrlConstants.StationUrl}/{regJournal.RegistrationId}/2";
            HttpResponseMessage response = await httpClient.GetAsync(techSpecUrl);

            if (response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                regJournal.ThrownException = new Exceptions.WebServerException("Web ctu did not respond properly.", response.StatusCode);
                return;
            }

            frontEndToken = await ObtainFrontEndToken(response.Content.ReadAsStreamAsync());

            Dictionary <string, string> postContent = new Dictionary <string, string>()
            {
                { "_csrf-frontend", frontEndToken },
                { "Station[a][updateStep]", "2" },
                { "Station[a][antenna_volume]", fpP2P.StationA.Volume.ToString() },
                { "Station[a][channel_width]", fpP2P.StationA.ChannelWidth.ToString() },
                { "Station[a][power]", fpP2P.StationA.Power.ToString() },
                { "StationFs[a][frequency]", fpP2P.StationA.Frequency.ToString() },
                { "StationFs[a][ratio_signal_interference]", fpP2P.StationA.RSN.ToString() },
                { "Station[a][hardware_identifier]", (fpP2P.StationA.SerialNumber == string.Empty)?"0":"1" },
                { String.Format("Station[a][{0}]", (fpP2P.StationA.SerialNumber == string.Empty)?"macAddress":"serialNumber"), (fpP2P.StationA.SerialNumber == string.Empty)?fpP2P.StationA.MAC:fpP2P.StationA.SerialNumber },
                { "Station[b][updateStep]", "2" },
                { "Station[b][antenna_volume]", fpP2P.StationB.Volume.ToString() },
                { "Station[b][channel_width]", fpP2P.StationB.ChannelWidth.ToString() },
                { "Station[b][power]", fpP2P.StationB.Power.ToString() },
                { "StationFs[b][frequency]", fpP2P.StationB.Frequency.ToString() },
                { "StationFs[b][ratio_signal_interference]", fpP2P.StationB.RSN.ToString() },
                { "Station[b][hardware_identifier]", (fpP2P.StationB.SerialNumber == string.Empty)?"0":"1" },
                { String.Format("Station[b][{0}]", (fpP2P.StationB.SerialNumber == string.Empty)?"macAddress":"serialNumber"), (fpP2P.StationB.SerialNumber == string.Empty)?fpP2P.StationB.MAC:fpP2P.StationB.SerialNumber }
            };

            response = await httpClient.PostAsync(response.RequestMessage.RequestUri, new FormUrlEncodedContent(postContent));

            if (response.StatusCode != HttpStatusCode.OK)
            {
                regJournal.ThrownException = new Exceptions.WebServerException("Web ctu did not respond properly.", response.StatusCode);
            }
        }