Example #1
0
        public static void setPlazaPos(System.Windows.Forms.Button b, int _x, int _y)
        {
            int i = botonesDiseño.IndexOf(b);

            ((Plaza)plazas[i]).X = _x;
            ((Plaza)plazas[i]).Y = _y;
        }
Example #2
0
 /// <summary>
 /// содержит ли ключ
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public bool Contains(System.Type key)
 {
     lock (types)
     {
         return(types.IndexOf(key) >= 0);
     }
 }
Example #3
0
        public static void AddPlaza(Plaza p)
        {
            plazas.Add(p);

            // Creamos el boton de diseño
            System.Windows.Forms.Button b = new System.Windows.Forms.Button();
            b.Location = new System.Drawing.Point(p.X, p.Y);
            if (p.isBarra)
            {
                b.Size = new System.Drawing.Size(32, 32);
            }
            else
            {
                b.Size = new System.Drawing.Size(40, 40);
            }
            b.Text      = "";
            b.Name      = "BotonDiseño" + plazas.IndexOf(p).ToString();
            b.BackColor = System.Drawing.Color.SlateBlue;
            botonesDiseño.Add(b);

            b          = new System.Windows.Forms.Button();
            b.Location = new System.Drawing.Point(p.X, p.Y);
            if (p.isBarra)
            {
                b.Size = new System.Drawing.Size(32, 32);
            }
            else
            {
                b.Size = new System.Drawing.Size(40, 40);
            }
            b.Text = "";
            b.Name = "BotonTPV" + plazas.IndexOf(p).ToString();
            botonesTPV.Add(b);
            ActualizarBotones();
        }
Example #4
0
		/// <summary>
		/// 获得列表中指定元素的前一个元素
		/// </summary>
		/// <param name="element">指定的元素</param>
		/// <returns>前一个元素,若不存在则返回空引用</returns>
		public HTMLElement GetPreElement( HTMLElement element )
		{
			int index = myList.IndexOf(element );
			if( index > 0 )
				return ( HTMLElement) myList[ index -1 ];
			else
				return null;
		}
Example #5
0
        public void Start(string virtualpath)
        {
            int index = mDomains.IndexOf(virtualpath);

            if (index >= 0)
            {
                ((AdapterDomain)mDomains[index]).Start();
            }
        }
Example #6
0
 public string LinhaTexto(string[] entrada, string select)
 {
     String[] linhas = entrada;
     System.Collections.ArrayList lista = new System.Collections.ArrayList(linhas);
     if (lista.IndexOf(select) >= 0)
     {
         return(linhas[lista.IndexOf(select)]);
     }
     else
     {
         return(linhas[0]);
     }
 }
Example #7
0
        public void RenameTest(Object WhatRename, String NewName)
        {
            Test NT = new Test();

            if (WhatRename.GetType().Equals(NT.GetType()))
            {
                ((Test)ArrayOfTest[ArrayOfTest.IndexOf(WhatRename)]).SetNameOfTest(NewName);
            }
            else
            {
                ((CollectionOfTest)ArrayOfTest[ArrayOfTest.IndexOf(WhatRename)]).SetName(NewName);
            }
        }
        public bool bRemove(string strNome)
        {
            if (!m_arlNomes.Contains(strNome))
            {
                return(false);
            }
            int nIndex = m_arlNomes.IndexOf(strNome);

            m_arlNomes.RemoveAt(nIndex);
            m_arlValores.RemoveAt(nIndex);
            m_arlPorcentagemExata.RemoveAt(nIndex);
            m_arlPorcentagem.RemoveAt(nIndex);
            return(true);
        }
Example #9
0
 public string RemoveLinhas(string[] lines, string TextSelecionado)
 {
     String[] linhas = lines;
     System.Collections.ArrayList lista = new System.Collections.ArrayList(linhas);
     if (0 <= lista.IndexOf(TextSelecionado))
     {
         lista.RemoveAt(lista.IndexOf(TextSelecionado));
         linhas = (System.String[])lista.ToArray(Type.GetType("System.String"));
         return(ArrayToString(linhas));
     }
     else
     {
         return(ArrayToString(linhas));
     }
 }
Example #10
0
 /// <summary>
 /// 获得MQ系统图片的文件名
 /// </summary>
 /// <param name="code">MQ系统表情代码</param>
 /// <returns></returns>
 private string GetMqPic(string code)
 {
     /// /:a1:0.gif,/:a1:1.gif……
     string[] codes = @"/:a1,/:a2,/:a3,/:a4,/:a5,/:a6,/:a7,/:a8,/:a9,/:a0,/:b1,/:b2,/:b3,/:b4,/:b5,/:b6,/:b7,/:b8,/:b9,/:b0,/:c1,/:c2,/:c3,/:c4,/:c5,/:c6,/:c7,/:c8,/:c9,/:c0,/:d1,/:d2,/:d3,/:d4,/:d5,/:d6,/:d7,/:d8,/:d9,/:d0,/:e1,/:e2,/:e3,/:e4,/:e5,/:e6,/:e7,/:e8,/:e9,/:e0,/:f1,/:f2,/:f3,/:f4,/:f5,/:f6,/:f7,/:f8,/:f9,/:f0,/:g1,/:g2,/:g3,/:g4,/:g5,/:g6,/:g7,/:g8,/:g9,/:g0,/:h1,/:h2,/:h3,/:h4,/:h5,/:h6,/:h7,/:h8,/:h9,/:h0,/:i1,/:i2,/:i3,/:i4,/:i5,/:i6,/:i7,/:i8,/:i9,/:i0,/:j1,/:j2,/:j3,/:j4,/:j5,/:j6,/:j7,/:j8,/:j9,/:j0,/:k1,/:k2,/:k3,/:k4,/:k5,/:k6,/:k7,/:k8,/:k9,/:k0,/:l1,/:l2,/:l3,/:l4,/:l5,/:l6,/:l7,/:l8,/:l9,/:l0,/:m1,/:m2,/:m3,/:m4,/:m5,/:m6,/:m7,/:m8,/:m9,/:m0,/:n1,/:n2,/:n3,/:n4,/:n5,/:n6,/:n7,/:n8,/:n9,/:n0,/:o1,/:o2,/:o3,/:o4,/:o5,/:o6,/:o7,/:o8,/:o9,/:o0,/:p1,/:p2,/:p3,/:p4,/:p5,/:p6,/:p7,/:p8,/:p9,/:p0,/:q1,/:q2,/:q3,/:q4,/:q5,/:q6,/:q7,/:q8,/:q9,/:q0,/:r1,/:r2,/:r3,/:r4,/:r5,/:r6,/:r7,/:r8,/:r9,/:r0,/:s1,/:s2,/:s3,/:s4,/:s5,/:s6,/:s7,/:s8,/:s9,/:s0,/:t1,/:t2,/:t3,/:t4,/:t5,/:t6,/:t7,/:t8,/:t9,/:t0".Split(',');
     System.Collections.ArrayList list = new System.Collections.ArrayList(codes);
     return(list.IndexOf(code).ToString() + ".gif");
 }
Example #11
0
        static void Main(string[] args)
        {
            //Jag vill mata in värden som sparas i en ArrayList
            //så jag kan använda metoderna
            System.Collections.ArrayList UserInputList = new System.Collections.ArrayList();

            //jag vill skriva in ord och trycka enter
            //så länge jag trycker ord och enter, fortsätt
            //avsluta när jag skriver in EXIT

            string key = "";

            do
            {
                key = Console.ReadLine();
                if (key != "EXIT")
                {
                    UserInputList.Add(key);
                }
            } while (key != "EXIT");

            Console.WriteLine("Tack, du matade in {0} ord", UserInputList.Count);

            foreach (string s in UserInputList)
            {
                Console.WriteLine("[{0}] {1}", UserInputList.IndexOf(s), s);
            }
        }
Example #12
0
        private string strCarregaDadosNormaDeOrigem()
        {
            System.Collections.ArrayList arlNormasStr, arlNormasStrCopia = new System.Collections.ArrayList(), arlIdOrdem;
            string strRetorno = "";

            vCarregaNormas(m_nIdTipoCO, out arlIdOrdem, out arlNormasStr);
            foreach (string strNorma in arlNormasStr)
            {
                arlNormasStrCopia.Add(strNorma);
            }
            int nIdOrdem = 0, nPrimeiroIdIntervalo = 0, nIdAtualIntervalo = 0;

            for (int nCount = 0; nCount < arlNormasStr.Count; nCount++)
            {
                nIdOrdem = nPrimeiroIdIntervalo = nIdAtualIntervalo = 0;
                if (arlNormasStrCopia.LastIndexOf(arlNormasStr[nCount]) == arlNormasStrCopia.IndexOf(arlNormasStr[nCount]))
                {
                    strRetorno += arlIdOrdem[nCount].ToString() + this.TextoEspacamento + arlNormasStr[nCount].ToString() + System.Environment.NewLine;
                }
                else if (strRetorno.IndexOf(arlNormasStr[nCount].ToString()) == -1)
                {
                    nIdOrdem = nCount;
                    while (nIdOrdem != -1)
                    {
                        nIdOrdem = arlNormasStr.IndexOf(arlNormasStr[nCount], nIdOrdem);
                        if (nIdOrdem != -1)
                        {
                            if (nPrimeiroIdIntervalo == 0)
                            {
                                nPrimeiroIdIntervalo = nIdAtualIntervalo = (int)arlIdOrdem[nIdOrdem];
                                strRetorno          += nPrimeiroIdIntervalo.ToString() + "-" + nIdAtualIntervalo.ToString();
                            }
                            else
                            {
                                if ((nIdAtualIntervalo + 1) == (int)arlIdOrdem[nIdOrdem])
                                {
                                    string strAntiga = nPrimeiroIdIntervalo.ToString() + "-" + nIdAtualIntervalo.ToString();
                                    nIdAtualIntervalo++;
                                    string strNova = nPrimeiroIdIntervalo.ToString() + "-" + nIdAtualIntervalo.ToString();
                                    strRetorno = strRetorno.Replace(strAntiga, strNova);
                                }
                                else
                                {
                                    nPrimeiroIdIntervalo = nIdAtualIntervalo = (int)arlIdOrdem[nIdOrdem];
                                    strRetorno          += "; " + nPrimeiroIdIntervalo.ToString() + "-" + nIdAtualIntervalo.ToString();
                                }
                            }
                            nIdOrdem++;
                        }
                    }
                    strRetorno += this.TextoEspacamento + arlNormasStr[nCount].ToString() + System.Environment.NewLine;
                }
            }
            if (strRetorno.Length > 2)
            {
                strRetorno = strRetorno.Substring(0, strRetorno.Length - 2);
            }
            return(strRetorno);
        }
Example #13
0
        public double[,] Calculate(out double[] result, out bool unsolvable)
        {
            int mainCol, mainRow; // ведущие столбец и строка

            while (IsNotEnd())
            {
                mainCol        = MainCol();
                mainRow        = MainRow(mainCol);
                basis[mainRow] = mainCol;

                double[,] new_table = new double[m, n];
                for (int j = 0; j < n; j++)
                {
                    new_table[mainRow, j] = table[mainRow, j] / table[mainRow, mainCol];
                }

                for (int i = 0; i < m; i++)
                {
                    if (i == mainRow)
                    {
                        continue;
                    }
                    for (int j = 0; j < n; j++)
                    {
                        new_table[i, j] = table[i, j] - table[i, mainCol] * new_table[mainRow, j];
                    }
                }
                table = new_table;
            }

            result     = new double[n];
            unsolvable = false;
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = (basis.IndexOf(i + 1) > -1) ? table[basis.IndexOf(i + 1), 0] : 0;
                if (unsolvable)
                {
                    continue;
                }
                else
                {
                    unsolvable = result[i] < 0;
                }
            }
            return(table);
        }
Example #14
0
        void menuselect(object obj)
        {
            hideallmenu();
            CalculateInterface.menuinterface sc;
            int myindex = list.IndexOf(obj);

            sc = (CalculateInterface.menuinterface)list[myindex];
            sc.Show();
        }
Example #15
0
 //DRY - Dont Repeat Yourself
 //Vi extraherar kod till en metod istället
 //så vi kan anropa och återanvända koden
 private static void PrintArrayListValues(System.Collections.ArrayList MyList)
 {
     foreach (string s in MyList)
     {
         Console.WriteLine("[{2}] Value: {0} ({1})", s,
                           s.Length,
                           MyList.IndexOf(s));
     }
 }
Example #16
0
        void menuselect(object obj)
        {
            hideallmenu();
            NetworkInterface.menuinterface sc;
            int myindex = list.IndexOf(obj);

            sc = (NetworkInterface.menuinterface)list[myindex];
            sc.Show();
        }
        /// <summary>
        /// Accepts the move of a base tree node on this node
        /// </summary>
        /// <param name="SourceNode"></param>
        public virtual void AcceptMove(BaseTreeNode SourceNode)
        {
            System.Collections.ArrayList SourceCollection = SourceNode.Model.EnclosingCollection;
            System.Collections.ArrayList ThisCollection   = Model.EnclosingCollection;

            if (ThisCollection != null && SourceCollection == ThisCollection)
            {
                // This is a reordering
                int sourceIndex = ThisCollection.IndexOf(SourceNode.Model);
                int thisIndex   = ThisCollection.IndexOf(Model);
                if (thisIndex >= 0 && thisIndex >= 0 && thisIndex != sourceIndex)
                {
                    ThisCollection.Remove(SourceNode.Model);
                    thisIndex = ThisCollection.IndexOf(Model);
                    ThisCollection.Insert(thisIndex, SourceNode.Model);
                    MainWindow.RefreshModel();
                }
            }
        }
Example #18
0
//		private bool m_mthDrawString(string strText,float X)
//		{
//			bool ret =false;
//			string[] strArr =strText.Split('\n');
//			strText ="";
//
//			for(int i=0;i<strArr.Length-1;i++)
//			{
//			strText+=strArr[i].PadRight(MaxLength,' ');
//			}
//			strText+=strArr[strArr.Length-1];
//			if(MaxLength*(subRow+1)<=strText.Length)
//			{
//				objDraw.Graphics.DrawString(strText.Substring(MaxLength*subRow,MaxLength),objFontNormal,Brushes.Black,X,Y);
//				Y+=this.fltRowHeight;
//				subRow++;
//				if(this.Y+this.fltRowHeight+20>this.objDraw.PageBounds.Height)
//				{
//					objDraw.HasMorePages =true;
//					return true;
//				}
//				m_mthDrawString(strText,X);
//			}
//			else
//			{
//				objDraw.Graphics.DrawString(strText.Substring(MaxLength*subRow,strText.Length-MaxLength*subRow),objFontNormal,Brushes.Black,X,Y);
//				Y+=this.fltRowHeight;
//				this.location++;
//				subRow=0;
//			}
//			if(this.Y+this.fltRowHeight+20>this.objDraw.PageBounds.Height)
//			{
//				objDraw.HasMorePages =true;
//				ret = true;
//			}
//			return ret;
//		}
        private bool m_mthDrawString(string strText, float X)
        {
            bool ret = false;

            if (strText == null)
            {
                strText = "";
            }
            string[] strArr = strText.Split('\n');
            float    tempX  = X;
            SizeF    size;

            for (int i = subRow; i < strArr.Length; i++)
            {
                size  = objDraw.Graphics.MeasureString(strArr[i], this.objFontNormal);
                tempX = X;
                if (size.Width > this.MaxLength)
                {
                    for (int i2 = 0; i2 < strArr[i].Length; i2++)
                    {
                        size = objDraw.Graphics.MeasureString(strArr[i][i2].ToString().Trim(), this.objFontNormal);
                        objDraw.Graphics.DrawString(strArr[i][i2].ToString().Trim(), objFontNormal, Brushes.Black, tempX, Y);
                        if (size.Width > 2.1f)
                        {
                            tempX += size.Width - 2.2f;
                        }
                        if (i2 < strArr[i].Length - 1)
                        {
                            if (tempX >= this.MaxLength && objSign.IndexOf(strArr[i][i2 + 1].ToString().Trim()) == -1)
                            {
                                Y    += this.fltRowHeight;
                                tempX = X;
                            }
                        }
                    }
                }
                else
                {
                    objDraw.Graphics.DrawString(strArr[i], objFontNormal, Brushes.Black, X, Y);
                }
                Y += this.fltRowHeight;
                subRow++;
                if (this.Y + this.fltRowHeight + 20 > this.objDraw.PageBounds.Height)
                {
                    objDraw.HasMorePages = true;
                    return(true);
                }
            }
            this.location++;
            subRow = 0;

            return(ret);
        }
 public int IndexOf(T obj)
 {
     mutex.WaitOne();
     try
     {
         return(array.IndexOf(obj));
     }
     finally
     {
         mutex.ReleaseMutex();
     }
 }
Example #20
0
 int System.Collections.IList.IndexOf(object Value)
 {
     Validate();
     if (Value == null)
     {
         return(-1);
     }
     try {
         return(Buffer.IndexOf(Value.ToString()));
     } catch (System.Exception Excpt) {
         Err.Add(Excpt);
     }
     return(-1);
 }
        /// <summary>
        /// Get list of unique SourceSystem values present in the collection
        /// </summary>
        /// <returns></returns>
        public BusinessObjects.WorkManagement.eWMSourceSystem[] GetSourceSystems()
        {
            BusinessObjects.WorkManagement.eWMSourceSystem[] arrPropertyValues = null;
            System.Collections.ArrayList colPropertyValues = new System.Collections.ArrayList();

            foreach (AssignmentDetails objDetails in this)
            {
                if (colPropertyValues.IndexOf(objDetails.SourceSystem) < 0)
                {
                    colPropertyValues.Add(objDetails.SourceSystem);
                }
            }

            if (colPropertyValues.Count > 0)
            {
                arrPropertyValues = (BusinessObjects.WorkManagement.eWMSourceSystem[])colPropertyValues.ToArray(typeof(BusinessObjects.WorkManagement.eWMSourceSystem));
            }

            return arrPropertyValues;
        }
Example #22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="listaRuoli"></param>
        /// <param name="idRuolo"></param>
        /// <returns></returns>
        public bool GetRuoliSuperiori(ref System.Collections.ArrayList listaRuoli, string idRuolo)
        {
            bool result = true;

            try
            {
                string            idParent;
                DocsPaUtils.Query q = DocsPaUtils.InitImportExportQuery.getInstance().getQuery("GET_RUOLI_LIVELLO_SUPERIORE");
                q.setParam("param1", idRuolo);
                string command = q.getSQL();
                logger.Debug(command);

                if (!this.ExecuteScalar(out idParent, command))
                {
                    throw new Exception();
                }

                if (idParent != null && idParent != string.Empty)
                {
                    if (listaRuoli.IndexOf(idParent) < 0)
                    {
                        listaRuoli.Add(idParent);
                    }
                }

                // Accedi ricorsivamente ai ruoli superiori di ogni ruolo
                if (idParent != null)
                {
                    this.GetRuoliSuperiori(ref listaRuoli, idParent);
                }
            }
            catch (Exception exception)
            {
                logger.Debug("Errore durante la lettura dei ruoli superiori", exception);
                result = false;
            }

            return(result);
        }
		/// <summary>
		/// Generates a Summary Table Outlining the Provider Charges and Revenues
		/// Illustrating Unearned Income
		/// use MinDate and MaxDate to flag all dates
		/// </summary>
		public static DataTable GenerateSummaryTable(int Guarantor,DateTime dtFrom, DateTime dtTo)
		{
			DataTable rValReturnTable = null;
			DataTable dtProviderBalance = Db.GetTableOld(ProviderRevenueByGuarantor(Guarantor,dtFrom,dtTo));
			DataTable dtProvAbbr = Db.GetTableOld("SELECT ProvNum, Abbr FROM Provider");
			if (dtProviderBalance != null && dtProviderBalance.Rows.Count != 0)
			{
				// Get Provider Abbreviations
				System.Collections.Hashtable htAllProvs = new System.Collections.Hashtable();
				for (int i = 0; i < dtProvAbbr.Rows.Count; i++)
					if (!htAllProvs.ContainsKey(dtProvAbbr.Rows[i][0].ToString()))
						htAllProvs[dtProvAbbr.Rows[i][0].ToString()] = dtProvAbbr.Rows[i][1].ToString();
				if (!htAllProvs.ContainsKey("0"))
					htAllProvs["0"] = "Unearned";
				// First establish a list of providers
				System.Collections.ArrayList alProvs = new System.Collections.ArrayList();
				for (int i = 0; i < dtProviderBalance.Rows.Count; i++)
					if (!alProvs.Contains(dtProviderBalance.Rows[i][0].ToString()))
						alProvs.Add(dtProviderBalance.Rows[i][0].ToString());

				// Fill and Create DataTable
				DataTable dtBalancesTable = new DataTable();
				dtBalancesTable.Columns.Add(new DataColumn("Provider", typeof(string)));
				dtBalancesTable.Columns.Add(new DataColumn("Charges", typeof(string)));
				dtBalancesTable.Columns.Add(new DataColumn("Adjustments", typeof(string)));
				dtBalancesTable.Columns.Add(new DataColumn("Revenue", typeof(string)));
				dtBalancesTable.Columns.Add(new DataColumn("Balance", typeof(string)));
				DataRow drWorkingRow = null;
				int ColumnIndex = -1;

				try
				{
					System.Collections.Hashtable htAllProvs_Indexes = new System.Collections.Hashtable();
					for (int i = 0; i < alProvs.Count; i++) // For Each Provider add a Row in the Balances Table
					{
						dtBalancesTable.Rows.Add(dtBalancesTable.NewRow());
						dtBalancesTable.Rows[i][0] = alProvs[i].ToString();
					}

					for (int i = 0; i < dtProviderBalance.Rows.Count; i++)
					{
						drWorkingRow = dtBalancesTable.Rows[alProvs.IndexOf(dtProviderBalance.Rows[i][0].ToString())];
						drWorkingRow[0] = htAllProvs[dtProviderBalance.Rows[i][0].ToString()].ToString(); // the abbreviation

						// Which Column of the Row to add the number to?  Find the column
						// stated in the query's column 2
						string ColumnName_FromQuery = dtProviderBalance.Rows[i][2].ToString();
						ColumnIndex = dtBalancesTable.Columns.IndexOf(ColumnName_FromQuery);
						if (ColumnIndex > 0)
							drWorkingRow[ColumnIndex] = dtProviderBalance.Rows[i][1].ToString(); // note is not cast as number so numeric specifies cannot apply //ToString("F2");
						else
							drWorkingRow[4] = "ERROR!";


						ColumnIndex = -1;
					}
					decimal[] Totals = new decimal[4];
					// Fill in Null and Empty Entries
					for (int j = 0; j < dtBalancesTable.Rows.Count; j++)
						for (int k = 1; k < dtBalancesTable.Columns.Count; k++)
						{
							if (dtBalancesTable.Rows[j][k] == null || dtBalancesTable.Rows[j][k].ToString().Trim() == "")
								dtBalancesTable.Rows[j][k] = "0.00";
							if (k == dtBalancesTable.Columns.Count - 1)
							{
								decimal Balance = decimal.Parse(dtBalancesTable.Rows[j][1].ToString())
								+ decimal.Parse(dtBalancesTable.Rows[j][2].ToString())
								+ decimal.Parse(dtBalancesTable.Rows[j][3].ToString());
								dtBalancesTable.Rows[j][4] = Balance.ToString("F2");
							}
							// Add to the Totals to be placed at the bottom of the Table
							Totals[k - 1] += decimal.Parse(dtBalancesTable.Rows[j][k].ToString());
							// Format the Numbers Better
							dtBalancesTable.Rows[j][k] = decimal.Parse(dtBalancesTable.Rows[j][k].ToString()).ToString("F2");
						}
					DataRow TotalRow = dtBalancesTable.NewRow();
					TotalRow[0] = "Totals-->";
					for (int i = 1; i < dtBalancesTable.Columns.Count; i++)
						TotalRow[i] = Totals[i - 1].ToString("F2");
					dtBalancesTable.Rows.Add(TotalRow);
				}
				catch
				{
				}
				rValReturnTable =  dtBalancesTable; // Set this first becuase SummaryTable_as_Strings() will check for _SummaryTable != null
			//	_SummaryTableHeader = SummaryTable_as_Strings();
			}
			return rValReturnTable;
		}
Example #24
0
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        protected void CalAction(HttpContext context, String action)
        {
            DataTable dtf = new DataTable();
            string result;
            if (dtf.Columns.Count < 1)
            {
                DataColumn fName = new DataColumn("mes", Type.GetType("System.String"));

                dtf.Dispose();
                dtf.Columns.Add(fName);

            }
            else
            { dtf.Clear(); }

            DataRow drf = dtf.NewRow();

            drf["mes"] = "OK";

            var parameters = getParameters(context.Request);

            switch (action)
            {
                case "UPDATEMDATE":
                    SysLog.WriteActionLog(context, action);
                    string gsql = "select id from itemrecordhead where mdate is null or mdate=''";
                    DataSet gds = Db.ExecDataSet(gsql);
                    DataTable gdt = gds.Tables[0];
                    for (int i = 0; i < gdt.Rows.Count; i++)
                    {
                       string id= gdt.Rows[i]["id"].ToString();
                       string asql = "select mdate from qcitemrecord where recordh_id=@id";
                       DataSet ads = Db.ExecDataSet(asql, new SqlParameter("id", id));
                       if (ads != null || ads.Tables[0].Rows.Count > 0)
                       {
                           DataTable adt = ads.Tables[0];
                           string mdate = adt.Rows[0]["mdate"].ToString();
                           string usql = "update itemrecordhead set mdate=@mdate where id=@id";
                           Db.ExecNonQuery(usql, new SqlParameter("mdate", mdate), new SqlParameter("id", id));
                       }
                    }

                    break;

                case "CALHEAD":
                    SysLog.WriteActionLog(context, action);
                    string sql = "delete from itemrecordhead";
                    Db.ExecNonQuery(sql);
                    sql = "select ponumber, poitem,sn,max(pn) as pn,max(type) as type,max(inspected_by) as inspected_by,max(reviewed_by) as reviewed_by,max(approved_by)as approved_by,max(printf)as printf from qcitemrecord group by ponumber,poitem,type,sn";
                    DataSet ds = Db.ExecDataSet(sql);
                    DataTable dt = ds.Tables[0];

                    long hid = DateTime.Now.Ticks;
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        hid++;
                        string pon = dt.Rows[i]["ponumber"].ToString();
                        string item = dt.Rows[i]["poitem"].ToString();
                        string type = dt.Rows[i]["type"].ToString();
                        string pn = dt.Rows[i]["pn"].ToString();
                        string sn = dt.Rows[i]["sn"].ToString();
                        string ib = dt.Rows[i]["inspected_by"].ToString();
                        string rb = dt.Rows[i]["reviewed_by"].ToString();
                        string ab = dt.Rows[i]["approved_by"].ToString();
                        string printf = dt.Rows[i]["printf"].ToString();
                        string sqla = "insert into itemrecordhead(id,ponumber,poitem,pn,sn,type,inspected_by,reviewed_by,approved_by,printf) values(@id,@pon,@item,@pn,@sn,@type,@ib,@rb,@ab,@printf)";
                        Db.ExecNonQuery(sqla, new SqlParameter("id", hid), new SqlParameter("pon", pon), new SqlParameter("item", item), new SqlParameter("pn", pn), new SqlParameter("sn", sn)
                            , new SqlParameter("type", type), new SqlParameter("ib", ib), new SqlParameter("rb", rb), new SqlParameter("ab", ab), new SqlParameter("printf", printf));
                        sqla = "update qcitemrecord set recordh_id = @id where ponumber=@pon and poitem=@item and sn=@sn and type=@type";
                        Db.ExecNonQuery(sqla, new SqlParameter("id", hid), new SqlParameter("pon", pon), new SqlParameter("item", item), new SqlParameter("sn", sn)
                        , new SqlParameter("type", type));

                        string sqlus = "select distinct status from qcitemrecord where recordh_id=@id";
                        string hstatus = "";
                        DateTime changet = DateTime.Now;
                        DataSet dsus = Db.ExecDataSet(sqlus, new SqlParameter("id", hid));
                        if (dsus != null || dsus.Tables[0].Rows.Count > 0)
                        {
                            System.Collections.ArrayList Alist = new System.Collections.ArrayList();
                            string sts;
                            for (var k = 0; k < dsus.Tables[0].Rows.Count; k++)
                            {
                                sts = dsus.Tables[0].Rows[k]["status"].ToString().Trim();
                                Alist.Add(sts);
                            }
                            //Alist.Sort();
                            if (Alist.IndexOf("") < 0)
                            {
                                if (Alist.IndexOf("0") < 0)
                                {
                                    if (Alist.IndexOf("-1") < 0)
                                    {
                                        if (Alist.IndexOf("2") < 0)
                                        {
                                            hstatus = "1";
                                        }
                                        else { hstatus = "2"; }
                                    }
                                    else { hstatus = "-1"; }
                                }
                                else { hstatus = "0"; }
                            }
                            else { hstatus = "0"; }
                        }
                        sqlus = "update itemrecordhead set status = @status where id = @id";
                        Db.ExecNonQuery(sqlus, new SqlParameter("status", hstatus), new SqlParameter("id", hid));

                    }
                    break;

                case "CALMR":
                    SysLog.WriteActionLog(context, action);
                    string msql = "select * from qcitemrecord  where (mean is null or mean='' or range='' or range is null)and value_type='0' and (status !='0'or printf='1') and A!='' and A!=null";
                    DataSet mds = Db.ExecDataSet(msql);
                    if (mds != null && mds.Tables[0].Rows.Count > 0)
                    {

                        for (int j = 0; j < mds.Tables[0].Rows.Count; j++)
                        {
                            DataTable mdt = mds.Tables[0];
                            string id = mdt.Rows[j]["id"].ToString();
                            string[] ads = Exprocedure(id);
                            if (ads != null && ads.Length > 0)
                            {
                                string mean = ads[0].ToString();
                                string range = ads[1].ToString();
                                if (mean != "" && range != "")
                                {
                                    string bsql = "update qcitemrecord set range=@range,mean=@mean where id = @id";
                                    Db.ExecNonQuery(bsql, new SqlParameter("id", id), new SqlParameter("range", range), new SqlParameter("mean", mean));
                                }
                            }
                            else continue;
                        }
                    }
                    break;

                case "CALMRR":
                    SysLog.WriteActionLog(context, action);
                    string rsql = "select B.id,B.A,B.B,B.C,B.D,B.E,B.F,B.G,B.H,B.I,B.J,B.K,B.L,B.M,B.N,B.O,B.P from itemrecordhead as A right join qcitemrecord as B on A.id=B.recordh_id where B.value_type='0' and (B.status !='0'or A.printf='1') and B.samples>1";
                    DataSet rds = Db.ExecDataSet(rsql);
                    if (rds != null && rds.Tables[0].Rows.Count > 0)
                    {

                        for (int j = 0; j < rds.Tables[0].Rows.Count; j++)
                        {
                            DataTable rdt = rds.Tables[0];
                            string id = rdt.Rows[j]["id"].ToString();
                            string[] ads = rExprocedure(id);
                            if (ads != null && ads.Length > 0)
                            {
                                string mean = ads[0].ToString();
                                string range = ads[1].ToString();
                                if (mean != "" && range != "")
                                {
                                    string bsql = "update qcitemrecord set range=@range,mean=@mean where id = @id";
                                    Db.ExecNonQuery(bsql, new SqlParameter("id", id), new SqlParameter("range", range), new SqlParameter("mean", mean));
                                }
                            }
                            else continue;
                        }
                    }
                    break;
            }

            dtf.Rows.Add(drf);
            result = Dtb2Json(dtf);
            context.Response.ContentType = "text/plain";
            context.Response.Write(result);
            return;
        }
Example #25
0
        public void IterateThroughJSON(dynamic myObj, Rhino.Collections.ArchivableDictionary myDict)
        {
            if (((IDictionary <String, object>)myObj).ContainsKey("children"))
            {
                Rhino.RhinoApp.WriteLine("is Folder");

                //myDict.Set(myObj.Key)


                List <object> myObjChildrenKeys = new List <object>();

                for (int i = 0; i < myObj.children.Count; i++)
                {
                    myObjChildrenKeys.Add(myObj.children[i].Key);
                    dynamic kvp = myObj.children[i];

                    System.Collections.ArrayList arrayList = new System.Collections.ArrayList(myObjChildrenKeys);


                    int first = arrayList.IndexOf(kvp.Key.ToString());
                    int last  = arrayList.LastIndexOf(kvp.Key.ToString());
                    //Rhino.RhinoApp.WriteLine(first.ToString(), "thatsmyobj");

                    if (((IDictionary <String, object>)kvp).ContainsKey("children"))
                    {
                        Rhino.Collections.ArchivableDictionary newDict = new Rhino.Collections.ArchivableDictionary();



                        if (first != -1 && first != last)
                        {
                            Rhino.RhinoApp.WriteLine("found it!");
                            myDict.Set(kvp.Key + " (at index " + i + ")", newDict);
                        }
                        else
                        {
                            myDict.Set(kvp.Key, newDict);
                        }

                        IterateThroughJSON(kvp, newDict);
                    }
                    else
                    {
                        if (kvp.Key == "Id")
                        {
                            Rhino.RhinoApp.WriteLine(kvp.Value);
                            Guid        myGuid      = new Guid(kvp.Value);
                            RhinoObject foundObject = Rhino.RhinoDoc.ActiveDoc.Objects.Find(myGuid);
                            myDict.Set("Geometry", foundObject.Geometry);
                        }
                        else
                        {
                            if (first != -1 && first != last)
                            {
                                Rhino.RhinoApp.WriteLine("found it!");
                                myDict.Set(kvp.Key + " (at index " + i + ")", kvp.Value);
                            }
                            else
                            {
                                myDict.Set(kvp.Key, kvp.Value);
                            }
                        }
                    }
                }
            }
            else   // no children
            {
                Rhino.RhinoApp.WriteLine(myObj.Value);
                myDict.Set(myObj.Key, myObj.Value);
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine($"1. a {new String('-', 15)}");
            System.Collections.ArrayList array = new System.Collections.ArrayList();
            Random random = new Random();

            for (int i = 0; i < 5; ++i)
            {
                array.Add(random.Next(0, 1000));
            }
            foreach (var item in array)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine($"1. b {new String('-', 15)}");
            array.Add("string");
            foreach (var item in array)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine($"1. c {new String('-', 15)}");
            array.Add(new Student());
            foreach (var item in array)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine($"1. d {new String('-', 15)}");
            array.Remove(3);
            foreach (var item in array)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine($"1. e {new String('-', 15)}");
            Console.WriteLine("ArrayList:");
            foreach (var item in array)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine($"Count: {array.Count}");
            Console.WriteLine($"1. f {new String('-', 15)}");
            Console.WriteLine($"Содержит в коллекции элемент 'string' в позиции:{array.IndexOf("string")}");
            Console.WriteLine($"2. a {new String('-', 15)}");
            SortedList <float, float> sortedList = new SortedList <float, float>()
            {
                [1.0f]  = 1.3f,
                [9.0f]  = 9.4f,
                [5.0f]  = 5.3f,
                [2.0f]  = 2.8f,
                [11.0f] = 11.1f,
                [13.0f] = 13.8f
            };

            foreach (var key in sortedList.Keys)
            {
                Console.WriteLine($"{key} : {sortedList[key]}");
            }
            Console.WriteLine($"2. b {new String('-', 15)}");
            Console.WriteLine("Введите количество удаляемых элементов со 2 позиции");
            int count = int.Parse(Console.ReadLine());

            for (int i = 0; i < count; ++i)
            {
                sortedList.RemoveAt(2);
            }
            foreach (var key in sortedList.Keys)
            {
                Console.WriteLine($"{key} : {sortedList[key]}");
            }
            Console.WriteLine($"2. с {new String('-', 15)}");
            sortedList.Add(21.0f, 21.4f);
            foreach (var key in sortedList.Keys)
            {
                Console.WriteLine($"{key} : {sortedList[key]}");
            }
            Console.WriteLine($"2. d {new String('-', 15)}");
            Stack <float> stack = new Stack <float>();

            foreach (var item in sortedList.Values)
            {
                stack.Push(item);
            }
            Console.WriteLine($"2. e {new String('-', 15)}");
            foreach (var item in sortedList.Values)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine($"2. f {new String('-', 15)}");
            Console.WriteLine($"Содержит в коллекции элемент '2.8' в позиции:{IndexOf(stack, 13.8f)}");
            Console.WriteLine($"3. a {new String('-', 15)}");
            SortedList <float, Rectangle> sortedList2 = new SortedList <float, Rectangle>()
            {
                [1.0f] = new Rectangle("Квадрат"),
                [2.0f] = new Rectangle("Шестиугольник"),
                [3.0f] = new Rectangle("Пятиугольник"),
                [4.0f] = new Rectangle("Круг")
            };

            foreach (var key in sortedList2.Keys)
            {
                Console.WriteLine($"{key} : {sortedList2[key]}");
            }
            Console.WriteLine($"3. b {new String('-', 15)}");
            Console.WriteLine("Введите количество удаляемых элементов со 2 позиции");
            count = int.Parse(Console.ReadLine());
            for (int i = 0; i < count; ++i)
            {
                sortedList2.RemoveAt(2);
            }
            foreach (var key in sortedList2.Keys)
            {
                Console.WriteLine($"{key} : {sortedList2[key]}");
            }
            Console.WriteLine($"3. с {new String('-', 15)}");
            sortedList2.Add(5.0f, new Rectangle("Двадцатишестиугольник"));
            foreach (var key in sortedList2.Keys)
            {
                Console.WriteLine($"{key} : {sortedList2[key]}");
            }
            Console.WriteLine($"3. d {new String('-', 15)}");
            Stack <Rectangle> stack2 = new Stack <Rectangle>();

            foreach (var item in sortedList2.Values)
            {
                stack2.Push(item);
            }
            Console.WriteLine($"3. e {new String('-', 15)}");
            foreach (var item in stack2)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine($"3. f {new String('-', 15)}");
            Console.WriteLine($"Элемент Rectangle находится в коллекции:{IndexOf(stack2, new Rectangle("Шестиугольник"))}");
            var observCollection = new ObservableCollection <Figure>();

            observCollection.CollectionChanged += ChangedCollection;
            observCollection.Add(new Figure("Rectangle"));
            observCollection.RemoveAt(0);
            Console.ReadKey();
        }
Example #27
0
        private void monitorear()
        {
            try
            {
                Logger.Log("Monitoreo iniciado.");
                string queryAlertas =
                    "SELECT nombre, id_satelital, alerta_id, umbral_nivel_verde, umbral_nivel_amarilla," +
                    "       umbral_nivel_roja, umbral_lluvia_verde, umbral_lluvia_amarilla " +
                    "FROM" +
                    "(" +
                    "    SELECT nombre, id_satelital, alerta_id" +
                    "    FROM SAT.Estaciones" +
                    "    WHERE activa = 1 AND alerta_id IS NOT NULL" +
                    ") AS e " +
                    "INNER JOIN (" +
                    "    SELECT id, umbral_nivel_verde, umbral_nivel_amarilla, umbral_nivel_roja, " +
                    "    umbral_lluvia_verde, umbral_lluvia_amarilla" +
                    "    FROM SAT.alertas" +
                    ") AS a ON a.id = e.alerta_id;";
                string queryDatos;
                MySqlConnection con;
                MySqlCommand cmd;
                MySqlDataReader rdrMonitoreo;
                System.Collections.ArrayList alertasEstaciones;
                alerta alertaEstacion;
                while (true)
                {
                    con = new MySqlConnection(Properties.Resources.MySqlConn);
                    cmd = new MySqlCommand(queryAlertas, con);
                    if (con.State != System.Data.ConnectionState.Open)
                    {
                        con.Open();
                        Logger.Log("Conexion a BD abierta");
                    }
                    rdrMonitoreo = cmd.ExecuteReader();
                    Logger.Log("Query de estaciones y alertas ejecutado");
                    string ids = "";
                    alertasEstaciones = new System.Collections.ArrayList(50);
                    Logger.Log("Preparando para leer estaciones");
                    while (rdrMonitoreo.Read())
                    {
                        alertaEstacion = new alerta(rdrMonitoreo.GetString("id_satelital"));
                        //alertaEstacion.idSatelital = ;
                        alertaEstacion.nombre = rdrMonitoreo.GetString("nombre");
                        alertaEstacion.idAlerta = rdrMonitoreo.GetUInt32("alerta_id");
                        alertaEstacion.uNivelVerde = rdrMonitoreo.IsDBNull(3) ? -1.0 : rdrMonitoreo.GetDouble("umbral_nivel_verde");
                        alertaEstacion.uNivelAmarilla = rdrMonitoreo.IsDBNull(4) ? -1.0 : rdrMonitoreo.GetDouble("umbral_nivel_amarilla");
                        alertaEstacion.uNivelRoja = rdrMonitoreo.IsDBNull(5) ? -1.0 : rdrMonitoreo.GetDouble("umbral_nivel_roja");
                        alertaEstacion.uLluviaVerde = rdrMonitoreo.IsDBNull(6) ? -1.0 : rdrMonitoreo.GetDouble("umbral_lluvia_verde");
                        alertaEstacion.uLluviaAmarilla = rdrMonitoreo.IsDBNull(7) ? -1.0 : rdrMonitoreo.GetDouble("umbral_lluvia_amarilla");
                        alertasEstaciones.Add(alertaEstacion);
                        ids += "'" + alertaEstacion.idSatelital + "',";
                    }
                    Logger.Log("Datos de estaciones leidos");
                    rdrMonitoreo.Close();
                    queryDatos =
                        "SELECT sta.SATELLITE_ID, dat.*, d.ED_VALUE " +
                        "FROM xc_data.xc_data1 as d " +
                        "INNER JOIN " +
                        "( " +
                        "SELECT STATION_ID, MAX(TIME_TAG) AS TIME_TAG, SENSORNAME " +
                        "FROM xc_data.xc_data1 " +
                        "WHERE SENSORNAME IN ('LLUVIA', 'NIVEL') " +
                        "GROUP BY STATION_ID, SENSORNAME " +
                        ") as dat on dat.TIME_TAG = d.TIME_TAG AND dat.STATION_ID = d.STATION_ID AND d.SENSORNAME = dat.SENSORNAME " +
                        "INNER JOIN " +
                        "( " +
                        "  SELECT STATION_ID, SATELLITE_ID " +
                        "  FROM xc_data.xc_sites " +
                        //"-- \"  WHERE SATELLITE_ID IN ('5042B196', '5045D644', '504484C2', '5042977A', '50469240', '50439580', '5040E41E')" +
                        "  WHERE SATELLITE_ID IN (" + ids.Substring(0, ids.Length - 1) + ") " +
                        ") as sta ON sta.STATION_ID = dat.STATION_ID;";
                    cmd.CommandText = queryDatos;
                    rdrMonitoreo = cmd.ExecuteReader();
                    Logger.Log("Query de datos ejectuado");
                    Logger.Log("Leyendo datos");
                    while (rdrMonitoreo.Read())
                    {
                        int idx = alertasEstaciones.IndexOf(new alerta(rdrMonitoreo.GetString("SATELLITE_ID")));
                        string msg = "";
                        switch (rdrMonitoreo.GetString("SENSORNAME"))
                        {
                            case "NIVEL":
                                if (rdrMonitoreo.GetDouble("ED_VALUE") >= ((alerta)(alertasEstaciones[idx])).uNivelRoja)
                                {
                                    /*System.Windows.Forms.MessageBox.Show(
                                    "ALERTA ROJA!\n" +
                                    "Estación: " + rdrMonitoreo.GetString("STATION_ID") + "\n" +
                                    "Sensor: " + rdrMonitoreo.GetString("SENSORNAME") + "\n" +
                                    "Umbral:" + ((alerta)(alertasEstaciones[idx])).uNivelRoja.ToString() + "\n" +
                                    "Valor: " + rdrMonitoreo.GetDouble("ED_VALUE").ToString() + "\n" +
                                    "Fecha/Hora: " + rdrMonitoreo.GetString("TIME_TAG") + "\n", "ALERTA!!!");*/
                                    msg = "ALERTA ROJA!\n" +
                                    "Estación: " + rdrMonitoreo.GetString("STATION_ID") + "\n" +
                                    "Sensor: " + rdrMonitoreo.GetString("SENSORNAME") + "\n" +
                                    "Umbral:" + ((alerta)(alertasEstaciones[idx])).uNivelRoja.ToString() + "\n" +
                                    "Valor: " + rdrMonitoreo.GetDouble("ED_VALUE").ToString() + "\n" +
                                    "Fecha/Hora: " + rdrMonitoreo.GetString("TIME_TAG") + "\n";
                                }
                                else if (rdrMonitoreo.GetDouble("ED_VALUE") >= ((alerta)(alertasEstaciones[idx])).uNivelAmarilla)
                                {
                                    /*System.Windows.Forms.MessageBox.Show(
                                    "ALERTA AMARILLA!\n" +
                                    "Estación: " + rdrMonitoreo.GetString("STATION_ID") + "\n" +
                                    "Sensor: " + rdrMonitoreo.GetString("SENSORNAME") + "\n" +
                                    "Umbral:" + ((alerta)(alertasEstaciones[idx])).uNivelAmarilla.ToString() + "\n" +
                                    "Valor: " + rdrMonitoreo.GetDouble("ED_VALUE").ToString() + "\n" +
                                    "Fecha/Hora: " + rdrMonitoreo.GetString("TIME_TAG") + "\n", "ALERTA!!!");*/
                                    msg = "ALERTA AMARILLA!\n" +
                                    "Estación: " + rdrMonitoreo.GetString("STATION_ID") + "\n" +
                                    "Sensor: " + rdrMonitoreo.GetString("SENSORNAME") + "\n" +
                                    "Umbral:" + ((alerta)(alertasEstaciones[idx])).uNivelAmarilla.ToString() + "\n" +
                                    "Valor: " + rdrMonitoreo.GetDouble("ED_VALUE").ToString() + "\n" +
                                    "Fecha/Hora: " + rdrMonitoreo.GetString("TIME_TAG") + "\n";
                                }
                                else if (rdrMonitoreo.GetDouble("ED_VALUE") >= ((alerta)(alertasEstaciones[idx])).uNivelVerde)
                                {
                                    /*System.Windows.Forms.MessageBox.Show(
                                    "ALERTA VERDE!\n" +
                                    "Estación: " + rdrMonitoreo.GetString("STATION_ID") + "\n" +
                                    "Sensor: " + rdrMonitoreo.GetString("SENSORNAME") + "\n" +
                                    "Umbral:" + ((alerta)(alertasEstaciones[idx])).uNivelVerde.ToString() + "\n" +
                                    "Valor: " + rdrMonitoreo.GetDouble("ED_VALUE").ToString() + "\n" +
                                    "Fecha/Hora: " + rdrMonitoreo.GetString("TIME_TAG") + "\n", "ALERTA!!!");**/
                                    msg = "ALERTA VERDE!\n" +
                                    "Estación: " + rdrMonitoreo.GetString("STATION_ID") + "\n" +
                                    "Sensor: " + rdrMonitoreo.GetString("SENSORNAME") + "\n" +
                                    "Umbral:" + ((alerta)(alertasEstaciones[idx])).uNivelVerde.ToString() + "\n" +
                                    "Valor: " + rdrMonitoreo.GetDouble("ED_VALUE").ToString() + "\n" +
                                    "Fecha/Hora: " + rdrMonitoreo.GetString("TIME_TAG") + "\n";
                                }
                                if (msg != "")
                                {
                                    Logger.Log(msg);
                                    Dictionary<string, string[]> dict =
                                        getContactos(((alerta)(alertasEstaciones[idx])).idAlerta);
                                    //Correos
                                    foreach (string dir in dict["Correos"])
                                    {
                                        try
                                        {
                                            if (dir != null)
                                            {
                                                Cartero.enviarCorreo(dir, msg);
                                                Logger.Log("Envio de alerta por correo a " + dir);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            Logger.Log("Error: " + ex.Message + "@-> " + dir);
                                        }
                                    }
                                    //Sms
                                    foreach (string tel in dict["Sms"])
                                    {
                                        try
                                        {
                                            if (tel != null)
                                            {
                                                //Mensajero.enviarMensaje(tel, msg);
                                                Logger.Log("Envio de alerta por SMS a " + tel);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            Logger.Log("Error: " + ex.Message + "@-> " + tel);
                                        }
                                    }
                                    //Llamadas
                                    foreach (string tel in dict["Llamadas"])
                                    {
                                        try
                                        {
                                            if (tel != null)
                                            {
                                                //Operadora.Llamar(tel, msg);
                                                Logger.Log("Envio de alerta por Teléfono a " + tel);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            Logger.Log("Error: " + ex.Message + "@-> " + tel);
                                        }
                                    }
                                }
                                break;
                            case "LLUVIA":
                                /* if (rdrMonitoreo.GetDouble("ED_VALUE") >= ((alerta)(alertasEstaciones[idx])).uLluviaVerde)
                                 {
                                     System.Windows.Forms.MessageBox.Show(
                                     "ALERTA ROJA!\n" +
                                     "Estación: " + rdrMonitoreo.GetString("STATION_ID") + "\n" +
                                     "Sensor: " + rdrMonitoreo.GetString("SENSORNAME") + "\n" +
                                     "Umbral:" + ((alerta)(alertasEstaciones[idx])).uNivelRoja.ToString() + "\n" +
                                     "Valor: " + rdrMonitoreo.GetDouble("ED_VALUE").ToString() + "\n" +
                                     "Fecha/Hora: " + rdrMonitoreo.GetString("TIME_TAG") + "\n", "ALERTA!!!");
                                 }
                                 else if (rdrMonitoreo.GetDouble("ED_VALUE") >= ((alerta)(alertasEstaciones[idx])).uLluviaAmarilla)
                                 {
                                     System.Windows.Forms.MessageBox.Show(
                                     "ALERTA AMARILLA!\n" +
                                     "Estación: " + rdrMonitoreo.GetString("STATION_ID") + "\n" +
                                     "Sensor: " + rdrMonitoreo.GetString("SENSORNAME") + "\n" +
                                     "Umbral:" + ((alerta)(alertasEstaciones[idx])).uNivelAmarilla.ToString() + "\n" +
                                     "Valor: " + rdrMonitoreo.GetDouble("ED_VALUE").ToString() + "\n" +
                                     "Fecha/Hora: " + rdrMonitoreo.GetString("TIME_TAG") + "\n", "ALERTA!!!");
                                 }*/
                                break;
                        }
                    }
                    rdrMonitoreo.Close();
                    if (con.State == System.Data.ConnectionState.Open)
                    {
                        con.Close();
                    }
                    Logger.Log("Datos leidos. A dormir " + Parametros.Intervalo.ToString("HH:mm:ss") + " ...");
                    Thread.Sleep(
                        new TimeSpan(
                            Parametros.Intervalo.Hour,
                            Parametros.Intervalo.Minute,
                            Parametros.Intervalo.Second
                        )
                    );
                }

            }
            catch (ThreadAbortException abortEx)
            {
                Logger.Log("Monitoreo detenido.");
                Logger.Log(abortEx.Message);
                return;
            }
            catch (ThreadInterruptedException interruptEx)
            {
                Logger.Log("Despertando...");
                mon = new Thread(this.monitorear);
                mon.Start();
                return;
            }
            catch (MySqlException mySqlEx)
            {
                Logger.Log("Error en el monitoreo: " + mySqlEx.Message);
                return;
            }
            catch (Exception Ex)
            {
                Logger.Log("Error en el monitoreo: " + Ex.Message);
                return;
            }
        }
Example #28
0
 /// <summary>
 /// 返回属性在列表中的从0开始的序号
 /// </summary>
 /// <param name="attr">属性对象</param>
 /// <returns>序号,若不存在则返回-1</returns>
 public int IndexOf(HTMLAttribute attr)
 {
     return(myItems.IndexOf(attr));
 }
Example #29
0
 ///<summary>
 ///Searches for the specified unit_node and returns the zero-based index of the first occurrence within the entire unit_nodeArrayList.
 ///</summary>
 ///<param name="value">The unit_node to locate in the unit_nodeArrayList. The value can be a null reference.<param>
 ///<returns>The zero-based index of the first occurrence of value within the entire unit_nodeArrayList, if found; otherwise, -1.</returns>
 public int IndexOf(unit_node value)
 {
     return(arr.IndexOf(value));
 }
Example #30
0
        private void RemoveComboBoxItems(ReadWriteObject readWriteObject)
        {
            int index = clientList.IndexOf(readWriteObject);

            comboBox1.Items.RemoveAt(index);
        }
Example #31
0
        public static void updatestatus(string id,string irecord_id,string istatus,string changetf)
        {
            //update status of qcitemrecord
            //string sql = "update qcitemrecord set status=@status where id=@record_id";
            //Db.ExecNonQuery(sql, new SqlParameter("status", istatus), new SqlParameter("record_id", irecord_id));

            //update status of itemrecordhead

            string recordh_id = id;
            string sqlus = "select distinct status from qcitemrecord where recordh_id=@id";
            string hstatus = "";
            DateTime changet = DateTime.Now;
            DataSet dsus = Db.ExecDataSet(sqlus, new SqlParameter("id", recordh_id));
            if (dsus != null || dsus.Tables[0].Rows.Count > 0)
            {
                System.Collections.ArrayList Alist = new System.Collections.ArrayList();
                string sts;
                for (var i = 0; i < dsus.Tables[0].Rows.Count; i++)
                {
                    sts = dsus.Tables[0].Rows[i]["status"].ToString().Trim();
                    Alist.Add(sts);
                }
                //Alist.Sort();
                if (Alist.IndexOf("") < 0)
                {
                    if (Alist.IndexOf("0") < 0)
                    {
                        if (Alist.IndexOf("-2") < 0)
                        {
                            if (Alist.IndexOf("-1") < 0)
                            {
                                if (Alist.IndexOf("2") < 0)
                                {
                                    hstatus = "1";
                                }
                                else { hstatus = "2"; }
                            }
                            else { hstatus = "-1"; }
                        }
                        else { hstatus = "-2"; }
                    }
                    else { hstatus = "0"; }
                }
                else { hstatus = "0"; }
            }
            if (changetf == "1")
            {
                sqlus = "update itemrecordhead set last_changed = @changet,status = @status where id = @id";
                Db.ExecNonQuery(sqlus, new SqlParameter("changet", changet), new SqlParameter("status", hstatus), new SqlParameter("id", recordh_id));
            }
            else {
                sqlus = "update itemrecordhead set status = @status where id = @id";
                Db.ExecNonQuery(sqlus, new SqlParameter("status", hstatus), new SqlParameter("id", recordh_id));

            }
        }
Example #32
0
		/// <summary> This is the core routine for decoding incoming messages and deciding what should be
		/// done with them.  We have registered ourself with DProtocol to be notified when any
		/// incoming messages have been received.
		/// 
		/// It is important to note that we should not rely on the contents of the message
		/// since it may be reused after we exit this method.
		/// </summary>
		public virtual void  messageArrived(DMessage msg, DProtocol which)
		{
			/* at this point we just open up a big switch statement and walk through all possible cases */
			int type = msg.Type;
			//		System.out.println("manager msg = "+DMessage.inTypeName(type));
			
			switch (type)
			{
				
				case DMessage.InVersion: 
				{
                    long ver = msg.getDWord();
					m_playerVersion = (int) ver;
					break;
				}
				
				
				case DMessage.InErrorExecLimit: 
				{
					handleFaultEvent(new RecursionLimitFault());
					break;
				}
				
				
				case DMessage.InErrorWith: 
				{
					handleFaultEvent(new InvalidWithFault());
					break;
				}
				
				
				case DMessage.InErrorProtoLimit: 
				{
					handleFaultEvent(new ProtoLimitFault());
					break;
				}
				
				
				case DMessage.InErrorURLOpen: 
				{
                    String url = msg.getString();
					handleFaultEvent(new InvalidURLFault(url));
					break;
				}
				
				
				case DMessage.InErrorTarget: 
				{
                    String name = msg.getString();
					handleFaultEvent(new InvalidTargetFault(name));
					break;
				}
				
				
				case DMessage.InErrorException: 
				{
                    long offset = msg.getDWord();
					// As of FP9, the player will also send the "toString()" message
					// of the exception.  But for backward compatibility with older
					// players, we won't assume that that is there.
					String exceptionMessage;
					if (msg.Remaining > 0)
                        exceptionMessage = msg.getString();
					else
						exceptionMessage = ""; //$NON-NLS-1$
					handleFaultEvent(new ExceptionFault(exceptionMessage));
					break;
				}
				
				
				case DMessage.InErrorStackUnderflow: 
				{
                    long offset = msg.getDWord();
					handleFaultEvent(new StackUnderFlowFault());
					break;
				}
				
				
				case DMessage.InErrorZeroDivide: 
				{
                    long offset = msg.getDWord();
					handleFaultEvent(new DivideByZeroFault());
					break;
				}
				
				
				case DMessage.InErrorScriptStuck: 
				{
					handleFaultEvent(new ScriptTimeoutFault());
					break;
				}
				
				
				case DMessage.InErrorConsole: 
				{
                    String s = msg.getString();
					handleFaultEvent(new ConsoleErrorFault(s));
					break;
				}
				
				
				case DMessage.InTrace: 
				{
                    String text = msg.getString();
					addEvent(new TraceEvent(text));
					break;
				}
				
				
				case DMessage.InSquelch: 
				{
                    long state = msg.getDWord();
					m_squelchEnabled = (state != 0)?true:false;
					break;
				}
				
				
				case DMessage.InParam: 
				{
                    String name = msg.getString();
                    String value = msg.getString();
					
					// here's where we get movie = URL and password which I'm not sure what to do with?
					//				System.out.println(name+"="+value);
					m_parms[name] = value;
					
					// if string is a "movie", then this is a URL
					if (name.StartsWith("movie"))
					//$NON-NLS-1$
						m_uri = convertToURI(value);
					break;
				}
				
				
				case DMessage.InPlaceObject: 
				{
                    long objId = msg.getDWord();
					String path = msg.getString();
					//				m_bag.placeObject((int)objId, path);
					break;
				}
				
				
				case DMessage.InSetProperty: 
				{
                    long objId = msg.getDWord();
					int item = msg.getWord();
                    String value = msg.getString();
					break;
				}
				
				
				case DMessage.InNewObject: 
				{
                    long objId = msg.getDWord();
					break;
				}
				
				
				case DMessage.InRemoveObject: 
				{
                    long objId = msg.getDWord();
					//				m_bag.removeObject((int)objId);
					break;
				}
				
				
				case DMessage.InSetVariable: 
				{
                    long objId = msg.getDWord();
                    String name = msg.getString();
					int dType = msg.getWord();
                    int flags = (int)msg.getDWord();
                    String value = msg.getString();
					
					//				m_bag.createVariable((int)objId, name, dType, flags, value);
					break;
				}
				
				
				case DMessage.InDeleteVariable: 
				{
                    long objId = msg.getDWord();
                    String name = msg.getString();
					//				m_bag.deleteVariable((int)objId, name);
					break;
				}
				
				
				case DMessage.InScript: 
				{
                    int module = (int)msg.getDWord();
                    int bitmap = (int)msg.getDWord();
                    String name = msg.getString(); // in "basepath;package;filename" format
                    String text = msg.getString();
					int swfIndex = - 1;
					
					/* new in flash player 9: player tells us what swf this is for */
					if (msg.Remaining >= 4)
                        swfIndex = (int)msg.getDWord();
					
					lock (m_source)
					{
						// create new source file
						if (putSource(swfIndex, module, bitmap, name, text))
						{
							// have we changed the list since last query
							if (!m_sourceListModified)
								addEvent(new FileListModifiedEvent());
							
							m_sourceListModified = true; /* current source list is stale */
						}
					}
					break;
				}
				
				
				case DMessage.InRemoveScript: 
				{
                    long module = msg.getDWord();
					lock (m_source)
					{
						if (removeSource((int) module))
						{
							// have we changed the list since last query
							if (!m_sourceListModified)
								addEvent(new FileListModifiedEvent());
							
							m_sourceListModified = true; /* current source list is stale */
						}
					}
					break;
				}
				
				
				case DMessage.InAskBreakpoints: 
				{
					// the player has just loaded a swf and we know the player
					// has halted, waiting for us to continue.  The only caveat
					// is that it looks like it still does a number of things in
					// the background which take a few seconds to complete.
					if (m_suspendInfo == null)
						m_suspendInfo = new DSuspendInfo(SuspendReason.ScriptLoaded, 0, 0, 0, 0);
					break;
				}
				
				
				case DMessage.InBreakAt: 
				{
                    long bp = msg.getDWord();
                    long id = msg.getDWord();
                    String stack = msg.getString();
					//				System.out.println(msg.getInTypeName()+",bp="+(bp&0xffff)+":"+(bp>>16)+",id="+id+",stack=\n"+stack);
					
					//System.out.println("InBreakAt");
					
					int module = DLocation.decodeFile(bp);
					int line = DLocation.decodeLine(bp);
					addEvent(new BreakEvent(module, line));
					break;
				}
				
				
				case DMessage.InContinue: 
				{
					/* we are running again so trash all our variable contents */
					continuing();
					break;
				}
				
				
				case DMessage.InSetLocalVariables: 
				{
                    long objId = msg.getDWord();
					//				m_bag.markObjectLocal((int)objId, true);
					break;
				}
				
				
				case DMessage.InSetBreakpoint: 
				{
                    long count = msg.getDWord();
					while (count-- > 0)
					{
                        long bp = msg.getDWord();
						
						int fileId = DLocation.decodeFile(bp);
						int line = DLocation.decodeLine(bp);
						
						DModule file = getSource(fileId);
						DLocation l = new DLocation(file, line);
						
						if (file != null)
							addBreakpoint((int) bp, l);
					}
					break;
				}
				
				
				case DMessage.InNumScript: 
				{
					/* lets us know how many scripts there are */
                    int num = (int)msg.getDWord();
					DSwfInfo swf;
					
					/*
					* New as of flash player 9: another dword indicating which swf this is for.
					* That means we don't have to guess whether this is for an old SWF
					* which has just had some more modules loaded, or for a new SWF!
					*/
					if (msg.Remaining >= 4)
					{
                        int swfIndex = (int)msg.getDWord();
						swf = getOrCreateSwfInfo(swfIndex);
						m_lastSwfInfo = swf;
					}
					else
					{
						/* This is not flash player 9 (or it is an early build of fp9).
						*
						* We use this message as a trigger that a new swf has been loaded, so make sure
						* we are ready to accept the scripts.
						*/
						swf = ActiveSwfInfo;
					}
					
					// It is NOT an error for the player to have sent us a new,
					// different sourceExpectedCount from whatever we had before!
					// In fact, this happens all the time, whenever a SWF has more
					// than one ABC.
					swf.SourceExpectedCount = num;
					break;
				}
				
				
				case DMessage.InRemoveBreakpoint: 
				{
                    long count = msg.getDWord();
					while (count-- > 0)
					{
                        long bp = msg.getDWord();
						removeBreakpoint((int) bp);
					}
					break;
				}
				
				
				case DMessage.InBreakAtExt: 
				{
                    long bp = msg.getDWord();
                    long num = msg.getDWord();
					
					//				System.out.println(msg.getInTypeName()+",bp="+(bp&0xffff)+":"+(bp>>16));
					/* we have stack info to store away */
					clearFrames(); // just in case
					int depth = 0;
					while (num-- > 0)
					{
                        long bpi = msg.getDWord();
                        long id = msg.getDWord();
                        String stack = msg.getString();
						int module = DLocation.decodeFile(bpi);
						int line = DLocation.decodeLine(bpi);
						DModule m = getSource(module);
						DStackContext c = new DStackContext(module, line, m, (int) id, stack, depth);
						// If addFrame() returns false, that means it chose to ignore this
						// frame, so we do NOT want to increment our depth for the next
						// time through the loop.  If it returns true, then we do want to.
						if (addFrame(c))
							++depth;
						//					System.out.println("   this="+id+",@"+(bpi&0xffff)+":"+(bpi>>16)+",stack="+stack);
					}
					mapOldFramesToNew();
					break;
				}
				
				
				case DMessage.InFrame: 
				{
					// For InFrame the first element is really our frame id
					DValue frame = null;
					DVariable child = null;
					System.Collections.ArrayList v = new System.Collections.ArrayList();
					System.Collections.ArrayList registers = new System.Collections.ArrayList();

                    int depth = (int)msg.getDWord(); // depth of frame
					
					// make sure we have a valid depth
					if (depth > - 1)
					{
						// first thing is number of registers
                        int num = (int)msg.getDWord();
						for (int i = 0; i < num; i++)
							registers.Add(extractRegister(msg, i + 1));
					}
					
					int currentArg = - 1;
					bool gettingScopeChain = false;
					
					// then our frame itself
					while (msg.Remaining > 0)
					{
                        long frameId = msg.getDWord();
						
						if (frame == null)
						{
							frame = getOrCreateValue(frameId);
							extractVariable(msg); // put the rest of the info in the trash
						}
						else
						{
							child = extractVariable(msg);
							if (currentArg == - 1 && child.getName().Equals(ARGUMENTS_MARKER))
							{
								currentArg = 0;
								gettingScopeChain = false;
							}
							else if (child.getName().Equals(SCOPE_CHAIN_MARKER))
							{
								currentArg = - 1;
								gettingScopeChain = true;
							}
							else if (currentArg >= 0)
							{
								// work around a compiler bug: If the variable's name is "undefined",
								// then change its name to "_argN", where "N" is the argument index,
								// e.g. _arg1, _arg2, etc.
								++currentArg;
								if (child.getName().Equals("undefined"))
								//$NON-NLS-1$
									child.setName("_arg" + currentArg); //$NON-NLS-1$
							}
							
							// All args and locals get added as "children" of
							// the frame; but scope chain entries do not.
							if (!gettingScopeChain)
								addVariableMember(frameId, child);
							
							// Everything gets added to the ordered list of
							// variables that came in.
							v.Add(child);
						}
					}
					
					// let's transfer our newly gained knowledge into the stack context
					if (depth == 0)
						populateRootNode(frame, v);
					else
						populateFrame(depth, v);
					
					break;
				}
				
				
				case DMessage.InOption: 
				{
                    String s = msg.getString();
                    String v = msg.getString();
					m_options[s] = v;
					break;
				}
				
				
				case DMessage.InGetVariable: 
				{
					// For InGetVariable the first element is the original entity we requested
					DValue parent = null;
					DVariable child = null;
					String definingClass = null;
					int level = 0;
					int highestLevelWithMembers = - 1;
					System.Collections.IList classes = new System.Collections.ArrayList();
					
					while (msg.Remaining > 0)
					{
                        long parentId = msg.getDWord();
						
						// build or get parent node
						if (parent == null)
						{
                            String name = msg.getString();
							
							// pull the contents of the node which normally are disposed of except if we did a 0,name call
							m_lastInGetVariable = extractVariable(msg, name);
							
							parent = getOrCreateValue(parentId);
						}
						else
						{
							// extract the child and add it to the parent.
							child = extractVariable(msg);
							if (showMember(child))
							{
								if (child.isAttributeSet(VariableAttribute.IS_DYNAMIC))
								{
									// Dynamic attributes always come in marked as a member of
									// class "Object"; but to the user, it makes more sense to
									// consider them as members of the topmost class.
									if (classes.Count > 0)
									{
										child.setDefiningClass(0, (String) classes[0]);
										highestLevelWithMembers = Math.Max(highestLevelWithMembers, 0);
									}
								}
								else
								{
									child.setDefiningClass(level, definingClass);
									if (definingClass != null)
									{
										highestLevelWithMembers = Math.Max(highestLevelWithMembers, level);
									}
								}
								addVariableMember(parent.Id, child);
							}
							else
							{
								if (isTraits(child))
								{
									definingClass = child.QualifiedName;
									level = classes.Count;
									
									// If the traits name end with "$", then it represents a class object --
									// in other words, the variables inside it are static variables of that
									// class.  In that case, we need to juggle the information.  For example,
									// if we are told that a variable is a member of "MyClass$", we actually
									// store it into the information for "MyClass".
									if (definingClass.EndsWith("$"))
									{
										//$NON-NLS-1$
										String classWithoutDollar = definingClass.Substring(0, (definingClass.Length - 1) - (0));
										int indexOfClass = classes.IndexOf(classWithoutDollar);
										if (indexOfClass != - 1)
										{
											level = indexOfClass;
											definingClass = classWithoutDollar;
										}
									}
									
									// It wasn't static -- so, add this class to the end of the list of classes
									if (level == classes.Count)
									{
										classes.Add(definingClass);
									}
								}
							}
						}
					}
					
					if (parent != null && parent.getClassHierarchy(true) == null)
					{
                        String[] classesArray = new String[classes.Count];
                        int index = 0;

                        foreach (String className in classes)
                        {
                            classesArray[index++] = className;
                        }

						parent.setClassHierarchy(classesArray, highestLevelWithMembers + 1);
					}
					
					break;
				}
				
				
				case DMessage.InWatch: 
				// for AS2; sends 16-bit ID field
				case DMessage.InWatch2:  // for AS3; sends 32-bit ID field
					{
						// This message is sent whenever a watchpoint is added
						// modified or removed.
						//
						// For an addition, flags will be non-zero and
						// success will be true.
						//
						// For a modification flags  will be non-zero.
						// and oldFlags will be non-zero and success
						// will be true.  Additionally oldFlags will not
						// be equal to flags.
						//
						// For a removal flags will be zero.  oldFlags
						// will be non-zero.
						//
						// flags identifies the type of watchpoint added,
						// see WatchKind.
						//
						// success indicates whether the operation was successful
						//
						// request.   It will be associated with the watchpoint.
                        int success = msg.getWord();
                        int oldFlags = msg.getWord();
                        int oldTag = msg.getWord();
                        int flags = msg.getWord();
                        int tag = msg.getWord();
						// for AS2, the ID came in above as a Word.  For AS3, the above value is
						// bogus, and it has been sent again as a DWord.
                        int id = (int)((type == DMessage.InWatch2) ? msg.getDWord() : msg.getWord());
                        String name = msg.getString();
						
						if (success != 0)
						{
							if (flags == 0)
							{
								removeWatchpoint(oldTag);
							}
							else
							{
								// modification or addition is the same to us
								// a new watch is created and added into the table
								// while any old entry if it exists is removed.
								removeWatchpoint(oldTag);
								DWatch w = new DWatch(id, name, flags, tag);
								addWatchpoint(w);
							}
						}
						break;
					}
				
				
				case DMessage.InGetSwf: 
				{
					// we only house the swf temporarily, PlayerSession then
					// pieces it back into swfinfo record.  Also, we don't
					// send any extra data in the message so that we need not
					// copy the bytes.
					m_swf = msg.Data;
					break;
				}
				
				
				case DMessage.InGetSwd: 
				{
					// we only house the swd temporarily, PlayerSession then
					// pieces it back into swfinfo record.
					m_swd = msg.Data;
					break;
				}
				
				
				case DMessage.InBreakReason: 
					{
						// the id map 1-1 with out SuspendReason interface constants
                        int suspendReason = msg.getWord();
                        int suspendPlayer = msg.getWord(); // item index of player
                        int breakOffset = (int)msg.getDWord(); // current script offset
                        int prevBreakOffset = (int)msg.getDWord(); // prev script offset
                        int nextBreakOffset = (int)msg.getDWord(); // next script offset
						m_suspendInfo = new DSuspendInfo(suspendReason, suspendPlayer, breakOffset, prevBreakOffset, nextBreakOffset);
						
						// augment the current frame with this information.  It
						// should work ok since we only get this message after a
						// InBreakAtExt message
						try
						{
							DStackContext c = getFrame(0);
							c.Offset = breakOffset;
							c.SwfIndex = suspendPlayer;
						}
						catch (Exception e)
						{
							if (Trace.error)
							{
								Trace.trace("Oh my god, gag me with a spoon...getFrame(0) call failed"); //$NON-NLS-1$
                                Console.Error.Write(e.StackTrace);
                                Console.Error.Flush();
                            }
						}
						break;
					}
					
					// obtain raw action script byte codes
				
				case DMessage.InGetActions: 
					{
                        int item = msg.getWord();
                        int rsvd = msg.getWord();
                        int at = (int)msg.getDWord();
                        int len = (int)msg.getDWord();
						int i = 0;
						
						m_actions = (len <= 0)?null:new byte[len];
						while (len-- > 0)
                            m_actions[i++] = (byte)msg.getByte();
						
						break;
					}
					
					// obtain data about a SWF
				
				case DMessage.InSwfInfo: 
					{
                        int count = msg.getWord();
						for (int i = 0; i < count; i++)
						{
                            long index = msg.getDWord();
                            long id = msg.getDWord();
							
							// get it
							DSwfInfo info = getOrCreateSwfInfo((int) index);
							
							// remember which was last seen
							m_lastSwfInfo = info;
							
							if (id != 0)
							{
                                bool debugComing = (msg.getByte() == 0) ? false : true;
                                byte vmVersion = (byte)msg.getByte(); // AS vm version number (1 = avm+, 0 == avm-)
                                int rsvd1 = msg.getWord();

                                long swfSize = msg.getDWord();
                                long swdSize = msg.getDWord();
                                long scriptCount = msg.getDWord();
                                long offsetCount = msg.getDWord();
                                long breakpointCount = msg.getDWord();

                                long port = msg.getDWord();
                                String path = msg.getString();
                                String url = msg.getString();
                                String host = msg.getString();
								
								// now we read in the swd debugging map (which provides
								// local to global mappings of the script ids
                                long num = msg.getDWord();
								IntMap local2global = new IntMap();
								int minId = Int32.MaxValue;
								int maxId = Int32.MinValue;
								for (int j = 0; j < num; j++)
								{
                                    long local = msg.getDWord();
                                    long global = msg.getDWord();
									local2global.put((int) local, (Int32) global);
									minId = ((int) global < minId)?(int) global:minId;
									maxId = ((int) global > maxId)?(int) global:maxId;
								}
								
								// If its a new record then the swf size would have been unknown at creation time
								bool justCreated = (info.SwfSize == 0);
								
								// if we are a avm+ engine then we don't wait for the swd to load
								if (vmVersion > 0)
								{
									debugComing = false;
									info.VmVersion = vmVersion;
									info.setPopulated(); // added by mmorearty on 9/5/05 for RSL debugging
								}
								
								// update this swfinfo with the lastest data
								info.freshen(id, path, url, host, port, debugComing, swfSize, swdSize, breakpointCount, offsetCount, scriptCount, local2global, minId, maxId);
								// now tie any scripts that have been loaded into this swfinfo object
								tieScriptsToSwf(info);
								
								// notify if its newly created
								if (justCreated)
									addEvent(new SwfLoadedEvent(id, (int) index, path, url, host, port, swfSize));
							}
							else
							{
								// note our state before marking it
								bool alreadyUnloaded = info.isUnloaded();
								
								// clear it out
								info.setUnloaded();
								
								// notify if this information is new.
								if (!alreadyUnloaded)
									addEvent(new SwfUnloadedEvent(info.Id, info.Path, (int) index));
							}
							//					System.out.println("[SWFLOAD] Loaded "+path+", size="+swfSize+", scripts="+scriptCount);
						}
						break;
					}
					
					// obtain the constant pool of some player
				
				case DMessage.InConstantPool: 
					{
                        int item = msg.getWord();
                        int count = (int)msg.getDWord();
						
						String[] pool = new String[count];
						for (int i = 0; i < count; i++)
						{
                            long id = msg.getDWord();
							DVariable var = extractVariable(msg);
							
							// we only need the contents of the variable
							pool[i] = var.getValue().ValueAsString;
						}
						m_lastConstantPool = pool;
						break;
					}
					
					// obtain one or more function name line number mappings.
				
				case DMessage.InGetFncNames: 
				{
                    long id = msg.getDWord(); // module id
                    long count = msg.getDWord(); // number of entries
					
					// get the DModule
					DModule m = getSource((int) id);
					if (m != null)
					{
						for (int i = 0; i < count; i++)
						{
                            int offset = (int)msg.getDWord();
                            int firstLine = (int)msg.getDWord();
                            int lastLine = (int)msg.getDWord();
                            String name = msg.getString();
							
							// now add the entries
							m.addLineFunctionInfo(offset, firstLine, lastLine, name);
						}
					}
					break;
				}
				
				
				default: 
				{
					break;
				}
				
			}
		}
Example #33
0
        /// <summary>
        /// Generates a Summary Table Outlining the Provider Charges and Revenues
        /// Illustrating Unearned Income
        /// use MinDate and MaxDate to flag all dates
        /// </summary>
        public static DataTable GenerateSummaryTable(int Guarantor, DateTime dtFrom, DateTime dtTo)
        {
            DataTable rValReturnTable   = null;
            DataTable dtProviderBalance = Db.GetTableOld(ProviderRevenueByGuarantor(Guarantor, dtFrom, dtTo));
            DataTable dtProvAbbr        = Db.GetTableOld("SELECT ProvNum, Abbr FROM Provider");

            if (dtProviderBalance != null && dtProviderBalance.Rows.Count != 0)
            {
                // Get Provider Abbreviations
                System.Collections.Hashtable htAllProvs = new System.Collections.Hashtable();
                for (int i = 0; i < dtProvAbbr.Rows.Count; i++)
                {
                    if (!htAllProvs.ContainsKey(dtProvAbbr.Rows[i][0].ToString()))
                    {
                        htAllProvs[dtProvAbbr.Rows[i][0].ToString()] = dtProvAbbr.Rows[i][1].ToString();
                    }
                }
                if (!htAllProvs.ContainsKey("0"))
                {
                    htAllProvs["0"] = "Unearned";
                }
                // First establish a list of providers
                System.Collections.ArrayList alProvs = new System.Collections.ArrayList();
                for (int i = 0; i < dtProviderBalance.Rows.Count; i++)
                {
                    if (!alProvs.Contains(dtProviderBalance.Rows[i][0].ToString()))
                    {
                        alProvs.Add(dtProviderBalance.Rows[i][0].ToString());
                    }
                }

                // Fill and Create DataTable
                DataTable dtBalancesTable = new DataTable();
                dtBalancesTable.Columns.Add(new DataColumn("Provider", typeof(string)));
                dtBalancesTable.Columns.Add(new DataColumn("Charges", typeof(string)));
                dtBalancesTable.Columns.Add(new DataColumn("Adjustments", typeof(string)));
                dtBalancesTable.Columns.Add(new DataColumn("Revenue", typeof(string)));
                dtBalancesTable.Columns.Add(new DataColumn("Balance", typeof(string)));
                DataRow drWorkingRow = null;
                int     ColumnIndex  = -1;

                try
                {
                    System.Collections.Hashtable htAllProvs_Indexes = new System.Collections.Hashtable();
                    for (int i = 0; i < alProvs.Count; i++)                     // For Each Provider add a Row in the Balances Table
                    {
                        dtBalancesTable.Rows.Add(dtBalancesTable.NewRow());
                        dtBalancesTable.Rows[i][0] = alProvs[i].ToString();
                    }

                    for (int i = 0; i < dtProviderBalance.Rows.Count; i++)
                    {
                        drWorkingRow    = dtBalancesTable.Rows[alProvs.IndexOf(dtProviderBalance.Rows[i][0].ToString())];
                        drWorkingRow[0] = htAllProvs[dtProviderBalance.Rows[i][0].ToString()].ToString();                         // the abbreviation

                        // Which Column of the Row to add the number to?  Find the column
                        // stated in the query's column 2
                        string ColumnName_FromQuery = dtProviderBalance.Rows[i][2].ToString();
                        ColumnIndex = dtBalancesTable.Columns.IndexOf(ColumnName_FromQuery);
                        if (ColumnIndex > 0)
                        {
                            drWorkingRow[ColumnIndex] = dtProviderBalance.Rows[i][1].ToString();                             // note is not cast as number so numeric specifies cannot apply //ToString("F2");
                        }
                        else
                        {
                            drWorkingRow[4] = "ERROR!";
                        }


                        ColumnIndex = -1;
                    }
                    decimal[] Totals = new decimal[4];
                    // Fill in Null and Empty Entries
                    for (int j = 0; j < dtBalancesTable.Rows.Count; j++)
                    {
                        for (int k = 1; k < dtBalancesTable.Columns.Count; k++)
                        {
                            if (dtBalancesTable.Rows[j][k] == null || dtBalancesTable.Rows[j][k].ToString().Trim() == "")
                            {
                                dtBalancesTable.Rows[j][k] = "0.00";
                            }
                            if (k == dtBalancesTable.Columns.Count - 1)
                            {
                                decimal Balance = decimal.Parse(dtBalancesTable.Rows[j][1].ToString())
                                                  + decimal.Parse(dtBalancesTable.Rows[j][2].ToString())
                                                  + decimal.Parse(dtBalancesTable.Rows[j][3].ToString());
                                dtBalancesTable.Rows[j][4] = Balance.ToString("F2");
                            }
                            // Add to the Totals to be placed at the bottom of the Table
                            Totals[k - 1] += decimal.Parse(dtBalancesTable.Rows[j][k].ToString());
                            // Format the Numbers Better
                            dtBalancesTable.Rows[j][k] = decimal.Parse(dtBalancesTable.Rows[j][k].ToString()).ToString("F2");
                        }
                    }
                    DataRow TotalRow = dtBalancesTable.NewRow();
                    TotalRow[0] = "Totals-->";
                    for (int i = 1; i < dtBalancesTable.Columns.Count; i++)
                    {
                        TotalRow[i] = Totals[i - 1].ToString("F2");
                    }
                    dtBalancesTable.Rows.Add(TotalRow);
                }
                catch
                {
                }
                rValReturnTable = dtBalancesTable;                  // Set this first becuase SummaryTable_as_Strings() will check for _SummaryTable != null
                //	_SummaryTableHeader = SummaryTable_as_Strings();
            }
            return(rValReturnTable);
        }
Example #34
0
 public int IndexOf(object value)
 {
     return(_innerList.IndexOf(value));
 }
Example #35
0
        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;
        }
Example #36
0
 ///<summary>
 ///Searches for the specified base_scope and returns the zero-based index of the first occurrence within the entire base_scopeArrayList.
 ///</summary>
 ///<param name="value">The base_scope to locate in the base_scopeArrayList. The value can be a null reference.<param>
 ///<returns>The zero-based index of the first occurrence of value within the entire base_scopeArrayList, if found; otherwise, -1.</returns>
 public int IndexOf(base_scope value)
 {
     return(arr.IndexOf(value));
 }
 /// <summary>
 /// Return the zero-based index of the first occurrence of a specific value
 /// in this ActivityCollection
 /// </summary>
 /// <param name="value">
 /// The IActivity value to locate in the ActivityCollection.
 /// </param>
 /// <returns>
 /// The zero-based index of the first occurrence of the _ELEMENT value if found;
 /// -1 otherwise.
 /// </returns>
 public virtual int IndexOf(IActivity value)
 {
     return(mList.IndexOf(value));
 }