Esempio n. 1
0
        public static webObject deleteCell(Cell aCell)
        {
            FanToken vFanToken = ServerSession.GetFanToken(HttpContext.Current.Session);
            ServerSession.ClearSessionBusiness(HttpContext.Current.Session);
            webObject vWebObject = new webObject();
            vWebObject.aTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session);

            try
            {
                FanServiceConsumer.DeleteCell(vFanToken, aCell);
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.OK;
                vWebObject.aTransactionStatus.Message = "Cell Deleted";
                ServerSession.SetTransactionStatus(HttpContext.Current.Session, vWebObject.aTransactionStatus);
                vWebObject.AnObject = aCell;
            }
            catch (TransactionStatusException tx)
            {

                vWebObject.aTransactionStatus.AssignFromSource(tx.TransactionStatus);
                return vWebObject;
            }
            catch (Exception ex)
            {
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.GeneralException;
                vWebObject.aTransactionStatus.Message = "Deletion of Cell unsuccesful" + ex.Message;
                vWebObject.aTransactionStatus.InnerMessage = ex.InnerException == null ? String.Empty : ex.InnerException.Message;
                return vWebObject;
            }
            return vWebObject;
        }
Esempio n. 2
0
 /// <summary>
 ///   Insert a <see cref="Cell"/> passed as an argument via Stored Procedure that returns the newly inserted Cell Key 
 /// </summary>
 /// <param name="aCell">A <see cref="Cell"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aCell</c> argument is <c>null</c>.</exception>
 public static void Insert(Cell aCell)
 {
     if (aCell == null)
     {
         throw new ArgumentNullException("aCell");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("insert into CEL_Cell");
         vStringBuilder.AppendLine("       (CEL_Name, FAN_Key,");
         vStringBuilder.AppendLine("        CEL_Avatar)");
         vStringBuilder.AppendLine("values");
         vStringBuilder.AppendLine("       (@CELName, @FANKey,");
         vStringBuilder.AppendLine("        @CELAvatar)");
         vStringBuilder.AppendLine(";");
         vStringBuilder.AppendLine("select SCOPE_IDENTITY()");
         ObjectToData(vSqlCommand, aCell);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         aCell.CelKey = Convert.ToInt32(vSqlCommand.ExecuteScalar());
         vSqlCommand.Connection.Close();
     }
 }
Esempio n. 3
0
 /// <summary>
 ///   The <c>AddCell</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="Cell"/> object.
 ///   It invokes the <c>Insert</c> method of <see cref="CellBusiness"/> with the newly deserialized <see cref="Cell"/> object.
 ///   Finally, it returns the inserted object (now with an assigned Cell Key) as a serialized <see cref="string"/> of XML.
 /// </summary>
 /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
 /// <returns><see cref="Cell"/> as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string AddCell(FanKey aFanKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of AddCell");
     }
     Cell vCell = new Cell();
     vCell = XmlUtils.Deserialize<Cell>(aXmlArgument);
     CellBusiness.Insert(aFanKey, vCell);
     return XmlUtils.Serialize<Cell>(vCell, true);
 }
Esempio n. 4
0
        /// <summary>
        ///   Load a <see cref="SqlDataReader"/> into a <see cref="Cell"/> object.
        /// </summary>
        /// <param name="aCell">A <see cref="Cell"/> argument.</param>
        /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
        public static void DataToObject(Cell aCell, SqlDataReader aSqlDataReader, bool aIncludeAvatar)
        {
            aCell.CelKey = Convert.ToInt32(aSqlDataReader["CEL_Key"]);
            aCell.CellName = Convert.ToString(aSqlDataReader["CEL_Name"]);
            aCell.FanKey = Convert.ToInt32(aSqlDataReader["FAN_Key"]);
            aCell.FanName = Convert.ToString(aSqlDataReader["CellOwner"]);

            if (aIncludeAvatar)
            {
                aCell.CellAvatar = CommonUtils.DbValueTo<byte[]>(aSqlDataReader["CEL_Avatar"], null);
            }
        }
Esempio n. 5
0
        /// <summary>
        ///   The overloaded Load method that will return a specific <see cref="Cell"/> object, with keys in <c>aCell</c>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aCell">A <see cref="Cell"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aCell</c> is <c>null</c>.</exception>
        public static void Load(FanKey aFanKey, Cell aCell)
        {
            if (aCell == null)
            {
                throw new ArgumentNullException("Load Cell Business");
            }

            //if (!FanFunctionAccessData.HasModeAccess(aFanKey, "Cell", AccessMode.Read))
            //{
            //    throw new ZpAccessException("Access Denied", String.Format("{0}", aFanKey.CellnKey), AccessMode.Read, "Cell");
            //}

            CellData.Load(aCell);
        }
Esempio n. 6
0
        /// <summary>
        ///   Insert a <see cref="Cell"/> object passed as an argument via Stored Procedure that returns the newly inserted <i>Cell Key</i>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aCell">A <see cref="Cell"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aCell</c> argument is <c>null</c>.</exception>
        public static void Insert(FanKey aFanKey, Cell aCell)
        {
            if (aCell == null)
            {
                throw new ArgumentNullException("Insert Cell Business");
            }

            //if (!FanFunctionAccessData.HasModeAccess(aFanKey, "Cell", AccessMode.Create))
            //{
            //    throw new ZpAccessException("Access Denied", String.Format("{0}", aFanKey.FannKey), AccessMode.Create, "Cell");
            //}

            CellData.Insert(aCell);
        }
Esempio n. 7
0
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="CellCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is CellCollection))
            {
                throw new ArgumentException("Invalid assignment source", "CellCollection");
            }

            _isFiltered = (aSource as CellCollection)._isFiltered;
            _cellFilter = (aSource as CellCollection)._cellFilter;
            _cellList.Clear();
            foreach (Cell vCellSource in (aSource as CellCollection)._cellList)
            {
                Cell vCellTarget = new Cell();
                vCellTarget.AssignFromSource(vCellSource);
                _cellList.Add(vCellTarget);
            }
        }
Esempio n. 8
0
 /// <summary>
 ///   Delete a <see cref="Cell"/> object passed as an argument.
 /// </summary>
 /// <param name="aCell">The <see cref="Cell"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aCell</c> argument is <c>null</c>.</exception>
 public static void Delete(Cell aCell)
 {
     if (aCell == null)
     {
         throw new ArgumentNullException("aCell");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete CEL_Cell");
         vStringBuilder.AppendLine("where  CEL_Key = @CELKey");
         vSqlCommand.Parameters.AddWithValue("@CELKey", aCell.CelKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Esempio n. 9
0
 /// <summary>
 ///   Update a <see cref="Cell"/> passed as an argument .
 /// </summary>
 /// <param name="aCell">A <see cref="Cell"/>.</param>
 public static void Update(Cell aCell)
 {
     if (aCell == null)
     {
         throw new ArgumentNullException("aCell");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update CEL_Cell");
         vStringBuilder.AppendLine("set    CEL_Name = @CELName,");
         vStringBuilder.AppendLine("       FAN_Key = @FANKey,");
         vStringBuilder.AppendLine("       CEL_Avatar = @CELAvatar");
         vStringBuilder.AppendLine("where  CEL_Key = @CELKey");
         ObjectToData(vSqlCommand, aCell);
         vSqlCommand.Parameters.AddWithValue("@CELKey", aCell.CelKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Esempio n. 10
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="Cell"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aCell">A <see cref="Cell"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, Cell aCell)
 {
     aSqlCommand.Parameters.AddWithValue("@CELName", aCell.CellName);
     aSqlCommand.Parameters.AddWithValue("@FANKey", aCell.FanKey);
     if (aCell.CellAvatar == null)
     {
         aSqlCommand.Parameters.Add("@CELAvatar", SqlDbType.Image).Value = DBNull.Value;
     }
     else
     {
         aSqlCommand.Parameters.AddWithValue("@CELAvatar", aCell.CellAvatar);
     }
 }
Esempio n. 11
0
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="Cell"/>, with keys in the <c>aCell</c> argument.
 /// </summary>
 /// <param name="aCell">A <see cref="Cell"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aCell</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(Cell aCell)
 {
     if (aCell == null)
     {
         throw new ArgumentNullException("aCell");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL(true);
         vStringBuilder.AppendLine("where t1.CEL_Key = @CELKey");
         vSqlCommand.Parameters.AddWithValue("@CELKey", aCell.CelKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!vSqlDataReader.HasRows)
             {
                 throw new Exception(String.Format("Expected Cell not found: CEL_Key = {0}", aCell.CelKey));
             }
             vSqlDataReader.Read();
             DataToObject(aCell, vSqlDataReader, true);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Esempio n. 12
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>CellList</c> property a <see cref="CellCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="Cell"/>, filtered by the filter properties of the passed <see cref="CellCollection"/>.
 /// </summary>
 /// <param name="aCellCollection">The <see cref="CellCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="CellCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aCellCollection</c> argument is <c>null</c>.</exception>
 public static void Load(CellCollection aCellCollection)
 {
     if (aCellCollection == null)
     {
         throw new ArgumentNullException("aCellCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL(false);
         if (aCellCollection.IsFiltered)
         {
             vStringBuilder.AppendFormat("where t1.CEL_Name is like '%{0}%", aCellCollection.CellFilter.CellNameFilter);
         }
         vStringBuilder.AppendLine("order by t1.CEL_Name");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vCell = new Cell();
                 DataToObject(vCell, vSqlDataReader, false);
                 aCellCollection.CellList.Add(vCell);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Esempio n. 13
0
 /// <summary>
 /// Call the WebService with a request to Add a Fan
 /// </summary>
 /// <param name="aCell">The Cell object to Add</param>
 /// <param name="aFanToken">A Fan token.</param>
 public static void AddCell(FanToken aFanToken, Cell aCell)
 {
     FanCallHandler.ServiceCall<Cell>(aFanToken, "AddCell", aCell);
 }