private void UpdateGeneratorAttribute(GeneratorAttribute currentGeneratorAttribute, GeneratorAttribute newGeneratorAttribute)
        {
            currentGeneratorAttribute.DateUpdated   = DateTime.Now;
            currentGeneratorAttribute.UserUpdatedId = newGeneratorAttribute.UserCreatedId;
            currentGeneratorAttribute.DateEnd       = newGeneratorAttribute.DateEnd;
            currentGeneratorAttribute.DateReplaced  = newGeneratorAttribute.DateReplaced;
            currentGeneratorAttribute.DependableGeneratingCapacity  = newGeneratorAttribute.DependableGeneratingCapacity;
            currentGeneratorAttribute.EffectiveLoadCarryingCapacity = newGeneratorAttribute.EffectiveLoadCarryingCapacity;
            currentGeneratorAttribute.EPACapacity                     = newGeneratorAttribute.EPACapacity;
            currentGeneratorAttribute.InServiceEndDate                = newGeneratorAttribute.InServiceEndDate;
            currentGeneratorAttribute.InServiceStartDate              = newGeneratorAttribute.InServiceStartDate;
            currentGeneratorAttribute.IsNitsNominated                 = newGeneratorAttribute.IsNitsNominated;
            currentGeneratorAttribute.MaximumPowerOutput              = newGeneratorAttribute.MaximumPowerOutput;
            currentGeneratorAttribute.MaxOutputForFirmTransmission    = newGeneratorAttribute.MaxOutputForFirmTransmission;
            currentGeneratorAttribute.MaxOutputForNonFirmTransmission = newGeneratorAttribute.MaxOutputForNonFirmTransmission;
            currentGeneratorAttribute.MaxTakeOrPayCapacity            = newGeneratorAttribute.MaxTakeOrPayCapacity;
            currentGeneratorAttribute.MonthlyAverageCapacity          = newGeneratorAttribute.MonthlyAverageCapacity;
            currentGeneratorAttribute.NamePlateCapacityInMW           = newGeneratorAttribute.NamePlateCapacityInMW;
            currentGeneratorAttribute.NitsDesignatedCapacity          = newGeneratorAttribute.NitsDesignatedCapacity;
            currentGeneratorAttribute.PhysicalMinimumOutput           = newGeneratorAttribute.PhysicalMinimumOutput;
            currentGeneratorAttribute.PointToPointCapacity            = newGeneratorAttribute.PointToPointCapacity;
            currentGeneratorAttribute.Probability                     = newGeneratorAttribute.Probability;
            currentGeneratorAttribute.RatedMVA = newGeneratorAttribute.RatedMVA;
            currentGeneratorAttribute.RatedOverExcitedPowerFactor  = newGeneratorAttribute.RatedOverExcitedPowerFactor;
            currentGeneratorAttribute.RatedPowerFactor             = newGeneratorAttribute.RatedPowerFactor;
            currentGeneratorAttribute.RatedUnderExcitedPowerFactor = newGeneratorAttribute.RatedUnderExcitedPowerFactor;
            currentGeneratorAttribute.RegulatoryMinimumOutput      = newGeneratorAttribute.RegulatoryMinimumOutput;
            currentGeneratorAttribute.ReliabilityMustRunCapacity   = newGeneratorAttribute.ReliabilityMustRunCapacity;
            currentGeneratorAttribute.SystemCapacity     = newGeneratorAttribute.SystemCapacity;
            currentGeneratorAttribute.LeadingPowerFactor = newGeneratorAttribute.LeadingPowerFactor;
            currentGeneratorAttribute.LaggingPowerFactor = newGeneratorAttribute.LaggingPowerFactor;

            newGeneratorAttribute.Id = currentGeneratorAttribute.Id;
        }
        public void DeleteAttribute(int generatingUnitId, int resourcePlanId, int?phaseId)
        {
            GeneratorAttribute generatorAttribute = this.Context.GeneratorAttributes.FirstOrDefault(ga => ga.GeneratingUnitId == generatingUnitId &&
                                                                                                    ga.ResourcePlanId == resourcePlanId &&
                                                                                                    ga.ProjectPhaseId == phaseId);

            if (generatorAttribute == null)
            {
                return;
            }
            this.Context.GeneratorAttributes.DeleteOnSubmit(generatorAttribute);
            this.Context.SubmitChanges();
        }
        /// <summary>
        /// Inserts any new GeneratorAttribute objects to Db and updates any existing GeneratorAttribute objects (based on GeneratingUnitId)
        /// </summary>
        /// <param name="generatorAttribute">GeneratorAttribute object</param>
        public void SaveGeneratorAttribute(GeneratorAttribute generatorAttribute)
        {
            GeneratorAttribute currentGeneratorAttribute = this.Context.GeneratorAttributes.FirstOrDefault(ga => ga.GeneratingUnitId == generatorAttribute.GeneratingUnitId && ga.ResourcePlanId == generatorAttribute.ResourcePlanId && !ga.ProjectPhaseId.HasValue);

            if (currentGeneratorAttribute != null)
            {
                UpdateGeneratorAttribute(currentGeneratorAttribute, generatorAttribute);
            }
            else
            {
                generatorAttribute.DateCreated = DateTime.Now;
                this.Context.GeneratorAttributes.InsertOnSubmit(generatorAttribute);
            }
            this.Context.SubmitChanges();
        }
        /// <summary>
        /// Inserts any new GeneratorAttribute objects to Db and updates any existing GeneratorAttribute objects (based on gen unit Id, plan id & phase id)
        /// </summary>
        /// <param name="generatorAttribute">GeneratorAttribute object</param>
        public void Save(GeneratorAttribute ga)
        {
            GeneratorAttribute currentGa = this.Context.GeneratorAttributes.FirstOrDefault(gua => gua.GeneratingUnitId == ga.GeneratingUnitId && gua.ResourcePlanId == ga.ResourcePlanId && (!gua.ProjectPhaseId.HasValue || gua.ProjectPhaseId == ga.ProjectPhaseId));

            if (currentGa != null)
            {
                UpdateGeneratorAttribute(currentGa, ga);
            }
            else
            {
                ga.DateCreated = DateTime.Now;
                this.Context.GeneratorAttributes.InsertOnSubmit(ga);
            }
            this.Context.SubmitChanges();
        }
        /// <summary>
        /// Inserts any new GeneratorAttribute objects to Db and updates any existing GeneratorAttribute objects (based on GeneratingUnitId, resourcsPlanId & projectPhaseId)
        /// Updates input reference param currentGeneratorAttribute with pre update state.  currentGeneratorAttribute remains null when the object is new
        /// </summary>
        /// <param name="generatorAttribute">GeneratorAttribute object</param>
        public bool SaveAttributeAgainstPhase(GeneratorAttribute newGeneratorAttribute, ref GeneratorAttribute currentGeneratorAttribute)
        {
            bool newToPhase = false;
            GeneratorAttribute existingGeneratorAttribute = this.Context.GeneratorAttributes.FirstOrDefault(ga => ga.GeneratingUnitId == newGeneratorAttribute.GeneratingUnitId &&
                                                                                                            ga.ResourcePlanId == newGeneratorAttribute.ResourcePlanId &&
                                                                                                            ga.ProjectPhaseId == newGeneratorAttribute.ProjectPhaseId);

            if (existingGeneratorAttribute != null)
            {
                currentGeneratorAttribute = existingGeneratorAttribute.Clone();
                UpdateGeneratorAttribute(existingGeneratorAttribute, newGeneratorAttribute);
            }
            else
            {
                this.Context.GeneratorAttributes.InsertOnSubmit(newGeneratorAttribute);
                newToPhase = true;
            }
            this.Context.SubmitChanges();
            return(newToPhase);
        }
Esempio n. 6
0
        public GeneratorAttribute Clone()
        {
            GeneratorAttribute clone = new GeneratorAttribute();

            clone.GeneratingUnitId                = this.GeneratingUnitId;
            clone.ResourcePlanId                  = this.ResourcePlanId;
            clone.ProjectPhaseId                  = this.ProjectPhaseId;
            clone.DateEnd                         = this.DateEnd;
            clone.DateReplaced                    = this.DateReplaced;
            clone.InServiceStartDate              = this.InServiceStartDate;
            clone.InServiceEndDate                = this.InServiceEndDate;
            clone.DependableGeneratingCapacity    = this.DependableGeneratingCapacity;
            clone.EffectiveLoadCarryingCapacity   = this.EffectiveLoadCarryingCapacity;
            clone.EPACapacity                     = this.EPACapacity;
            clone.IsNitsNominated                 = this.IsNitsNominated;
            clone.MaximumPowerOutput              = this.MaximumPowerOutput;
            clone.MaxOutputForFirmTransmission    = this.MaxOutputForFirmTransmission;
            clone.MaxOutputForNonFirmTransmission = this.MaxOutputForNonFirmTransmission;
            clone.LaggingPowerFactor              = this.LaggingPowerFactor;
            clone.LeadingPowerFactor              = this.LeadingPowerFactor;
            clone.MaxTakeOrPayCapacity            = this.MaxTakeOrPayCapacity;
            clone.MonthlyAverageCapacity          = this.MonthlyAverageCapacity;
            clone.NamePlateCapacityInMW           = this.NamePlateCapacityInMW;
            clone.NitsDesignatedCapacity          = this.NitsDesignatedCapacity;
            clone.PhysicalMinimumOutput           = this.PhysicalMinimumOutput;
            clone.PointToPointCapacity            = this.PointToPointCapacity;
            clone.Probability                     = this.Probability;
            clone.RatedMVA                        = this.RatedMVA;
            clone.RatedOverExcitedPowerFactor     = this.RatedOverExcitedPowerFactor;
            clone.RatedPowerFactor                = this.RatedPowerFactor;
            clone.RatedUnderExcitedPowerFactor    = this.RatedUnderExcitedPowerFactor;
            clone.RegulatoryMinimumOutput         = this.RegulatoryMinimumOutput;
            clone.ReliabilityMustRunCapacity      = this.ReliabilityMustRunCapacity;
            clone.SystemCapacity                  = this.SystemCapacity;
            return(clone);
        }