public override void Initialize() { base.Initialize(); LoadCfgData(CfgID); BrainReg = new Regulator(BrainRegIntervel + UnityEngine.Random.Range(-0.3f, 0.30f)); SensorReg = new Regulator(SensorRegIntervel + UnityEngine.Random.Range(-0.3f, 0.30f)); TargetSysReg = new Regulator(TargetSysRegIntervel + UnityEngine.Random.Range(-0.5f, 0.10f)); Brain = new SoldierThink(this, 1); FSM = new FSMSoldierStateMachine(this); Sensor = new SimSensor <BaseSoldier>(this); Sensor.Range = AlertRadius; Sensor.Initialize(); CombatCom = GetComponent <CombatComponent>(); TargetSys = new TargetSystem(this); TargetSys.OnTargetGet = OnTargetGet; Memory.AddLocation("Work", WorkPlace); }
public override XElement Process(RegulatorActionItemQueryArguments args) { Regulator regulator = null; TransactionScope.WriteQueryArguments(args); if (args.RegulatorCode.HasValue) { regulator = Repository.Regulators.GetByEDTIdentityKey(args.RegulatorCode.Value); if (regulator == null) { throw new Exception("The specified RegulatorCode \"" + args.RegulatorCode + "\" is invalid."); } TransactionScope.Connect(regulator); } var data = Repository.Events.SearchActionItems(args.RequestedOnStart, args.RequestedOnEnd, args.CERSID, organizationCode: args.OrganizationCode, typeID: args.TypeID, completed: args.Completed); RegulatorActionItemQueryXmlSerializer serializer = new RegulatorActionItemQueryXmlSerializer(Repository); XElement result = serializer.Serialize(TransactionScope.Transaction, data); TransactionScope.Complete(EDTTransactionStatus.Accepted); try { TransactionScope.SaveXml(result, EDTTransactionXmlDirection.Outbound); } catch { } return(result); }
public CameraController(ServerService serverService, Regulator regulator) { this.serverService = serverService; Regulator = regulator; observers = new HashSet <Helpers.IObserver <Position> >(); path = new Queue <Point>(); Theta = -1; // Not Set }
public BaseWeapon(WeaponConfig data) { ID = IDAllocator.Instance.GetID(); BulletCfgID = data.BulletCfgID; Rate = data.Rate; Range = data.Range; //data.Prefab; UseRate = new Regulator(Rate); }
public void Connect(Regulator regulator) { if (Transaction == null) { throw new InvalidOperationException("Transaction is required."); } regulator.CheckNull("regulator"); Repository.RegulatorEDTTransactions.EnsureExists(regulator, Transaction); }
public override void Initialize() { base.Initialize(); MonthSeconds = GameDateTime.Instance.SecondPerDay * MonthDays; //BenefitReg = new Regulator(1.0f / MonthSeconds); BenefitReg = new Regulator(3.0f); }
public override XElement Process(RegulatorOrganizatonQueryAdapterArguments args) { Regulator regulator = null; TransactionScope.WriteQueryArguments(args); if (args.RegulatorCode != null) { regulator = Repository.Regulators.GetByEDTIdentityKey(args.RegulatorCode.Value); if (regulator == null) { throw new Exception("The specified RegulatorCode \"" + args.RegulatorCode + "\" is invalid."); } TransactionScope.Connect(regulator); } XElement result = null; IEnumerable <OrganizationGridViewModel> organizationData = null; IEnumerable <FacilityGridViewModel> facilityData = null; int total = 0; organizationData = Repository.Organizations.GridSearch( args.OrganizationName, args.OrganizationCode, args.OrganizationHeadquarters, (int)OrganizationStatus.Active, CERSID: args.CERSID, nameSearchOption: StringSearchOption.StartsWith ); if (args.EstablishedSince.HasValue) { organizationData = from d in organizationData where d.CreatedOnDate >= args.EstablishedSince select d; } total = organizationData.Count(); TransactionScope.WriteActivity("Query returned " + total + " Organization(s)"); if (args.IncludeFacilities) { TransactionScope.WriteActivity("Basic facility data requested. Fetching..."); List <int> organizationIds = organizationData.Select(p => p.ID).ToList(); facilityData = Repository.Facilities.GridSearch().Where(p => organizationIds.Contains(p.OrganizationID)).ToList(); } RegulatorOrganizationQueryXmlSerializer serializer = new RegulatorOrganizationQueryXmlSerializer(Repository); result = serializer.Serialize(TransactionScope.Transaction, organizationData, total, facilityData); TransactionScope.Complete(EDTTransactionStatus.Accepted); TransactionScope.SaveXml(result, EDTTransactionXmlDirection.Outbound); return(result); }
void Start() { regulator = new Regulator { MinimumTimeMs = minimumTimeMs, MaximumDelayMs = maximumDelayMs, Mode = mode, DelayDistribution = regulatorDistribution, DistributionCurve = distributionCurve }; }
private string BuildSubmittalLandingText(IEnumerable <FacilitySubmittalElement> fseCollection, bool showPrintButton = false) { StringBuilder html = new StringBuilder(); Regulator reg = null; //Gets a distinct collection of submittals by Regulator var fseByregulators = fseCollection.GroupBy(g => g.GetRegulator().ID).Select(x => x.First()); foreach (var fse in fseByregulators) { reg = fse.GetRegulator(); html.Append(string.Format("You have submitted the following elements on {0} to <b>{1}</b>", fse.UpdatedOn.ToShortDateString(), reg.Name)); html.Append("<br /><br />"); var submittalsForRegulator = fseCollection.Where(f => f.GetRegulator().ID == reg.ID); html.Append("<ul>"); foreach (var subByReg in submittalsForRegulator) { html.Append("<li>"); html.Append(subByReg.SubmittalElement.Name); html.Append("</li>"); } html.Append("</ul>"); html.Append("<br />"); } #region Print All Button if (showPrintButton) { var organizationID = fseByregulators.First().Facility.OrganizationID; var CERSID = fseByregulators.First().Facility.CERSID; var fsID = fseByregulators.First().FacilitySubmittalID; StringBuilder printButtonHtml = new StringBuilder(); var onClickEvent = string.Format("onClick=\"OpenPrintSubmittalElementDocumentsWindow({0},{1},{2}); return false;\"", organizationID, CERSID, fsID); var buttonTitle = "Print Submittal"; var printIcon = Url.Content("~/Content/Bliss/Images/Icons/printer.png"); printButtonHtml.AppendFormat("<div class=\"right\" style=\"padding-top:10px\">"); printButtonHtml.AppendFormat("<a href=\"\" class=\"button\" id=\"printSEDocs\" {0}>", onClickEvent); printButtonHtml.AppendFormat("<span class=\"color\"><span>{0}</span></span>", buttonTitle + " <img alt=\"\" src=\"" + printIcon + "\""); printButtonHtml.AppendFormat("</a> </div>"); html.Append(printButtonHtml); } #endregion Print All Button return(html.ToString()); }
public override void PreInitialize() { base.PreInitialize(); NavAgent = GetComponent <NavMeshAgent>(); NavAgent.speed = MoveSpeed; BrainReg = new Regulator(BrainRegIntervel); FoodReg = new Regulator(FoodIntervel); WorkReg = new Regulator(WorkInterval); }
public ControllerInfo process(TcpClient socket) { var nextCoordianates = new Tuple <int, int>(0, 0); Regulator.road = path; var actualCoordiantes = Helpers.Helpers.fetchFromFrame(serverService.getCoordiantes(socket)); nextCoordianates = Regulator.getCoordinates(actualCoordiantes); Regulator.Theta = Theta; NotifyObservers(actualCoordiantes); return(new ControllerInfo(nextCoordianates.Item1, nextCoordianates.Item2)); }
public override void Initialize() { base.Initialize(); SelfTrans = GetComponent <Transform>(); BrainReg = new Regulator(15.0f); FoodCostReg = new Regulator(0.01f); Brain = new SimWoodBrain(this, 0); SensorReg = new Regulator(10f); TargetSysReg = new Regulator(100.0f); TargetSys = new TargetSystem(this); //WeaponSys = GetComponent<WeaponSystem>(); WeaponSys = new WeaponSystem(this); if (!System.Object.ReferenceEquals(null, WeaponSys)) { WeaponSys.OnWeaponChanged += OnWeaponChanged; } if (HealthbarPrefab) { SimHealthBag = Instantiate(HealthbarPrefab) as GameObject; if (!SimHealthBag) { return; } SimHealthBag.transform.SetParent(UIManager.Instance.HealthBarPanel); Health = SimHealthBag.GetComponent <HealthBar>(); if (!System.Object.ReferenceEquals(null, Health)) { Health.Target = HeadupTrans; OnXueChanged += OnXueChange; } } }
public override XElement Process(RegulatorFacilityTransferQueryArguments args) { Regulator regulator = null; TransactionScope.WriteQueryArguments(args); if (args.RegulatorCode.HasValue) { regulator = Repository.Regulators.GetByEDTIdentityKey(args.RegulatorCode.Value); if (regulator == null) { throw new Exception("The specified RegulatorCode \"" + args.RegulatorCode + "\" is invalid."); } TransactionScope.Connect(regulator); } else { throw new ArgumentException("Missing RegulatorCode", "RegulatorCode"); } int?organizationID = null; if (args.OrganizationCode.HasValue) { var organization = Repository.Organizations.GetByEDTIdentityKey(args.OrganizationCode.Value); if (organization != null) { organizationID = organization.ID; } } var data = Repository.FacilityTransferHistories.GridSearch(args.CERSID, regulator.ID, organizationID, args.OccurredOnStart, args.OccurredOnEnd, args.AssumedOwnershipOnStart, args.AssumedOwnershipOnEnd); RegulatorFacilityTransferQueryXmlSerializer serializer = new RegulatorFacilityTransferQueryXmlSerializer(Repository); XElement result = serializer.Serialize(TransactionScope.Transaction, data.ToList()); TransactionScope.Complete(EDTTransactionStatus.Accepted); TransactionScope.SaveXml(result, EDTTransactionXmlDirection.Outbound); return(result); }
public override void Awake() { base.Awake(); _renderer = GetComponent <Renderer>(); var parameters = Parameters.Instance; SensoryMemory = new SensoryMemory(this, parameters.AgentMemorySpan, parameters.FriendlyFire); TargetingSystem = new TargetingSystem(this); WeaponSystem = new WeaponSystem( this, parameters.AgentReactionTime, parameters.AgentAimAccuracy, parameters.AgentAimPersistenceTime); PathPlanner = GetComponent <PathPlanner>(); MaximumHealth = parameters.AgentMaximumHealth; Health = 10; HitIndicatorTimer = (int)parameters.HitFlashTime; Hit = false; Score = 0; GoalArbitrationRegulator = new Regulator(parameters.AgentGoalAppraisalUpdateFrequency); VisionUpdateRegulator = new Regulator(parameters.AgentVisionUpdateFrequency); TargetSelectionRegulator = new Regulator(parameters.AgentTargetingUpdateFrequency); WeaponSelectionRegulator = new Regulator(parameters.AgentWeaponSelectionFrequency); Brain = new Think(this); FieldOfView = parameters.AgentFieldOfView; _normalMaterial = _renderer.materials; _flashMaterial = CreateFlashMaterial(); }
public override XElement Process(RegulatorFacilityQueryArguments args) { Regulator regulator = null; TransactionScope.WriteQueryArguments(args); if (args.RegulatorCode != null) { regulator = Repository.Regulators.GetByEDTIdentityKey(args.RegulatorCode.Value); if (regulator == null) { throw new Exception("The specified RegulatorCode \"" + args.RegulatorCode + "\" is invalid."); } TransactionScope.Connect(regulator); } XElement result = null; IEnumerable <FacilityQueryResult> data = null; int total = 0; data = Repository.Facilities.EDTFacilityQuery(args.OrganizationCode, args.CERSID, args.RegulatorCode, args.CreatedOnStart, args.CreatedOnEnd, args.Street, args.City, args.ZIP); total = data.Count(); if (total > MaximumResultItems) { data = data.Take(MaximumResultItems); } RegulatorFacilityQueryXmlSerializer serializer = new RegulatorFacilityQueryXmlSerializer(Repository); result = serializer.Serialize(TransactionScope.Transaction, data, total); TransactionScope.Complete(EDTTransactionStatus.Accepted); TransactionScope.SaveXml(result, EDTTransactionXmlDirection.Outbound); return(result); }
public void TriggerActionEnd(Regulator.SDK.RegexActionTypes action,object result) { switch (action) { case RegexActionTypes.Match: if(MatchEnded!=null) { MatchEnded(this,(MatchCollection)result); } break; case RegexActionTypes.Split: if(SplitEnded!=null) { SplitEnded(this,(string[])result); } break; case RegexActionTypes.Replace: if(ReplaceEnded!=null) { ReplaceEnded(this,(string)result); } break; default: ; break; } }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as RegulatedAuthorization; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (Identifier != null) { dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy()); } if (Subject != null) { dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy(); } if (Type != null) { dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy(); } if (Description != null) { dest.Description = (Hl7.Fhir.Model.Markdown)Description.DeepCopy(); } if (Region != null) { dest.Region = new List <Hl7.Fhir.Model.CodeableConcept>(Region.DeepCopy()); } if (Status != null) { dest.Status = (Hl7.Fhir.Model.CodeableConcept)Status.DeepCopy(); } if (StatusDateElement != null) { dest.StatusDateElement = (Hl7.Fhir.Model.FhirDateTime)StatusDateElement.DeepCopy(); } if (ValidityPeriod != null) { dest.ValidityPeriod = (Hl7.Fhir.Model.Period)ValidityPeriod.DeepCopy(); } if (Indication != null) { dest.Indication = (Hl7.Fhir.Model.DataType)Indication.DeepCopy(); } if (IntendedUse != null) { dest.IntendedUse = (Hl7.Fhir.Model.CodeableConcept)IntendedUse.DeepCopy(); } if (Basis != null) { dest.Basis = new List <Hl7.Fhir.Model.CodeableConcept>(Basis.DeepCopy()); } if (RelatedDate != null) { dest.RelatedDate = new List <Hl7.Fhir.Model.RegulatedAuthorization.RelatedDateComponent>(RelatedDate.DeepCopy()); } if (JurisdictionalAuthorization != null) { dest.JurisdictionalAuthorization = new List <Hl7.Fhir.Model.ResourceReference>(JurisdictionalAuthorization.DeepCopy()); } if (Holder != null) { dest.Holder = (Hl7.Fhir.Model.ResourceReference)Holder.DeepCopy(); } if (Regulator != null) { dest.Regulator = (Hl7.Fhir.Model.ResourceReference)Regulator.DeepCopy(); } if (Case != null) { dest.Case = (Hl7.Fhir.Model.RegulatedAuthorization.CaseComponent)Case.DeepCopy(); } return(dest); }
///<summary> ///constructor ///</summary> ///<param name="entitySceneObject"></param> ///<param name="pos"></param> public BotEntity(IEntitySceneObject entitySceneObject, Vector2 pos) : base(entitySceneObject, pos, GameManager.GameManager.Instance.Parameters.BotScale, Vector2.Zero, GameManager.GameManager.Instance.Parameters.BotMaxSpeed, Vector2.One, // initial heading GameManager.GameManager.Instance.Parameters.BotMass, Vector2.Normalize(Vector2.One)* GameManager.GameManager.Instance.Parameters.BotScale, GameManager.GameManager.Instance.Parameters.BotMaxHeadTurnRate, GameManager.GameManager.Instance.Parameters.BotMaxForce) { _maxHealth = GameManager.GameManager.Instance.Parameters.BotMaxHealth; CurrentHealth = 10; _pathPlanner = null; _steering = null; _brain = null; NumUpdatesHitPersistent = (int) GameManager.GameManager.Instance.Parameters.HitFlashTime; Hit = false; Score = 0; _status = Statuses.Spawning; IsPossessed = false; _fieldOfView = MathHelper.ToRadians(GameManager.GameManager.Instance.Parameters.BotFOV); _maxNormalSpeed = GameManager.GameManager.Instance.Parameters.BotMaxSpeed; _maxSwimmingSpeed = GameManager.GameManager.Instance.Parameters.BotMaxSwimmingSpeed; _maxCrawlingSpeed = GameManager.GameManager.Instance.Parameters.BotMaxCrawlingSpeed; EntityType = EntityTypes.Bot; //a bot starts off facing in the direction it is heading Facing = Heading; //create the navigation module _pathPlanner = new PathPlanner(this); //create the steering behavior class _steering = new Steering.Steering(this); //create the regulators _weaponSelectionRegulator = new Regulator( GameManager.GameManager.Instance.Parameters.BotWeaponSelectionFrequency); _goalArbitrationRegulator = new Regulator( GameManager.GameManager.Instance.Parameters.BotGoalAppraisalUpdateFreq); _targetSelectionRegulator = new Regulator( GameManager.GameManager.Instance.Parameters.BotTargetingUpdateFreq); _triggerTestRegulator = new Regulator( GameManager.GameManager.Instance.Parameters.BotTriggerUpdateFreq); _visionUpdateRegulator = new Regulator( GameManager.GameManager.Instance.Parameters.BotVisionUpdateFreq); //create the goal queue _brain = new Think(this); //create the targeting system _targetingSystem = new TargetingSystem(this); _weaponSystem = new WeaponSystem(this, GameManager.GameManager.Instance.Parameters.BotReactionTime, GameManager.GameManager.Instance.Parameters.BotAimAccuracy, GameManager.GameManager.Instance.Parameters.BotAimPersistence); _sensoryMemory = new SensoryMemory( this, GameManager.GameManager.Instance.Parameters.BotMemorySpan); _navigationalMemory = new NavigationalMemory(this, GameManager.GameManager.Instance.Parameters.NavigationMemorySpan); //temp debbugging code _navigationalMemory.DumpFrequency = 10000; // 10 seconds FoundTriggers = new FoundTriggerList(Team); _logPrefixText = String.Format("[{0,-8}] [{1,17}.", Name, "BotEntity"); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as MedicinalProductAuthorization; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (Identifier != null) { dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy()); } if (Subject != null) { dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy(); } if (Country != null) { dest.Country = new List <Hl7.Fhir.Model.CodeableConcept>(Country.DeepCopy()); } if (Jurisdiction != null) { dest.Jurisdiction = new List <Hl7.Fhir.Model.CodeableConcept>(Jurisdiction.DeepCopy()); } if (Status != null) { dest.Status = (Hl7.Fhir.Model.CodeableConcept)Status.DeepCopy(); } if (StatusDateElement != null) { dest.StatusDateElement = (Hl7.Fhir.Model.FhirDateTime)StatusDateElement.DeepCopy(); } if (RestoreDateElement != null) { dest.RestoreDateElement = (Hl7.Fhir.Model.FhirDateTime)RestoreDateElement.DeepCopy(); } if (ValidityPeriod != null) { dest.ValidityPeriod = (Hl7.Fhir.Model.Period)ValidityPeriod.DeepCopy(); } if (DataExclusivityPeriod != null) { dest.DataExclusivityPeriod = (Hl7.Fhir.Model.Period)DataExclusivityPeriod.DeepCopy(); } if (DateOfFirstAuthorizationElement != null) { dest.DateOfFirstAuthorizationElement = (Hl7.Fhir.Model.FhirDateTime)DateOfFirstAuthorizationElement.DeepCopy(); } if (InternationalBirthDateElement != null) { dest.InternationalBirthDateElement = (Hl7.Fhir.Model.FhirDateTime)InternationalBirthDateElement.DeepCopy(); } if (LegalBasis != null) { dest.LegalBasis = (Hl7.Fhir.Model.CodeableConcept)LegalBasis.DeepCopy(); } if (JurisdictionalAuthorization != null) { dest.JurisdictionalAuthorization = new List <Hl7.Fhir.Model.MedicinalProductAuthorization.JurisdictionalAuthorizationComponent>(JurisdictionalAuthorization.DeepCopy()); } if (Holder != null) { dest.Holder = (Hl7.Fhir.Model.ResourceReference)Holder.DeepCopy(); } if (Regulator != null) { dest.Regulator = (Hl7.Fhir.Model.ResourceReference)Regulator.DeepCopy(); } if (Procedure != null) { dest.Procedure = (Hl7.Fhir.Model.MedicinalProductAuthorization.ProcedureComponent)Procedure.DeepCopy(); } return(dest); }
public XElement Process(Stream stream, int regulatorCode) { Regulator contextRegulator = Repository.Regulators.GetByEDTIdentityKey(regulatorCode); if (contextRegulator == null) { throw new ArgumentException("RegulatorCode does not contain a valid number.", "regulatorCode"); } //Connect the regulator after we verified it exists. TransactionScope.Connect(contextRegulator); //this endpoint supports multiple versions of the schema simultaneously. IXmlSchemaMetadata inputSchemaMetadata = null; IXmlSchemaMetadata outputSchemaMetadata = null; string version = null; RegulatorFacilityCreateResponseXmlSerializer responseSerializer = new RegulatorFacilityCreateResponseXmlSerializer(Repository); //lets default to Trial mode in case the XML is so messed up we can't parse it, and this is obviously less danagerous than //a Commit. RegulatorFacilityCreateMode mode = RegulatorFacilityCreateMode.Trial; //declare the package to be use to inflate the XML. RegulatorXmlObjectPacket <RegulatorFacilityCreateMode, FacilityCreatePackage> package = null; XmlSchemaValidationResult schemaValidationResult = null; var rfcXml = ConvertStreamToXDocument(stream); if (rfcXml != null) { string xml = rfcXml.ToString(); TransactionScope.SaveXml(xml, EDTTransactionXmlDirection.Inbound); TransactionScope.WriteActivity("XML Document is validating..."); //get the root element of the doc (should be named RegulatorFacilityCreate). var rootElement = rfcXml.Root; //try and obtain the targetNamespace var targetNamespace = rootElement.GetDefaultNamespace(); if (string.IsNullOrWhiteSpace(targetNamespace.NamespaceName)) { //couldn't obtain the schema we need because the root node didn't have a default non-prefixed xmlns attribute. //lets see of the document is using prefixes and look for the xmlns:cers="" attribute. targetNamespace = rootElement.GetNamespaceOfPrefix("cers"); } //if we have no targetNamespace then we should not proceed any further. if (targetNamespace == null || targetNamespace.NamespaceName == string.Empty) { TransactionScope.WriteMessage("Unable to resolve the targetNamespace of the received XML data.", EDTTransactionMessageType.Error); throw new Exception("Unable to resolve the targetNamespace of the received XML data."); } //find the metadata for the RegulatorFacilityCreate schema with the specified targetNamespace. inputSchemaMetadata = XmlSchemas.GetSchemaMetdataForNamespace(XmlSchema.RegulatorFacilityCreate, targetNamespace); //XmlSchemas.GetSchemaMetadata( XmlSchema.RegulatorFacilityCreate, version ); if (inputSchemaMetadata == null) { TransactionScope.WriteMessage("Unable to find a RegulatorFacilityCreate schema with the specified namespace: " + targetNamespace.NamespaceName, EDTTransactionMessageType.Error); throw new Exception("Unable to find a RegulatorFacilityCreate schema with the specified version: " + version); } //the outgoing schema version is dependant on the version specified in the input schema. //so parse the version and then look for the appropriate output (response schema). version = targetNamespace.ExtractVersion(); //now try and find the response schema with the version parsed from the targetSchema. outputSchemaMetadata = XmlSchemas.GetSchemaMetadata(XmlSchema.RegulatorFacilityCreateResponse, version); if (outputSchemaMetadata == null) { TransactionScope.WriteMessage("Unable to find a RegulatorFacilityCreateResponse schema with the specified version: " + version, EDTTransactionMessageType.Error); throw new Exception("Unable to find a RegulatorFacilityCreateResponse schema with the specified version: " + version); } schemaValidationResult = xml.IsValidAgainstSchema(inputSchemaMetadata); if (!schemaValidationResult.IsValid) { //make a new package so we have a storage area for the errors to be shipped back in the response xml. package = new RegulatorXmlObjectPacket <RegulatorFacilityCreateMode, FacilityCreatePackage>(); //package is invalid due to schema validation errors, update the transaction status, and write some diagnostic information. //Merge in the schema validation error messages and associate them with the transaction. TransactionScope.WriteActivity("XML Document is not valid against the schema."); package.Packet.Workspace.Messages.Add("XML Document is not valid against the schema.", FacilityOperationMessageType.Error); foreach (var error in schemaValidationResult.Errors) { TransactionScope.WriteMessage("Schema Validation Error: " + error, EDTTransactionMessageType.Error); package.Packet.Workspace.Messages.Add("Schema Validation Error: " + error, FacilityOperationMessageType.Error); } TransactionScope.WriteMessage("XML document does not validate against the schema.", EDTTransactionMessageType.Error); TransactionScope.Complete(EDTTransactionStatus.Rejected); } else { TransactionScope.WriteActivity("XML Document is valid against the schema."); //deserialize the data into the object structure. RegulatorFacilityCreateXmlSerializer serializer = new RegulatorFacilityCreateXmlSerializer(Repository); package = serializer.Deserialize(rfcXml); package.Packet.Version = version; //add in the version 4/1/2014. mode = package.Mode; // error if DataCollectionDate is less than 1970 and greater than today at 11:59 if (package.Packet.CERSPoint != null && package.Packet.CERSPoint.DataCollectionDate != null && (package.Packet.CERSPoint.DataCollectionDate < new DateTime(1970, 1, 1) || package.Packet.CERSPoint.DataCollectionDate > DateTime.Now.AddDays(1).AddTicks(-1))) { package.Packet.Workspace.Messages.Add("DataCollectionDate is out of range.", FacilityOperationMessageType.Error); } if (!package.Packet.HasErrors()) { ServiceManager.Facilities.Create(package.Packet, regulatorCode, mode, true); if (mode == RegulatorFacilityCreateMode.Commit && package.Packet.Workspace.FacilityCreated) { TransactionScope.Connect(package.Packet.Workspace.Facility); } } //if the package had errors, set rejected, otherwise set accepted. if (package.Packet.HasErrors()) { TransactionScope.Complete(EDTTransactionStatus.Rejected); } else { TransactionScope.Complete(EDTTransactionStatus.Accepted); } } } //prepare our output response XML. XElement responseXml = responseSerializer.PreparePackage(TransactionScope.Transaction, outputSchemaMetadata); responseSerializer.AddTransaction(responseXml, TransactionScope.Transaction, mode); //we should always have a package (unless schema validation failed). if (package != null) { //add the result hive to the root node if we created a facility (or virtually did in trial mode) responseSerializer.AddResult(responseXml, package.Packet, mode); //if using the 1/06 schema version... if (!string.IsNullOrWhiteSpace(package.Packet.Version) && (package.Packet.Version.IndexOf("1/06") > -1)) { responseSerializer.AddPotentialDuplicates(responseXml, package.Packet); } } //add the messages generated during the process. responseSerializer.AddMessages(responseXml, package.Packet); TransactionScope.SaveXml(responseXml, EDTTransactionXmlDirection.Outbound); return(responseXml); }
public XElement Process(Stream stream, int regulatorCode) { //make serializers needed RegulatorFacilitySubmittalResponseXmlSerializer responseSerializer = new RegulatorFacilitySubmittalResponseXmlSerializer(Repository); RegulatorFacilitySubmittalActionNotificationXmlSerializer serializer = new RegulatorFacilitySubmittalActionNotificationXmlSerializer(Repository); //contextRegulator is always the regulator this Processor is working under the context of. In this case, the assumption is, this Regulator is //ALWAYS a CUPA. Regulator contextRegulator = Repository.Regulators.GetByEDTIdentityKey(regulatorCode); if (contextRegulator == null) { throw new ArgumentException("RegulatorCode does not contain a valid number.", "regulatorCode"); } TransactionScope.Connect(contextRegulator); XmlSchemaValidationResult schemaValidationResult = null; var rfsanXml = ConvertStreamToXDocument(stream); if (rfsanXml != null) { string xml = rfsanXml.ToString(); TransactionScope.SaveXml(xml, EDTTransactionXmlDirection.Inbound); TransactionScope.WriteActivity("XML Document is validating..."); schemaValidationResult = xml.IsValidAgainstSchema(XmlSchema.RegulatorFacilitySubmittalActionNotification); if (!schemaValidationResult.IsValid) { //package is invalid due to schema validation errors, update the transaction status write some info. //Merge in the schema validation error messages and associate them with the transaction. TransactionScope.WriteActivity("XML Document is not valid against the schema."); foreach (var error in schemaValidationResult.Errors) { TransactionScope.WriteMessage("Schema Validation Error: " + error, EDTTransactionMessageType.Error); } TransactionScope.WriteMessage("XML document does not validate against the schema.", EDTTransactionMessageType.Error); TransactionScope.Complete(EDTTransactionStatus.Rejected); } else { TransactionScope.WriteActivity("XML Document is valid against the schema."); //deserialize the XML into an object graph package. var package = serializer.Deserialize(rfsanXml); TransactionScope.SetEDTClientKey(package.RegulatorTransactionKey); int totalErrorCount = 0; int errorCount = 0; //lets analyze and process each one. foreach (var se in package.Packets) { errorCount = 0; var targetSE = Repository.FacilitySubmittalElements.FindByKey(se.CERSUniqueKey.Value); if (targetSE != null) { //verify the CERSID from the XML matches the FSE if (targetSE.CERSID != se.CERSID.Value) { errorCount++; TransactionScope.WriteMessage("Facility Submittal Element with CERSUniqueKey '" + se.CERSUniqueKey.Value.ToString() + "' does not belong to CERSID '" + se.CERSID.Value + "'.", EDTTransactionMessageType.Error); } //Verify the SubmittalElementID from the XML matches the FSE if (targetSE.SubmittalElementID != (int)se.SubmittalElement.Value) { errorCount++; TransactionScope.WriteMessage("Facility Submittal Element with CERSUniqueKey '" + se.CERSUniqueKey.Value.ToString() + "' is not a Submittal Element of type '" + (int)se.SubmittalElement.Value + "'.", EDTTransactionMessageType.Error); } if (targetSE.SubmittalActionDateTime.HasValue) { //verify the SubmittalActionDateTime on the existing FSE is prior to the SubmittalActionDateTime on the targetFSE (from XML) if (se.ActionOn.Value < targetSE.SubmittalActionDateTime.Value) { TransactionScope.WriteMessage("The SubmittalActionOn value must be greater than the existing SubmittalActionOn value (" + targetSE.SubmittalActionDateTime.Value.ToString() + ") for Submittal Element with CERSUniqueKey " + se.CERSUniqueKey.Value.ToString() + ".", EDTTransactionMessageType.Error); } } //Get the Facility, and make sure it exists first. Facility facility = Repository.Facilities.GetByID(targetSE.CERSID); if (facility != null) { //figure out the CUPA. var CUPARegulator = Repository.Facilities.GetCUPA(facility); if (CUPARegulator != null) { //Ensure that the Facilities CUPA is associated with the CUPA calling this processor. if (contextRegulator.ID != CUPARegulator.ID) { errorCount++; TransactionScope.WriteMessage("Facility Submittal Element with CERSUniqueKey '" + se.CERSUniqueKey.Value.ToString() + "' is assigned to a CUPA the current account is not authorized to submit for.", EDTTransactionMessageType.Error); } } else { errorCount++; TransactionScope.WriteMessage("Cannot identify the CUPA for the Facility Submittal Element with CERSUniqueKey '" + se.CERSUniqueKey.Value.ToString() + "'.", EDTTransactionMessageType.Error); } } else { errorCount++; TransactionScope.WriteMessage("A facility with CERSID '" + targetSE.CERSID + "' cannot be found and therefore Facility Submittal Element with CERSUniqueKey '" + se.CERSUniqueKey.Value.ToString() + "' cannot be updated/found.", EDTTransactionMessageType.Error); } //Get the regulator that is described in the XML as the Regulating body that is changing the submittal action information. var regulator = Repository.Regulators.GetByEDTIdentityKey(se.RegulatorCode.Value); if (regulator != null) { se.TargetRegulator = regulator; } else { errorCount++; TransactionScope.WriteMessage("Facility Submittal Element with CERSUniqueKey '" + se.CERSUniqueKey.Value.ToString() + "' specifies '" + se.RegulatorCode.Value + "' for the RegulatorCode element which is not valid.", EDTTransactionMessageType.Error); } //make sure that NextDueDate is in the future. if (se.NextDueDate != null) { if (se.NextDueDate.Value < DateTime.Now) { errorCount++; TransactionScope.WriteMessage("Facility Submittal Element with CERSUniqueKey '" + se.CERSUniqueKey.Value.ToString() + "' has a NextDueDate of '" + se.NextDueDate.Value + "' which occurs in the past and is not allowed.", EDTTransactionMessageType.Error); } } } else { errorCount++; TransactionScope.WriteMessage("Facility Submittal Element with CERSUniqueKey '" + se.CERSUniqueKey.Value.ToString() + "' was not found.", EDTTransactionMessageType.Error); } if (errorCount == 0) { se.FacilitySubmittalElement = targetSE; } totalErrorCount += errorCount; } if (totalErrorCount > 0) { TransactionScope.WriteActivity("Found " + totalErrorCount + " total error(s) with package. Setting to Rejected."); TransactionScope.Complete(EDTTransactionStatus.Rejected); } else { try { FacilitySubmittalElement fse = null; //all is good, so lets update them all and process it. foreach (var se in package.Packets) { fse = se.FacilitySubmittalElement; if (fse != null) { ServiceManager.BusinessLogic.SubmittalElements.UpdateFacilitySubmittalElementStatus ( fse, se.Status.Value, se.ActionOn, se.Comments, se.NextDueDate, Repository.ContextAccount, se.TargetRegulator.ID, se.AgentName, se.AgentEmail, submittalActionEDTTransaction: TransactionScope.Transaction ); TransactionScope.Connect(fse); } } TransactionScope.WriteActivity("All Facility Submittal Elements (" + package.Packets + ") updated successfully."); TransactionScope.SetStatus(EDTTransactionStatus.Accepted); TransactionScope.SetProcessedOn(); } catch (Exception ex) { TransactionScope.WriteActivity("Errors occurred persisting updates to database.", ex); TransactionScope.Complete(EDTTransactionStatus.ErrorProcessing); } } } } else { TransactionScope.WriteMessage("No package received.", EDTTransactionMessageType.Error); TransactionScope.Complete(EDTTransactionStatus.ErrorProcessing); } XElement responseXml = responseSerializer.PreparePackage(TransactionScope.Transaction); responseSerializer.AddTransaction(responseXml, TransactionScope.Transaction); responseSerializer.AddSummary(responseXml, TransactionScope.Transaction); TransactionScope.SaveXml(responseXml, EDTTransactionXmlDirection.Outbound); return(responseXml); }
public XElement Process(Stream stream, int regulatorCode) { RegulatorFacilityMetadataResponseXmlSerializer responseSerializer = new RegulatorFacilityMetadataResponseXmlSerializer(Repository); Regulator regulator = Repository.Regulators.GetByEDTIdentityKey(regulatorCode); if (regulator == null) { throw new ArgumentException("RegulatorCode does not contain a valid number.", "regulatorCode"); } TransactionScope.Connect(regulator); //declare the package to be use to inflate the XML. RegulatorXmlObjectPacket <RegulatorFacilityMetadataPackage> package = null; XmlSchemaValidationResult schemaValidationResult = null; var rfmXml = ConvertStreamToXDocument(stream); if (rfmXml != null) { string xml = rfmXml.ToString(); TransactionScope.SaveXml(xml, EDTTransactionXmlDirection.Inbound); TransactionScope.WriteActivity("XML Document is validating..."); schemaValidationResult = xml.IsValidAgainstSchema(XmlSchema.RegulatorFacilityMetadata); if (!schemaValidationResult.IsValid) { //package is invalid due to schema validation errors, update the transaction status write some info. //Merge in the schema validation error messages and associate them with the transaction. TransactionScope.WriteActivity("XML Document is not valid against the schema."); foreach (var error in schemaValidationResult.Errors) { TransactionScope.WriteMessage("Schema Validation Error: " + error, EDTTransactionMessageType.Error); } TransactionScope.WriteMessage("XML document does not validate against the schema.", EDTTransactionMessageType.Error); TransactionScope.Complete(EDTTransactionStatus.Rejected); } else { TransactionScope.WriteActivity("XML Document is valid against the schema."); //deserialize the data into the object structure. RegulatorFacilityMetadataXmlSerializer serializer = new RegulatorFacilityMetadataXmlSerializer(Repository); package = serializer.Deserialize(rfmXml); TransactionScope.SetEDTClientKey(package.RegulatorTransactionKey); package.Packet.Workspace.Facility = Repository.Facilities.GetByID(package.Packet.CERSID); if (package.Packet.Workspace.Facility == null) { TransactionScope.WriteMessage("There is no facility with CERSID " + package.Packet.CERSID, EDTTransactionMessageType.Error); package.Packet.Workspace.Messages.Add("There is no facility with CERSID " + package.Packet.CERSID, FacilityOperationMessageType.Error); TransactionScope.Complete(EDTTransactionStatus.Rejected); } else { //get the original FRSE Mappings var originalFRSEMappings = GetOriginalFRSEMappings(package.Packet.CERSID); //merge the XML data into the existing FRSE objects. ServiceManager.Facilities.MergeFacilityRegulatorSubmittalElementCustomMappings(package.Packet, regulator.ID); //generate debug messages so we know what happened here. DetermineFacilityRegulatorSubmittalElementChanges(package, originalFRSEMappings); //merge the CERS Geo data in XML into the object graph. ServiceManager.Facilities.MergeCERSFacilityGeoPoint(package.Packet); //commit the changes to the database. CommitChanges(package); //complete the transaction indicating everything went according to plan. TransactionScope.Complete(EDTTransactionStatus.Accepted); } } } //prepare our output response XML. XElement responseXml = responseSerializer.PreparePackage(TransactionScope.Transaction); responseSerializer.AddTransaction(responseXml, TransactionScope.Transaction); if (package != null) { responseSerializer.AddMessages(responseXml, package.Packet); } TransactionScope.SaveXml(responseXml, EDTTransactionXmlDirection.Outbound); return(responseXml); }
public void ProjectChanged(Regulator.SDK.RegexProject newProject) { // TODO: Add Form1.ProjectChanged implementation }
public void OnInit(Regulator.SDK.AppContext context) { // TODO: Add Form1.OnInit implementation }
public virtual void OnInit(Regulator.SDK.AppContext context) { _context=context; //this.ActiveControl.BackColor=Color.Azure; }
public virtual void ProjectChanged(Regulator.SDK.RegexProject newProject) { _currentProject= newProject; _currentProject.ActionStarted+=new Regulator.SDK.RegexProject.RegexActionStartDelegate(OnProjectActionStarted); _currentProject.MatchEnded+=new Regulator.SDK.RegexProject.RegexMatchEndedDelegate(OnProjectMatchEnded); _currentProject.ReplaceEnded+=new Regulator.SDK.RegexProject.RegexReplaceEndedDelegate(OnProjectReplaceEnded); _currentProject.SplitEnded+=new Regulator.SDK.RegexProject.RegexSplitEndedDelegate(OnProjectSplitEnded); _currentProject.Updated+=new EventHandler(OnProjectUpdated); }
protected override void OnProjectActionStarted(Regulator.SDK.RegexProject sender, Regulator.SDK.RegexActionTypes action) { base.OnProjectActionStarted (sender, action); }
public void TriggerActionStart(Regulator.SDK.RegexActionTypes action) { if(ActionStarted!=null) { ActionStarted(this,action); } }
/// <summary> /// Serialize to a JSON object /// </summary> public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } if (!string.IsNullOrEmpty(ResourceType)) { writer.WriteString("resourceType", (string)ResourceType !); } ((Fhir.R4.Models.DomainResource) this).SerializeJson(writer, options, false); if ((Identifier != null) && (Identifier.Count != 0)) { writer.WritePropertyName("identifier"); writer.WriteStartArray(); foreach (Identifier valIdentifier in Identifier) { valIdentifier.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (Subject != null) { writer.WritePropertyName("subject"); Subject.SerializeJson(writer, options); } if ((Country != null) && (Country.Count != 0)) { writer.WritePropertyName("country"); writer.WriteStartArray(); foreach (CodeableConcept valCountry in Country) { valCountry.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((Jurisdiction != null) && (Jurisdiction.Count != 0)) { writer.WritePropertyName("jurisdiction"); writer.WriteStartArray(); foreach (CodeableConcept valJurisdiction in Jurisdiction) { valJurisdiction.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (Status != null) { writer.WritePropertyName("status"); Status.SerializeJson(writer, options); } if (!string.IsNullOrEmpty(StatusDate)) { writer.WriteString("statusDate", (string)StatusDate !); } if (_StatusDate != null) { writer.WritePropertyName("_statusDate"); _StatusDate.SerializeJson(writer, options); } if (!string.IsNullOrEmpty(RestoreDate)) { writer.WriteString("restoreDate", (string)RestoreDate !); } if (_RestoreDate != null) { writer.WritePropertyName("_restoreDate"); _RestoreDate.SerializeJson(writer, options); } if (ValidityPeriod != null) { writer.WritePropertyName("validityPeriod"); ValidityPeriod.SerializeJson(writer, options); } if (DataExclusivityPeriod != null) { writer.WritePropertyName("dataExclusivityPeriod"); DataExclusivityPeriod.SerializeJson(writer, options); } if (!string.IsNullOrEmpty(DateOfFirstAuthorization)) { writer.WriteString("dateOfFirstAuthorization", (string)DateOfFirstAuthorization !); } if (_DateOfFirstAuthorization != null) { writer.WritePropertyName("_dateOfFirstAuthorization"); _DateOfFirstAuthorization.SerializeJson(writer, options); } if (!string.IsNullOrEmpty(InternationalBirthDate)) { writer.WriteString("internationalBirthDate", (string)InternationalBirthDate !); } if (_InternationalBirthDate != null) { writer.WritePropertyName("_internationalBirthDate"); _InternationalBirthDate.SerializeJson(writer, options); } if (LegalBasis != null) { writer.WritePropertyName("legalBasis"); LegalBasis.SerializeJson(writer, options); } if ((JurisdictionalAuthorization != null) && (JurisdictionalAuthorization.Count != 0)) { writer.WritePropertyName("jurisdictionalAuthorization"); writer.WriteStartArray(); foreach (MedicinalProductAuthorizationJurisdictionalAuthorization valJurisdictionalAuthorization in JurisdictionalAuthorization) { valJurisdictionalAuthorization.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (Holder != null) { writer.WritePropertyName("holder"); Holder.SerializeJson(writer, options); } if (Regulator != null) { writer.WritePropertyName("regulator"); Regulator.SerializeJson(writer, options); } if (Procedure != null) { writer.WritePropertyName("procedure"); Procedure.SerializeJson(writer, options); } if (includeStartObject) { writer.WriteEndObject(); } }
public virtual XElement Process(Stream stream, int regulatorCode) { //contextRegulator is always the regulator this Processor is working under the context of. In this case, the assumption is, this Regulator is //ALWAYS a CUPA. Regulator contextRegulator = Repository.Regulators.GetByEDTIdentityKey(regulatorCode); if (contextRegulator == null) { throw new ArgumentException("RegulatorCode does not contain a valid number.", "regulatorCode"); } TransactionScope.Connect(contextRegulator); ZipFile zipFile = null; XDocument rfsXml = null; if (IsZipPackage(stream)) { //get the zip file. zipFile = ZipFile.Read(stream); if (ValidateZip(zipFile)) { TransactionScope.WriteActivity("The ZipFile passed validation."); //so now that we have validated the zip file's package integrity, lets pull the XML file out //zipFile = ZipFile.Read(stream); rfsXml = ExtractXmlFile(zipFile); } else { TransactionScope.WriteActivity("The ZipFile failed validation."); TransactionScope.WriteMessage("The ZipFile failed validation.", EDTTransactionMessageType.Error); TransactionScope.SetStatus(EDTTransactionStatus.Rejected); } } else { //there is no Zip File, so convert the Stream to XML. rfsXml = ConvertStreamToXDocument(stream); } if (rfsXml != null) { TransactionScope.SaveXml(rfsXml, EDTTransactionXmlDirection.Inbound); } try { if (rfsXml != null && ValidateXml(rfsXml, XmlSchema.RegulatorFacilitySubmittal)) { //at this point, at the high level the package appears to be good, so lets deserialize it, this part sucks... //call the Serializer for this type of schema that will deserialize the XML into object graphs RegulatorFacilitySubmittalXmlSerializer serializer = new RegulatorFacilitySubmittalXmlSerializer(Repository); var package = serializer.Deserialize(rfsXml, zipFile); if (VerifyPackageRules(package)) { TransactionScope.SetEDTClientKey(package.RegulatorTransactionKey); if (ValidateCommitPackage(package)) { // queue up submittal deltas for submitted FSE's if (package.Packets != null) { foreach (RegulatorFacilitySubmittalPacket packet in package.Packets) { var submittedSubmittalElements = (from sp in packet.FacilitySubmittalElementPackets select sp.FacilitySubmittalElement).ToList(); ServiceLocator.GetSystemServiceManager(Repository).SubmittalDelta.QueueDeltaFSEs(submittedSubmittalElements); } } TransactionScope.Complete(EDTTransactionStatus.Accepted); } else { TransactionScope.Complete(EDTTransactionStatus.Rejected); } } else { //package verification failed. TransactionScope.Complete(EDTTransactionStatus.Rejected); } } else { //either we didn't get XML or we did but it didn't validate. TransactionScope.Complete(EDTTransactionStatus.Rejected); } } catch (Exception ex) { Repository.ClearObjectContextState(); TransactionScope.WriteMessage(ex.Message, EDTTransactionMessageType.Error); TransactionScope.WriteActivity("An error occurred while attempting to process the XML.", ex, type: EDTTransactionMessageType.Error); TransactionScope.Complete(EDTTransactionStatus.Rejected); } var responseXml = PrepareResponsePackage(); TransactionScope.SaveXml(responseXml, EDTTransactionXmlDirection.Outbound); return(responseXml); }