Ejemplo n.º 1
0
        /// <summary>
        /// Calculate the new acceleration (translational and rotational)
        /// </summary>
        /// <param name="dt"></param>
        protected override double CalculateRotationalAcceleration(double dt)
        {
            double l_Acceleration = 0;

            Aux.TestArithmeticException(l_Acceleration, "particle rotational acceleration");
            return(l_Acceleration);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Calculate the new angular velocity of the particle using explicit Euler scheme.
        /// </summary>
        /// <param name="dt">Timestep</param>
        /// <param name="collisionTimestep">The time consumed during the collision procedure</param>
        protected override double CalculateAngularVelocity(double dt)
        {
            double l_RotationalVelocity = GetRotationalVelocity(1);

            Aux.TestArithmeticException(l_RotationalVelocity, "particle rotational velocity");
            return(l_RotationalVelocity);
        }
Ejemplo n.º 3
0
        internal T Key <T>(IAddition <IPrimaryKey <T> > keyedAddition)
        {
            var a = (Add)keyedAddition;

            if (!a.IsExecuted)
            {
                throw new TectureOrmFeatureException($"Cannot obtain primary key: addition of '{a.Entity}' did not happen yet");
            }

            T      result;
            string hash = Aux.IsHashRequired ? $"ORM_AdditionPK_{a.Order}" : string.Empty;

            if (Aux.IsEvaluationNeeded)
            {
                result = (T)(GetKey(a, GetKeyProperties <T>(a)).First());
            }
            else
            {
                result = Aux.Get <T>(hash, "ORM Addition PK retrieval");
            }

            if (Aux.IsTracingNeeded)
            {
                if (!Aux.IsEvaluationNeeded)
                {
                    Aux.Query(hash, "test data", "ORM Addition PK retrieval");
                }
                else
                {
                    Aux.Query(hash, result, "ORM Addition PK retrieval");
                }
            }

            return(result);
        }
Ejemplo n.º 4
0
        protected void loginButton1_Click(object sender, EventArgs e)
        {
            DataAccess_MySQL dbconn0 = new DataAccess_MySQL();
            Aux aux1 = new Aux();

            if (loginTextboxPass.Text.ToString().Contains("OR") || loginTextboxUser.Text.ToString().Contains("OR"))
            {
                ErrMsg_1.Text = "Sugi pula cristi";
                return;
            }
            if (aux1.IsEmpty(loginTextboxUser.Text.ToString()) == true || aux1.IsEmpty(loginTextboxPass.Text.ToString()) == true)
            {
                ErrMsg_1.Text = aux1.ErrorIsEmpty;
            }
            else
            {
                dbconn0.setUserName = loginTextboxUser.Text;
                dbconn0.setPassword = loginTextboxPass.Text;
                dbconn0.Settype     = "login";
                dbconn0.connect();

                if (dbconn0.setconnSuccess == true)
                {
                    Response.Redirect("~/Pages/ExerciseUpload.aspx");
                }
                else
                {
                    ErrMsg_1.Text         = "Invalid credentials if you want to create a new account, please click to SignUp button below";
                    signUpButton1.Visible = true;
                }
            }
            return;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Calculate the new particle angle after a collision
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="collisionTimestep">The time consumed during the collision procedure</param>
        protected override double CalculateParticleAngle(double dt, double collisionTimestep)
        {
            double l_Angle = GetAngle(1);

            Aux.TestArithmeticException(l_Angle, "particle angle");
            return(l_Angle);
        }
Ejemplo n.º 6
0
        public AStar(WeightedGraph <Node> g, Node s, Node des) : base(g, s, des)
        {
            pq     = new MinHeap <Aux>();
            distTo = new double[g.V];
            edgeTo = new Edge[g.V];

            for (int i = 0; i < g.V; i++)
            {
                distTo[i] = double.PositiveInfinity;
            }
            distTo[g.GetVertex(s)] = 0;

            pq.Add(new Aux(g.GetVertex(s), distTo[g.GetVertex(s)], 0));
            int exploredNodes = 0;

            while (pq.Count > 0)
            {
                exploredNodes++;
                Aux v = pq.ExtractDominating();
                if (v.V == g.GetVertex(des))
                {
                    ExploredNodes = exploredNodes;
                    break;
                }
                foreach (Edge e in g.Adj(v.V))
                {
                    Relax(e, v.V);
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Calculate the new particle position
        /// </summary>
        /// <param name="dt"></param>
        /// <summary>
        /// Calculate the new particle position
        /// </summary>
        /// <param name="dt"></param>
        protected override Vector CalculateParticlePosition(double dt)
        {
            Vector l_Position = GetPosition(1);

            Aux.TestArithmeticException(l_Position, "particle position");
            return(l_Position);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Calculate the new angular velocity of the particle using explicit Euler scheme.
        /// </summary>
        /// <param name="dt">Timestep</param>
        /// <param name="collisionTimestep">The time consumed during the collision procedure</param>
        protected override double CalculateAngularVelocity(double dt, double collisionTimestep)
        {
            double l_RotationalVelocity = 0;

            Aux.TestArithmeticException(l_RotationalVelocity, "particle rotational velocity");
            return(l_RotationalVelocity);
        }
Ejemplo n.º 9
0
    //guarda datos de una clase a un archivo binario
    public static void SaveListToDisk <T>(this List <T> listToSerialize, string path, bool encripted)
    {
        if (encripted)
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Create(path);

            Aux <T> aux = new Aux <T>();
            aux.list = listToSerialize;

            bf.Serialize(file, aux);
            file.Close();
        }
        else
        {
            StreamWriter file = File.CreateText(path);

            Aux <T> aux = new Aux <T>();
            aux.list = listToSerialize;

            string json = JsonUtility.ToJson(aux, true);
            file.Write(json);
            file.Close();
        }
    }
Ejemplo n.º 10
0
        /// <summary>
        /// Returns the support point of the particle in the direction specified by a vector.
        /// </summary>
        /// <param name="vector">
        /// A vector.
        /// </param>
        override public Vector GetSupportPoint(Vector supportVector, int SubParticleID)
        {
            Aux.TestArithmeticException(supportVector, "vector in calc of support point");
            if (supportVector.L2Norm() == 0)
            {
                throw new ArithmeticException("The given vector has no length");
            }

            Vector supportPoint = new Vector(supportVector);
            double angle        = Motion.GetAngle(0);
            Vector position     = new Vector(Motion.GetPosition(0));
            Vector rotVector    = new Vector(supportVector);

            rotVector[0] = supportVector[0] * Math.Cos(angle) - supportVector[1] * Math.Sin(angle);
            rotVector[1] = supportVector[0] * Math.Sin(angle) + supportVector[1] * Math.Cos(angle);
            Vector length = new Vector(position);

            length[0] = m_Length * Math.Cos(angle) - m_Thickness * Math.Sin(angle);
            length[1] = m_Length * Math.Sin(angle) + m_Thickness * Math.Cos(angle);
            for (int d = 0; d < position.Dim; d++)
            {
                supportPoint[d] = Math.Sign(rotVector[d]) * length[d] + position[d];
            }
            return(supportPoint);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Muestra la Información de la Visitanes por Tarifa en pantalla.
        /// </summary>
        /// <creo>Héctor Gabriel Galicia Luna</creo>
        /// <fecha_creo>19 de Enero de 2016</fecha_creo>
        /// <modifico></modifico>
        /// <fecha_modifico></fecha_modifico>
        /// <causa_modificacion></causa_modificacion>
        private void Recaudacion_Acumulado_Visitantes()
        {
            try
            {
                Cls_Rep_Ingresos_Negocio Neg_Ingresos;
                DataSet Resultados;
                DataRow Totales;

                Neg_Ingresos = Filtros();
                Resultados   = Neg_Ingresos.Recaudacion_Acumulado_Visitantes();

                Totales    = Resultados.Tables[0].NewRow();
                Totales[0] = "Totales";

                // Se realiza la suma de los Totales por Año.
                for (int i = 1; i < Resultados.Tables[0].Columns.Count; i++)
                {
                    Int64 Total = (from Aux in Resultados.Tables[0].AsEnumerable()
                                   select Aux.Field <Int64>(i)).Sum();

                    Totales[i] = Total;
                }

                Resultados.Tables[0].Rows.Add(Totales);

                Grd_Resultado.DataSource = Resultados;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 12
0
        internal T Key <T>(IAddition <IPrimaryKey <T> > keyedAddition)
        {
            var a = (Add)keyedAddition;

            if (!a.IsExecuted)
            {
                throw new TectureOrmAspectException($"Cannot obtain primary key: addition of '{a.Entity}' did not happen yet");
            }

            string explanation = $"Get primary key of added {a.EntityType.Name}";

            var p = Aux.Promise <T>();

            if (p is Containing <T> c)
            {
                return(c.Get($"ORM_AdditionPK_{a.Order}", explanation));
            }

            var result = (T)(GetKey(a, GetKeyProperties <T>(a)).First());

            if (p is Demanding <T> d)
            {
                d.Fullfill(result, $"ORM_AdditionPK_{a.Order}", explanation);
            }

            return(result);
        }
Ejemplo n.º 13
0
        public static int GetNextId(string Tabla, string NombreClave, System.Data.SqlClient.SqlTransaction tran)
        {
            try
            {
                SqlCommand Comando = new SqlCommand();
                object     Aux;
                int        ret;

                PrepararConexion(Comando, tran);

                //Armo la Query
                Comando.CommandType = CommandType.Text;
                Comando.CommandText = "SELECT MAX(" + NombreClave + ") " + "FROM [" + Tabla + "] ";

                //Obtengo el Nuevo Id
                Aux = EjecutarScalar(Comando);

                //Si el resultado es un numero, le sumo 1 y lo devuelvo.
                //Sino, devuelvo 1.
                if ((bool)int.TryParse(Aux.ToString(), out ret))
                {
                    return(ret + 1);
                }
                else
                {
                    return(1);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error en: DataLibrary - GetNextId", ex);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Calculate the new translational velocity of the particle
        /// </summary>
        /// <param name="dt">Timestep</param>
        protected override Vector CalculateTranslationalVelocity(double dt)
        {
            Vector l_TranslationalVelocity = GetTranslationalVelocity(1) + GetTranslationalAcceleration(0) * dt;

            Aux.TestArithmeticException(l_TranslationalVelocity, "particle translational velocity");
            return(l_TranslationalVelocity);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Calculate the new translational velocity of the particle using a Crank Nicolson scheme.
        /// </summary>
        /// <param name="dt">Timestep</param>
        protected override Vector CalculateTranslationalVelocity(double dt)
        {
            Vector l_TranslationalVelocity = new Vector(SpatialDim);

            Aux.TestArithmeticException(l_TranslationalVelocity, "particle translational velocity");
            return(l_TranslationalVelocity);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Calculate the new angular velocity of the particle using explicit Euler scheme.
        /// </summary>
        /// <param name="dt">Timestep</param>
        /// <param name="collisionTimestep">The time consumed during the collision procedure</param>
        protected override double CalculateParticleAngle(double dt)
        {
            double angle = GetAngle(1);

            Aux.TestArithmeticException(angle, "particle rotational velocity");
            return(angle);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Calculate the new translational velocity of the particle using a Crank Nicolson scheme.
        /// </summary>
        /// <param name="dt">Timestep</param>
        protected override Vector CalculateParticlePosition(double dt)
        {
            Vector position = GetPosition(1);

            Aux.TestArithmeticException(position, "particle translational velocity");
            return(position);
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Constructor for the trap used in the masters thesis if E. Deriabina (2019)
 /// </summary>
 /// <param name="motionInit">
 /// Initializes the motion parameters of the particle (which model to use, whether it is a dry simulation etc.)
 /// </param>
 /// <param name="width">
 /// The main lengthscale.
 /// </param>
 /// <param name="startPos">
 /// The initial position.
 /// </param>
 /// <param name="startAngl">
 /// The inital anlge.
 /// </param>
 /// <param name="activeStress">
 /// The active stress excerted on the fluid by the particle. Zero for passive particles.
 /// </param>
 /// <param name="startTransVelocity">
 /// The inital translational velocity.
 /// </param>
 /// <param name="startRotVelocity">
 /// The inital rotational velocity.
 /// </param>
 public Particle_TrapRight(InitializeMotion motionInit, double width, double[] startPos = null, double startAngl = 0, double activeStress = 0, double[] startTransVelocity = null, double startRotVelocity = 0) : base(motionInit, startPos, startAngl, activeStress, startTransVelocity, startRotVelocity)
 {
     m_Length = width;
     Aux.TestArithmeticException(width, "Particle width");
     Motion.SetParticleMaxLengthscale(width);
     Motion.SetParticleArea(Area);
     Motion.SetParticleMomentOfInertia(MomentOfInertia);
 }
Ejemplo n.º 19
0
 public void Add(GroupData newGroup)
 {
     OpenGroupsDialog();
     Aux.ControlClick(GROUPWINTITITLE, "", "WindowsForms10.BUTTON.app.0.2c908d53");
     Aux.Send(newGroup.Name);
     Aux.Send("{ENTER}");
     CloseGroupsDialog();
 }
Ejemplo n.º 20
0
        void initializeGraphics()
        {
            try
            {
                graphics = Graphics.FromHwnd(panel1.Handle);
                // load some predefined rendering module (may be also "WinDirectX" or "WinOpenGL")
                using (GsModule gsModule = (GsModule)SystemObjects.DynamicLinker.LoadModule("WinGDI.txv", false, true))
                {
                    // create graphics device
                    using (Teigha.GraphicsSystem.Device graphichsDevice = gsModule.CreateDevice())
                    {
                        // setup device properties
                        using (Dictionary props = graphichsDevice.Properties)
                        {
                            if (props.Contains("WindowHWND"))                                   // Check if property is supported
                            {
                                props.AtPut("WindowHWND", new RxVariant((Int32)panel1.Handle)); // hWnd necessary for DirectX device
                            }
                            if (props.Contains("WindowHDC"))                                    // Check if property is supported
                            {
                                props.AtPut("WindowHDC", new RxVariant(graphics.GetHdc()));     // hWindowDC necessary for Bitmap device
                            }
                            if (props.Contains("DoubleBufferEnabled"))                          // Check if property is supported
                            {
                                props.AtPut("DoubleBufferEnabled", new RxVariant(true));
                            }
                            if (props.Contains("EnableSoftwareHLR")) // Check if property is supported
                            {
                                props.AtPut("EnableSoftwareHLR", new RxVariant(true));
                            }
                            if (props.Contains("DiscardBackFaces")) // Check if property is supported
                            {
                                props.AtPut("DiscardBackFaces", new RxVariant(true));
                            }
                        }
                        // setup paperspace viewports or tiles
                        ContextForDbDatabase ctx = new ContextForDbDatabase(database);
                        ctx.UseGsModel = true;

                        helperDevice = LayoutHelperDevice.SetupActiveLayoutViews(graphichsDevice, ctx);
                        Aux.preparePlotstyles(database, ctx);
                        gripManager.init(helperDevice, helperDevice.Model, database);
                        //helperDevice.ActiveView.Mode = Teigha.GraphicsSystem.RenderMode.HiddenLine;
                    }
                }
                // set palette
                helperDevice.SetLogicalPalette(Device.DarkPalette);
                // set output extents
                resize();


                helperDevice.Model.Invalidate(InvalidationHint.kInvalidateAll);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 21
0
 public void Test_103()
 {
     var e1 = new HypoLambda();
     e1.Compile("5 if not this.S else 4");
     Aux y1 = new Aux();
     y1.S = null;
     e1.Externals["this"] = y1;
     Assert.AreEqual(5.0, Convert.ToDouble(e1.Run()));
 }
Ejemplo n.º 22
0
        public AppManager()
        {
            Aux.Run(@"c:\Users\e.ivanchenko\AddressBookNative4\AddressBook.exe", "", Aux.SW_SHOW);
            Aux.WinWait(WIN_TITLE);
            Aux.WinActivate(WIN_TITLE);
            Aux.WinWaitActive(WIN_TITLE);

            new GroupHelper(this);
        }
Ejemplo n.º 23
0
 void AddNestingsAsAux(IToken tok)
 {
     while (tok != null && tok is Dafny.NestedToken)
     {
         var nt = (Dafny.NestedToken)tok;
         tok = nt.Inner;
         Aux.Add(new AuxErrorInfo(tok, "Related location"));
     }
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Constructor for a bean.
        /// </summary>
        /// <param name="motionInit">
        /// Initializes the motion parameters of the particle (which model to use, whether it is a dry simulation etc.)
        /// </param>
        /// <param name="radius">
        /// The main lengthscale of the bean.
        /// </param>
        /// <param name="startPos">
        /// The initial position.
        /// </param>
        /// <param name="startAngl">
        /// The inital anlge.
        /// </param>
        /// <param name="activeStress">
        /// The active stress excerted on the fluid by the particle. Zero for passive particles.
        /// </param>
        /// <param name="startTransVelocity">
        /// The inital translational velocity.
        /// </param>
        /// <param name="startRotVelocity">
        /// The inital rotational velocity.
        /// </param>
        public Particle_Bean(InitializeMotion motionInit, double radius, double[] startPos = null, double startAngl = 0, double activeStress = 0, double[] startTransVelocity = null, double startRotVelocity = 0) : base(motionInit, startPos, startAngl, activeStress, startTransVelocity, startRotVelocity)
        {
            m_Radius = radius;
            Aux.TestArithmeticException(radius, "Particle radius");

            Motion.SetParticleMaxLengthscale(radius);
            Motion.SetParticleArea(Area);
            Motion.SetParticleMomentOfInertia(MomentOfInertia);
        }
Ejemplo n.º 25
0
        public static Aux Map(IDataRecord i)
        {
            Aux x = new Aux();

            x.matriculas = i.GetInt32(0);
            x.uc         = i.GetString(1);
            x.ano_letivo = i.GetDateTime(2);
            return(x);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Update Forces and Torque acting from fluid onto the particle
        /// </summary>
        /// <param name="U"></param>
        /// <param name="P"></param>
        /// <param name="levelSetTracker"></param>
        /// <param name="fluidViscosity"></param>
        /// <param name="cutCells"></param>
        /// <param name="dt"></param>
        public override double CalculateHydrodynamicTorque(ParticleHydrodynamicsIntegration hydrodynamicsIntegration, CellMask cutCells, double dt)
        {
            double tempTorque = hydrodynamicsIntegration.Torque(GetPosition(0), cutCells);

            Aux.TestArithmeticException(tempTorque, "temporal torque during calculation of hydrodynamics");
            TorqueMPISum(ref tempTorque);
            TorqueAddedDamping(ref tempTorque, dt);
            return(tempTorque);
        }
Ejemplo n.º 27
0
        public List <GroupData> GetGroupList()
        {
            List <GroupData> list = new List <GroupData>();

            OpenGroupsDialog();
            string count = Aux.ControlTreeView(GROUPWINTITITLE, "", "WindowsForms10.SysTreeView32.app.0.2c908d51", "GetItemCount", "#0", "");

            CloseGroupsDialog();
            return(list);
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Calculate the new translational velocity of the particle using a Crank Nicolson scheme.
 /// </summary>
 /// <param name="dt">Timestep</param>
 protected override double[] CalculateTranslationalVelocity(double dt)
 {
     double[] l_TranslationalVelocity = new double[m_Dim];
     for (int d = 0; d < m_Dim; d++)
     {
         l_TranslationalVelocity[d] = 0;
     }
     Aux.TestArithmeticException(l_TranslationalVelocity, "particle translational velocity");
     return(l_TranslationalVelocity);
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Constructor for a hippopede.
 /// </summary>
 /// <param name="motionInit">
 /// Initializes the motion parameters of the particle (which model to use, whether it is a dry simulation etc.)
 /// </param>
 /// <param name="length">
 /// The length of the horizontal halfaxis.
 /// </param>
 /// <param name="thickness">
 /// The length of the vertical halfaxis.
 /// </param>
 /// <param name="startPos">
 /// The initial position.
 /// </param>
 /// <param name="startAngl">
 /// The inital anlge.
 /// </param>
 /// <param name="activeStress">
 /// The active stress excerted on the fluid by the particle. Zero for passive particles.
 /// </param>
 /// <param name="startTransVelocity">
 /// The inital translational velocity.
 /// </param>
 /// <param name="startRotVelocity">
 /// The inital rotational velocity.
 /// </param>
 public Particle_Hippopede(InitializeMotion motionInit, double length, double thickness, double[] startPos = null, double startAngl = 0, double activeStress = 0, double[] startTransVelocity = null, double startRotVelocity = 0) : base(motionInit, startPos, activeStress, startAngl, startTransVelocity, startRotVelocity)
 {
     m_Length    = length;
     m_Thickness = thickness;
     Aux.TestArithmeticException(length, "Particle length");
     Aux.TestArithmeticException(thickness, "Particle thickness");
     Motion.SetParticleMaxLengthscale(GetLengthScales().Max());
     Motion.SetParticleArea(Area);
     Motion.SetParticleMomentOfInertia(MomentOfInertia);
 }
Ejemplo n.º 30
0
 public void Test_100()
 {
     var e1 = new HypoLambda();
     e1.Compile("5 if this.S == this.T else 4");
     Aux y1 = new Aux();
     y1.S = null;
     y1.T = "X";
     e1.Externals["this"] = y1;
     Assert.AreEqual(4.0, Convert.ToDouble(e1.Run()));
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Calculate the new translational velocity of the particle using a Crank Nicolson scheme.
 /// </summary>
 /// <param name="dt">Timestep</param>
 protected override double[] CalculateTranslationalVelocity(double dt, double collisionTimestep)
 {
     double[] l_TranslationalVelocity = new double[m_Dim];
     for (int d = 0; d < m_Dim; d++)
     {
         l_TranslationalVelocity[d] = GetTranslationalVelocity(1)[d] + GetTranslationalAcceleration(0)[d] * (dt - collisionTimestep);
     }
     Aux.TestArithmeticException(l_TranslationalVelocity, "particle translational velocity");
     return(l_TranslationalVelocity);
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Update Forces and Torque acting from fluid onto the particle
        /// </summary>
        /// <param name="hydrodynamicsIntegration"></param>
        /// <param name="fluidDensity"></param>
        public override Vector CalculateHydrodynamicForces(ParticleHydrodynamicsIntegration hydrodynamicsIntegration, double fluidDensity, CellMask cutCells, double dt)
        {
            Vector tempForces = new Vector(hydrodynamicsIntegration.Forces(out List <double[]>[] stressToPrintOut, cutCells));

            currentStress = TransformStressToPrint(stressToPrintOut);
            Aux.TestArithmeticException(tempForces, "temporal forces during calculation of hydrodynamics");
            tempForces = ForcesMPISum(tempForces);
            tempForces = CalculateGravitationalForces(fluidDensity, tempForces);
            return(tempForces);
        }
Ejemplo n.º 33
0
 public void Test_182()
 {
     var e1 = new HypoLambda();
     e1.Compile("this.X.X.S");
     var a1 = new Aux();
     a1.X = new Aux();
     a1.X.X = new Aux();
     a1.X.X.S = "Hola";
     e1.Externals["this"] = a1;
     Assert.AreEqual("Hola", e1.Run());
 }
Ejemplo n.º 34
0
 public void Test_180()
 {
     var e1 = new HypoLambda();
     e1.Compile("this.A1.A * this.A2.B");
     var a1 = new Aux();
     a1.A = 4;
     a1.B = 5;
     var a2 = new Aux();
     a2.A = 4;
     a2.B = 5;
     e1.Externals["this"] = new { A1 = a1, A2 = a2 };
     Assert.AreEqual(20.0, Convert.ToDouble(e1.Run()));
 }
Ejemplo n.º 35
0
 public void Test_130()
 {
     var exp = new HypoLambda();
     exp.Compile("x.X.A == 3");
     var x = new Aux();
     exp.Externals["x"] = x;
     Assert.Throws<NullReferenceException>(() => Convert.ToDouble(exp.Run()));
 }
Ejemplo n.º 36
0
 public static IList<Familia> GetNombresFamilias(string pre, Aux aux)
 {
     IList<Familia> lf = new List<Familia>();
     lf = CntAriGes.GetFamilias(pre);
     return lf;
 }
Ejemplo n.º 37
0
 public void Test_183()
 {
     var e1 = new HypoLambda("a1.X.X.S");
     var a1 = new Aux();
     a1.X = new Aux();
     a1.X.X = new Aux();
     a1.X.X.S = "Hola";
     e1.Externals["a1"] = a1;
     Assert.AreEqual("Hola", e1.Run());
 }
Ejemplo n.º 38
0
        public void Test_171()
        {
            var exp = new HypoLambda("this.A and (10 / this.A) > 0");

            var aux = new Aux();
            aux.A = 5.0;
            exp.Externals["this"] = aux;
            Assert.AreEqual(1.0, Convert.ToDouble(exp.Run()));

            aux.A = 0.0;
            Assert.AreEqual(0.0, Convert.ToDouble(exp.Run()));
        }
Ejemplo n.º 39
0
 public void Test_134()
 {
     var exp = new HypoLambda("x.X.A if 0 else 5");
     var x = new Aux();
     exp.Externals["x"] = x;
     Assert.AreEqual(5.0, Convert.ToDouble(exp.Run()));
 }
Ejemplo n.º 40
0
        public void Test_170()
        {
            var exp = new HypoLambda("1 if this.S else 1/this.S");

            var aux = new Aux();
            aux.S = "AAA";
            exp.Externals["this"] = aux;
            Assert.AreEqual(1.0, Convert.ToDouble(exp.Run()));
        }
        private List<PChart> RefreshPieChart()
        {
            EmPizza.Clear();

            List<string> busca = Repositorio.PeriodoRepositorio.GetOne();

            if (busca.Count == 0)
            {

                ParseJsonPeriodos();
                List<string> listaPeriodos = Repositorio.PeriodoRepositorio.GetOne();
                this.lpkPeriodos.ItemsSource = listaPeriodos;

                // List<Cota> listaFav = Repositorio.CotaRepositorio.Get(id);

                string mes = lpkPeriodos.SelectedItem.ToString();

                List<string> periodo = Repositorio.PeriodoRepositorio.BuscaPeriodo(mes);
                string per = Convert.ToString(periodo);
                //List<Classificacao> lista = Repositorio.ClassificRepositorio.ListaNome(per);
                // this.LstMoedas.ItemsSource = listaFav;

            }
            else
            {

                //PC1.DataSource = EmPizza;

                List<string> listaPeriodos = Repositorio.PeriodoRepositorio.GetOne();
                this.lpkPeriodos.ItemsSource = listaPeriodos;

                // List<Cota> listaFav = Repositorio.CotaRepositorio.Get(id);

                string mes = lpkPeriodos.SelectedItem.ToString();

                List<string> periodo = Repositorio.PeriodoRepositorio.BuscaPeriodo(mes);
                string per = periodo[0];

               // List<Classificacao> lista = Repositorio.ClassificRepositorio.ListaNome(per);
                List<Classificacao> listaTudo = Repositorio.ClassificRepositorio.Busca();

               List<double> listaPreco = Repositorio.CompraRepositorio.GetPreco(per);

                List<CompraEntidade> listaPeriodo = Repositorio.CompraRepositorio.GetPeriodo(per);

                if (listaPeriodo.Count != 0)
                {

                    //Resetar Classificação
                foreach (var item in listaTudo)
                {
                    Classificacao classific = new Classificacao
                        {
                            id = item.id,
                            nome = item.nome,
                            referencia = 0,
                            //total = listaPreco.Sum()
                            total = 0

                        };

                    ClassificRepositorio.Update(classific);
                }

                //Aux CompraAux;
                foreach (var item in listaPeriodo)
                {
                    foreach (var itemClassific in listaTudo)
                    {
                        if (item.classificacao == itemClassific.nome && itemClassific.referencia == 0)
                        {
                            //List<double> listaTotal = Repositorio.PeriodoRepositorio.buscaTotal(com);
                            Aux compras = new Aux
                            {
                                id = item.id,
                                preco = item.preco,
                                classificacao = item.classificacao,
                                periodo = item.periodo,

                            };
                           List<double> listaTotal = Repositorio.PeriodoRepositorio.buscaTotal(compras);

                            Classificacao classific = new Classificacao
                                {
                                    id = itemClassific.id,
                                    nome = itemClassific.nome,
                                    referencia = 1,
                                  total = listaTotal.Sum()

                                };

                            ClassificRepositorio.Update(classific);
                            listaTudo = Repositorio.ClassificRepositorio.Busca();
                        }
                        else
                        {
                            if (listaPeriodo.Count == 0)
                            {

                                //Resetar Classificação
                                Classificacao classific = new Classificacao
                                {
                                    id = itemClassific.id,
                                    nome = itemClassific.nome,
                                    referencia = 0,
                                    //total = listaPreco.Sum()
                                    total = 0
                                };
                                ClassificRepositorio.Update(classific);
                            }
                        }

                    //EmPizza.Add(pieChart);
                    //ClassificRepositorio.Update(classific);

                    }

                }

            }
                else
                {
                    //EmPizza.Add(null);
                    //PC1.DataSource = null;

                    //Resetar Classificação
                    foreach (var item in listaTudo)
                    {
                        Classificacao classific = new Classificacao
                        {
                            id = item.id,
                            nome = item.nome,
                            referencia = 0,
                            //total = listaPreco.Sum()
                            total = 0

                        };

                        ClassificRepositorio.Update(classific);
                    }

                }

                //List<double> listaTotal = Repositorio.PeriodoRepositorio.buscaTotal(CompraAux);

                //foreach (var item in listaPeriodo)
                //{

                //    double totalizando = item.Sum();

                //    foreach (var itemClas in listaTudo)
                //    {

                //        if (item.classificacao == itemClas.nome)
                //        {

                //            Classificacao classific = new Classificacao
                //                {
                //                    id = itemClas.id,
                //                    nome = itemClas.nome,
                //                    referencia = itemClas.referencia,
                //                    //total = listaPreco.Sum()
                //                    total = listaPeriodo.

                //                };

                //            ClassificRepositorio.Update(classific);

                //        }
                //    }
                //}

                //tentei concatenar mas parece que nao deu muito certo continuar tentando

                //foreach (var itemCompra in listaPeriodo)
                //{
                //    foreach (var item in listaTudo)
                //    {
                //        if (item.nome == itemCompra.classificacao)
                //        {

                //            Classificacao classific = new Classificacao
                //            {
                //                id = item.id,
                //                nome = item.nome,
                //                referencia = item.referencia,
                //                //total = listaPreco.Sum()
                //                total = itemCompra.preco

                //            };

                //            ClassificRepositorio.Update(classific);

                //        }

                //    }

                //}

                // this.LstMoedas.ItemsSource = listaFav;

                //string apelido = lpkMoedas.SelectedItem.ToString();
                 List<Classificacao> listaAux = Repositorio.ClassificRepositorio.Busca();

                // List<Classificacao> listaInteiro = Repositorio.ClassificRepositorio.BuscaInteiro(1);

                // this.LstMoedas.ItemsSource = listaFav;
                //double contador = (Convert.ToDouble(lista.Sum()));
                //    List<CompraEntidade> lista = Repositorio.CompraRepositorio.Get(id);

                 //if (EmPizza[0] != null)
                 //{
                 foreach (var item2 in listaAux)
                     {
                         // DateTime dtt = Convert.ToDateTime(item2.Data);
                         //Console.WriteLine("Year: {0}, Month: {1}, Day: {2}", dtt.Year, dtt.Month, dtt.Day);
                         //double total = (Convert.ToDouble(item2.Sum()));
                         //EmPizza.Clear();
                         if (item2.total != 0)
                         {

                             PChart pieChart = new PChart
                             {
                                 title = item2.nome,
                                 //Convert.ToString(dtt.Day) + "/" + Convert.ToString(dtt.Month),
                                 value = item2.total
                             };
                             EmPizza.Add(pieChart);
                         }
                         else
                         {
                              EmPizza = EmPizzaZero;
                             //PChart pieChart = new PChart
                             //{
                             //    title = "",
                             //    //Convert.ToString(dtt.Day) + "/" + Convert.ToString(dtt.Month),
                             //    value = 0
                             //};
                             //EmPizza.Add(pieChart);
                         }

                     }
                    //else
                    //{
                    //    EmPizza= null;

                    //}

                //}
            }
            //if (EmPizza.Count != 0)
            //{

                return EmPizza;

            //}
            //else
            //{

            //    return EmPizzaZero;
            //}
        }
Ejemplo n.º 42
0
 public void Test_22()
 {
     var exp = new HypoLambda();
     exp.Compile("(a.A+3)*5");
     Aux y = new Aux();
     y.A = 2;
     y.B = 1;
     exp.Externals["a"] = y;
     Assert.AreEqual(25.0, Convert.ToDouble(exp.Run()));
 }
Ejemplo n.º 43
0
        public void Test_ToFrom_PCode()
        {
            var e1 = new HypoLambda();
            e1.Compile("(this.A + this.B) * 5");
            Aux y1 = new Aux();
            y1.A = 2;
            y1.B = 1;
            e1.Externals["this"] = y1;
            Assert.AreEqual(15.0, Convert.ToDouble(e1.Run()));

            var pc1 = e1.ToPortablePCODE();

            var e2 = new HypoLambda();
            e2.FromPortablePCODE(pc1);
            //Compruebo la deserealizacion.
            Aux y2 = new Aux();
            y2.A = 2;
            y2.B = 1;
            e2.Externals["this"] = y2;
            Assert.AreEqual(15.0, Convert.ToDouble(e2.Run()));
        }
Ejemplo n.º 44
0
 public void Test_132()
 {
     var exp = new HypoLambda("1 or x.X.A == 3");
     var x = new Aux();
     exp.Externals["x"] = x;
     Assert.AreEqual(1.0, Convert.ToDouble(exp.Run()));
 }
Ejemplo n.º 45
0
 public void Test_105()
 {
     var e1 = new HypoLambda();
     e1.Compile("5 if this.S and this.S != \"\" else 4");
     Aux y1 = new Aux();
     y1.S = "X";
     e1.Externals["this"] = y1;
     Assert.AreEqual(5.0, Convert.ToDouble(e1.Run()));
 }
Ejemplo n.º 46
0
 public void Test_26()
 {
     var exp = new HypoLambda();
     exp.Compile("(this.A+this.B)*5");
     Aux y = new Aux();
     y.A = 2;
     y.B = 1;
     exp.Externals["this"] = y;
     Assert.AreEqual(15.0, Convert.ToDouble(exp.Run()));
 }