private void DoExport() { try { List <Supplier> list = DataGridViewUtil.BindingListToList <Supplier>(dataGridView1.DataSource); System.Collections.SortedList columns = new System.Collections.SortedList(); List <String> keys = new List <string>(); List <String> values = new List <string>(); foreach (DataGridViewColumn item in dataGridView1.Columns) { if (item.Visible) { if (item.Name != "Column1" && item.Name != "Column2" && item.Name != "enabledDataGridViewCheckBoxColumn") { keys.Add(item.DataPropertyName); values.Add(item.HeaderText); } } } NPOIHelper.Keys = keys.ToArray(); NPOIHelper.Values = values.ToArray(); NPOIHelper.ExportExcel(DataGridViewUtil.ToDataTable(list), path); GlobalMessageBox.Show("导出完毕!"); } catch (Exception ex) { ShowError(ex); } finally { UnLockPage(); } }
private void vContatosRefresh(int nIdTerminal, ref System.Windows.Forms.ListView lvContatos) { lvContatos.Items.Clear(); // Sorting System.Collections.SortedList sortListContatos = new System.Collections.SortedList(); foreach (mdlDataBaseAccess.Tabelas.XsdTbTerminaisContatos.tbTerminaisContatosRow dtrwContato in m_typDatSetTerminaisContatos.tbTerminaisContatos.Rows) { if ((dtrwContato.RowState != System.Data.DataRowState.Deleted) && (dtrwContato.nIdTerminal == nIdTerminal) && (!dtrwContato.IsstrNomeNull())) { if (!sortListContatos.ContainsKey(dtrwContato.strNome)) { sortListContatos.Add(dtrwContato.strNome, dtrwContato); } } } // Insert for (int i = 0; i < sortListContatos.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbTerminaisContatos.tbTerminaisContatosRow dtrwContatoInserir = (mdlDataBaseAccess.Tabelas.XsdTbTerminaisContatos.tbTerminaisContatosRow)sortListContatos.GetByIndex(i); System.Windows.Forms.ListViewItem lviInsert = lvContatos.Items.Add(dtrwContatoInserir.strNome); lviInsert.Tag = dtrwContatoInserir.nIdContato; if ((m_nIdSelectContato != -1) && (dtrwContatoInserir.nIdContato == m_nIdSelectContato)) { lviInsert.Selected = true; m_nIdSelectContato = -1; } } }
public static Discuz.Common.Generic.SortedList <int, object> GetTopicTypeArray() #endif { Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService(); #if NET1 System.Collections.SortedList topictypeList; #else Discuz.Common.Generic.SortedList <int, object> topictypeList; #endif topictypeList = cache.RetrieveObject("/TopicTypes") as Discuz.Common.Generic.SortedList <int, object>; if (topictypeList == null) { #if NET1 topictypeList = new System.Collections.SortedList(); #else topictypeList = new Discuz.Common.Generic.SortedList <int, object>(); #endif DataTable dt = DatabaseProvider.GetInstance().GetTopicTypeList(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { if ((dr["typeid"].ToString() != "") && (dr["name"].ToString() != "")) { topictypeList.Add(Int32.Parse(dr["typeid"].ToString()), dr["name"]); } } } cache.AddObject("/TopicTypes", topictypeList); } return(topictypeList); }
private static System.Collections.SortedList getDataSourceNames(Microsoft.Win32.RegistryKey baseReg) { System.Collections.SortedList dsnList = new System.Collections.SortedList(); // get system dsn's Microsoft.Win32.RegistryKey reg = baseReg.OpenSubKey("Software"); if (reg != null) { reg = reg.OpenSubKey("ODBC"); if (reg != null) { reg = reg.OpenSubKey("ODBC.INI"); if (reg != null) { reg = reg.OpenSubKey("ODBC Data Sources"); if (reg != null) { // Get all DSN entries defined in DSN_LOC_IN_REGISTRY. foreach (string sName in reg.GetValueNames()) { dsnList.Add(sName, sName); } } try { reg.Close(); } catch { /* ignore this exception if we couldn't close */ } } } } return(dsnList); }
private void cb_Bank_Deposit_Type_SelectedIndexChanged(object sender, EventArgs e) { try { Lst_Bank_Deposit_Type = new System.Collections.SortedList(); if (cb_Bank_Deposit_Type.ValueMember != null && cb_Bank_Deposit_Type.ValueMember != "" && cb_Bank_Deposit_Type.SelectedIndex > -1) { DataTable dt = DataClass.RetrieveData("SELECT BDT.Bank_Deposit_Type_ID, BDT.Acct_Deposit_From, BDT.Credit_Card_Deposit, BDT.CC_Discount_Acct, BDT.CC_Fees, BDT.Cash_Short_Over_Acct, BDT.Override_Fees, BDT.Bank_Account_ID, BAS.Bank_GL_Account FROM dbo.Bank_Deposit_Type AS BDT INNER JOIN dbo.Bank_Account_Setup AS BAS ON BDT.Bank_Account_ID = BAS.Bank_Account_ID WHERE (BDT.Bank_Deposit_Type_ID = " + cb_Bank_Deposit_Type.SelectedValue.ToString() + ")"); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Columns.Count; i++) { Lst_Bank_Deposit_Type.Add(dt.Columns[i].ColumnName, dt.Rows[0][i]); } lblCashOverSort.Visible = !(bool)Lst_Bank_Deposit_Type["Credit_Card_Deposit"]; lblCredit_Fees.Visible = (bool)Lst_Bank_Deposit_Type["Credit_Card_Deposit"]; if ((bool)Lst_Bank_Deposit_Type["Credit_Card_Deposit"]) { txtCash_Fees.ReadOnly = !(bool)Lst_Bank_Deposit_Type["Override_Fees"]; Calc_CC_Fees(); } else { txtCash_Fees.ReadOnly = false; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "General Ledger"); } }
/// <summary> /// 读取AD用户信息 /// </summary> /// <param name= "ADUsername "> 用户 </param> /// <param name= "ADPassword "> 密码 </param> /// <param name= "domain "> 域名 </param> /// <returns> </returns> public System.Collections.SortedList AdUserInfo(string ADUsername, string ADPassword, string domain) { System.DirectoryServices.DirectorySearcher src; string ADPath = "LDAP:// " + domain;// "ou=总公司,DC=abc,DC=com,DC=cn "; + ",ou=总公司 " System.Collections.SortedList sl = new System.Collections.SortedList(); string domainAndUsername = domain + @"\" + ADUsername; System.DirectoryServices.DirectoryEntry de = new System.DirectoryServices.DirectoryEntry(ADPath, domainAndUsername, ADPassword); src = new System.DirectoryServices.DirectorySearcher(de); src.Filter = "(SAMAccountName=" + ADUsername + ")"; src.PageSize = 10000;// 此参数可以任意设置,但不能不设置,如不设置读取AD数据为0~999条数据,设置后可以读取大于1000条数据。 // src.SizeLimit = 2000; src.SearchScope = System.DirectoryServices.SearchScope.Subtree; try { foreach (System.DirectoryServices.SearchResult res in src.FindAll()) { sl.Add(res.GetDirectoryEntry().Properties["Name"].Value, res.GetDirectoryEntry().InvokeGet("Description")); } } catch (Exception ex) { throw new Exception("Get Ad Info ", ex); } return(sl); }
public void ChangeColors() { m_nWhichColors = (m_nWhichColors+1)%3; System.Collections.SortedList aColors = new System.Collections.SortedList(); switch (m_nWhichColors) { case 0: aColors.Add(0.0, Color.FromArgb(0,255,0)); aColors.Add(0.5, Color.FromArgb(255,0,0)); aColors.Add(0.7, Color.FromArgb(255,0,0)); aColors.Add(0.75, Color.FromArgb(255,255,255)); aColors.Add(0.8, Color.FromArgb(100,0,255)); aColors.Add(1.0, Color.FromArgb(0,0,255)); break; case 1: aColors.Add(0.0, Color.FromArgb(255,255,0)); aColors.Add(0.5, Color.FromArgb(255,0,0)); aColors.Add(1.0, Color.FromArgb(0,0,0)); break; default: aColors.Add(0.0, Color.FromArgb(0,0,0)); aColors.Add(0.3, Color.FromArgb(0,0,0)); aColors.Add(0.7, Color.FromArgb(0,0,255)); aColors.Add(0.85, Color.FromArgb(0,255,0)); aColors.Add(1.0, Color.FromArgb(0,0,0)); break; } this.SetColorList(aColors); }
private void DoExport() { try { if (dataGridView1.DataSource != null && dataGridView1.Rows.Count > 0) { List <PfRetailAnalysisInfo> list = DataGridViewUtil.BindingListToList <PfRetailAnalysisInfo>(dataGridView1.DataSource); System.Collections.SortedList columns = new System.Collections.SortedList(); List <String> keys = new List <string>(); List <String> values = new List <string>(); foreach (DataGridViewColumn item in dataGridView1.Columns) { if (item.Visible) { keys.Add(item.DataPropertyName); values.Add(item.HeaderText); } } NPOIHelper.Keys = keys.ToArray(); NPOIHelper.Values = values.ToArray(); NPOIHelper.ExportExcel(DataGridViewUtil.ToDataTable(list), path); GlobalMessageBox.Show("导出完毕!"); } } catch (Exception ex) { ShowError(ex); } finally { UnLockPage(); } }
/// <summary> /// Gets all System data source names for the local machine. /// </summary> public System.Collections.SortedList GetSystemDataSourceNames() { System.Collections.SortedList dsnList = new System.Collections.SortedList(); // get system dsn's Microsoft.Win32.RegistryKey reg = (Microsoft.Win32.Registry.LocalMachine).OpenSubKey("Software"); if (reg != null) { reg = reg.OpenSubKey("ODBC"); if (reg != null) { reg = reg.OpenSubKey("ODBC.INI"); if (reg != null) { reg = reg.OpenSubKey("ODBC Data Sources"); if (reg != null) { // Get all DSN entries defined in DSN_LOC_IN_REGISTRY. foreach (string sName in reg.GetValueNames()) { dsnList.Add(sName, DataSourceType.System); } } try { reg.Close(); } catch { /* ignore this exception if we couldn't close */ } } } } return dsnList; }
/// <summary> /// Finds the first key in the sorted list that is >= val /// </summary> /// <param name="lst">Sorted list of values.</param> /// <param name="val">Key value to search for.</param> /// <returns>Returns the first index of an item with a key >= val. If none are found -1 is returned.</returns> private int FindFirst(System.Collections.SortedList lst, double val) { // do a binary search to find the first key occurance that is >= val int high = lst.Count - 1; int low = 0; int cur = low; // Initialize cur and curVal just in case there is only one value, which means low == high so the while loop will never execute. double curVal = (double)lst.GetKey(cur); while ((high - low > 2) && low != high) { cur = (high + low) / 2; curVal = (double)lst.GetKey(cur); if (curVal == val) { return(cur); } else if (curVal < val) { low = cur; } else // (curVal > val) { high = cur; } } return(low); }
protected void carregaDadosInterfaceEndereco(ref mdlComponentesGraficos.TextBox ctbEndereco, ref mdlComponentesGraficos.TextBox ctbCidade, ref mdlComponentesGraficos.TextBox ctbEstado, ref mdlComponentesGraficos.ComboBox cbPaises) { try { System.Collections.SortedList srlPaises = new System.Collections.SortedList(); foreach (mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow dtrwRowTbPaisesSorted in m_typDatSetTbPaises.tbPaises.Rows) { srlPaises.Add(dtrwRowTbPaisesSorted.nmPais, dtrwRowTbPaisesSorted); } mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow dtrwRowTbPaises; ctbEndereco.Text = m_strEnderecoEntrega; ctbCidade.Text = m_strCidadeEntrega; ctbEstado.Text = m_strEstadoEntrega; if (srlPaises != null) { for (int nCont = 0; nCont < srlPaises.Count; nCont++) { dtrwRowTbPaises = (mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow)srlPaises.GetByIndex(nCont); cbPaises.AddItem(dtrwRowTbPaises.nmPais, dtrwRowTbPaises.idPais); if (dtrwRowTbPaises.idPais == m_nIdPais) { cbPaises.SelectedIndex = nCont; m_strPaisEntrega = dtrwRowTbPaises.nmPais; } } } } catch (Exception err) { Object erro = err; m_cls_ter_tratadorErro.trataErro(ref erro); } }
protected void bindAttachments() { System.Collections.ArrayList selected = null; System.Collections.SortedList attachments = new System.Collections.SortedList(); bindAttachments(attachments, Session["sharpwebmail/read/message/temppath"]); if (!Session["sharpwebmail/read/message/temppath"].Equals(Session["sharpwebmail/send/message/temppath"])) { bindAttachments(attachments, Session["sharpwebmail/send/message/temppath"]); } if (this.newMessageWindowAttachmentsList.SelectedIndex != -1) { selected = new System.Collections.ArrayList(); foreach (System.Web.UI.WebControls.ListItem item in this.newMessageWindowAttachmentsList.Items) { if (item.Selected) { selected.Add(item.Value); } } } this.newMessageWindowAttachmentsList.DataSource = attachments; this.newMessageWindowAttachmentsList.DataTextField = "Value"; this.newMessageWindowAttachmentsList.DataValueField = "Key"; this.newMessageWindowAttachmentsList.DataBind(); if (selected != null) { foreach (System.String itemselected in selected) { this.AttachmentSelect(itemselected); } } }
protected void carregaDadosInterface(ref mdlComponentesGraficos.ListView lvImportadores, ref System.Windows.Forms.Button btEditar, ref System.Windows.Forms.Button btExcluir, ref System.Windows.Forms.Button btNovo) { try { System.Collections.SortedList srlImportadores = retornaImportadoresOrdenados(); // List View Item System.Windows.Forms.ListViewItem lvItemImportador; // Limpa os Items da List View lvImportadores.Items.Clear(); mdlDataBaseAccess.Tabelas.XsdTbImportadores.tbImportadoresRow dtrwRowTbImportadores; // Preenche os itens da List View for (int nCont = 0; nCont < srlImportadores.Count; nCont++) { dtrwRowTbImportadores = (mdlDataBaseAccess.Tabelas.XsdTbImportadores.tbImportadoresRow)srlImportadores.GetByIndex(nCont); if ((dtrwRowTbImportadores.RowState != System.Data.DataRowState.Deleted) && (!dtrwRowTbImportadores.IsnmCliNull())) { lvItemImportador = lvImportadores.Items.Add(dtrwRowTbImportadores.nmCli); lvItemImportador.Tag = dtrwRowTbImportadores.idImportador; if ((int)lvItemImportador.Tag == m_nIdImportador) { lvItemImportador.Selected = true; } } } if (lvImportadores.Items.Count == 0) { btEditar.Enabled = false; btExcluir.Enabled = false; if (m_bMostrarBaloes) { m_mgblBalaoToolTip = new mdlComponentesGraficos.MessageBalloon(); m_mgblBalaoToolTip.Caption = mdlConstantes.clsConstantes.BALLONTIP_DEFAULT_CAPTION; m_mgblBalaoToolTip.Content = mdlMensagens.clsRepositorioMensagens.GetMensagem(mdlMensagens.Mensagem.BALLOONTIP_mdlImportador_clsImportador_NovoImportador.ToString()); m_mgblBalaoToolTip.Icon = System.Drawing.SystemIcons.Information; m_mgblBalaoToolTip.CloseOnMouseClick = true; m_mgblBalaoToolTip.CloseOnDeactivate = true; m_mgblBalaoToolTip.CloseOnKeyPress = true; m_mgblBalaoToolTip.ShowBalloon((System.Windows.Forms.Control)btNovo); //m_mgblBalaoToolTip.StartPosition = System.Windows.Forms.FormStartPosition.Manual; //m_mgblBalaoToolTip.SetBounds((int)(btNovo.Bounds.Height / 2), (int)(btNovo.Bounds.Width / 2), m_mgblBalaoToolTip.Bounds.Width, m_mgblBalaoToolTip.Bounds.Height); } } else { btEditar.Enabled = true; btExcluir.Enabled = true; if (lvImportadores.SelectedItems.Count == 0) { lvItemImportador = lvImportadores.Items[0]; lvItemImportador.Selected = true; m_nIdImportador = (int)lvItemImportador.Tag; } } } catch (Exception err) { Object erro = err; m_cls_ter_tratadorErro.trataErro(ref erro); } }
public void InitializeSpread() { this.bsprGroupList.ClearHead(); this.bsprGroupList.UseFilter = false; this.bsprGroupList.FilterVisible = false; this.bsprGroupList.UseSpreadEdit = false; this.bsprGroupList.AutoGenerateColumns = false; this.bsprGroupList.UseGeneralContextMenu = false; this._slGroupColumnIndex = this._Initialization.InitializeColumnHeader(ref bsprGroupList, "SPC_MODEL_GROUP_POPUP", true, "HEADER_MODEL_GROUP"); this.bsprGroupList.ActiveSheet.Columns[(int)GroupColumnIndex.Modify].DataField = "_MODIFY"; this.bsprGroupList.AddHeadComplete(); this.bsprSPCModel.ClearHead(); this.bsprSPCModel.UseFilter = false; this.bsprSPCModel.FilterVisible = false; this.bsprSPCModel.UseSpreadEdit = false; this.bsprSPCModel.AutoGenerateColumns = false; this.bsprSPCModel.UseGeneralContextMenu = false; this._slGroupColumnIndex = this._Initialization.InitializeColumnHeader(ref bsprSPCModel, "SPC_MODEL_GROUP_POPUP", true, "HEADER_SPC_MODEL_LIST"); this.bsprSPCModel.AddHeadComplete(); this.bsprModelMapping.ClearHead(); this.bsprModelMapping.UseFilter = false; this.bsprModelMapping.FilterVisible = false; this.bsprModelMapping.UseSpreadEdit = false; this.bsprModelMapping.AutoGenerateColumns = false; this.bsprModelMapping.UseGeneralContextMenu = false; this._slGroupColumnIndex = this._Initialization.InitializeColumnHeader(ref bsprModelMapping, "SPC_MODEL_GROUP_POPUP", true, "HEADER_SPC_MODEL_MAPPING"); this.bsprModelMapping.AddHeadComplete(); }
private void vArmadoresRefresh(ref System.Windows.Forms.ListView lvArmadores) { lvArmadores.Items.Clear(); // Sorting System.Collections.SortedList sortListArmadores = new System.Collections.SortedList(); foreach (mdlDataBaseAccess.Tabelas.XsdTbArmadores.tbArmadoresRow dtrwArmador in m_typDatSetArmadores.tbArmadores.Rows) { if ((dtrwArmador.RowState != System.Data.DataRowState.Deleted) && (!dtrwArmador.IsstrNomeNull())) { if (!sortListArmadores.ContainsKey(dtrwArmador.strNome)) { sortListArmadores.Add(dtrwArmador.strNome, dtrwArmador); } } } // Insert for (int i = 0; i < sortListArmadores.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbArmadores.tbArmadoresRow dtrwArmadorInserir = (mdlDataBaseAccess.Tabelas.XsdTbArmadores.tbArmadoresRow)sortListArmadores.GetByIndex(i); System.Windows.Forms.ListViewItem lviInsert = lvArmadores.Items.Add(dtrwArmadorInserir.strNome); lviInsert.Tag = dtrwArmadorInserir.nIdArmador; if ((m_nIdSelect != -1) && (dtrwArmadorInserir.nIdArmador == m_nIdSelect)) { lviInsert.Selected = true; m_nIdSelect = -1; } } }
public SortedList() { Console.WriteLine("=> SortedList"); System.Collections.SortedList ages = new System.Collections.SortedList(); ages["Peter"] = 42; ages["John"] = 43; ages["Paul"] = 47; ages["Mathew"] = 37; System.Collections.Hashtable ages2 = new System.Collections.Hashtable() { { "Peter", 42 }, { "John", 43 }, { "Paul", 47 }, { "Mathew", 37 } }; foreach (System.Collections.DictionaryEntry e in ages2) { Console.WriteLine("Name: {0}, Age: {1}", (string)e.Key, (int)e.Value); } Console.WriteLine(); }
public AllObjectCollections( System.Collections.ArrayList prop0, System.Collections.IEnumerable prop1, System.Collections.ICollection prop2, System.Collections.IList prop3, System.Collections.Hashtable prop4, System.Collections.IDictionary prop5, System.Collections.Specialized.HybridDictionary prop6, System.Collections.Specialized.NameValueCollection prop7, System.Collections.BitArray prop8, System.Collections.Queue prop9, System.Collections.Stack prop10, System.Collections.SortedList prop11) { Prop0 = prop0; Prop1 = prop1; Prop2 = prop2; Prop3 = prop3; Prop4 = prop4; Prop5 = prop5; Prop6 = prop6; Prop7 = prop7; Prop8 = prop8; Prop9 = prop9; Prop10 = prop10; Prop11 = prop11; }
public void UnitPt_oCompareTo() { var objectSortedList = new System.Collections.SortedList(); Product pt1 = new Product(new int[] { 3, 4, 5 }); Product pt2 = new Product(pt1); Product pt3 = new Product(pt1); pt1.Rank = 10; pt2.Rank = 30; pt3.Rank = 20; objectSortedList.Add(pt1, 10); objectSortedList.Add(pt2, 30); objectSortedList.Add(pt3, 20); int expectedValue = 10; foreach (System.Collections.DictionaryEntry item in objectSortedList) { int actualIndex = (int)item.Value; Assert.AreEqual(expectedValue, actualIndex); expectedValue += 10; } Assert.AreEqual(40, expectedValue); }
protected void carregaDadosInterfacePaises(ref mdlComponentesGraficos.ComboBox cbPaises) { try { System.Collections.SortedList srlPaises = new System.Collections.SortedList(); foreach (mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow dtrwRowTbPaisesSorted in m_typDatSetTbPaises.tbPaises.Rows) { srlPaises.Add(dtrwRowTbPaisesSorted.nmPais, dtrwRowTbPaisesSorted); } mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow dtrwRowTbPaises; if (srlPaises != null) { for (int nCont = 0; nCont < srlPaises.Count; nCont++) { dtrwRowTbPaises = (mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow)srlPaises.GetByIndex(nCont); cbPaises.AddItem(dtrwRowTbPaises.nmPais, dtrwRowTbPaises.idPais); } } } catch (Exception err) { Object erro = err; m_cls_ter_tratadorErro.trataErro(ref erro); } }
private void replyTextMessage(string messageText) { //messageText = messageText + "\n\nrequest_signature=[" + request_signature + "], signature=[" + signature + "]"; System.Collections.IList messages = new System.Collections.ArrayList(); { var message_data = new System.Collections.SortedList(); message_data["type"] = "text"; message_data["text"] = messageText; messages.Add(message_data); } var content = new Dictionary <string, object>(); content["replyToken"] = this.replyToken; content["messages"] = messages; // リプライ { string json = Newtonsoft.Json.JsonConvert.SerializeObject(content); var request_body = new StringContent(json, Encoding.UTF8, "application/json"); var authorization = String.Format("Bearer {0}", Constants.CHANNEL_ACCESS_TOKEN); System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); client.DefaultRequestHeaders.Add("Authorization", authorization); client.PostAsync("https://api.line.me/v2/bot/message/reply", request_body); } }
// Returns a list of data source names from the local machine. public System.Collections.SortedList GetAllDataSourceNames() { // Get the list of user DSN's first. System.Collections.SortedList dsnList = GetUserDataSourceNames(); // Get list of System DSN's and add them to the first list. System.Collections.SortedList systemDsnList = GetSystemDataSourceNames(); for (int i = 0; i < systemDsnList.Count; i++) { string sName = systemDsnList.GetKey(i) as string; DataSourceType type = (DataSourceType)systemDsnList.GetByIndex(i); try { // This dsn to the master list dsnList.Add(sName, type); } catch { // An exception can be thrown if the key being added is a duplicate so // we just catch it here and have to ignore it. } } return(dsnList); }
protected void Page_Load(object sender, EventArgs e) { GooglePageBase google = Page as GooglePageBase; DataQuery query = new DataQuery(); query.Ids = "ga:" + google.Settings.Current.Id; query.Metrics = "ga:pageviews"; query.Dimensions = "ga:browser,ga:browserVersion"; query.Sort = "ga:browser,ga:pageviews"; query.GAStartDate = DateTime.Now.AddMonths(-1).AddDays(-1).ToString("yyyy-MM-dd"); query.GAEndDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"); if (google.Referringpage != null) { query.Filters = "ga:pagePath==" + google.Referringpage; } DataFeed actual = google.Analytics.Query(query); System.Data.DataTable browsers = new System.Data.DataTable("Browser"); browsers.Columns.Add("Browser"); browsers.Columns.Add("Views", typeof(int)); System.Data.DataTable versions = new System.Data.DataTable("BrowserVersion"); versions.Columns.Add("Browser"); versions.Columns.Add("Version"); versions.Columns.Add("Views", typeof(int)); System.Collections.SortedList values = new System.Collections.SortedList(); foreach (DataEntry entry in actual.Entries) { string browser = entry.Dimensions[0].Value.ToString(); string version = entry.Dimensions[1].Value.ToString(); int visits = int.Parse(entry.Metrics[0].Value); if (values.ContainsKey(browser)) { int current = int.Parse(values[browser].ToString()); current += int.Parse(entry.Metrics[0].Value); values[browser] = current; } else { values.Add(browser, int.Parse(entry.Metrics[0].Value)); } versions.Rows.Add(new object[] { browser, version, visits }); } foreach (String key in values.Keys) { browsers.Rows.Add(new object[] { key, int.Parse(values[key].ToString()) }); } this.pie_Browsers.GviEnableEvents = true; this.pie_Browsers.ChartData(browsers); this.tbl_Versions.ChartData(versions); }
private void DoExport() { try { List <CheckStoreSummary> unableStore = new List <CheckStoreSummary>(); List <CheckStoreSummary> stores = new List <CheckStoreSummary>(); List <CheckStoreSummary> list = (List <CheckStoreSummary>) this.dataGridView1.DataSource; System.Collections.SortedList columns = new System.Collections.SortedList(); List <String> keys = new List <string>(); List <String> values = new List <string>(); foreach (DataGridViewColumn item in dataGridView1.Columns) { if (item.Visible) { keys.Add(item.DataPropertyName); values.Add(item.HeaderText); } } NPOIHelper.Keys = keys.ToArray(); NPOIHelper.Values = values.ToArray(); NPOIHelper.ExportExcel(DataGridViewUtil.ToDataTable(list), path); GlobalMessageBox.Show("导出完毕!"); } catch (Exception ex) { ShowError(ex); } finally { UnLockPage(); } }
/// <summary> /// Gets all User data source names for the local machine. /// </summary> public System.Collections.SortedList GetUserDataSourceNames() { System.Collections.SortedList dsnList = new System.Collections.SortedList(); // get user dsn's Microsoft.Win32.RegistryKey reg = (Microsoft.Win32.Registry.LocalMachine).OpenSubKey("Software"); if (reg != null) { reg = reg.OpenSubKey("ODBC"); if (reg != null) { reg = reg.OpenSubKey("ODBCINST.INI"); if (reg != null) { reg = reg.OpenSubKey("ODBC Drivers"); if (reg != null) { // Get all DSN entries defined in DSN_LOC_IN_REGISTRY. foreach (string sName in reg.GetValueNames()) { dsnList.Add(sName, DataSourceType.User); } } try { reg.Close(); } catch { /* ignore this exception if we couldn't close */ } } } } return(dsnList); }
/// <summary>Parses message and dumps contents to props, with keys in the /// ZYX[a]-b[c]-d-e style. /// </summary> public static bool parseMessage(System.Collections.Specialized.NameValueCollection props, System.Collections.ArrayList msgMask, System.String message) { bool ok = false; if (message != null) { if (props == null) { props = new System.Collections.Specialized.NameValueCollection(); } SupportClass.Tokenizer messageTokenizer = new SupportClass.Tokenizer(message, segmentSeparators); if (messageTokenizer.HasMoreTokens()) { System.String firstSegment = messageTokenizer.NextToken(); NuGenEncodingCharacters encodingChars = new NuGenEncodingCharacters('0', "0000"); if (parseMSHSegmentWhole(props, msgMask, encodingChars, firstSegment)) { ok = true; System.Collections.SortedList segmentId2nextRepIdx = new System.Collections.SortedList(); segmentId2nextRepIdx[new System.Text.StringBuilder("MSH").ToString()] = 1; // in case we find another MSH segment, heh. while (messageTokenizer.HasMoreTokens()) { parseSegmentWhole(props, segmentId2nextRepIdx, msgMask, encodingChars, messageTokenizer.NextToken()); } } } } return(ok); }
IActivity getMatchingLogActivity(int index, int count) { //Note: the activity list may not be in perfect order, sort the tail if (activities == null || activities.Count != count) { activities = new System.Collections.SortedList(count); int logIndex = Plugin.Instance.Application.Logbook.Activities.Count - 1; for (int i = 0; i < count; i++) { //TBD: Only use My Activities and ignore My Friends Activities? while (logIndex >= 0 && activities.ContainsKey(Plugin.Instance.Application.Logbook.Activities[logIndex].StartTime)) { logIndex--; } if (logIndex > 0) { IActivity activity = Plugin.Instance.Application.Logbook.Activities[logIndex]; activities.Add(activity.StartTime, activity); } else { activities.Add(DateTime.MinValue, null); } } } return((IActivity)activities.GetByIndex(index)); }
private void initConfig() { Application["product"] = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name; Application["version"] = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; resources = new System.Resources.ResourceManager("SharpWebMail", System.Reflection.Assembly.GetExecutingAssembly()); Application["resources"] = resources; System.Collections.Hashtable config = (System.Collections.Hashtable)System.Configuration.ConfigurationSettings.GetConfig("sharpwebmail"); foreach (System.Collections.DictionaryEntry item in config) { Application.Add(item.Key.ToString(), item.Value); } config = null; if (Application["sharpwebmail/send/addressbook"] != null) { Application["sharpwebmail/general/addressbooks"] = true; } if ((bool)Application["sharpwebmail/read/message/useserverencoding"]) { anmar.SharpMimeTools.SharpMimeHeader.EncodingDefault = System.Text.Encoding.Default; } TestAvailableCultures(); System.Collections.SortedList availablecultures_values = new System.Collections.SortedList(availablecultures.Count); foreach (System.Collections.DictionaryEntry item in availablecultures) { availablecultures_values.Add(item.Value, item.Key); } Application["AvailableCultures"] = availablecultures_values; initInvariantCulture(); Application["sharpwebmail/read/message/temppath"] = parseTempFolder(Server.MapPath("/"), Application["sharpwebmail/read/message/temppath"]); Application["sharpwebmail/send/message/temppath"] = parseTempFolder(Server.MapPath("/"), Application["sharpwebmail/send/message/temppath"]); }
/// <summary> Check the hits for duplicates.</summary> /// <param name="hits"> /// </param> private void CheckHits(ScoreDoc[] hits, System.String prefix) { if (hits != null) { System.Collections.IDictionary idMap = new System.Collections.SortedList(); for (int docnum = 0; docnum < hits.Length; ++docnum) { System.Int32 luceneId; luceneId = (System.Int32)hits[docnum].doc; if (idMap.Contains(luceneId)) { System.Text.StringBuilder message = new System.Text.StringBuilder(prefix); message.Append("Duplicate key for hit index = "); message.Append(docnum); message.Append(", previous index = "); message.Append(((System.Int32)idMap[luceneId]).ToString()); message.Append(", Lucene ID = "); message.Append(luceneId); Log(message.ToString()); } else { idMap[luceneId] = (System.Int32)docnum; } } } }
/// <summary> /// Given the 2 maps fills a document for 1 word. /// </summary> private static int Index(System.Collections.IDictionary word2Nums, System.Collections.IDictionary num2Words, System.String g, Document doc) { var keys = (System.Collections.IList)word2Nums[g]; // get list of key#'s var i2 = keys.GetEnumerator(); var already = new System.Collections.SortedList(); // keep them sorted // pass 1: fill up 'already' with all words while (i2.MoveNext()) // for each key# { foreach (var item in ((System.Collections.IList)num2Words[i2.Current]).Cast <object>().Where(item => already.Contains(item) == false)) { already.Add(item, item); } } var num = 0; already.Remove(g); // of course a word is it's own syn var it = already.GetEnumerator(); while (it.MoveNext()) { var cur = (String)it.Key; // don't store things like 'pit bull' -> 'american pit bull' if (!IsDecent(cur)) { continue; } num++; doc.Add(new Field(F_SYN, cur, Field.Store.YES, Field.Index.NO)); } return(num); }
public InterpolatorColor(System.Collections.SortedList colorKeyFrames) { //_colors = a_colorKeyFrames; _interpolators = new List <Interpolator>(); for (int i = 0; i < 4; i++) { Interpolator ip = new Interpolator(); _interpolators.Add(ip); System.Collections.SortedList a = new System.Collections.SortedList(); for (int nClrNum = 0; nClrNum < colorKeyFrames.Count; nClrNum++) { Color clr = (Color)colorKeyFrames.GetByIndex(nClrNum); double dVal = 0; if (i == 0) { dVal = clr.A; } else if (i == 1) { dVal = clr.R; } else if (i == 2) { dVal = clr.G; } else if (i == 3) { dVal = clr.B; } a.Add(colorKeyFrames.GetKey(nClrNum), dVal); } ip.KeyFramesList = a; } }
private void vGeraPersonalizavel() { System.Text.StringBuilder strbPersonalizavel = new System.Text.StringBuilder(); System.Collections.SortedList sortLstDSEPE = new System.Collections.SortedList(new mdlComponentesColecoes.clsComparerNumbersTexts()); // Ordenando for (int i = 0; i < m_typDatSetDSEsPEs.tbDSEsPEs.Rows.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbDSEsPEs.tbDSEsPEsRow dtrwDSEPE = (mdlDataBaseAccess.Tabelas.XsdTbDSEsPEs.tbDSEsPEsRow)m_typDatSetDSEsPEs.tbDSEsPEs.Rows[i]; if ((dtrwDSEPE.RowState != System.Data.DataRowState.Deleted) && (dtrwDSEPE.nIdExportador == m_nIdExportador) && (dtrwDSEPE.strIdPE == m_strIdPe)) { sortLstDSEPE.Add(GetDSENumero(dtrwDSEPE.nIdDSE), dtrwDSEPE); } } // Inserindo for (int i = 0; i < sortLstDSEPE.Count; i++) { mdlDataBaseAccess.Tabelas.XsdTbDSEsPEs.tbDSEsPEsRow dtrwDSEPE = (mdlDataBaseAccess.Tabelas.XsdTbDSEsPEs.tbDSEsPEsRow)sortLstDSEPE.GetByIndex(i); if (strbPersonalizavel.ToString() != "") { strbPersonalizavel.Append(" , "); } strbPersonalizavel.Append(sortLstDSEPE.GetKey(i).ToString()); } m_strPersonalizavel = strbPersonalizavel.ToString(); if (m_typDatSetPes.tbPEs.Rows.Count > 0) { mdlDataBaseAccess.Tabelas.XsdTbPes.tbPEsRow dtrwPE = (mdlDataBaseAccess.Tabelas.XsdTbPes.tbPEsRow)m_typDatSetPes.tbPEs.Rows[0]; dtrwPE.mstrDSE = m_strPersonalizavel; } }
// GET api/<controller> public IEnumerable <DBModel.Person_FaceInfoModel> Get() { var m111 = YEasyModel.ModelDAL.SelectNotExists <DBModel.ST_PersonModel, DBModel.Person_FaceInfoModel>( (t1, t2) => t1.Person_ID == t2.Person_ID, t1 => t1.Person_Name != "", f => f.Person_Name + " as myName"); //调用存储过程查询CT_Comsume表最大ID DBModel.Proc.CT_Comsume_GetMaxIdModel proc = new DBModel.Proc.CT_Comsume_GetMaxIdModel(); int iReturn = YEasyModel.ProcedureUtil.Execute <DBModel.Proc.CT_Comsume_GetMaxIdModel>(proc); //调用存储过程删除Detail_ID = 4的记录 DBModel.Proc.CT_ComsumeDetail_DeleteModel de = new DBModel.Proc.CT_ComsumeDetail_DeleteModel(); de.Detail_ID = 4; int iReturn2 = YEasyModel.ProcedureUtil.Execute <DBModel.Proc.CT_ComsumeDetail_DeleteModel>(de); //多表join联合查询 List <DBModel.Person_FaceInfoModel> person_FaceInfoModel = YEasyModel.ModelDAL.Join <DBModel.Person_FaceInfoModel, DBModel.Person_FaceInfoModel, DBModel.ST_PersonModel>((t1, t2) => YEasyModel.SqlColumnUtil.IsNull(t1.Person_ID, 0) == t2.Person_ID, (t1, t2) => t1.Remark == null, null, (t1, t2) => t1.Person_ID, (t1, t2) => t1.Person_No, (t1, t2) => t1.FacePath); //YEasyModel.ModelDAL.JoinLeft<DBModel.Person_FaceInfoModel, DBModel.ST_PersonModel, DBModel.ST_PersonModel > ((t1, t2,t3) => t1.Person_ID == t2.Person_ID&& t3.Person_ID==int.Parse(t1.Remark)&& t1.Remark!=null); var dt = YEasyModel.ModelDAL.SelectForDataTable <DBModel.Person_FaceInfoModel>(); var list = YEasyModel.ModelUtil.DataTableParse <Models.FaceExt>(dt); System.Collections.SortedList ss = new System.Collections.SortedList(); //查询 Person_FaceInfoModel 对应表的所有记录 return(YEasyModel.ModelDAL.Select <DBModel.Person_FaceInfoModel>()); }
public InterpolatorColor(System.Collections.SortedList colorKeyFrames) { //_colors = a_colorKeyFrames; _interpolators = new List<Interpolator>(); for (int i = 0; i < 4; i++) { Interpolator ip = new Interpolator(); _interpolators.Add(ip); System.Collections.SortedList a = new System.Collections.SortedList(); for (int nClrNum = 0; nClrNum < colorKeyFrames.Count; nClrNum++) { Color clr = (Color)colorKeyFrames.GetByIndex(nClrNum); double dVal = 0; if (i == 0) dVal = clr.A; else if (i == 1) dVal = clr.R; else if (i == 2) dVal = clr.G; else if (i == 3) dVal = clr.B; a.Add(colorKeyFrames.GetKey(nClrNum), dVal); } ip.KeyFramesList = a; } }
public SADLActivity(string NewName) { Name = NewName; InputEdges = new System.Collections.SortedList(); InputSchemas = new System.Collections.SortedList(); OutputEdges = new System.Collections.SortedList(); OutputSchemas = new System.Collections.SortedList(); }
///<summary> /// ///</summary> public virtual void Randomize() { System.Random Rnd = new System.Random(); System.Collections.SortedList List = new System.Collections.SortedList(); foreach (System.Object Value in this) { List.Add(Rnd.Next(), Value); } this.Clear(); this.AddRange(List.Values); }
public void ChangeSizes() { m_nWhichSizes = (m_nWhichSizes+1)%3; System.Collections.SortedList aSizes = new System.Collections.SortedList(); switch (m_nWhichSizes) { case 0: aSizes.Add(0.0, 1.0); aSizes.Add(0.6, 1.0); aSizes.Add(0.8, 0.1); aSizes.Add(1.0, 0.9); break; case 1: aSizes.Add(0.0, 1.0); aSizes.Add(1.0, 1.0); break; default: aSizes.Add(0.0, 0.3); aSizes.Add(1.0, 0.01); aSizes.Add(1.1, 0.01); break; } this.SetSizeList(aSizes); }
private void AdvertTimer_Tick(object sender, ElapsedEventArgs e) { try { int i = 0; uint advertchannel = TheMySqlManager.advertchannel(Settings.botid); Random RandomClass = new Random(); string advertstr = "", str2 = "", endm = TheMySqlManager.advertendmessage().Trim(); if (TheTradeHandler.AmITrading() || (TheInventory.GettingInventoryItems == true)) { this.AdvertTimer.Interval = (1 * 1000);// +RandomClass.Next(0, (60 * 60 * 1000)); ;//m*s*us=1 hour TheLogger.Debug("Advert delayed due to current trade\n"); return; } if (advertchannel != 99999999) { //this.AdvertTimer.Interval = (15 * 60 * 1000) + RandomClass.Next(0, (60 * 60 * 1000)); ;//m*s*us=1 hour //this.AdvertTimer.Interval=60* i = TheMySqlManager.minadverttime() * 1000; i += (RandomClass.Next(0, TheMySqlManager.randomadvertdelay()) * 1000); if (i < 900000) i = 900000;//minimum 15 minute delay this.AdvertTimer.Interval = i; } else { if (MainClass.serverName == "test") { this.AdvertTimer.Interval = 1000; } } TheLogger.Debug("New AdvertTimer.Interval: " + this.AdvertTimer.Interval + "\n"); if (advertchannel != 99999999 && TheMySqlManager.lastadverttime(Settings.botid) < TheMySqlManager.minadverttime() && MainClass.serverName != "test") return; //Start the advertising here, if it's set to true... //Assumptions: 140 characters max length //Need to get advert_rates from the database for this bot to see how the weights are distributed if (TheMySqlManager.advertise()) { //decide if we should do a text message or a _goods_ message //get the rate for text adverts, it's a number between 0 and 1 //then get a random number between 0 and one, if the random number is less than the advert rate, do the advert //otherwise, do a _goods_ advert (buying and selling...) double advertTextRate = TheMySqlManager.getAdvertTextRate(); double sellRate = TheMySqlManager.getSellRate(); Random randomDouble = new Random(); double randomRate = randomDouble.NextDouble(); if (randomRate < advertTextRate) { //do a text advert //get a random row from the adverts table and use it as the advertisement //select * from adverts where botid = 2 order by rand() LIMIT 1; advertstr = TheMySqlManager.getTextAdvert(); } else { //do a goods advert (buying and selling) //get the selling rate, it's between 0 and 1 //get a random number between 0 and 1, if the rate is less than the selling rate, do a "selling" advert //otherwise, do a "buying" advert System.Collections.ArrayList MyInventoryList = TheInventory.GetInventoryList(); System.Collections.ArrayList MySellingItemsList = TheMySqlManager.GetSellingList(1); // sum up all inventory items if the items are on sale System.Collections.SortedList TheInventoryList = new System.Collections.SortedList(); System.Collections.ArrayList MyWantedItemsList = TheMySqlManager.GetWantedList(1); //add up the inventory stuff foreach (Inventory.inventory_item MyInventoryItem in MyInventoryList) { if (TheInventoryList.Contains(MyInventoryItem.SqlID) && MyInventoryItem.pos < 36) { Inventory.inventory_item TempInventoryItem = (Inventory.inventory_item)TheInventoryList[MyInventoryItem.SqlID]; TempInventoryItem.quantity += MyInventoryItem.quantity; TheInventoryList[MyInventoryItem.SqlID] = TempInventoryItem; } else { if (MyInventoryItem.pos < 36) { TheInventoryList.Add(MyInventoryItem.SqlID, MyInventoryItem); } } } randomRate = randomDouble.NextDouble(); if (randomRate < sellRate) { //selling advertstr = "Selling:"; foreach (TradeHandler.SellingItem MySellingItem in MySellingItemsList) { if (TheInventoryList.Contains(MySellingItem.KnownItemsSqlID)) { Inventory.inventory_item MyInventoryItem = (Inventory.inventory_item)TheInventoryList[MySellingItem.KnownItemsSqlID]; if (MySellingItem.pricesale > 0) { uint tempAmount = 0; if ((TheMySqlManager.ReservedAmount(MyInventoryItem.SqlID)) < MyInventoryItem.quantity) { tempAmount = MyInventoryItem.quantity; tempAmount = tempAmount - (TheMySqlManager.ReservedAmount(MyInventoryItem.SqlID)); } else { continue; } str2 = tempAmount.ToString() + " " + MyInventoryItem.name + ":" + MySellingItem.pricesale.ToString() + "gc"; if (advertstr.Length + str2.Length + endm.Length < 140) { if (advertstr.Length > 8) advertstr += ", "; advertstr += str2; } } } } if (advertstr.Length > 8) { advertstr += "|" + endm; } else { advertstr = ""; } } else { //buying advertstr = "Buying:"; foreach (TradeHandler.WantedItem MyWantedItem in MyWantedItemsList) { if (TheInventoryList.Contains(MyWantedItem.KnownItemsSqlID)) { Inventory.inventory_item MyInventoryItem = (Inventory.inventory_item)TheInventoryList[MyWantedItem.KnownItemsSqlID]; if (MyWantedItem.pricepurchase > 0 && MyInventoryItem.quantity < MyWantedItem.maxquantity) { str2 = TheMySqlManager.GetKnownItemsname(MyWantedItem.KnownItemsSqlID) + ":" + MyWantedItem.pricepurchase.ToString() + "gc"; if (advertstr.Length + str2.Length + endm.Length < 140) { if (advertstr.Length > 7) advertstr += ", "; advertstr += str2; } } } else { if (MyWantedItem.pricepurchase > 0) { str2 = TheMySqlManager.GetKnownItemsname(MyWantedItem.KnownItemsSqlID) + ":" + MyWantedItem.pricepurchase.ToString() + "gc"; if (advertstr.Length + str2.Length + endm.Length < 140) { if (advertstr.Length > 7) advertstr += ", "; advertstr += str2; } } } } if (advertstr.Length > 7) { advertstr += "|" + endm; } else { advertstr = ""; } } } } if (advertstr != "") { TheTCPWrapper.Send(CommandCreator.RAW_TEXT("#jc " + advertchannel.ToString())); TheTCPWrapper.Send(CommandCreator.RAW_TEXT("@" + advertstr)); TheTCPWrapper.Send(CommandCreator.RAW_TEXT("#lc " + advertchannel.ToString())); TheMySqlManager.advertlog("@@" + advertchannel.ToString() + " " + advertstr); string sql = "UPDATE bots SET lastadverttime = NOW() WHERE botid = " + Settings.botid; TheMySqlManager.raw_sql(sql); } advertstr = ""; } catch (Exception exception) { TheErrorHandler.writeErrorMessage("Exception raised in the advert handler..." + exception); } finally { } }
public Source(String file) { File = file; Modules = new System.Collections.SortedList(); }
public static void Main(System.String[] args) { // get command line arguments String prologFilename = null; // name of file "wn_s.pl" String indexDir = null; if (args.Length == 2) { prologFilename = args[0]; indexDir = args[1]; } else { Usage(); Environment.Exit(1); } // ensure that the prolog file is readable if (!(new FileInfo(prologFilename)).Exists) { err.WriteLine("Error: cannot read Prolog file: " + prologFilename); Environment.Exit(1); } // exit if the target index directory already exists if (Directory.Exists((new FileInfo(indexDir)).FullName)) { err.WriteLine("Error: index directory already exists: " + indexDir); err.WriteLine("Please specify a name of a non-existent directory"); Environment.Exit(1); } o.WriteLine("Opening Prolog file " + prologFilename); var fis = new FileStream(prologFilename, FileMode.Open, FileAccess.Read); var br = new StreamReader(new StreamReader(fis, System.Text.Encoding.Default).BaseStream, new StreamReader(fis, System.Text.Encoding.Default).CurrentEncoding); String line; // maps a word to all the "groups" it's in System.Collections.IDictionary word2Nums = new System.Collections.SortedList(); // maps a group to all the words in it System.Collections.IDictionary num2Words = new System.Collections.SortedList(); // number of rejected words var ndecent = 0; // status output var mod = 1; var row = 1; // parse prolog file o.WriteLine("[1/2] Parsing " + prologFilename); while ((line = br.ReadLine()) != null) { // occasional progress if ((++row) % mod == 0) // periodically print out line we read in { mod *= 2; o.WriteLine("\t" + row + " " + line + " " + word2Nums.Count + " " + num2Words.Count + " ndecent=" + ndecent); } // syntax check if (!line.StartsWith("s(")) { err.WriteLine("OUCH: " + line); Environment.Exit(1); } // parse line line = line.Substring(2); var comma = line.IndexOf(','); var num = line.Substring(0, comma); var q1 = line.IndexOf('\''); line = line.Substring(q1 + 1); var q2 = line.IndexOf('\''); var word = line.Substring(0, q2).ToLower().Replace("''", "'"); // make sure is a normal word if (!IsDecent(word)) { ndecent++; continue; // don't store words w/ spaces } // 1/2: word2Nums map // append to entry or add new one var lis = (System.Collections.IList) word2Nums[word]; if (lis == null) { lis = new List<String> {num}; word2Nums[word] = lis; } else lis.Add(num); // 2/2: num2Words map lis = (System.Collections.IList) num2Words[num]; if (lis == null) { lis = new List<String> { word }; num2Words[num] = lis; } else lis.Add(word); } // close the streams fis.Close(); br.Close(); // create the index o.WriteLine("[2/2] Building index to store synonyms, " + " map sizes are " + word2Nums.Count + " and " + num2Words.Count); Index(indexDir, word2Nums, num2Words); }
/// <summary> /// Returns a portion of the list whose keys are greater that the lowerLimit parameter less than the upperLimit parameter. /// </summary> /// <param name="l">The list where the portion will be extracted.</param> /// <param name="limit">The start element of the portion to extract.</param> /// <param name="limit">The end element of the portion to extract.</param> /// <returns>The portion of the collection.</returns> public static System.Collections.SortedList SubMap(System.Collections.SortedList list, System.Object lowerLimit, System.Object upperLimit) { System.Collections.Comparer comparer = System.Collections.Comparer.Default; System.Collections.SortedList newList = new System.Collections.SortedList(); if (list != null) { if ((list.Count > 0) && (!(lowerLimit.Equals(upperLimit)))) { int index = 0; while (comparer.Compare(list.GetKey(index), lowerLimit) < 0) index++; for (; index < list.Count; index++) { if (comparer.Compare(list.GetKey(index), upperLimit) >= 0) break; newList.Add(list.GetKey(index), list[list.GetKey(index)]); } } } return newList; }
public CharInfo() { Moving = false; my_buffs = new System.Collections.SortedList(); }
/// <summary> Parse a branch /// /// </summary> /// <param name="v"> Description of Parameter /// </param> /// <param name="buffer"> Description of Parameter /// </param> /// <param name="container"> Description of Parameter /// </param> /// <param name="parent"> Description of Parameter /// </param> /// <param name="chiral"> Description of Parameter /// </param> /// <param name="doubleBondConfiguration"> Description of Parameter /// </param> /// <param name="atomsInOrderOfSmiles"> Description of Parameter /// </param> private void parseChain(System.Collections.ArrayList v, System.Text.StringBuilder buffer, IAtomContainer container, IAtom parent, bool chiral, bool[] doubleBondConfiguration, System.Collections.ArrayList atomsInOrderOfSmiles) { int positionInVector = 0; IAtom atom; //System.out.println("in parse chain. Size of tree: " + v.size()); for (int h = 0; h < v.Count; h++) { System.Object o = v[h]; if (o is IAtom) { atom = (IAtom)o; if (parent != null) { parseBond(buffer, atom, parent, container); } else { if (chiral && BondTools.isStereo(container, atom)) { parent = (IAtom)((System.Collections.ArrayList)v[1])[0]; } } parseAtom(atom, buffer, container, chiral, doubleBondConfiguration, parent, atomsInOrderOfSmiles, v); //System.out.println("in parseChain after parseAtom()"); /* * The principle of making chiral smiles is quite simple, although the code is * pretty uggly. The Atoms connected to the chiral center are put in sorted[] in the * order they have to appear in the smiles. Then the Vector v is rearranged according * to sorted[] */ if (chiral && BondTools.isStereo(container, atom) && container.getBond(parent, atom) != null) { //System.out.println("in parseChain in isChiral"); IAtom[] sorted = null; System.Collections.IList chiralNeighbours = container.getConnectedAtomsVector(atom); if (BondTools.isTetrahedral(container, atom, false) > 0) { sorted = new IAtom[3]; } if (BondTools.isTetrahedral(container, atom, false) == 1) { if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[1] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } } } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UP) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[1] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } } } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UNDEFINED || container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_NONE) { bool normalBindingIsLeft = false; for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0) { if (BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom)) { normalBindingIsLeft = true; break; } } } } for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (normalBindingIsLeft) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { sorted[1] = (IAtom)chiralNeighbours[i]; } } else { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP) { sorted[1] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { sorted[2] = (IAtom)chiralNeighbours[i]; } } } } } } if (BondTools.isTetrahedral(container, atom, false) == 2) { if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UP) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[1] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } } } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { double angle1 = 0; double angle2 = 0; IAtom atom1 = null; IAtom atom2 = null; for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { if (angle1 == 0) { angle1 = BondTools.giveAngle(atom, parent, (IAtom)chiralNeighbours[i]); atom1 = (IAtom)chiralNeighbours[i]; } else { angle2 = BondTools.giveAngle(atom, parent, (IAtom)chiralNeighbours[i]); atom2 = (IAtom)chiralNeighbours[i]; } } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[1] = (IAtom)chiralNeighbours[i]; } } } if (angle1 < angle2) { sorted[0] = atom2; sorted[2] = atom1; } else { sorted[0] = atom1; sorted[2] = atom2; } } } if (BondTools.isTetrahedral(container, atom, false) == 3) { if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UP) { //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.TreeMap' and 'System.Collections.SortedList' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'" //UPGRADE_TODO: Constructor 'java.util.TreeMap.TreeMap' was converted to 'System.Collections.SortedList' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapTreeMap'" System.Collections.SortedList hm = new System.Collections.SortedList(); for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { hm[(double)BondTools.giveAngle(atom, parent, ((IAtom)chiralNeighbours[i]))] = (System.Int32)i; } } //UPGRADE_TODO: Method 'java.util.TreeMap.values' was converted to 'System.Collections.SortedList.Values' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapvalues'" System.Object[] ohere = SupportClass.ICollectionSupport.ToArray(hm.Values); for (int i = ohere.Length - 1; i > -1; i--) { sorted[i] = ((IAtom)chiralNeighbours[((System.Int32)ohere[i])]); } } if (container.getBond(parent, atom).Stereo == 0) { double angle1 = 0; double angle2 = 0; IAtom atom1 = null; IAtom atom2 = null; for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { if (angle1 == 0) { angle1 = BondTools.giveAngle(atom, parent, (IAtom)chiralNeighbours[i]); atom1 = (IAtom)chiralNeighbours[i]; } else { angle2 = BondTools.giveAngle(atom, parent, (IAtom)chiralNeighbours[i]); atom2 = (IAtom)chiralNeighbours[i]; } } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } } } if (angle1 < angle2) { sorted[1] = atom2; sorted[2] = atom1; } else { sorted[1] = atom1; sorted[2] = atom2; } } } if (BondTools.isTetrahedral(container, atom, false) == 4) { if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.TreeMap' and 'System.Collections.SortedList' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'" //UPGRADE_TODO: Constructor 'java.util.TreeMap.TreeMap' was converted to 'System.Collections.SortedList' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapTreeMap'" System.Collections.SortedList hm = new System.Collections.SortedList(); for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { hm[(double)BondTools.giveAngle(atom, parent, ((IAtom)chiralNeighbours[i]))] = (System.Int32)i; } } //UPGRADE_TODO: Method 'java.util.TreeMap.values' was converted to 'System.Collections.SortedList.Values' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapvalues'" System.Object[] ohere = SupportClass.ICollectionSupport.ToArray(hm.Values); for (int i = ohere.Length - 1; i > -1; i--) { sorted[i] = ((IAtom)chiralNeighbours[((System.Int32)ohere[i])]); } } if (container.getBond(parent, atom).Stereo == 0) { double angle1 = 0; double angle2 = 0; IAtom atom1 = null; IAtom atom2 = null; for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { if (angle1 == 0) { angle1 = BondTools.giveAngle(atom, parent, (IAtom)chiralNeighbours[i]); atom1 = (IAtom)chiralNeighbours[i]; } else { angle2 = BondTools.giveAngle(atom, parent, (IAtom)chiralNeighbours[i]); atom2 = (IAtom)chiralNeighbours[i]; } } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } } } if (angle1 < angle2) { sorted[1] = atom2; sorted[0] = atom1; } else { sorted[1] = atom1; sorted[0] = atom2; } } } if (BondTools.isTetrahedral(container, atom, false) == 5) { if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { sorted[1] = (IAtom)chiralNeighbours[i]; } } } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UP) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0) { sorted[1] = (IAtom)chiralNeighbours[i]; } } } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UNDEFINED || container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_NONE) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP) { sorted[1] = (IAtom)chiralNeighbours[i]; } } } } } if (BondTools.isTetrahedral(container, atom, false) == 6) { if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UP) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { sorted[1] = (IAtom)chiralNeighbours[i]; } } } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0) { sorted[1] = (IAtom)chiralNeighbours[i]; } } } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UNDEFINED || container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_NONE) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[2] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { sorted[1] = (IAtom)chiralNeighbours[i]; } } } } } if (BondTools.isSquarePlanar(container, atom)) { sorted = new IAtom[3]; //This produces a U=SP1 order in every case //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.TreeMap' and 'System.Collections.SortedList' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'" //UPGRADE_TODO: Constructor 'java.util.TreeMap.TreeMap' was converted to 'System.Collections.SortedList' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapTreeMap'" System.Collections.SortedList hm = new System.Collections.SortedList(); for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent && !isBondBroken((IAtom)chiralNeighbours[i], atom)) { hm[(double)BondTools.giveAngle(atom, parent, ((IAtom)chiralNeighbours[i]))] = (System.Int32)i; } } //UPGRADE_TODO: Method 'java.util.TreeMap.values' was converted to 'System.Collections.SortedList.Values' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapvalues'" System.Object[] ohere = SupportClass.ICollectionSupport.ToArray(hm.Values); for (int i = 0; i < ohere.Length; i++) { sorted[i] = ((IAtom)chiralNeighbours[((System.Int32)ohere[i])]); } } if (BondTools.isTrigonalBipyramidalOrOctahedral(container, atom) != 0) { sorted = new IAtom[container.getConnectedAtoms(atom).Length - 1]; //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.TreeMap' and 'System.Collections.SortedList' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'" //UPGRADE_TODO: Constructor 'java.util.TreeMap.TreeMap' was converted to 'System.Collections.SortedList' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapTreeMap'" System.Collections.SortedList hm = new System.Collections.SortedList(); if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UP) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (container.getBond(atom, (IAtom)chiralNeighbours[i]).Stereo == 0) { hm[(double)BondTools.giveAngle(atom, parent, ((IAtom)chiralNeighbours[i]))] = (System.Int32)i; } if (container.getBond(atom, (IAtom)chiralNeighbours[i]).Stereo == CDKConstants.STEREO_BOND_DOWN) { sorted[sorted.Length - 1] = (IAtom)chiralNeighbours[i]; } } //UPGRADE_TODO: Method 'java.util.TreeMap.values' was converted to 'System.Collections.SortedList.Values' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapvalues'" System.Object[] ohere = SupportClass.ICollectionSupport.ToArray(hm.Values); for (int i = 0; i < ohere.Length; i++) { sorted[i] = ((IAtom)chiralNeighbours[((System.Int32)ohere[i])]); } } if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_DOWN) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (container.getBond(atom, (IAtom)chiralNeighbours[i]).Stereo == 0) { hm[(double)BondTools.giveAngle(atom, parent, ((IAtom)chiralNeighbours[i]))] = (System.Int32)i; } if (container.getBond(atom, (IAtom)chiralNeighbours[i]).Stereo == CDKConstants.STEREO_BOND_UP) { sorted[sorted.Length - 1] = (IAtom)chiralNeighbours[i]; } } //UPGRADE_TODO: Method 'java.util.TreeMap.values' was converted to 'System.Collections.SortedList.Values' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapvalues'" System.Object[] ohere = SupportClass.ICollectionSupport.ToArray(hm.Values); for (int i = 0; i < ohere.Length; i++) { sorted[i] = ((IAtom)chiralNeighbours[((System.Int32)ohere[i])]); } } if (container.getBond(parent, atom).Stereo == 0) { for (int i = 0; i < chiralNeighbours.Count; i++) { if (chiralNeighbours[i] != parent) { if (container.getBond(atom, (IAtom)chiralNeighbours[i]).Stereo == 0) { hm[(double)(BondTools.giveAngleFromMiddle(atom, parent, ((IAtom)chiralNeighbours[i])))] = (System.Int32)i; } if (container.getBond(atom, (IAtom)chiralNeighbours[i]).Stereo == CDKConstants.STEREO_BOND_UP) { sorted[0] = (IAtom)chiralNeighbours[i]; } if (container.getBond(atom, (IAtom)chiralNeighbours[i]).Stereo == CDKConstants.STEREO_BOND_DOWN) { sorted[sorted.Length - 2] = (IAtom)chiralNeighbours[i]; } } } //UPGRADE_TODO: Method 'java.util.TreeMap.values' was converted to 'System.Collections.SortedList.Values' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapvalues'" System.Object[] ohere = SupportClass.ICollectionSupport.ToArray(hm.Values); sorted[sorted.Length - 1] = ((IAtom)chiralNeighbours[((System.Int32)ohere[ohere.Length - 1])]); if (ohere.Length == 2) { sorted[sorted.Length - 3] = ((IAtom)chiralNeighbours[((System.Int32)ohere[0])]); if (BondTools.giveAngleFromMiddle(atom, parent, ((IAtom)chiralNeighbours[((System.Int32)ohere[1])])) < 0) { IAtom dummy = sorted[sorted.Length - 2]; sorted[sorted.Length - 2] = sorted[0]; sorted[0] = dummy; } } if (ohere.Length == 3) { sorted[sorted.Length - 3] = sorted[sorted.Length - 2]; sorted[sorted.Length - 2] = ((IAtom)chiralNeighbours[((System.Int32)ohere[ohere.Length - 2])]); sorted[sorted.Length - 4] = ((IAtom)chiralNeighbours[((System.Int32)ohere[ohere.Length - 3])]); } } } //This builds an onew[] containing the objects after the center of the chirality in the order given by sorted[] if (sorted != null) { int numberOfAtoms = 3; if (BondTools.isTrigonalBipyramidalOrOctahedral(container, atom) != 0) { numberOfAtoms = container.getConnectedAtoms(atom).Length - 1; } System.Object[] omy = new System.Object[numberOfAtoms]; System.Object[] onew = new System.Object[numberOfAtoms]; for (int k = getRingOpenings(atom, null).Count; k < numberOfAtoms; k++) { if (positionInVector + 1 + k - getRingOpenings(atom, null).Count < v.Count) { omy[k] = v[positionInVector + 1 + k - getRingOpenings(atom, null).Count]; } } for (int k = 0; k < sorted.Length; k++) { if (sorted[k] != null) { for (int m = 0; m < omy.Length; m++) { if (omy[m] is IAtom) { if (omy[m] == sorted[k]) { onew[k] = omy[m]; } } else { if (omy[m] == null) { onew[k] = null; } else { if (((System.Collections.ArrayList)omy[m])[0] == sorted[k]) { onew[k] = omy[m]; } } } } } else { onew[k] = null; } } //This is a workaround for 3624.MOL.2 I don't have a better solution currently bool doubleentry = false; for (int m = 0; m < onew.Length; m++) { for (int k = 0; k < onew.Length; k++) { if (m != k && onew[k] == onew[m]) { doubleentry = true; } } } if (!doubleentry) { //Make sure that the first atom in onew is the first one in the original smiles order. This is important to have a canonical smiles. if (positionInVector + 1 < v.Count) { System.Object atomAfterCenterInOriginalSmiles = v[positionInVector + 1]; int l = 0; while (onew[0] != atomAfterCenterInOriginalSmiles) { System.Object placeholder = onew[onew.Length - 1]; for (int k = onew.Length - 2; k > -1; k--) { onew[k + 1] = onew[k]; } onew[0] = placeholder; l++; if (l > onew.Length) { break; } } } //This cares about ring openings. Here the ring closure (represendted by a figure) must be the first atom. In onew the closure is null. if (getRingOpenings(atom, null).Count > 0) { int l = 0; while (onew[0] != null) { System.Object placeholder = onew[0]; for (int k = 1; k < onew.Length; k++) { onew[k - 1] = onew[k]; } onew[onew.Length - 1] = placeholder; l++; if (l > onew.Length) { break; } } } //The last in onew is a vector: This means we need to exchange the rest of the original smiles with the rest of this vector. if (onew[numberOfAtoms - 1] is System.Collections.ArrayList) { for (int i = 0; i < numberOfAtoms; i++) { if (onew[i] is IAtom) { System.Collections.ArrayList vtemp = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); vtemp.Add(onew[i]); for (int k = positionInVector + 1 + numberOfAtoms; k < v.Count; k++) { vtemp.Add(v[k]); } onew[i] = vtemp; for (int k = v.Count - 1; k > positionInVector + 1 + numberOfAtoms - 1; k--) { v.RemoveAt(k); } for (int k = 1; k < ((System.Collections.ArrayList)onew[numberOfAtoms - 1]).Count; k++) { v.Add(((System.Collections.ArrayList)onew[numberOfAtoms - 1])[k]); } onew[numberOfAtoms - 1] = ((System.Collections.ArrayList)onew[numberOfAtoms - 1])[0]; break; } } } //Put the onew objects in the original Vector int k2 = 0; for (int m = 0; m < onew.Length; m++) { if (onew[m] != null) { v[positionInVector + 1 + k2] = onew[m]; k2++; } } } } } parent = atom; } else { //Have Vector //System.out.println("in parseChain after else"); bool brackets = true; System.Collections.ArrayList result = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); addAtoms((System.Collections.ArrayList)o, result); if (isRingOpening(parent, result) && container.getBondCount(parent) < 4) { brackets = false; } if (brackets) { buffer.Append('('); } parseChain((System.Collections.ArrayList)o, buffer, container, parent, chiral, doubleBondConfiguration, atomsInOrderOfSmiles); if (brackets) { buffer.Append(')'); } } positionInVector++; //System.out.println("in parseChain after positionVector++"); } }
private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e) { string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\""); string[] Inv=new string[64]; int maxlen = 4; bool validCommand = false; if (Message[0] != '#') { Message = "#" + Message; } string[] CommandArray = Message.Split(' '); if (CommandArray[0] == "#reserve" ) { bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#reserve", Settings.botid); string str1 = "", str2 = ""; if (TheInventory.GettingInventoryItems == true) { str2 = "I am building my inventory list, please try again in a few seconds"; str1 = str1.PadRight(str2.Length, '='); str1 = "[" + str1; str2 = "[" + str2; TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1)); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str2)); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1)); return; } if (disabled == true) { TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled")); return; } int rank = TheMySqlManager.GetUserRank(e.username, Settings.botid); if (rank < TheMySqlManager.GetCommandRank("#reserve", Settings.botid)) { TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!")); return; } if (this.TheTradeHandler.AmITrading() && e.username != TradeHandler.username) { TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I am currently trading, please retry shortly.")); return; } if (CommandArray.Length <= 1) goto WrongArguments; if (CommandArray[1] == "withdraw") { TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Still working on this function...")); validCommand = true; } if (CommandArray[1] == "details") { TheMySqlManager.reservedDetails(Settings.botid, e.username); validCommand = true; } if (CommandArray[1] == "list") { validCommand = true; // list all of the inventory items that have reserved amounts //set up the current inventory list System.Collections.ArrayList MyInventoryList = TheInventory.GetInventoryList(); //set up a sorted inventory list for output purposes System.Collections.SortedList TheInventoryList = new System.Collections.SortedList(); //loop through the inventory finding reserved amounts foreach (Inventory.inventory_item MyInventoryItem in MyInventoryList) { //find the largest name length for output purposes if (maxlen < MyInventoryItem.name.Length && (MyInventoryItem.pos < 36)) maxlen = MyInventoryItem.name.Length; //if it's not in the output array, put it there if (TheInventoryList.Contains(MyInventoryItem.SqlID) && MyInventoryItem.pos < 36) { //add the item quantities (these should be the unstackables...) Inventory.inventory_item TempInventoryItem = (Inventory.inventory_item)TheInventoryList[MyInventoryItem.SqlID]; TempInventoryItem.quantity += MyInventoryItem.quantity; TheInventoryList[MyInventoryItem.SqlID] = TempInventoryItem; } else { if (MyInventoryItem.pos < 36) { TheInventoryList.Add(MyInventoryItem.SqlID, MyInventoryItem); } } } //loop through the storage finding reserved amounts System.Collections.ArrayList MyStorageList = TheStorage.GetStorageList(); foreach (Storage.StorageItem MyStorageItem in MyStorageList) { if (maxlen < MyStorageItem.name.Length) { maxlen = MyStorageItem.name.Length; } if (TheInventoryList.Contains(MyStorageItem.knownItemsID)) { //already in the list, do nothing since storage quantity is already the total //and it repeats, kinda like an unstackable item } else { Inventory.inventory_item MyInventoryItem = new Inventory.inventory_item(); MyInventoryItem.name = MyStorageItem.name; MyInventoryItem.SqlID = MyStorageItem.knownItemsID; MyInventoryItem.quantity = MyStorageItem.quantity; MyInventoryItem.reservedQuantity = MyStorageItem.reservedQuantity; TheInventoryList.Add(MyInventoryItem.SqlID, MyInventoryItem); } } // pm the reserved items string str = ""; string msg = ""; str = "["; str = str.PadRight(maxlen + 27, '-'); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str)); foreach (Inventory.inventory_item MyInventoryItem in TheInventoryList.Values) { uint reservedQuantity = TheMySqlManager.ReservedAmount(MyInventoryItem.SqlID); if (MyInventoryItem.pos < 36 && reservedQuantity > 0) { msg = "["; msg += MyInventoryItem.name + " " + reservedQuantity + " of " + MyInventoryItem.quantity; TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, msg)); } } str = "["; str = str.PadRight(maxlen + 27, '-'); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str)); } if (CommandArray.Length > 2) { validCommand = true; try { if (CommandArray[1] == "delete") { Int32 rowIndex = Int32.Parse(CommandArray[2]); if (TheMySqlManager.reservedDelete(Settings.botid, e.username, rowIndex)) { TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Row Deleted.")); } else { TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Index not found.")); } } else { Int32 numberToReserve = Int32.Parse(CommandArray[1]); int i; string itemName = ""; for (i = 2; i < CommandArray.Length; i++) { itemName += CommandArray[i] + " "; } int itemId = TheMySqlManager.GetItemID(itemName,false); if (itemId > 0) { if (TheMySqlManager.reserveItem(itemId, (uint)numberToReserve, e.username) == true) { TheTradeHandler.AddTrade(itemId, 0, (uint)numberToReserve, "reserved"); TradeHandler.TradeLogItem myItem = new TradeHandler.TradeLogItem(); myItem.KnownItemsSqlID = itemId; myItem.quantity = (uint)numberToReserve; myItem.action = "reserved by"; TheMySqlManager.LogTrade(myItem, e.username, Settings.botid, true); TheInventory.requestInventory(); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[You just reserved " + myItem.quantity + " " + TheMySqlManager.GetKnownItemsname(myItem.KnownItemsSqlID))); } else //probably never get to this one... { TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Item not found!")); } } else { TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Item not found!")); } } } catch { goto WrongArguments; } } else { if (!validCommand) { goto WrongArguments; } } } return; WrongArguments: TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[----------------------------------------------------")); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #reserve command: ")); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#reserve <list>[withdraw] <amount item> ")); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[----------------------------------------------------")); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #reserve list ")); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #reserve amount item ")); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #reserve details ")); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #reserve delete <idx>* ")); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[*<idx> provided by #reserve details command. ")); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[----------------------------------------------------")); return; }
public static Discuz.Common.Generic.SortedList<int, object> GetTopicTypeArray() #endif { Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService(); #if NET1 System.Collections.SortedList topictypeList; #else Discuz.Common.Generic.SortedList<int, object> topictypeList; #endif topictypeList = cache.RetrieveObject("/TopicTypes") as Discuz.Common.Generic.SortedList<int, object>; if (topictypeList == null) { #if NET1 topictypeList = new System.Collections.SortedList(); #else topictypeList = new Discuz.Common.Generic.SortedList<int, object>(); #endif DataTable dt = DatabaseProvider.GetInstance().GetTopicTypeList(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { if ((dr["typeid"].ToString() != "") && (dr["name"].ToString() != "")) { topictypeList.Add(Int32.Parse(dr["typeid"].ToString()), dr["name"]); } } } cache.AddObject("/TopicTypes", topictypeList); } return topictypeList; }
private void initConfig() { Application["product"] = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name; Application["version"] = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; resources = new System.Resources.ResourceManager("SharpWebMail", System.Reflection.Assembly.GetExecutingAssembly()); Application["resources"] = resources; System.Collections.Hashtable config = (System.Collections.Hashtable)System.Configuration.ConfigurationSettings.GetConfig("sharpwebmail"); foreach ( System.Collections.DictionaryEntry item in config ) { Application.Add(item.Key.ToString(), item.Value); } config = null; if ( Application["sharpwebmail/send/addressbook"]!=null ) { Application["sharpwebmail/general/addressbooks"] = true; } if ( (bool)Application["sharpwebmail/read/message/useserverencoding"] ) { anmar.SharpMimeTools.SharpMimeHeader.EncodingDefault = System.Text.Encoding.Default; } TestAvailableCultures(); System.Collections.SortedList availablecultures_values = new System.Collections.SortedList(availablecultures.Count); foreach ( System.Collections.DictionaryEntry item in availablecultures ) { availablecultures_values.Add(item.Value, item.Key); } Application["AvailableCultures"] = availablecultures_values; initInvariantCulture(); Application["sharpwebmail/read/message/temppath"] = parseTempFolder(Server.MapPath("/"), Application["sharpwebmail/read/message/temppath"]); Application["sharpwebmail/send/message/temppath"] = parseTempFolder(Server.MapPath("/"), Application["sharpwebmail/send/message/temppath"]); }
private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e) { int UsedSlots = 0; string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\""); string[] Inv=new string[64]; int maxlen = 4; if (Message[0] != '#') { Message = "#" + Message; } string[] CommandArray = Message.Split(' '); bool isinv = false,isinvmembers = false; if (CommandArray[0] == "#inv" || CommandArray[0] == "#i" || CommandArray[0] == "#inb" || CommandArray[0] == "#sell" || CommandArray[0] == "#selling" || CommandArray[0] == "#inventory") isinv = true; if (CommandArray[0] == "#invmembers" || CommandArray[0] == "#im" || CommandArray[0] == "#invmemvers" || CommandArray[0] == "#invmember" || CommandArray[0] == "#invmemver") isinvmembers = true; if (isinv || isinvmembers) { bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#inv", Settings.botid); string str1 = "", str2 = ""; if (TheInventory.GettingInventoryItems == true) { str2 = "I am building my inventory list, please try again in a few seconds"; str1 = str1.PadRight(str2.Length, '='); str1 = "[" + str1; str2 = "[" + str2; TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1)); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str2)); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1)); return; } if (disabled == true) { TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled")); return; } if (Settings.IsTradeBot == false) { TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I am not a trade bot!")); return; } int rank = TheMySqlManager.GetUserRank(e.username, Settings.botid); if (rank < TheMySqlManager.GetCommandRank("#inv", Settings.botid)) { TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!")); return; } if ((CommandArray[0] == "#im" || CommandArray[0] == "#invmembers" || CommandArray[0] == "#invmemvers" || CommandArray[0] == "#invmember" || CommandArray[0] == "#invmemver") && ((rank < TheMySqlManager.GetCommandRank("#invmembers", Settings.botid)) && TheMySqlManager.CheckIfBannedGuild( e.username, Settings.botid) < 1)) { TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!")); return; } if (this.TheTradeHandler.AmITrading() && e.username != TradeHandler.username) { TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I am currently trading, please retry shortly.")); return; } if (CommandArray.Length < 1) goto WrongArguments; char invFiller = TheMySqlManager.getInvFiller(); System.Collections.ArrayList MyInventoryList = TheInventory.GetInventoryList(); System.Collections.Hashtable MySellingItemsList = TheMySqlManager.GetSellingItemList(0); // sum up all inventory items if the items are on sale System.Collections.SortedList TheInventoryList = new System.Collections.SortedList(); foreach (Inventory.inventory_item MyInventoryItem in MyInventoryList) { //adjust the number of slots used... if (MyInventoryItem.pos < 36) { if (MyInventoryItem.is_stackable) UsedSlots++; else UsedSlots = UsedSlots + (int)(MyInventoryItem.quantity); } //adjust the amount //only display if in selling list if (MySellingItemsList.Contains(MyInventoryItem.SqlID)) { //if already in inventory output (eg.., two slots) just sum the quantity //otherwise add to inventory output if (TheInventoryList.Contains(MyInventoryItem.SqlID) && MyInventoryItem.pos < 36) { Inventory.inventory_item TempInventoryItem = (Inventory.inventory_item)TheInventoryList[MyInventoryItem.SqlID]; TempInventoryItem.quantity += MyInventoryItem.quantity; TheInventoryList[MyInventoryItem.SqlID] = TempInventoryItem; } else { if (MyInventoryItem.pos < 36) { TheInventoryList.Add(MyInventoryItem.SqlID, MyInventoryItem); } } } } //foreach (Inventory.inventory_item MyInventoryItem in TheInventoryList.Values) //{ // if(maxlen<MyInventoryItem.name.Length && (MyInventoryItem.pos < 36)) // maxlen = MyInventoryItem.name.Length; //} //maxlen++; maxlen = 20 + 25 - Settings.Loginname.Length; // pm all summed up inventory items on sale int i = 0; for (i = 0; i < 64; i++) Inv[i] = "ZZZZZZZZZZZZZZZZ"; int c = 0; string str = ""; str2 = ""; str = "["; str = str.PadRight(maxlen + 27, '-'); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str)); bool Member = (TheMySqlManager.CheckIfTradeMember(e.username, Settings.botid) == true); str = "[name".PadRight(maxlen, ' '); str = str + "|qty".PadRight(7, ' '); str = str + "|price".PadRight(14, ' '); str = str + "|id".PadRight(6, ' '); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str)); str = "["; str = str.PadRight(maxlen + 27, '-'); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str)); string msg, msg2; foreach (Inventory.inventory_item MyInventoryItem in TheInventoryList.Values) { if (MyInventoryItem.pos < 36) { msg = ("[" + MyInventoryItem.name).PadRight(maxlen, i == 0 ? ' ' : invFiller); { uint tempAmount = 0; if ((TheMySqlManager.ReservedAmount(MyInventoryItem.SqlID)) < MyInventoryItem.quantity) { tempAmount = MyInventoryItem.quantity; tempAmount = tempAmount - (TheMySqlManager.ReservedAmount(MyInventoryItem.SqlID)); } else { continue; } msg2 = tempAmount.ToString(); } msg2 = msg2.PadLeft(6, i == 0 ? ' ' : invFiller); msg = msg + "|" + msg2; TradeHandler.SellingItem MySellingItem = (TradeHandler.SellingItem)(MySellingItemsList[MyInventoryItem.SqlID]); if(isinv) msg2 = MySellingItem.pricesale.ToString(); else msg2 = MySellingItem.pricesalemembers.ToString(); if (!msg2.Contains(".")) msg2 += ".00gc"; else if (msg2[msg2.Length - 2] == '.') msg2 += "0gc"; else msg2 += "gc"; msg2 = msg2.PadLeft(13, i == 0 ? ' ' : invFiller); msg = msg + "|" + msg2; msg2 = MyInventoryItem.SqlID.ToString().PadLeft(5, i == 0 ? ' ' : invFiller); msg = msg + "|" + msg2; Inv[c] = msg; c++; i = 1 - i; } } int d; // for (d = 0; d < c; d++) // { // str = Inv[d].Substring(16) + Inv[d].Substring(0, 16); // Inv[d] = str; // } Array.Sort(Inv); i = maxlen + 13; string filter = ""; if (CommandArray.Length > 1) { bool firstTime = true; foreach (string filterPart in CommandArray) { if (firstTime) { firstTime = false; continue; } filter += (" " + filterPart); } //filter = Message.Substring(CommandArray[0].Length); } else filter = ""; for (d = 0; d < c; d++) { str = Inv[d]; //27 chars after the name.... if (filter == "" || Inv[d].ToLower().Contains(filter.ToLower().Trim())) { string[] outFields = Inv[d].Split('|'); string outString = Inv[d]; if (outFields[0].Length > maxlen) { outString = outFields[0].Substring(0, maxlen - 3) + "..."; outString = outString.PadRight(maxlen, ' ') + "|".PadRight(7, ' ') + "|".PadRight(14, ' ') + "|".PadRight(6, ' '); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString)); outString = ("[..." + outFields[0].Substring(maxlen - 3).Trim()).PadRight(maxlen, ' '); int count = 0; foreach (string tempString in outFields) { if (count == 0) { count++; continue; } outString += "|" + tempString; } } TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString)); } else { //for (i = 1; i < CommandArray.Length; i++) { //if (Inv[d].ToLower().Contains(CommandArray[i].ToLower().Trim())) Console.WriteLine("inv(d): " + Inv[d] + " filter: " + filter); if (Inv[d].ToLower().Contains(filter.ToLower().Trim())) { string[] outFields = Inv[d].Split('|'); string outString = Inv[d]; if (outFields[0].Length > maxlen) { outString = outFields[0].Substring(0, maxlen - 3) + "..."; outString = outString.PadRight(maxlen, ' ') + "|".PadRight(14, ' ') + "|".PadRight(9, ' '); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString)); outString = ("[..." + outFields[0].Substring(maxlen - 3).Trim()).PadRight(maxlen, ' '); foreach (string tempString in outFields) { outString += "|" + tempString; } } TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString)); i = CommandArray.Length; } } } } int Phys = TheMySqlManager.GetBotPhysqiue(Settings.botid); int Coord = TheMySqlManager.GetBotCoordination(Settings.botid); int carry = (Phys + Coord) * 10; //int UsedSpace = TheMySqlManager.GetBotUsedSpace(Settings.botid); //int UsedSlots = TheMySqlManager.GetBotUsedSlots(Settings.botid); int UsedSpace = TheStats.MyCurrentCarryingAmt; int FreeSpace = carry - UsedSpace; str = "["; str = str.PadRight(maxlen + 27, '-'); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str)); str = "["; str += FreeSpace.ToString() + " EMU Avail|"; str += (36-UsedSlots).ToString() + " Open slot(s)"; if (rank > 89) { //str += TheMySqlManager.moneylevel(Settings.botid).ToString() + " gc"; str += "|"+TheInventory.GetMoneyAmount().ToString() + " gc"; } str = str.PadRight(maxlen + 27, ' '); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str)); str = "["; if (Member) { if ((CommandArray[0] != "#im" && CommandArray[0] != "#invmembers" && CommandArray[0] != "#invmemvers" && CommandArray[0] != "#invmember" && CommandArray[0] != "#invmemver")) { str = str.PadRight(maxlen + 27, '-'); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str)); str = "[Use invmembers (im) to see member prices"; str = str.PadRight(maxlen + 27, ' '); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str)); } //if (isinv) //{ // str = "[to see member prices use invmembers or im"; // str = str.PadRight(maxlen + 28, ' '); // TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str)); //} } str = "["; str = str.PadRight(maxlen + 27, '-'); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str)); return; } return; WrongArguments: TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------")); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #inv command:")); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#inv ")); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------")); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #inv ")); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #inv silver ore ")); TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------")); return; }
protected void Page_Load(object sender, EventArgs e) { if (!base.IsPostBack) { string personCode = CurrentUserInfo.Personcode; string companyId = CurrentUserInfo.CompanyId; string module_Code = this.Request.QueryString["ModuleCode"].ToString(); ModuleCode.Value = module_Code; dt = hrmDepartmentBll.getOrgTree(personCode, companyId, module_Code); //=================加載樹================= this.UltraWebTreeData.Nodes.Clear(); System.Collections.SortedList allTreeNodes = new System.Collections.SortedList(); Color foreColor; string strDeleted = ""; foreach (System.Data.DataRow row in dt.Rows) { switch (row["levelcode"].ToString()) { case "0": foreColor = Color.Blue; break; case "1": foreColor = Color.Maroon; break; case "2": foreColor = Color.SaddleBrown; break; case "3": foreColor = Color.Red; break; default: foreColor = Color.Black; break; } if (row["Deleted"].ToString() == "Y") { foreColor = Color.DarkGray; strDeleted = "[Disabled]"; } else { strDeleted = ""; } allTreeNodes.Add(System.Convert.ToString(row["depcode"]), base.CreateNode(System.Convert.ToString(row["depcode"]), System.Convert.ToString(row["depname"]) + "[" + System.Convert.ToString(row["depcode"]) + "]" + strDeleted, false, System.Convert.ToDecimal(dt.Compute("count(depcode)", "parentdepcode='" + row["depcode"] + "'")) == 0, foreColor)); if (row["parentdepcode"].ToString().Trim().Length > 0) { if (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0) { ((Infragistics.WebUI.UltraWebNavigator.Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Infragistics.WebUI.UltraWebNavigator.Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"]))); } else { this.UltraWebTreeData.Nodes.Add((Infragistics.WebUI.UltraWebNavigator.Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(System.Convert.ToString(row["depcode"])))); } } else { this.UltraWebTreeData.Nodes.Add((Infragistics.WebUI.UltraWebNavigator.Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(System.Convert.ToString(row["depcode"])))); } } //=================加載完成================= foreach (Node node in this.UltraWebTreeData.Nodes) { node.Expand(false); } } }
/// <summary> Check the hits for duplicates.</summary> /// <param name="hits"> /// </param> private void CheckHits(Hits hits, System.String prefix) { if (hits != null) { System.Collections.IDictionary idMap = new System.Collections.SortedList(); for (int docnum = 0; docnum < hits.Length(); ++docnum) { System.Int32 luceneId; try { luceneId = (System.Int32) hits.Id(docnum); if (idMap.Contains(luceneId)) { System.Text.StringBuilder message = new System.Text.StringBuilder(prefix); message.Append("Duplicate key for hit index = "); message.Append(docnum); message.Append(", previous index = "); message.Append(((System.Int32) idMap[luceneId]).ToString()); message.Append(", Lucene ID = "); message.Append(luceneId); Log(message.ToString()); } else { idMap[luceneId] = (System.Int32) docnum; } } catch (System.IO.IOException ioe) { System.Text.StringBuilder message = new System.Text.StringBuilder(prefix); message.Append("Error occurred for hit index = "); message.Append(docnum); message.Append(" ("); message.Append(ioe.Message); message.Append(")"); Log(message.ToString()); } } } }
/// <summary> Returns the atoms which are closes to an atom in an AtomContainer by /// distance in 3d. /// /// </summary> /// <param name="ac"> The AtomContainer to examine /// </param> /// <param name="a"> the atom to start from /// </param> /// <param name="max"> the number of neighbours to return /// </param> /// <returns> the average bond length /// </returns> /// <exception cref="CDKException"> Description of the Exception /// </exception> public static System.Collections.ArrayList findClosestInSpace(IAtomContainer ac, IAtom a, int max) { IAtom[] atoms = ac.Atoms; Point3d originalPoint = a.getPoint3d(); if (originalPoint == null) { throw new CDKException("No point3d, but findClosestInSpace is working on point3ds"); } //UPGRADE_TODO: Constructor 'java.util.TreeMap.TreeMap' was converted to 'System.Collections.SortedList' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilTreeMapTreeMap'" //UPGRADE_ISSUE: Class hierarchy differences between 'java.util.TreeMap' and 'System.Collections.SortedList' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'" System.Collections.IDictionary hm = new System.Collections.SortedList(); for (int i = 0; i < atoms.Length; i++) { if (atoms[i] != a) { if (atoms[i].getPoint3d() == null) { throw new CDKException("No point3d, but findClosestInSpace is working on point3ds"); } double distance = atoms[i].getPoint3d().distance(originalPoint); hm[(double)distance] = atoms[i]; } } //UPGRADE_TODO: Method 'java.util.Map.keySet' was converted to 'CSGraphT.SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilMapkeySet'" CSGraphT.SupportClass.SetSupport ks = new CSGraphT.SupportClass.HashSetSupport(hm.Keys); System.Collections.IEnumerator it = ks.GetEnumerator(); System.Collections.ArrayList returnValue = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); int i2 = 0; //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'" while (it.MoveNext() && i2 < max) { //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'" returnValue.Add(hm[it.Current]); i2++; } return (returnValue); }
public SADLScenario(string NewName) { Name = NewName; Activities = new System.Collections.SortedList(); }
public override bool Next() { if (termEnum == null) return false; // another term in this field? if (termEnum.Next() && (System.Object) termEnum.Term().Field() == (System.Object) field) return true; // yes, keep going termEnum.Close(); // close old termEnum // find the next field with terms, if any if (fieldIterator == null) { System.Collections.Comparer comparer = System.Collections.Comparer.Default; System.Collections.SortedList newList = new System.Collections.SortedList(); if (Enclosing_Instance.fieldToReader != null) { if (Enclosing_Instance.fieldToReader.Count > 0) { int index = 0; while (comparer.Compare(Enclosing_Instance.fieldToReader.GetKey(index), field) < 0) index++; for (; index < Enclosing_Instance.fieldToReader.Count; index++) { newList.Add(Enclosing_Instance.fieldToReader.GetKey(index), Enclosing_Instance.fieldToReader[Enclosing_Instance.fieldToReader.GetKey(index)]); } } } fieldIterator = newList.Keys.GetEnumerator(); fieldIterator.MoveNext(); System.Object generatedAux = fieldIterator.Current; // Skip field to get next one } while (fieldIterator.MoveNext()) { field = ((System.String) fieldIterator.Current); termEnum = ((IndexReader) Enclosing_Instance.fieldToReader[field]).Terms(new Term(field)); Term term = termEnum.Term(); if (term != null && (System.Object) term.Field() == (System.Object) field) return true; else termEnum.Close(); } return false; // no more fields }
// make sure the documents returned by the search match the expected list private void MatchHits(Searcher searcher, Sort sort) { // make a query without sorting first ScoreDoc[] hitsByRank = searcher.Search(query, null, 1000).ScoreDocs; CheckHits(hitsByRank, "Sort by rank: "); // check for duplicates System.Collections.IDictionary resultMap = new System.Collections.SortedList(); // store hits in TreeMap - TreeMap does not allow duplicates; existing entries are silently overwritten for (int hitid = 0; hitid < hitsByRank.Length; ++hitid) { resultMap[hitsByRank[hitid].Doc] = hitid; // Value: Hits-Objekt Index } // now make a query using the sort criteria ScoreDoc[] resultSort = searcher.Search(query, null, 1000, sort).ScoreDocs; CheckHits(resultSort, "Sort by custom criteria: "); // check for duplicates // besides the sorting both sets of hits must be identical for (int hitid = 0; hitid < resultSort.Length; ++hitid) { System.Int32 idHitDate = (System.Int32) resultSort[hitid].Doc; // document ID from sorted search if (!resultMap.Contains(idHitDate)) { Log("ID " + idHitDate + " not found. Possibliy a duplicate."); } Assert.IsTrue(resultMap.Contains(idHitDate)); // same ID must be in the Map from the rank-sorted search // every hit must appear once in both result sets --> remove it from the Map. // At the end the Map must be empty! resultMap.Remove(idHitDate); } if (resultMap.Count == 0) { // log("All hits matched"); } else { Log("Couldn't match " + resultMap.Count + " hits."); } Assert.AreEqual(resultMap.Count, 0); }
public PriorityQueue() { PseudoQueue = new System.Collections.SortedList(); }
/// <summary> Check the hits for duplicates.</summary> /// <param name="hits"> /// </param> private void CheckHits(ScoreDoc[] hits, System.String prefix) { if (hits != null) { System.Collections.IDictionary idMap = new System.Collections.SortedList(); for (int docnum = 0; docnum < hits.Length; ++docnum) { int luceneId; luceneId = hits[docnum].Doc; if (idMap.Contains(luceneId)) { System.Text.StringBuilder message = new System.Text.StringBuilder(prefix); message.Append("Duplicate key for hit index = "); message.Append(docnum); message.Append(", previous index = "); message.Append(((System.Int32) idMap[luceneId]).ToString()); message.Append(", Lucene ID = "); message.Append(luceneId); Log(message.ToString()); } else { idMap[luceneId] = docnum; } } } }
//private Port port; public CircuitoInserirPonto(System.Collections.SortedList PontosList, int cx, int cy, int cx_, int cy_, bool editando, bool hasPoint) { data = new CIPData(); this.hasPoint = hasPoint; this.editando = editando; this.cx = cx; this.cy = cy; this.cx_ = cx_; this.cy_ = cy_; this.PontosList = PontosList; InitializeComponent(); foreach (Ponto p in PontosList.Values) { ligarComboBox.Items.Add(p.Seq); } }
/// <summary/> public void ResetSortedList(ref System.Collections.SortedList list, string[] saContents) { list = new System.Collections.SortedList(); foreach (string s in saContents) if (s != null && !list.ContainsKey(s)) list.Add(s, s); #if TestingOnly Console.WriteLine("sorted list contains:"); for ( int i = 0; i < list.Count; i++ ) { Console.WriteLine( " {0}:{1}", list.GetKey(i), list.GetByIndex(i) ); } #endif }
/// <summary> /// Returns a portion of the list whose keys are greater than the limit object parameter. /// </summary> /// <param name="l">The list where the portion will be extracted.</param> /// <param name="limit">The start element of the portion to extract.</param> /// <returns>The portion of the collection whose elements are greater than the limit object parameter.</returns> public static System.Collections.SortedList TailMap(System.Collections.SortedList list, System.Object limit) { System.Collections.Comparer comparer = System.Collections.Comparer.Default; System.Collections.SortedList newList = new System.Collections.SortedList(); if (list != null) { if (list.Count > 0) { int index = 0; while (comparer.Compare(list.GetKey(index), limit) < 0) index++; for (; index < list.Count; index++) newList.Add(list.GetKey(index), list[list.GetKey(index)]); } } return newList; }
/// <summary> /// Retrieve OID name by OID string. /// </summary> /// <param name="inOidStr">source OID string.</param> /// <returns>OID name.</returns> public string GetOidName(string inOidStr) { if (oidDictionary == null) //Initialize oidDictionary: { oidDictionary = new StringDictionary(); string path = Application.ExecutablePath; string oidFile = System.IO.Path.GetDirectoryName(path) + "\\OID.txt"; string oidBackupFile = System.IO.Path.GetDirectoryName(path) + "\\OID.Backup.txt"; string oidStr = ""; string oidDesc = ""; bool loadOidError = false; int dbCounter = 0; try { using (StreamReader sr = new StreamReader(oidFile)) { string line; while ((line = sr.ReadLine()) != null) { string[] strs = line.Split(','); if (strs.Length < 2) continue; oidStr = strs[0].Trim(); oidDesc = strs[1].Trim(); try { oidDictionary.Add(oidStr, oidDesc); } catch(Exception ex) { loadOidError = true; string msg = ex.Message; dbCounter ++; } } } if (loadOidError) { using (StreamWriter sw = new StreamWriter(oidBackupFile)) { using (StreamReader sr = new StreamReader(oidFile)) { string line; while ((line = sr.ReadLine()) != null) { sw.Write(line+"\r\n"); } } } System.Collections.SortedList sList = new System.Collections.SortedList(); using (StreamWriter sw = new StreamWriter(oidFile)) { string val = ""; foreach ( System.Collections.DictionaryEntry de in oidDictionary ) { if (!sList.ContainsKey(de.Key)) sList.Add(de.Key, de.Value); } for(int i=0; i<sList.Count; i++) { val = String.Format("{0}, {1}\r\n", sList.GetKey(i), sList.GetByIndex(i)); sw.Write(val); } } MessageBox.Show(String.Format("Duplicated OIDs were found in the OID table: {0}.\r\n" + "The duplicate has been removed; the table is sorted.\r\n" + "The original OID file is copied as: {1}\r\n", oidFile, oidBackupFile)); } } catch(Exception ex) { MessageBox.Show("Failed to read OID values from file." + ex.Message); } } return oidDictionary[inOidStr]; }
/// <summary> /// Returns a key/value pair representing the attributes in the element. /// </summary> /// <param name="reader">The bufferred xml to analyze.</param> /// <returns>A sorted list of the attributes with the name as the key and the value as the value.</returns> /// <remarks>Executing this method querries the current node for the attributes without advancing to the next node.</remarks> private System.Collections.SortedList GetAttributes(System.Xml.XmlReader reader) { System.Collections.SortedList _List = new System.Collections.SortedList(); //FIX: December 9, 2005 - Fix to handle reading attributes from ReadXml routine if ((reader.NodeType != System.Xml.XmlNodeType.None) & (reader.MoveToFirstAttribute())) { do { if (reader.NodeType == System.Xml.XmlNodeType.Attribute) { _List.Add(reader.Name, reader.Value); } } while (reader.MoveToNextAttribute() | reader.NodeType != System.Xml.XmlNodeType.Attribute); } if (reader.NodeType == System.Xml.XmlNodeType.Attribute) { reader.MoveToElement(); } return _List; }
/// <summary> /// Given the 2 maps fills a document for 1 word. /// </summary> private static int Index(System.Collections.IDictionary word2Nums, System.Collections.IDictionary num2Words, System.String g, Document doc) { var keys = (System.Collections.IList) word2Nums[g]; // get list of key#'s var i2 = keys.GetEnumerator(); var already = new System.Collections.SortedList(); // keep them sorted // pass 1: fill up 'already' with all words while (i2.MoveNext()) // for each key# { foreach (var item in ((System.Collections.IList) num2Words[i2.Current]).Cast<object>().Where(item => already.Contains(item) == false)) { already.Add(item, item); } } var num = 0; already.Remove(g); // of course a word is it's own syn var it = already.GetEnumerator(); while (it.MoveNext()) { var cur = (String) it.Key; // don't store things like 'pit bull' -> 'american pit bull' if (!IsDecent(cur)) { continue; } num++; doc.Add(new Field(F_SYN, cur, Field.Store.YES, Field.Index.NO)); } return num; }