/// <summary> /// Builds MVPD Registration Array /// </summary> /// <param name="xmlNodeList"> xml node list</param> /// <param name="wsdba">White Space DBA Name</param> /// <param name="namespacemanager">XML name space manager</param> /// <returns>MVPDRegistration array</returns> private MVPDRegistration[] BuildMVPDRegistrations(XmlNodeList xmlNodeList, string wsdba, XmlNamespaceManager namespacemanager) { MVPDRegistration[] mvpdRegistrations; try { // MVPVD Registrations processing this.logger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "Begin " + "SyncManager.ParseResponseXML - MVPDRegistrations serialization Started"); mvpdRegistrations = new MVPDRegistration[xmlNodeList.Count]; for (int regindex = 0; regindex < xmlNodeList.Count; regindex++) { MVPDRegistration mvpdRegn = new MVPDRegistration(); this.regbuilder.BuildEntity(mvpdRegn, xmlNodeList[regindex], namespacemanager); mvpdRegn.WSDBA = wsdba; // xmlNodeList.SelectSingleNode("//ren:RegistrationRecordEnsemble/ren:EnsembleDescription/ren:Registrar", namespaceManager).InnerText; mvpdRegn.Timestamp = DateTime.Now; mvpdRegn.RowKey = mvpdRegn.Disposition.RegId; mvpdRegn.PartitionKey = mvpdRegn.WSDBA; mvpdRegn.SerializeObjectsToJston(); mvpdRegistrations[regindex] = mvpdRegn; } } catch { throw; } return(mvpdRegistrations); }
public IEnumerable <MVPDRegistration> GetMvpdRegistrations(string userId) { List <MVPDRegistration> registrations = new List <MVPDRegistration>(); object lockobject = new object(); var query = new TableQuery <DynamicTableEntity>(); List <string> columns = new List <string>(); columns.Add("MVPDRegDisposition"); columns.Add("MVPDRegistrant"); columns.Add("MVPDContact"); columns.Add("MVPDLocation"); columns.Add("MVPDChannel"); columns.Add("MVPDTransmitLocation"); columns.Add("UserId"); query.Select(columns); string registrationTableName = Microsoft.Whitespace.Common.Utils.GetRegionalTableName(Microsoft.Whitespace.Entities.Constants.MVPDRegistrationTableName); var results = this.azureTableOperations.GetTableEntityProjection(registrationTableName, query); if (results != null && results.Count() > 0) { if (!string.IsNullOrEmpty(userId)) { results = results.Where(x => x.Properties["UserId"].StringValue == userId); } Parallel.ForEach( results, result => { var mvpdRegistration = new MVPDRegistration { MVPDRegDisposition = result.Properties["MVPDRegDisposition"].StringValue, MVPDRegistrant = result.Properties["MVPDRegistrant"].StringValue, MVPDContact = result.Properties["MVPDContact"].StringValue, MVPDLocation = result.Properties["MVPDLocation"].StringValue, MVPDChannel = result.Properties["MVPDChannel"].StringValue, MVPDTransmitLocation = result.Properties["MVPDTransmitLocation"].StringValue, UserId = result.Properties["UserId"].StringValue, PartitionKey = result.PartitionKey, RowKey = result.RowKey, ETag = result.ETag }; lock (lockobject) { registrations.Add(mvpdRegistration); } }); } return(registrations); }
/// <summary> /// parses the response xml received as poll response. /// </summary> /// <param name="adminName">Indicates admin name </param> /// <param name="pollResponse">response xml string</param> /// <param name="key">public key of the administrator</param> private void ParseResponseXML(string adminName, string pollResponse, string key) { string wsdba = null; LPAuxRegistration[] lpauxRegistrations = null; MVPDRegistration[] mvpdRegistrations = null; TempBASRegistration[] tempBasRegistrations = null; FixedTVBDRegistration[] fixedTVBDRegistrations = null; TVReceiveSiteRegistration[] tvreceiveSiteRegistrtions = null; this.logger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "WSDBA:" + adminName + ", Begin - dbSyncManager ParseResponseXML()"); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.PreserveWhitespace = true; xmlDoc.LoadXml(pollResponse); XmlNodeList regNodes = null; XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xmlDoc.NameTable); namespaceManager.AddNamespace("vcard", Constants.VCardXmlns); namespaceManager.AddNamespace("ical", Constants.ICalXmlns); namespaceManager.AddNamespace("gml", Constants.GMLXmlns); namespaceManager.AddNamespace("ren", xmlDoc.DocumentElement.NamespaceURI); if (!this.IsXMLSignatureValid(xmlDoc, key)) { this.logger.Log(TraceEventType.Error, LoggingMessageId.DBSyncPollerGenericMessage, "WSDBA:" + adminName + ", SyncManager.ParseResponseXML - XML signature mismatched and not verified with the certificate. please check the xml file received."); throw new CryptographicException("Xml signature is not matching."); } else if (!this.IsXmlValidWithSchema(xmlDoc)) { this.logger.Log(TraceEventType.Error, LoggingMessageId.DBSyncPollerGenericMessage, "WSDBA:" + adminName + ", SyncManager.ParseResponseXML - XML file is invalid. please check the xml file received."); throw new XmlException("Xml file schema validaion failed."); } else { try { this.logger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "WSDBA:" + adminName + ", Begin " + "SyncManager.ParseResponseXML - LP-AuxRegistrations serialization Started"); wsdba = xmlDoc.SelectSingleNode("//ren:RegistrationRecordEnsemble/ren:EnsembleDescription/ren:Registrar", namespaceManager).InnerText; // lpAuxRegistrations processing. regNodes = xmlDoc.SelectNodes("//ren:Registration[ren:registrationType='LP-Aux_Registration']", namespaceManager); lpauxRegistrations = new LPAuxRegistration[regNodes.Count]; if (regNodes != null && regNodes.Count > 0) { lpauxRegistrations = this.BuildLPAuxRegistrations(regNodes, wsdba, namespaceManager); } this.logger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "WSDBA:" + adminName + ", End " + "SyncManager.ParseResponseXML - LP-AuxRegistrations serialization Completed"); // MVPD Registrations processing this.logger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "WSDBA:" + adminName + ", Begin " + "SyncManager.ParseResponseXML - MVPD Registration serialization Started"); regNodes = null; regNodes = xmlDoc.SelectNodes("//ren:Registration[ren:registrationType='MVPD_Registration']", namespaceManager); mvpdRegistrations = new MVPDRegistration[regNodes.Count]; if (regNodes != null && regNodes.Count > 0) { mvpdRegistrations = this.BuildMVPDRegistrations(regNodes, wsdba, namespaceManager); } this.logger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "WSDBA:" + adminName + ", End " + "SyncManager.ParseResponseXML - MVPD Registration serialization completed"); // Temp Bas Registraions Processing this.logger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "WSDBA:" + adminName + ", Begin " + "SyncManager.ParseResponseXML - Temp Bas Registration serialization Started"); regNodes = null; regNodes = xmlDoc.SelectNodes("//ren:Registration[ren:registrationType='Temp_BAS_Registration']", namespaceManager); tempBasRegistrations = new TempBASRegistration[regNodes.Count]; if (regNodes != null && regNodes.Count > 0) { tempBasRegistrations = this.BuildTempBASRegistration(regNodes, wsdba, namespaceManager); } this.logger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "WSDBA:" + adminName + ", End " + "SyncManager.ParseResponseXML - Temp Bas Registration serialization Completed"); // Fixed TVBD Registraions Processing this.logger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "WSDBA:" + adminName + ", Begin " + "SyncManager.ParseResponseXML - Fixed TVBD Registration serialization Started"); regNodes = null; regNodes = xmlDoc.SelectNodes("//ren:Registration[ren:registrationType='Fixed_TVBD_Registration']", namespaceManager); fixedTVBDRegistrations = new FixedTVBDRegistration[regNodes.Count]; if (regNodes != null && regNodes.Count > 0) { fixedTVBDRegistrations = this.BuildFixedTVBDRegistrations(regNodes, wsdba, namespaceManager); } this.logger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "WSDBA:" + adminName + ", End" + "SyncManager.ParseResponseXML - Fixed TVBD Registration serialization Completed"); // TV Receive Site Registrations proceswsing this.logger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "WSDBA:" + adminName + ", Begin " + "SyncManager.ParseResponseXML - TV Receive Site Registration serialization Started"); regNodes = null; regNodes = xmlDoc.SelectNodes("//ren:Registration[ren:registrationType='TV_Receive_Site_Registration']", namespaceManager); tvreceiveSiteRegistrtions = new TVReceiveSiteRegistration[regNodes.Count]; if (regNodes != null && regNodes.Count > 0) { tvreceiveSiteRegistrtions = this.BuildTVSiteReceiveRegistrations(regNodes, wsdba, namespaceManager); } this.logger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "WSDBA:" + adminName + ", Begin " + "SyncManager.ParseResponseXML - TV Receive Site Registration serialization Completed"); } catch { throw; } } try { this.logger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "WSDBA:" + adminName + ", Begin " + "dalcDBSync.Update - Registration saving to azure table started"); this.dalcDbSync.Update(adminName, fixedTVBDRegistrations, lpauxRegistrations, mvpdRegistrations, tvreceiveSiteRegistrtions, tempBasRegistrations, null); this.logger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "WSDBA:" + adminName + ", End " + "dalcDBSync.Update - Registration saving to azure table completed"); } catch (StorageException e) { this.logger.Log(TraceEventType.Error, LoggingMessageId.DBSyncPollerGenericMessage, "dalcDbSync " + "dalcDBSync.Update - Registration saving to azure table got exception :" + e.ToString()); this.auditor.Audit(AuditId.DBSyncPollRequest, AuditStatus.Failure, 0, "dalcDbSync " + "dalcDBSync.Update - Registration saving to azure table got exception :" + e.ToString()); } }
private static mwc.Incumbent GetIncumbent(object incumbent, IncumbentType requestedIncumbentType) { mwc.Incumbent incumbentModel = null; if (incumbent is MVPDRegistration) { MVPDRegistration mvpdRegistration = (MVPDRegistration)incumbent; // TODO: BroadcastStationContour was removed // List<Position> contourPoints = WhitespacesManager.GetContourPoints(mvpdRegistration.BroadcastStationContour); List <Position> contourPoints = new List <Position>(); incumbentModel = new mwc.Incumbent( mvpdRegistration.Channel.CallSign, mvpdRegistration.ChannelNumber, contourPoints, null, requestedIncumbentType, mvpdRegistration.Location, mvpdRegistration.TransmitLocation); } else if (incumbent is TempBASRegistration) { TempBASRegistration tempBasRegistration = (TempBASRegistration)incumbent; // TODO: BroadcastStationContour was removed // List<Position> contourPoints = WhitespacesManager.GetContourPoints(tempBasRegistration.BroadcastStationContour); List <Position> contourPoints = new List <Position>(); incumbentModel = new mwc.Incumbent( tempBasRegistration.Channel.CallSign, tempBasRegistration.ChannelNumber, contourPoints, tempBasRegistration.Event, requestedIncumbentType, tempBasRegistration.RecvLocation, tempBasRegistration.TransmitLocation); } else if (incumbent is LPAuxRegistration) { LPAuxRegistration lpAuxIncumbent = (LPAuxRegistration)incumbent; List <Position> contourPoints = new List <Position>(); if (lpAuxIncumbent.PointsArea != null) { contourPoints = lpAuxIncumbent.PointsArea.ToList(); } else if (lpAuxIncumbent.QuadrilateralArea != null) { foreach (QuadrilateralArea area in lpAuxIncumbent.QuadrilateralArea) { contourPoints.Add(area.NEPoint); contourPoints.Add(area.NWPoint); contourPoints.Add(area.SEPoint); contourPoints.Add(area.SWPoint); } } // TODO: How to get ReceiveLocation for LPAuxRegistration entity. incumbentModel = new mwc.Incumbent( lpAuxIncumbent.CallSign.CallSign, lpAuxIncumbent.CallSign.Channel.Value, contourPoints, lpAuxIncumbent.Event, requestedIncumbentType, null, new Location(lpAuxIncumbent.Latitude, lpAuxIncumbent.Longitude)); } //// TODO: Logic to create Incumbent object for TV_US incumbent type, as now not sure what Object type to be compare with. return(incumbentModel); }
/// <summary> /// Build MVPD Registration Xml Node /// </summary> /// <param name="node"> Xml Node </param> /// <param name="mvpdRegistration"> MVPD Registration </param> /// <param name="namespaceManager"> Namespace Manager </param> public static void BuildMVPDRegistrationXmlNode(XmlNode node, MVPDRegistration mvpdRegistration, XmlNamespaceManager namespaceManager) { mvpdRegistration.DeSerializeObjectsFromJson(); // disposition if (mvpdRegistration.Disposition != null) { node.SelectSingleNode("//ren:MVPD_Registration/ren:RegistrationDisposition/ren:RegistrationDate", namespaceManager).InnerText = mvpdRegistration.Disposition.RegDate.ToString(); node.SelectSingleNode("//ren:MVPD_Registration/ren:RegistrationDisposition/ren:RegID", namespaceManager).InnerText = mvpdRegistration.Disposition.RegId; node.SelectSingleNode("//ren:MVPD_Registration/ren:RegistrationDisposition/ren:Action", namespaceManager).InnerText = mvpdRegistration.Disposition.Action.ToString(); } // organization if (mvpdRegistration.Registrant.Org != null) { node.SelectSingleNode("//ren:MVPD_Registration/ren:mvpdRegistrant/vcard:properties/vcard:org/vcard:text", namespaceManager).InnerText = mvpdRegistration.Registrant.Org.OrganizationName; } // Formatted Name if (mvpdRegistration.Contact != null && mvpdRegistration.Contact.FN != null) { node.SelectSingleNode("//ren:MVPD_Registration/ren:mvpdContact/vcard:properties/vcard:fn/vcard:text", namespaceManager).InnerText = mvpdRegistration.Contact.FN.PrefText; } // Address if (mvpdRegistration.Contact != null && mvpdRegistration.Contact.Address != null) { node.SelectSingleNode("//ren:MVPD_Registration/ren:mvpdContact/vcard:properties/vcard:adr/vcard:street/vcard:text", namespaceManager).InnerText = mvpdRegistration.Contact.Address.Street; node.SelectSingleNode("//ren:MVPD_Registration/ren:mvpdContact/vcard:properties/vcard:adr/vcard:locality/vcard:text", namespaceManager).InnerText = mvpdRegistration.Contact.Address.Locality; node.SelectSingleNode("//ren:MVPD_Registration/ren:mvpdContact/vcard:properties/vcard:adr/vcard:region/vcard:text", namespaceManager).InnerText = mvpdRegistration.Contact.Address.Region; node.SelectSingleNode("//ren:MVPD_Registration/ren:mvpdContact/vcard:properties/vcard:adr/vcard:code/vcard:text", namespaceManager).InnerText = mvpdRegistration.Contact.Address.Code; node.SelectSingleNode("//ren:MVPD_Registration/ren:mvpdContact/vcard:properties/vcard:adr/vcard:country/vcard:text", namespaceManager).InnerText = mvpdRegistration.Contact.Address.Country; } // Email if (mvpdRegistration.Contact != null && mvpdRegistration.Contact.Email != null) { node.SelectSingleNode("//ren:MVPD_Registration/ren:mvpdContact/vcard:properties/vcard:email/vcard:text", namespaceManager).InnerText = mvpdRegistration.Contact.Email[0].EmailAddress; } // Telephone if (mvpdRegistration.Contact != null && mvpdRegistration.Contact.Telephone != null) { node.SelectSingleNode("//ren:MVPD_Registration/ren:mvpdContact/vcard:properties/vcard:tel/vcard:text", namespaceManager).InnerText = mvpdRegistration.Contact.Telephone[0].TelephoneNumber; } // MVPD Location if (mvpdRegistration.Location != null) { node = BuildLocation(node, mvpdRegistration.TransmitLocation, namespaceManager, "//ren:MVPD_Registration/ren:mvpdLocation/"); } // Channel if (mvpdRegistration.Channel != null) { if (mvpdRegistration.Channel.Channel != null) { node.SelectSingleNode("//ren:MVPD_Registration/ren:mvpdChannel/ren:ustChannel", namespaceManager).InnerText = mvpdRegistration.Channel.Channel.Value.ToString(); } else { XmlNode nodeChannel = node.SelectSingleNode("//ren:Temp_BAS_Registration/ren:tbasChannel/ren:ustChannel", namespaceManager); node.SelectSingleNode("//ren:Temp_BAS_Registration/ren:tbasChannel", namespaceManager).RemoveChild(nodeChannel); } if (mvpdRegistration.Channel.CallSign != null) { node.SelectSingleNode("//ren:MVPD_Registration/ren:mvpdChannel/ren:ustCallSign", namespaceManager).InnerText = mvpdRegistration.Channel.CallSign.ToString(); } } // Xmitter if (mvpdRegistration.TransmitLocation != null) { node = BuildLocation(node, mvpdRegistration.TransmitLocation, namespaceManager, "//ren:MVPD_Registration/ren:mvpdXmiterLocation/"); } }
/// <summary> /// constructs the MVPDRegistration entity. /// </summary> /// <param name="mvpdRegEntity">LPAuxRegistration Entity to be constructed.</param> /// <param name="xmlNode">XML Node of the Registration</param> /// <param name="namespaceManager">namespace manager for xml name spaces</param> public void BuildEntity(MVPDRegistration mvpdRegEntity, XmlNode xmlNode, XmlNamespaceManager namespaceManager) { this.syncLogger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "Begin RegistrationEntityBuilder.BuildEntity for MVPD Registration"); // Common Serialization XmlNode node = null; this.syncLogger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "Begin Build MVPD Registration Entity"); // build Registration disposition object RegistrationDisposition regDisposition = new RegistrationDisposition(); Utils.DeserializeXMLToObject(ref regDisposition, xmlNode.SelectSingleNode("ren:MVPD_Registration/ren:RegistrationDisposition", namespaceManager).OuterXml); mvpdRegEntity.Disposition = regDisposition; // eamil node = xmlNode.SelectSingleNode("ren:MVPD_Registration/ren:mvpdContact/vcard:properties/vcard:email", namespaceManager); if (node != null) { mvpdRegEntity.Contact.Email = this.BuildEamils(xmlNode.SelectNodes("ren:MVPD_Registration/ren:mvpdContact/vcard:properties/vcard:email", namespaceManager)); } // address node = null; node = xmlNode.SelectSingleNode("ren:MVPD_Registration/ren:mvpdContact/vcard:properties/vcard:adr", namespaceManager); if (node != null) { mvpdRegEntity.Contact.Address = this.BuildAddressEntity(node, namespaceManager); } // Registrant's org node = null; node = xmlNode.SelectSingleNode("ren:MVPD_Registration/ren:mvpdRegistrant/vcard:properties/vcard:org", namespaceManager); if (node != null) { Entities.Versitcard.Organization org = new Entities.Versitcard.Organization(); Utils.DeserializeXMLToObject(ref org, node.OuterXml); mvpdRegEntity.Registrant.Org = org; } // Telephones node = null; node = xmlNode.SelectSingleNode("ren:MVPD_Registration/ren:mvpdContact/vcard:properties/vcard:tel", namespaceManager); if (node != null) { mvpdRegEntity.Contact.Telephone = this.BuildTelephones(xmlNode.SelectNodes("ren:MVPD_Registration/ren:mvpdContact/vcard:properties/vcard:tel", namespaceManager)); } // Time zone node = null; node = xmlNode.SelectSingleNode("ren:MVPD_Registration/ren:mvpdEvent/ren:presentationTime/ren:tzname", namespaceManager); if (node != null) { mvpdRegEntity.Contact.TimeZone = node.InnerText; } // Title node = null; node = xmlNode.SelectSingleNode("ren:MVPD_Registration/ren:presentationTime/vcard:title", namespaceManager); if (node != null) { Entities.Versitcard.Title title = new Entities.Versitcard.Title(); Utils.DeserializeXMLToObject(ref title, node.OuterXml); mvpdRegEntity.Contact.Title = title; } // MVPD Channel serialization node = null; node = xmlNode.SelectSingleNode("ren:MVPD_Registration/ren:mvpdLocation", namespaceManager); if (node != null) { mvpdRegEntity.Location.Latitude = Convert.ToDouble(node.SelectSingleNode("//ren:locLatitude", namespaceManager).InnerText); mvpdRegEntity.Location.Longitude = Convert.ToDouble(node.SelectSingleNode("//ren:locLongitude", namespaceManager).InnerText); mvpdRegEntity.Location.Datum = node.SelectSingleNode("//ren:locDatum", namespaceManager).InnerText; RadiationCenter radiationCenter = new RadiationCenter(); Utils.DeserializeXMLToObject(ref radiationCenter, node.SelectSingleNode("//ren:locRadiationCenter", namespaceManager).OuterXml); mvpdRegEntity.Location.RadiationCenter = radiationCenter; } // mvpd Channel serialization node = null; node = xmlNode.SelectSingleNode("ren:MVPD_Registration/ren:mvpdChannel", namespaceManager); if (node != null) { mvpdRegEntity.Channel.Channel = Convert.ToInt32(node.SelectSingleNode("//ren:ustChannel", namespaceManager).InnerText); mvpdRegEntity.Channel.CallSign = node.SelectSingleNode("//ren:ustCallSign", namespaceManager).InnerText; } // mvpd transmit location serialiation node = null; node = xmlNode.SelectSingleNode("ren:MVPD_Registration/ren:mvpdXmiterLocation", namespaceManager); if (node != null) { XElement element = XElement.Parse(node.OuterXml); var curnamespace = element.GetDefaultNamespace(); mvpdRegEntity.TransmitLocation.Latitude = element.Descendants(XName.Get("locLatitude", curnamespace.NamespaceName)).FirstOrDefault().Value.ToDouble(); mvpdRegEntity.TransmitLocation.Longitude = element.Descendants(XName.Get("locLongitude", curnamespace.NamespaceName)).FirstOrDefault().Value.ToDouble(); mvpdRegEntity.TransmitLocation.Datum = element.Descendants(XName.Get("locDatum", curnamespace.NamespaceName)).FirstOrDefault().Value; RadiationCenter radiationCenter = new RadiationCenter(); Utils.DeserializeXMLToObject(ref radiationCenter, node.SelectSingleNode("//ren:locRadiationCenter", namespaceManager).OuterXml); mvpdRegEntity.TransmitLocation.RadiationCenter = radiationCenter; } this.syncLogger.Log(TraceEventType.Information, LoggingMessageId.DBSyncPollerGenericMessage, "End Build MVPD Registration Entity"); }