private BinaryOperatorAnalysisResult(OperatorAnalysisResultKind kind, BinaryOperatorSignature signature, Conversion leftConversion, Conversion rightConversion)
 {
     this.Kind = kind;
     this.Signature = signature;
     this.LeftConversion = leftConversion;
     this.RightConversion = rightConversion;
 }
        private ForEachEnumeratorInfo(
            TypeSymbol collectionType,
            TypeSymbol elementType,
            MethodSymbol getEnumeratorMethod,
            MethodSymbol currentPropertyGetter,
            MethodSymbol moveNextMethod,
            bool needsDisposeMethod,
            Conversion collectionConversion,
            Conversion currentConversion,
            Conversion enumeratorConversion,
            BinderFlags location)
        {
            Debug.Assert((object)collectionType != null, "Field 'collectionType' cannot be null");
            Debug.Assert((object)elementType != null, "Field 'elementType' cannot be null");
            Debug.Assert((object)getEnumeratorMethod != null, "Field 'getEnumeratorMethod' cannot be null");
            Debug.Assert((object)currentPropertyGetter != null, "Field 'currentPropertyGetter' cannot be null");
            Debug.Assert((object)moveNextMethod != null, "Field 'moveNextMethod' cannot be null");

            this.CollectionType = collectionType;
            this.ElementType = elementType;
            this.GetEnumeratorMethod = getEnumeratorMethod;
            this.CurrentPropertyGetter = currentPropertyGetter;
            this.MoveNextMethod = moveNextMethod;
            this.NeedsDisposeMethod = needsDisposeMethod;
            this.CollectionConversion = collectionConversion;
            this.CurrentConversion = currentConversion;
            this.EnumeratorConversion = enumeratorConversion;
            this.Location = location;
        }
 public ConversationWrapper(Conversion conv, Operand op, Type @from, Type to)
 {
     _conv = conv;
     _op = op;
     _to = to;
     _from = @from;
 }
        /// <summary>
        /// Constructs a custom conversion rule.
        /// </summary>
        /// <param name="conversion">The conversion operation.</param>
        public CustomConversionRule(Conversion conversion)
        {
            if (conversion == null)
                throw new ArgumentNullException("conversion");

            this.conversion = conversion;
        }
		public ConversionResolveResult(IType targetType, ResolveResult input, Conversion conversion)
			: base(targetType)
		{
			if (input == null)
				throw new ArgumentNullException("input");
			this.Input = input;
			this.Conversion = conversion;
		}
Example #6
0
			public void ProcessConversion(Expression expression, ResolveResult result, Conversion conversion, IType targetType)
			{
				if (!nodesWithConversions.Add(expression))
					throw new InvalidOperationException("Duplicate ProcessConversion() call");
				if (!conversion.IsValid && !allowErrors) {
					Console.WriteLine("Compiler error at " + fileName + ":" + expression.StartLocation + ": Cannot convert from " + result + " to " + targetType);
				}
			}
 protected BoundExpression CreateConversion(
     BoundExpression source,
     Conversion conversion,
     TypeSymbol destination,
     DiagnosticBag diagnostics)
 {
     return CreateConversion(source.Syntax, source, conversion, isCast: false, destination: destination, diagnostics: diagnostics);
 }
Example #8
0
 static void Main()
 {
     Conversion conversions = new Conversion();
     double fahr = 62;
     double celc = 30;
     Console.WriteLine("140 fahrenheit is " + conversions.FarToCel(fahr));
     Console.WriteLine("30 celcius is " + conversions.CelToFar(celc));
 }
 protected BoundExpression CreateConversion(
     CSharpSyntaxNode syntax,
     BoundExpression source,
     Conversion conversion,
     bool isCast,
     TypeSymbol destination,
     DiagnosticBag diagnostics)
 {
     return CreateConversion(syntax, source, conversion, isCast, source.WasCompilerGenerated, destination, diagnostics);
 }
		void TestOperator(ResolveResult condition, ResolveResult trueExpr, ResolveResult falseExpr,
		                  Conversion conditionConv, Conversion trueConv, Conversion falseConv,
		                  Type expectedResultType)
		{
			var corr = (ConditionalOperatorResolveResult)resolver.ResolveConditional(condition, trueExpr, falseExpr);
			AssertType(expectedResultType, corr);
			AssertConversion(corr.Condition, condition, conditionConv, "Condition Conversion");
			AssertConversion(corr.True, trueExpr, trueConv, "True Conversion");
			AssertConversion(corr.False, falseExpr, falseConv, "False Conversion");
		}
Example #11
0
        public static Conversion Is(this Tuple<Measurement, Measurement> conversion, decimal absolute)
        {
            decimal scalar = absolute / conversion.Item1.Value;

            var result = new Conversion(conversion.Item1.Unit, conversion.Item2.Unit);

            result.AddStep(new ScalingConversion(scalar));

            return result;
        }
Example #12
0
		void TestCast(Type targetType, ResolveResult input, Conversion expectedConversion)
		{
			IType type = targetType.ToTypeReference().Resolve(context);
			ResolveResult rr = resolver.ResolveCast(type, input);
			AssertType(targetType, rr);
			Assert.AreEqual(typeof(ConversionResolveResult), rr.GetType());
			var crr = (ConversionResolveResult)rr;
			Assert.AreEqual(expectedConversion, crr.Conversion, "ConversionResolveResult.Conversion");
			Assert.AreSame(input, crr.Input, "ConversionResolveResult.Input");
		}
Example #13
0
		void TestCast(Type targetType, ResolveResult input, Conversion expectedConversion)
		{
			IType type = compilation.FindType(targetType);
			ResolveResult rr = resolver.ResolveCast(type, input);
			AssertType(targetType, rr);
			Assert.AreEqual(typeof(ConversionResolveResult), rr.GetType());
			var crr = (ConversionResolveResult)rr;
			Assert.AreEqual(expectedConversion, crr.Conversion, "ConversionResolveResult.Conversion");
			Assert.AreSame(input, crr.Input, "ConversionResolveResult.Input");
		}
Example #14
0
        public void SelectsConversion()
        {
            var spec = new IntegerGreaterThanZero();
            var converter = (Expression<Func<double, int>>)(d => Math.Sign(d));
            var convertedSpec = new Conversion<double, int>(spec, converter);

            Assert.That(convertedSpec.IsSatisfiedBy(1), Is.True);
            Assert.That(convertedSpec.IsSatisfiedBy(0), Is.False);
            Assert.That(convertedSpec.IsSatisfiedBy(-1), Is.False);
        }
        private BoundExpression MakeAsOperator(
            BoundAsOperator oldNode,
            CSharpSyntaxNode syntax,
            BoundExpression rewrittenOperand,
            BoundTypeExpression rewrittenTargetType,
            Conversion conversion,
            TypeSymbol rewrittenType)
        {
            // TODO: Handle dynamic operand type and target type
            Debug.Assert(rewrittenTargetType.Type.Equals(rewrittenType));

            // target type cannot be a non-nullable value type
            Debug.Assert(!rewrittenType.IsValueType || rewrittenType.IsNullableType());

            if (!_inExpressionLambda)
            {
                ConstantValue constantValue = Binder.GetAsOperatorConstantResult(rewrittenOperand.Type, rewrittenType, conversion.Kind, rewrittenOperand.ConstantValue);

                if (constantValue != null)
                {
                    Debug.Assert(constantValue.IsNull);
                    BoundExpression result = rewrittenType.IsNullableType() ? new BoundDefaultOperator(syntax, rewrittenType) : MakeLiteral(syntax, constantValue, rewrittenType);

                    if (rewrittenOperand.ConstantValue != null)
                    {
                        // No need to preserve any side-effects from the operand. 
                        // We also can keep the "constant" notion of the result, which
                        // enables some optimizations down the road.
                        return result;
                    }

                    return new BoundSequence(
                        syntax: syntax,
                        locals: ImmutableArray<LocalSymbol>.Empty,
                        sideEffects: ImmutableArray.Create<BoundExpression>(rewrittenOperand),
                        value: result,
                        type: rewrittenType);
                }

                if (conversion.IsImplicit)
                {
                    // Operand with bound implicit conversion to target type.
                    // We don't need a runtime check, generate a conversion for the operand instead.
                    return MakeConversionNode(syntax, rewrittenOperand, conversion, rewrittenType, @checked: false);
                }
            }

            return oldNode.Update(rewrittenOperand, rewrittenTargetType, conversion, rewrittenType);
        }
 public static UserDefinedConversionAnalysis Lifted(
     MethodSymbol op,
     Conversion sourceConversion,
     Conversion targetConversion,
     TypeSymbol fromType,
     TypeSymbol toType)
 {
     return new UserDefinedConversionAnalysis(
         UserDefinedConversionAnalysisKind.ApplicableInLiftedForm,
         op,
         sourceConversion,
         targetConversion,
         fromType,
         toType);
 }
 private UserDefinedConversionAnalysis(
     UserDefinedConversionAnalysisKind kind,
     MethodSymbol op,
     Conversion sourceConversion,
     Conversion targetConversion,
     TypeSymbol fromType,
     TypeSymbol toType)
 {
     this.Kind = kind;
     this.Operator = op;
     this.SourceConversion = sourceConversion;
     this.TargetConversion = targetConversion;
     this.FromType = fromType;
     this.ToType = toType;
 }
Example #18
0
        public IEnumerable<Conversion> Conversions()
        {
            XPathNavigator nav = document.CreateNavigator();
            foreach (XPathNavigator n in nav.Select("ucumTests/conversion/case"))
            {
                Conversion conversion = new Conversion();
                conversion.Id = n.SelectSingleNode("@id").Value;
                conversion.Value = n.SelectSingleNode("@value").Value;
                conversion.SourceUnit = n.SelectSingleNode("@srcUnit").Value;
                conversion.DestUnit = n.SelectSingleNode("@dstUnit").Value; 
                conversion.Outcome = n.SelectSingleNode("@outcome").Value;
                //validation.Reason = = n.SelectSingleNode("unit").Value ;
                yield return conversion;

            }
        }
        protected BoundExpression CreateConversion(
            CSharpSyntaxNode syntax,
            BoundExpression source,
            Conversion conversion,
            bool isCast,
            bool wasCompilerGenerated,
            TypeSymbol destination,
            DiagnosticBag diagnostics)
        {
            Debug.Assert(source != null);
            Debug.Assert((object)destination != null);

            // We need to preserve any conversion that changes the type (even identity conversions, like object->dynamic),
            // or that was explicitly written in code (so that GetSemanticInfo can find the syntax in the bound tree).
            if (conversion.Kind == ConversionKind.Identity && !isCast && source.Type == destination)
            {
                return source;
            }

            ReportDiagnosticsIfObsolete(diagnostics, conversion, syntax, hasBaseReceiver: false);

            if (conversion.IsMethodGroup)
            {
                return CreateMethodGroupConversion(syntax, source, conversion, isCast, destination, diagnostics);
            }

            if (conversion.IsAnonymousFunction && source.Kind == BoundKind.UnboundLambda)
            {
                return CreateAnonymousFunctionConversion(syntax, source, conversion, isCast, destination, diagnostics);
            }

            if (conversion.IsUserDefined)
            {
                return CreateUserDefinedConversion(syntax, source, conversion, isCast, destination, diagnostics);
            }

            ConstantValue constantValue = this.FoldConstantConversion(syntax, source, conversion, destination, diagnostics);
            return new BoundConversion(
                syntax,
                source,
                conversion,
                IsCheckedConversion(source.Type, destination),
                explicitCastInCode: isCast && !wasCompilerGenerated,
                constantValueOpt: constantValue,
                type: destination)
            { WasCompilerGenerated = wasCompilerGenerated };
        }
Example #20
0
 private float GetAngle(Vector3 vec, Conversion axis)
 {
     switch (axis)
     {
         case Conversion.X:
             return vec.x;
         case Conversion.Y:
             return vec.y;
         case Conversion.Z:
             return vec.z;
         case Conversion.nX:
             return -vec.x;
         case Conversion.nY:
             return -vec.y;
         case Conversion.nZ:
             return -vec.z;
         default:
             return 0;
     }
 }
Example #21
0
        public void ConvertsCriteria()
        {
            var spec = new IntegerPredicate(i => i == 0);
            var converter = (Expression<Func<double, int>>)(d => Math.Sign(d));
            var criteria = spec.Criteria;
            var convertedSpec = new Conversion<double, int>(spec, converter);
            var convertedCriteria = convertedSpec.Criteria;

            Assert.That(convertedCriteria.Body, Is.AssignableTo<BinaryExpression>());

            var binary = (BinaryExpression)convertedCriteria.Body;

            Assert.That(binary.NodeType, Is.EqualTo(ExpressionType.Equal));
            Assert.That(binary.Left, Is.EqualTo(converter.Body));
            Assert.That(binary.Right, Is.EqualTo(((BinaryExpression)criteria.Body).Right));
            Assert.That(binary.Method, Is.Null);
            Assert.That(binary.IsLifted, Is.False);
            Assert.That(binary.IsLiftedToNull, Is.False);
            Assert.That(binary.Conversion, Is.Null);

            ExpressionWriter.Write(convertedCriteria);
        }
        private BoundExpression MakeAsOperator(
            BoundAsOperator oldNode,
            CSharpSyntaxNode syntax,
            BoundExpression rewrittenOperand,
            BoundTypeExpression rewrittenTargetType,
            Conversion conversion,
            TypeSymbol rewrittenType)
        {
            // TODO: Handle dynamic operand type and target type
            Debug.Assert(rewrittenTargetType.Type.Equals(rewrittenType));

            // target type cannot be a non-nullable value type
            Debug.Assert(!rewrittenType.IsValueType || rewrittenType.IsNullableType());

            if (!inExpressionLambda)
            {
                ConstantValue constantValue = Binder.GetAsOperatorConstantResult(rewrittenOperand.Type, rewrittenType, conversion.Kind, rewrittenOperand.ConstantValue);
                Debug.Assert(constantValue == null || constantValue.IsNull);

                if (conversion.IsImplicit)
                {
                    // Operand with bound implicit conversion to target type.
                    // We don't need a runtime check, generate a conversion for the operand instead.
                    return MakeConversion(syntax, rewrittenOperand, conversion, rewrittenType, @checked: false, constantValueOpt: constantValue);
                }
                else if (constantValue != null)
                {
                    return new BoundSequence(
                        syntax: syntax,
                        locals: ImmutableArray<LocalSymbol>.Empty,
                        sideEffects: ImmutableArray.Create<BoundExpression>(rewrittenOperand),
                        value: MakeLiteral(syntax, constantValue, rewrittenType),
                        type: rewrittenType);
                }
            }

            return oldNode.Update(rewrittenOperand, rewrittenTargetType, conversion, rewrittenType);
        }
Example #23
0
 public static bool CanChange(this object value, Type destinationType, CultureInfo culture, Conversion options)
 {
     return(TryToChange(value, destinationType, out _, options, culture));
 }
Example #24
0
        public void PipelineWithWorkspaceAndTemplateStepTest()
        {
            //Arrange
            Conversion conversion = new Conversion();
            //Source is: https://raw.githubusercontent.com/microsoft/azure-pipelines-yaml/master/templates/xamarin.ios.yml
            string yaml = @"
name: $(Version).$(rev:r)

variables:
- group: Common Netlify

trigger:
  branches:
    include:
    - dev
    - feature/*
    - hotfix/*
  paths:
    include:
    - 'Netlify/*'
    exclude:
    - 'pipelines/*'
    - 'scripts/*'
    - '.editorconfig'
    - '.gitignore'
    - 'README.md'

stages:
# Build Pipeline
- stage: Build
  jobs:
  - job: HostedVs2017
    displayName: Hosted VS2017
    pool:
      name: Hosted VS2017
      demands: npm
    workspace:
      clean: all
    
    steps:
    - template: templates/npm-build-steps.yaml
      parameters:
        extensionName: $(ExtensionName)
";

            //Act
            ConversionResponse gitHubOutput = conversion.ConvertAzurePipelineToGitHubAction(yaml);

            //Assert
            string expected = @"
#There is no conversion path for templates, currently there is no support to call other actions/yaml files from a GitHub Action
name: ${{ env.Version }}.${GITHUB_RUN_NUMBER}
on:
  push:
    branches:
    - dev
    - feature/*
    - hotfix/*
    paths:
    - Netlify/*
    paths-ignore:
    - pipelines/*
    - scripts/*
    - .editorconfig
    - .gitignore
    - README.md
env:
  group: Common Netlify
jobs:
  Build_Stage_HostedVs2017:
    name: Hosted VS2017
    runs-on: Hosted VS2017
    steps:
    - uses: actions/checkout@v2
    - #: There is no conversion path for templates, currently there is no support to call other actions/yaml files from a GitHub Action
      run: |
        #templates/npm-build-steps.yaml
        extensionName: ${{ env.ExtensionName }}
";

            expected = UtilityTests.TrimNewLines(expected);
            Assert.AreEqual(expected, gitHubOutput.actionsYaml);
        }
Example #25
0
 protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
 {
     pageSize = Conversion.ParseInt(ddlPageSize.SelectedValue);
     LoadData();
 }
Example #26
0
 /// <summary>
 /// Reads a <see cref="Boolean"/> value from the current stream and advances the current position of the stream
 /// by one byte. The bytes of the value are swapped according to the stream data endianness, which effectively
 /// does nothing for a <see cref="Boolean"/>.
 /// </summary>
 /// <returns><c>true</c> if the byte is nonzero; <c>false</c> otherwise.</returns>
 /// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
 /// <exception cref="ObjectDisposedException">The stream is closed.</exception>
 /// <exception cref="IOException">An I/O error occurred.</exception>
 public override bool ReadBoolean() =>
 ReverseEndianness?Conversion.ReverseEndianness(base.ReadBoolean()) : base.ReadBoolean();
Example #27
0
        public virtual Expression VisitConversion(Conversion conversion)
        {
            var exp = conversion.Expression.Accept(this);

            if (exp != Constant.Invalid)
            {
                var ptCvt = conversion.DataType.ResolveAs <PrimitiveType>();
                var ptSrc = conversion.SourceDataType.ResolveAs <PrimitiveType>();
                if (exp is Constant c && ptCvt != null)
                {
                    if (ptSrc != null)
                    {
                        if (ptCvt.Domain == Domain.Real)
                        {
                            if (ptSrc.Domain == Domain.Real)
                            {
                                if (ptCvt.Size < ptSrc.Size)
                                {
                                    // Real-to-real conversion.
                                    Changed = true;
                                    return(ConstantReal.Create(ptCvt, c.ToReal64()));
                                }
                            }
                            else if (ptSrc.IsWord)
                            {
                                // Raw bit pattern reinterpretation.
                                Changed = true;
                                return(CastRawBitsToReal(ptCvt, c));
                            }
                            else
                            {
                                // integer to real conversion
                                Changed = true;
                                return(ConstantReal.Create(ptCvt, c.ToInt64()));
                            }
                        }
                        else if ((ptSrc.Domain & Domain.Integer) != 0)
                        {
                            if (ptSrc != null)
                            {
                                if (ptSrc.Domain == Domain.SignedInt)
                                {
                                    Changed = true;
                                    return(Constant.Create(ptCvt, c.ToInt64()));
                                }
                                else if (ptSrc.Domain.HasFlag(Domain.SignedInt))
                                {
                                    Changed = true;
                                    return(Constant.Create(ptCvt, c.ToUInt64()));
                                }
                            }
                        }
                    }
                }
                if (exp is Identifier id &&
                    ctx.GetDefiningExpression(id) is MkSequence seq)
                {
                    // If we are casting a SEQ, and the corresponding element is >=
                    // the size of the cast, then use deposited part directly.
                    var lsbElem  = seq.Expressions[seq.Expressions.Length - 1];
                    int sizeDiff = lsbElem.DataType.Size - conversion.DataType.Size;
                    if (sizeDiff >= 0)
                    {
                        foreach (var elem in seq.Expressions)
                        {
                            ctx.RemoveExpressionUse(elem);
                        }
                        ctx.UseExpression(lsbElem);
                        Changed = true;
                        if (sizeDiff > 0)
                        {
                            return(new Conversion(lsbElem, lsbElem.DataType, conversion.DataType));
                        }
                        else
                        {
                            return(lsbElem);
                        }
                    }
                }
                if (exp is ProcedureConstant pc && conversion.DataType.BitSize == pc.DataType.BitSize)
                {
                    // (wordnn) procedure_const => procedure_const
                    return(pc);
                }
                if (exp.DataType.BitSize == conversion.DataType.BitSize)
                {
                    // Redundant word-casts can be stripped.
                    if (conversion.DataType.IsWord)
                    {
                        return(exp);
                    }
                }
                conversion = new Conversion(exp, exp.DataType, conversion.DataType);
            }
            if (convertConvertRule.Match(conversion))
            {
                Changed = true;
                return(convertConvertRule.Transform());
            }
            return(conversion);
        }
Example #28
0
        private void pdFacturaTDelivery_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            // formato de alineacion derecha
            StringFormat alineacion = new StringFormat();

            alineacion.Alignment = StringAlignment.Far;
            //fin formato alineacion



            e.Graphics.DrawString(Datos.nombreComercial, new Font("Courier New Condensada", 11, FontStyle.Bold), Brushes.Black, new Point(15, 12));
            e.Graphics.DrawString(Datos.RazonSocial, new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(110, 27));
            e.Graphics.DrawString("RUC: " + Datos.Ruc, new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(90, 40));
            e.Graphics.DrawString(Datos.Direccion, new Font("Courier New Condensada", 6, FontStyle.Regular), Brushes.Black, new Point(20, 52));
            e.Graphics.DrawString(Datos.Departmaneto, new Font("Courier New Condensada", 7, FontStyle.Regular), Brushes.Black, new Point(0, 64));
            e.Graphics.DrawString("TICKET FACTURA", new Font("Courier New Condensada", 8, FontStyle.Bold), Brushes.Black, new Point(90, 80));

            //nÚMERO COMPROBANTE
            e.Graphics.DrawString(txtSerie.Text + " - " + txtNumero.Text, new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(110, 94));



            //DAtos PErsona
            e.Graphics.DrawString("RAZ: " + txtCliente.Text, new Font("Courier New Condensada", 6, FontStyle.Regular), Brushes.Black, new Point(10, 112));
            e.Graphics.DrawString("RUC: " + txtNroIdentidad.Text, new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(10, 122));
            e.Graphics.DrawString("DIRECCION: " + txtDireccion.Text, new Font("Courier New Condensada", 6, FontStyle.Regular), Brushes.Black, new Point(10, 135));
            e.Graphics.DrawString("T. Pago: " + cboTipoPago.Text + " - F:" + DateTime.Now.ToShortDateString() + " / H: " + DateTime.Now.ToShortTimeString(), new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(10, 148));


            //Encabezado
            e.Graphics.DrawString("Cant.", new Font("Courier New Condensada", 8, FontStyle.Bold), Brushes.Black, new Point(10, 175));
            e.Graphics.DrawString("Producto", new Font("Courier New Condensada", 8, FontStyle.Bold), Brushes.Black, new Point(46, 175));
            e.Graphics.DrawString("Prec. Uni.", new Font("Courier New Condensada", 8, FontStyle.Bold), Brushes.Black, new Point(185, 175), alineacion);
            e.Graphics.DrawString("Importe", new Font("Courier New Condensada", 8, FontStyle.Bold), Brushes.Black, new Point(250, 175), alineacion);
            e.Graphics.DrawString("==========================================", new Font("Courier New Condensada", 8, FontStyle.Bold), Brushes.Black, new Point(10, 186));

            int SUMATORIA = 0;

            //DETALLADO
            if (cboTipoImpresion.Text == "D")
            {
                foreach (DataGridViewRow row in dgvPedido.Rows)
                {
                    decimal untario, costo;
                    decimal can_2;
                    int     cantidad;
                    string  descri;

                    descri = fn.selectValue("select p.Producto +' '+ pr.Presentacion as Presentacion from Presentacion pr INNER JOIN producto p on pr.IDProducto = p.IDProducto where IDPresentacion ='" + row.Cells["cnCodigo"].Value.ToString() + "'");

                    can_2   = Convert.ToDecimal(row.Cells["cnCantidad"].Value);
                    untario = Convert.ToDecimal(row.Cells["cnPrecio"].Value);
                    costo   = Convert.ToDecimal(row.Cells["cnImporte"].Value);


                    can_2    = Math.Round(can_2, 0);
                    untario  = Math.Round(untario, 2);
                    costo    = Math.Round(costo, 2);
                    cantidad = Convert.ToInt16(can_2);



                    e.Graphics.DrawString("" + cantidad, new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(10, 189 + SUMATORIA + 5));
                    e.Graphics.DrawString("" + descri, new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(46, 189 + SUMATORIA + 5));

                    e.Graphics.DrawString("" + untario.ToString("#,#.00"), new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(185, 202 + SUMATORIA + 8), alineacion);
                    e.Graphics.DrawString("" + costo.ToString("#,#.00"), new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(250, 202 + SUMATORIA + 8), alineacion);
                    e.Graphics.DrawString("------------------------------------------------------------------------", new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(10, 215 + SUMATORIA));
                    SUMATORIA = SUMATORIA + 30;
                }
            }
            else
            {
                e.Graphics.DrawString("1", new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(10, 189 + SUMATORIA + 5));
                e.Graphics.DrawString("POR CONSUMO", new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(46, 189 + SUMATORIA + 5));

                e.Graphics.DrawString(Convert.ToDecimal(lblTotal.Text).ToString("#,#.00"), new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(185, 202 + SUMATORIA + 8), alineacion);
                e.Graphics.DrawString(Convert.ToDecimal(lblTotal.Text).ToString("#,#.00"), new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(250, 202 + SUMATORIA + 8), alineacion);
                e.Graphics.DrawString("------------------------------------------------------------------------", new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(10, 215 + SUMATORIA));
                SUMATORIA = SUMATORIA + 30;
            }


            string letras;
            double sub_total2 = 0, igv2 = 0, total2 = 0;

            sub_total2 = Convert.ToDouble(lblTotal.Text) / 1.18;

            igv2 = sub_total2 * 0.18;

            total2 = Convert.ToDouble(lblTotal.Text);
            Clases.Conversion CONVERSION = new Conversion();
            letras = CONVERSION.enletras(lblTotal.Text.ToString());


            e.Graphics.DrawString("Descuento:", new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(70, 230 + SUMATORIA - 25));//276
            e.Graphics.DrawString("" + txtDescuentoSoles.Text, new Font("Courier New Condensada", 8, FontStyle.Bold), Brushes.Black, new Point(250, 230 + SUMATORIA - 25), alineacion);

            e.Graphics.DrawString("SubTotal:", new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(70, 243 + SUMATORIA - 25));//276
            e.Graphics.DrawString("" + lblSubTotal.Text, new Font("Courier New Condensada", 8, FontStyle.Bold), Brushes.Black, new Point(250, 243 + SUMATORIA - 25), alineacion);


            e.Graphics.DrawString("Igv:", new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(70, 256 + SUMATORIA - 25));//276
            e.Graphics.DrawString("" + lblIgv.Text, new Font("Courier New Condensada", 8, FontStyle.Bold), Brushes.Black, new Point(250, 256 + SUMATORIA - 25), alineacion);


            e.Graphics.DrawString("Total:", new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(70, 269 + SUMATORIA - 25));//276
            e.Graphics.DrawString("" + lblTotal.Text, new Font("Courier New Condensada", 8, FontStyle.Bold), Brushes.Black, new Point(250, 269 + SUMATORIA - 25), alineacion);

            string letras_ofi, mon, moneda = "Soles";

            if (moneda == "Soles")
            {
                mon = "SOLES";
            }
            else
            {
                mon = "DOLARES";
            }

            letras_ofi = "SON: " + letras + " " + mon;

            string letras1 = "", letras2 = "";
            int    indice_letras = -1, indiceletras2 = 46;

            while (indice_letras <= 45)
            {
                indice_letras += 1;

                if (indice_letras < letras_ofi.Length)
                {
                    letras1 += letras_ofi[indice_letras];
                }
            }
            while (indiceletras2 < letras_ofi.Length - 1)
            {
                indiceletras2 += 1;
                letras2       += letras_ofi[indiceletras2];
            }

            e.Graphics.DrawString("" + letras1, new Font("Courier New Condensada", 7, FontStyle.Regular), Brushes.Black, new Point(5, 282 + SUMATORIA - 25));
            e.Graphics.DrawString("" + letras2, new Font("Courier New Condensada", 7, FontStyle.Regular), Brushes.Black, new Point(5, 292 + SUMATORIA - 25));


            string l1, l2;

            l1 = "Número de Autorización:	"+ Datos.nroAutorizacion + "";
            l2 = "Serie de Impresora: " + Datos.serieImpresora + "";


            e.Graphics.DrawString("" + l1, new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(10, 305 + SUMATORIA));
            e.Graphics.DrawString("" + l2, new Font("Courier New Condensada", 8, FontStyle.Regular), Brushes.Black, new Point(10, 318 + SUMATORIA));



            e.Graphics.DrawString("Gracias por su compra.", new Font("Courier New Condensada", 7, FontStyle.Bold), Brushes.Black, new Point(75, 331 + SUMATORIA));
        }
Example #29
0
 public virtual void ProcessConversion(Expression expression, ResolveResult result, Conversion conversion, IType targetType)
 {
 }
        /// <summary>
        /// Lower "using (ResourceType resource = expression) statement" to a try-finally block.
        /// </summary>
        /// <remarks>
        /// Assumes that the local symbol will be declared (i.e. in the LocalsOpt array) of an enclosing block.
        /// Assumes that using statements with multiple locals have already been split up into multiple using statements.
        /// </remarks>
        private BoundBlock RewriteDeclarationUsingStatement(CSharpSyntaxNode usingSyntax, BoundLocalDeclaration localDeclaration, BoundBlock tryBlock, Conversion idisposableConversion)
        {
            CSharpSyntaxNode declarationSyntax = localDeclaration.Syntax;

            LocalSymbol localSymbol = localDeclaration.LocalSymbol;
            TypeSymbol localType = localSymbol.Type;
            Debug.Assert((object)localType != null); //otherwise, there wouldn't be a conversion to IDisposable

            BoundLocal boundLocal = new BoundLocal(declarationSyntax, localSymbol, localDeclaration.InitializerOpt.ConstantValue, localType);

            BoundStatement rewrittenDeclaration = (BoundStatement)Visit(localDeclaration);

            // If we know that the expression is null, then we know that the null check in the finally block
            // will fail, and the Dispose call will never happen.  That is, the finally block will have no effect.
            // Consequently, we can simply skip the whole try-finally construct and just create a block containing
            // the new declaration.
            if (boundLocal.ConstantValue == ConstantValue.Null)
            {
                //localSymbol will be declared by an enclosing block
                return BoundBlock.SynthesizedNoLocals(usingSyntax, rewrittenDeclaration, tryBlock);
            }

            if (localType.IsDynamic())
            {
                BoundExpression tempInit = MakeConversion(
                    declarationSyntax,
                    boundLocal,
                    idisposableConversion,
                    compilation.GetSpecialType(SpecialType.System_IDisposable),
                    @checked: false);

                BoundAssignmentOperator tempAssignment;
                BoundLocal boundTemp = this.factory.StoreToTemp(tempInit, out tempAssignment);

                BoundStatement tryFinally = RewriteUsingStatementTryFinally(usingSyntax, tryBlock, boundTemp);

                return new BoundBlock(
                    syntax: usingSyntax,
                    locals: ImmutableArray.Create<LocalSymbol>(boundTemp.LocalSymbol), //localSymbol will be declared by an enclosing block
                    statements: ImmutableArray.Create<BoundStatement>(
                        rewrittenDeclaration,
                        new BoundExpressionStatement(declarationSyntax, tempAssignment),
                        tryFinally));
            }
            else
            {
                BoundStatement tryFinally = RewriteUsingStatementTryFinally(usingSyntax, tryBlock, boundLocal);

                // localSymbol will be declared by an enclosing block
                return BoundBlock.SynthesizedNoLocals(usingSyntax, rewrittenDeclaration, tryFinally);
            }
        }
Example #31
0
 public virtual void ProcessConversion(Expression expression, ResolveResult result, Conversion conversion, IType targetType)
 {
 }
Example #32
0
        internal static long Add(string catalog, DateTime valueDate, string book, int officeId, int userId, long loginId,
                                 int costCenterId, string referenceNumber, string statementReference, StockMaster stockMaster,
                                 Collection <StockDetail> details, Collection <long> transactionIdCollection,
                                 Collection <Attachment> attachments)
        {
            if (stockMaster == null)
            {
                return(0);
            }

            if (details == null)
            {
                return(0);
            }

            if (details.Count.Equals(0))
            {
                return(0);
            }

            string tranIds    = ParameterHelper.CreateBigintArrayParameter(transactionIdCollection, "bigint", "@TranId");
            string detail     = StockMasterDetailHelper.CreateStockMasterDetailParameter(details);
            string attachment = AttachmentHelper.CreateAttachmentModelParameter(attachments);

            string sql = string.Format(CultureInfo.InvariantCulture,
                                       "SELECT * FROM transactions.post_purchase(@BookName::national character varying(48), @OfficeId::integer, @UserId::integer, @LoginId::bigint, @ValueDate::date, @CostCenterId::integer, @ReferenceNumber::national character varying(12), @StatementReference::text, @IsCredit::boolean, @PartyCode::national character varying(12), @PriceTypeId::integer, @ShipperId::integer, @StoreId::integer, ARRAY[{0}]::bigint[], ARRAY[{1}], ARRAY[{2}])",
                                       tranIds, detail, attachment);

            using (NpgsqlCommand command = new NpgsqlCommand(sql))
            {
                command.Parameters.AddWithValue("@BookName", book);
                command.Parameters.AddWithValue("@OfficeId", officeId);
                command.Parameters.AddWithValue("@UserId", userId);
                command.Parameters.AddWithValue("@LoginId", loginId);
                command.Parameters.AddWithValue("@ValueDate", valueDate);
                command.Parameters.AddWithValue("@CostCenterId", costCenterId);
                command.Parameters.AddWithValue("@ReferenceNumber", referenceNumber);
                command.Parameters.AddWithValue("@StatementReference", statementReference);


                command.Parameters.AddWithValue("@IsCredit", stockMaster.IsCredit);
                command.Parameters.AddWithValue("@PartyCode", stockMaster.PartyCode);

                if (stockMaster.PriceTypeId.Equals(0))
                {
                    command.Parameters.AddWithValue("@PriceTypeId", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@PriceTypeId", stockMaster.PriceTypeId);
                }

                if (stockMaster.ShipperId.Equals(0))
                {
                    command.Parameters.AddWithValue("@ShipperId", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@ShipperId", stockMaster.ShipperId);
                }

                command.Parameters.AddWithValue("@StoreId", stockMaster.StoreId);

                command.Parameters.AddRange(
                    ParameterHelper.AddBigintArrayParameter(transactionIdCollection, "@TranId").ToArray());
                command.Parameters.AddRange(StockMasterDetailHelper.AddStockMasterDetailParameter(details).ToArray());
                command.Parameters.AddRange(AttachmentHelper.AddAttachmentParameter(attachments).ToArray());

                long tranId = Conversion.TryCastLong(DbOperation.GetScalarValue(catalog, command));
                return(tranId);
            }
        }
Example #33
0
        public void Calc()
        {
            /************************ 代码开始 *********************/
            #region  参数定义
            double[]      hnl = new double[2];
            string        mcalBh, mlongStr;
            double[]      ljsy = new double[7];
            List <string> mtmpArray = new List <string>();
            string        mSjdjbh, mSjdj;
            double        mSz, mQdyq, mHsxs;
            int           vp;
            string        mjlgs;
            string        mMaxBgbh, mkljpq;
            string        mJSFF;
            bool          mAllHg   = true;
            bool          mGetBgbh = false;
            bool          mSFwc;
            double        mMj;
            mSFwc = true;
            #endregion

            #region  集合取值
            var data  = retData;
            var mrsDj = dataExtra["BZ_SPB_DJ"];
            var MItem = data["M_SPB"];
            var SItem = data["S_SPB"];
            #endregion

            #region  计算开始
            foreach (var sitem in SItem)
            {
                mSjdj = sitem["SJDJ"];
                mMj   = 70.7 * 70.7;
                if (string.IsNullOrEmpty(mSjdj))
                {
                    mSjdj = "";
                }
                var mrsDj_filter = mrsDj.FirstOrDefault(u => u["MC"].Contains(mSjdj));
                if (mrsDj_filter == null || mrsDj_filter.Count == 0)
                {
                    sitem["JCJG"] = "不下结论";
                    mAllHg        = false;
                    break;
                }
                //计算龄期
                sitem["LQ"] = (GetSafeDateTime(MItem[0]["SYRQ"]) - GetSafeDateTime(sitem["ZZRQ"])).Days.ToString();
                double md1, md2, md, pjmd, sum;
                int    xd, Gs;
                bool   sign;

                string jcxm = "、" + sitem["JCXM"].Replace(',', '、') + "、";

                #region 用料配合比计算
                if (IsNumeric(MItem[0]["T_CLSN"]))
                {
                    //水
                    if (IsNumeric(MItem[0]["T_CLS"]))
                    {
                        MItem[0]["T_PBS"] = Round(GetSafeDouble(MItem[0]["T_CLS"]) / GetSafeDouble(MItem[0]["T_CLSN"]), 2).ToString("0.00");
                    }
                    else
                    {
                        MItem[0]["T_PBS"] = "0";
                    }
                    //砂
                    if (IsNumeric(MItem[0]["T_CLSA"]))
                    {
                        MItem[0]["T_PBSA"] = Round(GetSafeDouble(MItem[0]["T_CLSA"]) / GetSafeDouble(MItem[0]["T_CLSN"]), 2).ToString("0.00");
                    }
                    else
                    {
                        MItem[0]["T_PBSA"] = "0";
                    }
                    //外加剂1
                    if (IsNumeric(MItem[0]["T_CLWJJ1"]))
                    {
                        MItem[0]["T_PBWJJ1"] = Round(GetSafeDouble(MItem[0]["T_CLWJJ1"]) / GetSafeDouble(MItem[0]["T_CLSN"]), 2).ToString("0.00");
                    }
                    else
                    {
                        MItem[0]["T_PBWJJ1"] = "0";
                    }
                    //外加剂2
                    if (IsNumeric(MItem[0]["T_CLWJJ2"]))
                    {
                        MItem[0]["T_PBWJJ2"] = Round(GetSafeDouble(MItem[0]["T_CLWJJ2"]) / GetSafeDouble(MItem[0]["T_CLSN"]), 2).ToString("0.00");
                    }
                    else
                    {
                        MItem[0]["T_PBWJJ2"] = "0";
                    }
                    //掺合料1
                    if (IsNumeric(MItem[0]["T_CLCHL1"]))
                    {
                        MItem[0]["T_PBCHL1"] = Round(GetSafeDouble(MItem[0]["T_CLCHL1"]) / GetSafeDouble(MItem[0]["T_CLSN"]), 2).ToString("0.00");
                    }
                    else
                    {
                        MItem[0]["T_PBCHL1"] = "0";
                    }
                    //掺合料2
                    if (IsNumeric(MItem[0]["T_CLCHL2"]))
                    {
                        MItem[0]["T_PBCHL2"] = Round(GetSafeDouble(MItem[0]["T_CLCHL2"]) / GetSafeDouble(MItem[0]["T_CLSN"]), 2).ToString("0.00");
                    }
                    else
                    {
                        MItem[0]["T_PBCHL2"] = "0";
                    }
                }
                #endregion
                if (sitem["JCXM"].Contains("7天强度") || jcxm.Contains("、配合比、"))
                {
                    if (!IsNumeric(sitem["KYHZ1_1"]) || Conversion.Val(sitem["KYHZ1_1"]) == 0)
                    {
                        DateTime dtnow = DateTime.Now;
                        if (DateTime.TryParse(sitem["ZZRQ"], out dtnow))
                        {
                            sitem["YQSYRQ"] = GetSafeDateTime(sitem["ZZRQ"]).AddDays(28).ToString("yyyy-MM-dd HH:mm:ss");
                        }
                    }
                    List <double> larray = new List <double>();
                    for (xd = 1; xd < 4; xd++)
                    {
                        if (IsNumeric(sitem["KYHZ" + xd + "_7"]) && Conversion.Val(sitem["KYHZ" + xd + "_7"]) != 0)
                        {
                            md = GetSafeDouble(sitem["KYHZ" + xd + "_7"].Trim());
                            md = 1350 * md / (70.7 * 70.7);
                            md = Round(md, 1);
                            sitem["KYQD" + xd + "_7"] = md.ToString("0.0");
                            larray.Add(md);
                        }
                        else
                        {
                            sitem["KYQD" + xd + "_7"] = "----";
                        }
                    }

                    if (larray.Count > 0)
                    {
                        sitem["KYPJ_7"] = larray.Average().ToString("0.0");
                    }
                    else
                    {
                        sitem["KYPJ_7"] = "----";
                    }
                }
                else
                {
                    for (xd = 1; xd < 4; xd++)
                    {
                        sitem["KYQD" + xd + "_7"] = "----";
                    }
                    sitem["KYPJ_7"] = "----";
                }
                if (sitem["JCXM"].Contains("28天强度") || jcxm.Contains("、配合比、"))
                {
                    if (!IsNumeric(sitem["KYHZ1_1"]) || Conversion.Val(sitem["KYHZ1_1"]) == 0)
                    {
                        DateTime dtnow = DateTime.Now;
                        if (DateTime.TryParse(sitem["ZZRQ"], out dtnow))
                        {
                            sitem["YQSYRQ"] = GetSafeDateTime(sitem["ZZRQ"]).AddDays(28).ToString("yyyy-MM-dd HH:mm:ss");
                        }
                        else
                        {
                            sitem["KYPJ"] = "----";
                        }
                    }
                    List <double> larray = new List <double>();
                    for (xd = 1; xd < 4; xd++)
                    {
                        if (IsNumeric(sitem["KYHZ" + xd]) && Conversion.Val(sitem["KYHZ" + xd]) != 0)
                        {
                            md = GetSafeDouble(sitem["KYHZ" + xd].Trim());
                            md = 1350 * md / (70.7 * 70.7);
                            md = Round(md, 1);
                            sitem["KYQD" + xd] = md.ToString("0.0");
                            larray.Add(md);
                        }
                        else
                        {
                            sitem["KYQD" + xd] = "----";
                        }
                    }
                    if (larray.Count > 0)
                    {
                        sitem["KYPJ"] = larray.Average().ToString("0.0");
                    }
                    else
                    {
                        sitem["KYPJ"] = "----";
                    }
                }
                else
                {
                    for (xd = 1; xd < 4; xd++)
                    {
                        sitem["KYQD" + xd] = "----";
                    }
                    sitem["KYPJ"] = "----";
                }
                if (sitem["JCXM"].Contains("抗冻"))
                {
                }
                else
                {
                    sitem["QDSSL"] = "----";
                    sitem["ZLSSL"] = "----";
                }
                if (sitem["JCXM"].Contains("拉伸粘结强度"))
                {
                    List <double> larray = new List <double>();
                    for (int i = 1; i < 11; i++)
                    {
                        sitem["LSQDQD" + i] = Math.Round(Conversion.Val(sitem["LSQDHZ" + i]) / (Conversion.Val(sitem["LSQDCD" + i]) * Conversion.Val(sitem["LSQDKD" + i])), 3).ToString();
                        larray.Add(GetSafeDouble(sitem["LSQDQD" + i]));
                    }

                    int    n   = 0;
                    double avg = 0;
                    avg = larray.Average();
                    //foreach (var l in larray)
                    //{
                    //    if (Math.Abs((l-avg)/avg*100) > 20)
                    //    {
                    //        larray.Remove(l);
                    //        n++;
                    //    }
                    //}

                    for (int i = 0; i < larray.Count; i++)
                    {
                        if (Math.Abs((larray[i] - avg) / avg * 100) > 20)
                        {
                            larray.Remove(larray[i]);
                            n++;
                        }
                    }
                    if (n < 4 && n != 0)
                    {
                        sitem["LSQDQD"] = "结果无效";
                    }
                    else
                    {
                        sitem["LSQDQD"] = Math.Round(larray.Average(), 2).ToString("0.00");
                    }
                }
                else
                {
                    sitem["LSQDQD"] = "----";
                }
                if (sitem["JCXM"].Contains("凝结时间") || jcxm.Contains("、配合比、"))
                {
                    sitem["ZNSJ"] = (Round(((GetSafeDouble(sitem["T1ZN"]) + GetSafeDouble(sitem["T2ZN"])) / 2) / 5, 0) * 5).ToString();
                }
                else
                {
                    sitem["ZNSJ"] = "0";
                    sitem["T1ZN"] = "0";
                    sitem["T2ZN"] = "0";
                }

                #region 抗渗性能
                if (sitem["JCXM"].Contains("抗渗性能"))
                {
                    if (Conversion.Val(sitem["KSKYQD1"]) > 0)
                    {
                        sitem["W_KSXN"] = "P" + (Conversion.Val(sitem["KSKYQD1"]) * 10 - 1).ToString();
                    }
                }
                else
                {
                    sitem["W_KSXN"] = "----";
                }
                #endregion
            }

            //主表总判断赋值
            //if (mAllHg)
            //    MItem[0]["JCJG"] = "合格";
            //else
            //    MItem[0]["JCJG"] = "不合格";

            if (mAllHg)
            {
                MItem[0]["JCJG"] = "----";
            }
            else
            {
                MItem[0]["JCJG"] = "----";
            }

            /************************ 代码结束 *********************/
            #endregion
        }
Example #34
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            m = m + 10;
            if (m < 1000)
            {
                a = (int)(Conversion.Int(1 + VBMath.Rnd() * 3));

                b = (int)(Conversion.Int(1 + VBMath.Rnd() * 3));

                c = (int)(Conversion.Int(1 + VBMath.Rnd() * 3));

                switch (a)
                {
                case 1:
                    PictureBox1.Image = Image.FromFile("C:\\Users\\don\\Desktop\\bg.o sa vb.net\\Slot Machine\\Slot Machine\\Resources\\apple.jpg");
                    break;

                case 2:
                    PictureBox1.Image = Image.FromFile("C:\\Users\\don\\Desktop\\bg.o sa vb.net\\Slot Machine\\Slot Machine\\Resources\\grapes.jpg");
                    break;

                case 3:
                    PictureBox1.Image = Image.FromFile("C:\\Users\\don\\Desktop\\bg.o sa vb.net\\Slot Machine\\Slot Machine\\Resources\\strawberry.jpg");
                    break;
                }

                switch (b)
                {
                case 1:
                    PictureBox2.Image = Image.FromFile("C:\\Users\\don\\Desktop\\bg.o sa vb.net\\Slot Machine\\Slot Machine\\Resources\\apple.jpg");
                    break;

                case 2:
                    PictureBox2.Image = Image.FromFile("C:\\Users\\don\\Desktop\\bg.o sa vb.net\\Slot Machine\\Slot Machine\\Resources\\grapes.jpg");
                    break;

                case 3:
                    PictureBox2.Image = Image.FromFile("C:\\Users\\don\\Desktop\\bg.o sa vb.net\\Slot Machine\\Slot Machine\\Resources\\strawberry.jpg");
                    break;
                }
                switch (c)
                {
                case 1:
                    PictureBox3.Image = Image.FromFile("C:\\Users\\don\\Desktop\\bg.o sa vb.net\\Slot Machine\\Slot Machine\\Resources\\apple.jpg");
                    break;

                case 2:
                    PictureBox3.Image = Image.FromFile("C:\\Users\\don\\Desktop\\bg.o sa vb.net\\Slot Machine\\Slot Machine\\Resources\\grapes.jpg");
                    break;

                case 3:
                    PictureBox3.Image = Image.FromFile("C:\\Users\\don\\Desktop\\bg.o sa vb.net\\Slot Machine\\Slot Machine\\Resources\\strawberry.jpg");
                    break;
                }
            }
            else
            {
                timer1.Enabled = false;
                m = 0;
                if (System.Convert.ToInt32(a == b) == c)
                {
                    lblMsg.Text = "Jackpot! You won P1,000,000″";
                }
                else
                {
                    lblMsg.Text = "No luck, try again";
                }
            }
        }
Example #35
0
        public void Calc()
        {
            #region
            /************************ 代码开始 *********************/
            var extraDJ    = dataExtra["BZ_QK3_DJ"];
            var extraGMDJB = dataExtra["BZ_QK3GMDJB"];

            var data = retData;

            var mjcjg    = "不合格";
            var jsbeizhu = "该组试样的检测结果全部合格";
            var SItems   = data["S_QK3"];

            if (!data.ContainsKey("M_QK3"))
            {
                data["M_QK3"] = new List <IDictionary <string, string> >();
            }
            var MItem = data["M_QK3"];

            if (MItem.Count == 0)
            {
                IDictionary <string, string> m = new Dictionary <string, string>();
                m["JCJG"]   = mjcjg;
                m["JCJGMS"] = jsbeizhu;
                MItem.Add(m);
            }
            var mAllHg = true;

            string mJSFF = "";
            double mSz = 0;
            double yqgmdx = 0, yqgmdd = 0;

            var           jcxm = "";
            double        mMaxKyqd, mMinKyqd, mMidKyqd, mAvgKyqd = 0;
            List <double> mtmpArray = new List <double>();
            var           jcxmBhg   = "";
            var           jcxmCur   = "";

            foreach (var sItem in SItems)
            {
                jcxm = "、" + sItem["JCXM"].Replace(',', '、') + "、";

                #region 数据准备工作

                //获取设计等级
                if (string.IsNullOrEmpty(sItem["SJDJ"]))
                {
                    sItem["SJDJ"] = "";
                }

                //从设计等级表中取得相应的计算数值、等级标准
                var extraFieldsDj = extraDJ.FirstOrDefault(u => u.Keys.Contains("MC") && u.Values.Contains(sItem["SJDJ"].Trim()));
                if (null != extraFieldsDj)
                {
                    mJSFF             = string.IsNullOrEmpty(extraFieldsDj["JSFF"]) ? "" : extraFieldsDj["JSFF"];
                    sItem["MDDJFW"]   = extraFieldsDj["MDDJFW"];
                    MItem[0]["G_MIN"] = extraFieldsDj["DKBXY"];
                    MItem[0]["G_PJZ"] = extraFieldsDj["PJBXY"];
                    if (MItem[0]["PDBZ"].ToString().ToUpper().Contains("2011"))
                    {
                        sItem["XSLYQ"] = "≤18";
                        sItem["HSLYQ"] = "≤18";
                    }
                    else
                    {
                        sItem["XSLYQ"] = extraFieldsDj["XSL"];
                        sItem["HSLYQ"] = extraFieldsDj["XSL"];
                    }
                }
                else
                {
                    mJSFF  = "";
                    mSz    = 0;
                    mAllHg = false;
                    continue;
                }

                var extraFieldsGMDJB = extraGMDJB.FirstOrDefault(u => u.Keys.Contains("MC") && u.Values.Contains(sItem["GMDDJ"].Trim()));
                if (null != extraFieldsGMDJB)
                {
                    MItem[0]["G_GMD"] = extraFieldsGMDJB["GMD2"];
                    yqgmdx            = GetSafeDouble(extraFieldsGMDJB["GMD1"]);
                    yqgmdd            = GetSafeDouble(extraFieldsGMDJB["GMD2"]);
                }

                sItem["KDYQ"]   = "质量损失率≤5% \r\n 强度损失率≤25%";
                sItem["ZLSSYQ"] = "≤5";
                sItem["QDSSYQ"] = "≤25";

                #endregion

                #region 初始化变量

                //MItem["WHICH"] = "bgqk3";
                double mtj1 = 0;
                double mtj2 = 0;
                double mtj3 = 0;
                double md1, md2, md, sum, pjmd = 0;
                #endregion

                if (jcxm.Contains("、干密度、"))
                {
                    jcxmCur = "干密度";
                    mtj1    = 0;
                    mtj1    = 0;
                    double mtj = 0;
                    double pj  = 0;
                    for (int i = 1; i < 4; i++)
                    {
                        sItem["CD" + i] = Math.Round((GetSafeDouble(sItem["CD" + i + "_1"]) + GetSafeDouble(sItem["CD" + i + "_2"])) / 2, 0).ToString();
                        sItem["KD" + i] = Math.Round((GetSafeDouble(sItem["KD" + i + "_1"]) + GetSafeDouble(sItem["KD" + i + "_2"])) / 2, 0).ToString();
                        sItem["GD" + i] = Math.Round((GetSafeDouble(sItem["GD" + i + "_1"]) + GetSafeDouble(sItem["GD" + i + "_2"])) / 2, 0).ToString();

                        mtj = GetSafeDouble(sItem["CD" + i]) / 1000 * GetSafeDouble(sItem["KD" + i]) / 1000 * GetSafeDouble(sItem["GD" + i]) / 1000;
                        if (mtj != 0)
                        {
                            //mtj = Math.Round(mtj, 3);
                            sItem["GMD" + i] = (Math.Round((GetSafeDouble(sItem["HGHZL" + i]) / mtj) / 10, 0) * 10).ToString();
                            pj += Math.Round((GetSafeDouble(sItem["HGHZL" + i]) / mtj) / 10, 0) * 10;
                        }
                        else
                        {
                            sItem["GMD" + i] = "0";
                        }
                    }

                    sItem["GMDPJ"] = (Math.Round(pj / 3 / 10, 0) * 10).ToString();

                    //sItem["GMDPJ"] = (Math.Round((GetSafeDouble(sItem["GMD1"]) + GetSafeDouble(sItem["GMD2"]) + GetSafeDouble(sItem["GMD3"])) / 3 / 10, 0) * 10).ToString();
                }
                else
                {
                    sItem["GMDPD"] = "----";
                }

                if (jcxm.Contains("、抗压强度、"))
                {
                    //if (Conversion.Val(sItem["KYHZ1"]) == 0)
                    //{
                    //    sItem["syr"] = "";
                    //}
                    jcxmCur       = "抗压强度";
                    sItem["QDYQ"] = "抗压强度平均值需≥" + GetSafeDouble(extraFieldsDj["PJBXY"]).ToString("0.0") + "MPa,\r\n 单块最小强度值需≥" + GetSafeDouble(extraFieldsDj["DKBXY"]).ToString("0.0") + "MPa";

                    sItem["QCD1"] = Math.Round((GetSafeDouble(sItem["QCD1_1"]) + GetSafeDouble(sItem["QCD1_2"])) / 2, 0).ToString();
                    sItem["QKD1"] = Math.Round((GetSafeDouble(sItem["QKD1_1"]) + GetSafeDouble(sItem["QKD1_2"])) / 2, 0).ToString();
                    sItem["QMJ1"] = (GetSafeDouble(sItem["QCD1"]) * GetSafeDouble(sItem["QKD1"])).ToString();

                    sItem["QCD2"] = Math.Round((GetSafeDouble(sItem["QCD2_1"]) + GetSafeDouble(sItem["QCD2_2"])) / 2, 0).ToString();
                    sItem["QKD2"] = Math.Round((GetSafeDouble(sItem["QKD2_1"]) + GetSafeDouble(sItem["QKD2_2"])) / 2, 0).ToString();
                    sItem["QMJ2"] = (GetSafeDouble(sItem["QCD2"]) * GetSafeDouble(sItem["QKD2"])).ToString();

                    sItem["QCD3"] = Math.Round((GetSafeDouble(sItem["QCD3_1"]) + GetSafeDouble(sItem["QCD3_2"])) / 2, 0).ToString();
                    sItem["QKD3"] = Math.Round((GetSafeDouble(sItem["QKD3_1"]) + GetSafeDouble(sItem["QKD3_2"])) / 2, 0).ToString();
                    sItem["QMJ3"] = (GetSafeDouble(sItem["QCD3"]) * GetSafeDouble(sItem["QKD3"])).ToString();

                    sItem["QCD4"] = Math.Round((GetSafeDouble(sItem["QCD4_1"]) + GetSafeDouble(sItem["QCD4_2"])) / 2, 0).ToString();
                    sItem["QKD4"] = Math.Round((GetSafeDouble(sItem["QKD4_1"]) + GetSafeDouble(sItem["QKD4_2"])) / 2, 0).ToString();
                    sItem["QMJ4"] = (GetSafeDouble(sItem["QCD4"]) * GetSafeDouble(sItem["QKD4"])).ToString();

                    sItem["QCD5"] = Math.Round((GetSafeDouble(sItem["QCD5_1"]) + GetSafeDouble(sItem["QCD5_2"])) / 2, 0).ToString();
                    sItem["QKD5"] = Math.Round((GetSafeDouble(sItem["QKD5_1"]) + GetSafeDouble(sItem["QKD5_2"])) / 2, 0).ToString();
                    sItem["QMJ5"] = (GetSafeDouble(sItem["QCD5"]) * GetSafeDouble(sItem["QKD5"])).ToString();

                    for (int i = 1; i < 6; i++)
                    {
                        if (GetSafeDouble(sItem["QMJ" + i]) == 0)
                        {
                            sItem["KYQD" + i] = "0";
                        }
                        else
                        {
                            sItem["KYQD" + i] = Math.Round(1000 * GetSafeDouble(sItem["KYHZ" + i]) / GetSafeDouble(sItem["QMJ" + i]), 2).ToString("0.00");
                        }
                        mtmpArray.Add(GetSafeDouble(sItem["KYQD" + i]));
                    }

                    sItem["KYPJ"] = mtmpArray.Average().ToString("0.0");
                    mtmpArray.Sort();
                    mMaxKyqd = mtmpArray[4];
                    mMinKyqd = mtmpArray[0];

                    sItem["DKZX"] = mMinKyqd.ToString("0.0");

                    //if (GetSafeDouble(sItem["KYPJ"]) >= GetSafeDouble(extraFieldsDj["PJBXY"]) && GetSafeDouble(sItem["DKZX"]) >= GetSafeDouble(extraFieldsDj["DKBXY"]) && GetSafeDouble(sItem["GMDPJ"]) <= GetSafeDouble(extraFieldsDj["MDDJFW"]))
                    if (GetSafeDouble(sItem["KYPJ"]) >= GetSafeDouble(extraFieldsDj["PJBXY"]) && GetSafeDouble(sItem["DKZX"]) >= GetSafeDouble(extraFieldsDj["DKBXY"]))
                    {
                        sItem["QDPD"] = "合格";   //强度判定(是否合格)
                    }
                    else
                    {
                        jcxmBhg      += jcxmBhg.Contains(jcxmCur) ? "" : jcxmCur + "、";
                        sItem["QDPD"] = "不合格";
                    }


                    if (yqgmdx != 0 && yqgmdd != 0)
                    {
                        if (GetSafeDouble(sItem["GMDPJ"]) <= yqgmdd && GetSafeDouble(sItem["GMDPJ"]) >= yqgmdx)
                        {
                            sItem["GMDPD"] = "合格";  //干密度判定(是否合格)
                        }
                        else
                        {
                            jcxmCur        = "干密度";
                            jcxmBhg       += jcxmBhg.Contains(jcxmCur) ? "" : jcxmCur + "、";
                            sItem["GMDPD"] = "不合格";
                        }

                        //sItem["MDDJFW"] = "密度等级范围≤" + GetSafeDouble(sItem["MDDJFW"]).ToString("0") + "kg/m&scsup3&scend";
                        sItem["MDDJFW"] = "≥" + yqgmdx.ToString() + "且" + "≤" + yqgmdd.ToString() + "kg/m&scsup3&scend";
                    }
                    else
                    {
                        sItem["MDDJFW"] = "----";
                        sItem["GMDPD"]  = "----";
                    }
                }
                else
                {
                    sItem["QDPD"] = "----";
                    sItem["KYPJ"] = "0";
                }

                if (jcxm.Contains("、吸水率、"))
                {
                    jcxmCur = "吸水率";
                    if (MItem[0]["PDBZ"].ToString().ToUpper().Contains("2011"))
                    {
                        sItem["XSLYQ"] = "≤18";
                    }
                    else
                    {
                        sItem["XSLYQ"] = extraFieldsDj["XSL"];
                    }
                    for (int i = 1; i < 4; i++)
                    {
                        if (GetSafeDouble(sItem["HXSM_" + i]) == 0)
                        {
                            sItem["HXSW2_" + i] = "0";
                        }
                        else
                        {
                            sItem["HXSW2_" + i] = Math.Round((GetSafeDouble(sItem["HXSM2_" + i]) - GetSafeDouble(sItem["HXSM_" + i])) / GetSafeDouble(sItem["HXSM_" + i]) * 100, 2).ToString("0.00");;
                        }
                    }
                    sItem["HXSW2"] = Math.Round((GetSafeDouble(sItem["HXSW2_1"]) + GetSafeDouble(sItem["HXSW2_2"]) + GetSafeDouble(sItem["HXSW2_3"])) / 3, 1).ToString("0.0");

                    if (IsQualified(sItem["XSLYQ"], sItem["HXSW2"]).Equals("合格"))
                    {
                        sItem["XSLPD"] = "合格";
                    }
                    else
                    {
                        jcxmBhg       += jcxmBhg.Contains(jcxmCur) ? "" : jcxmCur + "、";
                        sItem["XSLPD"] = "不合格";
                    }
                }
                else
                {
                    sItem["XSLPD"]   = "----";
                    sItem["HXSW2_1"] = "----";
                    sItem["HXSW2_2"] = "----";
                    sItem["HXSW2_3"] = "----";
                    sItem["XSLYQ"]   = "----";
                    sItem["HXSW2"]   = "----";
                }

                if (jcxm.Contains("、含水率、"))
                {
                    jcxmCur = "含水率";
                    if (MItem[0]["PDBZ"].ToString().ToUpper().Contains("2011"))
                    {
                        sItem["HSLYQ"] = "≤18";
                    }
                    else
                    {
                        sItem["HSLYQ"] = extraFieldsDj["XSL"];
                    }
                    for (int i = 1; i < 4; i++)
                    {
                        if (GetSafeDouble(sItem["HSM_" + i]) == 0)
                        {
                            sItem["HSW2_" + i] = "0";
                        }
                        else
                        {
                            sItem["HSW2_" + i] = Math.Round((GetSafeDouble(sItem["HSM2_" + i]) - GetSafeDouble(sItem["HSM_" + i])) / GetSafeDouble(sItem["HSM_" + i]) * 100, 2).ToString("0.00");;
                        }
                    }
                    sItem["HSW2"] = Math.Round((GetSafeDouble(sItem["HSW2_1"]) + GetSafeDouble(sItem["HSW2_2"]) + GetSafeDouble(sItem["HSW2_3"])) / 3, 1).ToString("0.0");

                    if (IsQualified(sItem["HSLYQ"], sItem["HSW2"]).Equals("合格"))
                    {
                        sItem["HSLPD"] = "合格";
                    }
                    else
                    {
                        jcxmBhg       += jcxmBhg.Contains(jcxmCur) ? "" : jcxmCur + "、";
                        sItem["HSLPD"] = "不合格";
                    }
                }
                else
                {
                    sItem["HSLPD"]  = "----";
                    sItem["HSW2_1"] = "----";
                    sItem["HSW2_2"] = "----";
                    sItem["HSW2_3"] = "----";
                    sItem["HSLYQ"]  = "----";
                    sItem["HSW2"]   = "----";
                }

                var sign = true;

                if (jcxm.Contains("、抗冻性、"))
                {
                    jcxmCur         = "抗冻性";
                    sItem["KDYQ"]   = "质量损失率≤5% \r\n 强度损失率≤25%";
                    sItem["ZLSSYQ"] = "≤5";
                    sItem["QDSSYQ"] = "≤25";
                    sum             = 0;

                    for (int i = 1; i < 6; i++)
                    {
                        if (!IsNumeric(sItem["KYPJ"]))
                        {
                            sign = false;
                            break;
                        }

                        if (!IsNumeric(sItem["DQZL" + i]))
                        {
                            sign = false;
                            break;
                        }
                        if (!IsNumeric(sItem["DHZL" + i]))
                        {
                            sign = false;
                            break;
                        }
                        if (!IsNumeric(sItem["DHCD" + i + "_1"]))
                        {
                            sign = false;
                            break;
                        }
                        if (!IsNumeric(sItem["DHCD" + i + "_2"]))
                        {
                            sign = false;
                            break;
                        }

                        if (!IsNumeric(sItem["DHKD" + i + "_1"]))
                        {
                            sign = false;
                            break;
                        }
                        if (!IsNumeric(sItem["DHKD" + i + "_2"]))
                        {
                            sign = false;
                            break;
                        }

                        if (!IsNumeric(sItem["DHKYHZ" + i]))
                        {
                            sign = false;
                            break;
                        }
                    }

                    if (sign)
                    {
                        sum = 0;
                        for (int i = 1; i < 6; i++)
                        {
                            md1 = GetSafeDouble(sItem["DQZL" + i]);
                            md2 = GetSafeDouble(sItem["DHZL" + i]);
                            md  = Math.Round(100 * (md1 - md2) / md1, 1);
                            sum = md + sum;
                        }
                        pjmd            = Math.Round(sum / 5, 1);
                        sItem["W_ZLSS"] = pjmd.ToString("0.0");

                        sum = 0;
                        for (int i = 1; i < 6; i++)
                        {
                            md   = 1;
                            md1  = GetSafeDouble(sItem["DHCD" + i + "_1"]);
                            md2  = GetSafeDouble(sItem["DHCD" + i + "_2"]);
                            pjmd = Math.Round((md1 + md2) / 2, 0);
                            md   = md * pjmd;

                            md1  = GetSafeDouble(sItem["DHKD" + i + "_1"]);
                            md2  = GetSafeDouble(sItem["DHKD" + i + "_2"]);
                            pjmd = Math.Round((md1 + md2) / 2, 0);
                            md   = md * pjmd;

                            md  = Math.Round(1000 * GetSafeDouble(sItem["DHKYHZ" + i]) / md, 1);
                            sum = sum + md;
                        }

                        pjmd            = sum / 5;
                        md1             = GetSafeDouble(sItem["KYPJ"]);
                        md2             = Math.Round(pjmd, 1);
                        md              = Math.Round(100 * (md1 - md2) / md1, 0);
                        sItem["W_QDSS"] = md.ToString("0");


                        if (IsQualified(sItem["ZLSSYQ"], sItem["W_ZLSS"]).Equals("合格") && IsQualified(sItem["QDSSYQ"], sItem["W_QDSS"]).Equals("合格"))
                        {
                            sItem["KDPD"] = "合格";
                        }
                        else
                        {
                            jcxmBhg      += jcxmBhg.Contains(jcxmCur) ? "" : jcxmCur + "、";
                            sItem["KDPD"] = "不合格";
                        }
                    }
                }
                else
                {
                    //mrsmainTablesItem["which") = "bgqk3"
                    sign = false;
                }

                if (jcxm.Contains("、外观质量、") || jcxm.Contains("、尺寸偏差、"))
                {
                    jcxmCur = CurrentJcxm(jcxm, "外观质量,尺寸偏差");
                    if (Conversion.Val(sItem["WCBHGS"]) < 7)
                    {
                        sItem["WCPD"] = "合格";
                    }
                    else
                    {
                        jcxmBhg      += jcxmBhg.Contains(jcxmCur) ? "" : jcxmCur + "、";
                        sItem["WCPD"] = "不合格";
                    }
                }
                else
                {
                    sItem["WCPD"] = "----";
                }

                if (jcxm.Contains("、传热系数、"))
                {
                    jcxmCur         = "传热系数";
                    sItem["G_CRXS"] = "≤" + sItem["G_CRXS"].Trim().Replace("≤", "");
                    if (IsQualified(sItem["G_CRXS"], sItem["KZ"], false) == "合格")
                    {
                        sItem["HG_CRXS"] = "合格";
                    }
                    else
                    {
                        sItem["HG_CRXS"] = "不合格";
                        jcxmBhg         += jcxmBhg.Contains(jcxmCur) ? "" : jcxmCur + "、";
                    }
                }
                else
                {
                    sItem["HG_CRXS"] = "----";
                    sItem["G_CRXS"]  = "----";
                    sItem["KZ"]      = "----";
                }

                if (!sign)
                {
                    sItem["KDYQ"]   = "----";
                    sItem["KDPD"]   = "----";
                    sItem["W_ZLSS"] = "----";
                    sItem["W_QDSS"] = "----";
                    sItem["QDSSYQ"] = "----";
                    sItem["ZLSSYQ"] = "----";
                    sItem["KZ"]     = "----";
                }

                if (sItem["XSLPD"] == "不合格" || sItem["QDPD"] == "不合格" || sItem["GMDPD"] == "不合格" || sItem["KDPD"] == "不合格" || sItem["WCPD"] == "不合格" || sItem["HG_CRXS"] == "不合格")
                {
                    sItem["JCJG"] = "不合格";
                    mAllHg        = false;
                    jsbeizhu      = "依据" + MItem[0]["PDBZ"] + "的规定,所检项目" + jcxmBhg.TrimEnd('、') + "不符合要求。";
                }
                else
                {
                    jsbeizhu      = "依据" + MItem[0]["PDBZ"] + "的规定,所检项目均符合要求。";
                    sItem["JCJG"] = "合格";
                }
            }
            #region 添加最终报告

            if (mAllHg && mjcjg != "----")
            {
                mjcjg = "合格";
            }

            MItem[0]["JCJG"]   = mjcjg;
            MItem[0]["JCJGMS"] = jsbeizhu;
            #endregion
            #endregion
        }
Example #36
0
 public static bool TryToChange(this object value, Type destinationType, out object result, Conversion options)
 {
     return(TryToChange(value, destinationType, out result, options, DefaultCultureInfo));
 }
Example #37
0
        private void UpdateUI(bool force = false)
        {
            if (progressView == null)
            {
                return;
            }

            RunOnUiThread(() => {
                Int64 steps = 0;
                if (Binder == null)
                {
                    if (Utils.IsSameDay)
                    {
                        steps = Helpers.Settings.CurrentDaySteps;
                    }
                }
                else
                {
                    steps = Binder.StepService.StepsToday;
                }

                progressView.SetStepCount(steps);

                stepCount.Text = Utils.FormatSteps(steps);

                var miles     = Conversion.StepsToMiles(steps);
                distance.Text = string.Format(distanceString,
                                              Helpers.Settings.UseKilometeres ?
                                              Conversion.StepsToKilometers(steps).ToString("N2") :
                                              miles.ToString("N2"));

                var lbs           = Helpers.Settings.UseKilometeres ? Helpers.Settings.Weight * 2.20462 : Helpers.Settings.Weight;
                calorieCount.Text = string.Format(calorieString,
                                                  Helpers.Settings.Enhanced ?
                                                  Conversion.CaloriesBurnt(miles, (float)lbs, Helpers.Settings.Cadence) :
                                                  Conversion.CaloriesBurnt(miles));

                var percent  = Conversion.StepCountToPercentage(steps);
                var percent2 = percent / 100;

                if (steps <= 10000)
                {
                    percentage.Text = steps == 0 ? string.Empty : string.Format(percentString, percent2.ToString("P2"));
                }
                else
                {
                    percentage.Text = completedString;
                }

                //set high score day
                highScore.Visibility = Settings.TodayIsHighScore ? Android.Views.ViewStates.Visible : Android.Views.ViewStates.Invisible;

                //Show daily goal message.
                if (!string.IsNullOrWhiteSpace(Settings.GoalTodayMessage) &&
                    Settings.GoalTodayDay.DayOfYear == DateTime.Today.DayOfYear &&
                    Settings.GoalTodayDay.Year == DateTime.Today.Year)
                {
                    Toast.MakeText(this, Settings.GoalTodayMessage, ToastLength.Long).Show();
                    Settings.GoalTodayMessage = string.Empty;
                }

                AnimateTopLayer((float)percent, force);

                this.Title = Utils.DateString;
            });
        }
Example #38
0
 /// <summary>
 /// Reads a <see cref="Decimal"/> from the current stream and advances the current position of the stream by
 /// sixteen bytes. The bytes of the value are swapped according to the stream data endianness.
 /// </summary>
 /// <returns>The <see cref="Decimal"/> value read from the current stream.</returns>
 /// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
 /// <exception cref="ObjectDisposedException">The stream is closed.</exception>
 /// <exception cref="IOException">An I/O error occurred.</exception>
 public override decimal ReadDecimal() =>
 ReverseEndianness?Conversion.ReverseEndianness(base.ReadDecimal()) : base.ReadDecimal();
Example #39
0
 public override void ProcessConversion(Expression expression, ResolveResult result, Conversion conversion, IType targetType)
 {
     if (conversion.IsUserDefined && conversion.Method.MemberDefinition == op)
     {
         ReportMatch(expression, result);
     }
 }
Example #40
0
 /// <summary>
 /// Reads an <see cref="Int32"/> from the current stream and advances the current position of the stream by four
 /// bytes. The bytes of the value are swapped according to the stream data endianness.
 /// </summary>
 /// <returns>The <see cref="Int32"/> value read from the current stream.</returns>
 /// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
 /// <exception cref="ObjectDisposedException">The stream is closed.</exception>
 /// <exception cref="IOException">An I/O error occurred.</exception>
 public override int ReadInt32() =>
 ReverseEndianness?Conversion.ReverseEndianness(base.ReadInt32()) : base.ReadInt32();
Example #41
0
        public void TestJobsWithAzurePipelineYamlToObject()
        {
            //Arrange
            Conversion conversion = new Conversion();
            string     yaml       = @"
trigger:
- master
variables:
  buildConfiguration: Release
  vmImage: ubuntu-latest
jobs:
- job: Build
  displayName: Build job
  pool: 
    vmImage: ubuntu-latest
  timeoutInMinutes: 23
  variables:
    buildConfiguration: Debug
    myJobVariable: 'data'
    myJobVariable2: 'data2'
  steps: 
  - script: dotnet build WebApplication1/WebApplication1.Service/WebApplication1.Service.csproj --configuration $(buildConfiguration) 
    displayName: dotnet build part 1
- job: Build2
  displayName: Build job
  dependsOn: Build
  pool: 
    vmImage: ubuntu-latest
  variables:
    myJobVariable: 'data'
  steps:
  - script: dotnet build WebApplication1/WebApplication1.Service/WebApplication1.Service.csproj --configuration $(buildConfiguration) 
    displayName: dotnet build part 2
  - script: dotnet build WebApplication1/WebApplication1.Service/WebApplication1.Service.csproj --configuration $(buildConfiguration) 
    displayName: dotnet build part 3";

            //Act
            ConversionResponse gitHubOutput = conversion.ConvertAzurePipelineToGitHubAction(yaml);

            //Assert
            string expected = @"
on:
  push:
    branches:
    - master
env:
  buildConfiguration: Release
  vmImage: ubuntu-latest
jobs:
  Build:
    name: Build job
    runs-on: ubuntu-latest
    timeout-minutes: 23
    env:
      buildConfiguration: Debug
      myJobVariable: data
      myJobVariable2: data2
    steps:
    - uses: actions/checkout@v2
    - name: dotnet build part 1
      run: dotnet build WebApplication1/WebApplication1.Service/WebApplication1.Service.csproj --configuration ${{ env.buildConfiguration }}
  Build2:
    name: Build job
    runs-on: ubuntu-latest
    needs: Build
    env:
      myJobVariable: data
    steps:
    - uses: actions/checkout@v2
    - name: dotnet build part 2
      run: dotnet build WebApplication1/WebApplication1.Service/WebApplication1.Service.csproj --configuration ${{ env.buildConfiguration }}
    - name: dotnet build part 3
      run: dotnet build WebApplication1/WebApplication1.Service/WebApplication1.Service.csproj --configuration ${{ env.buildConfiguration }}
";

            expected = UtilityTests.TrimNewLines(expected);
            Assert.AreEqual(expected, gitHubOutput.actionsYaml);
        }
Example #42
0
        public void XamarinAndroidPipelineTest()
        {
            //Arrange
            Conversion conversion = new Conversion();
            //Source is:
            string yaml = @"
# Xamarin.Android
# Build a Xamarin.Android project.
# Add steps that test, sign, and distribute an app, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/xamarin

trigger:
- master

pool:
  vmImage: 'macos-latest'

variables:
  buildConfiguration: 'Release'
  outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '**/*.sln'

- task: XamarinAndroid@1
  inputs:
    projectFile: '**/*droid*.csproj'
    outputDirectory: '$(outputDirectory)'
    configuration: '$(buildConfiguration)'
";

            //Act
            ConversionResponse gitHubOutput = conversion.ConvertAzurePipelineToGitHubAction(yaml);

            //Assert
            string expected = @"
#Note: This is a third party action: https://github.com/warrenbuckley/Setup-Nuget
on:
  push:
    branches:
    - master
env:
  buildConfiguration: Release
  outputDirectory: ${{ env.build.binariesDirectory }}/${{ env.buildConfiguration }}
jobs:
  build:
    runs-on: macos-latest
    steps:
    - uses: actions/checkout@v2
    - #: 'Note: This is a third party action: https://github.com/warrenbuckley/Setup-Nuget'
      uses: warrenbuckley/Setup-Nuget@v1
    - run: nuget  **/*.sln
      shell: powershell
    - run: |
        cd Blank
        nuget restore
        cd Blank.Android
        msbuild **/*droid*.csproj /verbosity:normal /t:Rebuild /p:Configuration=${{ env.buildConfiguration }}
";

            expected = UtilityTests.TrimNewLines(expected);
            Assert.AreEqual(expected, gitHubOutput.actionsYaml);
        }
Example #43
0
 /// <summary>
 /// Reads an <see cref="Int16"/> from the current stream and advances the current position of the stream by two
 /// bytes. The bytes of the value are swapped according to the stream data endianness.
 /// </summary>
 /// <returns>The <see cref="Int16"/> value read from the current stream.</returns>
 /// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
 /// <exception cref="ObjectDisposedException">The stream is closed.</exception>
 /// <exception cref="IOException">An I/O error occurred.</exception>
 public override short ReadInt16() =>
 ReverseEndianness?Conversion.ReverseEndianness(base.ReadInt16()) : base.ReadInt16();
Example #44
0
        public void XamariniOSPipelineTest()
        {
            //Arrange
            Conversion conversion = new Conversion();
            //Source is: https://raw.githubusercontent.com/microsoft/azure-pipelines-yaml/master/templates/xamarin.ios.yml
            string yaml = @"
# Xamarin.iOS
# Build a Xamarin.iOS project.
# Add steps that install certificates, test, sign, and distribute an app, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/xamarin

trigger:
- master

pool:
  vmImage: 'macos-latest'

steps:
# To manually select a Xamarin SDK version on the Microsoft-hosted macOS agent,
# configure this task with the *Mono* version that is associated with the
# Xamarin SDK version that you need, and set the ""enabled"" property to true.
# See https://go.microsoft.com/fwlink/?linkid=871629
- script: sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh 5_12_0
  displayName: 'Select the Xamarin SDK version'
  enabled: false

- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '**/*.sln'

- task: XamariniOS@2
  inputs:
    solutionFile: '**/*.sln'
    configuration: 'Release'
    buildForSimulator: true
    packageApp: false
";

            //Act
            ConversionResponse gitHubOutput = conversion.ConvertAzurePipelineToGitHubAction(yaml);

            //Assert
            string expected = @"
#Note: This is a third party action: https://github.com/warrenbuckley/Setup-Nuget
on:
  push:
    branches:
    - master
jobs:
  build:
    runs-on: macos-latest
    steps:
    - uses: actions/checkout@v2
    - name: Select the Xamarin SDK version
      run: sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh 5_12_0
    - #: 'Note: This is a third party action: https://github.com/warrenbuckley/Setup-Nuget'
      uses: warrenbuckley/Setup-Nuget@v1
    - run: nuget  **/*.sln
      shell: powershell
    - run: |
        cd Blank
        nuget restore
        cd Blank.Android
        msbuild  /verbosity:normal /t:Rebuild /p:Platform=iPhoneSimulator /p:Configuration=Release
";

            expected = UtilityTests.TrimNewLines(expected);
            Assert.AreEqual(expected, gitHubOutput.actionsYaml);
        }
Example #45
0
 /// <summary>
 /// Reads a <see cref="Single"/> from the current stream and advances the current position of the stream by four
 /// bytes. The bytes of the value are swapped according to the stream data endianness.
 /// </summary>
 /// <returns>The <see cref="Single"/> value read from the current stream.</returns>
 /// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
 /// <exception cref="ObjectDisposedException">The stream is closed.</exception>
 /// <exception cref="IOException">An I/O error occurred.</exception>
 public override float ReadSingle() =>
 ReverseEndianness?Conversion.ReverseEndianness(base.ReadSingle()) : base.ReadSingle();
Example #46
0
    protected void gvSetting_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Edit")
        {
            pteID = Convert.ToInt32(e.CommandArgument);
            lblErrorMessage.Visible = false;
        }

        else if (e.CommandName == "Delete")
        {
            lblErrorMessage.Visible = false;
            PTEStandards.DeleteSetting(Convert.ToInt32(e.CommandArgument), DateTime.Now, UserInfo.GetCurrentUserInfo().UserId);
            LoadData();
        }
        else if (e.CommandName == "AddMore")
        {
            //    LinkButton lnkbtnAddMore = gvSetting.FooterRow.FindControl("lnkbtnAddMore") as LinkButton;
            LinkButton lnkbtnAddMoreSetting = gvSetting.FooterRow.FindControl("lnkbtnAddMore") as LinkButton;
            LinkButton lnkbtnAddSetting     = gvSetting.FooterRow.FindControl("lnkbtnAddSetting") as LinkButton;
            LinkButton lnkbtnCancelSetting  = gvSetting.FooterRow.FindControl("lnkbtnCancelSetting") as LinkButton;
            lnkbtnAddSetting.Visible     = true;
            lnkbtnAddMoreSetting.Visible = false;
            lnkbtnCancelSetting.Visible  = true;

            //    DropDownList dllstakeholdertypefooter = gvSetting.FooterRow.FindControl("ddlstakeholderTypeListfooter") as DropDownList;
            DropDownList dlltiresizefooter = gvSetting.FooterRow.FindControl("ddlTireSizeListfooter") as DropDownList;
            TextBox      txtEffectiveDate  = gvSetting.FooterRow.FindControl("txteffectivedatefooter") as TextBox;
            TextBox      txtExpirtaionDate = gvSetting.FooterRow.FindControl("txtexpirationdatefooter") as TextBox;
            TextBox      txtDollarValue    = gvSetting.FooterRow.FindControl("txtDollarValuefooter") as TextBox;

            //   dllstakeholdertypefooter.Visible = true;
            dlltiresizefooter.Visible = true;
            txtEffectiveDate.Visible  = true;
            txtExpirtaionDate.Visible = true;
            txtDollarValue.Visible    = true;
            lblErrorMessage.Visible   = false;
            ScriptManager.RegisterStartupScript(this, GetType(), "AddDataPickerFooter", "SetDatePicket();", true);
        }
        else if (e.CommandName == "CancelSetting")
        {
            lblErrorMessage.Visible = false;
            gvSetting.EditIndex     = -1;
            LoadData();
        }
        else if (e.CommandName == "Insert")
        {
            DropDownList dllstakeholdertypefooter = gvSetting.FooterRow.FindControl("ddlstakeholderTypeListfooter") as DropDownList;
            DropDownList dlltiresizefooter        = gvSetting.FooterRow.FindControl("ddlTireSizeListfooter") as DropDownList;
            TextBox      txtEffectiveDate         = gvSetting.FooterRow.FindControl("txteffectivedatefooter") as TextBox;
            TextBox      txtExpirtaionDate        = gvSetting.FooterRow.FindControl("txtexpirationdatefooter") as TextBox;
            TextBox      txtDollarValue           = gvSetting.FooterRow.FindControl("txtDollarValuefooter") as TextBox;


            PTEStandards objPTE = new PTEStandards();
            //objPTE.OrganizationId = UserOrganizationId;
            objPTE.StateId = Conversion.ParseInt(ddlStewardship.SelectedItem.Value);
            //  objPTE.OrganizationSubTypeId = Convert.ToInt32(dllstakeholdertypefooter.SelectedValue);
            objPTE.SizeId          = Convert.ToInt32(dlltiresizefooter.SelectedValue);
            objPTE.EffectiveDate   = Convert.ToDateTime(txtEffectiveDate.Text, System.Globalization.CultureInfo.InvariantCulture);
            objPTE.ExpirationDate  = Convert.ToDateTime(txtExpirtaionDate.Text, System.Globalization.CultureInfo.InvariantCulture);
            objPTE.DollarValue     = float.Parse(txtDollarValue.Text);
            objPTE.LanguageId      = LanguageId;
            objPTE.CreatedDate     = DateTime.Now;
            objPTE.CreatedByUserId = UserInfo.GetCurrentUserInfo().UserId;

            int checkBit = PTEStandards.AddSetting(objPTE);
            if (checkBit == 0)
            {
                lblErrorMessage.Visible  = true;
                lblErrorMessage.CssClass = "custom-absolute-alert alert-danger";
                lblErrorMessage.Text     = "Record already Exists...";
                ScriptManager.RegisterStartupScript(this, GetType(), "fadeOut", "fadeOut();", true);
            }

            else
            {
                lblErrorMessage.Visible  = true;
                lblErrorMessage.CssClass = "custom-absolute-alert alert-success";
                lblErrorMessage.Text     = "Record added successfully...";
                ScriptManager.RegisterStartupScript(this, GetType(), "fadeOut", "fadeOut();", true);
            }

            LoadData();
        }
    }
 private BoundExpression MakeConversionLambda(Conversion conversion, TypeSymbol fromType, TypeSymbol toType)
 {
     string parameterName = "p";
     ParameterSymbol lambdaParameter = _bound.SynthesizedParameter(fromType, parameterName);
     var param = _bound.SynthesizedLocal(ParameterExpressionType);
     var parameterReference = _bound.Local(param);
     var parameter = ExprFactory("Parameter", _bound.Typeof(fromType), _bound.Literal(parameterName));
     _parameterMap[lambdaParameter] = parameterReference;
     var convertedValue = Visit(_bound.Convert(toType, _bound.Parameter(lambdaParameter), conversion));
     _parameterMap.Remove(lambdaParameter);
     var result = _bound.Sequence(
         ImmutableArray.Create(param),
         ImmutableArray.Create<BoundExpression>(_bound.AssignmentExpression(parameterReference, parameter)),
         ExprFactory(
             "Lambda",
             convertedValue,
             _bound.Array(ParameterExpressionType, ImmutableArray.Create<BoundExpression>(parameterReference))));
     return result;
 }
Example #48
0
 /// <summary>
 /// Reads a <see cref="Double"/> from the current stream and advances the current position of the stream by
 /// eight bytes. The bytes of the value are swapped according to the stream data endianness.
 /// </summary>
 /// <returns>The <see cref="Double"/> value read from the current stream.</returns>
 /// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
 /// <exception cref="ObjectDisposedException">The stream is closed.</exception>
 /// <exception cref="IOException">An I/O error occurred.</exception>
 public override double ReadDouble() =>
 ReverseEndianness?Conversion.ReverseEndianness(base.ReadDouble()) : base.ReadDouble();
Example #49
0
            public void Transfer(float posX, float posY, float posZ, float ori)
            {
                var p = new PacketClass(Opcodes.SMSG_TRANSFER_PENDING);

                p.AddInt32((int)Map);
                Client.Send(p);
                p.Dispose();

                // Actions Here
                IsInWorld = false;
                GetWorld.ClientDisconnect(Client.Index);
                _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Update(string.Format("UPDATE characters SET char_positionX = {0}, char_positionY = {1}, char_positionZ = {2}, char_orientation = {3}, char_map_id = {4} WHERE char_guid = {5};", Strings.Trim(Conversion.Str(posX)), Strings.Trim(Conversion.Str(posY)), Strings.Trim(Conversion.Str(posZ)), Strings.Trim(Conversion.Str(ori)), Map, Guid));

                // Do global transfer
                _clusterServiceLocator.WcNetwork.WorldServer.ClientTransfer(Client.Index, posX, posY, posZ, ori, Map);
            }
Example #50
0
 /// <summary>
 /// Reads an <see cref="Int64"/> from the current stream and advances the current position of the stream by
 /// eight bytes. The bytes of the value are swapped according to the stream data endianness.
 /// </summary>
 /// <returns>The <see cref="Int64"/> value read from the current stream.</returns>
 /// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
 /// <exception cref="ObjectDisposedException">The stream is closed.</exception>
 /// <exception cref="IOException">An I/O error occurred.</exception>
 public override long ReadInt64() =>
 ReverseEndianness?Conversion.ReverseEndianness(base.ReadInt64()) : base.ReadInt64();
Example #51
0
 public override void ProcessConversion(Expression expression, ResolveResult result, Conversion conversion, IType targetType)
 {
     if (conversion.IsUserDefined && findReferences.IsMemberMatch(op, conversion.Method, conversion.IsVirtualMethodLookup)) {
         ReportMatch(expression, result);
     }
 }
Example #52
0
        public void ARMTemplatePipelineTest()
        {
            //Arrange
            Conversion conversion = new Conversion();
            string     yaml       = @"
jobs:
- job: Deploy
  displayName: Deploy job
  pool:
    vmImage: ubuntu-latest
  variables:
    AppSettings.Environment: 'data'
    ArmTemplateResourceGroupLocation: 'eu'
    ResourceGroupName: 'MyProjectRG'
  steps:
  - task: DownloadBuildArtifacts@0
    displayName: 'Download the build artifacts'
    inputs:
      buildType: 'current'
      downloadType: 'single'
      artifactName: 'drop'
      downloadPath: '$(build.artifactstagingdirectory)'
  - task: AzureResourceGroupDeployment@2
    displayName: 'Deploy ARM Template to resource group'
    inputs:
      azureSubscription: 'connection to Azure Portal'
      resourceGroupName: $(ResourceGroupName)
      location: '[resourceGroup().location]'
      csmFile: '$(build.artifactstagingdirectory)/drop/ARMTemplates/azuredeploy.json'
      csmParametersFile: '$(build.artifactstagingdirectory)/drop/ARMTemplates/azuredeploy.parameters.json'
      overrideParameters: '-environment $(AppSettings.Environment) -locationShort $(ArmTemplateResourceGroupLocation)'
";

            //Act
            ConversionResponse gitHubOutput = conversion.ConvertAzurePipelineToGitHubAction(yaml);

            //Assert
            string expected = @"
#Note: 'AZURE_SP' secret is required to be setup and added into GitHub Secrets: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets
jobs:
  Deploy:
    name: Deploy job
    runs-on: ubuntu-latest
    env:
      AppSettings.Environment: data
      ArmTemplateResourceGroupLocation: eu
      ResourceGroupName: MyProjectRG
    steps:
    - uses: actions/checkout@v2
    - #: ""Note: 'AZURE_SP' secret is required to be setup and added into GitHub Secrets: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets""
      name: Azure Login
      uses: azure/login@v1
      with:
        creds: ${{ secrets.AZURE_SP }}
    - name: Download the build artifacts
      uses: actions/[email protected]
      with:
        name: drop
    - name: Deploy ARM Template to resource group
      uses: Azure/[email protected]
      with:
        inlineScript: az deployment group create --resource-group ${{ env.ResourceGroupName }} --template-file ${GITHUB_WORKSPACE}/drop/ARMTemplates/azuredeploy.json --parameters  ${GITHUB_WORKSPACE}/drop/ARMTemplates/azuredeploy.parameters.json -environment ${{ env.AppSettings.Environment }} -locationShort ${{ env.ArmTemplateResourceGroupLocation }}
";

            expected = UtilityTests.TrimNewLines(expected);
            Assert.AreEqual(expected, gitHubOutput.actionsYaml);
        }
		public void ProcessConversion(Expression expression, ResolveResult result, Conversion conversion, IType targetType)
		{
			foreach (var navigator in navigators) {
				navigator.ProcessConversion(expression, result, conversion, targetType);
			}
		}
Example #54
0
        public void DotNetDesktopPipelineTest()
        {
            //Arrange
            Conversion conversion = new Conversion();
            //Source is: https://github.com/microsoft/azure-pipelines-yaml/blob/master/templates/.net-desktop.yml
            string yaml = @"
# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: 'WindowsFormsApp1.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'
- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
";

            //Act
            ConversionResponse gitHubOutput = conversion.ConvertAzurePipelineToGitHubAction(yaml);

            //Assert
            string expected = @"
#Note: This is a third party action: https://github.com/warrenbuckley/Setup-Nuget
on:
  push:
    branches:
    - master
env:
  solution: WindowsFormsApp1.sln
  buildPlatform: Any CPU
  buildConfiguration: Release
jobs:
  build:
    runs-on: windows-latest
    steps:
    - uses: actions/checkout@v2
    - uses: microsoft/[email protected]
    - #: 'Note: This is a third party action: https://github.com/warrenbuckley/Setup-Nuget'
      uses: warrenbuckley/Setup-Nuget@v1
    - run: nuget  ${{ env.solution }}
      shell: powershell
    - run: msbuild '${{ env.solution }}' /p:configuration='${{ env.buildConfiguration }}' /p:platform='${{ env.buildPlatform }}'
";

            expected = UtilityTests.TrimNewLines(expected);
            Assert.AreEqual(expected, gitHubOutput.actionsYaml);
        }
Example #55
0
 private BoundExpression GenerateNullCoalescingBadBinaryOpsError(BinaryExpressionSyntax node, BoundExpression leftOperand, BoundExpression rightOperand, Conversion leftConversion, DiagnosticBag diagnostics)
 {
     Error(diagnostics, ErrorCode.ERR_BadBinaryOps, node, SyntaxFacts.GetText(node.OperatorToken.Kind()), leftOperand.Display, rightOperand.Display);
     return new BoundNullCoalescingOperator(node, leftOperand, rightOperand,
         leftConversion, CreateErrorType(), hasErrors: true);
 }
Example #56
0
        public void GoPipelineTest()
        {
            //Arrange
            Conversion conversion = new Conversion();
            //Source is: https://raw.githubusercontent.com/microsoft/azure-pipelines-yaml/master/templates/go.yml
            string yaml = @"
# Go
# Build your Go project.
# Add steps that test, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/go

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  GOBIN:  '$(GOPATH)/bin' # Go binaries path
  GOROOT: '/usr/local/go1.11' # Go installation path
  GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
  modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code

steps:
- script: |
    mkdir -p '$(GOBIN)'
    mkdir -p '$(GOPATH)/pkg'
    mkdir -p '$(modulePath)'
    shopt -s extglob
    shopt -s dotglob
    mv !(gopath) '$(modulePath)'
    echo '##vso[task.prependpath]$(GOBIN)'
    echo '##vso[task.prependpath]$(GOROOT)/bin'
  displayName: 'Set up the Go workspace'

- script: |
    go version
    go get -v -t -d ./...
    if [ -f Gopkg.toml ]; then
        curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
        dep ensure
    fi
    go build -v .
  workingDirectory: '$(modulePath)'
  displayName: 'Get dependencies, then build'
";

            //Act
            ConversionResponse gitHubOutput = conversion.ConvertAzurePipelineToGitHubAction(yaml);

            //Assert
            string expected = @"
on:
  push:
    branches:
    - master
env:
  GOBIN: ${{ env.GOPATH }}/bin
  GOROOT: /usr/local/go1.11
  GOPATH: ${{ env.system.defaultWorkingDirectory }}/gopath
  modulePath: ${{ env.GOPATH }}/src/github.com/${{ env.build.repository.name }}
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Set up the Go workspace
      run: |
        mkdir -p '${{ env.GOBIN }}'
        mkdir -p '${{ env.GOPATH }}/pkg'
        mkdir -p '${{ env.modulePath }}'
        shopt -s extglob
        shopt -s dotglob
        mv !(gopath) '${{ env.modulePath }}'
        echo '##vso[task.prependpath]${{ env.GOBIN }}'
        echo '##vso[task.prependpath]${{ env.GOROOT }}/bin'
    - name: Get dependencies, then build
      run: |
        go version
        go get -v -t -d ./...
        if [ -f Gopkg.toml ]; then
            curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
            dep ensure
        fi
        go build -v .
";

            expected = UtilityTests.TrimNewLines(expected);
            Assert.AreEqual(expected, gitHubOutput.actionsYaml);
        }
Example #57
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            if (Monto != ucTotalesSeña.TotalPagar)
            {
                _messageBoxDisplayService.ShowError("Los montos no coinciden");
                return;
            }

            Guid operadorAutoriza = Guid.Empty;

            if (_formMode == ActionFormMode.Edit)
            {

                //////Autorizacion para sin movimiento
                var operador = this.ObtenerOperadorAdministrador();

                if (operador == null)
                {
                    return;
                }

                if (!this.EsOperadorAdmin)
                {
                    //Guardamos el operador que autorizo la operacion.
                    operadorAutoriza = operador.Id;
                }

            }
            ////////////////////////////////




            //TODO: Reemplzar el numero cuando se agrege la columna a sucursal.
            int numeroDeSucursal = 1;

            ClienteMontoFavor clienteMontoFavor = new ClienteMontoFavor();
            clienteMontoFavor.Id = Guid.NewGuid();
            clienteMontoFavor.ClienteId = _cliente.Id;
            clienteMontoFavor.FechaComprobante = _clock.Now;
            clienteMontoFavor.TipoComprobanteId = TipoComprobanteEnum.SeñaCliente;
            clienteMontoFavor.LCN = "R" + numeroDeSucursal.ToString().PadLeft(4, '0') + CalcularLCN().PadLeft(8, '0');
            clienteMontoFavor.Concepto = "Seña " + clienteMontoFavor.LCN;
            clienteMontoFavor.Importe = ucTotalesSeña.TotalPagar;
            clienteMontoFavor.ImpOcupado = 0;
            clienteMontoFavor.Observaciones = TipoComprobanteEnum.SeñaCliente.ToString();
            clienteMontoFavor.FechaAlta = _clock.Now;
            clienteMontoFavor.OperadorAltaId = Context.OperadorActual.Id;
            clienteMontoFavor.SucursalAltaId = Context.SucursalActual.Id;
            if (operadorAutoriza != Guid.Empty)
                clienteMontoFavor.OperadorAutoriza = operadorAutoriza;

            Uow.ClientesMontosFavor.Agregar(clienteMontoFavor);

            //Si el Form=Editar significa que es SinGuardar los movimientos de caja
            if (_formMode == ActionFormMode.Create)
            {
                //ActualizarCaja y CajaMovimiento
                Caja caja = this.Context.CajaActual;
                if (caja.Egresos == null)
                    caja.Egresos = 0;
                caja.Ingresos += (float?)ucTotalesSeña.TotalPagar;
                caja.Saldo += (float?)ucTotalesSeña.TotalPagar;
                caja.FechaModificacion = _clock.Now;
                caja.SucursalModificacionId = 2;//Sucursal del operador
                caja.OperadorModificacionId = (Context.OperadorActual.Id);//Id el operador

                Uow.Cajas.Modificar(caja);

                CajaMovimiento cajaMovimiento = new CajaMovimiento();
                cajaMovimiento.Id = Guid.NewGuid();
                cajaMovimiento.CajaId = caja.Id;
                cajaMovimiento.TipoMovimientoCajaId = TipoMovimientoCajaEnum.SeñaCliente;
                cajaMovimiento.TipoComprobante = TipoComprobanteEnum.SeñaCliente;
                cajaMovimiento.ComprobanteId = clienteMontoFavor.Id;
                cajaMovimiento.Importe = ucTotalesSeña.TotalPagar;
                cajaMovimiento.FechaAlta = _clock.Now;
                cajaMovimiento.OperadorAltaId = Context.OperadorActual.Id;
                cajaMovimiento.SucursalAltaId = Context.SucursalActual.Id;
                cajaMovimiento.PcAlta = Environment.MachineName;
                //tipos de pagos
                foreach (VentaPago pago in ucTotalesSeña.Pagos)
                {
                    switch (pago.TipoPago)
                    {
                        case FormaPago.Efectivo:
                            cajaMovimiento.Efectivo = pago.Importe;
                            break;
                        case FormaPago.Tarjeta:
                            var pagoTarjeta = pago as VentaPagoTarjeta;
                            if (cajaMovimiento.Tarjeta == null)
                                cajaMovimiento.Tarjeta = 0;

                            cajaMovimiento.Tarjeta += pago.Importe;
                            //GUARDAR TARJETA MOVIMIENTO 
                            TarjetasMovimiento tarjetasMovimiento = new TarjetasMovimiento();
                            tarjetasMovimiento.CajaMovimientoId = cajaMovimiento.Id;
                            tarjetasMovimiento.TarjetaId = pagoTarjeta.TarjetaId ?? 0;
                            tarjetasMovimiento.LoteCupon = pagoTarjeta.CuponNumero;
                            tarjetasMovimiento.Fecha = _clock.Now;
                            tarjetasMovimiento.Importe = (float)pago.Importe;
                            tarjetasMovimiento.Estado = 1; // No se 
                            tarjetasMovimiento.FechaAlta = _clock.Now;
                            tarjetasMovimiento.SucursalAltaId = Context.SucursalActual.Id; //Sucursal del operador
                            tarjetasMovimiento.OperadorAltaId = (Context.OperadorActual.Id); //Id el operador

                            Uow.TarjetasMovimientos.Agregar(tarjetasMovimiento);
                            break;
                        case FormaPago.Cheque:
                            var pagoCheque = pago as VentaPagoCheque;

                            if (cajaMovimiento.Cheque == null)
                                cajaMovimiento.Cheque = 0;

                            cajaMovimiento.Cheque += pago.Importe;

                            ChequesTercero chequesTercero = new ChequesTercero();
                            chequesTercero.Id = Guid.NewGuid();
                            chequesTercero.CajaMovimientoId = cajaMovimiento.Id;
                            chequesTercero.BancoId = pagoCheque.BancoId ?? 0;
                            chequesTercero.NroCheque = pagoCheque.Numero;
                            chequesTercero.Fecha = _clock.Now;
                            chequesTercero.FechaCobro = _clock.Now;
                            chequesTercero.Importe = (float)pago.Importe;
                            chequesTercero.FechaAlta = _clock.Now;
                            chequesTercero.SucursalAltaId = Context.SucursalActual.Id;
                            chequesTercero.OperadorAltaId = (Context.OperadorActual.Id);

                            Uow.ChequesTerceros.Agregar(chequesTercero);
                            break;
                        case FormaPago.Deposito:
                            var pagoDeposito = pago as VentaPagoDeposito;
                            if (cajaMovimiento.Deposito == null)
                                cajaMovimiento.Deposito = 0;

                            //Guardar Cuentas Movimientos
                            cajaMovimiento.Deposito += pago.Importe;

                            CuentasMovimiento cuentasMovimiento = new CuentasMovimiento();
                            cuentasMovimiento.CuentaId = pagoDeposito.CuentaId;
                            cuentasMovimiento.TipoMovimientoId = 2; //Deposito
                            cuentasMovimiento.FechaMovimiento = pagoDeposito.Fecha;
                            cuentasMovimiento.EstadoMovimientoCuentaId = 0;
                            cuentasMovimiento.TipoComprobanteId = TipoComprobanteEnum.SeñaCliente;
                            cuentasMovimiento.ComprobanteId = clienteMontoFavor.Id;
                            cuentasMovimiento.MonedaId = 0;
                            cuentasMovimiento.CondicionVentaId = CondicionVentaEnum.Contado;
                            cuentasMovimiento.NroMovimiento = pagoDeposito.Numero;
                            cuentasMovimiento.Descripcion = "DEPOSITO NRO " + pagoDeposito.Numero.ToString();
                            cuentasMovimiento.FechaCobro = _clock.Now;
                            cuentasMovimiento.Debito = 0;
                            cuentasMovimiento.Credito = pago.Importe;
                            cuentasMovimiento.TipoCarga = 2;
                            cuentasMovimiento.CajaId = caja.Id;
                            cuentasMovimiento.FechaAlta = _clock.Now;
                            cuentasMovimiento.OperadorAltaId = Context.OperadorActual.Id;
                            cuentasMovimiento.SucursalAltaId = Context.SucursalActual.Id;

                            Uow.CuentasMovimientos.Agregar(cuentasMovimiento);
                            break;

                    }
                }

                Uow.CajaMovimientos.Agregar(cajaMovimiento);
            }


            Uow.Commit();
            _messageBoxDisplayService.ShowSuccess("Seña generada con éxito");

            //Si el Form=Editar significa que es SinGuardar los movimientos de caja
            if (_formMode == ActionFormMode.Create)
            {
                var crearSenia = FormFactory.Create<FrmComprobante>();
                crearSenia._concepto = "Seña de Cliente";
                crearSenia._LCN = clienteMontoFavor.LCN;
                var conv = new Conversion();

                crearSenia._montoTexto = conv.enletras(ucTotalesSeña.TotalPagar.ToString());
                //crearSenia._montoTexto = "cien";
                crearSenia.Show();
            }

            BuscarHistorial();
            Limpiar();
        }
Example #58
0
        public void NuGetPackagePipelineTest()
        {
            //Arrange
            Conversion conversion = new Conversion();
            string     yaml       = @"
resources:
- repo: self
  containers:
  - container: test123

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  BuildConfiguration: 'Release'
  BuildPlatform : 'Any CPU'
  BuildVersion: 1.1.$(Build.BuildId)

steps:
- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: restore
    projects: MyProject/MyProject.Models/MyProject.Models.csproj

- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    projects: MyProject/MyProject.Models/MyProject.Models.csproj
    arguments: '--configuration $(BuildConfiguration)'

- task: DotNetCoreCLI@2
  displayName: Publish
  inputs:
    command: publish
    publishWebProjects: false
    projects: MyProject/MyProject.Models/MyProject.Models.csproj
    arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
    zipAfterPublish: false

- task: DotNetCoreCLI@2
  displayName: 'dotnet pack'
  inputs:
    command: pack
    packagesToPack: MyProject/MyProject.Models/MyProject.Models.csproj
    versioningScheme: byEnvVar
    versionEnvVar: BuildVersion

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
";

            //Act
            ConversionResponse gitHubOutput = conversion.ConvertAzurePipelineToGitHubAction(yaml);

            //Assert
            string expected = @"
on:
  push:
    branches:
    - master
env:
  BuildConfiguration: Release
  BuildPlatform: Any CPU
  BuildVersion: 1.1.${{ env.Build.BuildId }}
jobs:
  build:
    runs-on: windows-latest
    container: {}
    steps:
    - uses: actions/checkout@v2
    - name: Restore
      run: dotnet restore MyProject/MyProject.Models/MyProject.Models.csproj
    - name: Build
      run: dotnet MyProject/MyProject.Models/MyProject.Models.csproj --configuration ${{ env.BuildConfiguration }}
    - name: Publish
      run: dotnet publish MyProject/MyProject.Models/MyProject.Models.csproj --configuration ${{ env.BuildConfiguration }} --output ${GITHUB_WORKSPACE}
    - name: dotnet pack
      run: dotnet pack
    - name: Publish Artifact
      uses: actions/upload-artifact@v2
      with:
        path: ${GITHUB_WORKSPACE}
";

            expected = UtilityTests.TrimNewLines(expected);
            Assert.AreEqual(expected, gitHubOutput.actionsYaml);
        }
Example #59
0
 ResolveResult Convert(ResolveResult rr, IType targetType, Conversion c)
 {
     if (c == Conversion.IdentityConversion)
         return rr;
     else if (rr.IsCompileTimeConstant && c != Conversion.None)
         return ResolveCast(targetType, rr);
     else
         return new ConversionResolveResult(targetType, rr, c);
 }
Example #60
0
        public void PythonPipelineTest()
        {
            //Arrange
            Conversion conversion = new Conversion();
            //Source is: https://raw.githubusercontent.com/microsoft/azure-pipelines-yaml/master/templates/python-django.yml
            string yaml = @"
trigger:
- master

pool:
  vmImage: 'ubuntu-latest'
strategy:
  matrix:
    Python35:
      PYTHON_VERSION: '3.5'
    Python36:
      PYTHON_VERSION: '3.6'
    Python37:
      PYTHON_VERSION: '3.7'
  maxParallel: 3

steps:
- task: UsePythonVersion@0
  inputs:
    versionSpec: '$(PYTHON_VERSION)'
    addToPath: true
    architecture: 'x64'
- task: PythonScript@0
  inputs:
    scriptSource: 'filePath'
    scriptPath: 'Python/Hello.py'
";

            //Act
            ConversionResponse gitHubOutput = conversion.ConvertAzurePipelineToGitHubAction(yaml);

            //Assert
            string expected = @"
on:
  push:
    branches:
    - master
jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        PYTHON_VERSION:
        - 3.5
        - 3.6
        - 3.7
      max-parallel: 3
    steps:
    - uses: actions/checkout@v2
    - name: Setup Python ${{ matrix.PYTHON_VERSION }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.PYTHON_VERSION }}
    - run: python Python/Hello.py
";

            expected = UtilityTests.TrimNewLines(expected);
            Assert.AreEqual(expected, gitHubOutput.actionsYaml);
        }