Ejemplo n.º 1
0
        public override Region CloneEntity(ProductRule productRule, BaseEntity container)
        {
            RowHeaderRegion newRegion = new RowHeaderRegion(container as RegionTable)
            {
                _location = _location != null?_location.Clone() : null,
                                ColSpannable = ColSpannable,
                                RowSpannable = RowSpannable,
                                EmptyFill    = EmptyFill,
                                Field        = Field,
                                IsBasedOn    = IsBasedOn,
                                MaxLevel     = MaxLevel,
                                //HeaderBodyRelation = HeaderBodyRelation.Clone() as SourceRelation,
                                //HeaderTreeRelation = HeaderTreeRelation.Clone() as SourceRelation,
                                //Source = Source.Clone() as Source,
                                //TreeSource = TreeSource.Clone() as TreeSource
            };

            if (Source != null)
            {
                newRegion.Source = productRule.GetSource(Source.Name);
            }
            if (HeaderBodyRelation != null)
            {
                newRegion.HeaderBodyRelation = HeaderBodyRelation.Clone(productRule);
            }
            //if (HeaderTreeRelation != null)
            //{
            //    newRegion.HeaderTreeRelation = HeaderTreeRelation.Clone(productRule);
            //}
            //if (TreeSource != null)
            //{
            //    newRegion.TreeSource = productRule.GetSource(TreeSource.Name) as TreeSource;
            //}
            return(newRegion);
        }
Ejemplo n.º 2
0
        private TreeSource parseTreeSource(string source, string mapping, ProductRule prod)
        {
            TreeSource treeSource = null;

            if (!string.IsNullOrEmpty(source) && source.Contains('.') &&
                !string.IsNullOrEmpty(mapping) && mapping.Contains(':'))
            {
                string name      = source.Split('.')[0];
                Source tmpSource = prod.GetSource(name);
                //treeSource = tmpSource != null ? tmpSource as TreeSource : new TreeSource(name);
                if (tmpSource == null)
                {
                    treeSource = new TreeSource(name);
                    prod.RegistSource(treeSource);
                }
                else if (tmpSource is TreeSource)
                {
                    treeSource = tmpSource as TreeSource;
                }
                else
                {
                    //替换原有Source
                    treeSource = new TreeSource(name);
                    prod.RegistSource(treeSource);
                }
                treeSource.ContentField  = source.Split('.')[1];
                treeSource.IdField       = mapping.Split(':')[0];
                treeSource.ParentIdField = mapping.Split(':')[1];
            }
            return(treeSource);
        }
Ejemplo n.º 3
0
        public void ProcessOrder(IEnumerable <IItem> items)
        {
            foreach (IItem item in items)
            {
                IRule rule;
                switch (item.ProductType)
                {
                case (int)ProductTypeEnum.Book:
                    rule = new ProductRule(item);
                    break;

                case (int)ProductTypeEnum.Video:
                    rule = new ProductRule(item);
                    break;

                case (int)ProductTypeEnum.Subscription:
                    rule = new MembershipRule(item);
                    break;

                default:
                    rule = null;
                    break;
                }

                if (rule != null)
                {
                    rule.CompleteRule();
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 导出Excel(用于Web)
        /// </summary>
        /// <param name="dataSet">数据集,DataSetName="产出物名称"</param>
        /// <param name="stream">流</param>
        public static void ExportForBS(DataSet dataSet, Stream stream)
        {
            ProductRule   productRule = GetProductRule(dataSet.DataSetName, true);
            ProductWriter writer      = ProductWriter.NewInstance(productRule, dataSet);

            writer.Export(stream);
        }
Ejemplo n.º 5
0
 private SourceRelation parseRelation(Source source, string tmpStr, ProductRule prod)
 {
     if (!string.IsNullOrEmpty(tmpStr))
     {
         string[]       values   = tmpStr.Split(':');
         SourceRelation relation = new SourceRelation();
         relation.Source = source;
         relation.Field  = values[0];
         if (values.Length > 0)
         {
             tmpStr = values[1];
             if (tmpStr.Contains('.'))
             {
                 relation.ReferecedField = tmpStr.Split('.')[1];
                 tmpStr = tmpStr.Split('.')[0];
                 relation.ReferecedSource = prod.RegistSource(tmpStr);
             }
             else
             {
                 relation.ReferecedField = tmpStr;
             }
         }
         return(relation);
     }
     return(null);
 }
Ejemplo n.º 6
0
        public void SetUp()
        {
            this._validator = new ProductRulesValidator();
            this._customer  = new Customer();

            this._rule = new ProductRule
            {
                ProductId = 1,
                RuleType  = ProductRuleType.MinimumIncome,
                RuleValue = 30000
            };

            this._products = new List <Product>()
            {
                new Product
                {
                    Name = "Barclaycard",
                    Apr  = 15.00m,
                    PromotionalMessage = "Just right.",
                    ImageUrl           = "/images/barclaycard.png",
                    Rules = new List <ProductRule>()
                    {
                        _rule,
                    }
                },
                new Product
                {
                    Name = "Vanquis",
                    Apr  = 30.15m,
                    PromotionalMessage = "That's the ticket.",
                    ImageUrl           = "/images/vanquiscard.png"
                }
            };
        }
Ejemplo n.º 7
0
        public static string GetTaskRelaName(string RelaType, string RelaCode)
        {
            string text4;

            try
            {
                string relaTypeName = "";
                string relaName     = "";
                switch (RelaType.ToUpper())
                {
                case "U":
                    relaTypeName = "单位工程";
                    relaName     = PBSRule.GetPBSUnitName(RelaCode);
                    break;

                case "B":
                    relaTypeName = "楼栋";
                    relaName     = ProductRule.GetBuildingName(RelaCode);
                    break;

                default:
                    relaTypeName = "一般工作项";
                    break;
                }
                text4 = ConcatTaskRelaName(relaTypeName, relaName);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text4);
        }
Ejemplo n.º 8
0
 public static void MapSalRoom(string ProjectCode)
 {
     try
     {
         EntityData entity = SalDAO.GetSalContractByProjectCode(ProjectCode);
         if (entity.HasRecord())
         {
             int count = entity.CurrentTable.Rows.Count;
             for (int i = 0; i < count; i++)
             {
                 entity.SetCurrentRow(i);
                 string contractCode = entity.GetString("ContractCode");
                 string chamberName  = entity.GetString("ChamberName");
                 string roomName     = entity.GetString("Room");
                 string roomCode     = ProductRule.GetRoomCodeByChamberRoomName(chamberName, roomName, ProjectCode);
                 if (roomCode != entity.GetString("RoomCode"))
                 {
                     entity.CurrentTable.Rows[i]["RoomCode"] = roomCode;
                     SalDAO.UpdateSalContract(entity);
                 }
                 UpdateRoomSalState(roomCode, contractCode);
             }
         }
         entity.Dispose();
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 导出Excel
        /// </summary>
        /// <param name="dataSet">数据集,DataSetName="产出物名称"</param>
        /// <param name="exportfile">绝对路径;导出文件名</param>
        public static void Export(DataSet dataSet, string exportfile)
        {
            ProductRule productRule = _config.GetRules(dataSet.DataSetName, true);

            MatchExcelVersion(productRule, ref exportfile);
            ProductWriter writer = ProductWriter.NewInstance(productRule, dataSet);

            writer.Export(exportfile);
        }
Ejemplo n.º 10
0
        private static EntityData ImportSalContractByClient(string ClientCode, string ProjectCode, DataSet dsSrc, StandardEntityDAO dao)
        {
            EntityData data2;

            try
            {
                DataTable table = dsSrc.Tables["Contract"];
                dao.EntityName = "SalContract";
                EntityData entitydata = new EntityData("SalContract");
                string[]   Params     = new string[] { "@ClientCode" };
                object[]   values     = new object[] { ClientCode };
                dao.FillEntity(SqlManager.GetSqlStruct("SalContract", "SelectByClient").SqlString, Params, values, entitydata, "SalContract");
                if (entitydata.HasRecord())
                {
                    dao.DeleteAllRow(entitydata);
                    dao.DeleteEntity(entitydata);
                }
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    DataRow row          = entitydata.CurrentTable.NewRow();
                    DataRow row2         = table.Rows[i];
                    string  contractCode = row2["contract_code"].ToString();
                    row["ProjectCode"]  = ProjectCode;
                    row["ContractCode"] = contractCode;
                    row["ContractID"]   = row2["contract_id"];
                    row["ClientCode"]   = row2["client_code"];
                    row["ClientName"]   = row2["client_name"];
                    row["RoomCode"]     = row2["room_code"];
                    row["ContractDate"] = row2["contract_date"];
                    row["TotalPrice"]   = row2["total_price"];
                    row["FactPrice"]    = row2["fact_price"];
                    row["UnitPrice"]    = row2["unit_price"];
                    //row["Jiesuan"] = row2["jiesuan"];
                    // row["BofangCode"] = row2["bofang_code"];
                    row["ChamberName"]  = row2["chamber"];
                    row["BuildDim"]     = row2["build_dim"];
                    row["RoomDim"]      = row2["room_dim"];
                    row["Room"]         = row2["room"];
                    row["BuildingName"] = row2["build_name"];
                    //row["JiesuanDate"] = row2["jiesuan_date"];
                    string suplCodeByName = GetSuplCodeByName(GetSuplNameByContract(row["ContractID"].ToString(), 4), ProjectCode);
                    row["SuplCode"] = suplCodeByName;
                    string roomCode = ProductRule.GetRoomCodeByChamberRoomName(ConvertRule.ToString(row["ChamberName"]), ConvertRule.ToString(row["Room"]), ProjectCode);
                    row["RoomCode"] = roomCode;
                    UpdateRoomSalState(roomCode, contractCode);
                    entitydata.AddNewRecord(row);
                    dao.InsertEntity(entitydata);
                }
                data2 = entitydata;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(data2);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 实体复制
        /// </summary>
        /// <typeparam name="T">实体类</typeparam>
        /// <param name="list">实体类列表</param>
        /// <param name="productRule">规则实体</param>
        /// <param name="container">(上级)容器实体</param>
        /// <returns></returns>
        public static List <T> Clone <T>(this IList <T> list, ProductRule productRule, BaseEntity container) where T : ICloneable <T>, IRuleEntity
        {
            List <T> newList = new List <T>();

            for (int i = 0; i < list.Count; i++)
            {
                newList.Add((T)list[i].CloneEntity(productRule, container));
            }
            return(newList);
        }
Ejemplo n.º 12
0
        public override BaseEntity Clone(ProductRule productRule, BaseEntity container)
        {
            RegionTable newRegionTable = new RegionTable(productRule, container, (Location)_location.Clone())
            {
                Freeze = Freeze,
                //TempleteRows = TempleteRows
            };

            newRegionTable._regions = _regions.Clone(productRule, newRegionTable);
            return(newRegionTable);
        }
Ejemplo n.º 13
0
        protected override Cell CreateEntity()
        {
            BaseEntity  container = _upperElement.CurrentEntity;
            ProductRule prodRule  = container.ProductRule;

            _entity = new Cell(prodRule, container, new Location(_data.GetAttribute("location")));
            parseSource(_data.GetAttribute("source"));
            _entity.DataIndex   = ParseUtil.ParseInt(_data.GetAttribute("index"), 0);
            _entity.ValueAppend = ParseUtil.ParseBoolean(_data.GetAttribute("valueAppend"), false);
            _entity.Value       = ParseUtil.IfNullOrEmpty(_data.GetAttribute("value"));
            _entity.FillType    = ParseUtil.ParseEnum <FillType>(_data.GetAttribute("fill"), FillType.Origin);
            return(_entity);
        }
Ejemplo n.º 14
0
        public void BundleFactory_ProductA_1_50_GetFinalPrice_Returns_50()
        {
            var productARules = new List<IProductRule>();
            var productABasicRule = new ProductRule();
            productABasicRule.Set('A', 1, 50);
            productARules.Add(productABasicRule);

            var bundleFactory = new BundleFactory();
            var bundles = bundleFactory.MakeBundles('A', 1, productARules);

            Assert.IsNotNull(bundles);
            Assert.AreEqual(1, bundles.Count());
            Assert.AreEqual(50, bundles.FirstOrDefault().FinalPrice);
        }
Ejemplo n.º 15
0
        public void BundleFactory_Tests(char product, uint quantity, double finalPrice)
        {
            var productARules = new List<IProductRule>();
            var productABasicRule = new ProductRule();
            productABasicRule.Set(product, quantity, finalPrice);
            productARules.Add(productABasicRule);

            var bundleFactory = new BundleFactory();
            var bundles = bundleFactory.MakeBundles(product, quantity, productARules);

            Assert.IsNotNull(bundles);
            Assert.AreEqual(1, bundles.Count());
            Assert.AreEqual(50, bundles.FirstOrDefault().FinalPrice);
        }
Ejemplo n.º 16
0
        public void Checkout_ProductA_Returns_50()
        {
            //var productABasicRule = new Mock<IProductRule>();
            //productABasicRule.Setup(r => r.Set('A', 1, 50));

            var productABasicRule = new ProductRule();
            productABasicRule.Set('A', 1, 50);

            var checkout = new Checkout();
            checkout.AddProductRule(productABasicRule);

            var price = checkout.GetPrice("A");
            const double expectedPrice = 50;

            Assert.AreEqual(expectedPrice, price);
        }
Ejemplo n.º 17
0
        public override Region CloneEntity(ProductRule productRule, BaseEntity container)
        {
            BodyRegion newRegion = new BodyRegion(container as RegionTable)
            {
                _location = _location != null?_location.Clone() : null,
                                EmptyFill = EmptyFill,
                                Field     = Field,
                                //Source = Source.Clone() as Source
            };

            if (Source != null)
            {
                newRegion.Source = productRule.GetSource(Source.Name);
            }
            return(newRegion);
        }
        public void DatoIlSeguentoListinoPrezzi(Table table)
        {
            var productRules = ScenarioContext.Current.Retrieve<List<IProductRule>>("productRules");

            foreach (var row in table.Rows)
            {
                var prodotto = row["Prodotto"][0];
                var prezzo = Convert.ToDouble(row["Prezzo"]);

                var productRule = new ProductRule();
                productRule.Set(prodotto, 1, prezzo);

                productRules.Add(productRule);
            }

            ScenarioContext.Current.Update("productRules", productRules);
        }
        public void DatoLeSeguentiOfferte(Table table)
        {
            var productRules = ScenarioContext.Current.Retrieve<List<IProductRule>>("productRules");

            foreach (var row in table.Rows)
            {
                var prodotto = row["Prodotto"][0];
                var quantita = Convert.ToUInt16(row["Quantità"]);
                var prezzo = Convert.ToDouble(row["Prezzo"]);

                var productRule = new ProductRule();
                productRule.Set(prodotto, quantita, prezzo);

                productRules.Add(productRule);
            }

            ScenarioContext.Current.Update("productRules", productRules);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 调整Excel版本:
        /// 检查导出文件与模板文件的Excel版本一致:(用后缀名表示区分版本)
        /// ①如匹配,不处理;
        /// ②如不匹配,优先满足“导出文件路径”中指定的Excel版本,调整模板使用的Excel后缀;
        ///   如果此版本对应的Excel模板不存在,调整导出文件的后缀与模板一致。
        /// </summary>
        /// <param name="productRule">导出规则对象</param>
        /// <param name="exportfile">导出文件路径</param>
        private static void MatchExcelVersion(ProductRule productRule, ref string exportfile)
        {
            string tempFile  = productRule.Template;
            string tempExt   = new FileInfo(tempFile).Extension;
            string exportExt = new FileInfo(exportfile).Extension;

            if (!tempExt.ToLower().Equals(exportExt.ToLower()))
            {
                tempFile = tempFile.Replace(tempExt, exportExt);
                if (File.Exists(tempFile))
                {
                    productRule.Template = tempFile;
                }
                else
                {
                    exportfile = exportfile.Replace(exportExt, tempExt);
                }
            }
        }
Ejemplo n.º 21
0
        protected override DynamicArea CreateEntity()
        {
            Sheet       sheet    = _sheetElement.Entity;
            ProductRule prodRule = sheet.ProductRule;

            Location location = new Location(_data.GetAttribute("location"));

            _entity = new DynamicArea(prodRule, sheet, location);
            string tmpStr = _data.GetAttribute("source");

            _entity.SourceName = tmpStr;
            sheet.ProductRule.RegistSource(tmpStr);
            //_entity.Source = sheet.ProductRule.RegistSource(tmpStr);
            //_entity.AddCells(parseCell(_sheetElement.ProductRuleElement.QuerySubNodes("Cells/Cell", _data)));
            //_entity.AddTables(parseTable(_sheetElement.ProductRuleElement.QuerySubNodes("Tables/Table", _data)));
            _entity.AddCells(parseSubElement <CellElement, Cell>(_sheetElement.ProductRuleElement.QuerySubNodes("Cells/Cell", _data)));
            _entity.AddTables(parseSubElement <TableElement, Table>(_sheetElement.ProductRuleElement.QuerySubNodes("Tables/Table", _data)));
            return(_entity);
        }
Ejemplo n.º 22
0
        protected static ProductWriter CreateInstance(ProductRule productRule, bool excel2007 = false, DataSet datas = null, Action <IWorkbook, ProductRule> action = null)
        {
            ProductWriter writer = null;

            if (productRule != null)
            {
                writer             = new ProductWriter(productRule);
                writer.IsExcel2007 = excel2007;
                if (action != null)
                {
                    writer.BeforeLoadAction = action;
                }
                if (datas != null)
                {
                    writer.LoadData(datas);
                }
            }
            return(writer);
        }
Ejemplo n.º 23
0
        private bool ValidateRule(ProductRule rule, Customer customer)
        {
            bool valid = false;

            switch (rule.RuleType)
            {
            case ProductRuleType.MinimumIncome:
            {
                if (customer.AnnualIncome > rule.RuleValue)
                {
                    valid = true;
                }

                break;
            }
            }

            return(valid);
        }
Ejemplo n.º 24
0
        public void Setup()
        {
            var productRuleA1 = new ProductRule();
            productRuleA1.Set('A', 1, 50);

            var productRuleA3 = new ProductRule();
            productRuleA3.Set('A', 3, 130);

            var productRuleB1 = new ProductRule();
            productRuleB1.Set('B', 1, 30);

            var productRuleB2 = new ProductRule();
            productRuleB2.Set('B', 2, 45);

            var productRuleC1 = new ProductRule();
            productRuleC1.Set('C', 1, 20);

            var productRuleD1 = new ProductRule();
            productRuleD1.Set('D', 1, 15);

            _productRules = new List<IProductRule> {productRuleA1, productRuleA3, productRuleB1, productRuleB2, productRuleC1, productRuleD1};
        }
Ejemplo n.º 25
0
        protected override Field CreateEntity()
        {
            Table       table = _tableElement.Entity;
            ProductRule prod  = table.ProductRule;

            _entity               = new Field(table, _data.GetAttribute("name"));
            _entity.ColIndex      = ParseUtil.ParseColumnIndex(_data.GetAttribute("colIndex"), -1);
            _entity.Type          = ParseUtil.ParseEnum <FieldType>(_data.GetAttribute("type"), FieldType.Unknown);
            _entity.Format        = _data.GetAttribute("format");
            _entity.CommentColumn = _data.GetAttribute("annnotationField");
            _entity.RefColumn     = _data.GetAttribute("refField");
            _entity.LinkType      = _data.GetAttribute("linkType");
            string tmpStr = _data.GetAttribute("dropDownListSource");

            if (!string.IsNullOrEmpty(tmpStr))
            {
                Source tmpSource = prod.GetSource(tmpStr);

                /**
                 * dropDownListSource数据源要么引用预定义的DataList,要么指定了DataTable.Field;否则将被忽略
                 */
                if (tmpSource != null && tmpSource is ListSource)
                {
                    _entity.DropDownListSource = tmpSource as ListSource;
                }
                else if (tmpSource == null && tmpStr.Contains('.'))
                {
                    tmpSource = new ListSource(tmpStr.Split('.')[0], tmpStr.Split('.')[1]);
                    _entity.DropDownListSource = tmpSource as ListSource;
                    prod.RegistSource(tmpSource);
                }
            }
            _entity.Spannable = ParseUtil.ParseBoolean(_data.GetAttribute("spannable"), false);
            _entity.ColSpan   = ParseUtil.ParseInt(_data.GetAttribute("colspan"), 1);
            _entity.SumField  = ParseUtil.ParseBoolean(_data.GetAttribute("sumfield"), false);
            _entity.EmptyFill = _data.GetAttribute("emptyFill");
            return(_entity);
        }
Ejemplo n.º 26
0
        protected override RegionTable CreateEntity()
        {
            Sheet       sheet    = _sheetElement.Entity;
            ProductRule prodRule = sheet.ProductRule;

            Location tmpLocation = new Location(_data.GetAttribute("location"));

            _entity        = new RegionTable(prodRule, sheet, tmpLocation);
            _entity.Freeze = ParseUtil.ParseBoolean(_data.GetAttribute("freeze"), false);

            XmlNodeList regionNodes = _sheetElement.ProductRuleElement.QuerySubNodes("Region", _data);

            foreach (XmlElement regionNode in regionNodes)
            {
                Region region = new RegionElement(regionNode, this).Entity;
                if (region != null)
                {
                    _entity.AddRegion(region);
                }
            }
            _entity.LinkRegionSource();
            return(_entity);
        }
Ejemplo n.º 27
0
        public void BundleFactory_Tests(char product, string productRulesCsv, uint quantity, double finalPrice)
        {
            var productRules = new List<IProductRule>();
            var stringRules = productRulesCsv.Split(new []{';'}, StringSplitOptions.RemoveEmptyEntries);
            foreach (var stringRule in stringRules)
            {
                var stringRuleElemnts = stringRule.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries);

                uint bundleQuantity = 0;
                double bundleFinalPrice = 0;
                uint.TryParse(stringRuleElemnts[0], out bundleQuantity);
                double.TryParse(stringRuleElemnts[1], out bundleFinalPrice);

                var rule = new ProductRule();
                rule.Set(product, bundleQuantity, bundleFinalPrice);

                productRules.Add(rule);
            }

            var bundleFactory = new BundleFactory();
            var bundles = bundleFactory.MakeBundles(product, quantity, productRules);

            Assert.AreEqual(finalPrice, bundles.Sum(b => b.FinalPrice));
        }
Ejemplo n.º 28
0
        protected override Table CreateEntity()
        {
            BaseEntity  container = _upperElement.CurrentEntity;
            ProductRule prodRule  = container.ProductRule;

            Location tmpLocation = new Location(_data.GetAttribute("location"));

            _entity = new Table(prodRule, container, tmpLocation);
            string tmpStr = _data.GetAttribute("source");

            if (!string.IsNullOrEmpty(tmpStr))
            {
                _entity.SourceName = tmpStr;
                //只要不是动态解析的数据源,Source不能为空
                if ((container is Sheet && !(container as Sheet).IsDynamic) || !DynamicSource.NeedDynamicParse(tmpStr))
                {
                    //_entity.Source = prodRule.RegistSource(tmpStr);
                    prodRule.RegistSource(tmpStr);
                }
            }
            _entity.RowNumIndex   = ParseUtil.ParseColumnIndex(_data.GetAttribute("rowNumIndex"), -1);
            _entity.CopyFill      = ParseUtil.ParseBoolean(_data.GetAttribute("copyFill"), true);
            _entity.SumLocation   = ParseUtil.ParseEnum <LocationPolicy>(_data.GetAttribute("sumLocation"), LocationPolicy.Undefined);
            _entity.SumOffset     = ParseUtil.ParseInt(_data.GetAttribute("sumOffset"), _entity.SumLocation == LocationPolicy.Undefined || _entity.SumLocation == LocationPolicy.Absolute ? -1 : 0);
            _entity.AutoFitHeight = ParseUtil.ParseBoolean(_data.GetAttribute("autoFitHeight"), false);
            int groupLevel = ParseUtil.ParseInt(_data.GetAttribute("groupLevel"), 0);

            if (groupLevel > 0)
            {
                tmpStr = _data.GetAttribute("groupNumShow");
                if (!string.IsNullOrEmpty(tmpStr))
                {
                    bool[]   shows = new bool[groupLevel];
                    string[] bools = tmpStr.Split(',');

                    for (int i = 0; i < bools.Length && i < shows.Length; i++)
                    {
                        if (bool.Parse(bools[i]))
                        {
                            shows[i] = true;
                        }
                    }
                    _entity.SetGroup(shows);
                }
            }

            _entity.AdjustSumOffset();

            #region Field重复出现的处理
            List <Field> fieldlist = new List <Field>();
            tmpStr = _data.GetAttribute("fields");
            if (!string.IsNullOrEmpty(tmpStr))
            {
                string[] fieldArray = tmpStr.Split(',');
                foreach (var fieldname in fieldArray)
                {
                    fieldlist.Add(new Field(_entity, fieldname));
                }
            }
            _entity.AddFields(fieldlist);

            //子结点
            parseField(_upperElement.ProductRuleElement.QuerySubNodes("Field", _data));

            #endregion Field重复出现的处理

            // 行号处理
            parseRowNum(_upperElement.ProductRuleElement.QuerySubNodes("RowNum", _data));

            //区域计算:计算行号、字段的列位置,以及Table填充列范围
            _entity.CalculateArea();

            //汇总列:在确定字段位置之后处理
            tmpStr = _data.GetAttribute("sumColumns");
            if (!string.IsNullOrEmpty(tmpStr))
            {
                string[] columns = tmpStr.Split(',');
                _entity.AddSumColumns(columns);
            }
            return(_entity);
        }
Ejemplo n.º 29
0
 public static T ToModel <T>(this ProductRule entity) where T : class
 {
     return(Mapper.Map <ProductRule, T>(entity));
 }
Ejemplo n.º 30
0
 //public HeaderTable(Sheet sheet, Location location) : base(sheet, location) { }
 public RegionTable(ProductRule productRule, BaseEntity container, Location location) : base(productRule, container, location)
 {
 }
Ejemplo n.º 31
0
 //public abstract override object Clone();
 public abstract override Region CloneEntity(ProductRule productRule, BaseEntity container);
Ejemplo n.º 32
0
        protected override Region CreateEntity()
        {
            RegionTable table    = _regionTableElement.Entity;
            ProductRule prodRule = table.ProductRule;

            string tmpStr = _data.GetAttribute("type");

            if (string.IsNullOrEmpty(tmpStr))
            {
                return(null);
            }
            _entity = "corner".Equals(tmpStr.ToLower()) ? (Region) new CornerRegion(table) :
                      "rowheader".Equals(tmpStr.ToLower()) ? new RowHeaderRegion(table) :
                      "columnheader".Equals(tmpStr.ToLower()) ? (Region) new ColumnHeaderRegion(table) :
                      new BodyRegion(table);
            tmpStr = _data.GetAttribute("source");
            if (!string.IsNullOrEmpty(tmpStr))
            {
                string[] values = tmpStr.Split('.');
                if (values.Length > 1)
                {
                    _entity.Field = values[1];
                }
                _entity.Source = prodRule.RegistSource(values[0]);
            }
            _entity.EmptyFill = _data.GetAttribute("emptyFill");

            if (_entity is BodyRegion)
            {
                //暂无逻辑
            }
            else if (_entity is HeaderRegion)
            {
                HeaderRegion header = _entity as HeaderRegion;
                header.Source = parseTreeSource(tmpStr, _data.GetAttribute("innerMapping"), prodRule) ?? header.Source;

                tmpStr = _data.GetAttribute("headerBodyMapping");
                header.HeaderBodyRelation = parseRelation(header.Source, tmpStr, prodRule);
                //tmpStr = _data.GetAttribute("treeSource");
                //header.TreeSource = parseTreeSource(tmpStr, _data.GetAttribute("treeInnerMapping"), prodRule);
                ////header.IdField = element.GetAttribute("IdField");
                ////header.ParentField = element.GetAttribute("parentField");
                //tmpStr = _data.GetAttribute("headerTreeMapping");
                //header.HeaderTreeRelation = parseRelation(header.Source, tmpStr, prodRule);
                //if (header.HeaderTreeRelation != null)
                //{
                //    header.HeaderTreeRelation.ReferecedSource = header.TreeSource;
                header.MaxLevel     = ParseUtil.ParseInt(_data.GetAttribute("maxLevel"), -1);
                header.ColSpannable = ParseUtil.ParseBoolean(_data.GetAttribute("colSpannable"));
                header.RowSpannable = ParseUtil.ParseBoolean(_data.GetAttribute("rowSpannable"));
                header.IsBasedOn    = ParseUtil.ParseBoolean(_data.GetAttribute("basedSource"));
                //}
            }
            else if (_entity is CornerRegion)
            {
                tmpStr = _data.GetAttribute("spanRule");
                if (!string.IsNullOrEmpty(tmpStr))
                {
                    CornerSpanRule spanRule = CornerSpanRule.None;
                    if (!Enum.TryParse(tmpStr, true, out spanRule))
                    {
                        spanRule = "row".Equals(tmpStr.ToLower()) ? CornerSpanRule.BaseOnRowHeader :
                                   "column".Equals(tmpStr.ToLower()) ? CornerSpanRule.BaseOnColumnHeader :
                                   "one".Equals(tmpStr.ToLower()) ? CornerSpanRule.AllInOne : CornerSpanRule.None;
                    }
                    (_entity as CornerRegion).SpanRule = spanRule;
                }
            }
            return(_entity);
        }
Ejemplo n.º 33
0
 public static ProductWriter NewInstance(ProductRule productRule, DataSet datas, Action <IWorkbook, ProductRule> action = null)
 {
     return(CreateInstance(productRule, false, datas, action));
 }
Ejemplo n.º 34
0
 /// <summary>
 /// 构建ProductWriter实例
 /// </summary>
 /// <param name="productRule">Excel规则实体</param>
 /// <param name="excel2007">指定导出Excel格式(模板为空时有效)</param>
 /// <returns>ProductWriter实例</returns>
 public static ProductWriter NewInstance(ProductRule productRule, bool excel2007 = false)
 {
     return(CreateInstance(productRule, excel2007));
 }
Ejemplo n.º 35
0
 /// <summary>
 /// 构建产出物
 /// </summary>
 /// <param name="productType">产出物导出规则</param>
 public ProductWriter(ProductRule productType) : base(productType, null)
 {
 }