Пример #1
0
        private ActivationItem GetModelFromReader(SqlDataReader reader)
        {
            ActivationItem result = new ActivationItem();
            int            index  = reader.GetOrdinal("admin");

            result.Admin = reader.GetString(index);

            index           = reader.GetOrdinal("userName");
            result.UserName = reader.GetString(index);

            index      = reader.GetOrdinal("MNC");
            result.MNC = reader.IsDBNull(index) ? string.Empty : reader.GetString(index);

            index        = reader.GetOrdinal("phone");
            result.Phone = reader.IsDBNull(index) ? string.Empty : reader.GetString(index);

            index        = reader.GetOrdinal("email");
            result.Email = reader.IsDBNull(index) ? string.Empty : reader.GetString(index);

            index           = reader.GetOrdinal("clientId");
            result.ClientId = reader.IsDBNull(index) ? string.Empty : reader.GetString(index);

            index           = reader.GetOrdinal("lastName");
            result.LastName = reader.IsDBNull(index) ? string.Empty : reader.GetString(index);

            index            = reader.GetOrdinal("firstName");
            result.FirstName = reader.IsDBNull(index) ? string.Empty : reader.GetString(index);

            index           = reader.GetOrdinal("address1");
            result.Address1 = reader.IsDBNull(index) ? string.Empty : reader.GetString(index);

            index           = reader.GetOrdinal("address2");
            result.Address2 = reader.IsDBNull(index) ? string.Empty : reader.GetString(index);

            index       = reader.GetOrdinal("city");
            result.City = reader.IsDBNull(index) ? string.Empty : reader.GetString(index);

            index        = reader.GetOrdinal("state");
            result.State = reader.IsDBNull(index) ? string.Empty : reader.GetString(index);

            index          = reader.GetOrdinal("country");
            result.Country = reader.IsDBNull(index) ? string.Empty : reader.GetString(index);

            index      = reader.GetOrdinal("zip");
            result.Zip = reader.IsDBNull(index) ? string.Empty : reader.GetString(index);

            index          = reader.GetOrdinal("created");
            result.Created = reader.IsDBNull(index) ? DateTime.MinValue : reader.GetDateTime(index);

            index           = reader.GetOrdinal("modified");
            result.Modified = reader.IsDBNull(index) ? DateTime.MinValue : reader.GetDateTime(index);

            index = reader.GetOrdinal("lateActivated");
            result.lateActivated = reader.IsDBNull(index) ? 0 : reader.GetInt16(index);

            index         = reader.GetOrdinal("idHash");
            result.IDHash = reader.IsDBNull(index) ? string.Empty : reader.GetString(index);

            return(result);
        }
Пример #2
0
        public ActivationItem GetActivationItem(string accountNo)
        {
            ActivationItem result = null;

            SqlConnection conn   = null;
            SqlDataReader reader = null;

            try
            {
                conn = Connect();
                SqlCommand cmd = new SqlCommand("knsp_activation_Get", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.Add("@admin", System.Data.SqlDbType.VarChar, 64);
                cmd.Parameters["@admin"].Value = accountNo;

                reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        result = GetModelFromReader(reader);
                    }
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                //  Logger.Instance.Error(this, "GetActivationItem", ex);
            }
            finally
            {
                Disconnect(conn);
            }
            return(result);;
        }
Пример #3
0
        public bool AddUserProfileActivationTemp(ActivationItem item)
        {
            SqlConnection con     = null;
            SqlCommand    com     = null;
            bool          _result = false;

            try
            {
                con             = Connect();
                com             = new SqlCommand("knsp_activation_temp_insert", con);
                com.CommandType = System.Data.CommandType.StoredProcedure;

                com.Parameters.Add("@admin", System.Data.SqlDbType.VarChar, 64);
                com.Parameters["@admin"].Value = item.Admin;
                com.Parameters.Add("@userName", System.Data.SqlDbType.VarChar, 64);
                com.Parameters["@userName"].Value = item.UserName;
                com.Parameters.Add("@clientId", System.Data.SqlDbType.VarChar, 64);
                com.Parameters["@clientId"].Value = item.ClientId;
                com.Parameters.Add("@MNC", System.Data.SqlDbType.VarChar, 40);
                com.Parameters["@MNC"].Value = item.MNC;
                com.Parameters.Add("@phone", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@phone"].Value = item.Phone;
                com.Parameters.Add("@email", System.Data.SqlDbType.VarChar, 255);
                com.Parameters["@email"].Value = item.Email;
                com.Parameters.Add("@lastName", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@lastName"].Value = item.LastName;
                com.Parameters.Add("@firstName", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@firstName"].Value = item.FirstName;
                com.Parameters.Add("@address1", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@address1"].Value = item.Address1;
                com.Parameters.Add("@address2", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@address2"].Value = item.Address2;
                com.Parameters.Add("@address3", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@address3"].Value = item.Address3 ?? string.Empty;
                com.Parameters.Add("@city", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@city"].Value = item.City;
                com.Parameters.Add("@state", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@state"].Value = item.State;
                com.Parameters.Add("@country", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@country"].Value = item.Country;
                com.Parameters.Add("@zip", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@zip"].Value = item.Zip;

                if (!string.IsNullOrEmpty(item.IDNumber))
                {
                    com.Parameters.Add("@idHash", System.Data.SqlDbType.VarChar, 64);
                    com.Parameters["@idHash"].Value = Crypto.SHA256Hash(item.IDNumber);
                }

                if (!string.IsNullOrEmpty(item.IDHash))
                {
                    com.Parameters.Add("@idHash", System.Data.SqlDbType.VarChar, 64);
                    com.Parameters["@idHash"].Value = item.IDHash;
                }

                com.ExecuteNonQuery();

                _result = true;
            }
            catch (Exception ex)
            {
                //   Logger.Instance.Error(this, "AddUserProfileActivationTemp", ex);
            }
            finally
            {
                Disconnect(con);
            }
            return(_result);
        }
Пример #4
0
        public bool AddUserProfileToDB(ActivationItem item, bool isWebCard)
        {
            if (item.ClientId.Equals("smmorder"))
            {
                return(true);
            }
            SqlConnection con     = null;
            SqlCommand    com     = null;
            bool          _result = false;

            try
            {
                con             = Connect();
                com             = new SqlCommand("knsp_activation_Add", con);
                com.CommandType = System.Data.CommandType.StoredProcedure;

                com.Parameters.Add("@admin", System.Data.SqlDbType.VarChar, 64);
                com.Parameters["@admin"].Value = item.Admin;
                com.Parameters.Add("@userName", System.Data.SqlDbType.VarChar, 64);
                com.Parameters["@userName"].Value = item.UserName;
                com.Parameters.Add("@MNC", System.Data.SqlDbType.VarChar, 40);
                com.Parameters["@MNC"].Value = item.MNC;
                com.Parameters.Add("@phone", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@phone"].Value = item.Phone;
                com.Parameters.Add("@email", System.Data.SqlDbType.VarChar, 255);
                com.Parameters["@email"].Value = item.Email;
                com.Parameters.Add("@clientId", System.Data.SqlDbType.VarChar, 64);
                com.Parameters["@clientId"].Value = item.ClientId;
                com.Parameters.Add("@lastName", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@lastName"].Value = item.LastName;
                com.Parameters.Add("@firstName", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@firstName"].Value = item.FirstName;
                com.Parameters.Add("@address1", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@address1"].Value = item.Address1;
                com.Parameters.Add("@address2", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@address2"].Value = item.Address2;
                com.Parameters.Add("@address3", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@address3"].Value = item.Address3 ?? string.Empty;
                com.Parameters.Add("@city", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@city"].Value = item.City;
                com.Parameters.Add("@state", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@state"].Value = item.State;
                com.Parameters.Add("@country", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@country"].Value = item.Country;
                com.Parameters.Add("@zip", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@zip"].Value = item.Zip;
                com.Parameters.Add("@title", System.Data.SqlDbType.NVarChar, 255);
                com.Parameters["@title"].Value = item.Title;
                com.Parameters.AddWithValue("@last4", item.Last4);
                com.Parameters.AddWithValue("@enPassword", item.Password);

                if (!string.IsNullOrEmpty(item.IDNumber))
                {
                    com.Parameters.Add("@idHash", System.Data.SqlDbType.VarChar, 64);
                    com.Parameters["@idHash"].Value = Crypto.SHA256Hash(item.IDNumber);
                }

                if (!string.IsNullOrEmpty(item.IDHash))
                {
                    com.Parameters.Add("@idHash", System.Data.SqlDbType.VarChar, 64);
                    com.Parameters["@idHash"].Value = item.IDHash;
                }

                if (item.lateActivated != 0)
                {
                    com.Parameters.Add("@lateActivated", System.Data.SqlDbType.SmallInt);
                    com.Parameters["@lateActivated"].Value = item.lateActivated;
                }

                if (!string.IsNullOrEmpty(item.DeviceId))
                {
                    com.Parameters.Add("@deviceId", System.Data.SqlDbType.VarChar, 255);
                    com.Parameters["@deviceId"].Value = item.DeviceId;
                }

                if (!string.IsNullOrEmpty(item.SubscriberId))
                {
                    com.Parameters.Add("@subscriberId", System.Data.SqlDbType.VarChar, 255);
                    com.Parameters["@subscriberId"].Value = item.SubscriberId;
                }
                com.ExecuteNonQuery();

                _result = true;

                if (!isWebCard)
                {
                    if (!AddtoActivationCode(item.Admin, string.Empty, 1))
                    {
                        //  Logger.Instance.Error(this, string.Format("AddUserProfileToDB AddtoActivationCode failed admin:{0} refcode:{1} type:{2}", item.Admin, string.Empty, 1));
                    }
                }
            }
            catch (Exception ex)
            {
                // Logger.Instance.Error(this, "AddUserProfileToDB", ex);
            }
            finally
            {
                Disconnect(con);
            }
            return(_result);
        }