当前位置: 首页>>代码示例>>C#>>正文


C# Hashtable.ContainsValue方法代码示例

本文整理汇总了C#中System.Collections.Hashtable.ContainsValue方法的典型用法代码示例。如果您正苦于以下问题:C# Hashtable.ContainsValue方法的具体用法?C# Hashtable.ContainsValue怎么用?C# Hashtable.ContainsValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.Hashtable的用法示例。


在下文中一共展示了Hashtable.ContainsValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestCtorDictionarySingle

        public void TestCtorDictionarySingle()
        {
            // No exception
            var hash = new Hashtable(new Hashtable(), 1f);
            // No exception
            hash = new Hashtable(new Hashtable(new Hashtable(new Hashtable(new Hashtable(new Hashtable()), 1f), 1f), 1f), 1f);

            // []test to see if elements really get copied from old dictionary to new hashtable
            Hashtable tempHash = new Hashtable();
            // this for assumes that MinValue is a negative!
            for (long i = long.MinValue; i < long.MinValue + 100; i++)
            {
                tempHash.Add(i, i);
            }

            hash = new Hashtable(tempHash, 1f);

            // make sure that new hashtable has the elements in it that old hashtable had
            for (long i = long.MinValue; i < long.MinValue + 100; i++)
            {
                Assert.True(hash.ContainsKey(i));
                Assert.True(hash.ContainsValue(i));
            }

            //[]make sure that there are no connections with the old and the new hashtable
            tempHash.Clear();
            for (long i = long.MinValue; i < long.MinValue + 100; i++)
            {
                Assert.True(hash.ContainsKey(i));
                Assert.True(hash.ContainsValue(i));
            }
        }
开发者ID:gitter-badger,项目名称:corefx,代码行数:32,代码来源:CtorTests.cs

示例2: TestAddBasic

        public void TestAddBasic()
        {
            Hashtable ht = null;
            string[] keys = { "key_0", "key_1"};
            string[] values = { "val_0", "val_1" };

            var k1 = new StringBuilder(keys[0]);
            var k2 = new StringBuilder(keys[1]);
            var v1 = new StringBuilder(values[0]);
            var v2 = new StringBuilder(values[1]);

            ht = new Hashtable();
            ht.Add(k1, v1);
            ht.Add(k2, v2);

            Assert.True(ht.ContainsKey(k2));
            Assert.True(ht.ContainsValue(v2));

            ICollection allkeys = ht.Keys;
            Assert.Equal(allkeys.Count, ht.Count);

            IEnumerator allkeysEnum = allkeys.GetEnumerator();
            int index = 0;
            string[] ary = new string[2];
            while (allkeysEnum.MoveNext())
            {
                ary[index++] = allkeysEnum.Current.ToString();
            }

            // Not necessary the same order
            if (keys[0] == ary[0])
            {
                Assert.Equal(keys[1], ary[1]);
            }
            else
            {
                Assert.Equal(keys[0], ary[1]);
            }

            ICollection allvalues = ht.Values;
            Assert.Equal(allvalues.Count, ht.Count);

            IEnumerator allvaluesEnum = allvalues.GetEnumerator();
            index = 0;
            while (allvaluesEnum.MoveNext())
            {
                ary[index++] = (string)allvaluesEnum.Current.ToString();
            }

            if (values[0] == ary[0])
            {
                Assert.Equal(values[1], ary[1]);
            }
            else
            {
                Assert.Equal(values[0], ary[1]);
            }
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:58,代码来源:AddTests.cs

示例3: TestClearBasic

        public void TestClearBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);
            Hashtable ht1 = null;
            string s1 = null;
            string s2 = null;

            int i = 0;
            ht1 = new Hashtable(); //default constructor
            ht1.Clear();

            Assert.Equal(0, ht1.Count);

            // add 100 key-val pairs
            ht1 = new Hashtable();

            for (i = 0; i < 100; i++)
            {
                sblMsg = new StringBuilder(99);
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg = new StringBuilder(99);
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                ht1.Add(s1, s2);
            }

            Assert.Equal(100, ht1.Count);
            ht1.Clear();

            Assert.Equal(0, ht1.Count);

            //[]we will make a token call for some important methods to make sure that this is indeed clear
            s1 = "key_0";
            Assert.False(ht1.ContainsKey(s1));

            s1 = "val_0";
            Assert.False(ht1.ContainsValue(s1));

            //[]repeated clears of the HT. Nothing should happen		

            for (i = 0; i < 100; i++)
            {
                ht1.Clear();

                Assert.Equal(0, ht1.Count);
            }
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:52,代码来源:ClearTests.cs

示例4: CbbUrl_DropDown

 private void CbbUrl_DropDown(object sender, EventArgs e)
 {
     Hashtable ht = new Hashtable();
     for (int i = 0; i < CbbUrl.Items.Count; i++)
     {
         if (!ht.ContainsValue(CbbUrl.Items[i].ToString()))
         {
             ht.Add(i, CbbUrl.Items[i].ToString());
         }
     }
     this.CbbUrl.Items.Clear();
     foreach (DictionaryEntry de in ht)
     {
         CbbUrl.Items.Add(de.Value);
     }
 }
开发者ID:97world,项目名称:97world_UpYun,代码行数:16,代码来源:UrlBar.cs

示例5: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     Peerfx.External_APIs.CurrencyCloud cc = new External_APIs.CurrencyCloud();
     DataTable dttemp = Peerfx_DB.SPs.ViewInfoFeeTypesAll().GetDataSet().Tables[0];
     Hashtable hstemp = new Hashtable();
     foreach (DataRow dr in dttemp.Rows){
         int currency1 = Convert.ToInt32(dr["currency1"]);
         int currency2 = Convert.ToInt32(dr["currency2"]);
         hstemp = cc.Exchange_Rate_ccy_pair(currency1, currency2);
         if (!hstemp.ContainsValue("error"))
         {
             decimal rate = Convert.ToDecimal(hstemp["market_price"]);
             Peerfx_DB.SPs.UpdateInfoFeeTypesExchangeRate(currency1, currency2, rate).Execute();
         }
     }
 }
开发者ID:Lornestar,项目名称:pfx,代码行数:16,代码来源:UpdateCurrencyCloudRates.aspx.cs

示例6: Main

        static void Main(string[] args)
        {
            Hashtable aHashtable = new Hashtable();

            aHashtable.Add(101,101001);
            aHashtable.Add("Key","Value");
            aHashtable.Add(110,"Hello");
            aHashtable.Add("BITM",201);

            Console.WriteLine(aHashtable.ContainsValue("Value"));
            Console.WriteLine(aHashtable.ContainsKey(111));
            Console.WriteLine(aHashtable.Contains(110));

            Console.WriteLine(aHashtable[110]);

            Console.ReadKey();
        }
开发者ID:SyedArifulIslamEmon,项目名称:ConsolApp,代码行数:17,代码来源:Program.cs

示例7: getRandomNum

 public static string getRandomNum()
 {
     Hashtable hashtable = new Hashtable();
     Random rm = new Random();
     StringBuilder bf = new StringBuilder();
     int RmNum = 10;
     for (int i = 0; hashtable.Count < RmNum; i++)
     {
         int nValue = rm.Next(33);
         if (!hashtable.ContainsValue(nValue) && nValue != 0)
         {
             hashtable.Add(nValue, nValue);
             bf.Append(nValue.ToString());
         }
     }
     return bf.ToString();
 }
开发者ID:rsdgjb,项目名称:ScanApplication,代码行数:17,代码来源:RandomUtil.cs

示例8: Main

        static void Main(string[] args)
        {
            var hashTbl = new Hashtable();

            hashTbl.Add("Shravan", 26);
            hashTbl["Pranav"] = 62;

            bool shravanIsKnown = hashTbl.ContainsKey("Shravan");
            Console.WriteLine(shravanIsKnown);
            bool someIsAged62 = hashTbl.ContainsValue(62);
            Console.WriteLine(someIsAged62);
            
            foreach (string name in hashTbl.Keys)
                Console.WriteLine("Age of {0} is {1}", name, hashTbl[name]);

            hashTbl.Remove("Shravan");

            foreach (string name in hashTbl.Keys)
                Console.WriteLine("Age of {0} is {1}", name, hashTbl[name]);

            Console.ReadLine();
        }
开发者ID:monishabhattacharya,项目名称:CSharp,代码行数:22,代码来源:Program.cs

示例9: Main

        static void Main(string[] args)
        {

            //hashtable similar to dictionary but it can store keyvalue objects of varying types.

            Hashtable grades = new Hashtable();
            grades.Add("C#", "A");
            grades.Add("Java", 74.0f);
            grades.Add("ASP.NET", "A");
            DisplayAllValues(grades);

            if (grades.ContainsKey("C")) //check for object by key
                Console.WriteLine("A C# Course Exists");
            if (grades.ContainsValue(74.0f))  //check for object by value
                Console.WriteLine("A course has a grade that is 74.0f");
            grades.Remove("Java"); //remove object by key
            if (!grades.Contains("Java"))
                Console.WriteLine("The Java course no longer exists");
            grades.Clear();
            DisplayAllValues(grades);
            Console.ReadLine();

        }
开发者ID:zaekeon,项目名称:csharp2,代码行数:23,代码来源:Program.cs

示例10: InitSodata2

        private void InitSodata2()
        {
            string sid = selectid;

            if (sid == "")
                return;

            Hashtable hs1 = new Hashtable();
            Hashtable hs3 = new Hashtable();

            substation suub = new substation();
            suub.UID = sid;
            suub.EleName = leixing;
            IList<substation> listsubstation = Services.BaseService.GetList<substation>("SelectsubstationByPowerID1", sid);
            foreach (substation s1 in listsubstation)
            {
                hs1.Add(Guid.NewGuid().ToString(), s1.UID);
            }

            IList<Substation_Info> ll2 = Services.BaseService.GetList<Substation_Info>("SelectSubstation_InfoByFlag", sid);
            foreach (Substation_Info ps in ll2)
            {
                hs3.Add(Guid.NewGuid().ToString(), ps.Code);
            }

            foreach (Substation_Info p2 in ll2)
            {

                if (p2.Code != "" && !hs1.ContainsValue(p2.Code))
                {
                    //ɾ��
                    Services.BaseService.Delete<Substation_Info>(p2);
                }
            }

            foreach (substation s2 in listsubstation)
            {
                if (!hs3.ContainsValue(s2.UID) && s2.ObligateField1 != "")
                {
                    //���
                    try
                    {
                        Substation_Info substation1 = new Substation_Info();
                        substation1.L1 = int.Parse(s2.ObligateField1);
                        substation1.Title = s2.EleName;
                        substation1.Code = s2.UID;
                        substation1.Flag = sid;

                        try
                        {
                            substation1.L1 = int.Parse(s2.ObligateField1);

                        }
                        catch { }

                        try
                        {
                            substation1.L10 = double.Parse(s2.ObligateField2);
                            if (substation1.L10==null&&s2.Number!=0)
                            {
                                substation1.L10 = Convert.ToDouble(s2.Burthen) / Convert.ToDouble(s2.Number) * 100;
                            }
                        }
                        catch { }

                        try
                        {
                            if (s2.Number != 0)
                            {
                                substation1.L2 = (double)(s2.Number);
                            }

                        }
                        catch { }
                         try
                        {
                          substation1.L3=Convert.ToInt32(s2.ObligateField7);
                        }
                        catch
                        {

                        }
                        try
                        {
                            substation1.L9 = Convert.ToDouble(s2.Burthen);
                        }
                        catch { }
                        substation1.AreaID = Itop.Client.MIS.ProgUID;
                        Services.BaseService.Create<Substation_Info>(substation1);
                    }
                    catch { }

                }
            }
        }
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:95,代码来源:FrmLayoutSubstationInfo.cs

示例11: Import

        /// <summary>
        /// DataType Import - taken from the core 
        /// 
        /// the core doesn't pass username, so fails on loading
        /// here we just pass usere User(0) - so we can work)
        /// </summary>
        /// <param name="xmlData"></param>
        /// <returns></returns>
        public static DataTypeDefinition Import(XmlNode xmlData, User u)
        {
            if (xmlData != null)
            {
                string _name = xmlData.Attributes["Name"].Value;
                string _id = xmlData.Attributes["Id"].Value;
                string _def = xmlData.Attributes["Definition"].Value;

                DataTypeDefinition dtd;

                if (CMSNode.IsNode(new Guid(_def)))
                {
                    dtd = DataTypeDefinition.GetDataTypeDefinition(new Guid(_def));
                }
                else
                {

                    if (u == null)
                        u = global::umbraco.BusinessLogic.User.GetUser(0);

                    global::umbraco.cms.businesslogic.datatype.controls.Factory f = new global::umbraco.cms.businesslogic.datatype.controls.Factory();

                    dtd = DataTypeDefinition.MakeNew(u, _name, new Guid(_def));
                    var dataType = f.DataType(new Guid(_id));
                    if (dataType == null)
                        throw new NullReferenceException("Could not resolve a data type with id " + _id);



                    dtd.DataType = dataType;
                    dtd.Save();
                }

                //
                // PREVALUES - HELL :: num 4532
                // 
                // Here we are attempting to add new prevalues to a DataType, and remove old ones.
                // between umbraco installs the IDs will change. we are not trying to match them,
                // we are just trying to match, based on value - problem being, if you change 
                // a value's value then this code would think it's a new ID, delete the old one
                // and create a new one - as we are syncing from a dev point of view we are
                // going to do this for now...
                //

                System.Collections.SortedList prevals = PreValues.GetPreValues(dtd.Id);
                Hashtable oldvals = new Hashtable();
                foreach (DictionaryEntry v in prevals)
                {
                    if ((PreValue)v.Value != null)
                    // if (!String.IsNullOrEmpty(((PreValue)v.Value).Value.ToString()))
                    {
                        oldvals.Add(((PreValue)v.Value).Id, ((PreValue)v.Value).Value.ToString());
                    }
                }

                Hashtable newvals = new Hashtable();
                foreach (XmlNode xmlPv in xmlData.SelectNodes("PreValues/PreValue"))
                {
                    XmlAttribute val = xmlPv.Attributes["Value"];

                    if (val != null)
                    {
                        // add new values only - because if we mess with old ones. it all goes pete tong..
                        if ((val.Value != null) && (!oldvals.ContainsValue(val.Value)))
                        {
                            Log.Add(LogTypes.Debug, 0, string.Format("Adding Prevalue [{0}]", val.Value));
                            PreValue p = new PreValue(0, 0, val.Value);
                            p.DataTypeId = dtd.Id;
                            p.Save();
                        }

                        newvals.Add(xmlPv.Attributes["Id"], val.Value);
                    }
                }


                // ok now delete any values that have gone missing between syncs..

                if (!uSyncSettings.Preserve || !uSyncSettings.PreservedPreValueDataTypes.Contains(_id))
                {
                    foreach (DictionaryEntry oldval in oldvals)
                    {
                        if (!newvals.ContainsValue(oldval.Value))
                        {
                            PreValue o = new PreValue((int)oldval.Key);
                            Log.Add(LogTypes.Debug, 0, string.Format("In {0} Deleting prevalue [{1}]", dtd.Text, oldval.Value));
                            o.Delete();
                        }
                    }
                }
                return dtd;
            }
//.........这里部分代码省略.........
开发者ID:jonnyirwin,项目名称:jumps.umbraco.usync,代码行数:101,代码来源:SyncDataType.cs

示例12: BindList

        private void BindList()
        {
            string sWhereString = "";

            // was there a search where passed in?
            sWhereString = (string)ui.GetQuerystringValue("status", typeof(string));
            sWhereString.Replace(";", "");

            Hashtable htValidValues = new Hashtable();
            htValidValues.Add("value1", "processing");
            htValidValues.Add("value2", "submitted");
            htValidValues.Add("value3", "pending");
            htValidValues.Add("value4", "aborting");
            htValidValues.Add("value5", "queued");
            htValidValues.Add("value7", "completed");
            htValidValues.Add("value8", "cancelled");
            htValidValues.Add("value9", "error");
            htValidValues.Add("value10", "staged");

            string sSearchString = " where (1=1) ";
            if (txtSearch.Text.Length > 0)
            {
                sSearchString += " and (ti.task_instance like '%" + txtSearch.Text.Replace("'", "''") + "%' " +
                                "or ti.task_id like '%" + txtSearch.Text.Replace("'", "''") + "%' " +
                                "or ti.asset_id like '%" + txtSearch.Text.Replace("'", "''") + "%' " +
                                "or ti.pid like '%" + txtSearch.Text.Replace("'", "''") + "%' " +
                                "or ti.task_status like '%" + txtSearch.Text.Replace("'", "''") + "%' " +
                                "or ar.hostname like '%" + txtSearch.Text.Replace("'", "''") + "%' " +
                                "or a.asset_name like '%" + txtSearch.Text.Replace("'", "''") + "%' " +
                                "or t.task_name like '%" + txtSearch.Text.Replace("'", "''") + "%' " +
                                "or t.version like '%" + txtSearch.Text.Replace("'", "''") + "%' " +
                                "or u.username like '%" + txtSearch.Text.Replace("'", "''") + "%' " +
                                "or u.full_name like '%" + txtSearch.Text.Replace("'", "''") + "%' " +
                                "or d.ecosystem_name like '%" + txtSearch.Text.Replace("'", "''") + "%') ";
            }

            if (txtStartDate.Text.Length == 0)
                txtStartDate.Text = DateTime.Now.AddDays(-30).ToShortDateString();
            //str_to_date('4/9/2011', '%m/%d/%Y')
            sSearchString += " and (submitted_dt >= str_to_date('" + txtStartDate.Text + "', '%m/%d/%Y')" +
                " or started_dt >= str_to_date('" + txtStartDate.Text + "', '%m/%d/%Y')" +
                " or completed_dt >= str_to_date('" + txtStartDate.Text + "', '%m/%d/%Y')) ";

            if (txtStopDate.Text.Length > 0)
            {
                sSearchString += " and (submitted_dt <= str_to_date('" + txtStopDate.Text + "', '%m/%d/%Y'" +
                " or started_dt <= str_to_date('" + txtStopDate.Text + "', '%m/%d/%Y'" +
                " or completed_dt <= str_to_date('" + txtStopDate.Text + "', '%m/%d/%Y') ";
            }

            if (sWhereString.Length > 0)
            {
                // to prevent sql injection dont take the where string as is, dice it up
                // and only accept valid values
                StringBuilder sb = new StringBuilder();
                string[] sWhereArray = sWhereString.Split(',');
                foreach (string part in sWhereArray)
                {
                    if (htValidValues.ContainsValue(part))
                    {
                        sb.Append("'" + part + "',");
                    }
                }

                if (sb.Length > 1) sb.Remove(sb.Length - 1, 1);

                // if after all of this, there is now string then sWhere will = " where ti.task_status in ('')
                if (sb.Length == 0)
                {
                    sWhereString = " and ti.task_status in ('')";
                }
                else
                {
                    sWhereString = " and ti.task_status in (" + sb.ToString() + ")";
                }

            }

            string sTagString = "";
            if (!ui.UserIsInRole("Developer") && !ui.UserIsInRole("Administrator"))
            {
                sTagString+= " join object_tags tt on t.original_task_id = tt.object_id" +
                    " join object_tags ut on ut.tag_name = tt.tag_name" +
                    " and ut.object_type = 1 and tt.object_type = 3" +
                    " and ut.object_id = '" + ui.GetSessionUserID() + "'";
            }

            sSQL = "select ti.task_instance, t.task_id, t.task_code, a.asset_name," +
                    " ti.pid as process_id, ti.task_status, t.task_name," +
                    " ifnull(u.full_name, '') as started_by," +
                    " t.version, u.full_name, ar.hostname as ce_name, ar.platform as ce_type," +
                    " d.ecosystem_name, d.ecosystem_id," +
                    " convert(ti.submitted_dt, CHAR(20)) as submitted_dt," +
                    " convert(ti.started_dt, CHAR(20)) as started_dt," +
                    " convert(ti.completed_dt, CHAR(20)) as completed_dt" +
                    " from tv_task_instance ti" +
                    " left join task t on t.task_id = ti.task_id" +
                    sTagString +
                    " left outer join application_registry ar on ti.ce_node = ar.id" +
                    " left outer join ecosystem d on ti.ecosystem_id = d.ecosystem_id" +
//.........这里部分代码省略.........
开发者ID:you8,项目名称:cato,代码行数:101,代码来源:taskActivityLog.aspx.cs

示例13: InitSodata1

        private void InitSodata1()
        {
            if (ctrlLayoutList1.FocusedObject == null)
                return;

            string sid = ctrlLayoutList1.FocusedObject.UID;

            Hashtable hs = new Hashtable();
            Hashtable hs2 = new Hashtable();

            IList<LineInfo> listLineInfo = Services.BaseService.GetList<LineInfo>("SelectLineInfoByPowerID", sid);
            foreach (LineInfo l1 in listLineInfo)
            {
                hs.Add(Guid.NewGuid().ToString(), l1.UID);
            }

            IList<Line_Info> ll1 = Services.BaseService.GetList<Line_Info>("SelectLine_InfoByFlag", sid);
            foreach (Line_Info ps in ll1)
            {
                hs2.Add(Guid.NewGuid().ToString(), ps.Code);
            }

            foreach (Line_Info p1 in ll1)
            {
                if (p1.Code != "" && !hs.ContainsValue(p1.Code))
                {
                    Services.BaseService.Delete<Line_Info>(p1);
                }
            }

            foreach (LineInfo l2 in listLineInfo)
            {
                if (!hs2.ContainsValue(l2.UID) && l2.Voltage != "")
                {
                    //���
                    try
                    {
                        Line_Info line1 = new Line_Info();
                        line1.DY = int.Parse(l2.Voltage.ToUpper().Replace("KV", ""));
                        line1.Title = l2.LineName;
                        line1.Code = l2.UID;
                        line1.Flag = sid;
                        Services.BaseService.Create<Line_Info>(line1);
                    }
                    catch { }

                }
            }
        }
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:49,代码来源:FrmLayoutSubstationInfo.cs

示例14: randomTopic

        public bool randomTopic(int Num,int exam_id)
        {
            //先获取题目总数
            string strSql = " select topic_id from ex_topic ";
            int totleNum= listEntity(strSql, null).Tables[0].Rows.Count;

            //判定 需要数量和总数  如果 总数小于 题目数量 则将所有考题选入该考试中
            if (Num> totleNum)
            {
                //全部考题
                strSql = "select topic_id from ex_topic ";
                DataTable Dt = listEntity(strSql, null).Tables[0];
                DataRowCollection rows = Dt.Rows;
                for (int i = 0; i < Dt.Rows.Count; i++)
                {
                    DataRow currRow = rows[i];
                    string topic_id=currRow["topic_id"]+"";

                    //获取TOPIC_ORDER
                    strSql = " select IFNULL(MAX(TOPIC_ORDER),0) from ex_examination_detail where  EXAMINATION_ID=" + exam_id;
                    DataSet ds = listEntity(strSql);
                    int order_id = Convert.ToInt32(ds.Tables[0].Rows[0][0]) + 1;

                    strSql = "insert into ex_examination_detail(EXAMINATION_ID, TOPIC_ID, TOPIC_ORDER) values(?EXAMINATION_ID, ?TOPIC_ID, ?TOPIC_ORDER); select last_insert_id();";
                    MySqlParameter[] parames = new MySqlParameter[] {
                new MySqlParameter("?EXAMINATION_ID", MySqlDbType.VarChar),
                new MySqlParameter("?TOPIC_ID", MySqlDbType.VarChar),
                new MySqlParameter("?TOPIC_ORDER", MySqlDbType.VarChar)
                };

                    parames[0].Value = exam_id;
                    parames[1].Value = topic_id;
                    parames[2].Value = order_id;

                    int EXAMINATION_DETAIL_ID = Convert.ToInt32(MySqlHelper.ExecuteScalar(strSql, parames));
                }
            }
            else
            {

                //全部考题
                strSql = "select topic_id from ex_topic ";
                DataTable Dt = listEntity(strSql, null).Tables[0];
                DataRowCollection rows = Dt.Rows;

                List<int> topic_ids = new List<int>();
                //因为TIPIC_ID不一定是连续的所以我们必须将TIOPIC_ID放入一个集合中然后按照随机数字从集合获取该ID
                for (int i = 0; i < Dt.Rows.Count; i++)
                {
                    DataRow currRow = rows[i];
                    string topic_id = currRow["topic_id"] + "";
                    topic_ids.Add(Convert.ToInt32(topic_id));
                }

                    Hashtable hashtable = new Hashtable();
                Random rm = new Random();
                int RmNum = Num;
                int MaxNum = rows.Count;

                bool doRandom = true;
                int ChooseNum = 0;

                do
                {

                    int nValue = topic_ids[rm.Next(MaxNum)];

                    //检查该数值是否已经存在该次考试中
                    strSql = "select topic_id from ex_examination_detail where topic_id=" + nValue+ " and EXAMINATION_ID="+exam_id;
                    Dt = listEntity(strSql, null).Tables[0];
                    rows = Dt.Rows;
                    if (rows.Count>0)
                    {
                        continue;
                    }

                    if (!hashtable.ContainsValue(nValue) && nValue != 0)
                    {
                        //hashtable.Add(nValue, nValue);
                        //Console.WriteLine(nValue.ToString());
                        //获取TOPIC_ORDER
                        strSql = " select IFNULL(MAX(TOPIC_ORDER),0) from ex_examination_detail where  EXAMINATION_ID=" + exam_id;
                        DataSet ds = listEntity(strSql);
                        int order_id = Convert.ToInt32(ds.Tables[0].Rows[0][0]) + 1;

                        int topic_id = nValue;

                        strSql = "insert into ex_examination_detail(EXAMINATION_ID, TOPIC_ID, TOPIC_ORDER) values(?EXAMINATION_ID, ?TOPIC_ID, ?TOPIC_ORDER); select last_insert_id();";
                        MySqlParameter[] parames = new MySqlParameter[] {
                new MySqlParameter("?EXAMINATION_ID", MySqlDbType.VarChar),
                new MySqlParameter("?TOPIC_ID", MySqlDbType.VarChar),
                new MySqlParameter("?TOPIC_ORDER", MySqlDbType.VarChar)
                };

                        parames[0].Value = exam_id;
                        parames[1].Value = topic_id;
                        parames[2].Value = order_id;

                        int EXAMINATION_DETAIL_ID = Convert.ToInt32(MySqlHelper.ExecuteScalar(strSql, parames));

//.........这里部分代码省略.........
开发者ID:yaopengchao,项目名称:tcz,代码行数:101,代码来源:ExaminationDao.cs

示例15: ScenesInOrderOfProximity

        /// <summary>
        /// Takes a list of scenes and forms a new orderd list according to the proximity of scenes to the second argument.
        /// </summary>
        protected static System.Collections.Generic.List<Scene> ScenesInOrderOfProximity(Hashtable sceneList, Scene scene)
        {
            int somethingAddedToList = 1;
            System.Collections.Generic.List<Scene> newList = new List<Scene>();
            newList.Add(scene);

            if (!sceneList.ContainsValue(scene))
            {
                foreach (Object sceneObj in sceneList)
                    newList.Add((Scene) sceneObj);
                return newList;
            }

            while (somethingAddedToList > 0)
            {
                somethingAddedToList = 0;
                for (int i = 0; i < newList.Count; i++)
                {
                    foreach (Object sceneObj in sceneList.Values)
                    {
                        if (newList[i].CheckNeighborRegion(((Scene)sceneObj).RegionInfo) && (!newList.Contains((Scene)sceneObj)))
                        {
                            newList.Add((Scene)sceneObj);
                            somethingAddedToList++;
                        }
                    }
                }
            }

            foreach (Object sceneObj in sceneList.Values)
                if (!newList.Contains((Scene)sceneObj))
                    newList.Add((Scene)sceneObj);

            return newList;
        }
开发者ID:ChrisD,项目名称:opensim,代码行数:38,代码来源:CMController.cs


注:本文中的System.Collections.Hashtable.ContainsValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。