Exemplo n.º 1
0
        public void PrintCheck()
        {
            var check = Fr.СоздатьЧек();

            check.Фискальный         = true;
            check.ТипНалогообложения = 1;
            check.Кассир             = "Иван Иванов";
            check.ИннКассира         = "0326031413";
            //TODO придумать предупреждение NRE

            check.Контакт     = "*****@*****.**";
            check.Департамент = 1;
            check.Электронный = false;

            check.Терминал = "test" + check.Терминал;
            check.ТипЧека  = ClientPrint.PrintServiceRef.CheckTypes.Продажа;
            check.ДобавитьПозицию105("Доставка пакетов", 1, 1, -30, 1, -1, 4, 4);
            check.ДобавитьПозицию105("Пакет красный", 1, 1, 0.5, 1, 0, 4, 1);
            check.ДобавитьПозицию105("Пакет желтый", 1, 1, 0.5, 1, 10, 4, 1);
            check.ДобавитьПозицию105("Пакет синий", 1, 1, 0.5, 1, 18, 4, 4);
            check.ДобавитьПозицию105("Пакет оранжевый", 1, 1, 0.5, 1, 110, 4, 1);
            check.ДобавитьПозицию105("Пакет с принтом", 1, 1, 0.5, 1, 118, 4, 1);

            check.ДобавитьОплатуНаличными(510);

            var val = Fr.аспечататьЧекАсинхронно(check);

            Res = val == 0 ? true : false;
            Assert.AreEqual(true, Res, MessageError);
        }
Exemplo n.º 2
0
        public void PrintNonFiscalString()
        {
            bool isFiscal           = false;
            bool isReturn           = false;
            bool canceleOpenedCheck = true;
            int  checkNumber;
            int  sessionNumber;

            Res = Fr.ОткрытьЧек(Device, isFiscal, isReturn, canceleOpenedCheck, out checkNumber, out sessionNumber);

            Assert.IsTrue(Res, MessageError);
            Assert.AreNotEqual(checkNumber, 0);
            Assert.AreNotEqual(sessionNumber, 0);

            string text = "Нефискальная строка";

            Res = Fr.НапечататьНефискСтроку(Device, text);

            Assert.IsTrue(Res, MessageError);

            double cash             = 100;
            double payByCard        = 0;
            double payByCredit      = 0;
            double payByCertificate = 0;

            Res = Fr.ЗакрытьЧек(Device, cash, payByCard, payByCredit, payByCertificate);

            Assert.IsTrue(Res, MessageError);
        }
Exemplo n.º 3
0
            public static Fr operator *(Fr x, Fr y)
            {
                Fr z = new Fr();

                z.Mul(x, y);
                return(z);
            }
Exemplo n.º 4
0
            public static Fr operator -(Fr x, Fr y)
            {
                Fr z = new Fr();

                z.Sub(x, y);
                return(z);
            }
Exemplo n.º 5
0
 public Magazine()
 {
     namePublication   = "Жизненные позиции";
     dataOut           = new DateTime(2013, 3, 24);
     numberPublication = 678;
     DaTaYear          = Fr.Monthly;
 }
Exemplo n.º 6
0
        public static void ExportTranslationToCSV(string path)
        {
            try
            {
                if (!File.Exists(path))
                {
                    File.Create(path).Close();
                }

                var toExport = En.Select(kv => new TranslationCSV
                {
                    En  = kv.Value,
                    Key = kv.Key,
                    Fr  = Fr.ContainsKey(kv.Key) ? Fr[kv.Key] : string.Empty
                }).ToList();

                using (var writer = new StreamWriter(new FileStream(path, FileMode.Open, FileAccess.ReadWrite),
                                                     Encoding.UTF8))
                    using (var csv = new CsvWriter(writer))
                    {
                        csv.WriteRecords(toExport);
                    }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while exporting: " + ex.Message);
            }
        }
Exemplo n.º 7
0
        public static void LoadTranslationFromCSV(string path)
        {
            try
            {
                using (var reader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.ReadWrite),
                                                     Encoding.UTF8))
                    using (var csv = new CsvReader(reader))
                    {
                        csv.Configuration.PrepareHeaderForMatch = (string header, int index) => header.ToLower();
                        var records = csv.GetRecords <TranslationCSV>();

                        Fr.Clear();
                        En.Clear();

                        foreach (var record in records)
                        {
                            En.Add(record.Key, record.En);
                            Fr.Add(record.Key, record.Fr);
                        }
                    }

                ImportedCsv?.Invoke();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while importing: " + ex.Message);
            }
        }
Exemplo n.º 8
0
            public static Fr operator +(Fr x, Fr y)
            {
                Fr z = new Fr();

                z.Add(x, y);
                return(z);
            }
Exemplo n.º 9
0
        static void TestG1()
        {
            Console.WriteLine("TestG1");
            G1 P = new G1();

            P.Clear();
            assert("P.IsValid", P.IsValid());
            assert("P.IsZero", P.IsZero());
            P.HashAndMapTo("abc");
            assert("P.IsValid", P.IsValid());
            assert("!P.IsZero", !P.IsZero());
            G1 Q = new G1();

            Q = P;
            assert("P == Q", Q.Equals(P));
            Q.Neg(P);
            Q.Add(Q, P);
            assert("P = Q", Q.IsZero());
            Q.Dbl(P);
            G1 R = new G1();

            R.Add(P, P);
            assert("Q == R", Q.Equals(R));
            Fr x = new Fr();

            x.SetInt(3);
            R.Add(R, P);
            Q.Mul(P, x);
            assert("Q == R", Q.Equals(R));
        }
Exemplo n.º 10
0
Arquivo: mcl.cs Projeto: renlulu/mcl
            public static Fr One()
            {
                var x = new Fr();

                x.SetInt(1);
                return(x);
            }
Exemplo n.º 11
0
            public static Fr operator /(Fr x, Fr y)
            {
                Fr z = new Fr();

                z.Div(x, y);
                return(z);
            }
Exemplo n.º 12
0
            public static Fr operator -(Fr x)
            {
                Fr y = new Fr();

                y.Neg(x);
                return(y);
            }
Exemplo n.º 13
0
        public static State FromBytes(ReadOnlyMemory <byte> bytes)
        {
            var cLen       = bytes.Slice(0, 4).Span.ToInt32();
            var commitment = cLen != 0 ? Commitment.FromBytes(bytes.Slice(4, cLen).ToArray()) : null;
            var n          = bytes.Slice(4 + cLen, 4).Span.ToInt32();
            var values     = bytes.Slice(8 + cLen, n * Fr.ByteSize).ToArray()
                             .Batch(Fr.ByteSize)
                             .Select(x => Fr.FromBytes(x.ToArray()))
                             .ToArray();
            var acks = bytes.Slice(8 + cLen + n * Fr.ByteSize).ToArray()
                       .Select(b => b != 0)
                       .ToArray();
            var result = new State(values.Length)
            {
                Commitment = commitment
            };

            for (var i = 0; i < n; ++i)
            {
                result.Values[i] = values[i];
                result.Acks[i]   = acks[i];
            }

            return(result);
        }
Exemplo n.º 14
0
        static void TestPairing()
        {
            Console.WriteLine("TestG2");
            G1 P = new G1();

            P.setStr("1 -1 1");
            G2 Q = new G2();

            Q.HashAndMapTo("1");
            Fr a = new Fr();
            Fr b = new Fr();

            a.SetStr("12345678912345673453");
            b.SetStr("230498230982394243424");
            G1 aP = new G1();
            G2 bQ = new G2();

            G1.Mul(aP, P, a);
            G2.Mul(bQ, Q, b);
            GT e1 = new GT();
            GT e2 = new GT();
            GT e3 = new GT();

            Pairing(e1, P, Q);
            Pairing(e2, aP, Q);
            GT.Pow(e3, e1, a);
            assert("e2.Equals(e3)", e2.Equals(e3));
            Pairing(e2, P, bQ);
            GT.Pow(e3, e1, b);
            assert("e2.Equals(e3)", e2.Equals(e3));
        }
Exemplo n.º 15
0
        static void TestG1()
        {
            Console.WriteLine("TestG1");
            G1 P = new G1();

            P.Clear();
            assert("P = 0", P.ToString() == "0");
            assert("P.IsValid", P.IsValid());
            assert("P.IsZero", P.IsZero());
            P.HashAndMapTo("abc");
            assert("P.IsValid", P.IsValid());
            assert("!P.IsZero", !P.IsZero());
            G1 Q = new G1();

            Q = P.Clone();
            assert("P == Q", Q.Equals(P));
            G1.Neg(Q, P);
            G1.Add(Q, Q, P);
            assert("P = Q", Q.IsZero());
            G1.Dbl(Q, P);
            G1 R = new G1();

            G1.Add(R, P, P);
            assert("Q == R", Q.Equals(R));
            Fr x = new Fr();

            x.SetInt(3);
            G1.Add(R, R, P);
            G1.Mul(Q, P, x);
            assert("Q == R", Q.Equals(R));
        }
Exemplo n.º 16
0
        static void TestPairing()
        {
            Console.WriteLine("TestG2");
            G1 P = new G1();

            P.HashAndMapTo("123");
            G2 Q = new G2();

            Q.HashAndMapTo("1");
            Fr a = new Fr();
            Fr b = new Fr();

            a.SetStr("12345678912345673453", 10);
            b.SetStr("230498230982394243424", 10);
            G1 aP = new G1();
            G2 bQ = new G2();

            aP.Mul(P, a);
            bQ.Mul(Q, b);
            GT e1 = new GT();
            GT e2 = new GT();
            GT e3 = new GT();

            e1.Pairing(P, Q);
            e2.Pairing(aP, Q);
            e3.Pow(e1, a);
            assert("e2.Equals(e3)", e2.Equals(e3));
            e2.Pairing(P, bQ);
            e3.Pow(e1, b);
            assert("e2.Equals(e3)", e2.Equals(e3));
        }
Exemplo n.º 17
0
        static void TestG2()
        {
            Console.WriteLine("TestG2");
            G2 P = new G2();

            P.Clear();
            assert("P = 0", P.ToString() == "0");
            assert("P is valid", P.IsValid());
            assert("P is zero", P.IsZero());
            P.HashAndMapTo("abc");
            assert("P is valid", P.IsValid());
            assert("P is not zero", !P.IsZero());
            G2 Q = new G2();

            Q = P.Clone();
            assert("P == Q", Q.Equals(P));
            G2.Neg(Q, P);
            G2.Add(Q, Q, P);
            assert("Q is zero", Q.IsZero());
            G2.Dbl(Q, P);
            G2 R = new G2();

            G2.Add(R, P, P);
            assert("Q == R", Q.Equals(R));
            Fr x = new Fr();

            x.SetInt(3);
            G2.Add(R, R, P);
            G2.Mul(Q, P, x);
            assert("Q == R", Q.Equals(R));
        }
Exemplo n.º 18
0
 public Edition(string nP1, DateTime dO1, Fr yeardat, double nPu1)
 {
     nP1     = namePublication;
     dO1     = dataOut;
     nPu1    = numberPublication;
     yeardat = Fr.Monthly;
 }
Exemplo n.º 19
0
        public void TestSimpleArithmetic()
        {
            for (var i = -100; i <= 100; ++i)
            {
                var x = GT.FromInt(i);
                Assert.AreEqual(GT.FromInt(-i), -x);
                for (var j = -100; j <= 100; ++j)
                {
                    var y = GT.FromInt(j);
                    Assert.AreEqual(GT.FromInt(i + j), x + y);
                    Assert.AreEqual(GT.FromInt(i * j), x * y);
                    Assert.AreEqual(GT.FromInt(i - j), x - y);
                    if (j == 0)
                    {
                        Assert.Throws <InvalidOperationException>(() =>
                        {
                            var unused = x * y / y;
                        });
                    }
                    else
                    {
                        Assert.AreEqual(GT.FromInt(i * j / j), x * y / y);
                    }

                    if (j > 0 && i >= -8 && i <= 8 && j <= 8)
                    {
                        Assert.AreEqual(GT.FromInt((int)Math.Pow(i, j)), GT.Pow(x, Fr.FromInt(j)));
                    }
                }
            }
        }
Exemplo n.º 20
0
 private void MainPage_BackRequested(object sender, BackRequestedEventArgs e)
 {
     e.Handled = true;
     try
     {
         if (Fr.CanGoBack)
         {
             Fr.GoBack();
         }
         else
         {
             RavinduL.LocalNotifications.LocalNotificationManager lnm = new RavinduL.LocalNotifications.LocalNotificationManager(MG);
             lnm.Show(new SimpleNotification
             {
                 TimeSpan          = TimeSpan.FromSeconds(5),
                 Text              = "Click/Tap Here to exit",
                 Glyph             = "\uE7E8",
                 Background        = (new SolidColorBrush((Color)Resources["SystemControlBackgroundAccentBrush"])),
                 VerticalAlignment = VerticalAlignment.Bottom,
                 Action            = () => { App.Current.Exit(); },
             }, RavinduL.LocalNotifications.LocalNotificationCollisionBehaviour.Wait);
             //var msg = new MessageDialog(MultilingualHelpToolkit.GetString("stringExit", "Text"));
             //msg.Commands.Add(new UICommand(MultilingualHelpToolkit.GetString("StringYes", "Text"), delegate
             //{
             //    App.Current.Exit();
             //}));
             //msg.Commands.Add(new UICommand(MultilingualHelpToolkit.GetString("StringNo", "Text"), delegate { }));
             //await msg.ShowAsync();
         }
     }
     catch
     {
     }
 }
Exemplo n.º 21
0
        /// <summary>
        /// Write all frames to specific TagStream
        /// </summary>
        /// <param name="writer">TagStream to write data to</param>
        /// <param name="Ver">Minor Version of ID3</param>
        private void WriteFrames(int Ver)
        {
            foreach (FrameCollectionBase Coll in _CollectionFrames.Values)
            {
                if (Coll.Name != CollectionIndex.Unknown.ToString() ||
                    (Coll.Name == CollectionIndex.Unknown.ToString() && !_DropUnknown))
                {
                    foreach (Frame Fr in Coll)
                    {
                        // If Frame is not valid and is not UserTextFrame we ignore it
                        if (!FramesInfo.IsCompatible(Fr.FrameID, Ver) && FramesInfo.IsTextFrame(Fr.FrameID, Ver) != 2)
                        {
                            AddError(new ID3Exception("nonCompatible Frame found on Frames and will not save with file", Fr.FrameID, ExceptionLevels.Warning));
                            continue;
                        }

                        if (Fr.IsValid)
                        {
                            Fr.WriteData(Ver);
                        }
                    }
                }
            }

            foreach (Frame Fr in _SingleFrames.Values)
            {
                if (FramesInfo.IsCompatible(Fr.FrameID, Ver) && Fr.IsValid)
                {
                    Fr.WriteData(Ver);
                }
            }
        }
Exemplo n.º 22
0
 public static BiVarSymmetricPolynomial Random(int degree)
 {
     return(new BiVarSymmetricPolynomial(
                degree,
                Enumerable.Range(0, degree + 1)
                .SelectMany(i => Enumerable.Range(0, i + 1).Select(j => Fr.GetRandom()))
                ));
 }
Exemplo n.º 23
0
        public void TestPowersCalculation()
        {
            var powers = Enumerable.Range(0, 30)
                         .Select(i => Fr.FromInt(1 << i))
                         .ToArray();

            CollectionAssert.AreEqual(powers, MclBls12381.Powers(Fr.FromInt(2), 30));
        }
Exemplo n.º 24
0
        public void CashInOutcome()
        {
            double Amount = 5;

            Res = Fr.НапечататьЧекВнесенияВыемки(Device, Amount);

            Assert.IsTrue(Res, MessageError);
        }
Exemplo n.º 25
0
            public static Fr One()
            {
                var fr = new Fr();

                fr.SetInt(1);

                return(fr);
            }
Exemplo n.º 26
0
        public void TestGetRandom()
        {
            var rnd = Fr.GetRandom();

            Assert.IsTrue(rnd.IsValid());
            rnd.Clear();
            Assert.AreEqual(Fr.Zero, rnd);
        }
Exemplo n.º 27
0
        public void DeserializationG2Test()
        {
            var x   = Fr.GetRandom();
            var a   = G2.Generator * x;
            var enc = a.ToBytes();
            var b   = G2.FromBytes(enc);

            Assert.True(a.Equals(b));
        }
Exemplo n.º 28
0
        public void PrintBarCode()
        {
            string barCodeType = "QR";
            string barCode     = "НапечататьШтрихКод(Device,barCodeType,barCode)";

            Res = Fr.НапечататьШтрихКод(Device, barCodeType, barCode);

            Assert.IsTrue(Res, MessageError);
        }
Exemplo n.º 29
0
        public void DeserializationFrTest()
        {
            var a   = Fr.GetRandom();
            var enc = a.ToBytes();

            Assert.AreEqual(enc.Length, 32);
            var b = Fr.FromBytes(enc);

            Assert.True(a.Equals(b));
        }
Exemplo n.º 30
0
        public IEnumerable <PrivateKeyShare> GetPrivateShares()
        {
            var shares = new Fr[_parties];

            for (var i = 0; i < _parties; ++i)
            {
                shares[i] = MclBls12381.EvaluatePolynomial(_coeffs, Fr.FromInt(i + 1));
            }
            return(shares.Select(share => new PrivateKeyShare(share)));
        }