コード例 #1
0
        public YellowstonePathology.Business.PreviousResultCollection GetPreviousResultsByTestFinal(int panelSetId, DateTime startDate, DateTime endDate, string tableName)
        {
            PreviousResultCollection result = new PreviousResultCollection();

            MySqlCommand cmd = new MySqlCommand();

            cmd.CommandType = System.Data.CommandType.Text;
            cmd.CommandText = this.m_TableDictionary[tableName];
            cmd.CommandText = cmd.CommandText.Replace("table_name", tableName);
            cmd.Parameters.AddWithValue("@PanelSetId", panelSetId);
            cmd.Parameters.AddWithValue("@StartDate", startDate);
            cmd.Parameters.AddWithValue("@EndDate", endDate);

            using (MySqlConnection cn = new MySqlConnection(YellowstonePathology.Properties.Settings.Default.CurrentConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (MySqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        PreviousResult previousResult = new PreviousResult();
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(previousResult, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                        result.Add(previousResult);
                    }
                }
            }
            return(result);
        }
コード例 #2
0
ファイル: PreviousResultsTests.cs プロジェクト: kevinXYX/npv
        public async Task SavePreviousResultsAsync()
        {
            //Arrange
            var previousResultEntity = new PreviousResult();

            previousResultEntity.LifeOfProject           = 5;
            previousResultEntity.InitialCost             = 300000;
            previousResultEntity.LowerBoundDiscountRate  = 1;
            previousResultEntity.UpperBoundDiscountRate  = 15;
            previousResultEntity.DiscountRateIncrement   = 0.65;
            previousResultEntity.NetPresentValue         = 234553;
            previousResultEntity.PresentValueOfCashFlows = 17345;
            previousResultEntity.CreatedDate             = DateTime.UtcNow;

            previousResultEntity.CashFlows.Add(new CashFlows {
                Year  = 1,
                Value = 12345,
            });
            previousResultEntity.CashFlows.Add(new CashFlows
            {
                Year  = 2,
                Value = 24223,
            });
            previousResultEntity.CashFlows.Add(new CashFlows
            {
                Year  = 3,
                Value = 22345,
            });
            previousResultEntity.CashFlows.Add(new CashFlows
            {
                Year  = 4,
                Value = 52344,
            });
            previousResultEntity.CashFlows.Add(new CashFlows
            {
                Year  = 5,
                Value = 12623,
            });
            //Act
            _npvContext.AddPreviousResults(previousResultEntity);

            var saveChangesResult = await _npvContext.SaveEntityChangesAsync();

            //Assert
            Assert.IsTrue(saveChangesResult > 0);
        }
コード例 #3
0
        public async Task <IActionResult> SavePreviousResults(CalculationModel calculationModel)
        {
            if (calculationModel == null)
            {
                throw new Exception("The parameter calculationModel is null");
            }

            var netPresentValue = Convert.ToDecimal(_calculationService.CalculateNetPresentValue(calculationModel));

            var presentValueOfCashFlows = netPresentValue + calculationModel.InitialCost;

            var previousResult = new PreviousResult();

            previousResult.LifeOfProject           = calculationModel.LifeOfProject;
            previousResult.InitialCost             = calculationModel.InitialCost;
            previousResult.LowerBoundDiscountRate  = calculationModel.LowerBoundDiscountRate;
            previousResult.UpperBoundDiscountRate  = calculationModel.UpperBoundDiscountRate;
            previousResult.DiscountRateIncrement   = calculationModel.DiscountRateIncrement;
            previousResult.NetPresentValue         = netPresentValue;
            previousResult.PresentValueOfCashFlows = presentValueOfCashFlows;

            calculationModel?.CashFlows?.ForEach(x =>
            {
                previousResult.CashFlows.Add(new CashFlows {
                    Year  = x.Year,
                    Value = x.Value
                });
            });

            previousResult.CreatedDate = DateTime.UtcNow;

            _npvContext.AddPreviousResults(previousResult);

            var saveChangesResult = await _npvContext.SaveEntityChangesAsync();

            if (saveChangesResult > 0)
            {
                return(Ok(new { Success = true }));
            }

            return(StatusCode((int)HttpStatusCode.InternalServerError));
        }
コード例 #4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "XML Data Set (.xml)|*.xml";

            if (openFileDialog.ShowDialog( ) != true)
            {
                return;
            }

            XmlDocument doc = new XmlDocument();

            doc.Load(openFileDialog.FileName);

            int     current_Person_ID = 0;
            Athlete athlete           = new Athlete();

            //CSDB context = ChampionshipSolutions.FileIO.FConnFile.getContext();

            foreach (XmlElement row in doc.ChildNodes[1].ChildNodes [1].ChildNodes)
            {
                //if (current_Person_ID == 0) current_Person_ID = int.Parse(row.Attributes["People_ID"].Value);

                if (current_Person_ID != int.Parse(row.Attributes ["People_ID"].Value))
                {
                    //FileIO.FConnFile.SaveChanges();

                    // new person
                    athlete = new Athlete( );

                    athlete.ID = int.Parse(row.Attributes ["People_ID"].Value);

                    current_Person_ID = athlete.ID;

                    athlete.FirstName  = row.Attributes ["FirstName"].Value;
                    athlete.MiddleName = row.Attributes ["MiddleName"].Value;
                    athlete.LastName   = row.Attributes ["LastName"].Value;

                    System.Diagnostics.Debug.WriteLine("New Athlete: " + athlete.Fullname);

                    athlete.Gender = (Gender)int.Parse(row.Attributes ["Gender"].Value);

                    if (!string.IsNullOrWhiteSpace(row.Attributes ["DateOfBirth"].Value))
                    {
                        athlete.DateOfBirth = DateTime.Parse(row.Attributes ["DateOfBirth"].Value);
                    }

                    if (!string.IsNullOrWhiteSpace(row.Attributes ["phoneNumber"].Value))
                    {
                        athlete.AddContact(new PhoneContactDetail( )
                        {
                            phoneNumber = row.Attributes ["phoneNumber"].Value
                        });
                    }

                    if (!string.IsNullOrWhiteSpace(row.Attributes ["SchoolCode"].Value))
                    {
                        //athlete.Attends = context.Schools.ToArray( ).Where( s => s.ShortName == row.Attributes [ "SchoolCode" ].Value ).FirstOrDefault( );
                        athlete.Attends = FileIO.FConnFile.GetFileDetails().IO.GetAll <School>().ToArray( ).Where(s => s.ShortName == row.Attributes ["SchoolCode"].Value).FirstOrDefault( );

                        if (athlete.Attends == null)
                        {
                            System.Diagnostics.Debug.WriteLine("Failed to find school: " + row.Attributes ["School"].Value);
                        }
                    }

                    FileIO.FConnFile.GetFileDetails( ).IO.Add <Person>(athlete);
                }

                PreviousResult pr = new PreviousResult(athlete, DateTime.Now);

                pr.Championship = row.Attributes ["Championship"].Value;
                pr.Venue        = row.Attributes ["ChampionshipLocation"].Value;
                pr.Team         = row.Attributes ["Team"].Value;
                pr.Event        = row.Attributes ["Event"].Value;
                pr.Rank         = row.Attributes ["Rank"].Value;

                if (!string.IsNullOrWhiteSpace(row.Attributes ["Value_RawValue"].Value))
                {
                    pr.Event = row.Attributes ["EventIfHeat"].Value;

                    ResultValue rv = new ResultValue((ResultDisplayDescription)int.Parse(row.Attributes["Value_ValueType"].Value));
                    rv.setResult(int.Parse(row.Attributes ["Value_RawValue"].Value));

                    pr.ResultValue = rv.ToString( );
                }

                athlete.AddNote(pr);



                //< FIELD FieldName = "School" DisplayLabel = "School" FieldType = "String" FieldClass = "TField" />

                //< FIELD FieldName = "Event_ID" DisplayLabel = "Event_ID" FieldType = "Integer" FieldClass = "TField" />
                //< FIELD FieldName = "VestNumber" DisplayLabel = "VestNumber" FieldType = "String" FieldClass = "TField" />
                //< FIELD FieldName = "EventIDIfHeat" DisplayLabel = "EventIDIfHeat" FieldType = "Integer" FieldClass = "TField" />
                //< FIELD FieldName = "FinalEventID" DisplayLabel = "FinalEventID" FieldType = "Integer" FieldClass = "TField" />
                //< FIELD FieldName = "TypeDescriminator" DisplayLabel = "TypeDescriminator" FieldType = "Integer" FieldClass = "TField" />
                //< FIELD FieldName = "ContactName" DisplayLabel = "ContactName" FieldType = "String" FieldClass = "TField" />
            }

            //FileIO.FConnFile.SaveChanges( );
        }
コード例 #5
0
 public void AddPreviousResults(PreviousResult previousResult)
 {
     PreviousResults.Add(previousResult);
 }