Beispiel #1
0
        public eTrikeCategory GetDataPolicy(int id)
        {
            Polices polices = new Polices();

            using (GetCon())
            {
                SqlCommand cmd = new SqlCommand("usp_Get_eTrike_Policies", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Id", id);

                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    polices.IdCategory   = id;
                    polices.CategoryName = rdr["data"].ToString();
                }
                con.Close();
            }
            return(polices);
        }
        public override byte[] Serialize()
        {
            List <byte> s = new List <byte>();

            // serialize Width
            s.Add((byte)((Width == null) ? 0 : 1));
            if (Width != null)
            {
                s.AddRange(BitConverter.GetBytes((int)Width));
            }

            // serialize Height
            s.Add((byte)((Height == null) ? 0 : 1));
            if (Height != null)
            {
                s.AddRange(BitConverter.GetBytes((int)Height));
            }

            // serialize Board
            s.Add((byte)((Board == null) ? 0 : 1));
            if (Board != null)
            {
                List <byte> tmp73 = new List <byte>();
                tmp73.AddRange(BitConverter.GetBytes((uint)Board.Count()));
                while (tmp73.Count > 0 && tmp73.Last() == 0)
                {
                    tmp73.RemoveAt(tmp73.Count - 1);
                }
                s.Add((byte)tmp73.Count);
                s.AddRange(tmp73);

                foreach (var tmp74 in Board)
                {
                    s.Add((byte)((tmp74 == null) ? 0 : 1));
                    if (tmp74 != null)
                    {
                        List <byte> tmp75 = new List <byte>();
                        tmp75.AddRange(BitConverter.GetBytes((uint)tmp74.Count()));
                        while (tmp75.Count > 0 && tmp75.Last() == 0)
                        {
                            tmp75.RemoveAt(tmp75.Count - 1);
                        }
                        s.Add((byte)tmp75.Count);
                        s.AddRange(tmp75);

                        foreach (var tmp76 in tmp74)
                        {
                            s.Add((byte)((tmp76 == null) ? 0 : 1));
                            if (tmp76 != null)
                            {
                                s.Add((byte)((sbyte)tmp76));
                            }
                        }
                    }
                }
            }

            // serialize Scores
            s.Add((byte)((Scores == null) ? 0 : 1));
            if (Scores != null)
            {
                List <byte> tmp77 = new List <byte>();
                tmp77.AddRange(BitConverter.GetBytes((uint)Scores.Count()));
                while (tmp77.Count > 0 && tmp77.Last() == 0)
                {
                    tmp77.RemoveAt(tmp77.Count - 1);
                }
                s.Add((byte)tmp77.Count);
                s.AddRange(tmp77);

                foreach (var tmp78 in Scores)
                {
                    s.Add((byte)((tmp78.Key == null) ? 0 : 1));
                    if (tmp78.Key != null)
                    {
                        List <byte> tmp79 = new List <byte>();
                        tmp79.AddRange(BitConverter.GetBytes((uint)tmp78.Key.Count()));
                        while (tmp79.Count > 0 && tmp79.Last() == 0)
                        {
                            tmp79.RemoveAt(tmp79.Count - 1);
                        }
                        s.Add((byte)tmp79.Count);
                        s.AddRange(tmp79);

                        s.AddRange(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(tmp78.Key));
                    }

                    s.Add((byte)((tmp78.Value == null) ? 0 : 1));
                    if (tmp78.Value != null)
                    {
                        s.AddRange(BitConverter.GetBytes((float)tmp78.Value));
                    }
                }
            }

            // serialize Bombs
            s.Add((byte)((Bombs == null) ? 0 : 1));
            if (Bombs != null)
            {
                List <byte> tmp80 = new List <byte>();
                tmp80.AddRange(BitConverter.GetBytes((uint)Bombs.Count()));
                while (tmp80.Count > 0 && tmp80.Last() == 0)
                {
                    tmp80.RemoveAt(tmp80.Count - 1);
                }
                s.Add((byte)tmp80.Count);
                s.AddRange(tmp80);

                foreach (var tmp81 in Bombs)
                {
                    s.Add((byte)((tmp81 == null) ? 0 : 1));
                    if (tmp81 != null)
                    {
                        s.AddRange(tmp81.Serialize());
                    }
                }
            }

            // serialize Terrorists
            s.Add((byte)((Terrorists == null) ? 0 : 1));
            if (Terrorists != null)
            {
                List <byte> tmp82 = new List <byte>();
                tmp82.AddRange(BitConverter.GetBytes((uint)Terrorists.Count()));
                while (tmp82.Count > 0 && tmp82.Last() == 0)
                {
                    tmp82.RemoveAt(tmp82.Count - 1);
                }
                s.Add((byte)tmp82.Count);
                s.AddRange(tmp82);

                foreach (var tmp83 in Terrorists)
                {
                    s.Add((byte)((tmp83 == null) ? 0 : 1));
                    if (tmp83 != null)
                    {
                        s.AddRange(tmp83.Serialize());
                    }
                }
            }

            // serialize Polices
            s.Add((byte)((Polices == null) ? 0 : 1));
            if (Polices != null)
            {
                List <byte> tmp84 = new List <byte>();
                tmp84.AddRange(BitConverter.GetBytes((uint)Polices.Count()));
                while (tmp84.Count > 0 && tmp84.Last() == 0)
                {
                    tmp84.RemoveAt(tmp84.Count - 1);
                }
                s.Add((byte)tmp84.Count);
                s.AddRange(tmp84);

                foreach (var tmp85 in Polices)
                {
                    s.Add((byte)((tmp85 == null) ? 0 : 1));
                    if (tmp85 != null)
                    {
                        s.AddRange(tmp85.Serialize());
                    }
                }
            }

            // serialize Constants
            s.Add((byte)((Constants == null) ? 0 : 1));
            if (Constants != null)
            {
                s.AddRange(Constants.Serialize());
            }

            return(s.ToArray());
        }