Exemple #1
0
        public static TransactionStatus clientLogon(Client aClient)
        {
            //    ServerSession.ClearSessionBusiness(HttpContext.Current.Session);
            TransactionStatus vTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session);
            //    try
            //    {
            //        ServerSession.Logon(HttpContext.Current.Session, aClient);
            //        vTransactionStatus.TransactionResult = TransactionResult.OK;
            //        vTransactionStatus.Message = "Login succesful";
            //        vTransactionStatus.TargetUrl = "/fandashboard.aspx";
            //        ServerSession.SetTransactionStatus(HttpContext.Current.Session, vTransactionStatus);
            //    }
            //    catch (TransactionStatusException tx)
            //    {

            //        vTransactionStatus.AssignFromSource(tx.TransactionStatus);
            //        return vTransactionStatus;
            //    }
            //    catch (Exception ex)
            //    {
            //        vTransactionStatus.TransactionResult = TransactionResult.GeneralException;
            //        vTransactionStatus.Message = "Login Unsuccesful - please check your username and password are correct" + ex.Message;
            //        vTransactionStatus.InnerMessage = ex.InnerException == null ? String.Empty : ex.InnerException.Message;
            //        return vTransactionStatus;
            //    }

            return vTransactionStatus;
        }
Exemple #2
0
        public static TransactionStatus clientRegister(Client aClient)
        {
            ServerSession.ClearSessionBusiness(HttpContext.Current.Session);
            TransactionStatus vTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session);
            try
            {
                UserToken aUserToken = new UserToken();
                aUserToken.UserID = "Register";
                aUserToken.Password = "******";
                aUserToken.Url = "http://localhost/z2zsoap/Z2ZService.asmx";
                aClient.ClnName = "fanatic";
                UserServiceConsumer.AddClient(aUserToken, aClient);
                vTransactionStatus.TransactionResult = TransactionResult.OK;
                vTransactionStatus.Message = "You have been succesfully registered!";
                vTransactionStatus.TargetUrl = "/clientdashboard.aspx";
                ServerSession.SetTransactionStatus(HttpContext.Current.Session, vTransactionStatus);
            }
            catch (TransactionStatusException tx)
            {
                vTransactionStatus.AssignFromSource(tx.TransactionStatus);
                return vTransactionStatus;
            }
            catch (Exception ex)
            {
                vTransactionStatus.TransactionResult = TransactionResult.GeneralException;
                vTransactionStatus.Message = ex.Message;
                vTransactionStatus.InnerMessage = ex.InnerException == null ? String.Empty : ex.InnerException.Message;
                return vTransactionStatus;
            }

            return vTransactionStatus;
        }
Exemple #3
0
 /// <summary>
 ///   Insert a <see cref="Client"/> passed as an argument via Stored Procedure that returns the newly inserted Client Key 
 /// </summary>
 /// <param name="aClient">A <see cref="Client"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aClient</c> argument is <c>null</c>.</exception>
 public static void Insert(Client aClient)
 {
     if (aClient == null)
     {
         throw new ArgumentNullException("aClient");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("insert into CLN_Client");
         vStringBuilder.AppendLine("       (CLN_Password, CLN_Name, CLN_Email,");
         vStringBuilder.AppendLine("        CLN_Contact, CLN_Avatar)");
         vStringBuilder.AppendLine("values");
         vStringBuilder.AppendLine("       (@CLNPassword, @CLNName, @CLNEmail,");
         vStringBuilder.AppendLine("        @CLNContact, @CLNAvatar)");
         vStringBuilder.AppendLine(";");
         vStringBuilder.AppendLine("select SCOPE_IDENTITY()");
         ObjectToData(vSqlCommand, aClient);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         aClient.ClnKey = Convert.ToInt32(vSqlCommand.ExecuteScalar());
         vSqlCommand.Connection.Close();
     }
 }
 /// <summary>
 ///   The <c>AddClient</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="Client"/> object.
 ///   It invokes the <c>Insert</c> method of <see cref="ClientBusiness"/> with the newly deserialized <see cref="Client"/> object.
 ///   Finally, it returns the inserted object (now with an assigned Client Key) as a serialized <see cref="string"/> of XML.
 /// </summary>
 /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
 /// <returns><see cref="Client"/> as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string AddClient(UserKey aUserKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of AddClient");
     }
     Client vClient = new Client();
     vClient = XmlUtils.Deserialize<Client>(aXmlArgument);
     ClientBusiness.Insert(aUserKey, vClient);
     return XmlUtils.Serialize<Client>(vClient, true);
 }
Exemple #5
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="Client"/> object.
 /// </summary>
 /// <param name="aClient">A <see cref="Client"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(Client aClient, SqlDataReader aSqlDataReader, bool aIncludeAvatar)
 {
     aClient.ClnKey = Convert.ToInt32(aSqlDataReader["CLN_Key"]);
     aClient.ClnPassword = Convert.ToString(aSqlDataReader["CLN_Password"]);
     aClient.ClnName = Convert.ToString(aSqlDataReader["CLN_Name"]);
     aClient.ClnEmail = Convert.ToString(aSqlDataReader["CLN_Email"]);
     if (aIncludeAvatar)
     {
         aClient.ClnAvatar = CommonUtils.DbValueTo<byte[]>(aSqlDataReader["CLN_Avatar"], null);
     }
 }
Exemple #6
0
        /// <summary>
        ///   The overloaded Load method that will return a specific <see cref="Client"/> object, with keys in <c>aClient</c>.
        /// </summary>
        /// <param name="aUserKey">A <see cref="UserKey"/> object.</param>
        /// <param name="aClient">A <see cref="Client"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aClient</c> is <c>null</c>.</exception>
        public static void Load(UserKey aUserKey, Client aClient)
        {
            if (aClient == null)
            {
                throw new ArgumentNullException("Load Client Business");
            }

            if (!UserFunctionAccessData.HasModeAccess(aUserKey, "Client", AccessMode.Read))
            {
                throw new ZpAccessException("Access Denied", String.Format("{0}", aUserKey.UsrKey), AccessMode.Read, "Client");
            }

            ClientData.Load(aClient);
        }
Exemple #7
0
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="ProviderCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is ClientCollection))
            {
                throw new ArgumentException("Invalid assignment source", "ClientCollection");
            }

            _clientFilter.AssignFromSource((aSource as ClientCollection)._clientFilter);
            _clientList.Clear();
            (aSource as ClientCollection)._clientList.ForEach(vClientSource =>
            {
                Client vClientTarget = new Client();
                vClientTarget.AssignFromSource(vClientSource);
                _clientList.Add(vClientTarget);
            });
        }
Exemple #8
0
 /// <summary>
 ///   Delete a <see cref="Client"/> object passed as an argument.
 /// </summary>
 /// <param name="aClient">The <see cref="Client"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aClient</c> argument is <c>null</c>.</exception>
 public static void Delete(Client aClient)
 {
     if (aClient == null)
     {
         throw new ArgumentNullException("aClient");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete CLN_Client");
         vStringBuilder.AppendLine("where  CLN_Key = @CLNKey");
         vSqlCommand.Parameters.AddWithValue("@CLNKey", aClient.ClnKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
 /// <summary>
 ///   Gets a specified <see cref="Client"/> by key.
 /// </summary>
 /// <param name="aUserToken">A <see cref="UserToken"/> object used for Access Control.</param>
 /// <param name="aClient"><see cref="Client"/> object.</param>
 public static void GetClient(UserToken aUserToken, Client aClient)
 {
     UserCallHandler.ServiceCall<Client>(aUserToken, "GetClient", aClient);
 }
Exemple #10
0
 /// <summary>
 ///   Update a <see cref="Client"/> passed as an argument .
 /// </summary>
 /// <param name="aClient">A <see cref="Client"/>.</param>
 public static void Update(Client aClient)
 {
     if (aClient == null)
     {
         throw new ArgumentNullException("aClient");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update CLN_Client");
         vStringBuilder.AppendLine("set    CLN_Password = @CLNPassword,");
         vStringBuilder.AppendLine("       CLN_Name = @CLNName,");
         vStringBuilder.AppendLine("       CLN_Email = @CLNEmail,");
         vStringBuilder.AppendLine("       CLN_Contact = @CLNContact,");
         vStringBuilder.AppendLine("       CLN_Avatar = @CLNAvatar");
         vStringBuilder.AppendLine("where  CLN_Key = @CLNKey");
         ObjectToData(vSqlCommand, aClient);
         vSqlCommand.Parameters.AddWithValue("@CLNKey", aClient.ClnKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemple #11
0
        /// <summary>
        ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="Client"/>.
        /// </summary>
        /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
        /// <param name="aClient">A <see cref="Client"/> argument.</param>
        public static void ObjectToData(SqlCommand aSqlCommand, Client aClient)
        {
            aSqlCommand.Parameters.AddWithValue("@CLNPassword", aClient.ClnPassword);
            aSqlCommand.Parameters.AddWithValue("@CLNName", aClient.ClnName);
            aSqlCommand.Parameters.AddWithValue("@CLNEmail", aClient.ClnEmail);
            aSqlCommand.Parameters.AddWithValue("@CLNContact", aClient.ClnContact);

            if (aClient.ClnAvatar == null)
            {
                aSqlCommand.Parameters.Add("@CLNAvatar", SqlDbType.Image).Value = DBNull.Value;
            }
            else
            {
                aSqlCommand.Parameters.AddWithValue("@CLNAvatar", aClient.ClnAvatar);
            }
        }
Exemple #12
0
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="Client"/>, with keys in the <c>aClient</c> argument.
 /// </summary>
 /// <param name="aClient">A <see cref="Client"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aClient</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(Client aClient)
 {
     if (aClient == null)
     {
         throw new ArgumentNullException("aClient");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL(true);
         vStringBuilder.AppendLine("where t1.CLN_Key = @CLNKey");
         vSqlCommand.Parameters.AddWithValue("@CLNKey", aClient.ClnKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!vSqlDataReader.HasRows)
             {
                 throw new Exception(String.Format("Expected Client not found: CLN_Key = {0}", aClient.ClnKey));
             }
             vSqlDataReader.Read();
             DataToObject(aClient, vSqlDataReader, true);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemple #13
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>ClientList</c> property a <see cref="ClientCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="Client"/>, filtered by the filter properties of the passed <see cref="ClientCollection"/>.
 /// </summary>
 /// <param name="aClientCollection">The <see cref="ClientCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="ClientCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aClientCollection</c> argument is <c>null</c>.</exception>
 public static void Load(ClientCollection aClientCollection)
 {
     if (aClientCollection == null)
     {
         throw new ArgumentNullException("aClientCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL(false);
         vStringBuilder.AppendLine("order by t1.CLN_Name");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vClient = new Client();
                 DataToObject(vClient, vSqlDataReader, false);
                 aClientCollection.ClientList.Add(vClient);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }