Exemple #1
0
        public static MappingClass loadByReflection()
        {
            logger.Info("loadByReflection");
            IList        asmList = DbConfig.Instance.AssemblyList;
            MappingClass map     = new MappingClass();

            for (int i = 0; i < asmList.Count; i++)
            {
                Assembly assembly = ObjectContext.LoadAssembly(asmList[i].ToString());
                map.AssemblyList[asmList[i].ToString()] = assembly;
                Type[] typeArray = ObjectContext.FindTypes(asmList[i].ToString());
                foreach (Type type in typeArray)
                {
                    ResolveOneType(map, type);
                }
                logger.Info("loaded assembly: " + assembly.FullName);
            }
            logger.Info("FinishPropertyInfo");
            FinishPropertyInfo(map.ClassList);
            logger.Info("cacheInterceptor");
            cacheInterceptor(map);
            logger.Info("AccessorUtil.Init");
            MetaList list = new MetaList(map.AssemblyList, map.ClassList);

            map.FactoryList = AccessorUtil.Init(list);
            try
            {
                checkMultiDB(map);
            }
            catch (Exception ex)
            {
                logger.Info("初始化数据库出现错误:" + ex.Message);
            }
            return(map);
        }
Exemple #2
0
 private void MapAddressList(ICustomerVO sessionCustomer, ICustomerVO formCustomer)
 {
     if (formCustomer.AddressList.Count > 0)
     {
         foreach (IAddressVO formAddress in formCustomer.AddressList)
         {
             if (formAddress.Id == 0)
             {
                 formAddress.Customer = sessionCustomer;
                 sessionCustomer.AddressList.Add(formAddress);
             }
             else
             {
                 foreach (IAddressVO sessionAddress in sessionCustomer.AddressList)
                 {
                     if (formAddress.Id == sessionAddress.Id)
                     {
                         AccessorUtil.copyValue(formAddress, sessionAddress, AddressVO.EXCLUDE_COPY);
                         sessionAddress.LastUpdateBy   = sessionCustomer.LastUpdateBy;
                         sessionAddress.LastUpdateDate = DateTime.Now;
                     }
                 }
             }
         }
     }
 }
Exemple #3
0
        public ICompanyCustomerVO UpdateCompanyCustomer(
            ICompanyCustomerVO sessionCustomer, ICompanyCustomerVO formCustomer)
        {
            Logger.Debug("UpdateCompanyCustomer|Update an existing customer.");

            AccessorUtil.copyValue(formCustomer, sessionCustomer, CustomerVO.EXCLUDE_COPY);
            MapAddressList(sessionCustomer, formCustomer);

            if (string.IsNullOrEmpty(sessionCustomer.CifNumber))
            {
                // Should be message call to host system.
                sessionCustomer.CifNumber = "90000" + sessionCustomer.IdNumber;
            }

            return(CustomerDAO.SaveCompanyCustomer(sessionCustomer));
        }
        public ActionResult ProcessCallReport(CallReportViewModel model, ActionType actionType)
        {
            Logger.Debug("SaveCallReport|Action type: " + actionType);

            if (actionType == ActionType.Process)
            {
                try
                {
                    ICallReportVO callReport = (CallReportVO)
                                               CallReportMapper.Map(model, typeof(CallReportViewModel), typeof(CallReportVO));

                    ICallReportVO sessionCallReport = (ICallReportVO)Session["SessionCallReport"];
                    if (callReport.Id == 0 || sessionCallReport == null)
                    {
                        sessionCallReport = new CallReportVO();
                    }

                    AccessorUtil.copyValue(callReport, sessionCallReport, CallReportVO.EXCLUDE_COPY);

                    sessionCallReport.LastUpdateBy = User.Identity.Name;

                    ICustomerVO sessionCustomer = (ICustomerVO)Session["SessionCustomer"];
                    sessionCallReport.Customer = sessionCustomer;

                    sessionCallReport = CallReportManager.ProcessCallReport(sessionCallReport, model.Action);

                    model = (CallReportViewModel)
                            CallReportMapper.Map(sessionCallReport, typeof(ICallReportVO), typeof(CallReportViewModel));

                    Session["SessionCallReport"]   = sessionCallReport;
                    TempData["MessageType"]        = MessageType.Success;
                    TempData["MessageDescription"] = CommonResources.MessageSaveSuccess;
                }
                catch (Exception exception)
                {
                    Logger.Debug("Exception encountered: " + exception.StackTrace);

                    TempData["MessageType"]        = MessageType.Error;
                    TempData["MessageDescription"] = CommonResources.MessageSaveError + exception.Message;
                }

                TempData["CallReportDetailModel"] = model;
                return(RedirectToAction("ViewCallReportDetails"));
            }

            return(RedirectToAction("ViewCallReportList"));
        }
Exemple #5
0
        public IBusinessVO UpdateBusiness(IBusinessVO sessionBusiness, IBusinessVO formBusiness)
        {
            AccessorUtil.copyValue(formBusiness, sessionBusiness, BusinessVO.EXCLUDE_COPY);

            return(BusinessDAO.SaveBusiness(sessionBusiness));
        }
Exemple #6
0
 public Accessor GetFieldOrPropertyAccessor(Type targetType, string path)
 {
     return(AccessorUtil.GetAccessor(targetType, path));
 }
Exemple #7
0
 public Accessor GetPropertyAccessor(PropertyInfo property)
 {
     return(AccessorUtil.GetAccessor(property));
 }