/// <summary>
        /// Returns true if BankingTransaction instances are equal
        /// </summary>
        /// <param name="other">Instance of BankingTransaction to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(BankingTransaction other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     AccountId == other.AccountId ||
                     AccountId != null &&
                     AccountId.Equals(other.AccountId)
                     ) &&
                 (
                     TransactionId == other.TransactionId ||
                     TransactionId != null &&
                     TransactionId.Equals(other.TransactionId)
                 ) &&
                 (
                     IsDetailAvailable == other.IsDetailAvailable ||
                     IsDetailAvailable != null &&
                     IsDetailAvailable.Equals(other.IsDetailAvailable)
                 ) &&
                 (
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                 ) &&
                 (
                     Status == other.Status ||
                     Status != null &&
                     Status.Equals(other.Status)
                 ) &&
                 (
                     Description == other.Description ||
                     Description != null &&
                     Description.Equals(other.Description)
                 ) &&
                 (
                     PostingDateTime == other.PostingDateTime ||
                     PostingDateTime != null &&
                     PostingDateTime.Equals(other.PostingDateTime)
                 ) &&
                 (
                     ValueDateTime == other.ValueDateTime ||
                     ValueDateTime != null &&
                     ValueDateTime.Equals(other.ValueDateTime)
                 ) &&
                 (
                     ExecutionDateTime == other.ExecutionDateTime ||
                     ExecutionDateTime != null &&
                     ExecutionDateTime.Equals(other.ExecutionDateTime)
                 ) &&
                 (
                     Amount == other.Amount ||
                     Amount != null &&
                     Amount.Equals(other.Amount)
                 ) &&
                 (
                     Currency == other.Currency ||
                     Currency != null &&
                     Currency.Equals(other.Currency)
                 ) &&
                 (
                     Reference == other.Reference ||
                     Reference != null &&
                     Reference.Equals(other.Reference)
                 ) &&
                 (
                     MerchantName == other.MerchantName ||
                     MerchantName != null &&
                     MerchantName.Equals(other.MerchantName)
                 ) &&
                 (
                     MerchantCategoryCode == other.MerchantCategoryCode ||
                     MerchantCategoryCode != null &&
                     MerchantCategoryCode.Equals(other.MerchantCategoryCode)
                 ) &&
                 (
                     BillerCode == other.BillerCode ||
                     BillerCode != null &&
                     BillerCode.Equals(other.BillerCode)
                 ) &&
                 (
                     BillerName == other.BillerName ||
                     BillerName != null &&
                     BillerName.Equals(other.BillerName)
                 ) &&
                 (
                     Crn == other.Crn ||
                     Crn != null &&
                     Crn.Equals(other.Crn)
                 ) &&
                 (
                     ApcaNumber == other.ApcaNumber ||
                     ApcaNumber != null &&
                     ApcaNumber.Equals(other.ApcaNumber)
                 ));
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (AccountId != null)
         {
             hashCode = hashCode * 59 + AccountId.GetHashCode();
         }
         if (TransactionId != null)
         {
             hashCode = hashCode * 59 + TransactionId.GetHashCode();
         }
         if (IsDetailAvailable != null)
         {
             hashCode = hashCode * 59 + IsDetailAvailable.GetHashCode();
         }
         if (Type != null)
         {
             hashCode = hashCode * 59 + Type.GetHashCode();
         }
         if (Status != null)
         {
             hashCode = hashCode * 59 + Status.GetHashCode();
         }
         if (Description != null)
         {
             hashCode = hashCode * 59 + Description.GetHashCode();
         }
         if (PostingDateTime != null)
         {
             hashCode = hashCode * 59 + PostingDateTime.GetHashCode();
         }
         if (ValueDateTime != null)
         {
             hashCode = hashCode * 59 + ValueDateTime.GetHashCode();
         }
         if (ExecutionDateTime != null)
         {
             hashCode = hashCode * 59 + ExecutionDateTime.GetHashCode();
         }
         if (Amount != null)
         {
             hashCode = hashCode * 59 + Amount.GetHashCode();
         }
         if (Currency != null)
         {
             hashCode = hashCode * 59 + Currency.GetHashCode();
         }
         if (Reference != null)
         {
             hashCode = hashCode * 59 + Reference.GetHashCode();
         }
         if (MerchantName != null)
         {
             hashCode = hashCode * 59 + MerchantName.GetHashCode();
         }
         if (MerchantCategoryCode != null)
         {
             hashCode = hashCode * 59 + MerchantCategoryCode.GetHashCode();
         }
         if (BillerCode != null)
         {
             hashCode = hashCode * 59 + BillerCode.GetHashCode();
         }
         if (BillerName != null)
         {
             hashCode = hashCode * 59 + BillerName.GetHashCode();
         }
         if (Crn != null)
         {
             hashCode = hashCode * 59 + Crn.GetHashCode();
         }
         if (ApcaNumber != null)
         {
             hashCode = hashCode * 59 + ApcaNumber.GetHashCode();
         }
         return(hashCode);
     }
 }
        protected override bool Execute(CodeActivityContext context)
        {
            int ti_id = TiId.Get(context);

            Value.Set(context, 0);
            Status.Set(context, (int)VALUES_FLAG_DB.DataNotFull);
            StatusStr.Set(context, TVALUES_DB.FLAG_to_String(VALUES_FLAG_DB.DataNotFull, ";"));
            ValueDateTime.Set(context, DateTime.MinValue);

            List <TINTEGRALVALUES_DB> _valueList = new List <TINTEGRALVALUES_DB>();

            ValueList.Set(context, _valueList);

            if (RequestType == enumEnrgyQualityRequestType.Archive)
            {
                if (StartDateTime.Get(context) == null || EndDateTime.Get(context) == null)
                {
                    Error.Set(context, "Для архивных значений начальная и конечная дата должна быть определена");
                    return(false);
                }
            }

            try
            {
                List <TI_ChanelType> tiList = new List <TI_ChanelType>()
                {
                    new TI_ChanelType()
                    {
                        TI_ID          = ti_id,
                        ChannelType    = Channel.Get(context),
                        DataSourceType = DataSourceType,
                    }
                };

                if (RequestType == enumEnrgyQualityRequestType.Archive)
                {
                    //TODO часовой пояс
                    var values = ARM_Service.DS_GetIntegralsValues_List(tiList,
                                                                        StartDateTime.Get(context),
                                                                        EndDateTime.Get(context),
                                                                        IsCoeffEnabled, false, false, true, false, false, enumTimeDiscreteType.DBHalfHours, EnumUnitDigit.None, null, false,
                                                                        false);


                    if (values != null && values.IntegralsValue30orHour != null && values.IntegralsValue30orHour.Count > 0)
                    {
                        var    integralTiValue = values.IntegralsValue30orHour[0];
                        double diff            = 0;
                        var    flag            = VALUES_FLAG_DB.None;
                        if (integralTiValue.Val_List != null)
                        {
                            foreach (var iVal in integralTiValue.Val_List)
                            {
                                diff += iVal.F_VALUE_DIFF;
                                flag  = flag.CompareAndReturnMostBadStatus(iVal.F_FLAG);
                                _valueList.Add(iVal);
                            }
                        }

                        Value.Set(context, diff);
                        var stat = flag;
                        Status.Set(context, (int)stat);
                        StatusStr.Set(context, TVALUES_DB.FLAG_to_String(stat, ";"));

                        if (integralTiValue.Val_List != null && integralTiValue.Val_List.Count > 0)
                        {
                            ValueDateTime.Set(context, integralTiValue.Val_List.Last().EventDateTime);
                        }
                    }
                }
                else
                {
                    var Val = ARM_Service.DS_ReadLastIntegralArchives(tiList);
                    if (Val != null && Val.Count > 0)
                    {
                        var ValDict = Val.ToDictionary(k => k.Key, v => v.Value, new TI_ChanelComparer());
                        foreach (var r in tiList)
                        {
                            TINTEGRALVALUES_DB i_val;

                            if (ValDict.TryGetValue(r, out i_val) && i_val != null)
                            {
                                Value.Set(context, i_val.F_VALUE);
                                Status.Set(context, (int)i_val.F_FLAG);
                                StatusStr.Set(context, TVALUES_DB.FLAG_to_String(i_val.F_FLAG, ";"));
                                ValueDateTime.Set(context, i_val.EventDateTime);
                                _valueList.Add(i_val);
                                break;
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                Error.Set(context, ex.Message);
                if (!HideException.Get(context))
                {
                    throw ex;
                }
            }

            ValueList.Set(context, _valueList);

            return(string.IsNullOrEmpty(Error.Get(context)));
        }