/// <summary>
 /// Maps properties of newSubstationAttribute object to currentSubstationAttribute object.  Changes are not commited to DB.
 /// </summary>
 /// <param name="newSubstationAttribute">SubstationAttribute object</param>
 /// <param name="currentSubstationAttribute">SubstationAttribute object</param>
 private void UpdateAttribute(SubstationAttribute newSa, SubstationAttribute currentSa)
 {
     currentSa.DateUpdated   = DateTime.Now;
     currentSa.UserUpdatedId = newSa.UserCreatedId;
     currentSa.DateEffective = newSa.DateEffective;
     currentSa.DateEnd       = newSa.DateEnd;
     currentSa.DateReplaced  = newSa.DateReplaced;
     currentSa.DependableGeneratingCapacity  = newSa.DependableGeneratingCapacity;
     currentSa.EffectiveLoadCarryingCapacity = newSa.EffectiveLoadCarryingCapacity;
     currentSa.EPACapacity         = newSa.EPACapacity;
     currentSa.InServiceEndDate    = newSa.InServiceEndDate;
     currentSa.InServiceStartDate  = newSa.InServiceStartDate;
     currentSa.LoadGrossSummerPeak = newSa.LoadGrossSummerPeak;
     currentSa.LoadGrossWinterPeak = newSa.LoadGrossWinterPeak;
     currentSa.LoadGrossSummerMin  = newSa.LoadGrossSummerMin;
     currentSa.LoadGrossWinterMin  = newSa.LoadGrossWinterMin;
     //currentSa.MaximumContinousRating = newSa.MaximumContinousRating;
     //currentSa.MaximumPowerOutput = newSa.MaximumPowerOutput;
     //currentSa.MaxReactiveAbsorptionInMVars = newSa.MaxReactiveAbsorptionInMVars;
     //currentSa.MaxReactiveProductionInMVars = newSa.MaxReactiveProductionInMVars;
     currentSa.MaxTakeOrPayCapacity   = newSa.MaxTakeOrPayCapacity;
     currentSa.NamePlateCapacityInMW  = newSa.NamePlateCapacityInMW;
     currentSa.NitsDesignatedCapacity = newSa.NitsDesignatedCapacity;
     currentSa.Nominated            = newSa.Nominated;
     currentSa.OriginalId           = newSa.OriginalId;
     currentSa.PointToPointCapacity = newSa.PointToPointCapacity;
     currentSa.Probability          = newSa.Probability;
     currentSa.ProjectPhaseId       = newSa.ProjectPhaseId;
     //currentSa.RatedAmp = newSa.RatedAmp;
     currentSa.MaxOutputForFirmTransmission    = newSa.MaxOutputForFirmTransmission;
     currentSa.MaxOutputForNonFirmTransmission = newSa.MaxOutputForNonFirmTransmission;
     currentSa.RatedMVA = newSa.RatedMVA;
     //currentSa.RatedMW = newSa.RatedMW;
     currentSa.RatedOverExcitedMvar        = newSa.RatedOverExcitedMvar;
     currentSa.RatedOverExcitedPowerFactor = newSa.RatedOverExcitedPowerFactor;
     currentSa.RatedPowerFactor            = newSa.RatedPowerFactor;
     //currentSa.RatedSpeed = newSa.RatedSpeed;
     currentSa.RatedUnderExcitedMvar           = newSa.RatedUnderExcitedMvar;
     currentSa.RatedUnderExcitedPowerFactor    = newSa.RatedUnderExcitedPowerFactor;
     currentSa.ReliabilityMustRunCapacity      = newSa.ReliabilityMustRunCapacity;
     currentSa.MaximumPowerOutput              = newSa.MaximumPowerOutput;
     currentSa.MaxOutputForNonFirmTransmission = newSa.MaxOutputForNonFirmTransmission;
     currentSa.MaxOutputForFirmTransmission    = newSa.MaxOutputForFirmTransmission;
     // radio buttons
     currentSa.UsePndcMasteredValue            = newSa.UsePndcMasteredValue;
     currentSa.UsePdgcMasteredValue            = newSa.UsePdgcMasteredValue;
     currentSa.UsePmpoMasteredValue            = newSa.UsePmpoMasteredValue;
     currentSa.UsePptpMasteredValue            = newSa.UsePptpMasteredValue;
     currentSa.UsePrmrMasteredValue            = newSa.UsePrmrMasteredValue;
     currentSa.UsePdmx0MasteredValue           = newSa.UsePdmx0MasteredValue;
     currentSa.UsePdmx1MasteredValue           = newSa.UsePdmx1MasteredValue;
     currentSa.UsePnpMasteredValue             = newSa.UsePnpMasteredValue;
     currentSa.UsePelccMasteredValue           = newSa.UsePelccMasteredValue;
     currentSa.InterconnectionsRequestCapacity = newSa.InterconnectionsRequestCapacity;
     newSa.Id = currentSa.Id;
 }
        public void DeleteAttribute(int substationId, int resourcePlanId, int?phaseId)
        {
            SubstationAttribute substationAttribute = GetAttribute(substationId, resourcePlanId, phaseId);

            if (substationAttribute == null)
            {
                return;
            }
            this.Context.SubstationAttributes.DeleteOnSubmit(substationAttribute);
            this.Context.SubmitChanges();
        }
        /// <summary>
        /// Inserts a new SubstationAttribute object to Db or updates any existing SubstationAttribute objects (based on substation Id, plan id & phase id)
        /// </summary>
        /// <param name="substationAttribute">SubstationAttribute object</param>
        public void Save(SubstationAttribute sa)
        {
            SubstationAttribute currentSa = this.Context.SubstationAttributes.FirstOrDefault(ssa => ssa.SubstationId == sa.SubstationId && ssa.ResourcePlanId == sa.ResourcePlanId && (!ssa.ProjectPhaseId.HasValue || ssa.ProjectPhaseId == sa.ProjectPhaseId));

            if (currentSa != null)
            {
                UpdateAttribute(sa, currentSa);
            }
            else
            {
                this.Context.SubstationAttributes.InsertOnSubmit(sa);
            }
            this.Context.SubmitChanges();
        }
Ejemplo n.º 4
0
        public SubstationAttribute Clone()
        {
            SubstationAttribute clone = new SubstationAttribute();

            clone.SubstationId       = this.SubstationId;
            clone.DateEffective      = this.DateEffective;
            clone.DateEnd            = this.DateEnd;
            clone.DateReplaced       = this.DateReplaced;
            clone.InServiceEndDate   = this.InServiceEndDate;
            clone.InServiceStartDate = this.InServiceStartDate;
            clone.InterconnectionsRequestCapacity = this.InterconnectionsRequestCapacity;
            clone.DependableGeneratingCapacity    = this.DependableGeneratingCapacity;
            clone.EffectiveLoadCarryingCapacity   = this.EffectiveLoadCarryingCapacity;
            clone.EPACapacity                     = this.EPACapacity;
            clone.LoadGrossSummerPeak             = this.LoadGrossSummerPeak;
            clone.LoadGrossWinterPeak             = this.LoadGrossWinterPeak;
            clone.LoadGrossSummerMin              = this.LoadGrossSummerMin;
            clone.LoadGrossWinterMin              = this.LoadGrossWinterMin;
            clone.MaxOutputForFirmTransmission    = this.MaxOutputForFirmTransmission;
            clone.MaxOutputForNonFirmTransmission = this.MaxOutputForNonFirmTransmission;
            clone.MaximumPowerOutput              = this.MaximumPowerOutput;
            clone.MaxTakeOrPayCapacity            = this.MaxTakeOrPayCapacity;
            clone.NamePlateCapacityInMW           = this.NamePlateCapacityInMW;
            clone.NitsDesignatedCapacity          = this.NitsDesignatedCapacity;
            clone.Nominated                    = this.Nominated;
            clone.OriginalId                   = this.OriginalId;
            clone.PointToPointCapacity         = this.PointToPointCapacity;
            clone.Probability                  = this.Probability;
            clone.ProjectPhaseId               = this.ProjectPhaseId;
            clone.ResourcePlanId               = this.ResourcePlanId;
            clone.RatedMVA                     = this.RatedMVA;
            clone.RatedOverExcitedMvar         = this.RatedOverExcitedMvar;
            clone.RatedOverExcitedPowerFactor  = this.RatedOverExcitedPowerFactor;
            clone.RatedPowerFactor             = this.RatedPowerFactor;
            clone.RatedUnderExcitedMvar        = this.RatedUnderExcitedMvar;
            clone.RatedUnderExcitedPowerFactor = this.RatedUnderExcitedPowerFactor;
            clone.ReliabilityMustRunCapacity   = this.ReliabilityMustRunCapacity;
            clone.UsePdgcMasteredValue         = this.UsePdgcMasteredValue;
            clone.UsePmpoMasteredValue         = this.UsePmpoMasteredValue;
            clone.UsePptpMasteredValue         = this.UsePptpMasteredValue;
            clone.UsePrmrMasteredValue         = this.UsePrmrMasteredValue;
            clone.UsePndcMasteredValue         = this.UsePndcMasteredValue;
            clone.UsePnpMasteredValue          = this.UsePnpMasteredValue;
            clone.UsePdmx0MasteredValue        = this.UsePdmx0MasteredValue;
            clone.UsePdmx1MasteredValue        = this.UsePdmx1MasteredValue;
            clone.UsePelccMasteredValue        = this.UsePelccMasteredValue;
            return(clone);
        }
        /// <summary>
        /// Inserts a new SubstationAttribute object to Db or updates any existing SubstationAttribute objects (based on SubstationId, ResourcePlanId and ProjectPhaseId)
        /// </summary>
        /// <param name="substationAttribute">SubstationAttribute object</param>
        public bool SaveAttributeAgainstProjectPhase(SubstationAttribute sa)
        {
            bool newToPhase = false;
            SubstationAttribute currentSa = this.Context.SubstationAttributes.FirstOrDefault(ssa => ssa.SubstationId == sa.SubstationId &&
                                                                                             ssa.ResourcePlanId == sa.ResourcePlanId &&
                                                                                             ssa.ProjectPhaseId == sa.ProjectPhaseId);

            if (currentSa != null)
            {
                UpdateAttribute(sa, currentSa);
            }
            else
            {
                this.Context.SubstationAttributes.InsertOnSubmit(sa);
                newToPhase = true;
            }
            this.Context.SubmitChanges();
            return(newToPhase);
        }
        public bool SaveAttributeAgainstProjectPhase(SubstationAttribute newSa, ref SubstationAttribute currentSa)
        {
            SubstationAttribute existingSa = this.Context.SubstationAttributes.FirstOrDefault(ssa => ssa.SubstationId == newSa.SubstationId &&
                                                                                              ssa.ResourcePlanId == newSa.ResourcePlanId &&
                                                                                              ssa.ProjectPhaseId == newSa.ProjectPhaseId);
            bool newToPhase = false;

            if (existingSa != null)
            {
                currentSa = existingSa.Clone();
                UpdateAttribute(newSa, existingSa);
            }
            else
            {
                this.Context.SubstationAttributes.InsertOnSubmit(newSa);
                newToPhase = true;
            }
            this.Context.SubmitChanges();
            return(newToPhase);
        }