コード例 #1
0
ファイル: CRCSliceBy8.cs プロジェクト: matsremman/SSISMHash
        private UInt32[] MakeTable(UInt32 polynomial, int offset)
        {
            UInt32[] table = new UInt32[256];

            UInt64 c, x, rem;

            for (int i = table.GetLowerBound(0); i <= table.GetUpperBound(0); i++)
            {
                c   = ((UInt64)i) << offset;
                rem = 0;

                for (int part = 8; --part >= 0;)
                {
                    x   = c >> 56;
                    c <<= 8;

                    rem ^= x;
                    for (int j = 8; --j >= 0;)
                    {
                        rem = (rem & (0x01u)) != 0 ? polynomial ^ (rem >> 1) : (rem >> 1);
                    }
                }

                table[i] = (UInt32)rem;
            }
            return(table);
        }
コード例 #2
0
        /// <summary>
        ///   Customized container radius search which returns a list of simobject ID's in the radius.
        /// </summary>
        /// <param name="p"> </param>
        /// <param name="searchradius"> </param>
        /// <param name="searchmask"> </param>
        /// <param name="useclientcontainer"> </param>
        /// <returns> </returns>
        internal List <UInt32> ContainerRadiusSearch(Point3F p, double searchradius, UInt32 searchmask, bool useclientcontainer)
        {
            uint[] foundid = new UInt32[100];

            List <uint> lid = new List <uint>();

            Int32 countof = SafeNativeMethods.mContainerRadiusSearch(p.x, p.y, p.z, (float)searchradius, searchmask, useclientcontainer, foundid);

            if (countof > 0)
            {
                for (int i = 0; i < foundid.GetUpperBound(0); i++)
                {
                    lid.Add(foundid[i]);
                }
            }


            return(lid);
        }
コード例 #3
0
        // Removal Of Recurrences Of PriceList
        public void RemovalOfRecurrencesOfPriceList(string NameOfTable, bool Compulsorily)
        {
            //
            // Initializing Checking Command
            //
            MySqlCommand CommandOfChecking =
                new MySqlCommand(
                    "SELECT COUNT(*) FROM Service " +
                    "WHERE ((Id_Service = 9) AND NOT((Year(Date_Service) = '2010') AND (Month(Date_Service) = '08') AND " +
                    "(Day(Date_Service) = '13')))", ConnectionToBase);

            //
            ConnectionToBase.Open();
            int CountOfRows = Convert.ToInt32(CommandOfChecking.ExecuteScalar());

            ConnectionToBase.Close();
            //
            CommandOfChecking.CommandText =
                "SELECT COUNT(*) FROM Price_List AS PL " +
                "WHERE (SELECT COUNT(*) FROM Price_List AS PL2 " +
                "WHERE PL.Id_Pharmacy = PL2.Id_Pharmacy AND PL.Id_Product = PL2.Id_Product) > 1 " +
                "ORDER BY PL.Id_Pharmacy, PL.ID_Product, PL.Price;";
            //
            //ConnectionToBase.Open();
            //int CountOfRecurrences = Convert.ToInt32(CommandOfChecking.ExecuteScalar());
            //ConnectionToBase.Close();
            //
            //SELECT * FROM Pharm66.Price_List WHERE Id_Pharmacy = Id_Product
            //
            if ((CountOfRows != 1) || Compulsorily)// || (CountOfRecurrences > 0))
            {
                //
                // Formating Text Of Selection
                //
                string TextOfSelectionCommand =
                    String.Format(
                        "SELECT PL.Id_Price_List AS 'ID', PL.Id_Pharmacy AS 'ID_PH', PL.ID_Product AS 'ID_PR' " +
                        "FROM {0} AS PL " +
                        "WHERE (SELECT COUNT(*) FROM {0} AS PL2 " +
                        "WHERE PL.Id_Pharmacy = PL2.Id_Pharmacy AND PL.Id_Product = PL2.Id_Product) > 1 " +
                        "ORDER BY PL.Id_Pharmacy, PL.ID_Product, PL.Price;", NameOfTable);
                //
                // Initialize UpdatingPriceList
                //
                MySqlCommand CommandOfSelection = new MySqlCommand(TextOfSelectionCommand, ConnectionToBase);
                //
                MySqlCommand CommandOfDeleting = new MySqlCommand(
                    String.Format("DELETE FROM {0} WHERE Id_Price_list = @P1;", NameOfTable),
                    ConnectionToBase);
                CommandOfDeleting.Parameters.Add("@P1", MySqlDbType.UInt32, 0, "ID");
                //
                MySqlDataAdapter UpdatingPriceList = new MySqlDataAdapter(CommandOfSelection);
                UpdatingPriceList.DeleteCommand = CommandOfDeleting;
                //
                // Filling PriceList
                //
                DataTable PriceListForClearing = new DataTable();
                UpdatingPriceList.FillSchema(PriceListForClearing, SchemaType.Source);
                UpdatingPriceList.Fill(PriceListForClearing);
                //
                // Deleting Of Recurrences
                //
                // Getting IDs Of Drugstores
                //
                DataTable TableOfIDsOfDrugstores = new DataView(PriceListForClearing).ToTable(true, "ID_PH");
                int[]     IDsOfDrugstores        = new int[TableOfIDsOfDrugstores.Rows.Count];
                for (int i = 0; i < IDsOfDrugstores.Length; i++)
                {
                    IDsOfDrugstores[i] = Convert.ToInt32(TableOfIDsOfDrugstores.Rows[i]["ID_PH"]);
                }
                //
                // Importing Of Drugstores
                //
                DataView GettingDrugstore = new DataView(PriceListForClearing);
                for (int i = 0; i < IDsOfDrugstores.Length; i++)
                {
                    //
                    // Getting Prices Of Drugstore
                    //
                    GettingDrugstore.RowFilter = String.Format("ID_PH={0}", IDsOfDrugstores[i]);
                    DataTable PricesOfDrugstore = GettingDrugstore.ToTable("PricesOfDrugstore");
                    PricesOfDrugstore.AcceptChanges();
                    //
                    // Addition Of TMP Of ID Of Prices
                    //
                    PricesOfDrugstore.PrimaryKey = new DataColumn[1] {
                        PricesOfDrugstore.Columns["ID"]
                    };
                    //
                    // Filling ID Of Prices And ID_PR Of Products
                    //
                    UInt32[,] IDAndIDPROfPrices = new UInt32[PricesOfDrugstore.Rows.Count, 2];
                    for (int i2 = 0; i2 <= IDAndIDPROfPrices.GetUpperBound(0); i2++)
                    {
                        IDAndIDPROfPrices[i2, 0] = (UInt32)PricesOfDrugstore.Rows[i2]["ID"];
                        IDAndIDPROfPrices[i2, 1] = (UInt32)PricesOfDrugstore.Rows[i2]["ID_PR"];
                    }
                    //
                    // Search And Liquidation Of Recurrences
                    //
                    for (int i2 = 0; i2 <= IDAndIDPROfPrices.GetUpperBound(0); i2++)
                    {
                        for (int i3 = 0; i3 <= IDAndIDPROfPrices.GetUpperBound(0); i3++)
                        {
                            if ((i2 != i3) && (i2 > i3) && (IDAndIDPROfPrices[i2, 1] == IDAndIDPROfPrices[i3, 1]))
                            {
                                DataRow GetRow = PricesOfDrugstore.Rows.Find(IDAndIDPROfPrices[i3, 0]);
                                if (GetRow != null)
                                {
                                    GetRow.Delete();
                                }
                            }
                        }
                    }
                    //
                    int CountOfDeleting = 0;
                    foreach (DataRow CurRow in PricesOfDrugstore.Rows)
                    {
                        if (CurRow.RowState == DataRowState.Deleted)
                        {
                            CountOfDeleting++;
                        }
                    }
                    this.RecordingInLogFile(
                        String.Format("Удаление повторяющихся строк в таблице {0}, Повторений: {1}, Удалений: {2}",
                                      NameOfTable, PricesOfDrugstore.Rows.Count, CountOfDeleting));
                    //
                    // Clearing PriceList
                    //
                    UpdatingPriceList.Update(PricesOfDrugstore);
                }
            }
        }