Exemplo n.º 1
0
        private void MenuItem_ClickOpen(object sender, RoutedEventArgs e)
        {
            mn_Import.IsEnabled = false;
            Lg.Clear();
            btnsave.IsEnabled = false;
            //
            richTextBox1.Document.Blocks.Clear();
            dg1.Items.Refresh();
            //
            var openFileDialog = new OpenFileDialog();

            openFileDialog.Multiselect      = true;
            openFileDialog.Filter           = "Text files (*.txt)|*.txt|(*.rtf)|*.rtf|All files (*.*)|*.*";
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            if (openFileDialog.ShowDialog() == true)
            {
                var txt = File.ReadAllText(openFileDialog.FileName);
                var ext = Path.GetExtension(openFileDialog.FileName);

                var stream = new MemoryStream(Encoding.Default.GetBytes(txt));

                if (ext.ToLower() == ".rtf")
                {
                    richTextBox1.Selection.Load(stream, DataFormats.Rtf);
                }
                if (ext.ToLower() == ".txt")
                {
                    richTextBox1.Selection.Load(stream, DataFormats.Text);
                }

                mn_Import.IsEnabled = true;
            }
        }
Exemplo n.º 2
0
        public void Lg()
        {
            var log      = new Lg(new Number(10));
            var expected = new Number(1);

            SimpleTest(log, expected);
        }
Exemplo n.º 3
0
        public void ExecuteTest2()
        {
            var complex = new Complex(2, 3);
            var exp     = new Lg(new ComplexNumber(complex));

            Assert.Equal(Complex.Log10(complex), exp.Execute());
        }
Exemplo n.º 4
0
        public void CloneTest()
        {
            var exp   = new Lg(new Number(0));
            var clone = exp.Clone();

            Assert.Equal(exp, clone);
        }
Exemplo n.º 5
0
        public void SimpleTest(double arg, double expected)
        {
            Lg     calc   = new Lg();
            double result = calc.Action(arg);

            Assert.AreEqual(expected, result);
        }
Exemplo n.º 6
0
        private async void ButtonImport_Click(object sender, RoutedEventArgs e)
        {
            //GetSzablon
            btnsave.IsEnabled = false;
            Lg.Clear();
            //
            dg1.ItemsSource = null;
            dg1.Items.Clear();
            dg1.Items.Refresh();
            MessageBox.Show("Proszę czekać...");

            try
            {
                var tmpItems = JsonUtils.LoadJsonFile <List <SzablonItem> >(@"Template.dat");
                if (tmpItems is null)
                {
                    MessageBox.Show("brak pliku Template.dat");
                    return;
                }

                tmpItems = tmpItems.Where(p => p.Import).ToList();
                var textRange     = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd);
                var importService = new GeoDataImportService(_progressService);
                var points        = await importService.Import(tmpItems, textRange.Text);

                dg1.ItemsSource = points;
                MessageBox.Show("Zadanie wykonane");
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }
Exemplo n.º 7
0
        public void Calculate(double input, double output)
        {
            var calculator = new Lg();
            var testResult = calculator.Calculate(input);
            var result     = output;

            Assert.AreEqual(testResult, result);
        }
Exemplo n.º 8
0
        public void MergeFrom(Event other)
        {
            if (other == null)
            {
                return;
            }
            if (other.Created != 0L)
            {
                Created = other.Created;
            }
            if (other.Source.Length != 0)
            {
                Source = other.Source;
            }
            if (other.Instance.Length != 0)
            {
                Instance = other.Instance;
            }
            switch (other.MsgCase)
            {
            case MsgOneofCase.Ka:
                if (Ka == null)
                {
                    Ka = new global::Monik.Common.KeepAlive();
                }
                Ka.MergeFrom(other.Ka);
                break;

            case MsgOneofCase.Lg:
                if (Lg == null)
                {
                    Lg = new global::Monik.Common.Log();
                }
                Lg.MergeFrom(other.Lg);
                break;

            case MsgOneofCase.Pc:
                if (Pc == null)
                {
                    Pc = new global::Monik.Common.PerfCounter();
                }
                Pc.MergeFrom(other.Pc);
                break;

            case MsgOneofCase.Mc:
                if (Mc == null)
                {
                    Mc = new global::Monik.Common.Metric();
                }
                Mc.MergeFrom(other.Mc);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
Exemplo n.º 9
0
        private IQueryable <Project> QueryProjectsExportViewableByUser(UserSessionModel user, ProjectExportParameter exportParam = null)
        {
            IQueryable <Project> query;

            if (user == null)
            {
                query = this.Projects;
            }
            else
            {
                // Does user have rights to see projects in his/her own group ?
                bool inclusive = user.HasAccess(SystemAccessEnum.ViewProjectsInGroup);

                query = from project in this.Projects
                        join owner in this.Context.Users on project.OwnerId equals owner.UserId
                        join groups in this.QueryGroupsViewableBelowByGroupId(user.GroupId.Value, inclusive) on owner.GroupId equals groups.GroupId into Lg
                        from groups in Lg.DefaultIfEmpty()

                        // Return any in group tree or the users own projects
                        where (owner.GroupId == groups.GroupId) || project.OwnerId == user.UserId
                        select project;

                // Get al projects which have been transferred
                var transfersQuery =
                    from project in this.Projects
                    join transfers in this.Context.ProjectTransfers on new { user.UserId, project.ProjectId } equals new { transfers.UserId, transfers.ProjectId }
                select project;

                // join the two
                query = query.Union(transfersQuery);

                bool removeDeletedProjects = false;

                //if user cannot see deleted projects to start with, filter them out
                if (!user.HasAccess(SystemAccessEnum.UndeleteProject))
                {
                    removeDeletedProjects = true;
                }
                else
                {
                    //I have permission, and a search project, and I chose to NOT show deleted projects
                    if (exportParam != null && exportParam.ShowDeletedProjects == false)
                    {
                        removeDeletedProjects = true;
                    }
                }

                if (removeDeletedProjects)
                {
                    query = query.Where(p => p.Deleted == false);
                }
            }

            return(query);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Analyzes the specified expression.
        /// </summary>
        /// <param name="exp">The expression.</param>
        /// <returns>
        /// The result of analysis.
        /// </returns>
        public override IExpression Analyze(Lg exp)
        {
            if (!Helpers.HasVariable(exp, Variable))
            {
                return(new Number(0));
            }

            var ln   = new Ln(new Number(10));
            var mul1 = new Mul(exp.Argument.Clone(), ln);
            var div  = new Div(exp.Argument.Clone().Analyze(this), mul1);

            return(div);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Get Common Sync Context with errors and performance with process details
 /// </summary>
 public Ax(Sld CurrSession, f <Lst, bool> SyncSaveLogsMethod, IDictionary <Tx, Cx> BaseContexts = null)
     : base(null, true)
 {
     T      = BaseContexts;
     L      = CurrSession.N(SyncSaveLogsMethod);
     this.M = () =>
     {
         if (L != null)
         {
             L.Sv();
         }
         return(true);
     };
 }
Exemplo n.º 12
0
        /// <summary>
        /// Run Common Sync Try FuncToRunSync With Errors And Performance Logging based on CurrCodeType.
        /// Logging is saved to CustomLogToAddRecords or default static logs (_.D.L)
        /// </summary>
        public static T r <T>(this Lg CurrLog, f <T> FuncToRunSync, Cx CustomCodeType = null, Mx CustomMethodContext = null, T ReturnOnError = default)
        {
            if (FuncToRunSync == null)
            {
                return(ReturnOnError);
            }

            var t       = CustomCodeType;
            Prf PerfLog = null;
            var ef      = false;

            if (t.S != null && t.S.P == true)
            {
                PerfLog = CurrLog.P(t, CustomMethodContext);
            }

            T Result = ReturnOnError;

            if (CustomCodeType.T)
            {
                try
                {
                    Result = FuncToRunSync();
                }
                catch (Exception exc)
                {
                    if (t.S != null && t.S.L == true)
                    {
                        CurrLog.E(null, exc, t, CustomMethodContext);
                    }
                    ef = true;
                }
            }
            else
            {
                Result = FuncToRunSync();
            }

            if (t.S != null && t.S.P == true)
            {
                CurrLog.Pa(PerfLog, null, t);
            }

            if (ef)
            {
                return(ReturnOnError);
            }

            return(Result);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Get Common Async Context with errors and performance with process details
        /// </summary>
        public Ax(Sld CurrSession, f <Lst, Task <bool> > AsyncSaveLogsMethod, IDictionary <Tx, Cx> BaseContexts = null)
            : base(null, true)
        {
            T      = BaseContexts;
            L      = CurrSession.N(AsyncSaveLogsMethod);
            this.M = () =>
            {
                if (L != null)
                {
                    var r = L.Sva();
                    if (r != null)
                    {
                        var rs = r.Result;
                    }
                }

                return(true);
            };
        }
Exemplo n.º 14
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Created != 0L)
            {
                hash ^= Created.GetHashCode();
            }
            if (Source.Length != 0)
            {
                hash ^= Source.GetHashCode();
            }
            if (Instance.Length != 0)
            {
                hash ^= Instance.GetHashCode();
            }
            if (msgCase_ == MsgOneofCase.Ka)
            {
                hash ^= Ka.GetHashCode();
            }
            if (msgCase_ == MsgOneofCase.Lg)
            {
                hash ^= Lg.GetHashCode();
            }
            if (msgCase_ == MsgOneofCase.Pc)
            {
                hash ^= Pc.GetHashCode();
            }
            if (msgCase_ == MsgOneofCase.Mc)
            {
                hash ^= Mc.GetHashCode();
            }
            hash ^= (int)msgCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 15
0
    public override string ToString()
    {
        var cultureInfo   = CultureInfo.CurrentCulture;
        var listSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);

        // Initial capacity [128] is an estimate based on a sum of:
        // 72 = 6x double (twelve digits is generous for the range of values likely)
        //  4 = 4x separator characters
        var sb = new StringBuilder(128);

        sb.Append(Xs.ToString(cultureInfo));
        sb.Append(listSeparator);
        sb.Append(Sm.ToString(cultureInfo));
        sb.Append(listSeparator);
        sb.Append(Md.ToString(cultureInfo));
        sb.Append(listSeparator);
        sb.Append(Lg.ToString(cultureInfo));
        sb.Append(listSeparator);
        sb.Append(Xl.ToString(cultureInfo));
        sb.Append(listSeparator);
        sb.Append(Xxl.ToString(cultureInfo));
        return(sb.ToString());
    }
Exemplo n.º 16
0
 public virtual Expression On(Lg e) => On(e as Log);
Exemplo n.º 17
0
 /// <summary>
 /// Analyzes the specified expression.
 /// </summary>
 /// <param name="exp">The expression.</param>
 /// <returns>
 /// The result of analysis.
 /// </returns>
 /// <exception cref="System.NotSupportedException">Always.</exception>
 public virtual TResult Analyze(Lg exp)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 18
0
        public void TestLgUndefined()
        {
            var exp = new Lg(Variable.X);

            Test(exp, ResultType.Undefined);
        }
Exemplo n.º 19
0
        public void ExecuteTestException()
        {
            var exp = new Lg(new Bool(false));

            Assert.Throws <ResultIsNotSupportedException>(() => exp.Execute());
        }
Exemplo n.º 20
0
        public void TestLgNumber()
        {
            var exp = new Lg(new Number(10));

            Test(exp, ResultType.Number);
        }
Exemplo n.º 21
0
        public void ExecuteTest1()
        {
            var exp = new Lg(new Number(2));

            Assert.Equal(Math.Log10(2), exp.Execute());
        }
Exemplo n.º 22
0
 public void NegativeLgTests()
 {
     var calculator = new Lg();
     var result     = calculator.Calculate(-4);
 }
Exemplo n.º 23
0
        /// <summary>
        /// Creates an expression object from <see cref="FunctionToken"/>.
        /// </summary>
        /// <param name="token">The function token.</param>
        /// <returns>An expression.</returns>
        protected virtual IExpression CreateFunction(FunctionToken token)
        {
            IExpression exp;

            switch (token.Function)
            {
            case Functions.Add:
                exp = new Add(); break;

            case Functions.Sub:
                exp = new Sub(); break;

            case Functions.Mul:
                exp = new Mul(); break;

            case Functions.Div:
                exp = new Div(); break;

            case Functions.Pow:
                exp = new Pow(); break;

            case Functions.Absolute:
                exp = new Abs(); break;

            case Functions.Sine:
                exp = new Sin(); break;

            case Functions.Cosine:
                exp = new Cos(); break;

            case Functions.Tangent:
                exp = new Tan(); break;

            case Functions.Cotangent:
                exp = new Cot(); break;

            case Functions.Secant:
                exp = new Sec(); break;

            case Functions.Cosecant:
                exp = new Csc(); break;

            case Functions.Arcsine:
                exp = new Arcsin(); break;

            case Functions.Arccosine:
                exp = new Arccos(); break;

            case Functions.Arctangent:
                exp = new Arctan(); break;

            case Functions.Arccotangent:
                exp = new Arccot(); break;

            case Functions.Arcsecant:
                exp = new Arcsec(); break;

            case Functions.Arccosecant:
                exp = new Arccsc(); break;

            case Functions.Sqrt:
                exp = new Sqrt(); break;

            case Functions.Root:
                exp = new Root(); break;

            case Functions.Ln:
                exp = new Ln(); break;

            case Functions.Lg:
                exp = new Lg(); break;

            case Functions.Lb:
                exp = new Lb(); break;

            case Functions.Log:
                exp = new Log(); break;

            case Functions.Sineh:
                exp = new Sinh(); break;

            case Functions.Cosineh:
                exp = new Cosh(); break;

            case Functions.Tangenth:
                exp = new Tanh(); break;

            case Functions.Cotangenth:
                exp = new Coth(); break;

            case Functions.Secanth:
                exp = new Sech(); break;

            case Functions.Cosecanth:
                exp = new Csch(); break;

            case Functions.Arsineh:
                exp = new Arsinh(); break;

            case Functions.Arcosineh:
                exp = new Arcosh(); break;

            case Functions.Artangenth:
                exp = new Artanh(); break;

            case Functions.Arcotangenth:
                exp = new Arcoth(); break;

            case Functions.Arsecanth:
                exp = new Arsech(); break;

            case Functions.Arcosecanth:
                exp = new Arcsch(); break;

            case Functions.Exp:
                exp = new Exp(); break;

            case Functions.GCD:
                exp = new GCD(); break;

            case Functions.LCM:
                exp = new LCM(); break;

            case Functions.Factorial:
                exp = new Fact(); break;

            case Functions.Sum:
                exp = new Sum(); break;

            case Functions.Product:
                exp = new Product(); break;

            case Functions.Round:
                exp = new Round(); break;

            case Functions.Floor:
                exp = new Floor(); break;

            case Functions.Ceil:
                exp = new Ceil(); break;

            case Functions.Derivative:
                exp = new Derivative(); break;

            case Functions.Simplify:
                exp = new Simplify(); break;

            case Functions.Del:
                exp = new Del(); break;

            case Functions.Define:
                exp = new Define(); break;

            case Functions.Vector:
                exp = new Vector(); break;

            case Functions.Matrix:
                exp = new Matrix(); break;

            case Functions.Transpose:
                exp = new Transpose(); break;

            case Functions.Determinant:
                exp = new Determinant(); break;

            case Functions.Inverse:
                exp = new Inverse(); break;

            case Functions.If:
                exp = new If(); break;

            case Functions.For:
                exp = new For(); break;

            case Functions.While:
                exp = new While(); break;

            case Functions.Undefine:
                exp = new Undefine(); break;

            case Functions.Im:
                exp = new Im(); break;

            case Functions.Re:
                exp = new Re(); break;

            case Functions.Phase:
                exp = new Phase(); break;

            case Functions.Conjugate:
                exp = new Conjugate(); break;

            case Functions.Reciprocal:
                exp = new Reciprocal(); break;

            case Functions.Min:
                exp = new Min(); break;

            case Functions.Max:
                exp = new Max(); break;

            case Functions.Avg:
                exp = new Avg(); break;

            case Functions.Count:
                exp = new Count(); break;

            case Functions.Var:
                exp = new Var(); break;

            case Functions.Varp:
                exp = new Varp(); break;

            case Functions.Stdev:
                exp = new Stdev(); break;

            case Functions.Stdevp:
                exp = new Stdevp(); break;

            default:
                exp = null; break;
            }

            if (exp is DifferentParametersExpression diff)
            {
                diff.ParametersCount = token.CountOfParams;
            }

            return(exp);
        }
Exemplo n.º 24
0
        public void LgToStringTest()
        {
            var exp = new Lg(new Number(5));

            Assert.Equal("lg(5)", exp.ToString(commoonFormatter));
        }
Exemplo n.º 25
0
        /// <summary>
        /// Select all records from
        /// </summary>
        /// <param name="intCityIdno"></param>
        /// <param name="strtolltaxname"></param>
        /// <returns></returns>

        public IList SelectForSearch(Int32 cityid, Int32 ToCity, string strtollname, Int32 Lorry)
        {
            using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
            {
                var lst = (from CT in db.tbltollmasters
                           join sm in db.tblCityMasters on CT.city equals sm.City_Idno
                           join sm2 in db.tblCityMasters on CT.Tocity equals sm2.City_Idno into gj
                           from full in gj.DefaultIfEmpty()
                           join LT in db.LorryTypes on CT.LorryType_Idno equals LT.Id into Lg from LTG in Lg.DefaultIfEmpty()
                           select new
                {
                    TollTaxid = CT.Toll_id,
                    Cityid = CT.city,
                    Status = CT.Status,
                    CityName = sm.City_Name,
                    ToCityName = full.City_Name,
                    ToCityIdNo = full.City_Idno,
                    TollTaxName = CT.Tolltax_name,
                    Lorry_Type = LTG.Lorry_Type,
                    LorryType_Idno = CT.LorryType_Idno,
                    Ammount = CT.Amount
                }).ToList();


                if (cityid > 0)
                {
                    lst = (from l in lst where l.Cityid == cityid select l).ToList();
                }
                if (ToCity > 0)
                {
                    lst = (from l in lst where l.ToCityIdNo == ToCity select l).ToList();
                }
                if (strtollname != "")
                {
                    lst = (from I in lst where I.TollTaxName.ToLower().Contains(strtollname.ToLower()) select I).ToList();
                }
                if (Lorry > 0)
                {
                    lst = (from I in lst where I.LorryType_Idno == Lorry select I).ToList();
                }

                return(lst);
            }
        }
Exemplo n.º 26
0
        public void TestLgComplexNumber()
        {
            var exp = new Lg(new ComplexNumber(10, 10));

            Test(exp, ResultType.ComplexNumber);
        }
Exemplo n.º 27
0
        public void TestLgException()
        {
            var exp = new Lg(new Bool(false));

            TestException(exp);
        }
Exemplo n.º 28
0
        public void Zero()
        {
            Lg calc = new Lg();

            Assert.Throws <Exception>(() => calc.Action(0));
        }
Exemplo n.º 29
0
        public void Negative()
        {
            Lg calc = new Lg();

            Assert.Throws <Exception>(() => calc.Action(-9));
        }
Exemplo n.º 30
0
 /// <summary>
 /// Analyzes the specified expression.
 /// </summary>
 /// <param name="exp">The expression.</param>
 /// <returns>The result of analysis.</returns>
 public string Analyze(Lg exp)
 {
     return(ToString(exp, "lg({0})"));
 }