コード例 #1
0
ファイル: GGManager.cs プロジェクト: Tobiasnm/WFC-GG
    public void InsertColumn()
    {
        int mod = 0;

        if (mostWinningPoint.xIndex > mostDistantPoint.xIndex)
        {
            mod = 1;
        }

        for (int i = xSize - 1; i >= mostWinningPoint.xIndex - mod; i--)
        {
            for (int k = 0; k < ySize; k++)
            {
                points[i + 1, k] = DeepCopy.DeepCopyPoint(points[i, k]);
                points[i + 1, k].xIndex++;
            }
        }

        int index = mostWinningPoint.xIndex + 1 - mod;

        for (int i = 0; i < ySize; i++)
        {
            points[index, i].position = Vector3.Lerp(points[index, i].position, points[index + 1, i].position, 0.5f);
        }

        xSize++;
    }
コード例 #2
0
ファイル: SystemState.cs プロジェクト: daveasy805/Horizon-1
        /// <summary>
        /// A deep clone of the System State, but keeping the reference to Previous as a reference
        /// </summary>
        /// <returns></returns>
        public SystemState DeepClone()
        {
            SystemState newState = new SystemState();

            //foreach(KeyValuePair<StateVarKey<int>, HSFProfile<int>> data in this.Idata)
            //{
            //    newState.addValue(data.Key, new HSFProfile<int>(data.Value));
            //}
            //foreach (KeyValuePair<StateVarKey<bool>, HSFProfile<bool>> data in this.Bdata)
            //{
            //    newState.addValue(data.Key, new HSFProfile<bool>(data.Value));
            //}
            //foreach (KeyValuePair<StateVarKey<double>, HSFProfile<double>> data in this.Ddata)
            //{
            //    newState.addValue(data.Key, new HSFProfile<double>(data.Value));
            //}
            //foreach (KeyValuePair<StateVarKey<Matrix<double>>, HSFProfile<Matrix<double>>> data in this.Mdata)
            //{
            //    newState.addValue(data.Key.DeepClone(), new HSFProfile<Matrix<double>>(data.Value));
            //}
            //foreach (KeyValuePair<StateVarKey<Quat>, HSFProfile<Quat>> data in this.Qdata)
            //{
            //    newState.addValue(data.Key.DeepClone(), new HSFProfile<Quat>(data.Value));
            //}
            newState.Idata    = (DeepCopy.Copy(Idata));
            newState.Bdata    = (DeepCopy.Copy(Bdata));
            newState.Ddata    = (DeepCopy.Copy(Ddata));
            newState.Mdata    = (DeepCopy.Copy(Mdata));
            newState.Previous = Previous;
            return(newState);
        }
コード例 #3
0
ファイル: Piece.cs プロジェクト: cmps-115/cmps-115
    public List <Vector2> CheckLegalMoves(Board boardClone, List <Vector2> currentLegalMoves)
    {
        List <Vector2> newLegalMoves   = new List <Vector2>();
        Board          boardCopy       = DeepCopy.Copy(boardClone);
        bool           wasBlackinCheck = KingInCheck.IsBlackInCheck();
        bool           wasWhiteinCheck = KingInCheck.IsWhiteInCheck();


        int   selectedPiece = boardClone.GetActivePieces().IndexOf(this);
        Piece selectedCopy  = boardCopy.GetActivePieces()[selectedPiece];


        Debug.Log("Current legal moves are: ");
        foreach (Vector2 move in currentLegalMoves)
        {
            //When checkMove is false, the current teams king is not in check and the move is valid
            if (selectedCopy.CheckMove(boardCopy, move) == false)
            {
                newLegalMoves.Add(move);
            }
        }

        KingInCheck.SetBlackCheck(wasBlackinCheck);
        KingInCheck.SetWhiteCheck(wasWhiteinCheck);


        return(newLegalMoves);
    }
コード例 #4
0
        /// <summary>
        /// Create an appropriate response given the results
        /// </summary>
        /// <param name="results">The results that matches the query</param>
        /// <param name="map">The HL7 query parameter mapping</param>
        /// <param name="request">The original request message</param>
        /// <param name="count">The number of results that the user requested</param>
        /// <param name="offset">The offset to the first result</param>
        /// <param name="queryId">The unique query identifier used</param>
        /// <returns>The constructed result message</returns>
        protected virtual IMessage CreateQueryResponse(Hl7MessageReceivedEventArgs request, Expression filter, Hl7QueryParameterType map, IEnumerable results, Guid queryId, int offset, int count, int totalResults)
        {
            var retVal = this.CreateACK(map.ResponseType, request.Message, "AA", "Query Success");
            var omsh   = retVal.GetStructure("MSH") as MSH;
            var qak    = retVal.GetStructure("QAK") as QAK;
            var odsc   = retVal.GetStructure("DSC") as DSC;
            var oqpd   = retVal.GetStructure("QPD") as QPD;

            DeepCopy.copy(request.Message.GetStructure("QPD") as ISegment, oqpd);
            omsh.MessageType.MessageCode.Value      = "RSP";
            omsh.MessageType.MessageStructure.Value = retVal.GetType().Name;
            omsh.MessageType.TriggerEvent.Value     = map.ResponseTrigger;
            omsh.MessageType.MessageStructure.Value = map.ResponseTypeXml;
            qak.HitCount.Value            = totalResults.ToString();
            qak.HitsRemaining.Value       = (totalResults - offset - count > 0 ? totalResults - offset - count : 0).ToString();
            qak.QueryResponseStatus.Value = totalResults == 0 ? "NF" : "OK";
            qak.ThisPayload.Value         = results.OfType <Object>().Count().ToString();

            if (ApplicationServiceContext.Current.GetService <Core.Services.IQueryPersistenceService>() != null &&
                Int32.Parse(qak.HitsRemaining.Value) > 0)
            {
                odsc.ContinuationPointer.Value = queryId.ToString();
                odsc.ContinuationStyle.Value   = "RD";
            }

            // Process results
            retVal = map.QueryHandler.AppendQueryResult(results, filter, retVal, request, map.ScoreConfiguration, offset);

            return(retVal);
        }
コード例 #5
0
ファイル: AssetSchedule.cs プロジェクト: tiffthi/Horizon
        /**
         * Creates a new endstate-safe schedule from the given schedule. (last state copied as deep copy, all others shallow copies)
         * @param schedToMakeSafeCopyFrom the schedule to copy
         */
        public AssetSchedule(AssetSchedule oldSchedule)
        {
            AssetSchedule newAssetSched = DeepCopy.Copy <AssetSchedule>(oldSchedule);

            InitialState = newAssetSched.InitialState;
            Events       = newAssetSched.Events;
        }
コード例 #6
0
ファイル: NPCBlacksmith.cs プロジェクト: Sage-SQ/RPGFrameWork
    void AddToItemsNeeded(Item item, int quantity)
    {
        Item craftMat = DeepCopy.CopyItem(item);

        craftMat.CurStacks = quantity;
        itemsNeeded.Add(craftMat);
    }
コード例 #7
0
ファイル: Event.cs プロジェクト: tiffthi/Horizon
        public Event(Event eventToCopyExactly)
        {
            Event newEvent = DeepCopy.Copy <Event>(eventToCopyExactly);

            Task  = newEvent.Task;
            State = newEvent.State;
        }
コード例 #8
0
ファイル: NeuralNet.cs プロジェクト: JanekUchman/CMP304-AI
    public Queue <Queue <float> > ExtractChromosomeGeneSets()
    {
        Queue <Queue <float> > chromosome = new Queue <Queue <float> >();

        for (int i = 1; i < layers.Length; i++)
        {
            foreach (var node in layers[i].nodes)
            {
                Queue <float> geneSet = new Queue <float>();
                //Extract the bias gene
                geneSet.Enqueue(node.bias);
                //Extract each weighting gene
                foreach (var nodeConnection in node.inputConnections)
                {
                    geneSet.Enqueue(nodeConnection.weight);
                }
                chromosome.Enqueue(geneSet);
            }
        }

        Queue <Queue <float> > deepCopy = new Queue <Queue <float> >();

        foreach (Queue <float> floats in chromosome)
        {
            deepCopy.Enqueue((Queue <float>)DeepCopy.Copy(floats));
        }

        return(deepCopy);
    }
コード例 #9
0
        /// <summary>
        /// Creates a copy of this trade system.
        /// </summary>
        /// <returns>A copy of this trade system.</returns>
        public TradeSystem Clone()
        {
            TradeSystem clone = new TradeSystem();

            clone.BuyCondition = DeepCopy.getDeepCopy(this.BuyCondition);
            return(clone);
        }
コード例 #10
0
ファイル: GGManager.cs プロジェクト: Tobiasnm/WFC-GG
    public void InsertRow()
    {
        int mod = 0;

        if (mostWinningPoint.yIndex > mostDistantPoint.yIndex)
        {
            mod = 1;
        }

        for (int i = ySize - 1; i >= mostWinningPoint.yIndex - mod; i--)
        {
            for (int k = 0; k < xSize; k++)
            {
                points[k, i + 1] = DeepCopy.DeepCopyPoint(points[k, i]);
                points[k, i + 1].yIndex++;
            }
        }

        int index = mostWinningPoint.yIndex + 1 - mod;

        for (int i = 0; i < xSize; i++)
        {
            points[i, index].position = Vector3.Lerp(points[i, index].position, points[i, index + 1].position, 0.5f);
        }
        ySize++;
    }
コード例 #11
0
        /// <summary>
        /// Create an Ack message based on a received message
        /// </summary>
        /// <param name="inboundMessage">received message</param>
        /// <param name="ackCode">Should be "AE" or "AR", can be "AA".</param>
        /// <param name="errorMessage">The reason the message was rejected or an error. If "AA" was supplied as ackCode the errorMessage should be null.</param>
        /// <returns>Created ACK message</returns>
        public static IMessage MakeACK(IMessage inboundMessage, string ackCode, string errorMessage)
        {
            IMessage ackMessage = null;
            // Get an object from the right ACK class
            string ackClassType = string.Format("NHapi.Model.V{0}.Message.ACK, NHapi.Model.V{0}", inboundMessage.Version.Remove(inboundMessage.Version.IndexOf('.'), 1));
            Type   x            = Type.GetType(ackClassType);

            ackMessage = (IMessage)Activator.CreateInstance(x);

            Terser   inboundTerser = new Terser(inboundMessage);
            ISegment inboundHeader = null;

            inboundHeader = inboundTerser.getSegment("MSH");

            // Find the HL7 version of the inbound message:
            //
            string version = null;

            try
            {
                version = Terser.Get(inboundHeader, 12, 0, 1, 1);
            }
            catch (NHapi.Base.HL7Exception)
            {
                // I'm not happy to proceed if we can't identify the inbound
                // message version.
                throw new NHapi.Base.HL7Exception("Failed to get valid HL7 version from inbound MSH-12-1");
            }

            // Create a Terser instance for the outbound message (the ACK).
            Terser terser = new Terser(ackMessage);

            // Populate outbound MSH fields using data from inbound message
            ISegment outHeader = (ISegment)terser.getSegment("MSH");

            DeepCopy.copy(inboundHeader, outHeader);

            // Now set the message type, HL7 version number, acknowledgement code
            // and message control ID fields:
            string sendingApp = terser.Get("/MSH-3");
            string sendingEnv = terser.Get("/MSH-4");

            terser.Set("/MSH-3", CommunicationName);
            terser.Set("/MSH-4", EnvironmentIdentifier);
            terser.Set("/MSH-5", sendingApp);
            terser.Set("/MSH-6", sendingEnv);
            terser.Set("/MSH-7", DateTime.Now.ToString("yyyyMMddmmhh"));
            terser.Set("/MSH-9", "ACK");
            terser.Set("/MSH-12", version);
            terser.Set("/MSA-1", ackCode == null ? "AA" : ackCode);
            terser.Set("/MSA-2", Terser.Get(inboundHeader, 10, 0, 1, 1));

            // Set error message
            if (errorMessage != null)
            {
                terser.Set("/ERR-7", errorMessage);
            }

            return(ackMessage);
        }
コード例 #12
0
 public InputComponentControl(Entity entity)
 {
     InitializeComponent();
     engineData     = new List <FFComponent>();
     selectedEntity = entity;
     actions        = new Dictionary <string, MakerSquare.FrontFacingECS.Tuple <string, string, string> >();
     basePanel      = DeepCopy <StackPanel> .DeepCopyMethod(ActionPanel);
 }
コード例 #13
0
ファイル: AssetSchedule.cs プロジェクト: tiffthi/Horizon
        /**
         * Creates a new assetSchedule from and old assetSchedule and a new Event shared pointer
         * @param oldSchedule the old schedule to base this schedule off of
         * @param newEvent the new event to add to the schedule
         */
        public AssetSchedule(AssetSchedule oldSchedule, Event newEvent)
        {
            AssetSchedule newAssetSched = DeepCopy.Copy <AssetSchedule>(oldSchedule);

            InitialState = newAssetSched.InitialState;
            Events       = newAssetSched.Events;
            Events.Push(newEvent);
        }
コード例 #14
0
        public TestCopyClass(TestCopyClass other)
        {
            TestCopyClass copy = DeepCopy.Copy <TestCopyClass>(other);

            Num    = copy.Num;
            Name   = copy.Name;
            Helper = copy.Helper;
        }
コード例 #15
0
        /// <summary>
        /// Rewrite a QPD query to an HDSI query
        /// </summary>
        public virtual NameValueCollection ParseQuery(QPD qpd, Hl7QueryParameterType map)
        {
            NameValueCollection retVal = new NameValueCollection();

            // Control of strength
            String strStrength = (qpd.GetField(4, 0) as Varies)?.Data.ToString(),
                   algorithm   = (qpd.GetField(5, 0) as Varies)?.Data.ToString();
            Double?strength    = String.IsNullOrEmpty(strStrength) ? null : (double?)Double.Parse(strStrength);

            // Query parameters
            foreach (var itm in MessageUtils.ParseQueryElement(qpd.GetField(3).OfType <Varies>(), map, algorithm, strength))
            {
                try
                {
                    retVal.Add(itm.Key, itm.Value);
                }
                catch (Exception e)
                {
                    this.m_tracer.TraceError("Error processing query parameter", "QPD", "1", 3, 0, e);
                    throw new HL7ProcessingException(this.m_localizationService.FormatString("error.type.HL7ProcessingException", new
                    {
                        param = "query parameter"
                    }), "QPD", "1", 3, 0, e);
                }
            }

            // Return domains
            foreach (var rt in qpd.GetField(8).OfType <Varies>())
            {
                try
                {
                    var rid = new CX(qpd.Message);
                    DeepCopy.Copy(rt.Data as GenericComposite, rid);
                    var authority = rid.AssigningAuthority.ToModel();

                    if (authority.Key == this.m_configuration.LocalAuthority.Key)
                    {
                        retVal.Add("_id", rid.IDNumber.Value);
                    }
                    else
                    {
                        retVal.Add($"identifier[{authority.DomainName}]", "!null");
                    }
                }
                catch (Exception e)
                {
                    this.m_tracer.TraceError("Error processing return domains", "QPD", "1", 8, 0, e);
                    throw new HL7ProcessingException(this.m_localizationService.FormatString("error.type.HL7ProcessingException", new
                    {
                        param = "return domains"
                    }), "QPD", "1", 8, 0, e);
                }
            }

            retVal.Add("obsoletionTime", "null");

            return(retVal);
        }
コード例 #16
0
        public async Task <IResponseEntity> UpdateSystemConfig(SystemConfig req)
        {
            var result = await _settingService.WriteConfig <SystemConfig>("System", opt =>
            {
                DeepCopy.CopyToAll(req, opt);
            });

            return(ResponseEntity.Result(result));
        }
コード例 #17
0
    //Takes two array segments and combines them into a new genome

    private float[] CreateChild(List <float> fatherSegment, List <float> motherSegment)
    {
        float[] newChromosome = new float[NumberOfGenes];
        //Add the father segment to the start of the array, since this is where we took it from earlier
        fatherSegment.CopyTo(newChromosome, 0);
        //Add the mother's genes onto the end of the fathers
        motherSegment.CopyTo(newChromosome, fatherSegment.Count);
        return((float[])DeepCopy.Copy(newChromosome));
    }
コード例 #18
0
ファイル: DeepCopyTest.cs プロジェクト: zzl1010/ZhaoCode
        public void DeepCopyTest1()
        {
            User u1 = new User();

            u1.UName = "张三";
            User u2 = DeepCopy.DeepCopyByReflect(u1);

            Assert.AreNotEqual(u1, u2);
        }
コード例 #19
0
    public DeepCopyClient()
    {
        DeepCopy dc1 = new DeepCopy();
        DeepCopy dc2 = (DeepCopy)dc1.Clone();
        dc1.v[0] = 9;

        dc1.Display();
        dc2.Display();
    }
コード例 #20
0
        /// <summary>
        /// Rewrite a QPD query to an HDSI query
        /// </summary>
        public virtual NameValueCollection ParseQuery(QPD qpd, Hl7QueryParameterType map)
        {
            NameValueCollection retVal = new NameValueCollection();

            // Query domains
            foreach (var rt in qpd.GetField(3).OfType <Varies>())
            {
                try
                {
                    var rid = new CX(qpd.Message);
                    DeepCopy.Copy(rt.Data as GenericComposite, rid);
                    var authority = rid.AssigningAuthority.ToModel();

                    if (authority.Key == m_configuration.LocalAuthority.Key)
                    {
                        retVal.Add("_id", rid.IDNumber.Value);
                    }
                    else
                    {
                        retVal.Add($"identifier[{authority.DomainName}].value", rid.IDNumber.Value);
                    }
                }
                catch (Exception e)
                {
                    this.m_tracer.TraceError("Error processing patient identity", "QPD", "1", 3, 4, e);
                    throw new HL7ProcessingException(this.m_localizationService.FormatString("error.type.HL7ProcessingException", new
                    {
                        param = "patient identity"
                    }), "QPD", "1", 3, 4, e);
                }
            }


            //// Return domains
            // This just verifies the return domains
            foreach (var rt in qpd.GetField(4).OfType <Varies>())
            {
                try
                {
                    var rid = new CX(qpd.Message);
                    DeepCopy.Copy(rt.Data as GenericComposite, rid);
                    var authority = rid.AssigningAuthority.ToModel();
                }
                catch (Exception e)
                {
                    this.m_tracer.TraceError("Error processing what domains returned", "QPD", "1", 4, 4, e);
                    throw new HL7ProcessingException(this.m_localizationService.FormatString("error.type.HL7ProcessingException", new
                    {
                        param = "what domains returned"
                    }), "QPD", "1", 4, 4, e);
                }
            }


            return(retVal);
        }
コード例 #21
0
        public void MatrixDeepCopyTest()
        {
            Matrix <double> A = new Matrix <double>(new double[, ] {
                { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }
            });

            Matrix <double> B = DeepCopy.Copy(A);

            Assert.AreEqual(B, A);
        }
コード例 #22
0
        public SystemClass(SystemClass other)
        {
            SystemClass copy = DeepCopy.Copy <SystemClass>(other);

            Assets      = copy.Assets;
            Subsystems  = copy.Subsystems;
            Constraints = copy.Constraints;
            Environment = copy.Environment;
            ThreadNum   = copy.ThreadNum;
        }
コード例 #23
0
ファイル: Event.cs プロジェクト: jasonchin95/Horizon
 /// <summary>
 /// New Event with a deep copy of the state.
 /// </summary>
 /// <param name="eventToCopyExactly"></param>
 public Event(Event eventToCopyExactly)
 {
     Tasks       = eventToCopyExactly.Tasks;
     State       = DeepCopy.Copy(eventToCopyExactly.State);
     EventStarts = eventToCopyExactly.EventStarts;
     EventEnds   = eventToCopyExactly.EventEnds;
     //EventStarts = DeepCopy.Copy(eventToCopyExactly.EventStarts);
     //EventEnds = DeepCopy.Copy(eventToCopyExactly.EventEnds);
     TaskStarts = DeepCopy.Copy(eventToCopyExactly.TaskStarts);
     TaskEnds   = DeepCopy.Copy(eventToCopyExactly.TaskEnds);
 }
コード例 #24
0
        public Runtime.GLTF SetModelAttributes(Runtime.GLTF wrapper, Runtime.Material material, List <Property> combo, ref glTFLoader.Schema.Gltf gltf)
        {
            // Switch from the flat plane to a model with multiple nodes
            wrapper = Common.MultiNode();
            var nodeList = new List <Runtime.Node>();

            nodeList.Add(wrapper.Scenes[0].Nodes[0]);
            nodeList.Add(wrapper.Scenes[0].Nodes[0].Children[0]);

            // Add a new child node that will inherit the transformations
            nodeList.Add((DeepCopy.CloneObject(wrapper.Scenes[0].Nodes[0])));
            nodeList[2].Name     = "Node1";
            nodeList[2].Children = null;
            nodeList[1].Children = new List <Runtime.Node>();
            nodeList[1].Children.Add(nodeList[2]);

            // Clear the vertex normal and tangent values already in the model
            foreach (var node in nodeList)
            {
                node.Mesh.MeshPrimitives[0].Normals  = null;
                node.Mesh.MeshPrimitives[0].Tangents = null;
            }

            foreach (Property property in combo)
            {
                if (property.name == Propertyname.Matrix)
                {
                    nodeList[1].Matrix = specialProperties[0].value;
                }
                else if (property.name == Propertyname.Translation ||
                         property.name == Propertyname.Translation_X ||
                         property.name == Propertyname.Translation_Y ||
                         property.name == Propertyname.Translation_Z)
                {
                    nodeList[1].Translation = property.value;
                }
                else if (property.name == Propertyname.Rotation)
                {
                    nodeList[1].Rotation = specialProperties[1].value;
                }
                else if (property.name == Propertyname.Scale)
                {
                    nodeList[1].Scale = property.value;
                }
            }

            // Apply the material to each node
            foreach (var node in nodeList)
            {
                node.Mesh.MeshPrimitives[0].Material = material;
            }

            return(wrapper);
        }
コード例 #25
0
        private List <EncodingTaskBase> GetTasksForSelectedFiles()
        {
            var tasksForSelectedFiles = new List <EncodingTaskBase>();

            foreach (var file in SelectedFiles)
            {
                var taskCopies = Tasks.Select(x => DeepCopy.Copy(x)).ToArray();
                tasksForSelectedFiles.Add(ConvertToAssemblyLineIfNeeded(taskCopies, file));
            }

            return(tasksForSelectedFiles);
        }
コード例 #26
0
        /// <summary>
        /// Append query results to the message
        /// </summary>
        public virtual IMessage AppendQueryResult(IEnumerable results, Expression queryDefinition, IMessage currentResponse, Hl7MessageReceivedEventArgs evt, String matchConfiguration = null, int offset = 0)
        {
            var patients = results.OfType <Patient>();

            if (patients.Count() == 0)
            {
                return(currentResponse);
            }
            var retVal = currentResponse as RSP_K21;

            var pidHandler         = SegmentHandlers.GetSegmentHandler("PID");
            var pd1Handler         = SegmentHandlers.GetSegmentHandler("PD1");
            var nokHandler         = SegmentHandlers.GetSegmentHandler("NK1");
            var matchService       = ApplicationServiceContext.Current.GetService <IRecordMatchingService>();
            var matchConfigService = ApplicationServiceContext.Current.GetService <IRecordMatchingConfigurationService>();

            // Return domains
            var rqo = evt.Message as QBP_Q21;
            List <AssigningAuthority> returnDomains = new List <AssigningAuthority>();

            foreach (var rt in rqo.QPD.GetField(8).OfType <Varies>())
            {
                var rid = new CX(rqo.Message);
                DeepCopy.copy(rt.Data as GenericComposite, rid);
                var authority = rid.AssigningAuthority.ToModel();
                returnDomains.Add(authority);
            }
            if (returnDomains.Count == 0)
            {
                returnDomains = null;
            }

            // Process results
            int i = offset + 1;

            foreach (var itm in patients)
            {
                var queryInstance = retVal.GetQUERY_RESPONSE(retVal.QUERY_RESPONSERepetitionsUsed);
                pidHandler.Create(itm, queryInstance, returnDomains?.ToArray());
                pd1Handler.Create(itm, queryInstance, null);
                nokHandler.Create(itm, queryInstance, null);
                queryInstance.PID.SetIDPID.Value = (i++).ToString();
                // QRI?
                if (matchService != null && !String.IsNullOrEmpty(matchConfiguration))
                {
                    var score = matchService.Score <Patient>(itm, queryDefinition as Expression <Func <Patient, bool> >, matchConfiguration);
                    queryInstance.QRI.CandidateConfidence.Value            = score.Score.ToString();
                    queryInstance.QRI.AlgorithmDescriptor.Identifier.Value = matchConfiguration;
                }
            }

            return(retVal);
        }
コード例 #27
0
ファイル: Program.cs プロジェクト: dib0/NHapiExampleApp
        public static void MakeACK(ISegment inboundHeader, string ackCode, IMessage ackMessage, string errorMessage)
        {
            if (!inboundHeader.GetStructureName().Equals("MSH"))
            {
                throw new NHapi.Base.HL7Exception("Need an MSH segment to create a response ACK (got " + inboundHeader.GetStructureName() + ")");
            }

            // Find the HL7 version of the inbound message:
            string version = null;

            try
            {
                version = Terser.Get(inboundHeader, 12, 0, 1, 1);
            }
            catch (NHapi.Base.HL7Exception)
            {
                // I'm not happy to proceed if we can't identify the inbound
                // message version.
                throw new NHapi.Base.HL7Exception("Failed to get valid HL7 version from inbound MSH-12-1");
            }

            // Create a Terser instance for the outbound message (the ACK).
            Terser terser = new Terser(ackMessage);

            // Populate outbound MSH fields using data from inbound message
            ISegment outHeader = (ISegment)terser.getSegment("MSH");

            DeepCopy.copy(inboundHeader, outHeader);

            // Now set the message type, HL7 version number, acknowledgement code
            // and message control ID fields:
            string sendingApp = terser.Get("/MSH-3");
            string sendingEnv = terser.Get("/MSH-4");

            // Make sure you fill the MSH-3 and MSH-4 with the correct values
            // for you application, preferably with configuration
            terser.Set("/MSH-3", "HL7Client");
            terser.Set("/MSH-4", "EnvironmentIdentifier");
            terser.Set("/MSH-5", sendingApp);
            terser.Set("/MSH-6", sendingEnv);
            terser.Set("/MSH-7", DateTime.Now.ToString("yyyyMMddmmhh"));
            terser.Set("/MSH-9", "ACK");
            terser.Set("/MSH-12", version);
            terser.Set("/MSA-1", ackCode == null ? "AA" : ackCode);
            terser.Set("/MSA-2", Terser.Get(inboundHeader, 10, 0, 1, 1));

            // Set error message
            if (errorMessage != null)
            {
                terser.Set("/ERR-7", errorMessage);
            }
        }
コード例 #28
0
        public static IMessage MakeACK(ISegment inboundHeader, string ackCode)
        {
            if (!inboundHeader.GetStructureName().Equals("MSH"))
            {
                throw new NHapi.Base.HL7Exception(
                          "Need an MSH segment to create a response ACK (got " + inboundHeader.GetStructureName() + ")");
            }

            // Find the HL7 version of the inbound message:
            //
            string version = null;

            try
            {
                version = Terser.Get(inboundHeader, 12, 0, 1, 1);
            }
            catch (NHapi.Base.HL7Exception)
            {
                // I'm not happy to proceed if we can't identify the inbound
                // message version.
                throw new NHapi.Base.HL7Exception("Failed to get valid HL7 version from inbound MSH-12-1");
            }

            IMessage ackMessage = new ACK();
            // Create a Terser instance for the outbound message (the ACK).
            Terser terser = new Terser(ackMessage);

            // Populate outbound MSH fields using data from inbound message
            ISegment outHeader = (ISegment)terser.getSegment("MSH");

            DeepCopy.copy(inboundHeader, outHeader);

            // Now set the message type, HL7 version number, acknowledgement code
            // and message control ID fields:
            string sendingApp = terser.Get("/MSH-3");
            string sendingEnv = terser.Get("/MSH-4");

            terser.Set("/MSH-3", CommunicationName);
            terser.Set("/MSH-4", EnvironmentIdentifier);
            terser.Set("/MSH-5", sendingApp);
            terser.Set("/MSH-6", sendingEnv);
            terser.Set("/MSH-7", DateTime.Now.ToString("yyyyMMddmmhh"));
            terser.Set("/MSH-9", "ACK");
            terser.Set("/MSH-12", version);
            terser.Set("/MSA-1", ackCode == null ? "AA" : ackCode);
            terser.Set("/MSA-2", Terser.Get(inboundHeader, 10, 0, 1, 1));

            return(ackMessage);
        }
コード例 #29
0
 public Task <AspNetUser> FindAsync(string userName, string password)
 {
     return(Task <AspNetUser> .Factory.StartNew(() =>
     {
         using (AspNetUserRepository repository = new AspNetUserRepository())
         {
             //repository.LazyLoadingEnabled = false;
             repository.ProxyCreationEnabled = false;
             password = PasswordHasher.HashPassword(password);
             var result = repository.GetSingle(user => user.UserName == userName && user.Password == password, user => user.AspNetUserClaim, user => user.AspNetUserClaim);
             //return result;
             return (AspNetUser)DeepCopy.CloneInternal(result, 2);
         }
     }));
 }
コード例 #30
0
        /// <summary>
        /// Run the genetic algorithm.
        /// </summary>
        /// <param name="worker">The background worker object.</param>
        /// <param name="e">Do work event args.</param>
        public void Run(BackgroundWorker worker, DoWorkEventArgs e)
        {
            fitnessAlgorithm.SetFitness(chromosomes);
            Dictionary <string, double> fitnessResult         = fitnessAlgorithm.getFitness();
            IEnumerable <KeyValuePair <string, double> > temp = fitnessResult.OrderByDescending(d => d.Value);

            chromosomes    = chromosomes.OrderByDescending(d => d.Capital).ToArray();
            bestChromosome = DeepCopy.getDeepCopy(chromosomes[0]);
            chromosomes    = breedingAlgorithm.Breed(chromosomes);
            mutatingAlgorithm.Mutate(ref chromosomes);
            for (int j = 0; j < chromosomes.Count(); j++)
            {
                chromosomes[j].newID();
            }
        }
コード例 #31
0
ファイル: SystemState.cs プロジェクト: tiffthi/Horizon
        /**
         * Copy constructor for exact state copies
         */
        public SystemState(SystemState initialStateToCopy)
        {
            SystemState newState = DeepCopy.Copy <SystemState>(initialStateToCopy);

            Previous   = newState.Previous;
            EventStart = newState.EventStart;
            TaskStart  = newState.TaskStart;
            TaskEnd    = newState.TaskEnd;
            EventEnd   = newState.EventEnd;
            Idata      = newState.Idata;
            Ddata      = newState.Ddata;
            //       Fdata = newState.Fdata;
            Bdata = newState.Bdata;
            Mdata = newState.Mdata;
            Qdata = newState.Qdata;
        }