Exemple #1
0
        public static TemplateInfoDto MockRecipeDetailTemplate()
        {
            TemplateInfoDto template = new TemplateInfoDto();
            template.HideTitle = false;

            List<ZoneInfoDto> zones = new List<ZoneInfoDto>();
            template.Zones = zones;

            // Recipe zone/block
            ZoneInfoDto zone1 = new ZoneInfoDto();
            zones.Add(zone1);
            zone1.Block = BlockDataProvider.MockRecipeDetail();

            ZoneInfoDto zone3 = new ZoneInfoDto();
            zones.Add(zone3);
            zone3.Style = CmsRegister.RIGHT_RAIL_STYLE;
            zone3.Block = BlockDataProvider.MockAdWidget();

            ZoneInfoDto zone2 = new ZoneInfoDto();
            zones.Add(zone2);
            zone2.Style = CmsRegister.RIGHT_RAIL_STYLE;
            zone2.Block = BlockDataProvider.MockRelatedContent();

            return template;
        }
Exemple #2
0
        public static TemplateInfoDto MockHomeTemplate()
        {
            TemplateInfoDto template = new TemplateInfoDto();
            template.HideTitle = true;
            template.Name = "Complex Home";

            List<ZoneInfoDto> zones = new List<ZoneInfoDto>();
            template.Zones = zones;

            //ZoneInfoDto zone1 = new ZoneInfoDto();
            //zones.Add(zone1);
            //zone1.Block = BlockDataProvider.MockRotator();
            //zone1.Style = CmsRegister.FULL_WIDTH_STYLE;

            //ZoneInfoDto zone2 = new ZoneInfoDto();
            //zones.Add(zone2);
            //zone2.Block = BlockDataProvider.MockFeaturedContent();

            //ZoneInfoDto zone3 = new ZoneInfoDto();
            //zones.Add(zone3);
            //zone3.Block = BlockDataProvider.MockFeaturedContent2nd();

            //ZoneInfoDto zone4 = new ZoneInfoDto();
            //zones.Add(zone4);
            //zone4.Style = CmsRegister.RIGHT_RAIL_STYLE;
            //zone4.Block = BlockDataProvider.MockAdWidget();

            return template;
        }
Exemple #3
0
        public TemplateInfoDto GetTemplateInfoByTemplateIdAndSpecId(int input, int[] specId)
        {
            var item = _tplRepostitory.Single(x => x.Id == input);

            if (item != null)
            {
                BaseInfoDto tplBaseInfo = new BaseInfoDto()
                {
                    Id    = item.Id,
                    Name  = item.TplName,
                    Count = 1
                };
                List <TplSpecimen> specList = new List <TplSpecimen>();
                if (specId.Contains(-1) || specId.Length == 0)
                {
                    specList = _tplSpecRepostitory.GetAll().Where(x => x.TplId == item.Id && x.IsDeleted == false).OrderBy(x => x.OrderNum).ToList();
                }
                else
                {
                    specList = _tplSpecRepostitory.GetAll().Where(x => x.TplId == item.Id && x.IsDeleted == false && specId.Contains(x.Id)).OrderBy(x => x.OrderNum).ToList();
                }

                var specIdList = specList.Select(x => x.Id).ToArray();
                var eleList    = _tplEleRepostitory.GetAll().Where(x => specIdList.Contains(x.TplSpecId) && x.IsDeleted == false)
                                 .OrderBy(x => x.TplSpecId).ToList();

                List <BaseInfoDto> specInfoList = new List <BaseInfoDto>();
                List <BaseInfoDto> eleInfoList  = new List <BaseInfoDto>();

                foreach (var specItem in specList)
                {
                    var tempEleList = eleList.Where(x => x.TplSpecId == specItem.Id).Select(x => new BaseInfoDto()
                    {
                        Id       = x.Id,
                        Name     = x.ElementName + (String.IsNullOrEmpty(x.UnitName) ? string.Empty : "(" + x.UnitName + ")"),
                        Count    = 1,
                        OrderNum = x.OrderNo
                    }).OrderBy(x => x.OrderNum).ToList();
                    BaseInfoDto tempSpecInfo = new BaseInfoDto()
                    {
                        Id    = specItem.Id,
                        Name  = specItem.SpecName,
                        Count = tempEleList.Count() == 0 ? 1 : tempEleList.Count()
                    };
                    specInfoList.Add(tempSpecInfo);
                    eleInfoList.InsertRange(eleInfoList.Count(), tempEleList);
                }

                TemplateInfoDto tplInfoDto = new TemplateInfoDto()
                {
                    Template  = tplBaseInfo,
                    Specimens = specInfoList,
                    Elements  = eleInfoList,
                };
                return(tplInfoDto);
            }
            return(null);
        }
Exemple #4
0
        public DataSearchTableDto GetDataInfoByTemplateIdAndSpecId(int input, int[] specId, DateTime begin, DateTime endTime)
        {
            begin   = begin.ToLocalTime();
            endTime = endTime.ToLocalTime();

            var query = _typeInRepository.GetAll()
                        .Where(x => x.TplId == input && string.Compare(x.SamplingDate, begin.ToString("yyyy-MM-dd")) >= 0 && string.Compare(x.SamplingTime, endTime.ToString("yyyy-MM-dd")) <= 0);

            if (!specId.Contains(-1))
            {
                query = query.Where(x => specId.Contains(x.SpecId));
            }

            var typeInList = query
                             .OrderByDescending(x => x.SamplingDate)
                             .ToList();

            List <List <string> > strList    = new List <List <string> >();
            TemplateInfoDto       schemaInfo = this.GetTemplateInfoByTemplateIdAndSpecId(input, specId);

            if (typeInList.Count() > 0)
            {
                var idArray = typeInList.Select(x => x.Id);

                var typeGrpList = typeInList.GroupBy(x => new { x.SamplingDate, x.SamplingTime })
                                  .ToList();

                var typeItemList = _typeInItemRepository.GetAll()
                                   .Where(x => !x.IsDeleted && idArray.Contains(x.TypeInId))
                                   .ToList();

                // 分组整理数据
                foreach (var item in typeGrpList)
                {
                    var tempTypeIn = typeInList.Where(x => x.SamplingDate == item.Key.SamplingDate && x.SamplingTime == item.Key.SamplingTime).ToList();
                    if (tempTypeIn.Count() > 0)
                    {
                        List <string> tempRow = GetSingleRow(tempTypeIn, typeItemList, schemaInfo, item.Key.SamplingDate, item.Key.SamplingTime);
                        strList.Add(tempRow);
                    }
                }
            }

            if (strList.Count > 1)
            {
                List <string> statisticRow = GetStatisticRow(strList);
                strList.Add(statisticRow);
            }

            return
                (new DataSearchTableDto()
            {
                TableHead = schemaInfo,
                TableData = strList
            });
        }
 public TemplateInfoDto GetTemplate(object templateId)
 {
     using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CMSDataStoreKey))
     {
         uow.BeginTransaction();
         TemplateFacade  facade = new TemplateFacade(uow);
         TemplateInfoDto result = facade.GetTemplateInfo(templateId, new TemplateInfoConverter());
         return(result);
     }
 }
        public TemplateInfoDto GetTemplate(object templateId)
        {
            TemplateInfoDto template = new TemplateInfoDto();

            template.Categorys = CategoryDataProvider.MockCategories();

            template.Keywords = KeywordDataProvider.MockKeywords();

            return(template);
        }
 public IFacadeUpdateResult <TemplateData> SaveTemplateCategorys(TemplateInfoDto template)
 {
     using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CMSDataStoreKey))
     {
         uow.BeginTransaction();
         TemplateFacade facade = new TemplateFacade(uow);
         // TODO: implement after cms
         IFacadeUpdateResult <TemplateData> result = new FacadeUpdateResult <TemplateData>();
         return(result);
     }
 }
Exemple #8
0
        private TemplateInfoDto GetSingleTemplateSchema(int tplId, int[] specIds)
        {
            var item = _tplRepostitory.Single(x => x.Id == tplId);

            if (item != null)
            {
                BaseInfoDto tplBaseInfo = new BaseInfoDto()
                {
                    Id    = item.Id,
                    Name  = item.TplName,
                    Count = 1
                };
                List <TplSpecimen> specList = new List <TplSpecimen>();
                specList = _tplSpecRepostitory.GetAll().Where(x => x.TplId == item.Id && specIds.Contains(x.Id) && x.IsDeleted == false).OrderBy(x => x.OrderNum).ToList();

                var specIdList = specList.Select(x => x.Id).ToArray();
                var eleList    = _tplEleRepostitory.GetAll().Where(x => specIdList.Contains(x.TplSpecId) && x.IsDeleted == false)
                                 .OrderBy(x => x.TplSpecId).ToList();

                List <BaseInfoDto> specInfoList = new List <BaseInfoDto>();
                List <BaseInfoDto> eleInfoList  = new List <BaseInfoDto>();

                int rowNum = 0;
                foreach (var specItem in specList)
                {
                    var tempEleList = eleList.Where(x => x.TplSpecId == specItem.Id).Select(x => new BaseInfoDto()
                    {
                        Id       = x.Id,
                        Name     = x.ElementName + (String.IsNullOrEmpty(x.UnitName) ? string.Empty : "(" + x.UnitName + ")"),
                        Count    = 1,
                        OrderNum = x.OrderNo
                    }).OrderBy(x => x.OrderNum).ToList();
                    BaseInfoDto tempSpecInfo = new BaseInfoDto()
                    {
                        Id    = specItem.Id,
                        Name  = specItem.SpecName,
                        Count = tempEleList.Count() == 0 ? 1 : tempEleList.Count()
                    };
                    rowNum += tempSpecInfo.Count;
                    specInfoList.Add(tempSpecInfo);
                    eleInfoList.InsertRange(eleInfoList.Count(), tempEleList);
                }
                tplBaseInfo.Count = rowNum;

                TemplateInfoDto tplInfoDto = new TemplateInfoDto()
                {
                    Template  = tplBaseInfo,
                    Specimens = specInfoList,
                    Elements  = eleInfoList,
                };
                return(tplInfoDto);
            }
            return(null);
        }
Exemple #9
0
        private void InitRecipeKeywordsAndCategories()
        {
            ITemplateService service  = ServiceLocator.Current.GetInstance <ITemplateService>();
            TemplateInfoDto  template = service.GetTemplate(CmsRegister.RECIPE_TEMPLATE_ID);

            foreach (KeywordDto item in template.Keywords)
            {
                RecipeKeywords.Add(item.Slug, item);
            }
            foreach (CategoryDto item in template.Categorys)
            {
                RecipeCategories.Add(item.Slug, item);
            }
        }
Exemple #10
0
        public static TemplateInfoDto MockPhotoGalleryTemplate()
        {
            TemplateInfoDto template = new TemplateInfoDto();
            template.HideTitle = false;

            List<ZoneInfoDto> zones = new List<ZoneInfoDto>();
            template.Zones = zones;

            ZoneInfoDto zone1 = new ZoneInfoDto();
            zones.Add(zone1);
            zone1.Block = BlockDataProvider.MockPhotoGallery();

            return template;
        }
Exemple #11
0
        public static TemplateInfoDto MockSubjectsListViewTemplate()
        {
            TemplateInfoDto template = new TemplateInfoDto();
            template.HideTitle = true;
            template.Name = "Subjects List View";

            List<ZoneInfoDto> zones = new List<ZoneInfoDto>();
            template.Zones = zones;

            ZoneInfoDto zone1 = new ZoneInfoDto();
            zones.Add(zone1);
            zone1.Block = BlockDataProvider.MockListViewWidget();

            return template;
        }
Exemple #12
0
        public static TemplateInfoDto MockYouTubeVideoTemplate()
        {
            TemplateInfoDto template = new TemplateInfoDto();
            template.HideTitle = false;

            List<ZoneInfoDto> zones = new List<ZoneInfoDto>();
            template.Zones = zones;

            ZoneInfoDto zone1 = new ZoneInfoDto();
            zones.Add(zone1);
            zone1.Block = BlockDataProvider.MockYouTubeVideo();

            ZoneInfoDto zone2 = new ZoneInfoDto();
            zones.Add(zone2);
            zone2.Style = CmsRegister.RIGHT_RAIL_STYLE;
            zone2.Block = BlockDataProvider.MockRelatedContent();

            return template;
        }
Exemple #13
0
        // 生成单行数据
        public List <string> GetSingleRow(List <TypeIn> typeInList, List <TypeInItem> typeItemList, TemplateInfoDto schema, string samplingDate, string samplingTime)
        {
            var           tempTypeInArray  = typeInList.Select(x => x.Id);
            var           tempTypeItemList = typeItemList.Where(x => tempTypeInArray.Contains(x.TypeInId)).ToList();
            int           eleIndex         = 0;
            List <string> strList          = new List <string>();

            strList.Add($"{samplingDate} {samplingTime}");
            //strList.Add(samplingTime);
            foreach (var specItem in schema.Specimens)
            {
                for (int i = 0; i < specItem.Count; i++)
                {
                    int        tempEleId = schema.Elements[i + eleIndex].Id;
                    TypeInItem tempItem  = tempTypeItemList.Where(x => x.SpecimenId == specItem.Id && x.ElementId == tempEleId).FirstOrDefault();
                    if (tempItem != null)
                    {
                        strList.Add(tempItem.EleValue);
                    }
                    else
                    {
                        strList.Add(string.Empty);
                    }
                }
                eleIndex += specItem.Count;
            }
            return(strList);
        }