public async Task GetAllAsyncShouldReturnAllExistingTypes()
        {
            const int testBusinessTypesCount = 3;

            // Arrange
            this.FakeDb.Add(new BusinessType()
            {
                Id = 0, Name = TestBusinessTypeName
            });
            this.FakeDb.Add(new BusinessType()
            {
                Id = 1, Name = TestBusinessTypeName + 1
            });
            this.FakeDb.Add(new BusinessType()
            {
                Id = 2, Name = TestBusinessTypeName + 2
            });

            this.businessTypeService = new BusinessTypeService(this.GetMockedRepositoryReturningAllAsNoTracking());

            // Act
            var businessTypes = await this.businessTypeService.GetAllAsync <BusinessTypeTestViewModel>();

            // Assert
            Assert.Equal(testBusinessTypesCount, businessTypes.Count());
        }
 public CustomerFormController(CustomerForm instance)
 {
     this.frmCustomer     = instance;
     this.srvCustomer     = SamsaraAppContext.Resolve <ICustomerService>();
     this.srvBusinessType = SamsaraAppContext.Resolve <IBusinessTypeService>();
     this.InitializeFormControls();
 }
        /// <summary>
        /// 存储所需修改IssueReceiptD的数据集合的临时表
        /// </summary>
        private IDataEntityType CreateDTmpTable(IQueryService qrySrv)
        {
            string typeName = "Temp_UpdateSalesIssueD_" + DateTime.Now.ToString("HHmmssfff");// 临时表表名的处理
            DependencyObjectType defaultType = new DependencyObjectType(typeName, new Attribute[] { });
            IBusinessTypeService businessSrv = this.GetServiceForThisTypeKey <IBusinessTypeService>();

            #region 字段

            defaultType.RegisterSimpleProperty("item_no", businessSrv.SimpleItemCodeType, string.Empty, false, new Attribute[] { businessSrv.SimpleItemCode });

            defaultType.RegisterSimpleProperty("item_feature_no", businessSrv.SimpleItemFeatureType, string.Empty, false, new Attribute[] { businessSrv.SimpleItemFeature });

            defaultType.RegisterSimpleProperty("picking_unit_no", businessSrv.SimpleUnitCodeType, string.Empty, false, new Attribute[] { businessSrv.SimpleUnitCode });

            defaultType.RegisterSimpleProperty("doc_no", businessSrv.SimpleDocNoType, string.Empty, false, new Attribute[] { businessSrv.SimpleDocNo });

            SimplePropertyAttribute tempAttr = new SimplePropertyAttribute(GeneralDBType.Int32);
            defaultType.RegisterSimpleProperty("seq", typeof(Int32), 0, false, new Attribute[] { tempAttr });

            defaultType.RegisterSimpleProperty("warehouse_no", businessSrv.GetBusinessType("WarehouseCode"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("WarehouseCode") });

            defaultType.RegisterSimpleProperty("storage_spaces_no", businessSrv.GetBusinessType("Bin"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("Bin") });

            defaultType.RegisterSimpleProperty("lot_no", businessSrv.SimpleLotCodeType, string.Empty, false, new Attribute[] { businessSrv.SimpleLotCode });

            defaultType.RegisterSimpleProperty("picking_qty", businessSrv.SimpleQuantityType, 0M, false, new Attribute[] { businessSrv.SimpleQuantity });

            tempAttr = new SimplePropertyAttribute(GeneralDBType.String, 1000);
            defaultType.RegisterSimpleProperty("barcode_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr });

            #endregion

            qrySrv.CreateTempTable(defaultType);
            return(defaultType);
        }
Exemplo n.º 4
0
 public BusinessTypeController(
     IBusinessTypeService service,
     IBusinessTypeExpenseGroupService businessTypeExpenseGroup,
     IBusinessTypeCostOfSaleGroupService businessCostOfSaleService
     ) : base(service)
 {
     this.businessTypeExpenseGroup  = businessTypeExpenseGroup;
     this.businessCostOfSaleService = businessCostOfSaleService;
 }
        /// <summary>
        /// 创建存储传入参数集合的临时表
        /// </summary>
        private void CreateTemp()
        {
            IBusinessTypeService businessSrv = this.GetServiceForThisTypeKey <IBusinessTypeService>();

            string typeName = "Temp_Scan" + DateTime.Now.ToString("HHmmssfff");// 临时表表名的处理
            DependencyObjectType defaultType = new DependencyObjectType(typeName, new Attribute[] { });

            #region 单头
            defaultType.RegisterSimpleProperty("ID", businessSrv.SimplePrimaryKeyType, Maths.GuidDefaultValue(), false, new Attribute[] { businessSrv.SimplePrimaryKey });
            //人员
            defaultType.RegisterSimpleProperty("employee_no", businessSrv.GetBusinessType("BusinessCode"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("BusinessCode") });
            SimplePropertyAttribute tempAttr = new SimplePropertyAttribute(GeneralDBType.String);
            tempAttr.Size = 10;
            //部门
            defaultType.RegisterSimpleProperty("picking_department_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr });
            //工厂编号
            defaultType.RegisterSimpleProperty("site_no", businessSrv.GetBusinessType("Factory"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("Factory") });
            //信息批号
            tempAttr.Size = 30;
            defaultType.RegisterSimpleProperty("info_lot_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr });
            _tempScan = defaultType;
            _qurService.CreateTempTable(_tempScan);
            #endregion

            typeName    = "Temp_ScanDetail" + DateTime.Now.ToString("HHmmssfff");// 临时表表名的处理
            defaultType = new DependencyObjectType(typeName, new Attribute[] { });
            #region 单身
            defaultType.RegisterSimpleProperty("ID", businessSrv.SimplePrimaryKeyType, Maths.GuidDefaultValue(), false, new Attribute[] { businessSrv.SimplePrimaryKey });
            //信息批号
            tempAttr.Size = 30;
            defaultType.RegisterSimpleProperty("info_lot_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr });
            //序号
            tempAttr = new SimplePropertyAttribute(GeneralDBType.Int32);
            defaultType.RegisterSimpleProperty("SequenceNumber", typeof(Int32), 0, false, new Attribute[] { tempAttr });
            //品号
            defaultType.RegisterSimpleProperty("item_no", businessSrv.GetBusinessType("ItemCode"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("ItemCode") });
            //特征码
            defaultType.RegisterSimpleProperty("item_feature_no", businessSrv.GetBusinessType("ItemFeature"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("ItemFeature") });
            //单位
            defaultType.RegisterSimpleProperty("picking_unit_no", businessSrv.GetBusinessType("UnitCode"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("UnitCode") });
            //仓库
            defaultType.RegisterSimpleProperty("warehouse_no", businessSrv.GetBusinessType("WarehouseCode"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("WarehouseCode") });
            //库位
            defaultType.RegisterSimpleProperty("storage_spaces_no", businessSrv.GetBusinessType("Bin"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("Bin") });
            //批号
            defaultType.RegisterSimpleProperty("lot_no", businessSrv.GetBusinessType("LotCode"), string.Empty, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("LotCode") });
            //拣货数量
            defaultType.RegisterSimpleProperty("picking_qty", businessSrv.GetBusinessType("Quantity"), 0M, false, new Attribute[] { businessSrv.GetSimplePropertyAttribute("Quantity") });
            //条码编号
            tempAttr      = new SimplePropertyAttribute(GeneralDBType.String);
            tempAttr.Size = 1000;
            defaultType.RegisterSimpleProperty("barcode_no", typeof(string), string.Empty, false, new Attribute[] { tempAttr });
            _tempScanDetail = defaultType;
            _qurService.CreateTempTable(_tempScanDetail);
            #endregion
        }
        public async Task CreateBusinessTypeShouldWorkCorrectly()
        {
            // Arrange
            this.businessTypeService = new BusinessTypeService(this.GetMockedRepositoryWithCreateOperations());

            // Act
            var id = await this.businessTypeService.CreateAsync(TestBusinessTypeName);

            // Assert
            Assert.Single(this.FakeDb);
        }
Exemplo n.º 7
0
        public CustomerFormController(CustomerForm frmCustomer)
            : base(frmCustomer)
        {
            this.frmCustomer = frmCustomer;

            if (LicenseManager.UsageMode != LicenseUsageMode.Designtime)
            {
                this.srvCustomer     = SamsaraAppContext.Resolve <ICustomerService>();
                this.srvBusinessType = SamsaraAppContext.Resolve <IBusinessTypeService>();
            }
        }
Exemplo n.º 8
0
 public BusinessController(
     IBusinessService businessService,
     IBusinessTypeService businessTypeService,
     IShiftApplicationService shiftApplicationService,
     IShiftChangeService shiftChangeService,
     IEmployeeGroupService employeeGroupService)
 {
     this.businessService         = businessService;
     this.businessTypeService     = businessTypeService;
     this.shiftApplicationService = shiftApplicationService;
     this.shiftChangeService      = shiftChangeService;
     this.employeeGroupService    = employeeGroupService;
 }
Exemplo n.º 9
0
        private void CreateTempTable()
        {
            IBusinessTypeService businessTypeSrv = GetServiceForThisTypeKey <IBusinessTypeService>();

            #region 单头临时表
            string tempName = "Table_scan" + "_" + DateTime.Now.ToString("HHmmssfff");
            DependencyObjectType    defaultType = new DependencyObjectType(tempName, new Attribute[] { null });
            SimplePropertyAttribute tempAttr    = new SimplePropertyAttribute(GeneralDBType.String);
            #region 字段
            //营运据点
            defaultType.RegisterSimpleProperty("site_no", typeof(string),
                                               string.Empty, false, new Attribute[] { tempAttr });
            //条码编号
            defaultType.RegisterSimpleProperty("barcode_no", typeof(string),
                                               string.Empty, false, new Attribute[] { tempAttr });
            //料件编号
            defaultType.RegisterSimpleProperty("item_no", businessTypeSrv.GetBusinessType("ItemCode"),
                                               string.Empty, false, new Attribute[] { businessTypeSrv.GetSimplePropertyAttribute("ItemCode") });
            //产品特征
            defaultType.RegisterSimpleProperty("item_feature_no", businessTypeSrv.GetBusinessType("ItemFeature"),
                                               string.Empty, false, new Attribute[] { businessTypeSrv.GetSimplePropertyAttribute("ItemFeature") });
            //库位编号
            defaultType.RegisterSimpleProperty("warehouse_no", businessTypeSrv.GetBusinessType("WarehouseCode"),
                                               string.Empty, false, new Attribute[] { businessTypeSrv.GetSimplePropertyAttribute("WarehouseCode") });
            //储位编号
            defaultType.RegisterSimpleProperty("storage_spaces_no", businessTypeSrv.GetBusinessType("Bin"),
                                               string.Empty, false, new Attribute[] { businessTypeSrv.GetSimplePropertyAttribute("Bin") });
            //批号
            defaultType.RegisterSimpleProperty("lot_no", businessTypeSrv.GetBusinessType("LotCode"),
                                               string.Empty, false, new Attribute[] { businessTypeSrv.GetSimplePropertyAttribute("LotCode") });
            //盘点数量
            defaultType.RegisterSimpleProperty("qty", businessTypeSrv.GetBusinessType("Quantity"),
                                               0M, false, new Attribute[] { businessTypeSrv.GetSimplePropertyAttribute("Quantity") });
            //盘点人员
            defaultType.RegisterSimpleProperty("employee_no", businessTypeSrv.GetBusinessType("BusinessCode"),
                                               string.Empty, false, new Attribute[] { businessTypeSrv.GetSimplePropertyAttribute("BusinessCode") });
            //盘点日期
            defaultType.RegisterSimpleProperty("complete_date", typeof(DateTime),
                                               OrmDataOption.EmptyDateTime, false, new Attribute[] { new SimplePropertyAttribute(GeneralDBType.Date) });
            //交易对象类型
            defaultType.RegisterSimpleProperty("transaction_type", typeof(string),
                                               string.Empty, false, new Attribute[] { tempAttr });
            tempAttr.Size = 10;
            //交易对象编号
            defaultType.RegisterSimpleProperty("transaction_no", typeof(string),
                                               string.Empty, false, new Attribute[] { tempAttr });
            #endregion
            _Table_scan = defaultType;
            _qurService.CreateTempTable(_Table_scan);
            #endregion
        }
Exemplo n.º 10
0
Arquivo: Tools.cs Projeto: Ocun/VSTool
        public void creatTmp(string TypeKey, out DataTable dt, out DependencyObjectType targetType)
        {
            dt         = null;
            targetType = null;
            string[] spiltTypeKeys = null;
            bool     isColls       = false;
            string   primaryKey    = string.Empty;

            if (TypeKey.Contains(@"."))
            {
                spiltTypeKeys = TypeKey.Split(new[] { '.' });
                TypeKey       = spiltTypeKeys[0];
                primaryKey    = spiltTypeKeys[spiltTypeKeys.Length - 2];
                isColls       = true;
            }

            ICreateService createSrv = Provider.GetService(typeof(ICreateService), TypeKey) as ICreateService;

            if (createSrv == null)
            {
                return;
            }
            var entity = createSrv.Create() as DependencyObject;
            DependencyObjectType toType = entity.DependencyObjectType;

            if (isColls && spiltTypeKeys != null)
            {
                spiltTypeKeys.ToList().ForEach(key => {
                    if (!key.Equals(TypeKey))
                    {
                        toType =
                            ((ICollectionProperty)(toType.Properties[key])).ItemDataEntityType as DependencyObjectType;
                    }
                });
            }
            IBusinessTypeService businessTypeSrv =
                Provider.GetService(typeof(IBusinessTypeService), CallContext.TypeKey) as IBusinessTypeService;

            targetType = RegiesterType(toType, targetType);
            if (isColls)
            {
                string primaryKeyName = primaryKey + "_ID";

                targetType.RegisterSimpleProperty(primaryKeyName, businessTypeSrv.SimplePrimaryKeyType,
                                                  null, false, new Attribute[] {
                    businessTypeSrv.SimplePrimaryKey
                });
            }

            dt = CreateDt(targetType, dt);
        }
Exemplo n.º 11
0
 public StoreController(
     IAppUserService AppUserService,
     IDistrictService DistrictService,
     IOrganizationService OrganizationService,
     IProvinceService ProvinceService,
     IStatusService StatusService,
     IStoreGroupingService StoreGroupingService,
     IStoreStatusService StoreStatusService,
     IStoreTypeService StoreTypeService,
     IWardService WardService,
     IStoreService StoreService,
     IBusinessTypeService BusinessTypeService,
     IPositionService PositionService,
     IStoreDeliveryTimeService StoreDeliveryTimeService,
     IRelationshipCustomerTypeService RelationshipCustomerTypeService,
     IInfulenceLevelMarketService InfulenceLevelMarketService,
     IMarketPriceService MarketPriceService,
     IConsultingServiceService ConsultingServiceService,
     ICooperativeAttitudeService CooperativeAttitudeService,
     ICurrencyService CurrencyService,
     ICurrentContext CurrentContext
     , IHttpContextAccessor httpContextAccessor, DataContext _DataContext
     ) : base(httpContextAccessor, _DataContext)
 {
     this.AppUserService                  = AppUserService;
     this.DistrictService                 = DistrictService;
     this.OrganizationService             = OrganizationService;
     this.ProvinceService                 = ProvinceService;
     this.StatusService                   = StatusService;
     this.StoreGroupingService            = StoreGroupingService;
     this.StoreStatusService              = StoreStatusService;
     this.StoreTypeService                = StoreTypeService;
     this.WardService                     = WardService;
     this.StoreService                    = StoreService;
     this.BusinessTypeService             = BusinessTypeService;
     this.PositionService                 = PositionService;
     this.StoreDeliveryTimeService        = StoreDeliveryTimeService;
     this.RelationshipCustomerTypeService = RelationshipCustomerTypeService;
     this.InfulenceLevelMarketService     = InfulenceLevelMarketService;
     this.MarketPriceService              = MarketPriceService;
     this.ConsultingServiceService        = ConsultingServiceService;
     this.CooperativeAttitudeService      = CooperativeAttitudeService;
     this.CurrencyService                 = CurrencyService;
     this.CurrentContext                  = CurrentContext;
 }
Exemplo n.º 12
0
        /// <summary>
        /// 存储所需修改IssueReceiptD的数据集合的临时表
        /// </summary>
        private IDataEntityType CreateIssueReceiptDTmpTable(IQueryService qrySrv)
        {
            string typeName = "Temp_UpdateIssueReceiptD_" + DateTime.Now.ToString("HHmmssfff");// 临时表表名的处理
            DependencyObjectType defaultType = new DependencyObjectType(typeName, new Attribute[] { });

            IBusinessTypeService    businessSrv        = this.GetServiceForThisTypeKey <IBusinessTypeService>();
            SimplePropertyAttribute simplePrimaryAttri = businessSrv.SimplePrimaryKey;
            SimplePropertyAttribute qtyAttri           = businessSrv.SimpleQuantity;
            SimplePropertyAttribute tempAttr;

            #region 字段
            //单号
            tempAttr = new SimplePropertyAttribute(GeneralDBType.String);
            defaultType.RegisterSimpleProperty("DOC_NO", typeof(string), string.Empty, false, new Attribute[] { tempAttr });
            //序号
            tempAttr = new SimplePropertyAttribute(GeneralDBType.Int32);
            defaultType.RegisterSimpleProperty("SequenceNumber", typeof(int), 0, false, new Attribute[] { tempAttr });
            //拣货数量  //该数量等价于规格中的picking_qty
            defaultType.RegisterSimpleProperty("ISSUE_RECEIPT_QTY", businessSrv.SimpleQuantityType, 0m, false, new Attribute[] { qtyAttri });
            //工厂编号
            tempAttr = new SimplePropertyAttribute(GeneralDBType.String);
            defaultType.RegisterSimpleProperty("PLANT_CODE", typeof(string), string.Empty, false, new Attribute[] { tempAttr });
            //品号
            defaultType.RegisterSimpleProperty("ITEM_CODE", businessSrv.SimpleItemCodeType, "", false, new Attribute[] { businessSrv.SimpleItemCode });
            //特征码
            defaultType.RegisterSimpleProperty("ITEM_FEATURE_CODE", businessSrv.SimpleItemFeatureType, "", false, new Attribute[] { businessSrv.SimpleItemFeature });
            tempAttr = new SimplePropertyAttribute(GeneralDBType.String);
            //单位编号
            defaultType.RegisterSimpleProperty("UNIT_CODE", typeof(string), "", false, new Attribute[] { tempAttr });
            //仓库编号
            defaultType.RegisterSimpleProperty("WAREHOUSE_CODE", typeof(string), "", false, new Attribute[] { tempAttr });
            //库位编号
            defaultType.RegisterSimpleProperty("BIN_CODE", typeof(string), "", false, new Attribute[] { tempAttr });
            //批号
            defaultType.RegisterSimpleProperty("LOT_CODE", businessSrv.SimpleLotCodeType, "", false, new Attribute[] { businessSrv.SimpleLotCode });
            //条码
            defaultType.RegisterSimpleProperty("BARCODE_NO", typeof(string), "", false, new Attribute[] { tempAttr });
            #endregion

            qrySrv.CreateTempTable(defaultType);

            return(defaultType);
        }
Exemplo n.º 13
0
 public BusinessTypeForm()
 {
     InitializeComponent();
     this.ctrlBusinessTypeForm = new BusinessTypeFormController(this);
     this.srvBusinessType      = SamsaraAppContext.Resolve <IBusinessTypeService>();
 }
Exemplo n.º 14
0
        /// <summary>
        /// 简单属性的类型转换
        /// 将移动对应的实体的字符串类型统一转换为指定的数据类型
        /// </summary>
        /// <param name="sourceType">原数据类型</param>
        /// <param name="businessTypeService">业务服务接口</param>
        /// <returns></returns>
        public DependencyObjectType ConvertToDependencyObjectType(IDataEntityType sourceType, IBusinessTypeService businessTypeService)
        {
            DependencyObjectType newType = new DependencyObjectType(sourceType.Name);

            foreach (DependencyProperty property in sourceType.SimpleProperties)
            {
                if (_dateTimeProperties.Contains(property.Name))
                {
                    newType.RegisterSimpleProperty(property.Name, typeof(DateTime), OrmDataOption.EmptyDateTime
                                                   , false, new Attribute[] { new SimplePropertyAttribute(GeneralDBType.DateTime) });
                }
                else if (_decimalProperties.Contains(property.Name))
                {
                    newType.RegisterSimpleProperty(property.Name, businessTypeService.SimpleQuantityType, 0m
                                                   , false, new Attribute[] { businessTypeService.SimpleQuantity });
                }
                else if (_intProperties.Contains(property.Name))
                {
                    newType.RegisterSimpleProperty(property.Name, typeof(int), 0
                                                   , false, new Attribute[] { new SimplePropertyAttribute(GeneralDBType.Int32) });
                }
                else
                {
                    newType.RegisterSimpleProperty(property.Name, typeof(string), string.Empty
                                                   , false, new Attribute[] { new SimplePropertyAttribute(GeneralDBType.String) });
                }
            }

            return(newType);
        }
Exemplo n.º 15
0
 /// <summary>
 /// 组织新的数据类型
 /// </summary>
 /// <param name="sourceType">原数据类型</param>
 /// <param name="newType">新数据类型</param>
 /// <param name="businessTypeService"></param>
 public void BuildCollectionPorpertyType(IDataEntityType sourceType, IDataEntityType newType, IBusinessTypeService businessTypeService)
 {
     //集合属性需重新运用递归计算类型
     foreach (var subCollPro in sourceType.CollectionProperties)
     {
         DependencyObjectType subNewType = ConvertToDependencyObjectType(subCollPro.ItemDataEntityType, businessTypeService);
         (newType as DependencyObjectType).RegisterCollectionProperty(subCollPro.Name, subNewType);
         BuildCollectionPorpertyType(subCollPro.ItemDataEntityType, subNewType, businessTypeService);
     }
 }
Exemplo n.º 16
0
        /// <summary>
        /// 将移动传过来的实体的字符串类型统一转换为对应的具体类型
        /// 如:字符串的 2016/11/11 17:40:22 转换为对应的日期类型
        /// 后续业务就不用额外的转换了
        /// </summary>
        /// <param name="sourceColls">原集合</param>
        /// <param name="businessTypeService"></param>
        /// <returns>返回转换类型之后的新集合</returns>
        public DependencyObjectCollection ConvertToDependencyObjectCollection(DependencyObjectCollection sourceColls, IBusinessTypeService businessTypeService)
        {
            //组织新的数据类型
            DependencyObjectType newType = ConvertToDependencyObjectType(sourceColls.ItemDependencyObjectType, businessTypeService);

            BuildCollectionPorpertyType(sourceColls.ItemDependencyObjectType, newType, businessTypeService);

            //新集合
            DependencyObjectCollection newColl = new DependencyObjectCollection(newType);

            BuildCollectionValue(sourceColls, newColl);

            return(newColl);
        }
Exemplo n.º 17
0
Arquivo: Tools.cs Projeto: Ocun/VSTool
        /// <summary>
        /// 手动指定列名、类型 注册临时表
        /// </summary>
        /// <param name="businessTypeSrv"></param>
        /// <param name="formType"></param>
        /// <param name="targetType"></param>
        /// <returns></returns>
        public DependencyObjectType RegiesterType(
            List <RegiesterTypeParameter> formType, DependencyObjectType targetType)
        {
            if (targetType == null)
            {
                string tempTableName = "tmpYC_" + DateTime.Now.ToString("yyyyMMddHHmmssfff");
                targetType = new DependencyObjectType(tempTableName, new Attribute[] {});
            }
            IBusinessTypeService businessTypeSrv =
                Provider.GetService(typeof(IBusinessTypeService), CallContext.TypeKey) as IBusinessTypeService;
            SimplePropertyAttribute stringAttr = new SimplePropertyAttribute(GeneralDBType.String);
            SimplePropertyAttribute dtAttr     = new SimplePropertyAttribute(GeneralDBType.DateTime);
            SimplePropertyAttribute IntAttr    = new SimplePropertyAttribute(GeneralDBType.Int32);

            if (formType == null)
            {
                return(null);
            }

            formType.ToList().ForEach(prop => {
                Type prop_type = prop.Type;
                var prop_names = prop.Properties;
                foreach (var prop_name in prop_names)
                {
                    string typeName = prop_type.ToString();
                    var isExist     = targetType.Properties.FirstOrDefault(p => p.Name.Equals(prop_name));
                    if (isExist != null)
                    {
                        continue;
                    }
                    if (prop_name.EndsWith("_ID"))
                    {
                        targetType.RegisterSimpleProperty(prop_name, businessTypeSrv.SimplePrimaryKeyType,
                                                          Guid.Empty, false, new Attribute[] {
                            businessTypeSrv.SimplePrimaryKey
                        });
                    }
                    else if (prop_name.Equals("REMARK"))
                    {
                        targetType.RegisterSimpleProperty(prop_name, businessTypeSrv.SimpleRemarkType,
                                                          string.Empty, false, new Attribute[] {
                            businessTypeSrv.SimpleRemark
                        });
                    }
                    else
                    {
                        switch (typeName)
                        {
                        case "System.String":
                            targetType.RegisterSimpleProperty(prop_name, prop_type,
                                                              string.Empty, false, new Attribute[] { stringAttr });
                            break;

                        case "System.DateTime":
                            targetType.RegisterSimpleProperty(prop_name, prop_type,
                                                              OrmDataOption.EmptyDateTime, false, new Attribute[] { dtAttr });
                            break;

                        case "System.Int16":     //整型
                        case "System.Int32":
                        case "System.Int64":
                            targetType.RegisterSimpleProperty(prop_name, prop_type,
                                                              0, false, new Attribute[] { IntAttr });
                            break;

                        case "System.Decimal":     //浮点型
                        case "System.Double":
                            targetType.RegisterSimpleProperty(prop_name, businessTypeSrv.SimpleQuantityType,
                                                              0m, false, new Attribute[] { businessTypeSrv.SimpleQuantity });
                            break;

                        default:
                            targetType.RegisterSimpleProperty(prop_name, prop_type,
                                                              null, false, new Attribute[] {});
                            break;
                        }
                    }
                }
                ;
            });

            return(targetType);
        }
 /// <summary>
 /// 初始化全局变量
 /// </summary>
 private void InitParameters()
 {
     _querySrv        = GetService <IQueryService>();
     _businessTypeSrv = GetServiceForThisTypeKey <IBusinessTypeService>();
     _sysParameterSrv = GetService <ISysParameterService>();
 }
Exemplo n.º 19
0
Arquivo: Tools.cs Projeto: Ocun/VSTool
        //参考标准MO
        /// <summary>
        ///  根据DependencyObjectType创建簡單临时表结构
        /// </summary>
        /// <param name="formType">DependencyObject屬性</param>
        /// <param name="targetType"></param>
        /// <returns></returns>
        public DependencyObjectType RegiesterType(
            DependencyObjectType formType, DependencyObjectType targetType)
        {
            IBusinessTypeService businessTypeSrv =
                Provider.GetService(typeof(IBusinessTypeService), CallContext.TypeKey) as IBusinessTypeService;
            SimplePropertyAttribute stringAttr = new SimplePropertyAttribute(GeneralDBType.String);
            SimplePropertyAttribute dtAttr     = new SimplePropertyAttribute(GeneralDBType.DateTime);
            SimplePropertyAttribute IntAttr    = new SimplePropertyAttribute(GeneralDBType.Int32);

            if (targetType == null)
            {
                string tempTableName = "tmpYC_" + DateTime.Now.ToString("yyyyMMddHHmmssfff");
                targetType = new DependencyObjectType(tempTableName, new Attribute[] {});
            }

            if (formType == null)
            {
                return(null);
            }
            foreach (var prop in formType.Properties)
            {
                //临时表字段名不可大于30个字符,不是处理方式,后续补充
                string prop_name = prop.Name.Length > 30 ? prop.Name.Substring(0, 29) : prop.Name;


                var isExist = targetType.Properties.FirstOrDefault(p => p.Name.Equals(prop_name));
                if (isExist != null)
                {
                    continue;
                }
                //過濾管理字段 //批量插入有影响
                string[] cnames =
                {
                    "Version",
                    "CreateDate",    "LastModifiedDate",  "ModifiedDate",  "CreateBy",
                    "LastModifiedBy","ModifiedBy",        "ApproveStatus", "ApproveDate", "ApproveBy"
                };
                if (cnames.Contains(prop_name))
                {
                    continue;
                }

                Type prop_type = prop.PropertyType;

                if (prop_type == typeof(DependencyObject) ||
                    prop_type == typeof(DependencyObjectCollection))
                {
                    // 本次个案需要
                    try {
                        var flag = prop is IComplexProperty;
                        if (flag)
                        {
                            if (((IComplexProperty)(prop)).DataEntityType.Name == "ReferToEntity")
                            {
                                var cpropies = ((IComplexProperty)(prop)).DataEntityType.SimpleProperties;

                                if (cpropies != null)
                                {
                                    var existRTK =
                                        cpropies.ToList()
                                        .FirstOrDefault(
                                            cprop => cprop.Name.Equals("ROid") || cprop.Name.Equals("RTK"));
                                    if (existRTK != null)
                                    {
                                        string rtk_name  = prop_name + "_RTK";
                                        string roid_name = prop_name + "_ROid";
                                        targetType.RegisterSimpleProperty(rtk_name, typeof(string),
                                                                          string.Empty, false, new Attribute[] {
                                            stringAttr
                                        });

                                        targetType.RegisterSimpleProperty(roid_name,
                                                                          businessTypeSrv.SimplePrimaryKeyType,
                                                                          null, false, new Attribute[] {
                                            businessTypeSrv.SimplePrimaryKey
                                        });
                                    }
                                }
                            }
                        }
                    }
                    catch {
                    }
                }

                else if (prop_name.StartsWith("UDF"))
                {
                    continue;
                }

                else
                {
                    object DEFv = prop.DefaultValue;

                    if (prop_name.EndsWith("_ID"))
                    {
                        targetType.RegisterSimpleProperty(prop_name, businessTypeSrv.SimplePrimaryKeyType,
                                                          DEFv, false, new Attribute[] {
                            businessTypeSrv.SimplePrimaryKey
                        });
                    }
                    else if (prop_name.Equals("REMARK"))
                    {
                        targetType.RegisterSimpleProperty(prop_name, businessTypeSrv.SimpleRemarkType,
                                                          DEFv, false, new Attribute[] {
                            businessTypeSrv.SimpleRemark
                        });
                    }
                    else
                    {
                        string typeName = prop_type.ToString();
                        switch (typeName)
                        {
                        case "System.String":
                            targetType.RegisterSimpleProperty(prop_name, prop_type,
                                                              DEFv, false, new Attribute[] { stringAttr });
                            break;

                        case "System.DateTime":
                            targetType.RegisterSimpleProperty(prop_name, prop_type,
                                                              DEFv, false, new Attribute[] { dtAttr });
                            break;

                        case "System.Int16":     //整型
                        case "System.Int32":
                        case "System.Int64":
                            targetType.RegisterSimpleProperty(prop_name, prop_type,
                                                              DEFv, false, new Attribute[] { IntAttr });
                            break;

                        case "System.Decimal":     //浮点型
                        case "System.Double":
                            targetType.RegisterSimpleProperty(prop_name, businessTypeSrv.SimpleQuantityType,
                                                              DEFv, false, new Attribute[] { businessTypeSrv.SimpleQuantity });
                            break;

                        default:
                            targetType.RegisterSimpleProperty(prop_name, prop_type,
                                                              DEFv, false, new Attribute[] {});
                            break;
                        }
                    }
                }
            }
            return(targetType);
        }
 public BusinessTypeController(IBusinessTypeService businessType, ILoggerManager logger) {
     _businessTypeService = businessType;
     _loggerManager = logger;
 }
Exemplo n.º 21
0
 public BusinessTypeController(IBusinessTypeService businessTypeService)
 {
     this.businessTypeService = businessTypeService;
 }