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)); } }
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]); } }
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); } }
static public int ContainsValue(IntPtr l) { try { System.Collections.Hashtable self = (System.Collections.Hashtable)checkSelf(l); System.Object a1; checkType(l, 2, out a1); var ret = self.ContainsValue(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
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); } }
static int ContainsValue(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); System.Collections.Hashtable obj = (System.Collections.Hashtable)ToLua.CheckObject(L, 1, typeof(System.Collections.Hashtable)); object arg0 = ToLua.ToVarObject(L, 2); bool o = obj.ContainsValue(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
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(); } } }
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(); }
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(); }
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(); }
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(); }
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" + " left join users u on u.user_id = ti.submitted_by" + " left join asset a on a.asset_id = ti.asset_id" + sSearchString.Replace(";", "") + sWhereString + " order by ti.task_instance desc" + " limit " + sNumRecords; DataTable dt = new DataTable(); if (!dc.sqlGetDataTable(ref dt, sSQL, ref sErr)) { ui.RaiseError(Page, sErr, true, ""); } ui.SetSessionObject("TaskInstanceList", dt, "TaskInstanceTables"); //now, actually get the data from the session table and display it GetTasks(); }
public bool Contains(object value) { return(hashtable.ContainsValue(value)); }
/// <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; }
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)); } ChooseNum = ChooseNum + 1; if (ChooseNum== RmNum) { doRandom = false; } } while (doRandom); } //如果总数大于所需数量 则随机添加 //随机时候判定是否已经添加到该考试 已经添加过了继续随机知道达到要求 return true; }
private void InitSodata2() { if (ctrlLayoutList1.FocusedObject == null) return; string sid = ctrlLayoutList1.FocusedObject.UID; Hashtable hs1 = new Hashtable(); Hashtable hs3 = new Hashtable(); IList<substation> listsubstation = Services.BaseService.GetList<substation>("SelectsubstationByPowerID", sid); foreach (substation s1 in listsubstation) { hs1.Add(Guid.NewGuid().ToString(), s1.UID); } IList<Substation_Info> ll2 = Common.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.L2 = double.Parse(s2.Number.ToString()); } catch { } substation1.L6 = s2.ObligateField5; substation1.AreaName = s2.ObligateField6; Services.BaseService.Create<Substation_Info>(substation1); } catch { } } } }
public void InitSodata() { if (ctrlPowerEachList1.FocusedObject == null) return; string sid = typeFlag2= ctrlPowerEachList1.FocusedObject.UID; Hashtable hs = new Hashtable(); Hashtable hs1 = new Hashtable(); ddd = DateTime.Now; sss += "2:" + ddd.ToString(); IList<Itop.Domain.Graphics.LineInfo> listLineInfo = Services.BaseService.GetList<Itop.Domain.Graphics.LineInfo>("SelectLineInfoByPowerID", sid); foreach (Itop.Domain.Graphics.LineInfo l1 in listLineInfo) { hs.Add(Guid.NewGuid().ToString(), l1.UID); } ddd = DateTime.Now; sss += "3:" + ddd.ToString(); IList<substation> listsubstation = Services.BaseService.GetList<substation>("SelectsubstationByPowerID2", sid); foreach (substation s1 in listsubstation) { hs.Add(Guid.NewGuid().ToString(), s1.UID); } ddd = DateTime.Now; sss += "4:" + ddd.ToString(); PSP_PowerProValues_LangFang psp_Type = new PSP_PowerProValues_LangFang(); psp_Type.Flag2 = sid; IList<PSP_PowerProValues_LangFang> listProTypes = Common.Services.BaseService.GetList<PSP_PowerProValues_LangFang>("SelectPSP_PowerProValues_LangFangByFlag2", psp_Type); foreach (PSP_PowerProValues_LangFang ps in listProTypes) { hs1.Add(Guid.NewGuid().ToString(), ps.Code); } ddd = DateTime.Now; sss += "5:" + ddd.ToString(); foreach (PSP_PowerProValues_LangFang p1 in listProTypes) { if (p1.Code != "" && !hs.ContainsValue(p1.Code) && p1.ParentID != "0") { //删除 Services.BaseService.Delete<PSP_PowerProValues_LangFang>(p1); } } ddd = DateTime.Now; sss += "6:" + ddd.ToString(); foreach (Itop.Domain.Graphics.LineInfo l2 in listLineInfo) { if (!hs1.ContainsValue(l2.UID) && l2.Voltage != "") { //添加 try { PSP_PowerProValues_LangFang ps2 = new PSP_PowerProValues_LangFang(); ps2.ParentID = l2.Voltage.ToUpper().Replace("KV", ""); ps2.L3 = l2.LineName; ps2.Code = l2.UID; ps2.Flag = 1; ps2.Flag2 = sid; ps2.L4 = l2.Voltage; ps2.L8 = double.Parse(l2.Length).ToString(); ; ps2.L9 = l2.LineType; ps2.ID = Guid.NewGuid().ToString(); Services.BaseService.Create<PSP_PowerProValues_LangFang>(ps2); } catch( Exception ex){ System.Console.WriteLine(ex.Message); } } if (hs1.ContainsValue(l2.UID) && l2.Voltage != "") { //更新 try { PSP_PowerProValues_LangFang p2 = new PSP_PowerProValues_LangFang(); p2.Code = l2.UID; p2.Flag2 = sid; PSP_PowerProValues_LangFang ps2=(PSP_PowerProValues_LangFang)Services.BaseService.GetObject("SelectPSP_PowerProValues_LangFangByselectObject", p2); ps2.ParentID = l2.Voltage.ToUpper().Replace("KV", ""); ps2.L3 = l2.LineName; ps2.Flag = 1; ps2.L4 = l2.Voltage; ps2.L8 = double.Parse(l2.Length).ToString(); ; ps2.L9 = l2.LineType; Services.BaseService.Update("UpdatePSP_PowerProValues_LangFangByCode", ps2); } catch (Exception ex) { System.Console.WriteLine(ex.Message); } } } ddd = DateTime.Now; sss += "7:" + ddd.ToString(); //ps.Type = OBJ.L7; Project_Sum psp = new Project_Sum(); psp.S5 = "2"; IList<Project_Sum> sum = Common.Services.BaseService.GetList<Project_Sum>("SelectProject_SumByS5", psp); Hashtable ha = new Hashtable(); ArrayList al=new ArrayList(); foreach (substation s2 in listsubstation) { if (!hs1.ContainsValue(s2.UID) && s2.ObligateField1 != "") { ha.Clear(); al.Clear(); int kk = 0; //添加 try { Substation_Info sub = new Substation_Info(); sub.Code = s2.UID; Substation_Info station = (Substation_Info)Common.Services.BaseService.GetObject("SelectSubstation_InfoByCode", sub); PSP_PowerProValues_LangFang ps3 = new PSP_PowerProValues_LangFang(); ps3.ParentID = s2.ObligateField1; ps3.L3 = s2.EleName; ps3.Code = s2.UID; ps3.Flag = 2; ps3.Flag2 = sid; ps3.L4 = s2.ObligateField1.ToString(); if (station != null) { ps3.L5 = station.L3.ToString(); } foreach (Project_Sum ps1 in sum) { if (s2.ObligateField1.ToString() == ps1.S1.ToString()) { try { double mva = double.Parse(s2.Number.ToString()); double t5 = Convert.ToDouble(ps1.T5);//单台容量 int ta = Convert.ToInt32(ps1.T1);//主变台数 if (mva == (t5 * ta)) { ha.Add(t5, ta); al.Add(t5); } } catch { } } } if (al.Count > 0) { double va = Convert.ToDouble(al[0].ToString()); for (int ii = 0; ii < al.Count; ii++) { if (va < Convert.ToDouble(al[ii].ToString())) va = Convert.ToDouble(al[ii].ToString()); } ps3.L5 = ha[va].ToString(); ps3.L6 = va.ToString(); } else { ps3.L5 = ""; ps3.L6 = ""; } ps3.IsConn = double.Parse(s2.Number.ToString()).ToString();//总容量 ps3.ID = Guid.NewGuid().ToString(); Services.BaseService.Create<PSP_PowerProValues_LangFang>(ps3); } catch { } } if (hs1.ContainsValue(s2.UID) && s2.ObligateField1 != "") { ha.Clear(); al.Clear(); int kk = 0; //更新 try { Substation_Info sub = new Substation_Info(); sub.Code = s2.UID; Substation_Info station = (Substation_Info)Common.Services.BaseService.GetObject("SelectSubstation_InfoByCode", sub); PSP_PowerProValues_LangFang p3 = new PSP_PowerProValues_LangFang(); p3.Code = s2.UID; p3.Flag2 = sid; PSP_PowerProValues_LangFang ps3 = (PSP_PowerProValues_LangFang)Services.BaseService.GetObject("SelectPSP_PowerProValues_LangFangByselectObject", p3); ps3.ParentID = s2.ObligateField1; ps3.L3 = s2.EleName; ps3.Flag = 2; ps3.L4 = s2.ObligateField1.ToString(); if (station != null) { ps3.L5 = station.L3.ToString(); } foreach (Project_Sum ps1 in sum) { if (s2.ObligateField1.ToString() == ps1.S1.ToString()) { try { double mva = double.Parse(s2.Number.ToString()); double t5 = Convert.ToDouble(ps1.T5);//单台容量 int ta = Convert.ToInt32(ps1.T1);//主变台数 if (mva == (t5 * ta)) { ha.Add(t5, ta); al.Add(t5); } } catch { } } } if (al.Count > 0) { double va = Convert.ToDouble(al[0].ToString()); for (int ii = 0; ii < al.Count; ii++) { if (va < Convert.ToDouble(al[ii].ToString())) va = Convert.ToDouble(al[ii].ToString()); } ps3.L5 = ha[va].ToString(); ps3.L6 = va.ToString(); } else { ps3.L5 = ""; ps3.L6 = ""; } ps3.IsConn = double.Parse(s2.Number.ToString()).ToString();//总容量 Services.BaseService.Update("UpdatePSP_PowerProValues_LangFangByCode", ps3); } catch { } } } ddd = DateTime.Now; sss += "8:" + ddd.ToString(); if (updat == "true") { LoadDatadata(); } else if (updat == "false") { UpdataLoadDatadata(); updat = "true"; } else { LoadData(); updat = "true"; } ddd = DateTime.Now; sss += "9:" + ddd.ToString(); }
/// <summary> /// Demonstrates the increase of floor to floor height by iterating over a set of available /// levels. /// </summary> public void SimpleLevelIteration() { // Clear all related elements if a shed has already been created to prevent overlapping elements. m_revitApp.ActiveUIDocument.Document.Delete( m_shedElements ); // Use the simple shed sample to demonstrate the increase in floor to floor height. SimpleShed(); DialogResult dlgRes = MessageBox.Show( "This will increase the floor to floor height of the Simple Shed by 10 Ft \n \t\t Hit Cancel to see original shed.", "Test Framework", MessageBoxButtons.OKCancel, MessageBoxIcon.Information ); if( dlgRes == System.Windows.Forms.DialogResult.OK ) { ArrayList levels = new ArrayList(); ArrayList elevations = new ArrayList(); Hashtable hash = new Hashtable(); FilteredElementCollector fec = new FilteredElementCollector( m_revitApp.ActiveUIDocument.Document ); ElementClassFilter elementsAreWanted = new ElementClassFilter( typeof( Level ) ); fec.WherePasses( elementsAreWanted ); List<Element> elements = fec.ToElements() as List<Element>; foreach( Element element in elements ) { Level systemLevel = element as Level; if( null != systemLevel ) { // collect all the levels levels.Add( systemLevel ); } } // Polulates a hashtable with the [key. value] pair represented as [Elevation, Level] // Also populate a list of elevations. for( Int32 i = 0; i < levels.Count; i++ ) { Level lev = (Level) levels[i]; if( !hash.ContainsKey( lev.Elevation ) && !hash.ContainsValue( lev ) ) { hash.Add( lev.Elevation, lev ); } elevations.Add( lev.Elevation ); } // Sort the elevations elevations.Sort(); Double elevation = (Double) elevations[0]; // Now that we have the elevations sorted, get the levels corresponding to them and bump // them up by a desired value. for( Int32 z = 1; z < elevations.Count; z++ ) { Double elev = (Double) elevations[z]; if( elev != 0.0 ) { Level level = (Level) hash[elev]; elevation = elevation + 20.0; level.Elevation = elevation; } } } }
//��ȡ���� private void LoadValues1(Hashtable htt) { PSP_Values psp_Values = new PSP_Values(); psp_Values.ID = typeFlag2;//��ID�ֶδ��Flag2��ֵ IList<PSP_Values> listValues = Common.Services.BaseService.GetList<PSP_Values>("SelectPSP_ValuesListByFlag2", psp_Values); foreach (PSP_Values value in listValues) { if (!htt.ContainsValue(value.Year)) continue; TreeListNode node = treeList1.FindNodeByFieldValue("ID", value.TypeID); if (node != null) { node.SetValue(value.Year + "��", value.Value); } } }
private void Get1(PSP_P_Types pt, IList<PSP_P_Types> li, Hashtable hs) { IList<PSP_P_Types> li1 = Services.BaseService.GetList<PSP_P_Types>("SelectPSP_P_TypesByParentID", pt); foreach (PSP_P_Types pt1 in li1) { if (hs.ContainsValue(pt1)) continue; hs.Add(Guid.NewGuid().ToString(), pt1); //li.Add(pt1); Get1(pt1, li, hs); } }
#pragma warning restore 618 private static string GenerateFriendlyName(string className, Hashtable classes) { if (classes.ContainsKey(className)) return (string)classes[className]; Type type = System.Type.GetType(className, false, false); if (type != null && !type.IsVisible) type = null; if (type == null) return className; if (!classes.ContainsValue(type.Name)) { classes.Add(className, type.Name); return type.Name; } else if (!classes.ContainsValue(type.FullName)) { classes.Add(className, type.FullName); return type.FullName; } else { classes.Add(className, type.AssemblyQualifiedName); return type.AssemblyQualifiedName; } }
public void TestContainsValue() { { Hashtable h = new Hashtable(); h['a'] = "blue"; Assert.IsTrue (h.ContainsValue("blue"), "blue? it's in there!"); Assert.IsTrue (!h.ContainsValue("green"), "green? no way!"); Assert.IsTrue (!h.ContainsValue(null), "null? no way!"); h['b'] = null; Assert.IsTrue (h.ContainsValue(null), "null? it's in there!"); } }
private void InitSodata2() { string sid = "1"; Hashtable hs1 = new Hashtable(); Hashtable hs3 = new Hashtable(); IList<substation> listsubstation = Services.BaseService.GetList<substation>("SelectsubstationByPowerIDStuff", sid); foreach (substation s1 in listsubstation) { hs1.Add(Guid.NewGuid().ToString(), s1.UID); } IList<Substation_Info> ll2 = Common.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); } catch { } try { substation1.L2 = Convert.ToDouble(s2.Number); } catch { } try { substation1.L9 = Convert.ToDouble(s2.Burthen); } catch { } Services.BaseService.Create<Substation_Info>(substation1); //Substation_Info substation1 = new Substation_Info(); //substation1.L1 = int.Parse(s2.ObligateField1); //substation1.Title = s2.EleName; //substation1.Code = s2.UID; //substation1.Flag = sid; //Services.BaseService.Create<Substation_Info>(substation1); } catch { } } } }
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 { } } } }
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 { } } } }
private void InitSodata1() { ////if (ctrlLayoutList1.FocusedObject == null) //// return; ////string sid = ctrlLayoutList1.FocusedObject.UID; string sid = selectid; if (sid == "") return; Hashtable hs = new Hashtable(); Hashtable hs2 = new Hashtable(); LineInfo lia1 = new LineInfo(); lia1.LineName = "SELECT " +"t1.uid as UID, " +"EleID, " +"LineName, " +"Length, " +"LineType, " +"Voltage, " + "t2.PicSelectName as SvgUID, " +"LayerID, " +"ObligateField1, " +"ObligateField2, " +"ObligateField3, " +"ObligateField4, " + "ObligateField5,ObligateField6,ObligateField7 " + "FROM LineInfo t1,PSP_PowerPicSelect t2 where t1.LayerID=t2.PicSelectID and t2.EachListID='"+sid+"' and t1.ObligateField1='"+leixing+"'"; IList<LineInfo> listLineInfo = Services.BaseService.GetList<LineInfo>("SelectLineInfoByWhere1", lia1); if (leixing == "����") { IList<LineInfo> lla = new List<LineInfo>(); Hashtable hsss1 = new Hashtable(); foreach (LineInfo l1 in listLineInfo) { if (!hsss1.ContainsKey(l1.LineName)) { lla = new List<LineInfo>(); lla.Add(l1); hsss1.Add(l1.LineName, lla); } else { IList<LineInfo> llb = (IList<LineInfo>)hsss1[l1.LineName]; llb.Add(l1); hsss1[l1.LineName] = llb; } } foreach (DictionaryEntry de1 in hsss1) { string uuid=Guid.NewGuid().ToString(); int sff=10000; IList<LineInfo> llc = (IList<LineInfo>)de1.Value; foreach (LineInfo l2 in llc) { string yearss = l2.SvgUID; int years1 = 0; int years2 = DateTime.Now.Year-1; try { years1 = int.Parse(yearss.Substring(0, 4)); } catch { continue; } if (Math.Abs(years2 - years1) <= sff) { sff = Math.Abs(years2 - years1); if (hs.ContainsKey(uuid)) { hs[uuid] = l2.UID; } else { hs.Add(uuid, l2.UID); } } } } } else { foreach (LineInfo l1 in listLineInfo) { hs.Add(Guid.NewGuid().ToString(), l1.UID); } } IList<Line_Info> ll1 = Common.Services.BaseService.GetList<Line_Info>("SelectLine_InfoByFlag", sid); foreach (Line_Info ps in ll1) { if(ps.Code!="") hs2.Add(ps.Code,ps.UID); } 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 (hs.ContainsValue(l2.UID) && l2.Voltage != "") { Line_Info line1 = new Line_Info(); if (hs2.ContainsKey(l2.UID)) line1 = Services.BaseService.GetOneByKey<Line_Info>(hs2[l2.UID].ToString()); line1.Title = l2.LineName; line1.Code = l2.UID; line1.Flag = sid; if (System.Configuration.ConfigurationSettings.AppSettings["LangFang"].ToString() == "�ȷ�") { line1.AreaName = l2.ObligateField5;//��ʱΪ�����ͺ� } try { int dy = int.Parse(l2.Voltage.ToUpper().Replace("KV", "")); line1.DY = dy; line1.K1 = dy; line1.L1 = dy; } catch { } try { line1.L4 = l2.LineType; line1.K2 = l2.LineType; } catch { } line1.AreaID = ProjectUID; try { line1.L6 = l2.ObligateField3;//Ͷ������ } catch { line1.L6 = null; } try { line1.L5 = double.Parse(l2.Length); line1.K5 = double.Parse(l2.Length); } catch { } try { if (!hs2.ContainsKey(l2.UID)) { Services.BaseService.Create<Line_Info>(line1); } else { //line1.UID = hs2[l2.UID].ToString(); Services.BaseService.Update<Line_Info>(line1); } } catch (Exception ex) { System.Console.Write(ex.Message); } } } }
static void Removeduplicate(int seed) { //Dictionary<int, int> dic = new Dictionary<int, int>();其实用字典更好,应该字典可以保证没有重复的值 Hashtable hashtable = new Hashtable(); Random rm = new Random(seed); int RmNum = 10; for (int i = 0; hashtable.Count < RmNum; i++) { int nValue = rm.Next(20); if (!hashtable.ContainsValue(nValue) && nValue != 0) { hashtable.Add(nValue, nValue); Console.Write(nValue+" "); } } Console.Write("\n"); }
/// <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; } return null; }
private void LoadData1(int id) { if (dataTable != null) { dataTable.Columns.Clear(); treeList1.Columns.Clear(); } switch (id) { case 999999: typeFlag2 = 1; break; case 888888: typeFlag2 = 2; break; } PSP_Types psp_Type = new PSP_Types(); psp_Type.Flag2 = typeFlag2; IList listTypes = Common.Services.BaseService.GetList("SelectPSP_TypesByFlag2", psp_Type); dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(PSP_Types)); treeList1.DataSource = dataTable; treeList1.Columns["Title"].Caption = "������"; treeList1.Columns["Title"].Width = 180; treeList1.Columns["Title"].OptionsColumn.AllowEdit = false; treeList1.Columns["Title"].OptionsColumn.AllowSort = false; treeList1.Columns["Flag"].VisibleIndex = -1; treeList1.Columns["Flag"].OptionsColumn.ShowInCustomizationForm = false; treeList1.Columns["Flag2"].VisibleIndex = -1; treeList1.Columns["Flag2"].OptionsColumn.ShowInCustomizationForm = false; PSP_Years psp_Year = new PSP_Years(); psp_Year.Flag = typeFlag2; IList<PSP_Years> listYears = Common.Services.BaseService.GetList<PSP_Years>("SelectPSP_YearsListByFlag", psp_Year); Hashtable htt = new Hashtable(); foreach (PSP_Years item in listYears) { if(!htt.ContainsValue(item.Year)) htt.Add(Guid.NewGuid().ToString(),item.Year); AddColumn1(item.Year); } Application.DoEvents(); LoadValues1(htt); treeList1.ExpandAll(); }
private void LoadValues1() { Hashtable hs = new Hashtable(); foreach (DataColumn dc in dataTable.Columns) { if (dc.ColumnName.IndexOf("年") < 0) continue; hs.Add(Guid.NewGuid().ToString(),dc.ColumnName); } foreach (DictionaryEntry de1 in hs) { int year = Convert.ToInt32(de1.Value.ToString().Replace("年","")); if(!hs.ContainsValue((year+1)+"年")) continue; for (int i = 1; i < 4; i++) { double s1 = 0; double s2 = 0; try { s1 = (double)(dataTable.Rows[i][(year + 1) + "年"]); } catch { } try { s2 = (double)(dataTable.Rows[i][year + "年"]); } catch { } if (s2 != 0) dataTable.Rows[i + 4][(year + 1) + "年"] = Math.Round((s1 - s2) * 100 / s2, 2); } } }
public override bool ContainsValue(object value) { return(host.ContainsValue(value)); }
/// <summary> /// 获取代码中所有文件的以HTTP开头的URL地址 /// </summary> /// <param name="sourceString">代码内容</param> /// <returns>ArrayList</returns> public static Hashtable GetFileUrlPath(string sourceString) { Hashtable url = new Hashtable(); Regex r = new Regex(" (src|href|background|value)=('|\"|)(http://.*?)('|\"| |>)", RegexOptions.IgnoreCase | RegexOptions.Compiled); MatchCollection mc = r.Matches(sourceString); for (int i = 0; i < mc.Count; i++) { if (!url.ContainsValue(mc[i].Result("$3"))) { url.Add(i, mc[i].Result("$3")); } } return url; }
private void GetFFData(int sid,string type,string title) { FormXiaoshi_Fs ffs = new FormXiaoshi_Fs(); ffs.Type = type; ffs.ForecastReports = forecastReport; if (ffs.ShowDialog() != DialogResult.OK) return; Hashtable hs = ffs.HS; if (hs.Count != 3) return; int uid = (int)hs["H1"]; TreeListNode tn = (TreeListNode)hs["H2"]; bool bool1 = (bool)hs["H3"]; PSP_P_Types pt=new PSP_P_Types(); if (bool1) { PSP_Types pt1 = Services.BaseService.GetOneByKey<PSP_Types>(uid); InitTypes(pt1, pt); } else { pt = Services.BaseService.GetOneByKey<PSP_P_Types>(uid); } #region �趨types string str2 = " ID=" + sid + " and Flag='" + typeFlag + "' and Flag2='" + forecastReport.ID + "' "; IList listTypes = Common.Services.BaseService.GetList("SelectPSP_P_TypesByWhere", str2); if (listTypes.Count != 0) { PSP_P_Values ppvvv = new PSP_P_Values(); ppvvv.TypeID = sid; ppvvv.Flag2 = forecastReport.ID; Services.BaseService.Update("DeletePSP_P_ValuesByType", ppvvv); } pt.ID = sid; pt.Flag2 = forecastReport.ID; pt.Flag = typeFlag; pt.Title = title; Services.BaseService.Create<PSP_P_Types>(pt); #endregion #region �趨year value Hashtable hta = new Hashtable(); ArrayList al = new ArrayList(); foreach (TreeListColumn tlc in tn.TreeList.Columns) { if (tlc.FieldName.IndexOf("��") >= 0) { int year = 0; try { year=int.Parse(tlc.FieldName.Replace("��", "")); } catch { } if (year != 0 && year > forecastReport.EndYear) continue; hta.Add(Guid.NewGuid().ToString(), year); try { PSP_P_Values pv = new PSP_P_Values(); pv.Year=year; pv.TypeID=sid; try { pv.Value = double.Parse(tn[tlc.FieldName].ToString()); } catch { } pv.Flag2 = forecastReport.ID; Services.BaseService.Create<PSP_P_Values>(pv); } catch { } try { PSP_P_Years ppy = new PSP_P_Years(); ppy.Flag = forecastReport.ID; ppy.Flag2 = typeFlag; ppy.Year = year; Services.BaseService.Create<PSP_P_Years>(ppy); } catch (Exception ex) { //MessageBox.Show(ex.Message); } } } for (int m = forecastReport.StartYear; m <= forecastReport.EndYear; m++) { if (!hta.ContainsValue(m)) { try { PSP_P_Years ppy = new PSP_P_Years(); ppy.Flag = forecastReport.ID; ppy.Flag2 = typeFlag; ppy.Year = m; Services.BaseService.Create<PSP_P_Years>(ppy); } catch (Exception ex) { //MessageBox.Show(ex.Message); } } } #endregion Application.DoEvents(); this.Cursor = Cursors.WaitCursor; treeList1.BeginUpdate(); LoadData(); treeList1.EndUpdate(); this.Cursor = Cursors.Default; Compute(); RefreshChart(); }
private static void ProfileGetRelatedElevData(IApplication app, List<ProfileGraphDetails> ProfileGraph, IGeometricNetwork pGeometricNet, IEnumNetEID pResultEdges, IEnumNetEID pResultJunctions, int CurrentDetail, ref IFeatureLayer pFLManhole, ref IFeatureLayer pFLMain, ref IFeatureLayer pFLTap) { List<mainDetails> SewerColMains = null; List<manholeDetails> SewerColManholes = null; List<tapDetails> SewerColTap = null; IEIDHelper pEIDHelperEdges = null; IEnumEIDInfo pEnumEIDInfoEdges = null; IEIDHelper pEIDHelperJunctions = null; IEnumEIDInfo pEnumEIDInfoJunctions = null; IPolyline pPolyline = null; IPointCollection pPtColl = null; IEIDInfo pEIDInfo = null; IPoint pNewPt = null; ISegmentCollection pSegColl = null; IMSegmentation pMSegmentation = null; IMAware pMAware = null; IPointCollection pPtCollection = null; IEnumVertex pEnumVertex; IHitTest pHtTest = null; IPoint pHitPntOne = null; IPoint pHitPntTwo = null; IFeature pFeature = null; Hashtable pFeatureAdded = null; mainDetails mainDet = null; IEdgeFeature pEdge = null; IPoint pGeoOne = null; IPoint pGeoTwo = null; IField pFld = null; IJunctionFeature pJunc = null; tapDetails tapDet = null; manholeDetails manDet = null; IFeatureLayer pFl = null; ISpatialFilter pSpatFilt = null; IFeatureCursor pFC = null; try { SewerColMains = new List<mainDetails>(); SewerColManholes = new List<manholeDetails>(); SewerColTap = new List<tapDetails>(); pEIDHelperEdges = new EIDHelper(); pEIDHelperEdges.GeometricNetwork = pGeometricNet; pEIDHelperEdges.ReturnFeatures = true; pEIDHelperEdges.ReturnGeometries = true; pEIDHelperEdges.PartialComplexEdgeGeometry = true; pEnumEIDInfoEdges = pEIDHelperEdges.CreateEnumEIDInfo(pResultEdges); pEnumEIDInfoEdges.Reset(); //edges pEIDHelperJunctions = new EIDHelperClass(); pEIDHelperJunctions.GeometricNetwork = pGeometricNet; pEIDHelperJunctions.ReturnFeatures = true; pEIDHelperJunctions.ReturnGeometries = true; pEIDHelperJunctions.PartialComplexEdgeGeometry = true; pEnumEIDInfoJunctions = pEIDHelperJunctions.CreateEnumEIDInfo(pResultJunctions); pEnumEIDInfoJunctions.Reset();// junctions pPolyline = new PolylineClass(); pPolyline.SpatialReference = (pFLMain as IGeoDataset).SpatialReference; pPtColl = (IPointCollection)pPolyline; //QI for (int i = 0; i < pEnumEIDInfoJunctions.Count; i++) { pEIDInfo = pEnumEIDInfoJunctions.Next(); pNewPt = (IPoint)pEIDInfo.Geometry; pPtColl.AddPoint(pNewPt); } pSegColl = (ISegmentCollection)pPolyline; pPolyline.Densify(50, 0.01); pMAware = (IMAware)pPolyline;//'QI pMAware.MAware = true; pMSegmentation = (IMSegmentation)pPolyline; // get the M values, put the distance in m, 0 to Length pMSegmentation.SetMsAsDistance(false); pPtCollection = (IPointCollection)pPolyline; pEnumVertex = pPtCollection.EnumVertices; pEnumVertex.Reset(); pHtTest = pPolyline as IHitTest; pHitPntOne = new PointClass(); pHitPntTwo = new PointClass(); double pHitDistOne = -1; double pHitDistTwo = -1; int pHitPrtOne = -1; int pHitPrtTwo = -1; int pHitSegOne = -1; int pHitSegTwo = -1; bool pHitSideOne = false; bool pHitSideTwo = false; pFeatureAdded = new Hashtable(); pEnumEIDInfoEdges.Reset(); //edges int intUpStreamFld = pFLMain.FeatureClass.Fields.FindField(ProfileGraph[CurrentDetail].Line_UpStreamElevationField); int intDownStreamFld = pFLMain.FeatureClass.Fields.FindField(ProfileGraph[CurrentDetail].Line_DownStreamElevationField); if (intDownStreamFld < 0) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19c") + ProfileGraph[CurrentDetail].Line_DownStreamElevationField + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19b")); } if (intUpStreamFld < 0) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19d") + ProfileGraph[CurrentDetail].Line_UpStreamElevationField + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19b")); } for (int i = 0; i < pResultEdges.Count; i++) { pEIDInfo = pEnumEIDInfoEdges.Next(); pFeature = pEIDInfo.Feature; if (((IDataset)pFeature.Class).Name != ((IDataset)pFLMain.FeatureClass).Name) continue; if (pFeatureAdded.ContainsValue(pFeature.OID)) continue; mainDet = new mainDetails(); pEdge = (IEdgeFeature)pFeature; pGeoOne = (IPoint)pEdge.FromJunctionFeature.get_OriginalGeometryForJunctionElement(0); pGeoTwo = (IPoint)pEdge.ToJunctionFeature.get_OriginalGeometryForJunctionElement(0); pFeature = ((IFeatureClass)pFeature.Class).GetFeature(pFeature.OID); bool bHitOne = pHtTest.HitTest(pGeoOne, .1, esriGeometryHitPartType.esriGeometryPartVertex, pHitPntOne, ref pHitDistOne, ref pHitPrtOne, ref pHitSegOne, ref pHitSideOne); bool bHitTwo = pHtTest.HitTest(pGeoTwo, .1, esriGeometryHitPartType.esriGeometryPartVertex, pHitPntTwo, ref pHitDistTwo, ref pHitPrtTwo, ref pHitSegTwo, ref pHitSideTwo); if (bHitOne && bHitTwo) { if (pHitPntOne.M < pHitPntTwo.M) { mainDet.UpM = pHitPntOne.M; mainDet.DownM = pHitPntTwo.M; if (intUpStreamFld > 0) { if (pFeature.get_Value(intUpStreamFld).ToString() != "") { mainDet.UpElev = Convert.ToDouble(pFeature.get_Value(intUpStreamFld)); } else mainDet.UpElev = -9999; } else mainDet.UpElev = -9999; if (intDownStreamFld > 0) { if (pFeature.get_Value(intDownStreamFld).ToString() != "") { mainDet.DownElev = Convert.ToDouble(pFeature.get_Value(intDownStreamFld)); } else mainDet.DownElev = -9999; } else mainDet.DownElev = -9999; } else { mainDet.DownM = pHitPntOne.M; mainDet.UpM = pHitPntTwo.M; if (intUpStreamFld > 0) { if (pFeature.get_Value(intUpStreamFld) != null && pFeature.get_Value(intUpStreamFld).ToString() != "") { mainDet.DownElev = Convert.ToDouble(pFeature.get_Value(intUpStreamFld)); } else mainDet.DownElev = -9999; } else mainDet.DownElev = -9999; if (intDownStreamFld > 0) { if (pFeature.get_Value(intDownStreamFld) != null && pFeature.get_Value(intDownStreamFld).ToString() != "") { mainDet.UpElev = Convert.ToDouble(pFeature.get_Value(intDownStreamFld)); } else mainDet.UpElev = -9999; } else mainDet.UpElev = -9999; } string label = ""; for (int l = 0; l < ProfileGraph[CurrentDetail].Line_Labels.Length; l++) { if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Line_Labels[l]) > 0) { int fldIdx = pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Line_Labels[l]); pFld = pFeature.Fields.get_Field(fldIdx); if (pFeature.get_Value(fldIdx) != null) { if (label == "") { label = Globals.GetDomainDisplay(pFeature.get_Value(fldIdx), pFeature, pFld); } else { label = label + "\r\n" + Globals.GetDomainDisplay(pFeature.get_Value(fldIdx), pFeature, pFld); } } } } mainDet.Label = label; } if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Line_IDField) > 0) { if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Line_IDField)) != null && pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Line_IDField)).ToString() != "") { mainDet.MainID = Convert.ToString(pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Line_IDField))); } else mainDet.MainID = "Unk"; } else mainDet.MainID = "Unk"; pFeatureAdded.Add(pFeature.OID, pFeature.OID); SewerColMains.Add(mainDet); } pFeatureAdded = new Hashtable(); pEnumEIDInfoJunctions.Reset(); for (int i = 0; i < pEnumEIDInfoJunctions.Count; i++) { pEIDInfo = pEnumEIDInfoJunctions.Next(); pFeature = pEIDInfo.Feature; if (pFLTap != null) { if (((IDataset)pFeature.Class).Name == ((IDataset)pFLTap.FeatureClass).Name) { pJunc = (IJunctionFeature)pFeature; pFeature = ((IFeatureClass)pFeature.Class).GetFeature(pFeature.OID); pHitPntOne = new PointClass(); bool bHit = pHtTest.HitTest(pFeature.Shape as IPoint, .1, esriGeometryHitPartType.esriGeometryPartVertex, pHitPntOne, ref pHitDistOne, ref pHitPrtOne, ref pHitSegOne, ref pHitSideOne); if (bHit) { tapDet = new tapDetails(); tapDet.M = pHitPntOne.M; if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].PointAlong_IDField) > 0) { if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].PointAlong_IDField)) != null && pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].PointAlong_IDField)).ToString() != "") { tapDet.tapID = pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].PointAlong_IDField)).ToString(); } else tapDet.tapID = "Unk"; } else tapDet.tapID = "Unk"; string label = ""; for (int l = 0; l < ProfileGraph[CurrentDetail].PointAlong_Labels.Length; l++) { if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].PointAlong_Labels[l]) > 0) { int fldIdx = pFeature.Fields.FindField(ProfileGraph[CurrentDetail].PointAlong_Labels[l]); pFld = pFeature.Fields.get_Field(fldIdx); if (pFeature.get_Value(fldIdx) != null) { if (label == "") { label = Globals.GetDomainDisplay(pFeature.get_Value(fldIdx), pFeature, pFld); } else { label = label + "\r\n" + Globals.GetDomainDisplay(pFeature.get_Value(fldIdx), pFeature, pFld); } } } } tapDet.tapLabel = label; SewerColTap.Add(tapDet); } } } if (((IDataset)pFeature.Class).Name == ((IDataset)pFLManhole.FeatureClass).Name) { if (pFeatureAdded.ContainsValue(pFeature.OID)) continue; pJunc = (IJunctionFeature)pFeature; pFeature = ((IFeatureClass)pFeature.Class).GetFeature(pFeature.OID); pHitPntOne = new PointClass(); bool bHit = pHtTest.HitTest(pFeature.Shape as IPoint, .1, esriGeometryHitPartType.esriGeometryPartVertex, pHitPntOne, ref pHitDistOne, ref pHitPrtOne, ref pHitSegOne, ref pHitSideOne); if (bHit) { manDet = new manholeDetails(); manDet.M = pHitPntOne.M; if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_TopElevationField) > 0) { if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_TopElevationField)) != null && pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_TopElevationField)).ToString() != "") { manDet.Top = (double)pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_TopElevationField)); } else manDet.Top = -9999; } else manDet.Top = -9999; if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationField) > 0) { if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationField)) != null && pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationField)).ToString() != "") { manDet.Bottom = (double)pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationField)); if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationTypeField) > 0) { if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationTypeField)) != null && pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationTypeField)).ToString() != "") { if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationTypeField)).ToString().ToUpper() == "INVERT") manDet.Bottom = manDet.Top - (double)pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_BottomElevationTypeField)); } } } else manDet.Bottom = -9999; } else manDet.Bottom = -9999; //if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertElevationField) > 0) //{ // if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertElevationField)) != null && pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertElevationField)).ToString() != "") // { // manDet.InvertElev = (double)pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertElevationField)); // } // else // manDet.InvertElev = -9999; //} //else // manDet.InvertElev = -9999; //if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertField) > 0) //{ // if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertField)) != null && pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertField)).ToString() != "") // { // manDet.Invert = (double)pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_InvertField)); // } // else // manDet.Invert = -9999; //} //else // manDet.Invert = -9999; //if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_RimElevationField) > 0) //{ // if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_RimElevationField)) != null && pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_RimElevationField)).ToString() != "") // { // manDet.Rim = (double)pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_RimElevationField)); // } // else // manDet.Rim = -9999; //} //else // manDet.Rim = -9999; if (pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_IDField) > 0) { if (pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_IDField)) != null && pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_IDField)).ToString() != "") { manDet.ManholeID = pFeature.get_Value(pFeature.Fields.FindField(ProfileGraph[CurrentDetail].Point_IDField)).ToString(); } else manDet.ManholeID = "UNK"; } else manDet.ManholeID = "UNK"; pFeatureAdded.Add(pFeature.OID, pFeature.OID); SewerColManholes.Add(manDet); } } } if (ProfileGraph[CurrentDetail].Lines_Along != null) { if (ProfileGraph[CurrentDetail].Lines_Along.Length > 0) { pSpatFilt = new SpatialFilterClass(); pSpatFilt.Geometry = pPolyline; pSpatFilt.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; for (int i = 0; i < ProfileGraph[CurrentDetail].Lines_Along.Length; i++) { bool FCorLayerTemp = true; pFl = (IFeatureLayer)Globals.FindLayer(app, ProfileGraph[CurrentDetail].Lines_Along[i].Layer_Name, ref FCorLayerTemp); if (pFl != null) { intUpStreamFld = pFl.FeatureClass.Fields.FindField(ProfileGraph[CurrentDetail].Lines_Along[i].Line_UpStreamElevationField); intDownStreamFld = pFl.FeatureClass.Fields.FindField(ProfileGraph[CurrentDetail].Lines_Along[i].Line_DownStreamElevationField); int intIdFld = pFl.FeatureClass.Fields.FindField(ProfileGraph[CurrentDetail].Lines_Along[i].Line_IDField); if (intIdFld < 0) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19f") + ProfileGraph[CurrentDetail].Lines_Along[i].Line_IDField + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19e") + ProfileGraph[CurrentDetail].Lines_Along[i].Layer_Name); } if (intDownStreamFld < 0) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19c") + ProfileGraph[CurrentDetail].Lines_Along[i].Line_DownStreamElevationField + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19e") + ProfileGraph[CurrentDetail].Lines_Along[i].Layer_Name); } if (intUpStreamFld < 0) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19d") + ProfileGraph[CurrentDetail].Lines_Along[i].Line_UpStreamElevationField + A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19e") + ProfileGraph[CurrentDetail].Lines_Along[i].Layer_Name); } pSpatFilt.GeometryField = pFl.FeatureClass.ShapeFieldName; pFC = pFl.Search(pSpatFilt, true); } } } } ProfileCreateGraph(app, ProfileGraph, pPolyline, SewerColMains, SewerColManholes, SewerColTap, CurrentDetail); } catch (Exception Ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ErrorInThe") + "ProfileGetRelatedSewerElevData " + Ex.Message); } finally { SewerColMains = null; SewerColManholes = null; SewerColTap = null; pEIDHelperEdges = null; pEnumEIDInfoEdges = null; pEIDHelperJunctions = null; if (pEnumEIDInfoJunctions != null) Marshal.ReleaseComObject(pEnumEIDInfoJunctions); pEnumEIDInfoJunctions = null; pPolyline = null; pPtColl = null; pEIDInfo = null; pNewPt = null; pSegColl = null; pMSegmentation = null; pMAware = null; pPtCollection = null; pEnumVertex = null; pHtTest = null; pHitPntOne = null; pHitPntTwo = null; pFeature = null; pFeatureAdded = null; mainDet = null; pEdge = null; pGeoOne = null; pGeoTwo = null; pFld = null; pJunc = null; tapDet = null; manDet = null; pFl = null; pSpatFilt = null; if (pFC != null) Marshal.ReleaseComObject(pFC); pFC = null; } }