internal virtual void Clear() { terms.Clear(); queries.Clear(); docIDs.Clear(); numTerms = 0; bytesUsed = 0; }
public PMHandler(TCPWrapper MyTCPWrapper, BasicCommunication.MessageParser MyMessageParser, MySqlManager MyMySqlManager) { this.TheTCPWrapper = MyTCPWrapper; this.TheMessageParser = MyMessageParser; this.TheMySqlManager = MyMySqlManager; CommandArrayList.Clear(); TheMessageParser.Got_PM += new BasicCommunication.MessageParser.Got_PM_EventHandler(OnGotPM); }
public void RemoveScales() { foreach (Object obj in AdditionalList) { main_canvas.Children.Remove(obj as System.Windows.UIElement); } AdditionalList.Clear(); }
internal virtual bool setName(String name) { if (m_nameLocked) { return(true); } m_namedPath.Clear(); pushName(name); return(true); }
public void Default_Clear(int[] items, int capacity) { var arrayList = new System.Collections.ArrayList(capacity); arrayList.AddRange(items); arrayList.Clear(); }
private void button1_Click(object sender, EventArgs e) { //初始化 int p = int.Parse(this.textBox2.Text); int Generations = int.Parse(this.textBox4.Text);//迭代次数 if (p <= Parameter.m) { Parameter.p = p; GA GAAlgo = new GA(); System.Collections.ArrayList bestFitness = new System.Collections.ArrayList(); GAAlgo.MutationRate = double.Parse(this.textBox5.Text); GAAlgo.CrossRate = double.Parse(this.textBox6.Text); if (comboBox1.Text == (string)comboBox1.Items[1]) { GAAlgo.Selection = GA.SelectionType.Tournment; } if (comboBox2.Text == (string)comboBox2.Items[1]) { GAAlgo.Crosstype = 2; } //寻优 GAAlgo.Initialize();//产生第一代群体 progressBar1.Value = 0; GAChromosome GAChr = new GAChromosome(); bestFitness.Clear(); while (GAAlgo.GenerationNum < Generations)//产生下一代群体 { GAAlgo.CreateNextGeneration(); GAChr = GAAlgo.GetBestChromosome(); bestFitness.Add(GAChr.Fitness); } progressBar1.Value = 100; //记录结果 Parameter.x = GAChr.ToArray(); Parameter.opti = 100 / GAChr.Fitness; //显示结果 label10.Text = (100 / GAChr.Fitness).ToString(); //图像分析 GAChartForm.chartControl1.Series.Clear(); if (checkBox1.Checked) { ChartSeries fitnessSeries = new ChartSeries("bestFitness"); fitnessSeries.SeriesIndexedModelImpl = new StringIndexedModel(fitnessSeries, (double[])bestFitness.ToArray(typeof(double))); GAChartForm.chartControl1.Series.Add(fitnessSeries); } if (checkBox2.Checked) { ChartSeries total_fitnessSeries = new ChartSeries("totalFitness"); total_fitnessSeries.SeriesIndexedModelImpl = new StringIndexedModel(total_fitnessSeries, (double[])GAAlgo.TotalFitness.ToArray(typeof(double))); GAChartForm.chartControl1.Series.Add(total_fitnessSeries); } for (int i = 0; i < GAChartForm.chartControl1.Series.Count; i++) { GAChartForm.chartControl1.Series[i].Type = ChartSeriesType.Line; } } }
public void Init() { _score = 0; _head.Init(); _bodyPartArray.Clear(); _isAlive = false; _scale = 1f; Global._playerScale = 1; }
static void Main(string[] args) { Person oPerson1 = new Person(); oPerson1.Age = 20; oPerson1.FullName = "Ali Reza Alavi"; Person oPerson2 = new Person(); oPerson2.Age = 20; oPerson2.FullName = "Ali Reza Alavi"; Person oPerson3 = new Person(); oPerson3.Age = 30; oPerson3.FullName = "Ali Reza Alavi"; System.Console.WriteLine("\n----------"); if (oPerson1.Equals(oPerson2)) { System.Console.WriteLine("oPerson1 is equal to oPerson2"); } else { System.Console.WriteLine("oPerson1 is not equal to oPerson2"); } System.Console.WriteLine("----------"); System.Console.WriteLine("----------"); if (oPerson1.Equals(oPerson3)) { System.Console.WriteLine("oPerson1 is equal to oPerson3"); } else { System.Console.WriteLine("oPerson1 is not equal to oPerson3"); } System.Console.WriteLine("----------\n"); System.Collections.ArrayList oCollection = new System.Collections.ArrayList(); oCollection.Add(new Person("Ali Reza Alavi", 20)); oCollection.Add(new Person("Sara Ahmadi", 30)); oCollection.Add(new Person("Sanaz Samimi", 40)); oCollection.Remove(new Person("Ali Reza Alavi", 20)); foreach (Person oPerson in oCollection) { oPerson.ShowInfo(); } oCollection.Clear(); System.Console.ReadLine(); }
protected new void carregaTypDatSet() { try { mdlDataBaseAccess.Tabelas.XsdTbFaturasComerciais.tbFaturasComerciaisRow dtrwRowTbFaturasComerciais; System.Collections.ArrayList arlCondicaoCampo = new System.Collections.ArrayList(); System.Collections.ArrayList arlCondicaoComparador = new System.Collections.ArrayList(); System.Collections.ArrayList arlCondicaoValor = new System.Collections.ArrayList(); arlCondicaoCampo.Add("idExportador"); arlCondicaoComparador.Add(mdlDataBaseAccess.Comparador.Igual); arlCondicaoValor.Add(m_nIdExportador); m_typDatSetTbExportadores = m_cls_dba_ConnectionBD.GetTbExportadores(arlCondicaoCampo, arlCondicaoComparador, arlCondicaoValor, null, null); arlCondicaoCampo.Add("idPE"); arlCondicaoComparador.Add(mdlDataBaseAccess.Comparador.Igual); arlCondicaoValor.Add(m_strIdPE); m_typDatSetTbFaturasComerciais = m_cls_dba_ConnectionBD.GetTbFaturasComerciais(arlCondicaoCampo, arlCondicaoComparador, arlCondicaoValor, null, null); if (m_typDatSetTbFaturasComerciais.tbFaturasComerciais.Rows.Count > 0) { dtrwRowTbFaturasComerciais = (mdlDataBaseAccess.Tabelas.XsdTbFaturasComerciais.tbFaturasComerciaisRow)m_typDatSetTbFaturasComerciais.tbFaturasComerciais.Rows[0]; if (!dtrwRowTbFaturasComerciais.IsdataEmissaoNull()) { m_dtData = dtrwRowTbFaturasComerciais.dataEmissao; } if (!dtrwRowTbFaturasComerciais.IsnumeroFaturaNull()) { m_strNumero = dtrwRowTbFaturasComerciais.numeroFatura.Replace("\0", ""); } if (!dtrwRowTbFaturasComerciais.IsidImportadorNull()) { m_nIdImportador = dtrwRowTbFaturasComerciais.idImportador; } } arlCondicaoCampo.Clear(); arlCondicaoComparador.Clear(); arlCondicaoValor.Clear(); arlCondicaoCampo.Add("idExportador"); arlCondicaoComparador.Add(mdlDataBaseAccess.Comparador.Igual); arlCondicaoValor.Add(m_nIdExportador); arlCondicaoCampo.Add("idImportador"); arlCondicaoComparador.Add(mdlDataBaseAccess.Comparador.Igual); arlCondicaoValor.Add(m_nIdImportador); m_typDatSetTbImportadores = m_cls_dba_ConnectionBD.GetTbImportadores(arlCondicaoCampo, arlCondicaoComparador, arlCondicaoValor, null, null); } catch (Exception err) { Object erro = err; m_cls_ter_tratadorErro.trataErro(ref erro); } }
public void Clear() { lock (this) { EventType.Clear(); BytesToRead.Clear(); NumEventsHandled = 0; } }
internal static void loadPrinterCombo(System.Windows.Forms.ComboBox cmbPrinter) { System.Collections.ArrayList allPrinters = Printer.GetPrinterList(); for (int i = 0; i < allPrinters.Count; i++) { cmbPrinter.Items.Add(allPrinters[i].ToString()); } allPrinters.Clear(); allPrinters = null; }
/// <summary> /// Get the list of available printers /// </summary> private void GetPrinters() { System.Collections.ArrayList alPrinters = Printer.GetPrinterList(); for (int i = 0; i < alPrinters.Count; i++) { this.cmbPrinter.Items.Add(alPrinters[i].ToString()); } alPrinters.Clear(); alPrinters = null; }
public void Clear() { //Free instance //for (int i = 0; i < actList.Count; i++) //{ // wfActivity act = actList[i]; // //} actList.Clear(); }
//populate component list box public void fillComponentList() { componentlist.Clear(); componentlist = bc.PopulateComponent(this.cmbproject.GetItemText(this.cmbproject.SelectedItem)); foreach (string item in componentlist) { this.listboxcomponent.Items.Add(item); } }
private void UpdateItemsListInternal() { System.Collections.ArrayList dirty_items = new System.Collections.ArrayList(); for (int i = 0; i < listView_items_data_items.Count; i++) { uint id = Util.GetUInt32(((ListViewItem)listView_items_data_items[i]).SubItems[2].Text); if (Globals.gamedata.nearby_items.ContainsKey(id)) { ItemInfo item = Util.GetItem(id); item.InList = true; //update it //((ListViewItem)listView_items_data_items[i]).SubItems[0].Text = Util.GetItemName(item.ItemID); //((ListViewItem)listView_items_data_items[i]).SubItems[1].Text = item.Count.ToString(); //((ListViewItem)listView_items_data_items[i]).SubItems[2].Text = item.ID.ToString(); } else { dirty_items.Add(i); } } //need to remove all dirty items now for (int i = dirty_items.Count - 1; i >= 0; i--) { listView_items_data_items.RemoveAt((int)dirty_items[i]); } dirty_items.Clear(); foreach (ItemInfo item in Globals.gamedata.nearby_items.Values) { if (!item.InList) { item.InList = true; string mesh_info = ""; if (!item.HasMesh) { mesh_info = " [NO MESH]"; } //add it System.Windows.Forms.ListViewItem ObjListItem; ObjListItem = new ListViewItem(Util.GetItemName(item.ItemID) + mesh_info); //ItmID ObjListItem.SubItems.Add(item.Count.ToString()); //Count ObjListItem.SubItems.Add(item.ID.ToString()); //ObjID ObjListItem.ImageIndex = AddInfo.Get_Item_Image_Index(item.ItemID); listView_items_data_items.Add(ObjListItem); } } }
/// <summary> /// почистить /// </summary> public void Clear() { lock (types) { types.Clear(); } lock (values) { values.Clear(); } }
internal static Line[] findLineCross(Line[] lineAcross) { System.Collections.ArrayList crossLines = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); System.Collections.ArrayList lineNeighbor = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); System.Collections.ArrayList lineCandidate = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); Line compareLine; for (int i = 0; i < lineAcross.Length; i++) { lineCandidate.Add(lineAcross[i]); } for (int i = 0; i < lineCandidate.Count - 1; i++) { lineNeighbor.Clear(); lineNeighbor.Add(lineCandidate[i]); for (int j = i + 1; j < lineCandidate.Count; j++) { if (Line.isNeighbor((Line)lineNeighbor[lineNeighbor.Count - 1], (Line)lineCandidate[j])) { lineNeighbor.Add(lineCandidate[j]); compareLine = (Line)lineNeighbor[lineNeighbor.Count - 1]; if (lineNeighbor.Count * 5 > compareLine.Length && j == lineCandidate.Count - 1) { crossLines.Add(lineNeighbor[lineNeighbor.Count / 2]); for (int k = 0; k < lineNeighbor.Count; k++) { lineCandidate.Remove(lineNeighbor[k]); } } } else if (cantNeighbor((Line)lineNeighbor[lineNeighbor.Count - 1], (Line)lineCandidate[j]) || (j == lineCandidate.Count - 1)) { compareLine = (Line)lineNeighbor[lineNeighbor.Count - 1]; if (lineNeighbor.Count * 6 > compareLine.Length) { crossLines.Add(lineNeighbor[lineNeighbor.Count / 2]); for (int k = 0; k < lineNeighbor.Count; k++) { lineCandidate.Remove(lineNeighbor[k]); } } break; } } } Line[] foundLines = new Line[crossLines.Count]; for (int i = 0; i < foundLines.Length; i++) { foundLines[i] = (Line)crossLines[i]; } return(foundLines); }
protected void carregaDadosInterfaceCadEdit(ref mdlComponentesGraficos.TextBox ctbNome, ref mdlComponentesGraficos.TextBox ctbEndereco, ref mdlComponentesGraficos.TextBox ctbCidade, ref mdlComponentesGraficos.TextBox ctbEstado, ref mdlComponentesGraficos.ComboBox cbPaises, ref mdlComponentesGraficos.TextBox ctbTelefone, ref mdlComponentesGraficos.TextBox ctbFax, ref mdlComponentesGraficos.TextBox ctbEMail, ref mdlComponentesGraficos.TextBox ctbSite, ref System.Windows.Forms.TextBox ctbObs) { try { #region Pesquisa System.Collections.ArrayList arlOrdenacaoTipo = new System.Collections.ArrayList(); System.Collections.ArrayList arlOrdenacaoValor = new System.Collections.ArrayList(); arlOrdenacaoTipo.Add(mdlDataBaseAccess.TipoOrdenacao.Crescente); arlOrdenacaoValor.Clear(); arlOrdenacaoValor.Add("nmPais"); m_cls_dba_ConnectionDB.FonteDosDados = mdlDataBaseAccess.FonteDados.Resource; m_typDatSetTbPaises = m_cls_dba_ConnectionDB.GetTbPaises(null, null, null, /*arlOrdenacaoValor,arlOrdenacaoTipo*/ null, null); m_cls_dba_ConnectionDB.FonteDosDados = mdlDataBaseAccess.FonteDados.DataBase; mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow dtrwRowTbPaises; System.Collections.SortedList srlPaises = new System.Collections.SortedList(); foreach (mdlDataBaseAccess.Tabelas.XsdTbPaises.tbPaisesRow dtrwRowTbPaisesSorted in m_typDatSetTbPaises.tbPaises.Rows) { srlPaises.Add(dtrwRowTbPaisesSorted.nmPais, dtrwRowTbPaisesSorted); } #endregion #region Adicionando Items ao Formulário ctbNome.Text = m_strImportador; ctbEndereco.Text = m_strEndereco; ctbCidade.Text = m_strCidade; ctbEstado.Text = m_strEstado; 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_strPais = dtrwRowTbPaises.nmPais; } } } ctbTelefone.Text = m_strTelefone; ctbFax.Text = m_strFax; ctbEMail.Text = m_strEMail; ctbSite.Text = m_strSite; ctbObs.Text = m_strObs; #endregion } catch (Exception err) { Object erro = err; m_cls_ter_tratadorErro.trataErro(ref erro); } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init"></see> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"></see> object that contains the event data.</param> protected override void OnInit(EventArgs e) { base.OnInit(e); string sn = Page.Request.QueryString[_ImageTag]; if (sn != null) { Byte[] bytes = null; try { Crypto a = new Crypto(); a.CryptText = sn; a.CryptIV = IV; a.CryptKey = Key; sn = a.Decrypt(); System.Collections.ArrayList imgs = new System.Collections.ArrayList(); int width = 0; System.Drawing.Image img = null; foreach (Char item in sn) { img = (System.Drawing.Image)Images[item.ToString()]; width += img.Width; imgs.Add(img); } Bitmap bmp = new Bitmap(width, 37); Graphics grap = Graphics.FromImage(bmp); int left = 0; foreach (System.Drawing.Image item in imgs) { grap.DrawImage(item, left, 0); left += item.Width; } imgs.Clear(); grap.Flush(); grap.Dispose(); System.IO.MemoryStream stream = new System.IO.MemoryStream(); bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Gif); bmp.Dispose(); bytes = new byte[stream.Length]; stream.Position = 0; stream.Read(bytes, 0, bytes.Length); stream.Close(); } catch (Exception e_) { string str = e_.Message; } Page.Response.Clear(); Page.Response.BinaryWrite(bytes); Page.Response.Flush(); Page.Response.End(); } }
/// <summary> /// 子プロセス(複数)を取得する /// </summary> /// <param name="i_Process"></param> /// <returns>Process[] 子プロセスオブジェクト配列</returns> public static System.Diagnostics.Process[] GetChileProcess(System.Diagnostics.Process i_Process) { System.IntPtr a_hSnapShot = System.IntPtr.Zero; PROCESSENTRY32 a_Entry; System.Collections.ArrayList a_ProcessArray = null; try { a_hSnapShot = CreateToolhelp32Snapshot(SnapshotFlags.Process, 0); a_Entry = new PROCESSENTRY32(); a_Entry.dwSize = (uint)Memory.SizeOf(a_Entry); a_ProcessArray = new System.Collections.ArrayList(0); if (Process32First(a_hSnapShot, ref a_Entry)) { /* ////////////////////////////////////////////////////// */ // 親プロセスIDが指定したプロセスIDと一致するプロセスを配列へ追加する do { if (i_Process.Id == a_Entry.th32ParentProcessID) { try { a_ProcessArray.Add(System.Diagnostics.Process.GetProcessById((int)a_Entry.th32ProcessID)); } catch (System.Exception ex) { // 例外発生時はプロセス配列をクリアして外へ例外を投げる a_ProcessArray.Clear(); throw ex; } finally { } } }while(Process32Next(a_hSnapShot, ref a_Entry)); /* ////////////////////////////////////////////////////// */ } } catch (System.Exception ex) { // 例外発生時は配列を開放して外へ例外を投げる a_ProcessArray = null; throw ex; } finally { CloseHandle(a_hSnapShot); a_hSnapShot = System.IntPtr.Zero; } return((System.Diagnostics.Process[])a_ProcessArray.ToArray(typeof(System.Diagnostics.Process))); }
private void carregaTypDatSet() { try { System.Collections.ArrayList arlCondicaoCampo = new System.Collections.ArrayList(); System.Collections.ArrayList arlCondicaoComparador = new System.Collections.ArrayList(); System.Collections.ArrayList arlCondicaoValor = new System.Collections.ArrayList(); System.Collections.ArrayList arlOrdenacaoCampo = new System.Collections.ArrayList(); System.Collections.ArrayList arlOrdenacaoTipo = new System.Collections.ArrayList(); arlCondicaoCampo.Add("idExportador"); arlCondicaoComparador.Add(mdlDataBaseAccess.Comparador.Igual); arlCondicaoValor.Add(m_nIdExportador); arlOrdenacaoCampo.Add("mstrDescricao"); arlOrdenacaoTipo.Add(mdlDataBaseAccess.TipoOrdenacao.Crescente); if (m_typDatSetTbProdutos == null) { m_typDatSetTbProdutos = m_cls_dba_ConnectionDB.GetTbProdutos(arlCondicaoCampo, arlCondicaoComparador, arlCondicaoValor, /*arlOrdenacaoCampo, arlOrdenacaoTipo*/ null, null); } arlCondicaoCampo.Clear(); arlCondicaoCampo.Add("nIdExportador"); m_typDatSetTbProdutosParents = m_cls_dba_ConnectionDB.GetTbProdutosParents(arlCondicaoCampo, arlCondicaoComparador, arlCondicaoValor, /*arlOrdenacaoCampo, arlOrdenacaoTipo*/ null, null); arlCondicaoCampo.Clear(); arlCondicaoCampo.Add("nIdExportador"); if (m_typDatSetTbProdutosNcm == null) { m_typDatSetTbProdutosNcm = m_cls_dba_ConnectionDB.GetTbProdutosNcm(arlCondicaoCampo, arlCondicaoComparador, arlCondicaoValor, null, null); } if (m_typDatSetTbProdutosNaladi == null) { m_typDatSetTbProdutosNaladi = m_cls_dba_ConnectionDB.GetTbProdutosNaladi(arlCondicaoCampo, arlCondicaoComparador, arlCondicaoValor, null, null); } } catch (Exception err) { Object erro = err; m_cls_ter_tratadorErro.trataErro(ref erro); } }
public void Clear() { mutex.WaitOne(); try { array.Clear(); } finally { mutex.ReleaseMutex(); } }
internal void ClearPrefixes() { if (m_tmpEntries == null) { m_tmpEntries = new System.Collections.ArrayList(); m_entries = null; } else { m_tmpEntries.Clear(); } }
static void Main(string[] args) { System.Collections.ArrayList oStringCollection = new System.Collections.ArrayList(); oStringCollection.Add("Kazem"); oStringCollection.Add("Ahmad"); oStringCollection.Add("Sanaz"); oStringCollection.Add("Babak"); System.Console.WriteLine("\n----------"); foreach (string str in oStringCollection) { System.Console.WriteLine(str); } System.Console.WriteLine("----------"); oStringCollection.Sort(); System.Console.WriteLine("\n----------"); foreach (string str in oStringCollection) { System.Console.WriteLine(str); } System.Console.WriteLine("----------"); oStringCollection.Clear(); System.Collections.ArrayList oPersonCollection = new System.Collections.ArrayList(); oPersonCollection.Add(new Person("Kazem", 30)); oPersonCollection.Add(new Person("Ahmad", 40)); oPersonCollection.Add(new Person("Sanaz", 20)); oPersonCollection.Add(new Person("Babak", 10)); System.Console.WriteLine("\n----------"); foreach (Person oPerson in oPersonCollection) { oPerson.ShowInfo(); } System.Console.WriteLine("----------"); // Wrong Usage! oPersonCollection.Sort(); System.Console.WriteLine("\n----------"); foreach (Person oPerson in oPersonCollection) { oPerson.ShowInfo(); } System.Console.WriteLine("----------"); System.Console.ReadLine(); }
/// <summary> /// Clears all variables managing ROI objects /// </summary> public void Reset() { ROIList.Clear(); ActiveROIIndex = -1; _ROIMode = null; if (ModelROI != null) { ModelROI.Dispose(); } ModelROI = null; this.NotifyIconic(EVENT_DELETED_ALL_ROIS); }
/// <summary>given segment, starting with "MSH", then encoding characters, etc... /// put MSH[0]-1[0]-1-1 (== MSH-1) and MSH[0]-2[0]-1-1 (== MSH-2) into props, if found, /// plus everything else found in 'segment' /// </summary> protected internal static bool parseMSHSegmentWhole(System.Collections.Specialized.NameValueCollection props, System.Collections.ArrayList msgMask, NuGenEncodingCharacters encodingChars, System.String segment) { bool ret = false; try { ER7SegmentHandler handler = new ER7SegmentHandler(); handler.m_props = props; handler.m_encodingChars = encodingChars; handler.m_segmentId = "MSH"; handler.m_segmentRepIdx = 0; if (msgMask != null) { handler.m_msgMask = msgMask; } else { handler.m_msgMask = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); handler.m_msgMask.Add(new NuGenDatumPath()); // everything will pass this // (every DatumPath startsWith the zero-length DatumPath) } encodingChars.FieldSeparator = segment[3]; System.Collections.ArrayList nodeKey = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); nodeKey.Add(0); handler.putDatum(nodeKey, System.Convert.ToString(encodingChars.FieldSeparator)); encodingChars.ComponentSeparator = segment[4]; encodingChars.RepetitionSeparator = segment[5]; encodingChars.EscapeCharacter = segment[6]; encodingChars.SubcomponentSeparator = segment[7]; nodeKey[0] = 1; handler.putDatum(nodeKey, encodingChars.ToString()); if (segment[8] == encodingChars.FieldSeparator) { ret = true; // now -- we recurse // through fields / field-repetitions / components / subcomponents. nodeKey.Clear(); nodeKey.Add(2); parseSegmentGuts(handler, segment.Substring(9), nodeKey); } } catch (System.IndexOutOfRangeException) { } catch (System.NullReferenceException) { } return(ret); }
private void UpdateNPCListInternal() { System.Collections.ArrayList dirty_items = new System.Collections.ArrayList(); for (int i = 0; i < listView_npc_data.Items.Count; i++) { uint id = Util.GetUInt32(((ListViewItem)listView_npc_data_items[i]).SubItems[2].Text); if (Globals.gamedata.nearby_npcs.ContainsKey(id)) { NPCInfo npc = Util.GetNPC(id); npc.InList = true; //update it //((ListViewItem)listView_npc_data_items[i]).SubItems[0].Text = Util.GetNPCName(npc.NPCID); //((ListViewItem)listView_npc_data_items[i]).SubItems[1].Text = npc.Title; //((ListViewItem)listView_npc_data_items[i]).SubItems[2].Text = npc.ID.ToString(); //((ListViewItem)listView_npc_data_items[i]).SubItems[3].Text = npc.NPCID.ToString(); } else { dirty_items.Add(i); } } //need to remove all dirty items now for (int i = dirty_items.Count - 1; i >= 0; i--) { listView_npc_data_items.RemoveAt((int)dirty_items[i]); } dirty_items.Clear(); foreach (NPCInfo npc in Globals.gamedata.nearby_npcs.Values) { if (!npc.InList) { npc.InList = true; if (npc.isInvisible != 1) { //add it System.Windows.Forms.ListViewItem ObjListItem; ObjListItem = new ListViewItem(Util.GetNPCName(npc.NPCID)); //Name ObjListItem.SubItems.Add(npc.Title); //Title ObjListItem.SubItems.Add(npc.ID.ToString()); //ObjID ObjListItem.SubItems.Add(npc.NPCID.ToString()); //TypeID listView_npc_data_items.Add(ObjListItem); } } } }
public void RemoveAllSurveyResponses() { if (surveyResponses != null) { System.Collections.ArrayList tmpSurveyResponses = new System.Collections.ArrayList(); foreach (SurveyResponse oldSurveyResponse in surveyResponses) { tmpSurveyResponses.Add(oldSurveyResponse); } surveyResponses.Clear(); tmpSurveyResponses.Clear(); } }
private void btnClear_Click(object sender, EventArgs e) { System.Collections.ArrayList student = new System.Collections.ArrayList(); student.Add("Ryu"); student.Add("Candy"); student.Clear(); string msg = "目前陣列清單共有" + student.Count + "個元素"; MessageBox.Show(msg, "Clear()方法"); }
public void RemoveAllOperations() { if (operations != null) { System.Collections.ArrayList tmpTerm = new System.Collections.ArrayList(); foreach (int oldTerm in operations) { tmpTerm.Add(oldTerm); } operations.Clear(); tmpTerm.Clear(); } }
public override OutputQueueData getOutputdata() { //return base.getOutputdata(); System.Collections.ArrayList ary = new System.Collections.ArrayList(); int maxMode = -1000; if (outputQueue.Count == 0) return null; System.Collections.IDictionaryEnumerator ie = outputQueue.GetEnumerator(); while (ie.MoveNext()) { OutputQueueData quedata = (OutputQueueData)ie.Value; if ((int)quedata.mode == maxMode) { ary.Add(quedata); } else if ((int)quedata.mode > maxMode) { ary.Clear(); ary.Add(quedata); maxMode = (int)quedata.mode; } } int maxSpd = -100; OutputQueueData maxSpdQueData = null; foreach (OutputQueueData data in ary) { if (data.data == null && maxSpdQueData == null) { maxSpdQueData = data; continue; } System.Data.DataSet ds = ((RemoteInterface.HC.CSLSOutputData)data.data).dataset; if (System.Convert.ToInt32(ds.Tables[0].Rows[0]["speed"]) > maxSpd) { maxSpdQueData = data; maxSpd = System.Convert.ToInt32(ds.Tables[0].Rows[0]["speed"]); } } return maxSpdQueData; }
public void Ebayclassifieds(string statename) { if (stopebay) { int varcount = 0; string sname = ""; string price = ""; string location = ""; string pho = ""; string desc = ""; string url = ""; string title = ""; string mainurl = "http://www.ebayclassifieds.com/state/"; string state = statename.ToLower(); if (state.Contains(" ")) state = state.Replace(" ", "+"); mainurl = mainurl + state; FillCurrentPageData(mainurl); Regex r1 = new Regex("<li>(.*?)</li>"); str = content; str = content.Replace('\n', ' '); System.Collections.ArrayList al1 = new System.Collections.ArrayList(); System.Text.RegularExpressions.MatchCollection mc1 = null; mc1 = r1.Matches(str); al1.Clear(); al1.InsertRange(al1.Count, mc1); if (stopebay) { if (al1.Count > 0) { for (int i = 0; i < al1.Count; i++) { int page = 0; string a = al1[i].ToString().Replace("<li>", ""); a = a.Substring(0, a.IndexOf(">")); a = a.Replace("<a href=", ""); a = a.Replace("\"", ""); FillCurrentPageData(a + "cars/?catId=100028"); Regex r2 = new Regex("<span class=\"ec-breadcrumb\" style=\"padding-left: 5px;\">(.*?)</span>"); System.Collections.ArrayList al2 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc2 = null; mc2 = r2.Matches(str); al2.Clear(); al2.InsertRange(al2.Count, mc2); if (al2.Count > 0) { string res = al2[0].ToString(); res = Regex.Replace(res, "[A-Za-z]", ""); string[] res1 = Regex.Split(res, @"\D+"); page = (int.Parse(res1[res1.Length - 2]) / 24) + 1; } if (stopebay) { for (int j = 0; j <= page; j++) { if (stopebay) { #region ebay FillCurrentPageData(a + "cars/?catId=100028&page=" + j); Regex r3 = new Regex("<div class=\"ad-title\"><p>(.*?)</p></div>");//<span class=\"h2\">(.*?)</span> // <div class=\"h1gray\">(.*?)</div> System.Collections.ArrayList al3 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc3 = null; mc3 = r3.Matches(str); al3.Clear(); al3.InsertRange(al3.Count, mc3); if (al3.Count > 0) { for (int k = 0; k < al3.Count; k++) { url = al3[k].ToString(); url = url.Substring(url.IndexOf("href="), url.IndexOf("id=") - url.IndexOf("href=")); url = url.Replace("href=", ""); url = url.Replace("\"", ""); FillCurrentPageData(url); Regex r4 = new Regex("<h1 id=\"ad-title\">(.*?)</span></h1>"); System.Collections.ArrayList al4 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc4 = null; mc4 = r4.Matches(str); al4.Clear(); al4.InsertRange(al4.Count, mc4); if (al4.Count > 0) { for (int l = 0; l < al4.Count; l++) { string tot = al4[l].ToString(); if (tot.IndexOf("<span class=\"price\">") != -1) { title = tot.Substring(tot.IndexOf("<span>"), tot.IndexOf("<span class=\"price\">") - tot.IndexOf("<span>")); tot = tot.Replace(title, ""); title = title.Replace("<span>", ""); title = title.Replace("</span>", ""); } if (tot.IndexOf("<span class=\"location\">") != -1) { price = tot.Substring(tot.IndexOf("<span class=\"price\">"), tot.IndexOf("<span class=\"location\">") - tot.IndexOf("<span class=\"price\">")); tot = tot.Replace(price, ""); price = price.Replace("<span class=\"price\">", ""); price = price.Replace("</span>", ""); price = price.Replace("-", ""); } if (tot.IndexOf("<span class=\"location\">") != -1) { location = tot.Substring(tot.IndexOf("<span class=\"location\">"), tot.IndexOf("</span>") - tot.IndexOf("<span class=\"location\">")); location = location.Substring(location.IndexOf(">")); location = location.Replace(">", ""); location = location.Replace("(", ""); location = location.Replace(")", ""); } } } Regex r5 = new Regex("<strong id=\"postedBy\">(.*?)</strong>"); //<div id="listing-description" class="clearfix"> System.Collections.ArrayList al5 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc5 = null; mc5 = r5.Matches(str); al5.Clear(); al5.InsertRange(al5.Count, mc5); if (al5.Count > 0) { for (int m = 0; m < al5.Count; m++) { sname = al5[m].ToString(); sname = sname.Replace("<strong id=\"postedBy\">", ""); sname = sname.Replace("</strong>", ""); } } Regex r6 = new Regex("<li class=\"desc-text\">(.*?)</li>"); System.Collections.ArrayList al6 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc6 = null; mc6 = r6.Matches(str); al6.Clear(); al6.InsertRange(al6.Count, mc6); if (al6.Count > 0) { for (int n = 0; n < al6.Count; n++) { desc = al6[n].ToString(); desc = desc.Replace("<li class=\"desc-text\">", ""); desc = desc.Replace("</li>", ""); } } Regex r7 = new Regex("<span class=\"bld phd orange-text\">(.*?)</span>"); //<div id="listing-description" class="clearfix"> System.Collections.ArrayList al7 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc7 = null; mc7 = r7.Matches(str); al7.Clear(); al7.InsertRange(al7.Count, mc7); if (al7.Count > 0) { for (int p = 0; p < al7.Count; p++) { string ph = al7[p].ToString(); if (ph.IndexOf("{") != -1) { ph = ph.Substring(ph.IndexOf("{"), ph.IndexOf("}") - ph.IndexOf("{")); ph = ph.Substring(0, ph.LastIndexOf(",")); string[] ph1 = ph.Split(','); pho = ""; foreach (string phindex in ph1) { string abs = phindex.ToString(); pho += abs.Substring(abs.IndexOf(":")); pho = pho.Replace("'", ""); pho = pho.Replace(":", ""); pho = Regex.Replace(pho, "[^0-9a-zA-Z]+", ""); } } } } varcount++; //objDal.SaveebayData(title, sname, pho, price, location, desc, url, state); objDal.SaveLeadsData("", "", title, pho, price, url, sname, state, location, "", "", "", "", desc, "", "", "", "", "", "", "", ""); Navigate.Text = "Rec No:" + (varcount + 1).ToString(); } } #endregion } } } } } } } }
/* public static void TestPatch(FpuSegment seg) { ArrayList TempCode; //Generate the code TempCode=new ArrayList(Program.ReadFileBytes("out")); byte[] sseCode=(byte[])TempCode.ToArray(typeof(byte)); TempCode.Clear(); StreamWriter sr=new StreamWriter("tout.txt"); sr.WriteLine("bits 32"); foreach(string s in seg.TestData) { sr.WriteLine(s); } sr.Close(); Process p=new Process(); p.StartInfo.FileName="nasm.exe"; p.StartInfo.Arguments="-o tout tout.txt"; p.StartInfo.UseShellExecute=false; p.StartInfo.CreateNoWindow=true; p.Start(); p.WaitForExit(); p.Close(); FileInfo fi=new FileInfo("tout"); if(fi.Length==0) throw new OptimizationException("Patcher: patch tester produced uncompilable code"); TempCode.AddRange(Program.ReadFileBytes("tout")); byte[] fpuCode=(byte[])TempCode.ToArray(typeof(byte)); //inject and run the code if(sseCode.Length>InjectionLength||fpuCode.Length>InjectionLength) throw new OptimizationException("Checker: Injection site is too short"); try { File.Delete("asmTester2.exe"); } catch { } try { File.Copy("asmTester.exe","asmTester2.exe"); FileStream fs=File.Open("asmTester2.exe",FileMode.Open); fs.Position=TestPoint1; fs.Write(fpuCode,0,fpuCode.Length); fs.Position=TestPoint2; fs.Write(sseCode,0,sseCode.Length); fs.Close(); p=new Process(); p.StartInfo.UseShellExecute=false; p.StartInfo.CreateNoWindow=true; p.StartInfo.FileName="asmTester2.exe"; p.Start(); p.WaitForExit(); if(!p.HasExited) { p.Kill(); p.Close(); throw new OptimizationException("Checker: Process has not exited"); } if(p.ExitCode!=1) { p.Close(); throw new OptimizationException("Checker: Patch appears to be corrupt"); } p.Close(); } catch (Exception e) { if(e is OptimizationException) throw; throw new OptimizationException("Checker: Something threw an exception"); } } */ public static void Benchmark(FpuSegment seg) { ArrayList TempCode; //Get the sse code TempCode=new ArrayList(Program.ReadFileBytes("out")); TempCode.AddRange(JumpCode); byte[] bytes=(byte[])TempCode.ToArray(typeof(byte)); TempCode.Clear(); //Get the fpu code int a=0; for(int i=0;i<seg.Lines.Length;i++) { if(a==CodeGenerator.FpuLines.Length) break; if(CodeGenerator.FpuLines[a]==i) { TempCode.AddRange(HexToString(seg.Lines[i].code)); a++; } } TempCode.AddRange(JumpCode); byte[] bytes2=(byte[])TempCode.ToArray(typeof(byte)); Benchmark(bytes,bytes2); if(!Program.IgnoreBenchmark) { if(SseTime>=FpuTime+Bias) throw new OptimizationException("Benchmarker: Patch was slower than original code"); } }
[Test] public void RowFilter() { //note: this test does not check all the possible row filter expression. this is done in DataTable.Select method. // this test also check DataView.Count property DataRowView[] drvResult = null; System.Collections.ArrayList al = new System.Collections.ArrayList(); //create the source datatable DataTable dt = DataProvider.CreateChildDataTable(); //create the dataview for the table DataView dv = new DataView(dt); //------------------------------------------------------------- //Get excpected result al.Clear(); foreach (DataRow dr in dt.Rows ) { if ((int)dr["ChildId"] == 1) { al.Add(dr); } } // RowFilter = 'ChildId=1', check count dv.RowFilter = "ChildId=1"; Assert.AreEqual(al.Count , dv.Count , "DV70"); // RowFilter = 'ChildId=1', check rows drvResult = new DataRowView[dv.Count]; dv.CopyTo(drvResult,0); //check that the filterd rows exists bool Succeed = true; for (int i=0; i<drvResult.Length ; i++) { Succeed = al.Contains(drvResult[i].Row); if (!Succeed) break; } Assert.AreEqual(true, Succeed , "DV71"); //------------------------------------------------------------- //------------------------------------------------------------- //Get excpected result al.Clear(); foreach (DataRow dr in dt.Rows ) if ((int)dr["ChildId"] == 1 && dr["String1"].ToString() == "1-String1" ) al.Add(dr); // RowFilter - ChildId=1 and String1='1-String1' dv.RowFilter = "ChildId=1 and String1='1-String1'"; Assert.AreEqual(al.Count , dv.Count , "DV72"); // RowFilter = ChildId=1 and String1='1-String1', check rows drvResult = new DataRowView[dv.Count]; dv.CopyTo(drvResult,0); //check that the filterd rows exists Succeed = true; for (int i=0; i<drvResult.Length ; i++) { Succeed = al.Contains(drvResult[i].Row); if (!Succeed) break; } Assert.AreEqual(true, Succeed , "DV73"); //------------------------------------------------------------- //EvaluateException // RowFilter - check EvaluateException try { dv.RowFilter = "Col=1"; Assert.Fail("DV74: RowFilter Failed to throw EvaluateException"); } catch (EvaluateException) {} catch (AssertionException exc) {throw exc;} catch (Exception exc) { Assert.Fail("DV75: RowFilter. Wrong exception type. Got:" + exc); } //SyntaxErrorException 1 // RowFilter - check SyntaxErrorException 1 try { dv.RowFilter = "sum('something')"; Assert.Fail("DV76: RowFilter Failed to throw SyntaxErrorException"); } catch (SyntaxErrorException) {} catch (AssertionException exc) {throw exc;} catch (Exception exc) { Assert.Fail("DV77: RowFilter. Wrong exception type. Got:" + exc); } //SyntaxErrorException 2 // RowFilter - check SyntaxErrorException 2 try { dv.RowFilter = "HH**!"; Assert.Fail("DV78: RowFilter Failed to throw SyntaxErrorException"); } catch (SyntaxErrorException) {} catch (AssertionException exc) {throw exc;} catch (Exception exc) { Assert.Fail("DV79: RowFilter. Wrong exception type. Got:" + exc); } }
/// <summary> /// Constrói dados do grupo. /// Percorre tabela de dados do relatório, filtrando e distinguindo os dados pela coluna do grupo. /// Também calcula os valores de cada grupo, totalizando-os. /// </summary> /// <param name="p_table">Tabela de dados do relatório.</param> /// <param name="p_parentgroupcolumn">Coluna do grupo pai.</param> public void BuildCalculate(System.Data.DataTable p_table, string p_parentgroupcolumn) { System.Collections.ArrayList v_allcolumns_temp; string[] v_allcolumns; int i, j, k; // PASSO 1: PEGANDO COLUNAS E DADOS DO GRUPO // alocando lista de colunas v_allcolumns_temp = new System.Collections.ArrayList(); // adicionando coluna do grupo pai if (p_parentgroupcolumn != null && p_parentgroupcolumn != "") v_allcolumns_temp.Add(p_parentgroupcolumn); // adicionando coluna do grupo v_allcolumns_temp.Add(this.v_column); // adicionando todas as colunas do cabeçalho do grupo (exceto as colunas de valor) for (k = 0; k < this.v_headerfields.Count; k++) { if (((Spartacus.Reporting.Field)this.v_headerfields [k]).v_column != "" && !((Spartacus.Reporting.Field)this.v_headerfields [k]).v_groupedvalue && !v_allcolumns_temp.Contains(((Spartacus.Reporting.Field)this.v_headerfields [k]).v_column)) v_allcolumns_temp.Add(((Spartacus.Reporting.Field)this.v_headerfields [k]).v_column); } // adicionando todas as colunas do rodapé do grupo (exceto as colunas de valor) for (k = 0; k < this.v_footerfields.Count; k++) { if (((Spartacus.Reporting.Field)this.v_footerfields [k]).v_column != "" && !((Spartacus.Reporting.Field)this.v_footerfields [k]).v_groupedvalue && !v_allcolumns_temp.Contains(((Spartacus.Reporting.Field)this.v_footerfields [k]).v_column)) v_allcolumns_temp.Add(((Spartacus.Reporting.Field)this.v_footerfields [k]).v_column); } // alocando vetor de string v_allcolumns = new string[v_allcolumns_temp.Count]; // copiando nomes de colunas para o vetor de string for (k = 0; k < v_allcolumns_temp.Count; k++) v_allcolumns [k] = (string)v_allcolumns_temp [k]; // filtrando dados distintos pela lista de colunas, e armazenando em tabela if (p_parentgroupcolumn != null && p_parentgroupcolumn != "") p_table.DefaultView.Sort = p_parentgroupcolumn + ", " + this.v_column; else p_table.DefaultView.Sort = this.v_column; this.v_table = p_table.DefaultView.ToTable(true, v_allcolumns); // PASSO 2: PREENCHENDO VALORES // limpando array temporario v_allcolumns_temp.Clear(); // adicionando todas as colunas do cabeçalho do grupo (somente as colunas de valor) for (k = 0; k < this.v_headerfields.Count; k++) { if (((Spartacus.Reporting.Field)this.v_headerfields [k]).v_column != "" && ((Spartacus.Reporting.Field)this.v_headerfields [k]).v_groupedvalue && ! v_allcolumns_temp.Contains(((Spartacus.Reporting.Field)this.v_headerfields [k]).v_column)) v_allcolumns_temp.Add(((Spartacus.Reporting.Field)this.v_headerfields [k]).v_column); } // adicionando todas as colunas do rodapé do grupo (somente as colunas de valor) for (k = 0; k < this.v_footerfields.Count; k++) { if (((Spartacus.Reporting.Field)this.v_footerfields [k]).v_column != "" && ((Spartacus.Reporting.Field)this.v_footerfields [k]).v_groupedvalue && ! v_allcolumns_temp.Contains(((Spartacus.Reporting.Field)this.v_footerfields [k]).v_column)) v_allcolumns_temp.Add(((Spartacus.Reporting.Field)this.v_footerfields [k]).v_column); } // criando colunas de valor na tabela do grupo for (k = 0; k < v_allcolumns_temp.Count; k++) this.v_table.Columns.Add((string)v_allcolumns_temp [k]); // preenchendo valores sumarizados for (i = 0; i < this.v_table.Rows.Count; i++) { for (j = 0; j < v_allcolumns_temp.Count; j++) this.v_table.Rows [i] [(string)v_allcolumns_temp [j]] = p_table.Compute("Sum(" + ((string)v_allcolumns_temp [j]) + ")", this.v_column + " = '" + this.v_table.Rows [i] [this.v_column].ToString() + "'").ToString(); } }
public virtual void TestPhrasePrefix() { RAMDirectory indexStore = new RAMDirectory(); IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); Add("blueberry pie", writer); Add("blueberry strudel", writer); Add("blueberry pizza", writer); Add("blueberry chewing gum", writer); Add("bluebird pizza", writer); Add("bluebird foobar pizza", writer); Add("piccadilly circus", writer); writer.Optimize(); writer.Close(); IndexSearcher searcher = new IndexSearcher(indexStore); // search for "blueberry pi*": MultiPhraseQuery query1 = new MultiPhraseQuery(); // search for "strawberry pi*": MultiPhraseQuery query2 = new MultiPhraseQuery(); query1.Add(new Term("body", "blueberry")); query2.Add(new Term("body", "strawberry")); System.Collections.ArrayList termsWithPrefix = new System.Collections.ArrayList(); IndexReader ir = IndexReader.Open(indexStore); // this TermEnum gives "piccadilly", "pie" and "pizza". System.String prefix = "pi"; TermEnum te = ir.Terms(new Term("body", prefix)); do { if (te.Term().Text().StartsWith(prefix)) { termsWithPrefix.Add(te.Term()); } } while (te.Next()); query1.Add((Term[]) termsWithPrefix.ToArray(typeof(Term))); Assert.AreEqual("body:\"blueberry (piccadilly pie pizza)\"", query1.ToString()); query2.Add((Term[]) termsWithPrefix.ToArray(typeof(Term))); Assert.AreEqual("body:\"strawberry (piccadilly pie pizza)\"", query2.ToString()); ScoreDoc[] result; result = searcher.Search(query1, null, 1000).scoreDocs; Assert.AreEqual(2, result.Length); result = searcher.Search(query2, null, 1000).scoreDocs; Assert.AreEqual(0, result.Length); // search for "blue* pizza": MultiPhraseQuery query3 = new MultiPhraseQuery(); termsWithPrefix.Clear(); prefix = "blue"; te = ir.Terms(new Term("body", prefix)); do { if (te.Term().Text().StartsWith(prefix)) { termsWithPrefix.Add(te.Term()); } } while (te.Next()); query3.Add((Term[]) termsWithPrefix.ToArray(typeof(Term))); query3.Add(new Term("body", "pizza")); result = searcher.Search(query3, null, 1000).scoreDocs; Assert.AreEqual(2, result.Length); // blueberry pizza, bluebird pizza Assert.AreEqual("body:\"(blueberry bluebird) pizza\"", query3.ToString()); // test slop: query3.SetSlop(1); result = searcher.Search(query3, null, 1000).scoreDocs; Assert.AreEqual(3, result.Length); // blueberry pizza, bluebird pizza, bluebird foobar pizza MultiPhraseQuery query4 = new MultiPhraseQuery(); try { query4.Add(new Term("field1", "foo")); query4.Add(new Term("field2", "foobar")); Assert.Fail(); } catch (System.ArgumentException e) { // okay, all terms must belong to the same field } searcher.Close(); indexStore.Close(); }
/// <summary> Return a array of SourceFiles whose names match /// the specified string. The array is sorted by name. /// The input can be mx.controls.xxx which will /// </summary> public virtual SourceFile[] getFiles(String matchString) { bool doStartsWith = false; bool doIndexOf = false; bool doEndsWith = false; bool leadingAsterisk = matchString.StartsWith("*") && matchString.Length > 1; //$NON-NLS-1$ bool trailingAsterisk = matchString.EndsWith("*"); //$NON-NLS-1$ bool usePath = matchString.IndexOf('.') > - 1; if (leadingAsterisk && trailingAsterisk) { matchString = matchString.Substring(1, (matchString.Length - 1) - (1)); doIndexOf = true; } else if (leadingAsterisk) { matchString = matchString.Substring(1); doEndsWith = true; } else if (trailingAsterisk) { matchString = matchString.Substring(0, (matchString.Length - 1) - (0)); doStartsWith = true; } else if (usePath) { doIndexOf = true; } else { doStartsWith = true; } SourceFile[] files = FileList; System.Collections.ArrayList fileList = new System.Collections.ArrayList(); int n = files.Length; int exactHitAt = - 1; // If the matchString already starts with "." (e.g. ".as" or ".mxml"), then dotMatchString // will be equal to matchString; otherwise, dotMatchString will be "." + matchString String dotMatchString = (matchString.StartsWith("."))?matchString:("." + matchString); //$NON-NLS-1$ //$NON-NLS-2$ for (int i = 0; i < n; i++) { SourceFile sourceFile = files[i]; bool pathExists = (usePath && new System.Text.RegularExpressions.Regex(@".*[/\\].*").Match(sourceFile.FullPath).Success); //$NON-NLS-1$ String name = pathExists?sourceFile.FullPath:sourceFile.Name; // if we are using the full path string, then prefix a '.' to our matching string so that abc.as and Gabc.as don't both hit String match = (usePath && pathExists)?dotMatchString:matchString; name = name.Replace('/', '.'); // get rid of path identifiers and use dots name = name.Replace('\\', '.'); // would be better to modify the input string, but we don't know which path char will be used. // exact match? We are done if (name.Equals(match)) { exactHitAt = i; break; } else if (doStartsWith && name.StartsWith(match)) fileList.Add(sourceFile); else if (doEndsWith && name.EndsWith(match)) fileList.Add(sourceFile); else if (doIndexOf && name.IndexOf(match) > - 1) fileList.Add(sourceFile); } // trim all others if we have an exact file match if (exactHitAt > - 1) { fileList.Clear(); fileList.Add(files[exactHitAt]); } SourceFile[] fileArray = (SourceFile[]) SupportClass.ICollectionSupport.ToArray(fileList, new SourceFile[fileList.Count]); ArrayUtil.sort(fileArray, this); return fileArray; }
public void GetLeadsForLocanto(string statecode) { string pages = ""; int page = 0; //string mainurl = "http://www.locanto.com/Vehicles/H/?professional=0&page="; string mainurl = "http://" + statecode + ".locanto.com/Vehicles/H/"; if (stoplocanto) { FillCurrentPageData(mainurl); Regex regexindividual31 = new Regex("<div style=\"padding:3px 0 0 240px;\">(.*?)</div>"); str = content; str = content.Replace('\n', ' '); System.Collections.ArrayList individualCararraylist31 = new System.Collections.ArrayList(); System.Text.RegularExpressions.MatchCollection regexindividualCollec31 = null; regexindividualCollec31 = regexindividual31.Matches(str); individualCararraylist31.Clear(); individualCararraylist31.InsertRange(individualCararraylist31.Count, regexindividualCollec31); if (individualCararraylist31.Count > 0) { pages = individualCararraylist31[0].ToString().Replace("<div style=\"padding:3px 0 0 240px;\">", ""); pages = Regex.Replace(pages, "[^0-9]", ""); pages = (int.Parse(pages) / 25).ToString(); page = int.Parse(pages); if (page > 79) page = 79; } for (int p = 0; p <= page; p++) { if (stoplocanto) { #region tot FillCurrentPageData(mainurl + p + "/"); Regex regexindividual3 = new Regex("<span class=\"textHeader \">(.*?)</span>"); str = content; str = content.Replace('\n', ' '); System.Collections.ArrayList individualCararraylist3 = new System.Collections.ArrayList(); System.Text.RegularExpressions.MatchCollection regexindividualCollec3 = null; regexindividualCollec3 = regexindividual3.Matches(str); individualCararraylist3.Clear(); individualCararraylist3.InsertRange(individualCararraylist3.Count, regexindividualCollec3); for (int dj = 0; dj < individualCararraylist3.Count; dj++) { string desc = ""; string title = ""; string price = ""; string pubDate = ""; string name = ""; string location = ""; string place = ""; string phno = string.Empty; string state = ""; string city = ""; #region fetch string url = individualCararraylist3[dj].ToString(); url = url.Substring(url.IndexOf("href=")); url = url.Replace("href=", ""); url = url.Substring(0, url.IndexOf("onclick")); //url = url.Replace(">", ""); url = url.Replace("\"", ""); title = individualCararraylist3[dj].ToString(); title = title.Replace("<span class=\"textHeader \">", ""); title = title.Substring(title.IndexOf(">")); title = title.Replace(">", "").Trim(); if (title.IndexOf("<span") != -1) { //location = title.Substring(title.IndexOf("<span")); title = title.Substring(0, title.IndexOf("<span")); //location = location.Replace("<span class=\"textLoc\"", ""); //location = location.Replace("</span", "").Trim(); //if (location.IndexOf(",") != -1) // city = location.Substring(0, location.IndexOf(",")); //else // city = location; //state = location.Replace(city, ""); //state = state.Replace(",", ""); //state = Regex.Replace(state, "[0-9]", ""); } else title = title.Replace("</span", ""); //location = title.Substring(title.IndexOf("<span")); FillCurrentPageData(url); Regex r3 = new Regex("<div class=\"user_content\">(.*?)</div>");//<span class=\"h2\">(.*?)</span> // <div class=\"h1gray\">(.*?)</div> System.Collections.ArrayList al3 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc3 = null; mc3 = r3.Matches(str); al3.Clear(); al3.InsertRange(al3.Count, mc3); for (int x = 0; x < al3.Count; x++) { desc = al3[x].ToString(); desc = desc.Replace("<div class=\"user_content\">", ""); desc = desc.Replace("</div>", ""); //desc = desc.Substring(0, desc.IndexOf("<!-- AddThis Button BEGIN -->")); string phone = Regex.Replace(desc, "[A-Za-z]", ""); string[] digits = Regex.Split(phone, @"\D+"); for (int ph = 0; ph < digits.Length; ph++) { if (digits[ph].Length == 10) { phno = digits[ph]; } else if (digits[ph].Length == 3 && digits[ph + 1].Length == 3 && digits[ph + 2].Length == 4) { phno = digits[ph] + digits[ph + 1] + digits[ph + 2]; } else if (digits[ph].Length == 3 && digits[ph + 1].Length == 7) { phno = digits[ph] + digits[ph + 1]; } } } Regex r2 = new Regex("<div class=\"h1gray\">(.*?)</div>"); System.Collections.ArrayList al2 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc2 = null; mc2 = r2.Matches(str); al2.Clear(); al2.InsertRange(al2.Count, mc2); for (int i = 0; i < al2.Count; i++) { price = al2[0].ToString(); price = price.Replace("<div class=\"h1gray\">", ""); price = price.Replace("</div>", ""); } Regex r4 = new Regex("<span itemprop=\"postalCode\">(.*?)</span>"); System.Collections.ArrayList al4 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc4 = null; mc4 = r4.Matches(str); al4.Clear(); al4.InsertRange(al4.Count, mc4); if (al4.Count > 0) { for (int i = 0; i < al4.Count; i++) { location = al4[0].ToString(); location = location.Replace("<span itemprop=\"postalCode\">", ""); location = location.Replace("</span>", ""); if (location.IndexOf(",") != -1) { city = location.Substring(0, location.IndexOf(",")); city = city.Replace(",", ""); //state = location.Substring(location.IndexOf(city)); //state = Regex.Replace(state, "[0-9]", ""); } else { city = location; //state = ""; } } } #endregion #region Save //objDal.SaveLocanto_Leads(title, desc, state,city, price, phno, url); objDal.SaveLeadsData("", "", title, phno, price, url, "", statecode, city, "", "", "", "", desc, "", "", "", "", "", "", "", ""); Navigate.Text = (int.Parse(Navigate.Text) + 1).ToString(); #endregion } #endregion } } } }
private static DataTable getConfigDataTable() { try { DataTable dt = new DataTable(); _tab = Globals.FindTable(ArcMap.Document.FocusMap, _defaultsTableName); if (_tab == null) return null; for (int i = 0; i < _tab.Fields.FieldCount; i++) { if (_tab.Fields.get_Field(i).Type == esriFieldType.esriFieldTypeString) dt.Columns.Add(_tab.Fields.get_Field(i).Name, typeof(string)); else if (_tab.Fields.get_Field(i).Type == esriFieldType.esriFieldTypeGlobalID) dt.Columns.Add(_tab.Fields.get_Field(i).Name, typeof(string)); else if (_tab.Fields.get_Field(i).Type == esriFieldType.esriFieldTypeGUID) dt.Columns.Add(_tab.Fields.get_Field(i).Name, typeof(string)); else if (_tab.Fields.get_Field(i).Type == esriFieldType.esriFieldTypeDate) dt.Columns.Add(_tab.Fields.get_Field(i).Name, typeof(string)); else dt.Columns.Add(_tab.Fields.get_Field(i).Name, typeof(int)); } ICursor cur = _tab.Search(null, true); IRow row; System.Collections.ArrayList ar = new System.Collections.ArrayList(); while ((row = cur.NextRow()) != null) { for (int i = 0; i < _tab.Fields.FieldCount; i++) { ar.Add(row.get_Value(i)); } dt.Rows.Add(ar.ToArray()); ar.Clear(); } if (row != null) { Marshal.ReleaseComObject(row); GC.WaitForFullGCComplete(); row = null; } if (cur != null) { Marshal.ReleaseComObject(cur); GC.Collect(300); GC.WaitForFullGCComplete(); cur = null; } return dt; } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain0") + ex.Message); return null; } }
/// <summary> /// Remove all instances of Appointment from the collection /// </summary> /// <pdGenerated>Default removeAll</pdGenerated> public void RemoveAllAppointments_costumer() { if (appointments_costumer != null) { System.Collections.ArrayList tmpAppointments_costumer = new System.Collections.ArrayList(); foreach (Appointment oldAppointment in appointments_costumer) tmpAppointments_costumer.Add(oldAppointment); appointments_costumer.Clear(); foreach (Appointment oldAppointment in tmpAppointments_costumer) oldAppointment.Costumers_Appointments = null; tmpAppointments_costumer.Clear(); } }
private void UpdateInventoryListInternal() { System.Collections.ArrayList dirty_items = new System.Collections.ArrayList(); #region Equipped Items if (radioButton_inv_equipped.Checked) { for (int i = 0; i < listView_inventory_items.Count; i++) { uint id = Util.GetUInt32(((ListViewItem)listView_inventory_items[i]).SubItems[4].Text); if (Globals.gamedata.inventory.ContainsKey(id)) { //already in the list... InventoryInfo inv_inf = Util.GetInventory(id); if (inv_inf.isEquipped == 0x01) { inv_inf.InList = true; //update the entry if (inv_inf.Enchant == 0) { ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = Util.GetItemName(inv_inf.ItemID); } else { ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = "+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID); } ((ListViewItem)listView_inventory_items[i]).SubItems[1].Text = inv_inf.Count.ToString();//Count if (inv_inf.isEquipped == 0x01)//isEquipped { ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = "X"; } else { ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = " "; } //((ListViewItem)listView_inventory_items[i]).SubItems[3].Text = inv_inf.Slot.ToString();//Slot } else { //not in the list... //delete this item dirty_items.Add(i); } } else { //not in the list... //delete this item dirty_items.Add(i); } } //need to remove all dirty items now for (int i = dirty_items.Count - 1; i >= 0; i--) { listView_inventory_items.RemoveAt((int)dirty_items[i]); } dirty_items.Clear(); foreach (InventoryInfo inv_inf in Globals.gamedata.inventory.Values) { if (!inv_inf.InList && inv_inf.isEquipped == 0x01) { inv_inf.InList = true; //add it System.Windows.Forms.ListViewItem ObjListItem; if (inv_inf.Enchant == 0) { ObjListItem = new ListViewItem(Util.GetItemName(inv_inf.ItemID)); } else { ObjListItem = new ListViewItem("+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID)); } ObjListItem.SubItems.Add(inv_inf.Count.ToString());//Count if (inv_inf.isEquipped == 0x01)//isEquipped { ObjListItem.SubItems.Add("X"); //Do_Equip(inv_inf); } else { ObjListItem.SubItems.Add(" "); } ObjListItem.SubItems.Add(inv_inf.Slot.ToString());//Slot ObjListItem.SubItems.Add(inv_inf.ID.ToString());//ObjID ObjListItem.ImageIndex = AddInfo.Get_Item_Image_Index(inv_inf.ItemID); listView_inventory_items.Add(ObjListItem); } } } #endregion #region Normal Items if (radioButton_inv_items.Checked) { for (int i = 0; i < listView_inventory_items.Count; i++) { uint id = Util.GetUInt32(((ListViewItem)listView_inventory_items[i]).SubItems[4].Text); if (Globals.gamedata.inventory.ContainsKey(id)) { //already in the list... InventoryInfo inv_inf = Util.GetInventory(id); if (inv_inf.isEquipped != 0x01 && inv_inf.Type2 != 0x03) { inv_inf.InList = true; //update the entry if (inv_inf.Enchant == 0) { ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = Util.GetItemName(inv_inf.ItemID); } else { ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = "+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID); } ((ListViewItem)listView_inventory_items[i]).SubItems[1].Text = inv_inf.Count.ToString();//Count if (inv_inf.isEquipped == 0x01)//isEquipped { ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = "X"; } else { ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = " "; } //((ListViewItem)listView_inventory_items[i]).SubItems[3].Text = inv_inf.Slot.ToString();//Slot } else { //not in the list... //delete this item dirty_items.Add(i); } } else { //not in the list... //delete this item dirty_items.Add(i); } } //need to remove all dirty items now for (int i = dirty_items.Count - 1; i >= 0; i--) { listView_inventory_items.RemoveAt((int)dirty_items[i]); } dirty_items.Clear(); foreach (InventoryInfo inv_inf in Globals.gamedata.inventory.Values) { if (!inv_inf.InList && inv_inf.isEquipped != 0x01 && inv_inf.Type2 != 0x03) { inv_inf.InList = true; //add it System.Windows.Forms.ListViewItem ObjListItem; if (inv_inf.Enchant == 0) { ObjListItem = new ListViewItem(Util.GetItemName(inv_inf.ItemID)); } else { ObjListItem = new ListViewItem("+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID)); } ObjListItem.SubItems.Add(inv_inf.Count.ToString());//Count if (inv_inf.isEquipped == 0x01)//isEquipped { ObjListItem.SubItems.Add("X"); //Do_Equip(inv_inf); } else { ObjListItem.SubItems.Add(" "); } ObjListItem.SubItems.Add(inv_inf.Slot.ToString());//Slot ObjListItem.SubItems.Add(inv_inf.ID.ToString());//ObjID ObjListItem.ImageIndex = AddInfo.Get_Item_Image_Index(inv_inf.ItemID); listView_inventory_items.Add(ObjListItem); } } } #endregion #region Quest Items if (radioButton_inv_quest.Checked) { for (int i = 0; i < listView_inventory_items.Count; i++) { uint id = Util.GetUInt32(((ListViewItem)listView_inventory_items[i]).SubItems[4].Text); if (Globals.gamedata.inventory.ContainsKey(id)) { //already in the list... InventoryInfo inv_inf = Util.GetInventory(id); if (inv_inf.Type2 == 0x03) { inv_inf.InList = true; //update the entry if (inv_inf.Enchant == 0) { ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = Util.GetItemName(inv_inf.ItemID); } else { ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = "+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID); } ((ListViewItem)listView_inventory_items[i]).SubItems[1].Text = inv_inf.Count.ToString();//Count if (inv_inf.isEquipped == 0x01)//isEquipped { ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = "X"; } else { ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = " "; } //((ListViewItem)listView_inventory_items[i]).SubItems[3].Text = inv_inf.Slot.ToString();//Slot } else { //not in the list... //delete this item dirty_items.Add(i); } } else { //not in the list... //delete this item dirty_items.Add(i); } } //need to remove all dirty items now for (int i = dirty_items.Count - 1; i >= 0; i--) { listView_inventory_items.RemoveAt((int)dirty_items[i]); } dirty_items.Clear(); foreach (InventoryInfo inv_inf in Globals.gamedata.inventory.Values) { if (!inv_inf.InList && inv_inf.Type2 == 0x03) { inv_inf.InList = true; //add it System.Windows.Forms.ListViewItem ObjListItem; if (inv_inf.Enchant == 0) { ObjListItem = new ListViewItem(Util.GetItemName(inv_inf.ItemID)); } else { ObjListItem = new ListViewItem("+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID)); } ObjListItem.SubItems.Add(inv_inf.Count.ToString());//Count if (inv_inf.isEquipped == 0x01)//isEquipped { ObjListItem.SubItems.Add("X"); //Do_Equip(inv_inf); } else { ObjListItem.SubItems.Add(" "); } ObjListItem.SubItems.Add(inv_inf.Slot.ToString());//Slot ObjListItem.SubItems.Add(inv_inf.ID.ToString());//ObjID ObjListItem.ImageIndex = AddInfo.Get_Item_Image_Index(inv_inf.ItemID); listView_inventory_items.Add(ObjListItem); } } } #endregion }
private void UpdateItemsListInternal() { System.Collections.ArrayList dirty_items = new System.Collections.ArrayList(); for (int i = 0; i < listView_items_data_items.Count; i++) { uint id = Util.GetUInt32(((ListViewItem)listView_items_data_items[i]).SubItems[2].Text); if (Globals.gamedata.nearby_items.ContainsKey(id)) { ItemInfo item = Util.GetItem(id); item.InList = true; //update it //((ListViewItem)listView_items_data_items[i]).SubItems[0].Text = Util.GetItemName(item.ItemID); //((ListViewItem)listView_items_data_items[i]).SubItems[1].Text = item.Count.ToString(); //((ListViewItem)listView_items_data_items[i]).SubItems[2].Text = item.ID.ToString(); } else { dirty_items.Add(i); } } //need to remove all dirty items now for (int i = dirty_items.Count - 1; i >= 0; i--) { listView_items_data_items.RemoveAt((int)dirty_items[i]); } dirty_items.Clear(); foreach (ItemInfo item in Globals.gamedata.nearby_items.Values) { if (!item.InList) { item.InList = true; string mesh_info = ""; if (!item.HasMesh) { mesh_info = " [NO MESH]"; } //add it System.Windows.Forms.ListViewItem ObjListItem; ObjListItem = new ListViewItem(Util.GetItemName(item.ItemID) + mesh_info);//ItmID ObjListItem.SubItems.Add(item.Count.ToString());//Count ObjListItem.SubItems.Add(item.ID.ToString());//ObjID ObjListItem.ImageIndex = AddInfo.Get_Item_Image_Index(item.ItemID); listView_items_data_items.Add(ObjListItem); } } }
public void GetLeadsForOodle(string state) { int varcount = 0; string mainurl = "http://cars.oodle.com/used-cars/for-sale/" + state + "/condition_used/?o="; int res = 0; for (int i = 0; i <= 267; i++) { res = i * 15; string url1 = mainurl + res; FillCurrentPageData(url1); //url list Regex r11 = new Regex("<span class=\"listing-title\">(.*?)</span>"); str = content; str = content.Replace('\n', ' '); System.Collections.ArrayList al11 = new System.Collections.ArrayList(); System.Text.RegularExpressions.MatchCollection mc11 = null; mc11 = r11.Matches(str); al11.Clear(); al11.InsertRange(al11.Count, mc11); if (al11.Count > 0) { if (stopoodle) { for (int k = 0; k < al11.Count; k++) { string sname = ""; string title = ""; string url = ""; string price = ""; string phno = ""; string location = ""; string description = ""; string statename = ""; string city = ""; if (stopoodle) { #region data if (al11[k].ToString().IndexOf("href=") != -1) url = al11[k].ToString().Substring(al11[k].ToString().IndexOf("href=")); if(url.IndexOf("title=\"\"") !=-1) url = url.Substring(0, url.IndexOf("title=\"\"")); url = url.Replace(",,", ""); url = url.Replace("href=", ""); url = url.Replace("\"", ""); url = "http://cars.oodle.com" + url; FillCurrentPageData(url); //seller-name Regex r1 = new Regex("<span id=\"seller-name\">(.*?)</span>"); str = content; str = content.Replace('\n', ' '); System.Collections.ArrayList al1 = new System.Collections.ArrayList(); System.Text.RegularExpressions.MatchCollection mc1 = null; mc1 = r1.Matches(str); al1.Clear(); al1.InsertRange(al1.Count, mc1); if (al1.Count > 0) { for (int j = 0; j < al1.Count; j++) { sname = al1[j].ToString(); if (sname.IndexOf("</a>") != -1) { sname = sname.Substring(0, sname.IndexOf("</a>")); sname = sname.Replace("</a>", ""); sname = sname.Substring(sname.LastIndexOf(">")); sname = sname.Replace(">", ""); } else { sname = sname.Replace("<span>", ""); sname = sname.Replace("</span>", ""); } } } //title Regex r2 = new Regex("<h2 id=\"detail-title-text\">(.*?)</h2>"); System.Collections.ArrayList al2 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc2 = null; mc2 = r2.Matches(str); al2.Clear(); al2.InsertRange(al2.Count, mc2); if (al2.Count > 0) { for (int j = 0; j < al2.Count; j++) { title = al2[j].ToString(); title = title.Replace("<h2 id=\"detail-title-text\">", ""); title = title.Replace("</h2>", ""); title = title.Replace("\t", "").Trim(); } } //price Regex r3 = new Regex("<div id=\"listing-price\">(.*?)</div>(.*?)</div>");//<span class=\"h2\">(.*?)</span> // <div class=\"h1gray\">(.*?)</div> System.Collections.ArrayList al3 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc3 = null; mc3 = r3.Matches(str); al3.Clear(); al3.InsertRange(al3.Count, mc3); if (al3.Count > 0) { for (int j = 0; j < al3.Count; j++) { price = al3[j].ToString(); if (price.IndexOf("<span>") != -1) price = price.Substring(price.IndexOf("<span>")); price = price.Replace("<span>", ""); price = price.Replace("</span>", ""); price = price.Replace("</div>", ""); price = price.Replace("\t", "").Trim(); } } //location Regex r4 = new Regex("<div id=\"listing-location\" class=\"clearfix\">(.*?)</div>(.*?)</div>"); System.Collections.ArrayList al4 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc4 = null; mc4 = r4.Matches(str); al4.Clear(); al4.InsertRange(al4.Count, mc4); if (al4.Count > 0) { for (int j = 0; j < al4.Count; j++) { location = al4[j].ToString(); location = location.Replace("</div>", ""); if (location.LastIndexOf(">") != -1) location = location.Substring(location.LastIndexOf(">")); location = location.Replace(">", ""); if (location.IndexOf(",") != -1) { city = location.Substring(0, location.IndexOf(",")); statename = location.Replace(city, ""); statename = statename.Replace(",", ""); } else { city = ""; statename = location; } } } //description Regex r5 = new Regex("<div id=\"listing-description\" class=\"clearfix\">(.*?)</div>(.*?)</div>"); //<div id="listing-description" class="clearfix"> System.Collections.ArrayList al5 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc5 = null; mc5 = r5.Matches(str); al5.Clear(); al5.InsertRange(al5.Count, mc5); if (al5.Count > 0) { for (int j = 0; j < al5.Count; j++) { description = al5[j].ToString(); if (description.IndexOf("<span>") != -1) { description = description.Substring(description.IndexOf("<span>")); description = description.Replace("<span>", ""); description = description.Replace("</span>", ""); description = description.Replace("</div>", ""); string phone = Regex.Replace(description, "[A-Za-z]", ""); string[] digits = Regex.Split(phone, @"\D+"); for (int ph = 0; ph < digits.Length; ph++) { if (digits[ph].Length == 10) { phno = digits[ph]; } else if ((digits.Length > ph + 2) && digits[ph].Length == 3 && digits[ph + 1].Length == 3 && digits[ph + 2].Length == 4) { phno = digits[ph] + digits[ph + 1] + digits[ph + 2]; } else if ((digits.Length > ph + 1) && digits[ph].Length == 3 && digits[ph + 1].Length == 7) { phno = digits[ph] + digits[ph + 1]; } } } } } #endregion #region save varcount++; //objDal.SaveoodleData(title, sname, phno, price, statename,city, description, url); objDal.SaveLeadsData("", "", title, phno, price, url, sname, statename, city, "", "", "", "", "", "", "", "", "", "", "", "", ""); Navigate.Text = "Page :" + (1 + i).ToString() + "Rec No:" + (varcount + 1).ToString(); #endregion } } } } } }
public bool Shrink() { bool isChange = false; System.Collections.ArrayList rmlst = new System.Collections.ArrayList(); if (devlist.Count == 0) { this.DelMark = true; return false; } VDDeviceWrapper vd = this.devlist[0] as VDDeviceWrapper; VDDeviceWrapper lastVD = this.devlist[devlist.Count - 1] as VDDeviceWrapper; do { if (vd.jamLevel < 3) { isChange = true; rmlst.Add(vd); } else break; if (vd == lastVD) break; vd = vd.NextDevice as VDDeviceWrapper; } while (true); foreach (VDDeviceWrapper dev in rmlst) devlist.Remove(dev); if (devlist.Count == 0) { this.DelMark = true; return false; } rmlst.Clear(); vd = this.devlist[devlist.Count-1] as VDDeviceWrapper; lastVD = this.devlist[0] as VDDeviceWrapper; do { if (vd.jamLevel < 3) { rmlst.Add(vd); isChange = true; } else break; if (vd == lastVD) break; vd = vd.PreDevice as VDDeviceWrapper; } while (true); foreach (VDDeviceWrapper dev in rmlst) devlist.Remove(dev); if (devlist.Count == 0) { this.DelMark = true; return false; } devlist.Sort(); return isChange; }
public void loadTravelSetting() { System.Collections.ArrayList ary = new System.Collections.ArrayList(); System.Collections.ArrayList mainary = new System.Collections.ArrayList(); OdbcConnection cn = new OdbcConnection(Global.Db2ConnectionString); OdbcDataReader rdMain, rd; OdbcCommand cmd = new OdbcCommand(); OdbcCommand cmdMain = new OdbcCommand(); cmd.Connection = cn; cmdMain.Connection = cn; try { cn.Open(); cmdMain.CommandText = "select DISPLAY_PART ,g_code_id,message1,message2,msg1forecolor,msg2forecolor,msg1backcolor,msg2backcolor,uppertravelTime,lowerTravelTime,offset,enable from tblRGSTravelTime where devicename='" + this.deviceName + "' and enable='Y' order by display_part"; //if (deviceName == "CMS-T78-E-28.5") // Console.WriteLine(); rdMain = cmdMain.ExecuteReader(); while (rdMain.Read()) { ary.Clear(); int displaypart = System.Convert.ToInt32(rdMain[0]); int iconid = System.Convert.ToInt32(rdMain[1]); string mesg1 = rdMain[2].ToString(); string mesg2 = rdMain[3].ToString(); string[] tmp = rdMain[4].ToString().Split(new char[] { ',' }); byte[] fcolor1 = new byte[mesg1.Length]; // if (mesg1.Length != 0) for (int i = 0; i < fcolor1.Length; i++) fcolor1[i] = System.Convert.ToByte(tmp[i]); tmp = rdMain[5].ToString().Split(new char[] { ',' }); byte[] fcolor2 = new byte[mesg2.Length]; for (int i = 0; i < fcolor2.Length; i++) fcolor2[i] = System.Convert.ToByte(tmp[i]); tmp = rdMain[6].ToString().Split(new char[] { ',' }); int upperTravelTime = System.Convert.ToInt32(rdMain[8]); int lowerTraveltime = System.Convert.ToInt32(rdMain[9]); int offset = System.Convert.ToInt32(rdMain[10]); bool enable = rdMain[11].ToString().ToUpper() == "Y" ? true : false; //byte[] bcolor1 = new byte[tmp.Length]; //for (int i = 0; i < bcolor1.Length; i++) // bcolor1[i] = System.Convert.ToByte(tmp[i]); //tmp = rdMain[7].ToString().Split(new char[] { ',' }); //byte[] bcolor2 = new byte[tmp.Length]; //for (int i = 0; i < bcolor2.Length; i++) // bcolor2[i] = System.Convert.ToByte(tmp[i]); #region read detail cmd.CommandText = "select start_lineid, direction, display_part,start_mileage,end_mileage, isXml from tblRgsTravelTimeDetail where devicename='" + this.deviceName + "' and Display_part=" + displaypart; rd = cmd.ExecuteReader(); while (rd.Read()) { string lineid = rd[0].ToString(); string direction = rd[1].ToString(); int displaypartd = System.Convert.ToInt32(rd[2]); int startmile = System.Convert.ToInt32(rd[3]); int endmile = System.Convert.ToInt32(rd[4]); bool isXml = (System.Convert.ToString(rd[5])=="Y")?true:false;; ary.Add(new TravelDisplayDetailData(displaypartd, lineid, direction, startmile, endmile,isXml)); } rd.Close(); TravelDisplayDetailData[] ddata = new TravelDisplayDetailData[ary.Count]; for (int i = 0; i < ddata.Length; i++) ddata[i] = (TravelDisplayDetailData)ary.ToArray()[i]; #endregion mainary.Add(new TravelDisplaySettingData(displaypart, iconid, mesg1, mesg2, fcolor1, fcolor2, null, null, ddata,upperTravelTime,lowerTraveltime,offset,enable)); } rdMain.Close(); travelDisplaySettingData = new TravelDisplaySettingData[mainary.Count]; for (int i = 0; i < travelDisplaySettingData.Length; i++) travelDisplaySettingData[i] = (TravelDisplaySettingData)mainary.ToArray()[i]; } catch (Exception ex) { RemoteInterface.ConsoleServer.WriteLine(this.deviceName+ex.Message + ex.StackTrace); } finally { cn.Close(); } }
//private static byte[] MorrowindNocdMD5= { 172,252,170,234,11,184,94,254,190,35,82,235,117,170,153,249 }; public MainForm() { InitializeComponent(); lVersion.Text="Exe optimizer "+version; this.Text="Exe optimizer"; mainform=this; PatchDialog.mainform=this; //Load settings if(File.Exists("ExeOpt.ini")) { BinaryReader br=new BinaryReader(File.OpenRead("ExeOpt.ini")); if(br.ReadString()!=sVersion) { br.Close(); try { File.Delete("ExeOpt.ini"); } catch { } return; } tbBlacklist.Text=br.ReadString(); cbBenchmark.Checked=br.ReadBoolean(); cbDiscard.Checked=br.ReadBoolean(); cbWin98.Checked=br.ReadBoolean(); tbBias.Text=br.ReadString(); cbModv2s.Checked=br.ReadBoolean(); cbModv3s.Checked=br.ReadBoolean(); cbModv4s.Checked=br.ReadBoolean(); cbAlignv2s.Text=br.ReadString(); cbAlignv3s.Text=br.ReadString(); cbAlignv4s.Text=br.ReadString(); cbBackups.Checked=br.ReadBoolean(); cbLogs.Checked=br.ReadBoolean(); cbPrompts.Checked=br.ReadBoolean(); cbSave.Checked=br.ReadBoolean(); cbLoops.Text=br.ReadString(); cbReadHeader.Checked=br.ReadBoolean(); tbOffset.Text=br.ReadString(); tbCodeSize.Text=br.ReadString(); cbRestrict.Checked=br.ReadBoolean(); tbFirstPatch.Text=br.ReadString(); tbLastPatch.Text=br.ReadString(); MorrowindPath=br.ReadString(); if(MorrowindPath=="null"||!File.Exists(MorrowindPath+"\\Morrowind.exe")) { MorrowindPath=null; MorrowindInstalled=false; } else { MorrowindInstalled=true; lMorrowindVersion.Text="Morrowind installation found in:\n "+MorrowindPath; } br.Close(); } //Load advanced settings if(File.Exists("config.ini")) { StreamReader sr=new StreamReader(File.OpenRead("config.ini")); ArrayList list=new ArrayList(); string s=";"; while(s[0]!='[') { s=sr.ReadLine().Trim().ToLower(); if(s==""||s[0]==';') continue; if(s[0]!='[') list.Add(s); else { string[] lines=(string[])list.ToArray(typeof(string)); list.Clear(); switch(s) { case "[registers]": Program.Registers=lines; break; case "[jump instructions]": Program.JumpInstructions=lines; break; case "[fpu instructions]": Program.FpuInstructions=lines; break; case "[parsable fpu instructions]": Program.ReadableFpuInstructions=lines; break; case "[fpu ignore]": Program.FpuIgnoreInstructions=lines; break; case "[fpu read]": Program.FpuReadInstructions=lines; break; case "[fpu write]": Program.FpuWriteInstructions=lines; break; case "[read only instructions]": Program.ReadOnlyInstructions=lines; break; } } } } else { if(Environment.OSVersion.Platform==PlatformID.Win32NT) { cbWin98.Checked=false; } else { cbWin98.Checked=true; } } //Get morrowind installation directory if(!MorrowindInstalled) { RegistryKey rk=Registry.LocalMachine.OpenSubKey("Software\\Bethesda softworks\\morrowind"); string mPath; if(rk==null||(mPath=(string)rk.GetValue("Installed Path",null))==null|| !File.Exists(mPath+"\\Morrowind.exe")) { MorrowindInstalled=false; MorrowindPath=null; lMorrowindVersion.Text="Morrowind not installed"; } else { MorrowindInstalled=true; MorrowindPath=mPath; lMorrowindVersion.Text="Morrowind installation found in:\n "+MorrowindPath; } } }
private void UpdatePlayerListInternal() { bool Active = true; float x = Globals.gamedata.my_char.X; float y = Globals.gamedata.my_char.Y; float z = Globals.gamedata.my_char.Z; System.Collections.ArrayList dirty_items = new System.Collections.ArrayList(); for (int i = 0; i < listView_players_data_items.Count; i++) { uint id = Util.GetUInt32(((ListViewItem)listView_players_data_items[i]).SubItems[5].Text); if (Globals.gamedata.nearby_chars.ContainsKey(id)) { CharInfo player = Util.GetChar(id); player.InList = true; //update it ((ListViewItem)listView_players_data_items[i]).SubItems[0].Text = player.WarState.ToString(); //((ListViewItem)listView_players_data_items[i]).SubItems[1].Text = player.Name; if (Active) { ((ListViewItem)listView_players_data_items[i]).SubItems[2].Text = Util.GetClass(player.Class) + (player.isAlikeDead == 0x00 ? " :A: " : " :D: ") + ((int)Util.Distance(x, y, z, player.X, player.Y, player.Z)).ToString("0000"); } else { ((ListViewItem)listView_players_data_items[i]).SubItems[2].Text = Util.GetClass(player.Class); } ((ListViewItem)listView_players_data_items[i]).SubItems[3].Text = player.ClanName;//clan ((ListViewItem)listView_players_data_items[i]).SubItems[4].Text = player.AllyName;//ally //((ListViewItem)listView_players_data_items[i]).SubItems[5].Text = player.ID.ToString();//didnt change ((ListViewItem)listView_players_data_items[i]).ImageIndex = player.ClanCrestIndex; } else { dirty_items.Add(i); } } //need to remove all dirty items now for (int i = dirty_items.Count - 1; i >= 0; i--) { listView_players_data_items.RemoveAt((int)dirty_items[i]); } dirty_items.Clear(); foreach (CharInfo player in Globals.gamedata.nearby_chars.Values) { //find the item in our arraylist... if (!player.InList) { player.InList = true; //add it System.Windows.Forms.ListViewItem ObjListItem; ObjListItem = new ListViewItem(player.WarState.ToString());//war ObjListItem.SubItems.Add(player.Name);//name if (Active) { ObjListItem.SubItems.Add(Util.GetClass(player.Class) + (player.isAlikeDead == 0x00 ? " :A: " : " :D: ") + ((int)Util.Distance(x, y, z, player.X, player.Y, player.Z)).ToString("0000"));//class } else { ObjListItem.SubItems.Add(Util.GetClass(player.Class));//class } ObjListItem.SubItems.Add(player.ClanName);//clan ObjListItem.SubItems.Add(player.AllyName);//ally ObjListItem.SubItems.Add(player.ID.ToString());//ID //UpdateClanInfo(ObjListItem); if (player.ClanCrestIndex != 0) { ObjListItem.ImageIndex = player.ClanCrestIndex; } else { ObjListItem.ImageIndex = -1; } //oop cache if (Globals.gamedata.botoptions.OOPNamesArray.Contains(player.Name.ToUpperInvariant())) { if (!Globals.gamedata.botoptions.OOPIDs.Contains(player.ID)) { Globals.gamedata.botoptions.OOPIDs.Add(player.ID); } } listView_players_data_items.Add(ObjListItem); } } }
protected override Object CreateObject(NonterminalToken token) { string name; int bytes, inx, value; CmdItem cmdItem; TestValue testval; try { switch (token.Rule.Id) { case (int)RuleConstants.RULE_TESTGROUPEXPRESS_TESTEQ: CanTest = false; break; case (int)RuleConstants.RULE_VERSION_VERSIONEQ_FLOAT: this.version = token.Tokens[1].UserObject.ToString(); break; case (int)RuleConstants.RULE_TESTGROUPEXPRESS_TESTEQ2: CanTest = true; break; case (int)RuleConstants.RULE_TESTEXPRESS_ATCMD: tmpTestExpress.Add(tmpTestValues); tmpTestValues = new System.Collections.ArrayList(10); break; case (int)RuleConstants.RULE_TESTREPEATITEMS_LBRACE_RBRACE: testval = (TestValue)token.Tokens[0].UserObject; inx = tmpTestValues.IndexOf(testval); for (int i = inx + 1; i < tmpTestValues.Count; i++) testval.subValues.Add(tmpTestValues[i]); for (int i = tmpTestValues.Count - 1; i > inx; i--) tmpTestValues.RemoveAt(i); break; case (int)RuleConstants.RULE_TESTSELECTVALUE_NUMBER: return token.Tokens[0].ToString(); case (int)RuleConstants.RULE_TESTSELECTVALUES: return token.Tokens[0].UserObject; case (int)RuleConstants.RULE_TESTSELECTITEM_IDENTIFIER_LPARAN_RPARAN: name = token.Tokens[0].UserObject.ToString(); value = Convert.ToInt32(token.Tokens[2].UserObject.ToString()); tmpTestValues.Add(testval = new TestValue(name, value)); return testval; case (int)RuleConstants.RULE_TESTITEM2: return token.Tokens[0].UserObject; case (int)RuleConstants.RULE_RANGEITEM_IDENTIFIER_LPARAN_RPARAN: NonterminalToken ntok; name = token.Tokens[getTokenInx(token, "Identifier")].UserObject.ToString(); ntok = findToken(token, "Bytes"); bytes = Convert.ToInt32(ntok.Tokens[0].UserObject.ToString()); ntok = findToken(token, "LValue"); int lval = Convert.ToInt32(ntok.Tokens[0].UserObject.ToString()); ntok = findToken(token, "HValue"); int hval = Convert.ToInt32(ntok.Tokens[0].UserObject.ToString()); TmpCmdItems.Add(cmdItem = new CmdItem(name, bytes, lval, hval)); return cmdItem; case (int)RuleConstants.RULE_SELECTITEM_IDENTIFIER_LPARAN_RPARAN: SelectValue[] selectvalues; name = token.Tokens[0].UserObject.ToString(); bytes = Convert.ToInt32(findToken(token, "Bytes").Tokens[0].UserObject.ToString()); selectvalues = new SelectValue[TmpSelectValues.Count]; for (int i = 0; i < TmpSelectValues.Count; i++) { selectvalues[i] = (SelectValue)TmpSelectValues[i]; } TmpCmdItems.Add(cmdItem = new CmdItem(name, bytes, selectvalues)); TmpSelectValues.Clear(); return cmdItem; case (int)RuleConstants.RULE_SELECTVALUE_NUMBER: SelectValue sVal = new SelectValue(); sVal.value = Convert.ToInt32(token.Tokens[0].UserObject.ToString()); sVal.valueName = findToken(token, "ValueDescription").Tokens[0].UserObject.ToString(); TmpSelectValues.Add(sVal); break; case (int)RuleConstants.RULE_EXPRESSITEM: return token.Tokens[0].UserObject; case (int)RuleConstants.RULE_REPEATEXPRESS_LBRACE_RBRACE: inx = TmpCmdItems.IndexOf(token.Tokens[0].UserObject); for (int i = inx + 1; i < TmpCmdItems.Count; i++) ((CmdItem)TmpCmdItems[inx]).AddSubItems((CmdItem)TmpCmdItems[i]);//reduce repeat item for (int i = TmpCmdItems.Count - 1; i > inx; i--) TmpCmdItems.RemoveAt(i); return TmpCmdItems[inx]; case (int)RuleConstants.RULE_SENDEXPRESS_SENDEQ: //send express tmpSendExpress.Clear(); break; case (int)RuleConstants.RULE_SENDEXPRESS_SENDEQ2: //sendexpress tmpSendExpress = (System.Collections.ArrayList)TmpCmdItems.Clone(); TmpCmdItems.Clear(); break; case (int)RuleConstants.RULE_RETURNEXPRESS_RETURNEQ: tmpReturnExpress.Clear(); break; case (int)RuleConstants.RULE_RETURNEXPRESS_RETURNEQ2: tmpReturnExpress = (System.Collections.ArrayList)TmpCmdItems.Clone(); TmpCmdItems.Clear(); break; case (int)RuleConstants.RULE_DEVICETYPE_DEVICETYPEEQ_IDENTIFIER: this.DeviceType = token.Tokens[1].UserObject.ToString(); break; case (int)RuleConstants.RULE_IP_IPEQ_IP: ip = token.Tokens[1].UserObject.ToString(); break; case (int)RuleConstants.RULE_PORT_PORTEQ_NUMBER: port = int.Parse(token.Tokens[1].UserObject.ToString()); break; case (int)RuleConstants.RULE_DEVICEID_DEVICEIDEQ_DEVICEID: deviceId = Convert.ToInt32(token.Tokens[1].ToString(), 16); break; case (int)RuleConstants.RULE_CMD_CMDEQ_CMD: //Cmd cmd; //if(token.Tokens[2].UserObject==null) // cmd=new Cmd(Convert.ToByte(token.Tokens[1].UserObject.ToString(),16)); //else //cmd=new Cmd(Convert.ToByte(token.Tokens[1].UserObject.ToString(),16), // Convert.ToByte(token.Tokens[2].UserObject.ToString(),16)); // return cmd; break; case (int)RuleConstants.RULE_COMMAND: //CmdClass cls; //CmdType type; //string desc; //string func_name; //byte cmdcode; Cmd cmd = new Cmd(this); // inx = getTokenInx(token, "Description"); for (int i = 0; i < token.Tokens.Length; i++) { NonterminalToken ttok; ttok = (NonterminalToken)token.Tokens[i]; if (token.Rule.Rhs[i].Name == "Description") { cmd.description = ((NonterminalToken)token.Tokens[i]).Tokens[1].UserObject.ToString().Trim(new char[] { '\"' }); } else if (token.Rule.Rhs[i].Name == "FuncName") { cmd.cmdName = ((NonterminalToken)token.Tokens[i]).Tokens[1].UserObject.ToString().Trim(new char[] { '\"' }); } else if (token.Rule.Rhs[i].Name == "CmdClass") { switch (((NonterminalToken)token.Tokens[i]).Tokens[1].UserObject.ToString()[0]) { case 'A': cmd.cmdClass = CmdClass.A; break; case 'B': cmd.cmdClass = CmdClass.B; break; case 'C': cmd.cmdClass = CmdClass.C; break; case 'D': cmd.cmdClass = CmdClass.D; break; } } else if (token.Rule.Rhs[i].Name == "CmdType") { if (((NonterminalToken)token.Tokens[i]).Tokens[1].UserObject.ToString() == "Set") cmd.cmdType = CmdType.CmdSet; else if (((NonterminalToken)token.Tokens[i]).Tokens[1].UserObject.ToString() == "Query") cmd.cmdType = CmdType.CmdQuery; else if (((NonterminalToken)token.Tokens[i]).Tokens[1].UserObject.ToString() == "Report") cmd.cmdType = CmdType.CmdReport; else cmd.cmdType = CmdType.CmdUnkonwn; } else if (token.Rule.Rhs[i].Name == "Cmd") { cmd.cmd = Convert.ToByte(ttok.Tokens[1].UserObject.ToString(), 16); //cmd if (((NonterminalToken)ttok.Tokens[2]).Tokens.Length > 0) cmd.subCmd = Convert.ToByte(((NonterminalToken)ttok.Tokens[2]).Tokens[0].UserObject.ToString(), 16); //subCmd } } //for cmd.SendCmdItems = (System.Collections.ArrayList)tmpSendExpress.Clone(); cmd.ReturnCmdItems = (System.Collections.ArrayList)tmpReturnExpress.Clone(); cmd.TestGroupValues = tmpTestExpress; cmd.CanTest = CanTest; tmpReturnExpress.Clear(); tmpSendExpress.Clear(); tmpTestValues.Clear(); tmpTestExpress = new System.Collections.ArrayList(5); //try //{ if (cmd.cmdType != CmdType.CmdReport) cmd.CheckTestValue(); cmd.GenerateCmdDataSet(); //} //catch (Exception ex) //{ // Console.WriteLine(ex.StackTrace); //} this.AddCmd(cmd); break; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); throw ex; } return null; }
private void UpdateNPCListInternal() { System.Collections.ArrayList dirty_items = new System.Collections.ArrayList(); for (int i = 0; i < listView_npc_data.Items.Count; i++) { uint id = Util.GetUInt32(((ListViewItem)listView_npc_data_items[i]).SubItems[2].Text); if (Globals.gamedata.nearby_npcs.ContainsKey(id)) { NPCInfo npc = Util.GetNPC(id); npc.InList = true; //update it //((ListViewItem)listView_npc_data_items[i]).SubItems[0].Text = Util.GetNPCName(npc.NPCID); //((ListViewItem)listView_npc_data_items[i]).SubItems[1].Text = npc.Title; //((ListViewItem)listView_npc_data_items[i]).SubItems[2].Text = npc.ID.ToString(); //((ListViewItem)listView_npc_data_items[i]).SubItems[3].Text = npc.NPCID.ToString(); } else { dirty_items.Add(i); } } //need to remove all dirty items now for (int i = dirty_items.Count - 1; i >= 0; i--) { listView_npc_data_items.RemoveAt((int)dirty_items[i]); } dirty_items.Clear(); foreach (NPCInfo npc in Globals.gamedata.nearby_npcs.Values) { if (!npc.InList) { npc.InList = true; if (npc.isInvisible != 1) { //add it System.Windows.Forms.ListViewItem ObjListItem; ObjListItem = new ListViewItem(Util.GetNPCName(npc.NPCID));//Name ObjListItem.SubItems.Add(npc.Title);//Title ObjListItem.SubItems.Add(npc.ID.ToString());//ObjID ObjListItem.SubItems.Add(npc.NPCID.ToString());//TypeID listView_npc_data_items.Add(ObjListItem); } } } }
public void BackPage(string state) { string phno = ""; string title = ""; string price = ""; int varcount = 0; string city = ""; for (int j = 1; j <= 100; j++) { string mainurl = "http://" + state.Replace(" ", "").ToLower() + ".backpage.com/AutosForSale/" + "?page=" + j; FillCurrentPageData(mainurl); Regex r1 = new Regex("<div class=\"cat\">(.*?)</div>"); str = content; str = content.Replace('\n', ' '); System.Collections.ArrayList al1 = new System.Collections.ArrayList(); System.Text.RegularExpressions.MatchCollection mc1 = null; mc1 = r1.Matches(str); al1.Clear(); al1.InsertRange(al1.Count, mc1); if (al1.Count > 0) { if (stopbackpage) { for (int i = 0; i < al1.Count; i++) { if (stopbackpage) { string url = al1[i].ToString(); url = url.Replace("<div class=\"cat\">", ""); url = url.Substring(0, url.IndexOf(">")); url = url.Replace("<a href=", ""); url = url.Replace("\r", ""); url = url.Replace("\"", "").Trim(); FillCurrentPageData(url); Regex r21 = new Regex("<div style=\"padding-left:2em;\">(.*?)</div>"); System.Collections.ArrayList al21 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc21 = null; mc21 = r21.Matches(str); al21.Clear(); al21.InsertRange(al21.Count, mc21); if (al21.Count > 0) { city = al21[0].ToString(); city = city.Replace("<div style=\"padding-left:2em;\">", ""); city = city.Replace("• Location:", "").Trim(); city = city.Replace("</div>", "").Trim(); if (city.IndexOf(",") != -1) { city = city.Substring(0, city.IndexOf(",")); city = city.Replace(",", ""); } } Regex r2 = new Regex("<a class=\"h1link\" href=\"javascript:void;\">(.*?)</a>"); System.Collections.ArrayList al2 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc2 = null; mc2 = r2.Matches(str); al2.Clear(); al2.InsertRange(al2.Count, mc2); if (al2.Count > 0) { for (int k = 0; k < al2.Count; k++) { title = al2[k].ToString(); title = title.Replace("<a class=\"h1link\" href=\"javascript:void;\">", ""); title = title.Replace("</a>", ""); title = title.Replace("<h1>", ""); title = title.Replace("</h1>", ""); if (title.Contains("$")) { title = title.Replace(",", ""); price = title.Substring(0, title.IndexOf(" ")); } } } Regex r3 = new Regex("<div class=\"postingBody\">(.*?)</div>(.*?)<p class=\"metaInfoDisplay\">"); //<span class=\"h2\">(.*?)</span> // <div class=\"h1gray\">(.*?)</div> System.Collections.ArrayList al3 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc3 = null; mc3 = r3.Matches(str); al3.Clear(); al3.InsertRange(al3.Count, mc3); phno = ""; if (al3.Count > 0) { for (int l = 0; l < al3.Count; l++) { string desc = al3[l].ToString(); string phone = Regex.Replace(desc, "[A-Za-z]", ""); string[] digits = Regex.Split(phone, @"\D+"); for (int ph = 0; ph < digits.Length; ph++) { if (digits[ph].Length == 10) { phno = digits[ph]; } else if ((digits.Length > ph + 2) && digits[ph].Length == 3 && digits[ph + 1].Length == 3 && digits[ph + 2].Length == 4) { phno = digits[ph] + digits[ph + 1] + digits[ph + 2]; } else if ((digits.Length > ph + 1) && digits[ph].Length == 3 && digits[ph + 1].Length == 7) { phno = digits[ph] + digits[ph + 1]; } } if (phno == "") { Regex r4 = new Regex("<p class=\"metaInfoDisplay\">(.*?)</p>"); System.Collections.ArrayList al4 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc4 = null; mc4 = r4.Matches(str); al4.Clear(); al4.InsertRange(al4.Count, mc4); if (al4.Count > 0) { for (int m = 0; m < al4.Count; m++) { string desc1 = al4[m].ToString(); phone = Regex.Replace(desc1, "[A-Za-z]", ""); digits = Regex.Split(phone, @"\D+"); for (int ph = 0; ph < digits.Length; ph++) { if (digits[ph].Length == 10) { phno = digits[ph]; } else if ((digits.Length > ph + 2) && digits[ph].Length == 3 && digits[ph + 1].Length == 3 && digits[ph + 2].Length == 4) { phno = digits[ph] + digits[ph + 1] + digits[ph + 2]; } else if ((digits.Length > ph + 1) && digits[ph].Length == 3 && digits[ph + 1].Length == 7) { phno = digits[ph] + digits[ph + 1]; } } } } } } } varcount++; //objDal.SaveBackPageLeads(title, price, phno, cmbState.SelectedItem.ToString().ToLower(), url); objDal.SaveLeadsData("", "", title, phno, price, url, "", state, city, "", "", "", "", "", "", "", "", "", "", "", "", ""); Navigate.Text = "Page :" + j.ToString() + "Rec No:" + (varcount + 1).ToString(); } } } } } }
private void UpdateMyBuffsListInternal() { System.Collections.ArrayList dirty_items = new System.Collections.ArrayList(); for (int i = 0; i < listView_mybuffs_data.Items.Count; i++) { uint id = Util.GetUInt32(((ListViewItem)listView_mybuffs_data_items[i]).SubItems[3].Text); if (Globals.gamedata.mybuffs.ContainsKey(id)) { CharBuff cb = Util.GetBuff(id); cb.InList = true; if (cb.ExpiresTime == -1) { ((ListViewItem)listView_mybuffs_data_items[i]).SubItems[2].Text = "ON"; } else { System.TimeSpan remain = new System.TimeSpan(cb.ExpiresTime - System.DateTime.Now.Ticks); //update it //((ListViewItem)listView_npc_data_items[i]).SubItems[0].Text = Util.GetNPCName(npc.NPCID); //((ListViewItem)listView_npc_data_items[i]).SubItems[1].Text = npc.Title; ((ListViewItem)listView_mybuffs_data_items[i]).SubItems[2].Text = ((int)remain.TotalMinutes).ToString() + ":" + remain.Seconds.ToString(); //((ListViewItem)listView_mybuffs_data_items[i]).SubItems[2].Text = cb.ID.ToString(); } } else { dirty_items.Add(i); } } //need to remove all dirty items now for (int i = dirty_items.Count - 1; i >= 0; i--) { listView_mybuffs_data_items.RemoveAt((int)dirty_items[i]); } dirty_items.Clear(); foreach (CharBuff cb in Globals.gamedata.mybuffs.Values) { if (!cb.InList) { cb.InList = true; System.TimeSpan remain = new System.TimeSpan(0); if (cb.ExpiresTime == -1) { } else { remain = new System.TimeSpan(cb.ExpiresTime - System.DateTime.Now.Ticks); } //add it System.Windows.Forms.ListViewItem ObjListItem; ObjListItem = new ListViewItem(Util.GetSkillName(cb.ID,cb.SkillLevel));//Name ObjListItem.SubItems.Add(cb.SkillLevel.ToString());//Title if (cb.ExpiresTime == -1) { ObjListItem.SubItems.Add("ON"); } else { ObjListItem.SubItems.Add(((int)remain.TotalMinutes).ToString() + ":" + remain.Seconds.ToString());//Remaining Time } ObjListItem.SubItems.Add(cb.ID.ToString());//ObjID ObjListItem.ImageIndex = AddInfo.Get_Skill_Image_Index(cb.ID); listView_mybuffs_data_items.Add(ObjListItem); } } }
/// <summary> /// �q�v���Z�X(����)��擾���� /// </summary> /// <param name="i_Process"></param> /// <returns>Process[] �q�v���Z�X�I�u�W�F�N�g�z��</returns> public static System.Diagnostics.Process[] GetChileProcess( System.Diagnostics.Process i_Process ) { System.IntPtr a_hSnapShot = System.IntPtr.Zero; PROCESSENTRY32 a_Entry; System.Collections.ArrayList a_ProcessArray = null; try { a_hSnapShot = CreateToolhelp32Snapshot( SnapshotFlags.Process, 0 ); a_Entry = new PROCESSENTRY32(); a_Entry.dwSize = (uint)Memory.SizeOf( a_Entry ); a_ProcessArray = new System.Collections.ArrayList( 0 ); if ( Process32First( a_hSnapShot, ref a_Entry ) ) { /* ////////////////////////////////////////////////////// */ // �e�v���Z�XID���w�肵���v���Z�XID�ƈ�v����v���Z�X��z��֒lj����� do { if ( i_Process.Id == a_Entry.th32ParentProcessID ) { try { a_ProcessArray.Add( System.Diagnostics.Process.GetProcessById( (int)a_Entry.th32ProcessID ) ); } catch ( System.Exception ex ) { // ��O�������̓v���Z�X�z���N���A���ĊO�֗�O�𓊂��� a_ProcessArray.Clear(); throw ex; } finally { } } } while( Process32Next( a_hSnapShot, ref a_Entry ) ); /* ////////////////////////////////////////////////////// */ } } catch ( System.Exception ex ) { // ��O�������͔z���J�����ĊO�֗�O�𓊂��� a_ProcessArray = null; throw ex; } finally { CloseHandle( a_hSnapShot ); a_hSnapShot = System.IntPtr.Zero; } return (System.Diagnostics.Process[])a_ProcessArray.ToArray( typeof( System.Diagnostics.Process ) ); }
void DataRepairTask() { System.Collections.ArrayList aryThread = new System.Collections.ArrayList(); System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(Comm.DB2.Db2.db2ConnectionStr); System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand(); cmd.CommandTimeout = 120; StRepairData rpd=null;//=new StRepairData(); cmd.Connection = cn; System.Collections.Queue queue = new System.Collections.Queue(); int dayinx = 1; while (true) { Comm.TC.VDTC tc; if (!IsLoadTcCompleted ) { System.Threading.Thread.Sleep(1000); continue; } try { // cn= new System.Data.Odbc.OdbcConnection(Comm.DB2.Db2.db2ConnectionStr); while (this.dbServer.getCurrentQueueCnt() > 50) System.Threading.Thread.Sleep(1000 * 10); cn.Open(); ConsoleServer.WriteLine("Repair task begin!"); cmd.Connection = cn; // string sqlGetRepair = "select * from (SELECT t1.DEVICENAME, t1.TIMESTAMP ,trycnt,datavalidity FROM TBLVDDATA1MIN t1 inner join tbldeviceconfig t2 on t1.devicename=t2.devicename WHERE mfccid='{0}' and comm_state <> 3 and t1.TIMESTAMP between '{1}' and '{2}' and trycnt<3 fetch first 300 row only ) where DATAVALIDITY = 'N' order by trycnt,timestamp desc "; string sqlGetRepair = "select t1.DEVICENAME, TIMESTAMP ,trycnt,datavalidity,comm_state from TBLVDDATA1MIN t1 inner join tblDeviceConfig t2 on t1.devicename=t2.devicename where mfccid='{0}' and TIMESTAMP between '{1}' and '{2}' and trycnt <1 and datavalidity='N' and comm_state=1 and enable='Y' order by timestamp desc fetch first 300 row only "; cmd.CommandText = string.Format(sqlGetRepair,mfccid, Comm.DB2.Db2.getTimeStampString(System.DateTime.Now.AddDays(-dayinx)), Comm.DB2.Db2.getTimeStampString(System.DateTime.Now.AddDays(-dayinx+1).AddMinutes(-10))); System.Data.Odbc.OdbcDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { string devName="" ; DateTime dt ; devName = rd[0] as string; dt = System.Convert.ToDateTime(rd[1]); queue.Enqueue(new StRepairData(dt,devName)); } rd.Close(); ConsoleServer.WriteLine("total:" + queue.Count + " to repair!"); if (queue.Count < 300) { dayinx++; if (dayinx ==4) dayinx = 1; } if(queue.Count<10) System.Threading.Thread.Sleep(1000 * 60); aryThread.Clear(); while (queue.Count!=0) { try { rpd =(StRepairData)queue.Dequeue() ; if (Program.mfcc_vd.manager.IsContains(rpd.devName)) tc = (Comm.TC.VDTC)Program.mfcc_vd.manager[rpd.devName]; else continue; if (!tc.IsConnected) { dbServer.SendSqlCmd(string.Format("update tbldeviceconfig set comm_state=3 where devicename='{0}' ", rpd.devName)); continue; } System.Threading.Thread th= new System.Threading.Thread(Repair_job); aryThread.Add(th); th.Start(rpd); if (aryThread.Count >= 5) { for (int i = 0; i < aryThread.Count; i++) ((System.Threading.Thread)aryThread[i]).Join(); aryThread.Clear(); } // ConsoleServer.WriteLine("==>repair:" + rpd.devName + "," + rpd.dt.ToString()); } catch (Exception ex) { ConsoleServer.WriteLine( ex.Message + ex.StackTrace); } } for (int i = 0; i < aryThread.Count; i++) ((System.Threading.Thread)aryThread[i]).Join(); aryThread.Clear(); } catch (Exception x) { ConsoleServer.WriteLine(x.Message+ x.StackTrace); } finally { try { cn.Close(); } catch { ;} } } }
public void ProcessRequest(MFToolkit.Net.Web.HttpContext context) { string rawURL_string = string.Empty; string menu_Pachube = string.Empty; string menu_SuperUser = string.Empty; DateTime endTime = DateTime.Now; TimeSpan span = endTime.Subtract(AlarmByZones.dLastResetCycle); string strUptime = span.Duration().Days == 1 ? span.Days + " day " + span.Hours + " hours " + span.Minutes + " minutes" : span.Days + " days " + span.Hours + " hours " + span.Minutes + " minutes " + "<br>"; if (Alarm.ConfigDefault.Data.USE_PACHUBE) { menu_Pachube = "<li class=\"toplinks\"><a href='/pachube' title='Generates Pachube Graphics'>PACHUBE GRAPHICS</a></li>"; } if (context.Request.RawUrl == "/su") { menu_SuperUser = "******"; } string menu_Header = "<div>\n" + "<ul>\n" + "<li class='toplinks'><a href='/' title='Home'>HOME</a></li>\n" + "<li class='toplinks'><a href='/sdcard' title='Retrieve alarm events stored in SD Card'>SD CARD EVENT LOG</a></li>\n" + menu_Pachube + menu_SuperUser + "<li class='toplinks'><a href='/diag' title='Diagnostics'>DIAGNOSTICS</a></li>\n" + "<li class='toplinks'><a href='" + Alarm.ConfigDefault.Data.HTTP_HOST + "' target='_blank' title='HomeAlarmPlus Pi'>HomeAlarmPlus Pi</a></li>\n" + "<li class='toplinks'><a href='" + Alarm.ConfigDefault.Data.HTTP_HOST + "/NetduinoPlus/about-netduino.php' title='Credits and contributors'>ABOUT</a></li>\n" + "</ul>\n" + "</div>\n"; string jquery_ui_script = "<script src='http://code.jquery.com/jquery-1.9.1.js'></script>" + "<script src='http://code.jquery.com/ui/1.10.2/jquery-ui.js'></script>" + "<link rel='stylesheet' href='http://code.jquery.com/ui/1.10.2/themes/redmond/jquery-ui.css' />"; string fileLink = string.Empty; try { rawURL_string = context.Request.RawUrl.Substring(0, 5); } catch { } try { if (rawURL_string == "/open") { string[] url = context.Request.RawUrl.Split('_'); fileLink = context.Request.RawUrl.Substring(6, context.Request.RawUrl.Length - 6); fileLink = Extension.Replace(fileLink, "/", @"\"); context.Request.RawUrl = "/open"; } } catch { } try { if (rawURL_string == "/date") { string[] url = context.Request.RawUrl.Split('_'); DateTime networkDateTime = new DateTime(Int16.Parse((url[1])), Int16.Parse(url[2]), Int16.Parse(url[3]), Int16.Parse(url[4]), Int16.Parse(url[5]), Int16.Parse(url[6])); Debug.Print(networkDateTime.ToString()); Utility.SetLocalTime(networkDateTime); context.Request.RawUrl = "/date"; } } catch { } try { if (rawURL_string == "/weat") { string[] url = context.Request.RawUrl.Split('_'); Alarm.Common.Weather_Info.current_temperature = url[1] + Alarm.Common.Weather_Info.WEATHER_UNITS; Alarm.Common.Weather_Info.current_conditions = url[2]; Alarm.Common.Weather_Info.today_high = url[3] + Alarm.Common.Weather_Info.WEATHER_UNITS; ; Alarm.Common.Weather_Info.today_low = url[4] + Alarm.Common.Weather_Info.WEATHER_UNITS; ; context.Request.RawUrl = "/weat"; } } catch { } switch (context.Request.RawUrl) { case "/date": case "/weat": break; case "/su": case "/": case "/mobile": //AlarmByZones.email.SendEmail("Web Server access", "Home web server access.\nAssemblyInfo: " + System.Reflection.Assembly.GetExecutingAssembly().FullName); //PushingBox Web server access notification Notification.PushingBox.Notification.Connect("vPUSHINGBOX"); string time = DateTime.Now.ToString(); string ttime = Extension.Replace(time, " ", "%20"); Notification.Pushover.Connect(ttime, "Netduino%20Plus%20Web%20Trigger", "Web%20Server%20Access%20from%20Netduino%20Plus", false); Console.DEBUG_ACTIVITY(Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress); string HTML_tbHeader = "<table class='gridtable'><tr><th><center>Time</center></th><th><center>Zone/Sensor</center></th><th><center>Description</center></th></tr>"; string AlarmStatus = Alarm.Common.Alarm_Info.sbActivity.Length == 0 ? "No Alarms/Sensors " : HTML_tbHeader + Alarm.Common.Alarm_Info.sbActivity.ToString(); context.Response.ContentType = "text/html"; context.Response.WriteLine("<html><head><title>Control Panel - Home</title>"); context.Response.WriteLine("<meta name='author' content='Gilberto García'/>"); context.Response.WriteLine("<meta name='mod-date' content='01/02/2014'/>"); context.Response.WriteLine("<meta name='application-name' content='HomeAlarm Plus'/>"); context.Response.WriteLine("<meta charset='utf-8' />"); context.Response.WriteLine("<meta name='viewport' content='initial-scale=1.0, user-scalable=no' />"); context.Response.WriteLine("<meta name='apple-mobile-web-app-capable' content='yes' />"); context.Response.WriteLine("<meta name='apple-mobile-web-app-status-bar-style' content='black' />"); if (context.Request.RawUrl == "/mobile") { context.Response.WriteLine("<link rel='stylesheet' type='text/css' href='" + Alarm.ConfigDefault.Data.HTTP_HOST + "WebResources/jquery_table_style_blue.css'></style>"); context.Response.WriteLine("<link rel='stylesheet' href='http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css' />"); context.Response.WriteLine("<script src='http://code.jquery.com/jquery-1.7.2.min.js'></script>"); context.Response.WriteLine("<script src='http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js'></script>"); context.Response.WriteLine("<script src='" + Alarm.ConfigDefault.Data.HTTP_HOST + "WebResources/jquery_animate_collapse.js'></script>"); context.Response.WriteLine("</head><body>"); context.Response.WriteLine("<div data-role='page' id='mobile-page' data-add-back-btn='true' data-theme='b' data-content-theme='b'>"); context.Response.WriteLine("<div data-theme='b' data-role='header' class='jqm-header' data-fullscreen='true' >"); context.Response.WriteLine("<h3>Alarm Activity - Monitor System #1 - Home</h3>"); context.Response.WriteLine("</div>"); context.Response.WriteLine("<div data-role='content'>"); context.Response.WriteLine("<div class='content-primary'>"); context.Response.WriteLine("<p>System Time: <b>" + DateTime.Now.ToString("dd MMM yyyy hh:mm:ss tt").ToUpper() + "</b></p></br>"); context.Response.WriteLine("Alarm Status Log: " + AlarmStatus); context.Response.WriteLine("</table>"); context.Response.WriteLine("</div>"); context.Response.WriteLine("</div>"); context.Response.WriteLine("<br/><br/><br/>"); context.Response.WriteLine("<div data-role='footer' class='footer-docs' data-theme='c' data-position='fixed'>"); context.Response.WriteLine("<p>Copyright 2014 Gilberto García</p>"); context.Response.WriteLine("</div> "); } else { context.Response.WriteLine(jquery_ui_script); context.Response.WriteLine("<link rel='stylesheet' type='text/css' href='" + Alarm.ConfigDefault.Data.HTTP_HOST + "WebResources/header_style.css'></style>"); context.Response.WriteLine("<link rel='stylesheet' type='text/css' href='" + Alarm.ConfigDefault.Data.HTTP_HOST + "WebResources/table_style.css'></style>"); context.Response.WriteLine("</head><body>"); context.Response.WriteLine("<div class='ui-widget'>\n"); context.Response.WriteLine("<div class='ui-widget-header ui-corner-top'>\n"); context.Response.WriteLine("<h2>Alarm Activity - Monitor System #1</h2></div>"); context.Response.WriteLine("<div class='ui-widget-content ui-corner-bottom'>"); context.Response.WriteLine("<p>System Time: <b>" + DateTime.Now.ToString("dd MMM yyyy hh:mm:ss tt").ToUpper() + "</b></p></br>"); context.Response.WriteLine(menu_Header); context.Response.WriteLine("<br>"); context.Response.WriteLine("Alarm Status Log: " + AlarmStatus); context.Response.WriteLine("</table>"); context.Response.WriteLine("<br><br>"); context.Response.WriteLine("<div style='border:1px solid #CCCCCC;'>"); context.Response.WriteLine("<p><span class='note'>Copyright © 2014 Gilberto García</span></p></div></div>"); } context.Response.WriteLine("</div></body></html>"); //clear variables HTML_tbHeader = null; AlarmStatus = null; menu_Header = null; rawURL_string = null; break; case "/assy": string assy = Properties.Resources.GetString(Properties.Resources.StringResources.assy_builddate); context.Response.ContentType = "text/html"; context.Response.WriteLine(assy); //clear variables assy = null; rawURL_string = null; break; case "/sdcard": context.Response.ContentType = "text/html"; context.Response.WriteLine("<html><head><title>Control Panel - SD Card History Log</title>"); context.Response.WriteLine("<meta name='author' content='Gilberto García'/>"); context.Response.WriteLine("<meta name='mod-date' content='01/02/2014'/>"); context.Response.WriteLine("<meta name='application-name' content='HomeAlarm Plus'/>"); context.Response.WriteLine("<meta charset='utf-8' />"); context.Response.WriteLine("<meta name='viewport' content='initial-scale=1.0, user-scalable=no' />"); context.Response.WriteLine("<meta name='apple-mobile-web-app-capable' content='yes' />"); context.Response.WriteLine("<meta name='apple-mobile-web-app-status-bar-style' content='black' />"); context.Response.WriteLine(jquery_ui_script); context.Response.WriteLine("<link rel='stylesheet' type='text/css' href='" + Alarm.ConfigDefault.Data.HTTP_HOST + "WebResources/header_style.css'></style>"); context.Response.WriteLine("</head><body>"); context.Response.WriteLine("<div class='ui-widget'>\n"); context.Response.WriteLine("<div class='ui-widget-header ui-corner-top'>\n"); context.Response.WriteLine("<h2>Alarm Activity - Monitor System #1</h2></div>"); context.Response.WriteLine("<div class='ui-widget-content ui-corner-bottom'>"); context.Response.WriteLine("<p>System Time: <b>" + DateTime.Now.ToString("dd MMM yyyy hh:mm:ss tt").ToUpper() + "</b></p></br>"); if (AlarmByZones.SdCardEventLogger.IsSDCardAvailable()) { context.Response.WriteLine("SD Card detected and found the following files:<br><br>"); context.Response.WriteLine("<form name='sdForm'"); int i = 0; try { foreach (string file in AlarmByZones.SdCardEventLogger.FileList) { context.Response.WriteLine(file + "<br>"); Console.DEBUG_ACTIVITY(i.ToString() + " " + file); i++; } context.Response.WriteLine("</form>"); } catch (Exception ex) { Debug.Print(ex.Message); } } else { context.Response.WriteLine(AlarmByZones.SdCardEventLogger.NO_SD_CARD + "<br>"); } context.Response.WriteLine("<br>"); context.Response.WriteLine("<a href='/'>Back to main page...</a>"); context.Response.WriteLine("<div style='border:1px solid #CCCCCC;'>"); context.Response.WriteLine("<p><span class='note'>Copyright © 2014 Gilberto García</span></p>"); context.Response.WriteLine("</div></div></div></body></html>"); rawURL_string = null; break; case "/open": System.Collections.ArrayList alOpen = new System.Collections.ArrayList(); context.Response.ContentType = "text/html"; context.Response.WriteLine("<html><head><title>Control Panel - Open SD Card File</title>"); context.Response.WriteLine("<meta name='author' content='Gilberto García'/>"); context.Response.WriteLine("<meta name='mod-date' content='01/02/2014'/>"); context.Response.WriteLine("<meta name='application-name' content='HomeAlarm Plus'/>"); context.Response.WriteLine(jquery_ui_script); context.Response.WriteLine("<link rel='stylesheet' type='text/css' href='" + Alarm.ConfigDefault.Data.HTTP_HOST + "WebResources/header_style.css'></style>"); context.Response.WriteLine("</head><body>"); context.Response.WriteLine("<div class='ui-widget'>\n"); context.Response.WriteLine("<div class='ui-widget-header ui-corner-top'>\n"); context.Response.WriteLine("<h2>Alarm Activity - Monitor System #1</h2></div>"); context.Response.WriteLine("<div class='ui-widget-content ui-corner-bottom'>"); context.Response.WriteLine(menu_Header); context.Response.WriteLine("<p>System Time: <b>" + DateTime.Now.ToString("dd MMM yyyy hh:mm:ss tt").ToUpper() + "</b></p></br>"); if (AlarmByZones.SdCardEventLogger.IsSDCardAvailable()) { AlarmByZones.SdCardEventLogger.openFileContent(fileLink, alOpen); context.Response.WriteLine("File: " + fileLink + "<br>"); context.Response.WriteLine("File Content: " + "<br>"); foreach (string content in alOpen) { context.Response.WriteLine(content + "<br>"); } //clear variables alOpen.Clear(); } else { context.Response.WriteLine(AlarmByZones.SdCardEventLogger.NO_SD_CARD); } context.Response.WriteLine("<br><br>"); context.Response.WriteLine("<a href='/'>Back to main page...</a>"); context.Response.WriteLine("<div style='border:1px solid #CCCCCC;'>"); context.Response.WriteLine("<p><span class='note'>Copyright © 2014 Gilberto García</span></p>"); context.Response.WriteLine("</div></div></div></body></html>"); //clear variables alOpen.Clear(); alOpen = null; menu_Header = null; rawURL_string = null; break; case "/pachube": System.Collections.ArrayList alPachube = new System.Collections.ArrayList(); Pachube.EmbeddableGraphGenerator.EmbeddableHTML.GenerateHTML(alPachube); context.Response.ContentType = "text/html"; context.Response.WriteLine("<html><head><title>Control Panel - Pachube Graphics</title>"); context.Response.WriteLine("<meta name='author' content='Gilberto García'/>"); context.Response.WriteLine("<meta name='mod-date' content='01/02/2014'/>"); context.Response.WriteLine("<meta name='application-name' content='HomeAlarm Plus'/>"); context.Response.WriteLine(jquery_ui_script); context.Response.WriteLine("<link rel='stylesheet' type='text/css' href='"+ Alarm.ConfigDefault.Data.HTTP_HOST + "WebResources/header_style.css'></style>"); context.Response.WriteLine("<link rel='stylesheet' type='text/css' href='" + Alarm.ConfigDefault.Data.HTTP_HOST + "WebResources/table_style.css'></style>"); context.Response.WriteLine("</head><body>"); context.Response.WriteLine("<div class='ui-widget'>\n"); context.Response.WriteLine("<div class='ui-widget-header ui-corner-top'>\n"); context.Response.WriteLine("<h2>Alarm Activity - Monitor System #1</h2></div>"); context.Response.WriteLine("<div class='ui-widget-content ui-corner-bottom'>"); context.Response.WriteLine(menu_Header); context.Response.WriteLine("<p>System Time: <b>" + DateTime.Now.ToString("dd MMM yyyy hh:mm:ss tt").ToUpper() + "</b></p></br>"); foreach (string content in alPachube) { context.Response.WriteLine(content); context.Response.WriteLine("<br>"); } context.Response.WriteLine("<a href='/'>Back to main page...</a>"); context.Response.WriteLine("<div style='border:1px solid #CCCCCC;'>"); context.Response.WriteLine("<p><span class='note'>Copyright © 2014 Gilberto García</span></p>"); context.Response.WriteLine("</div></div></div></body></html>"); //clear variables alPachube.Clear(); alPachube = null; menu_Header = null; rawURL_string = null; break; case "/delete-confirm": if (AlarmByZones.SdCardEventLogger.IsSDCardAvailable()) { string rawHref = AlarmByZones.SdCardEventLogger.FileList[AlarmByZones.SdCardEventLogger.FileList.Count - 1].ToString(); string[] parseHref = rawHref.Split(new Char[] { '<', '>' }); //We do not want to delete Config.ini string LastFile = rawHref == Alarm.User_Definitions.Constants.ALARM_CONFIG_FILE_PATH ? rawHref : parseHref[2]; context.Response.ContentType = "text/html"; context.Response.WriteLine("<html><head><title>Control Panel - Delete SD Card confirm</title>"); context.Response.WriteLine("<meta name='author' content='Gilberto García'/>"); context.Response.WriteLine("<meta name='mod-date' content='01/02/2014'/>"); context.Response.WriteLine("<meta name='application-name' content='HomeAlarm Plus'/>"); context.Response.WriteLine(jquery_ui_script); context.Response.WriteLine("<link rel='stylesheet' type='text/css' href='" + Alarm.ConfigDefault.Data.HTTP_HOST + "WebResources/header_style.css'></style>"); context.Response.WriteLine("</head><body>"); context.Response.WriteLine("<div class='ui-widget'>\n"); context.Response.WriteLine("<div class='ui-widget-header ui-corner-top'>\n"); context.Response.WriteLine("<h2>Alarm Activity - Monitor System #1</h2></div>"); context.Response.WriteLine("<div class='ui-widget-content ui-corner-bottom'>"); context.Response.WriteLine(menu_Header); context.Response.WriteLine("<p>System Time: <b>" + DateTime.Now.ToString("dd MMM yyyy hh:mm:ss tt").ToUpper() + "</b></p></br>"); if (LastFile != Alarm.User_Definitions.Constants.ALARM_CONFIG_FILE_PATH && LastFile != @"\SD\Logs" && LastFile != @"\SD\Exception" ) { context.Response.WriteLine("<A HREF='/delete-last' onCLick='return confirm('Are you sure you want to delete " +LastFile +" file?')'>Delete " + LastFile + "</A>"); } else { context.Response.WriteLine("No files to delete."); } context.Response.WriteLine("<br><br>"); //clear variables rawHref = null; parseHref = null; LastFile = null; } context.Response.WriteLine("<a href='/'>Back to main page...</a>"); context.Response.WriteLine("<div style='border:1px solid #CCCCCC;'>"); context.Response.WriteLine("<p><span class='note'>Copyright © 2014 Gilberto García</span></p>"); context.Response.WriteLine("</div></div></div></body></html>"); menu_Header = null; rawURL_string = null; break; case "/delete": case "/delete-last": context.Response.ContentType = "text/html"; context.Response.WriteLine("<html><head><title>Control Panel - Delete SD Card File</title>"); context.Response.WriteLine("<meta name='author' content='Gilberto García'/>"); context.Response.WriteLine("<meta name='mod-date' content='01/02/2014'/>"); context.Response.WriteLine("<meta name='application-name' content='HomeAlarm Plus'/>"); context.Response.WriteLine(jquery_ui_script); context.Response.WriteLine("<link rel='stylesheet' type='text/css' href='" + Alarm.ConfigDefault.Data.HTTP_HOST + "WebResources/header_style.css'></style>"); context.Response.WriteLine("</head><body>"); context.Response.WriteLine("<div class='ui-widget'>\n"); context.Response.WriteLine("<div class='ui-widget-header ui-corner-top'>\n"); context.Response.WriteLine("<h2>Alarm Activity - Monitor System #1</h2></div>"); context.Response.WriteLine("<div class='ui-widget-content ui-corner-bottom'>"); context.Response.WriteLine(menu_Header); context.Response.WriteLine("<p>System Time: <b>" + DateTime.Now.ToString("dd MMM yyyy hh:mm:ss tt").ToUpper() + "</b></p></br>"); if (AlarmByZones.SdCardEventLogger.IsSDCardAvailable()) { string rawHref = AlarmByZones.SdCardEventLogger.FileList[AlarmByZones.SdCardEventLogger.FileList.Count - 1].ToString(); string[] parseHref = rawHref.Split(new Char[] { '<', '>' }); //string LastFile = parseHref[2]; string LastFile = rawHref == Alarm.User_Definitions.Constants.ALARM_CONFIG_FILE_PATH ? rawHref : parseHref[2]; if (LastFile != Alarm.User_Definitions.Constants.ALARM_CONFIG_FILE_PATH && LastFile != @"\SD\Logs" && LastFile != @"\SD\Exception") { AlarmByZones.SdCardEventLogger.deleteFile(LastFile); context.Response.WriteLine("Deleted File: " + LastFile); } else { context.Response.WriteLine("No files to delete."); } context.Response.WriteLine("<br><br>"); //clear variables rawHref = null; parseHref = null; LastFile = null; } context.Response.WriteLine("<a href='/'>Back to main page...</a>"); context.Response.WriteLine("<div style='border:1px solid #CCCCCC;'>"); context.Response.WriteLine("<p><span class='note'>Copyright © 2014 Gilberto García</span></p>"); context.Response.WriteLine("</div></div></div></body></html>"); menu_Header = null; rawURL_string = null; break; case "/diag": case "/diagnostics": //This option is very useful when used with Android App "Overlook Wiz" //--------------------------------------------------------------- //Overlook Wiz settings: //Host name or IP address: your host settings. //Host custom name shown on widget: Alarm System //Monitored service: Web Server (HTTP) //Service TCP Port: same as entered in Config.ini [NETDUINO_PLUS_HTTP_PORT], otherwise enter the default port 8080 //Website URL to be requested: /diag context.Response.ContentType = "text/html"; context.Response.WriteLine("<html><head><title>Control Panel - Diagnostics</title>"); context.Response.WriteLine("<meta name='author' content='Gilberto García'/>"); context.Response.WriteLine("<meta name='mod-date' content='01/02/2014'/>"); context.Response.WriteLine("<meta name='application-name' content='HomeAlarm Plus'/>"); context.Response.WriteLine("<meta charset='utf-8' />"); context.Response.WriteLine("<meta name='viewport' content='initial-scale=1.0, user-scalable=no' />"); context.Response.WriteLine("<meta name='apple-mobile-web-app-capable' content='yes' />"); context.Response.WriteLine("<meta name='apple-mobile-web-app-status-bar-style' content='black' />"); context.Response.WriteLine(jquery_ui_script); context.Response.WriteLine("</head><body>"); context.Response.WriteLine("<div class='ui-widget'>\n"); context.Response.WriteLine("<div class='ui-widget-header ui-corner-top'>\n"); context.Response.WriteLine("<h2>Alarm Activity - Monitor System #1</h2></div>"); context.Response.WriteLine("<div class='ui-widget-content ui-corner-bottom'>"); context.Response.WriteLine("<p>System Time: <b>" + DateTime.Now.ToString("dd MMM yyyy hh:mm:ss tt").ToUpper() + "</b></p></br>"); context.Response.WriteLine("<p><font size='5' face='verdana' color='green'>Alarm System is up and running!</font></p><br>"); context.Response.WriteLine("<b>Power Cycle</b>"); context.Response.WriteLine("<ul><li>Last Time since reset: " + AlarmByZones.LastResetCycle + "</li>"); //context.Response.Write("<li>Uptime: " + span.Days + " days, " + span.Hours + ":" + span.Minutes + ":" + span.Seconds + " (hh:mm:ss)</li></ul><br>"); context.Response.WriteLine("<li>Uptime: " + strUptime); context.Response.WriteLine("<b>Memory</b>"); context.Response.WriteLine("<ul>"); context.Response.WriteLine("<li>Available Memory: " + Debug.GC(true) + "</li>"); context.Response.WriteLine(AlarmByZones.SdCardEventLogger.SDCardInfo(false)); context.Response.WriteLine("<br>"); context.Response.WriteLine("<b>AssemblyInfo</b>"); context.Response.WriteLine("<li>" + System.Reflection.Assembly.GetExecutingAssembly().FullName + "</li><br>"); context.Response.WriteLine("</ul>"); context.Response.WriteLine("<br><br>"); context.Response.WriteLine("<a href='/'>Back to main page...</a>"); context.Response.WriteLine("<div style='border:1px solid #CCCCCC;'>"); context.Response.WriteLine("<p><span class='note'>Copyright © 2014 Gilberto García</span></p>"); context.Response.WriteLine("</div></div></div></body></html>"); rawURL_string = null; break; case "/diag-mod": context.Response.ContentType = "text/html"; context.Response.WriteLine("<html><head><title>Control Panel - Diagnostics</title>"); context.Response.WriteLine("<meta name='author' content='Gilberto García'/>"); context.Response.WriteLine("<meta name='mod-date' content='07/17/2013'/>"); context.Response.WriteLine("<meta name='application-name' content='HomeAlarm Plus'/>"); context.Response.WriteLine("<meta charset='utf-8' />"); context.Response.WriteLine("<meta name='viewport' content='initial-scale=1.0, user-scalable=no' />"); context.Response.WriteLine("<meta name='apple-mobile-web-app-capable' content='yes' />"); context.Response.WriteLine("<meta name='apple-mobile-web-app-status-bar-style' content='black' />"); context.Response.WriteLine("</head><body>"); context.Response.WriteLine("<table>"); context.Response.WriteLine("<tr class='mheader'>"); context.Response.WriteLine("<td colspan='2' class='head center'>Netduino Plus - General Info</td>"); context.Response.WriteLine("</tr><tr>"); context.Response.WriteLine("<td width=110>System Time</td>"); context.Response.WriteLine("<td width=268>" + DateTime.Now.ToString("dd MMM yyyy hh:mm:ss tt").ToUpper() + "</td>"); context.Response.WriteLine("</tr><tr>"); context.Response.WriteLine("<td>Status</td>"); context.Response.WriteLine("<td>" + "<font face='verdana' color='green'>Alarm System is up and running!</font>" +"</td>"); context.Response.WriteLine("</tr><tr>"); context.Response.WriteLine("<td>Netduino Temperature</td><td>" + Sensor.TMP36.GetTemperature(false, AlarmByZones.tempSensor) + "</td>"); context.Response.WriteLine("</table><br>"); context.Response.WriteLine("<table>"); context.Response.WriteLine("<tr class='mheader'>"); context.Response.WriteLine("<td colspan='2' class='head center'>Power Cycle</td>"); context.Response.WriteLine("</tr><tr>"); context.Response.WriteLine("<td width=110>Last reset</td><td width=268>" + AlarmByZones.LastResetCycle + "</td>"); context.Response.WriteLine("</tr><tr>"); context.Response.WriteLine("<td>Uptime</td><td>" + strUptime + "</td>"); context.Response.WriteLine("</tr></table><br>"); context.Response.WriteLine("<table>"); context.Response.WriteLine("<tr class='mheader'>"); context.Response.WriteLine("<td colspan='2' class='head center'>Memory</td>"); context.Response.WriteLine("</tr><tr>"); context.Response.WriteLine("<td width=110>Available Memory</td><td width=268>" + Debug.GC(true) + "</td>"); context.Response.WriteLine("</tr></table><br>"); context.Response.WriteLine("<table>"); context.Response.WriteLine("<tr class='mheader'>"); context.Response.WriteLine("<td colspan='2' class='head center'>SD Card Status</td>"); context.Response.WriteLine("</tr><tr>"); context.Response.WriteLine(AlarmByZones.SdCardEventLogger.SDCardInfo(true) + "</td>"); context.Response.WriteLine("</table><br>"); context.Response.WriteLine("</body></html>"); rawURL_string = null; break; case "/re": case "/rst": Notification.PushingBox.Connect("vPUSHINGBOX_RESET"); time = DateTime.Now.ToString(); ttime = Extension.Replace(time, " ", "%20"); Notification.Pushover.Connect(ttime, "Netduino%20Plus%20Web%20Trigger", "Netduino%20Plus%20executing%20Reset%20", false); Microsoft.SPOT.Hardware.PowerState.RebootDevice(false); //true = Hard reboot rawURL_string = null; break; default: rawURL_string = null; context.Response.RaiseError(MFToolkit.Net.Web.HttpStatusCode.NotFound); break; } }
public static void ReadCode() { #if clean File.Delete("Morrowind.exe"); File.Delete("code"); File.Copy("clean\\Morrowind.exe","Morrowind.exe"); File.Copy("clean\\code","code"); #endif Console.WriteLine("Loading code segments"); StreamReader sr=new StreamReader("dcode.txt"); ArrayList segLines=new ArrayList(); int count=0; bool DropSegment=false; bool StartedSegment=true; LineInfo li; #if !fulltest||partialtest int count2=0; #endif count3=0; while(sr.Peek()!=-1) { string s=sr.ReadLine(); #if !fulltest||partialtest count2++; LineNo=count2; if(count2<500000||count2>510000) continue; #endif try { li=new LineInfo(s); } catch(Exception) { DropSegment=true; li=new LineInfo("00000000 00 int3"); } if(Array.IndexOf(JumpInstructions,li.instruction)==-1) { if(StartedSegment) { segLines.Add(li); } else if(Array.IndexOf(FpuInstructions,li.instruction)!=-1) { StartedSegment=true; segLines.Add(li); } } else if(StartedSegment) { if(!DropSegment) { segLines.Add(li); CodeSegment cs=new CodeSegment(segLines); try { if(OptimizeSegment(ref cs)) count3++; #if !fulltest } catch(OptimizationException ex) { if(thingy) { try { LogFile.WriteLine(CurrentSeg.Lines[0].address); LogFile.WriteLine("\nPatched:"); LogFile.Write(CurrentSeg.ToString()); LogFile.WriteLine("\nwith:"); s=string.Join("\n",fpu.Result); LogFile.WriteLine(s); //LogFile.Write(tempFpu.PreString()+File.ReadAll("out.txt")+tempFpu.PostString()); LogFile.WriteLine("------------------------------------------------"); } catch { } string ss=ex.ToString(); Console.WriteLine(ss); thingy=false; } #else } catch(OptimizationException) { #endif } count++; #if useconsole if(count%100==0) { Console.WriteLine("Processed "+count.ToString()+" segments and found "+count3+" patches."); } #else Console.WriteLine("Processed "+count.ToString()+" segments and found "+count3+" patches."); #endif } segLines.Clear(); DropSegment=false; StartedSegment=false; } else DropSegment=false; } sr.Close(); }
public void GetLeadsForGlobal() { int varcount = 0; for (int a = 1; a <= 43; a++) { string mainurl = "http://usa.global-free-classified-ads.com/cars-cid-14-page-" + a; FillCurrentPageData(mainurl); //<span class="location"> Regex r2 = new Regex("<span class=\"location\">(.*?)</span>"); System.Collections.ArrayList al2 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc2 = null; mc2 = r2.Matches(str); al2.Clear(); al2.InsertRange(al2.Count, mc2); Regex regexindividual31 = new Regex("<h1>(.*?)</h1>"); str = content; str = content.Replace('\n', ' '); System.Collections.ArrayList individualCararraylist31 = new System.Collections.ArrayList(); System.Text.RegularExpressions.MatchCollection regexindividualCollec31 = null; regexindividualCollec31 = regexindividual31.Matches(str); individualCararraylist31.Clear(); individualCararraylist31.InsertRange(individualCararraylist31.Count, regexindividualCollec31); for (int p = 0; p < individualCararraylist31.Count; p++) { string desc = ""; string title = ""; string price = ""; string pubDate = ""; string name = ""; string location = ""; string place = ""; string phno = string.Empty; string city = ""; string state = ""; string url = individualCararraylist31[p].ToString(); url = url.Substring(url.IndexOf("href=")); url = url.Replace("href=", ""); url = url.Substring(0, url.IndexOf(">")); url = url.Replace("\"", ""); location = al2[p].ToString().Replace("<span class=\"location\">", ""); location = location.Replace("</span>", ""); location = location.Replace("</a>", ""); if(location.IndexOf(">") != -1) location = location.Substring(location.IndexOf(">")); location = location.Replace("Cars", ""); location = location.Replace(">", ""); location = location.Replace(":", ""); if (location.IndexOf(",") != -1) { city = location.Substring(0, location.IndexOf(",")); state = location.Replace(city + ",", ""); if (state.IndexOf(",") != -1) state = state.Substring(0, state.IndexOf(",")); } else { state = location; city = ""; } FillCurrentPageData(url); Regex r3 = new Regex("<div class=\"content_box_1\">(.*?)</div>"); System.Collections.ArrayList al3 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc3 = null; mc3 = r3.Matches(str); al3.Clear(); al3.InsertRange(al3.Count, mc3); for (int x = 0; x < al3.Count; x++) { if (al3[x].ToString().Contains("Seller's Comments and Description:")) { desc = al3[x].ToString(); desc = desc.Replace("<div class=\"user_content\">", ""); desc = desc.Replace("</div>", ""); desc = desc.Replace("<div class=\"content_box_1\">", ""); desc = desc.Replace("<h3>Seller's Comments and Description:</h3>", ""); desc = desc.Replace("<p>", ""); string phone = Regex.Replace(desc, "[A-Za-z]", ""); string[] digits = Regex.Split(phone, @"\D+"); for (int ph = 0; ph < digits.Length; ph++) { if (digits[ph].Length == 10) { phno = digits[ph]; } else if (digits[ph].Length == 3 && digits[ph + 1].Length == 3 && digits[ph + 2].Length == 4) { phno = digits[ph] + digits[ph + 1] + digits[ph + 2]; } else if (digits[ph].Length == 3 && digits[ph + 1].Length == 7) { phno = digits[ph] + digits[ph + 1]; } } } } //Regex r2 = new Regex("<p class=\"content_section\">(.*?)</p>"); //System.Collections.ArrayList al2 = new System.Collections.ArrayList(); //str = content; //str = content.Replace('\n', ' '); //System.Text.RegularExpressions.MatchCollection mc2 = null; //mc2 = r2.Matches(str); //al2.Clear(); //al2.InsertRange(al2.Count, mc2); //location = al2[1].ToString(); //location = location.Replace("<p class=\"content_section\">", ""); //location = location.Replace("</p>", "").Trim(); //if (location.IndexOf(",") == 0) //{ // city = location.Substring(1); // if (city.IndexOf(",") != -1) // { // city = city.Substring(0, city.IndexOf(",")).Trim(); // state = location.Substring(1); // state = state.Replace(city + ",", ""); // if (state.IndexOf(",") != -1) // state = state.Substring(0, state.IndexOf(",")).Trim(); // else state = city; // } // else // { // state = city; // city = ""; // } //} //else //{ // if (location.IndexOf(",") == -1) // { // city = location; // state = ""; // } // else // { // location = location.Substring(location.IndexOf(",")).Trim(); // if (location.IndexOf(",") == 0) // { // city = location.Substring(1); // if (city.IndexOf(",") != -1) // city = city.Substring(0, city.IndexOf(",")).Trim(); // else // city = ""; // state = location.Substring(1); // state = state.Replace(city + ",", ""); // if (state.IndexOf(",") != -1) // state = state.Substring(0, state.IndexOf(",")).Trim(); // else // state = city; // } // } //} Regex r21 = new Regex("<h1 class=\"seller_username\">(.*?)</h1>"); System.Collections.ArrayList al21 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc21 = null; mc21 = r21.Matches(str); al21.Clear(); al21.InsertRange(al21.Count, mc21); if (al21.Count > 0) { name = al21[0].ToString(); name = name.Replace("</a>", ""); name = name.Replace("</h1>", ""); name = name.Substring(name.LastIndexOf(">")); name = name.Replace(">", ""); } Regex r211 = new Regex("<h1 class=\"listing_title\" style=\"display: inline;\">(.*?)</h1>"); System.Collections.ArrayList al211 = new System.Collections.ArrayList(); str = content; str = content.Replace('\n', ' '); System.Text.RegularExpressions.MatchCollection mc211 = null; mc211 = r211.Matches(str); al211.Clear(); al211.InsertRange(al211.Count, mc211); for (int i = 0; i < al211.Count; i++) { string title1 = al211[i].ToString(); title1 = title1.Replace("<h1 class=\"listing_title\" style=\"display: inline;\">", ""); title = title1.Substring(0, title1.IndexOf("<span")); title1 = title1.Replace(title, ""); price = title1.Replace("<span class=\"value price\">", ""); price = price.Substring(0, price.IndexOf("<")); } varcount++; objDal.SaveLeadsData("", "", title, phno, price, url, "", state, city, location, "", "", "", desc, "", "", "", "", "", "", "", ""); //objDal.SaveGlobal(title, price, phno, city, state, name, a, url); Navigate.Text = "Page :" + a.ToString() + "Rec No:" + (varcount + 1).ToString(); } } }
/// <exception cref="ParseException">throw in overridden method to disallow /// </exception> public /*protected internal*/ virtual Query GetFieldQuery(System.String field, System.String queryText) { // Use the analyzer to get all the tokens, and then build a TermQuery, // PhraseQuery, or nothing based on the term count TokenStream source; try { source = analyzer.ReusableTokenStream(field, new System.IO.StringReader(queryText)); source.Reset(); } catch (System.IO.IOException e) { source = analyzer.TokenStream(field, new System.IO.StringReader(queryText)); } CachingTokenFilter buffer = new CachingTokenFilter(source); TermAttribute termAtt = null; PositionIncrementAttribute posIncrAtt = null; int numTokens = 0; bool success = false; try { buffer.Reset(); success = true; } catch (System.IO.IOException e) { // success==false if we hit an exception } if (success) { if (buffer.HasAttribute(typeof(TermAttribute))) { termAtt = (TermAttribute) buffer.GetAttribute(typeof(TermAttribute)); } if (buffer.HasAttribute(typeof(PositionIncrementAttribute))) { posIncrAtt = (PositionIncrementAttribute) buffer.GetAttribute(typeof(PositionIncrementAttribute)); } } int positionCount = 0; bool severalTokensAtSamePosition = false; bool hasMoreTokens = false; if (termAtt != null) { try { hasMoreTokens = buffer.IncrementToken(); while (hasMoreTokens) { numTokens++; int positionIncrement = (posIncrAtt != null)?posIncrAtt.GetPositionIncrement():1; if (positionIncrement != 0) { positionCount += positionIncrement; } else { severalTokensAtSamePosition = true; } hasMoreTokens = buffer.IncrementToken(); } } catch (System.IO.IOException e) { // ignore } } try { // rewind the buffer stream buffer.Reset(); // close original stream - all tokens buffered source.Close(); } catch (System.IO.IOException e) { // ignore } if (numTokens == 0) return null; else if (numTokens == 1) { System.String term = null; try { bool hasNext = buffer.IncrementToken(); System.Diagnostics.Debug.Assert(hasNext == true); term = termAtt.Term(); } catch (System.IO.IOException e) { // safe to ignore, because we know the number of tokens } return NewTermQuery(new Term(field, term)); } else { if (severalTokensAtSamePosition) { if (positionCount == 1) { // no phrase query: BooleanQuery q = NewBooleanQuery(true); for (int i = 0; i < numTokens; i++) { System.String term = null; try { bool hasNext = buffer.IncrementToken(); System.Diagnostics.Debug.Assert(hasNext == true); term = termAtt.Term(); } catch (System.IO.IOException e) { // safe to ignore, because we know the number of tokens } Query currentQuery = NewTermQuery(new Term(field, term)); q.Add(currentQuery, BooleanClause.Occur.SHOULD); } return q; } else { // phrase query: MultiPhraseQuery mpq = NewMultiPhraseQuery(); mpq.SetSlop(phraseSlop); System.Collections.ArrayList multiTerms = new System.Collections.ArrayList(); int position = - 1; for (int i = 0; i < numTokens; i++) { System.String term = null; int positionIncrement = 1; try { bool hasNext = buffer.IncrementToken(); System.Diagnostics.Debug.Assert(hasNext == true); term = termAtt.Term(); if (posIncrAtt != null) { positionIncrement = posIncrAtt.GetPositionIncrement(); } } catch (System.IO.IOException e) { // safe to ignore, because we know the number of tokens } if (positionIncrement > 0 && multiTerms.Count > 0) { if (enablePositionIncrements) { mpq.Add((Term[]) multiTerms.ToArray(typeof(Term)), position); } else { mpq.Add((Term[]) multiTerms.ToArray(typeof(Term))); } multiTerms.Clear(); } position += positionIncrement; multiTerms.Add(new Term(field, term)); } if (enablePositionIncrements) { mpq.Add((Term[]) multiTerms.ToArray(typeof(Term)), position); } else { mpq.Add((Term[]) multiTerms.ToArray(typeof(Term))); } return mpq; } } else { PhraseQuery pq = NewPhraseQuery(); pq.SetSlop(phraseSlop); int position = - 1; for (int i = 0; i < numTokens; i++) { System.String term = null; int positionIncrement = 1; try { bool hasNext = buffer.IncrementToken(); System.Diagnostics.Debug.Assert(hasNext == true); term = termAtt.Term(); if (posIncrAtt != null) { positionIncrement = posIncrAtt.GetPositionIncrement(); } } catch (System.IO.IOException e) { // safe to ignore, because we know the number of tokens } if (enablePositionIncrements) { position += positionIncrement; pq.Add(new Term(field, term), position); } else { pq.Add(new Term(field, term)); } } return pq; } } }
private void Render() { Response.ContentType = "application/xml"; ErrorLog log = ErrorLog.GetDefault(_context); // // We'll be emitting RSS vesion 0.91. // RichSiteSummary rss = new RichSiteSummary(); rss.version = "0.91"; // // Set up the RSS channel. // Channel channel = new Channel(); string hostName = Environment.TryGetMachineName(_context); channel.title = "Daily digest of errors in " + log.ApplicationName + (hostName.Length > 0 ? " on " + hostName : null); channel.description = "Daily digest of application errors"; channel.language = "en"; Uri baseUrl = new Uri(ErrorLogPageFactory.GetRequestUrl(_context).GetLeftPart(UriPartial.Authority) + Request.ServerVariables["URL"]); channel.link = baseUrl.ToString(); rss.channel = channel; // // Build the channel items. // const int pageSize = 30; const int maxPageLimit = 30; ArrayList itemList = new ArrayList(pageSize); ArrayList errorEntryList = new ArrayList(pageSize); // // Start with the first page of errors. // int pageIndex = 0; // // Initialize the running state. // DateTime runningDay = DateTime.MaxValue; int runningErrorCount = 0; Item item = null; StringBuilder sb = new StringBuilder(); HtmlTextWriter writer = new HtmlTextWriter(new StringWriter(sb)); do { // // Get a logical page of recent errors and loop through them. // errorEntryList.Clear(); log.GetErrors(pageIndex++, pageSize, errorEntryList); foreach (ErrorLogEntry entry in errorEntryList) { Error error = entry.Error; DateTime time = error.Time.ToUniversalTime(); DateTime day = new DateTime(time.Year, time.Month, time.Day); // // If we're dealing with a new day then break out to a // new channel item, finishing off the previous one. // if (day < runningDay) { if (runningErrorCount > 0) { RenderEnd(writer); item.description = sb.ToString(); itemList.Add(item); } runningDay = day; runningErrorCount = 0; if (itemList.Count == pageSize) break; item = new Item(); item.pubDate = time.ToString("r"); item.title = string.Format("Digest for {0} ({1})", runningDay.ToString("yyyy-MM-dd"), runningDay.ToLongDateString()); sb.Length = 0; RenderStart(writer); } RenderError(writer, entry, baseUrl); runningErrorCount++; } } while (pageIndex < maxPageLimit && itemList.Count < pageSize && errorEntryList.Count > 0); if (runningErrorCount > 0) { RenderEnd(writer); item.description = sb.ToString(); itemList.Add(item); } channel.item = (Item[]) itemList.ToArray(typeof(Item)); // // Stream out the RSS XML. // Response.Write(XmlText.StripIllegalXmlCharacters(XmlSerializer.Serialize(rss))); }
/// <exception cref="ParseException">throw in overridden method to disallow /// </exception> protected internal virtual Query GetFieldQuery(System.String field, System.String queryText) { // Use the analyzer to get all the tokens, and then build a TermQuery, // PhraseQuery, or nothing based on the term count TokenStream source = analyzer.TokenStream(field, new System.IO.StringReader(queryText)); System.Collections.ArrayList v = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); Lucene.Net.Analysis.Token t; int positionCount = 0; bool severalTokensAtSamePosition = false; while (true) { try { t = source.Next(); } catch (System.IO.IOException e) { t = null; } if (t == null) break; v.Add(t); if (t.GetPositionIncrement() != 0) positionCount += t.GetPositionIncrement(); else severalTokensAtSamePosition = true; } try { source.Close(); } catch (System.IO.IOException e) { // ignore } if (v.Count == 0) return null; else if (v.Count == 1) { t = (Lucene.Net.Analysis.Token) v[0]; return new TermQuery(new Term(field, t.TermText())); } else { if (severalTokensAtSamePosition) { if (positionCount == 1) { // no phrase query: BooleanQuery q = new BooleanQuery(true); for (int i = 0; i < v.Count; i++) { t = (Lucene.Net.Analysis.Token) v[i]; TermQuery currentQuery = new TermQuery(new Term(field, t.TermText())); q.Add(currentQuery, BooleanClause.Occur.SHOULD); } return q; } else { // phrase query: MultiPhraseQuery mpq = new MultiPhraseQuery(); System.Collections.ArrayList multiTerms = new System.Collections.ArrayList(); for (int i = 0; i < v.Count; i++) { t = (Lucene.Net.Analysis.Token) v[i]; if (t.GetPositionIncrement() == 1 && multiTerms.Count > 0) { mpq.Add((Term[]) multiTerms.ToArray(typeof(Term))); multiTerms.Clear(); } multiTerms.Add(new Term(field, t.TermText())); } mpq.Add((Term[]) multiTerms.ToArray(typeof(Term))); return mpq; } } else { PhraseQuery q = new PhraseQuery(); q.SetSlop(phraseSlop); for (int i = 0; i < v.Count; i++) { q.Add(new Term(field, ((Lucene.Net.Analysis.Token) v[i]).TermText())); } return q; } } }
//合併RGS data private OutputQueueData mergeOutputQueueData(OutputQueueData higher, OutputQueueData lower) { if (higher.data == null) return higher; // OutputQueueData retData = new OutputQueueData(higher.ruleid, higher.priority, higher.data); RGS_GenericDisplay_Data data1 = (RGS_GenericDisplay_Data)higher.data; RGS_GenericDisplay_Data data2 = (RGS_GenericDisplay_Data)lower.data; RGS_GenericDisplay_Data mergeData = new RGS_GenericDisplay_Data(data1.mode, data1.graph_code_id, data1.icons, data1.msgs, data1.sections); if (data1.mode != 2 || data2.mode!=2) //cms mode return new OutputQueueData(this.deviceName,higher.mode,higher.ruleid, higher.priority,mergeData); System.Collections.ArrayList ary = new System.Collections.ArrayList(); ary.Clear(); for (int i = 0; i < data1.icons.Length; i++) ary.Add(data1.icons[i]); bool bfind = false; for (int i = 0; i < data2.icons.Length; i++) { bfind = false; foreach (RGS_Generic_ICON_Data icon in ary) { if (icon.y == data2.icons[i].y) { bfind = true; break; } } if (!bfind && !IsCmsModeOutput(data2.icons[i].y/128+1,data1)) ary.Add(data2.icons[i]); } mergeData.icons = new RGS_Generic_ICON_Data[ary.Count]; int inx = 0; foreach (RGS_Generic_ICON_Data icon in ary) mergeData.icons[inx++] = icon; ary.Clear(); for (int i = 0; i < data1.msgs.Length; i++) ary.Add(data1.msgs[i]); for (int i = 0; i < data2.msgs.Length; i++) { bfind = false; foreach (RGS_Generic_Message_Data msg in ary) { if (msg.y == data2.msgs[i].y) { bfind = true; break; } } if (!bfind && !IsCmsModeOutput(data2.msgs[i].y/128+1,data1)) ary.Add(data2.msgs[i]); } inx = 0; mergeData.msgs = new RGS_Generic_Message_Data[ary.Count]; foreach (RGS_Generic_Message_Data msg in ary) mergeData.msgs[inx++] = msg; return new OutputQueueData(this.deviceName,higher.mode,higher.ruleid, higher.priority,mergeData); }