Exemplo n.º 1
0
        public EquipmentModel GetEquipment(string equipmentId)
        {
            var equipment = new EquipmentModel();

            equipment.EquipmentId = equipmentId;

            var dtEquipment = new DalEquipment().GetEquipment(equipmentId);

            if (dtEquipment.Rows.Count == 0)
            {
                return(equipment);
            }


            equipment.EquipmentName = dtEquipment.Rows[0]["EquipmentName"].ToString();

            if (dtEquipment.Rows[0]["DTUID"] == null || string.IsNullOrEmpty(dtEquipment.Rows[0]["DTUID"].ToString()))
            {
                return(equipment);
            }

            equipment.Items = new List <ItemModel>();
            for (var i = 2; i < dtEquipment.Columns.Count; i++)
            {
                equipment.Items.Add(new ItemModel {
                    Name = dtEquipment.Columns[i].ColumnName, Value = dtEquipment.Rows[0][i].ToString()
                });
            }


            return(equipment);
        }
 public Equipment MapToOrm(DalEquipment entity)
 {
     return(new Equipment
     {
         id = entity.Id,
         checkDate = entity.CheckDate,
         isChecked = entity.IsChecked,
         nextTechnicalCheckDate = entity.NextTechnicalCheckDate,
         numberOfTechnicalCheck = entity.NumberOfTechnicalCheck,
         technicalCheckDate = entity.TechnicalCheckDate,
         factoryNumber = entity.FactoryNumber,
         name = entity.Name,
         pressmark = entity.Pressmark,
         type = entity.Type,
     });
 }
Exemplo n.º 3
0
        public BllEquipment MapToBll(DalEquipment entity)
        {
            BllEquipment bllEntity = new BllEquipment
            {
                Id                     = entity.Id,
                CheckDate              = entity.CheckDate,
                IsChecked              = entity.IsChecked,
                FactoryNumber          = entity.FactoryNumber,
                Name                   = entity.Name,
                NextTechnicalCheckDate = entity.NextTechnicalCheckDate,
                NumberOfTechnicalCheck = entity.NumberOfTechnicalCheck,
                Pressmark              = entity.Pressmark,
                TechnicalCheckDate     = entity.TechnicalCheckDate,
                Type                   = entity.Type
            };

            return(bllEntity);
        }
Exemplo n.º 4
0
        public DalEquipment MapToDal(BllEquipment entity)
        {
            DalEquipment dalEntity = new DalEquipment
            {
                Id                     = entity.Id,
                CheckDate              = entity.CheckDate,
                IsChecked              = entity.IsChecked.Value,
                FactoryNumber          = entity.FactoryNumber,
                Name                   = entity.Name,
                NextTechnicalCheckDate = entity.NextTechnicalCheckDate,
                NumberOfTechnicalCheck = entity.NumberOfTechnicalCheck,
                Pressmark              = entity.Pressmark,
                TechnicalCheckDate     = entity.TechnicalCheckDate,
                Type                   = entity.Type
            };

            return(dalEntity);
        }
        /// <summary>
        /// This method returns account and statement information for the given account.
        /// </summary>
        /// <param name="siteId"></param>
        /// <param name="setTopBoxId"></param>
        /// <returns></returns>
        public Account InquireAccount([RequiredItem()] int siteId, [RequiredItem()][StringLength(1, 16)] string setTopBoxId)
        {
            BillingLogEntry logEntry = new BillingLogEntry(eBillingActivityType.AccountInquiry, siteId, setTopBoxId);

            using (Log log = CreateLog(logEntry))
            {
                try
                {
                    // validate the parameters.
                    MethodValidator validator = new MethodValidator(MethodBase.GetCurrentMethod(), siteId, setTopBoxId);
                    validator.Validate();

                    //look up the sitecode
                    string siteCode = DalSiteCode.Instance.GetSiteCode(siteId);

                    //get account number
                    string       accountNumber9 = null;
                    DalEquipment dalEquipment   = new DalEquipment();
                    accountNumber9 = dalEquipment.GetAccountFromSetTopBoxId(siteId, siteCode,
                                                                            setTopBoxId).PadLeft(9, '0');

                    if (accountNumber9 == null || accountNumber9 == string.Empty)
                    {
                        throw new InvalidSetTopBoxIdException(string.Format(
                                                                  __setTopBoxIdToAccountNumberException, setTopBoxId));
                    }

                    //look up division for this account
                    DalAccount dalAccount = new DalAccount();
                    CompanyDivisionFranchise companyDivisionFranchise = dalAccount.GetCompanyDivisionFranchise(siteId,
                                                                                                               siteCode, accountNumber9);

                    //turn accountNumber9 into accountNumber13
                    string accountNumber13 = companyDivisionFranchise.Company.ToString().PadLeft(2, '0') + companyDivisionFranchise.Division.ToString().PadLeft(2, '0') + accountNumber9;

                    // convert to CustomerAccountNumber
                    CustomerAccountNumber accountNumber = (CustomerAccountNumber)TypeDescriptor.GetConverter(
                        typeof(CustomerAccountNumber)).ConvertFrom(accountNumber13);

                    // get the siteid/sitecode information
                    PopulateSiteInfo(accountNumber);
                    logEntry.CustomerAccountNumber = accountNumber.AccountNumber16;

                    // setup return
                    Account account = new Account();

                    // setup adapter and fill account object.
                    AccountAdapter adapter = new AccountAdapter(accountNumber, _userName, _siteId, _siteCode);
                    adapter.Fill(account);

                    //set the AllowOnlineOrdering flag
                    SetAllowOnlineOrderingFlag(ref account);

                    // all done.
                    return(account);
                }
                catch (ValidationException ve)
                {
                    logEntry.SetError(ve.Message);
                    throw;
                }
                catch (BusinessLogicLayerException blle)
                {
                    logEntry.SetError(new ExceptionFormatter(blle).Format());
                    throw;
                }
                catch (DataSourceException de)
                {
                    logEntry.SetError(de.Message);
                    throw new DataSourceUnavailableException(de);
                }
                catch (Exception e)
                {
                    logEntry.SetError(e.Message);
                    throw new UnexpectedSystemException(e);
                }
            }
        }