Beispiel #1
0
        private IEnumerable <ReservationDateRangeItem> GetReservationDateRangeItems(DataTable dtToolDataClean)
        {
            var result = new List <ReservationDateRangeItem>();

            foreach (DataRow dr in dtToolDataClean.Rows)
            {
                result.Add(ReservationDateRangeItem.Create(
                               dr.Field <int>("ReservationID"),
                               dr.Field <int>("ResourceID"),
                               dr.Field <string>("ResourceName"),
                               dr.Field <int>("ProcessTechID"),
                               dr.Field <string>("ProcessTechName"),
                               dr.Field <int>("ClientID"),
                               dr.Field <string>("UserName"),
                               dr.Field <string>("LName"),
                               dr.Field <string>("FName"),
                               dr.Field <int>("ActivityID"),
                               dr.Field <string>("ActivityName"),
                               dr.Field <int>("AccountID"),
                               dr.Field <string>("AccountName"),
                               dr.Field <string>("ShortCode"),
                               dr.Field <int>("ChargeTypeID"),
                               dr.Field <bool>("IsActive"),
                               dr.Field <bool>("IsStarted"),
                               dr.Field <DateTime>("BeginDateTime"),
                               dr.Field <DateTime>("EndDateTime"),
                               dr.Field <DateTime>("ActualBeginDateTime"),
                               dr.Field <DateTime>("ActualEndDateTime"),
                               dr.Field <DateTime>("LastModifiedOn"),
                               dr.Field <DateTime?>("CancelledDateTime"),
                               dr.Field <double>("ChargeMultiplier"),
                               _costs));
            }

            return(result);
        }
Beispiel #2
0
        private IEnumerable <ReservationDateRangeItem> GetReservationDateRangeItems(DataTable dtToolDataClean, DateTime period, int resourceId)
        {
            var cutoff = period.AddMonths(1);

            var costs = Provider.Data.Cost.FindToolCosts(resourceId, cutoff);

            var result = new List <ReservationDateRangeItem>();

            DataTable dtAccounts;

            using (var conn = NewConnection())
                using (var cmd = new SqlCommand("SELECT acct.AccountID, acct.Name AS AccountName, acct.ShortCode, org.OrgID, ot.ChargeTypeID FROM sselData.dbo.Account acct INNER JOIN sselData.dbo.Org org ON org.OrgID = acct.OrgID INNER JOIN sselData.dbo.OrgType ot ON ot.OrgTypeID = org.OrgTypeID", conn)
                {
                    CommandType = CommandType.Text
                })
                    using (var adap = new SqlDataAdapter(cmd))
                    {
                        dtAccounts = new DataTable();
                        adap.Fill(dtAccounts);
                        dtAccounts.PrimaryKey = new[] { dtAccounts.Columns["AccountID"] };
                    }

            foreach (DataRow dr in dtToolDataClean.Rows)
            {
                var accountId = dr.Field <int>("AccountID");
                var drAcct    = dtAccounts.Rows.Find(accountId);

                if (drAcct == null)
                {
                    throw new Exception($"No Account found for AccountID = {accountId}");
                }

                result.Add(ReservationDateRangeItem.Create(
                               dr.Field <int>("ReservationID"),
                               dr.Field <int>("ResourceID"),
                               dr.Field <string>("ResourceName"),
                               dr.Field <int>("ProcessTechID"),
                               dr.Field <string>("ProcessTechName"),
                               dr.Field <int>("ClientID"),
                               dr.Field <string>("UserName"),
                               dr.Field <string>("LName"),
                               dr.Field <string>("FName"),
                               dr.Field <int>("ActivityID"),
                               dr.Field <string>("ActivityName"),
                               accountId,
                               drAcct.Field <string>("AccountName"),
                               drAcct.Field <string>("ShortCode"),
                               drAcct.Field <int>("ChargeTypeID"),
                               dr.Field <bool>("IsActive"),
                               dr.Field <bool>("IsStarted"),
                               dr.Field <DateTime>("BeginDateTime"),
                               dr.Field <DateTime>("EndDateTime"),
                               dr.Field <DateTime>("ActualBeginDateTime"),
                               dr.Field <DateTime>("ActualEndDateTime"),
                               dr.Field <DateTime>("LastModifiedOn"),
                               dr.Field <DateTime?>("CancelledDateTime"),
                               dr.Field <double>("ChargeMultiplier"),
                               costs));
            }

            return(result);
        }