public static void BenchVirtualObjects()
        {
            HighPrecisionTimer timer = new HighPrecisionTimer();
            int n = 0;

            Console.WriteLine("Start...");
            ulong ids = 1;

            timer.Start();
            do
            {
                MyClasse_B B = new MyClasse_B();
                B.Id   = ids++;
                B.Name = "Gabriel is in the floers and the camps !";
                B.Name = "Veronique had a small car !";
                if (B.Name == "Ok")
                {
                    n = n * 2 / 2;
                }
                B.A = 65;
                n++;
                if (timer.Milliseconds > 1000)
                {
                    Console.WriteLine("Iterations : " + n);
                    break;
                }
            } while (true);
            Console.WriteLine("*********************************** !");
            timer.Stop();

            n = 0;
            timer.Reset(true);
            do
            {
                MyClasse_B B2 = new MyClasse_B();
                B2.Id   = ids++;
                B2.Name = "Le monde est jolie ! Le monde il est beau ! Tout le monde s'aime !";
                B2.A    = 65;
                //Repository<ulong>.Add(B2);
                n++;
                if (timer.Milliseconds > 1000)
                {
                    Console.WriteLine("Iterations : " + n);
                    break;
                }
            } while (true);
            timer.Stop();

            Console.WriteLine("Block Count : " + MemoryAllocator.BlockCount);
            Console.WriteLine("Efficiency Ratio : " + MemoryAllocator.EfficiencyRatio);
            Console.WriteLine("Segment Count : " + MemoryAllocator.SegmentCount);
            Console.WriteLine("Total Allocated Memory : " + MemoryAllocator.TotalAllocatedMemory);
        }
        public static unsafe void TestRepositoryDictionnary()
        {
            Dictionary <VOId, IntPtr> rep   = new Dictionary <VOId, IntPtr>();
            HighPrecisionTimer        timer = new HighPrecisionTimer();
            int n = 0;

            Console.WriteLine("Start...");
            ulong      ids = 1;
            MyClasse_B B   = new MyClasse_B();

            B.Name = "Is it ok ?";
            timer.Start();
            do
            {
                ids++;
                B.Id = ids;
                rep.Add(B.Id, (IntPtr)B.Data);
                n++;
                if (timer.Milliseconds > 1000)
                {
                    Console.WriteLine("Iterations : " + n);
                    break;
                }
            } while (true);
            Console.WriteLine("*********************************** !");
            timer.Stop();
        }
Exemplo n.º 3
0
        private void btnGo_Click(object sender, EventArgs e)
        {
            // perform the search on each of the checked indexes

            try {
                this.Cursor = Cursors.WaitCursor;

                List <string> indexNames = new List <string>();
                foreach (string name in clbIndexes.CheckedItems)
                {
                    indexNames.Add(name);
                }

                StringBuilder sb    = new StringBuilder();
                int           count = 0;
                using (HighPrecisionTimer timer = new HighPrecisionTimer("timer", true)) {
                    foreach (int accessionID in performSearch(txtSearch.Text, chkIgnoreCase.Checked, chkMatchAll.Checked, indexNames, "Accessions"))
                    {
                        sb.AppendLine(accessionID.ToString());
                        count++;
                    }
                    timer.Stop();
                    txtAccessions.Text     = sb.ToString();
                    lblAccessions.Text     = "Accessions - " + count.ToString("G");
                    lblAccessionsTime.Text = "Search Time: " + timer.ElapsedMilliseconds.ToString("##,###.000") + " ms";
                }

                sb    = new StringBuilder();
                count = 0;
                using (HighPrecisionTimer timer = new HighPrecisionTimer("timer", true)) {
                    foreach (int inventoryID in performSearch(txtSearch.Text, chkIgnoreCase.Checked, chkMatchAll.Checked, indexNames, "Inventory"))
                    {
                        sb.AppendLine(inventoryID.ToString());
                        count++;
                    }
                    timer.Stop();
                    txtInventory.Text     = sb.ToString();
                    lblInventory.Text     = "Inventory - " + count.ToString("G");
                    lblInventoryTime.Text = "Search Time: " + timer.ElapsedMilliseconds.ToString("##,###.000") + " ms";
                }

                sb    = new StringBuilder();
                count = 0;
                using (HighPrecisionTimer timer = new HighPrecisionTimer("timer", true)) {
                    foreach (int orderID in performSearch(txtSearch.Text, chkIgnoreCase.Checked, chkMatchAll.Checked, indexNames, "Orders"))
                    {
                        sb.AppendLine(orderID.ToString());
                        count++;
                    }
                    txtOrders.Text     = sb.ToString();
                    lblOrders.Text     = "Orders - " + count.ToString("G");
                    lblOrdersTime.Text = "Search Time: " + timer.ElapsedMilliseconds.ToString("##,###.000") + " ms";
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            } finally {
                this.Cursor = Cursors.Default;
            }
        }
        public static unsafe void TestRepository()
        {
            VirtualObjectRepository <VOId> rep   = new VirtualObjectRepository <VOId>();
            HighPrecisionTimer             timer = new HighPrecisionTimer();
            int n = 0;

            Console.WriteLine("Start...");
            ulong ids = 0;
            int   cnt = 0;

            timer.Start();
            do
            {
                MyClasse_B B = new MyClasse_B();
                B.City = "Lyon : one of the beutufillest city of France !";
                B.Id   = ids++;
                rep.Add(B);
                n++;
                if (timer.Milliseconds > 10000)
                {
                    Console.WriteLine("Iterations : " + n);
                    cnt = n;
                    break;
                }
            } while (true);

            n = 0;
            Random r = new Random();

            timer.Reset(true);
            do
            {
                ids = (ulong)r.Next(cnt - 1);
                var obj = rep.Get(new VOId(ids));
                n++;
                if (timer.Milliseconds > 10000)
                {
                    Console.WriteLine("Iterations : " + n);
                    break;
                }
            } while (true);

            Console.WriteLine("*********************************** !");
            timer.Stop();
        }
Exemplo n.º 5
0
 void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     _timer.Stop();
     updateTimer();
     _clockTimer.Stop();
     if (e.Error != null)
     {
         string txt = "Fatal error occured: " + e.Error.Message + ".";
         lbProgress.Items.Add(txt);
         lbProgress.SelectedIndex = lbProgress.Items.Count - 1;
         lblStatus.Text           = txt;
         MessageBox.Show(txt);
     }
     else
     {
         TimeSpan ts      = TimeSpan.FromSeconds(_timer.ElapsedSeconds);
         string   elapsed = ts.Hours + "h " + ts.Minutes.ToString("00") + "m " + ts.Seconds.ToString("00") + "s " + ts.Milliseconds.ToString("000") + "ms ";
         lbProgress.Items.Add("Operation completed in " + elapsed);
         lbProgress.SelectedIndex = lbProgress.Items.Count - 1;
     }
     Cursor = Cursors.Default;
 }
Exemplo n.º 6
0
        public string CopyDataFromFiles(string inputDirectory, List <TableInfo> allTables, bool dryRun, bool onlyRequiredData)
        {
            using (HighPrecisionTimer hptImport = new HighPrecisionTimer("import", true)) {
                if (onlyRequiredData)
                {
                    var tn = this.TableName.ToLower();
                    // %CABEXE% n %GG%\gringlobal.database.setup\system_data.cab %RAWDATA%\sys_*.* + %RAWDATA%\cooperator*.* + %RAWDATA%\app_*.* + %RAWDATA%\web_user.* + %RAWDATA%\web_user_preference.* + %RAWDATA%\web_cooperator.* + %RAWDATA%\site.* + %RAWDATA%\region*.* + %RAWDATA%\geo*.* + %RAWDATA%\code*.*

                    if (tn.StartsWith("sys_") ||
                        tn.StartsWith("cooperator") ||
                        tn == "app_resource" ||
                        tn == "app_setting" ||
                        tn == "web_user" ||
                        tn == "web_user_preference" ||
                        tn.StartsWith("web_cooperator") ||
                        tn == "site" ||
                        tn.StartsWith("region") ||
                        tn.StartsWith("geo") ||
                        tn.StartsWith("code"))
                    {
                        // this is a system-required table, ok to include
                    }
                    else
                    {
                        // not required, exclude.
                        return("");
                    }
                }

                var output = bulkLoad(inputDirectory, allTables, dryRun);
                showProgress(getDisplayMember("CopyDataFromFiles{total}", "Total import time for {0}: {1}", TableName, Toolkit.FormatTimeElapsed(((int)hptImport.Stop()) / 1000)), 0, 0);
                return(output);
            }
        }
Exemplo n.º 7
0
        void doSearch(string advanceQry)
        {
            try
            {
                using (HighPrecisionTimer hpt = new HighPrecisionTimer("timer", true))
                {
                    List <DataTable> tables = new List <DataTable>();

                    int limit = Toolkit.ToInt32(lim.SelectedValue, 0);

                    string query = "";
                    if (ml.Checked)
                    {
                        query = q2.Text;
                    }
                    else
                    {
                        query = q.Text;
                    }

                    q.Text = q2.Text = query;

                    string sDv           = "";
                    string advancedQuery = "";
                    if (advanceQry == "")
                    {
                        advancedQuery = getAdvancedQuery();
                    }
                    else
                    {
                        advancedQuery = advanceQry;
                    }
                    var searchString = query;
                    query = query + advancedQuery;
                    string op = ma.Checked ? " and " : " or ";
                    if (query.Length >= op.Length)
                    {
                        if (query.Substring(0, op.Length) == op)
                        {
                            query = query.Substring(op.Length, query.Length - op.Length);
                        }
                    }

                    //if (ed.Checked && query != "")
                    //    query = query + " AND (@inventory.is_distributable = 'Y' and @inventory.is_available = 'Y')";

                    if (query == "")
                    {
                        Master.ShowError(Page.GetDisplayMember("Search", "doSearch{noCriteria}", "Please enter search string or other search criteria and try again."));
                    }
                    else
                    {
                        var searchIndexes = Toolkit.GetSetting("WebSearchableIndexes", "accession, accession_name, taxonomy_species, inventory, accession_source, cooperator");

                        DataSet ds = null;
                        using (var sd = new SecureData(true, UserManager.GetLoginToken(true)))
                        {
                            //ds = sd.Search(query, ic.Checked, ma.Checked, searchIndexes, "accession", 0, limit, 0, 0, view.SelectedValue, "passthru=always;OrMultipleLines=" + (ml.Checked ? "true" : "false"), null, null);
                            if (exp.Checked)
                            {
                                sDv = "web_search_overview_export";
                            }
                            else
                            {
                                sDv = view.SelectedValue;
                            }

                            //if (ed.Checked)
                            //    ds = sd.Search(query, ic.Checked, ma.Checked, searchIndexes, "accession", 0, 0, 0, 0, "", "passthru=nonindexedorcomparison;OrMultipleLines=" + (ml.Checked ? "true" : "false"), null, null);
                            //else
                            //    ds = sd.Search(query, ic.Checked, ma.Checked, searchIndexes, "accession", 0, limit, 0, 0, sDv, "passthru=nonindexedorcomparison;OrMultipleLines=" + (ml.Checked ? "true" : "false"), null, null);
                            query = query + " and @accession.is_web_visible = 'Y' ";
                            query = Utils.Sanitize2(query);

                            ds = sd.Search(query, ic.Checked, ma.Checked, searchIndexes, "accession", 0, limit, 0, 0, sDv, "passthru=nonindexedorcomparison;OrMultipleLines=" + (ml.Checked ? "true" : "false"), null, null);

                            var dtError = ds.Tables["ExceptionTable"];
                            if (dtError != null && dtError.Rows.Count > 0)
                            {
                                if (dtError.Rows[0]["Message"].ToString().ToLower().StartsWith("bad search string"))
                                {
                                    Master.ShowError(Page.GetDisplayMember("Search", "doSearch{invalidquery}", "Invalid query.  Please alter your criteria and try again."));
                                }
                                else
                                {
                                    var type = dtError.Rows[0]["ExceptionType"].ToString().ToLower();
                                    if (type.Contains("endpointnotfoundexception"))
                                    {
                                        throw new InvalidOperationException(dtError.Rows[0]["Message"].ToString());
                                    }
                                    else
                                    {
                                        Master.ShowError(dtError.Rows[0]["Message"].ToString());
                                    }
                                }
                            }

                            /*
                             * else
                             * {
                             *  if (ed.Checked)
                             *  {
                             *      List<int> IDs = new List<int>();
                             *      int id;
                             *      if (ds != null)
                             *      {
                             *          foreach (DataRow dr in ds.Tables["SearchResult"].Rows)
                             *          {
                             *              if (int.TryParse(dr[0].ToString(), out id))
                             *                  IDs.Add(id);
                             *          }
                             *      }
                             *
                             *      DataTable dtID = null;
                             *      List<int> IDa = new List<int>();
                             *      using (var dm = DataManager.Create(sd.DataConnectionSpec))
                             *      {
                             *          dtID = dm.Read("select distinct accession_id from inventory where is_distributable =  'Y' and is_available = 'Y'");
                             *          if (dtID != null)
                             *          {
                             *              foreach (DataRow dr in dtID.Rows)
                             *              {
                             *                  if (int.TryParse(dr[0].ToString(), out id))
                             *                      IDa.Add(id);
                             *              }
                             *          }
                             *      }
                             *
                             *      List<int> IDavail = IDs.Intersect(IDa).ToList();
                             *
                             *      if (limit < IDavail.Count)
                             *          IDavail = IDavail.GetRange(0, limit);
                             *
                             *      ds = sd.GetData(sDv, ":idlist=" + string.Join(",", IDavail.Select(n => n.ToString()).ToArray()), 0, 0, "");
                             *  }
                             * } */
                        }
                        hpt.Stop();

                        //TimeSpan ts = TimeSpan.FromMilliseconds(hpt.ElapsedMilliseconds);
                        //string elapsed = ts.Seconds.ToString("00") + "." + ts.Milliseconds.ToString("000");

                        // lblTimer.Text = "Search time: " + elapsed + " seconds";

                        DataTable dt = ds.Tables[sDv];
                        if (exp.Checked)
                        {
                            pnlSearchResults.Visible = false;
                            if (dt == null)
                            {
                                Master.ShowError(Page.GetDisplayMember("Search", "doSearch{errorout}", "Query limit exceeded capacity.  Please reduce your return accessions number and try again."));
                            }
                            else
                            {
                                Toolkit.OutputData(dt, Response, "csv", false, true);
                                //exportToExcel(dt);
                            }
                        }
                        else
                        {
                            pnlSearchResults.Visible = true;
                            //if (rs.SelectedValue.Contains("obs")) {
                            //    // special case: obs data is stored row-wise,
                            //    //               we need it column-wise
                            //    // need to pivot by the 'trait_value' column

                            //    dt = dt.transform(new string[] { "accession_id", "pi_number" }, "trait_name", null, "trait_value");

                            //}

                            if (dt == null || dt.Rows.Count == 0)
                            {
                                pnlSearchResultsHeader.Visible = false;
                                ggPivotView.DataSource         = dt;
                                ggPivotView.DataBind();
                            }
                            else
                            {
                                pnlSearchResultsHeader.Visible = true;
                                ggPivotView.DataSource         = dt;
                                ggPivotView.DataBind();
                            }
                            var display = "<b>Query Criteria:</b><br /> " + "&nbsp; &nbsp; &nbsp;Search String: " + searchString + "<br />" + getAdvancedQueryDisplay();
                            Master.ShowMore(display);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                pnlSearch.Visible     = false;
                pnlSearchDown.Visible = true;
                if (Page.User.IsInRole("Admins"))
                {
                    pnlError.Visible = true;
                    SearchError      = ex.ToString();
                }
                else
                {
                    pnlError.Visible = false;
                }
            }
        }