コード例 #1
0
        public static ProjectBlockViewModel FromEnitity(ProjectBlock entity)
        {
            var detail = entity.ProjectBlockDetails.FirstOrDefault(o => o.Language == Omi.Base.Properties.Resources.DEFAULT_LANGUAGE);

            var viewModelResult = new ProjectBlockViewModel
            {
                Id           = entity.Id,
                Language     = detail.Language,
                Label        = detail.Label,
                EntityTypeId = entity.EntityTypeId,
                PackageId    = entity.PackageId,
                ParentId     = entity.PackageId,
                Children     = entity.Children?.Select(o => FromEnitity(o))
            };

            var layoutImageFileEntity = entity.ProjectBlockFiles.FirstOrDefault(o => o.UsingType == 0);

            if (layoutImageFileEntity != null)
            {
                viewModelResult.LayoutImage = FileEntityInfo.FromEntity(layoutImageFileEntity.FileEntity);
            }

            viewModelResult.LayoutPoints = entity.ProjectBlockFiles.Where(o => o.UsingType == 1).Select(o => {
                var obj   = Newtonsoft.Json.JsonConvert.DeserializeObject <LayoutPoint>(o.JsonData);
                obj.Image = FileEntityInfo.FromEntity(o.FileEntity);
                return(obj);
            });

            return(viewModelResult);
        }
コード例 #2
0
        public static ProjectServiceModel FromViewModel(ProjectViewModel viewModel)
        {
            var nestedProjectBlocks = viewModel.ProjectBlocks.Select(o => ProjectBlock.FromViewModel(o));

            nestedProjectBlocks = nestedProjectBlocks.Process((tower) =>
            {
                tower.ProjectId    = viewModel.Id;
                tower.EntityTypeId = EntityTypeSeed.Tower.Id;
                tower.Children     = tower.Children.Process(floor => {
                    floor.EntityTypeId = EntityTypeSeed.Floor.Id;
                    floor.Children     = floor.Children.Process(room =>
                    {
                        room.EntityTypeId = EntityTypeSeed.Room.Id;
                        return(room);
                    }).ToList();
                    return(floor);
                }).ToList();
                return(tower);
            });

            var taxonomyIds = new List <long>();

            if (viewModel.ProjectTypeId != default)
            {
                taxonomyIds.Add(viewModel.ProjectTypeId);
            }
            if (viewModel.ProjectStatusId != default)
            {
                taxonomyIds.Add(viewModel.ProjectStatusId);
            }

            return(new ProjectServiceModel
            {
                Id = viewModel.Id,
                Name = viewModel.Name,
                Detail = new ProjectDetail
                {
                    ProjectId = viewModel.Id,
                    Title = viewModel.Title,
                    Language = viewModel.Language,
                    Area = viewModel.Area,
                    Investor = viewModel.Invertor,
                    StartedYear = viewModel.StartedYear,
                    TotalApartment = viewModel.TotalApartment,
                    Website = viewModel.Website,
                    Street = viewModel.Street,
                    MapLatitude = viewModel.MapLatitude,
                    MapLongitude = viewModel.MapLongitude
                },

                ProjectBlocks = nestedProjectBlocks,
                AvatarFileId = viewModel.Avatar.FileId,
                TaxonomyIds = taxonomyIds,
                CityId = viewModel.CityId,
            });
        }
コード例 #3
0
        public static ProjectBlockViewModel FromEnitity(ProjectBlock entity)
        {
            var detail = entity.ProjectBlockDetails.FirstOrDefault(o => o.ForCurrentRequestLanguage());

            var viewModelResult = new ProjectBlockViewModel
            {
                Id           = entity.Id,
                EntityTypeId = entity.EntityTypeId,
                PackageId    = entity.PackageId,
                ParentId     = entity.PackageId,
                Children     = entity.Children?.Select(o => FromEnitity(o))
            };

            if (entity.Project != null)
            {
                viewModelResult.Project = new ProjectViewModel()
                {
                    Id   = entity.Project.Id,
                    Name = entity.Project.Name
                }
            }
            ;

            if (entity.Package != null)
            {
                viewModelResult.Package = PackageViewModel.FromEntity(entity.Package);
            }

            if (detail != null)
            {
                viewModelResult = viewModelResult.MergeWith(AutoMapper.Mapper.Map <ProjectBlockViewModel>(detail));
            }

            var layoutImageFileEntity = entity.ProjectBlockFiles.FirstOrDefault(o => o.UsingType == 0);

            if (layoutImageFileEntity != null)
            {
                viewModelResult.LayoutImage = FileEntityInfo.FromEntity(layoutImageFileEntity.FileEntity);
            }

            viewModelResult.LayoutPoints = entity.ProjectBlockFiles.Where(o => o.UsingType == 1).Select(o => {
                var obj   = Newtonsoft.Json.JsonConvert.DeserializeObject <LayoutPoint>(o.JsonData);
                obj.Image = FileEntityInfo.FromEntity(o.FileEntity);
                return(obj);
            });

            return(viewModelResult);
        }
    }
コード例 #4
0
        public static ProjectServiceModel FromViewModel(ProjectViewModel viewModel)
        {
            var nestedProjectBlocks = viewModel.ProjectBlocks.Select(o => ProjectBlock.FromViewModel(o));

            nestedProjectBlocks = nestedProjectBlocks.Select((tower) =>
            {
                tower.ProjectId    = viewModel.ProjectId;
                tower.EntityTypeId = EntityTypeSeed.RoomType.Id;
                tower.Children     = tower.Children.Select(floor => {
                    floor.EntityTypeId = EntityTypeSeed.RoomLayout.Id;
                    floor.Children     = floor.Children.Select(room =>
                    {
                        room.EntityTypeId = EntityTypeSeed.Perspective.Id;
                        return(room);
                    }).ToList();
                    return(floor);
                }).ToList();
                return(tower);
            });

            var taxonomyIds = new List <long>();

            if (viewModel.ProjectTypeId != default)
            {
                taxonomyIds.Add(viewModel.ProjectTypeId);
            }
            if (viewModel.ProjectStatusId != default)
            {
                taxonomyIds.Add(viewModel.ProjectStatusId);
            }

            var projectName = viewModel.Title.ToEntityName();

            return(new ProjectServiceModel
            {
                Id = viewModel.ProjectId,
                Name = projectName,
                Detail = AutoMapper.Mapper.Map <ProjectDetail>(viewModel),
                ProjectBlocks = nestedProjectBlocks,
                BudgetMin = viewModel.BudgetMin,
                BudgetMax = viewModel.BudgetMax,
                AvatarFileId = viewModel.Avatar.FileId,
                LocationImageId = viewModel.LocationImage.FileId,
                SiteMapImageId = viewModel.SiteMapImage.FileId,

                TaxonomyIds = taxonomyIds,
                CityId = viewModel.CityId,
            });
        }
コード例 #5
0
        //добавить блок в проект
        public int InsertBlock(string title, string functional, int[] parameters, List <BlockEquipment> blockEquips)
        {
            using (DataEntities db = new DataEntities())
            {
                try
                {
                    #region Добавление блока
                    //
                    ProjectBlock projectBlock = new ProjectBlock();

                    projectBlock.Title      = title;
                    projectBlock.Functional = functional;
                    projectBlock.IdBaseH    = parameters[0];
                    projectBlock.IdBaseB    = parameters[1];
                    projectBlock.IdVSize    = parameters[2];
                    projectBlock.IdSchema   = parameters[3];
                    if (parameters[4] != 0)
                    {
                        projectBlock.IdProjectNumber = parameters[4];
                    }

                    db.ProjectBlocks.Add(projectBlock);
                    db.SaveChanges();
                    //
                    #endregion

                    #region Привязка оборудования к блоку
                    int?bid = db.ProjectBlocks.OrderByDescending(x => x.Id).FirstOrDefault().Id;
                    if (bid != null)
                    {
                        foreach (BlockEquipment beq in blockEquips)
                        {
                            beq.IdBlock = bid;
                            db.BlockEquipments.Add(beq);
                        }
                    }
                    db.SaveChanges();
                    return((int)bid);

                    #endregion
                }
                catch
                {
                    return(-1); //ошибка
                }
            }
        }
コード例 #6
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var model = request.Model;
            var proid = UMC.Data.Utility.Guid(this.AsyncDialog("Id", g => this.DialogValue(request.Url.ToString())));

            if (proid.HasValue == false)
            {
                this.Prompt("参数不正确");
            }
            var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>();

            var sub = subEntity.Where.And().Equal(new Subject {
                Id = proid
            }).Entities.Single();

            if (sub == null)
            {
                this.Prompt("参数不正确");
            }
            var Type = this.AsyncDialog("Type", g =>
            {
                //return this.DialogValue("auto");
                var sheet = new Web.UISheetDialog()
                {
                    Title = "更多"
                };                                                    //屏蔽
                sheet.Options.Add(new Web.UIClick("Id", proid.ToString(), "Type", "Share")
                {
                    Command = request.Command, Model = model, Text = "分享到应用"
                });
                //sheet.Options.Add(new Web.UIClick("Id", proid.ToString(), "Type", "0") { Command = request.Command, Model = model, Text = "屏蔽此作者" });
                //sheet.Options.Add(new Web.UIClick("Id", proid.ToString(), "Type", "1") { Command = request.Command, Model = model, Text = "屏蔽此项目" });
                sheet.Options.Add(new Web.UIClick("Id", proid.ToString(), "Type", "Off")
                {
                    Command = request.Command, Model = model, Text = "举报内容"
                });
                return(sheet);
            });
            var user = Security.Identity.Current;

            switch (Type)
            {
            case "Off":
                var frm = this.AsyncDialog("Settings", g =>
                {
                    var fm   = new UIFormDialog();
                    fm.Title = "举报";
                    fm.AddRadio("违规性质", "Type").Put("内容质量差").Put("旧闻重复").Put("内容不实").Put("标题夸张").Put("低俗色情")
                    .Put("其他问题").Put("侵犯名誉/商誉/隐私/肖像权");
                    fm.AddFile("证明材料", "Url", "");
                    fm.AddTextarea("举报描述", "Description", "");
                    return(fm);
                });
                var url = new Uri(frm["Url"]);

                var s = "UserResources/TipOff" + url.AbsolutePath.Substring(url.AbsolutePath.IndexOf('/', 2));    //
                Data.WebResource.Instance().Transfer(url, s);
                var t = new SubjectTipOff();
                Data.Reflection.SetProperty(t, frm.GetDictionary());
                t.user_id      = user.Id;
                t.Url          = Data.WebResource.Instance().ResolveUrl(s);
                t.sub_id       = sub.Id;
                t.CreationTime = DateTime.Now;
                Utility.CMS.ObjectEntity <SubjectTipOff>().Where.And().Equal(new SubjectTipOff {
                    user_id = user.Id, sub_id = sub.Id
                })
                .Entities.IFF(e => e.Update(t) == 0, e => e.Insert(t));
                if (sub.TipOffs.HasValue)
                {
                    subEntity.Update("{0}+{1}", new Subject {
                        TipOffs = 1
                    });
                }
                else
                {
                    subEntity.Update(new Subject {
                        TipOffs = 1
                    });
                }
                this.Prompt("举报成功,我们将尽快处理");
                break;

            case "Share":
                response.Redirect(request.Model, "Share", proid.ToString());
                break;

            default:
            case "Block":

                var ui      = this.AsyncDialog("UI", g => this.DialogValue("none"));
                var section = this.AsyncDialog("section", g => this.DialogValue("1"));
                var row     = this.AsyncDialog("row", g => this.DialogValue("1"));
                var frm2    = Utility.IntParse(this.AsyncDialog("Settings", g =>
                {
                    if (Utility.IntParse(Type, -1) > -1)
                    {
                        return(this.DialogValue(Type));
                    }
                    var fm   = new UISelectDialog();
                    fm.Title = "屏蔽";
                    fm.Options.Put("屏蔽此作者", "0").Put("屏蔽此项目", "1");
                    return(fm);
                }), 0);
                var block = new ProjectBlock {
                    user_id = user.Id, ref_id = sub.user_id, Type = frm2
                };
                switch (frm2)
                {
                case 0:
                    block.ref_id = sub.user_id;
                    break;

                case 1:
                    block.ref_id = sub.project_id;
                    break;
                }
                if (block.ref_id.HasValue)
                {
                    Utility.CMS.ObjectEntity <ProjectBlock>().Where.And().Equal(block)
                    .Entities.IFF(e => e.Count() == 0, e => e.Insert(block));
                }
                if (ui == "none")
                {
                    this.Prompt("屏蔽成功");
                }
                else
                {
                    var editer = new Web.UISection.Editer(section, row, ui);
                    editer.Delete();
                    editer.ReloadSinle();
                    editer.Builder(this.Context, ui, true);
                }
                break;
            }
        }