Beispiel #1
0
        public static webObject loadActivityCollection(Activity aActivity)
        {
            ActivityCollection vActivityCollection = new ActivityCollection();

            vActivityCollection.ActivityFilter.ActFilter.AssignFromSource(aActivity);

            FanToken  vFanToken  = ServerSession.GetFanToken(HttpContext.Current.Session);
            webObject vWebObject = new webObject();

            vWebObject.aTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session);

            try
            {
                FanServiceConsumer.GetActivityCollection(vFanToken, vActivityCollection);
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.OK;
                vWebObject.aTransactionStatus.Message           = "ActivityCollection Loaded";
                ServerSession.SetTransactionStatus(HttpContext.Current.Session, vWebObject.aTransactionStatus);
                vWebObject.AnObject = vActivityCollection;
            }
            catch (TransactionStatusException tx)
            {
                vWebObject.aTransactionStatus.AssignFromSource(tx.TransactionStatus);
                return(vWebObject);
            }
            catch (Exception ex)
            {
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.GeneralException;
                vWebObject.aTransactionStatus.Message           = "Load of ActivityCollection unsuccesful" + ex.Message;
                vWebObject.aTransactionStatus.InnerMessage      = ex.InnerException == null ? String.Empty : ex.InnerException.Message;
                return(vWebObject);
            }
            return(vWebObject);
        }
Beispiel #2
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>ActivityList</c> property a <see cref="ActivityCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="Activity"/>, filtered by the filter properties of the passed <see cref="ActivityCollection"/>.
 /// </summary>
 /// <param name="aActivityCollection">The <see cref="ActivityCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="ActivityCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aActivityCollection</c> argument is <c>null</c>.</exception>
 public static void Load(ActivityCollection aActivityCollection)
 {
     if (aActivityCollection == null)
     {
         throw new ArgumentNullException("aActivityCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aActivityCollection.IsFiltered)
         {
             if (aActivityCollection.ActivityFilter.ActFilter.ExcKey > 0)
             {
                 vStringBuilder.AppendLine("and t1.EXC_Key = @EXCKey");
                 vSqlCommand.Parameters.AddWithValue("@EXCKey", aActivityCollection.ActivityFilter.ActFilter.ExcKey);
             }
             if (aActivityCollection.ActivityFilter.ActFilter.WrtKey > 0)
             {
                 vStringBuilder.AppendLine("and t2.WRT_Key = @WRTKey");
                 vSqlCommand.Parameters.AddWithValue("@WRTKey", aActivityCollection.ActivityFilter.ActFilter.WrtKey);
             }
             if (aActivityCollection.ActivityFilter.ActFilter.ActUnitOfMeasure > 0)
             {
                 vStringBuilder.AppendFormat("and t3.ACT_UnitOfMeasure = @ACTUnitOfMeasure");
                 vSqlCommand.Parameters.AddWithValue("@ACTUnitOfMeasure", aActivityCollection.ActivityFilter.ActFilter.ActUnitOfMeasure);
             }
             if (aActivityCollection.ActivityFilter.ActFilter.ActUnitOfTime > 0)
             {
                 vStringBuilder.AppendFormat("and t3.ACT_UnitOfTime = @ACTUnitOfTime");
                 vSqlCommand.Parameters.AddWithValue("@ACTUnitOfTime", aActivityCollection.ActivityFilter.ActFilter.ActUnitOfTime);
             }
         }
         vStringBuilder.AppendLine("order by t3.ACT_Key");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vActivity = new Activity();
                 DataToObject(vActivity, vSqlDataReader);
                 aActivityCollection.ActivityList.Add(vActivity);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Beispiel #3
0
        /// <summary>
        ///   The overloaded Load method that will return a <see cref="ActivityCollection"/>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aActivityCollection">A <see cref="ActivityCollection"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aActivityCollection</c> argument is <c>null</c>.</exception>
        public static void Load(FanKey aFanKey, ActivityCollection aActivityCollection)
        {
            if (aActivityCollection == null)
            {
                throw new ArgumentNullException("Load Activity Business");
            }

            //if (!FanFunctionAccessData.HasModeAccess(aFanKey, "Activity", AccessMode.List))
            //{
            //    throw new ZpAccessException("Access Denied", String.Format("{0}", aFanKey.ActivitynKey), AccessMode.List, "Activity");
            //}

            ActivityData.Load(aActivityCollection);
        }
Beispiel #4
0
        /// <summary>
        ///   The overloaded Load method that will return a <see cref="ActivityCollection"/>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aActivityCollection">A <see cref="ActivityCollection"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aActivityCollection</c> argument is <c>null</c>.</exception>
        public static void Load(FanKey aFanKey, ActivityCollection aActivityCollection)
        {
            if (aActivityCollection == null)
            {
                throw new ArgumentNullException("Load Activity Business");
            }

            //if (!FanFunctionAccessData.HasModeAccess(aFanKey, "Activity", AccessMode.List))
            //{
            //    throw new ZpAccessException("Access Denied", String.Format("{0}", aFanKey.ActivitynKey), AccessMode.List, "Activity");
            //}

            ActivityData.Load(aActivityCollection);
        }
Beispiel #5
0
        public static webObject loadActivityCollection(Activity aActivity)
        {
            ActivityCollection vActivityCollection = new ActivityCollection();
            vActivityCollection.ActivityFilter.ActFilter.AssignFromSource(aActivity);

            FanToken vFanToken = ServerSession.GetFanToken(HttpContext.Current.Session);
            webObject vWebObject = new webObject();
            vWebObject.aTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session);

            try
            {
                FanServiceConsumer.GetActivityCollection(vFanToken, vActivityCollection);
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.OK;
                vWebObject.aTransactionStatus.Message = "ActivityCollection Loaded";
                ServerSession.SetTransactionStatus(HttpContext.Current.Session, vWebObject.aTransactionStatus);
                vWebObject.AnObject = vActivityCollection;
            }
            catch (TransactionStatusException tx)
            {

                vWebObject.aTransactionStatus.AssignFromSource(tx.TransactionStatus);
                return vWebObject;
            }
            catch (Exception ex)
            {
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.GeneralException;
                vWebObject.aTransactionStatus.Message = "Load of ActivityCollection unsuccesful" + ex.Message;
                vWebObject.aTransactionStatus.InnerMessage = ex.InnerException == null ? String.Empty : ex.InnerException.Message;
                return vWebObject;
            }
            return vWebObject;
        }
Beispiel #6
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>ActivityList</c> property a <see cref="ActivityCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="Activity"/>, filtered by the filter properties of the passed <see cref="ActivityCollection"/>.
 /// </summary>
 /// <param name="aActivityCollection">The <see cref="ActivityCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="ActivityCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aActivityCollection</c> argument is <c>null</c>.</exception>
 public static void Load(ActivityCollection aActivityCollection)
 {
     if (aActivityCollection == null)
     {
         throw new ArgumentNullException("aActivityCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aActivityCollection.IsFiltered)
         {
             if (aActivityCollection.ActivityFilter.ActFilter.ExcKey > 0)
             {
                 vStringBuilder.AppendLine("and t1.EXC_Key = @EXCKey");
                 vSqlCommand.Parameters.AddWithValue("@EXCKey", aActivityCollection.ActivityFilter.ActFilter.ExcKey);
             }
             if (aActivityCollection.ActivityFilter.ActFilter.WrtKey > 0)
             {
                 vStringBuilder.AppendLine("and t2.WRT_Key = @WRTKey");
                 vSqlCommand.Parameters.AddWithValue("@WRTKey", aActivityCollection.ActivityFilter.ActFilter.WrtKey);
             }
             if (aActivityCollection.ActivityFilter.ActFilter.ActUnitOfMeasure > 0)
             {
                 vStringBuilder.AppendFormat("and t3.ACT_UnitOfMeasure = @ACTUnitOfMeasure");
                 vSqlCommand.Parameters.AddWithValue("@ACTUnitOfMeasure", aActivityCollection.ActivityFilter.ActFilter.ActUnitOfMeasure);
             }
             if (aActivityCollection.ActivityFilter.ActFilter.ActUnitOfTime > 0)
             {
                 vStringBuilder.AppendFormat("and t3.ACT_UnitOfTime = @ACTUnitOfTime");
                 vSqlCommand.Parameters.AddWithValue("@ACTUnitOfTime", aActivityCollection.ActivityFilter.ActFilter.ActUnitOfTime);
             }
         }
         vStringBuilder.AppendLine("order by t3.ACT_Key");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vActivity = new Activity();
                 DataToObject(vActivity, vSqlDataReader);
                 aActivityCollection.ActivityList.Add(vActivity);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Beispiel #7
0
 /// <summary>
 ///   The <c>GetActivityCollection</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="ActivityCollection"/> object.
 ///   It invokes the <c>Insert</c> method of <see cref="ActivityBusiness"/> with the newly deserialized <see cref="ActivityCollection"/> object.
 ///   Finally, it returns the collection object as a serialized <see cref="string"/> of XML.
 /// </summary>
 /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
 /// <returns><see cref="ActivityCollection"/> as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string GetActivityCollection(FanKey aFanKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of GetActivityCollection");
     }
     ActivityCollection vActivityCollection = new ActivityCollection();
     vActivityCollection = XmlUtils.Deserialize<ActivityCollection>(aXmlArgument);
     ActivityBusiness.Load(aFanKey, vActivityCollection);
     return XmlUtils.Serialize<ActivityCollection>(vActivityCollection, true);
 }
Beispiel #8
0
 /// <summary>
 /// Gets a FanCollection
 /// </summary>
 /// <param name="aFantoken">A fantoken.</param>
 /// <param name="aActivityCollection">A user collection.</param>
 public static void GetActivityCollection(FanToken aFantoken, ActivityCollection aActivityCollection)
 {
     FanCallHandler.ServiceCall <ActivityCollection>(aFantoken, "GetActivityCollection", aActivityCollection);
 }
Beispiel #9
0
 /// <summary>
 /// Gets a FanCollection
 /// </summary>
 /// <param name="aFantoken">A fantoken.</param>
 /// <param name="aActivityCollection">A user collection.</param>
 public static void GetActivityCollection(FanToken aFantoken, ActivityCollection aActivityCollection)
 {
     FanCallHandler.ServiceCall<ActivityCollection>(aFantoken, "GetActivityCollection", aActivityCollection);
 }