示例#1
0
        public List<PostDescription> Getxuqiu(WorkFlowInstance Model)
        {
            List<PostDescription> ReturnModel = new List<PostDescription>();

            if (Model.Activities == null)
            {
                return null;
            }
            foreach (var item in Model.Activities)
            {
                if (Model.Assignments == null)
                {
                    Model.Assignments = new List<WorkFlowEngine.Assignment>();
                }

                PostDescription SingeModel = new PostDescription();

                var id = ObjectId.Parse(item.UnitID);
                var activeId = item._id.ToString();
                var name = Model.WorkFlow.Units.Where(c => c._id == id).Select(x => x.Name).FirstOrDefault();
                var list = Model.Assignments.Where(c => c.ActivityID == activeId && (c.Keyword == 12002 || c.Keyword == 12003 || c.Keyword == 12005)).Select(x => x.UserCode).ToList();
                var keyword = Model.Assignments.Where(c => c.ActivityID == activeId && (c.Keyword == 12002 || c.Keyword == 12003 || c.Keyword == 12005)).Select(x => x.Keyword).ToList();
                var StringTime = Model.Assignments.Where(c => c.ActivityID == activeId && (c.Keyword == 12002 || c.Keyword == 12003 || c.Keyword == 12005)).Select(x => x.updatetime).ToList();
                if (name != "开始" && name != "结束" && name != "重新提交")
                {
                    SingeModel.Post = name;
                    SingeModel.JobNumber = list.FirstOrDefault();
                    SingeModel.Time = StringTime.FirstOrDefault();

                    ReturnModel.Add(SingeModel);
                }
            }

            return ReturnModel;
        }
示例#2
0
        protected override void Seed(ApplicationDbContext context)
        {
            ApplicationUser user = new ApplicationUser();

            if (!context.Roles.Any(r => r.Name == "Admin"))
            {
                var store   = new RoleStore <IdentityRole>(context);
                var manager = new RoleManager <IdentityRole>(store);
                var role    = new IdentityRole {
                    Name = "Admin"
                };
                manager.Create(role);
            }

            if (!context.Users.Any(u => u.UserName == "*****@*****.**"))
            {
                var store   = new UserStore <ApplicationUser>(context);
                var manager = new UserManager <ApplicationUser>(store);
                user = new ApplicationUser {
                    UserName = "******", Email = "*****@*****.**"
                };

                manager.Create(user, "Alex-123");
                manager.AddToRole(user.Id, "Admin");
            }
            Party party = new Party()
            {
                Name        = "политическая партия Всеукраинское объединение Батьківщина",
                PolitDerect = "Left"
            };
            City city = new City()
            {
                Name = "Киев"
            };
            Position posit = new Position()
            {
                Name = "Народный депутат"
            };
            List <Person> pers = new List <Person>()
            {
                new Person()
                {
                    Name      = "Иван",
                    Family    = "Иванович",
                    Surname   = "Иванов",
                    Foto      = "nf80.jpg",
                    Party     = party,
                    City      = city,
                    Date      = DateTime.Now,
                    Position  = posit,
                    Submitted = user,
                    Rate      = 0
                }, new Person()
                {
                    Name      = "Иван",
                    Family    = "Иванович",
                    Surname   = "Иванов",
                    Foto      = "nf80.jpg",
                    Party     = party,
                    City      = city,
                    Position  = posit,
                    Date      = DateTime.Now,
                    Submitted = user,
                    Rate      = 0
                }, new Person()
                {
                    Name      = "Иван",
                    Family    = "Иванович",
                    Surname   = "Иванов",
                    Foto      = "nf80.jpg",
                    Party     = party,
                    City      = city,
                    Date      = DateTime.Now,
                    Position  = posit,
                    Submitted = user,
                    Rate      = 0
                }, new Person()
                {
                    Name      = "Иван",
                    Family    = "Иванович",
                    Surname   = "Иванов",
                    Foto      = "nf80.jpg",
                    Party     = party,
                    City      = city,
                    Position  = posit,
                    Date      = DateTime.Now,
                    Submitted = user,
                    Rate      = 0
                }, new Person()
                {
                    Name      = "Иван",
                    Family    = "Иванович",
                    Surname   = "Иванов",
                    Foto      = "nf80.jpg",
                    Party     = party,
                    City      = city,
                    Position  = posit,
                    Date      = DateTime.Now,
                    Submitted = user,
                    Rate      = 0
                }, new Person()
                {
                    Name      = "Иван",
                    Family    = "Иванович",
                    Surname   = "Иванов",
                    Foto      = "nf80.jpg",
                    Party     = party,
                    City      = city,
                    Position  = posit,
                    Date      = DateTime.Now,
                    Submitted = user,
                    Rate      = 0
                }, new Person()
                {
                    Name      = "Иван",
                    Family    = "Иванович",
                    Surname   = "Иванов",
                    Foto      = "nf80.jpg",
                    Party     = party,
                    City      = city,
                    Position  = posit,
                    Date      = DateTime.Now,
                    Submitted = user,
                    Rate      = 0
                }, new Person()
                {
                    Name      = "Иван",
                    Family    = "Иванович",
                    Surname   = "Иванов",
                    Foto      = "nf80.jpg",
                    Party     = party,
                    City      = city,
                    Position  = posit,
                    Date      = DateTime.Now,
                    Submitted = user,
                    Rate      = 0
                }
            };
            List <PeopleComment> com1 = new List <PeopleComment>()
            {
                new PeopleComment()
                {
                    Person   = pers[1],
                    Text     = "LJMHasdasd1231asdasdasd13123123",
                    User     = user,
                    Datetime = DateTime.Now,
                }, new PeopleComment()
                {
                    Person   = pers[1],
                    Text     = "LJMHasdasd1231asdasdasd13123123",
                    User     = user,
                    Datetime = DateTime.Now,
                }, new PeopleComment()
                {
                    Person   = pers[1],
                    Text     = "LJMHasdasd1231asdasdasd13123123",
                    User     = user,
                    Datetime = DateTime.Now,
                }, new PeopleComment()
                {
                    Person   = pers[1],
                    Text     = "LJMHasdasd1231asdasdasd13123123",
                    User     = user,
                    Datetime = DateTime.Now,
                }, new PeopleComment()
                {
                    Person   = pers[1],
                    Text     = "LJMHasdasd1231asdasdasd13123123",
                    User     = user,
                    Datetime = DateTime.Now,
                }
            };
            PeopleComment com2 = new PeopleComment()
            {
                Person    = pers[1],
                Text      = "LJMHasdasd1231asdasdasd13123123",
                User      = user,
                Datetime  = DateTime.Now,
                Childrens = com1.Cast <Comment>().ToList()
            };
            List <Tag> tag = new List <Tag>()
            {
                new Tag()
                {
                    Name = "криминал"
                },
                new Tag()
                {
                    Name = "хорошие дела"
                }
            };
            List <PostComment> postComments = new List <PostComment>()
            {
                new PostComment()
                {
                    Text     = "LJMHasdasd1231asdasdasd13123123",
                    User     = user,
                    Datetime = DateTime.Now,
                }, new PostComment()
                {
                    Text     = "LJMHasdasd1231asdasdasd13123123",
                    User     = user,
                    Datetime = DateTime.Now,
                }, new PostComment()
                {
                    Text     = "LJMHasdasd1231asdasdasd13123123",
                    User     = user,
                    Datetime = DateTime.Now,
                }, new PostComment()
                {
                    Text     = "LJMHasdasd1231asdasdasd13123123",
                    User     = user,
                    Datetime = DateTime.Now,
                }, new PostComment()
                {
                    Text     = "LJMHasdasd1231asdasdasd13123123",
                    User     = user,
                    Datetime = DateTime.Now,
                }
            };
            PostDescription PostDescription = new PostDescription()
            {
                Content = "Picture removal detract earnest is by. Esteems met joy attempt way clothes yet demesne tedious. Replying an marianne do it an entrance advanced. Two dare say play when hold. Required bringing me material stanhill jointure is as he. Mutual indeed yet her living result matter him bed whence." +
                          "Ask especially collecting terminated may son expression.Extremely eagerness principle estimable own was man.Men received far his dashwood subjects new.My sufficient surrounded an companions dispatched in on.Connection too unaffected expression led son possession.New smiling friends and her another.Leaf she does none love high yet.Snug love will up bore as be.Pursuit man son musical general pointed.It surprise informed mr advanced do outweigh.",
                Type = "text",
            };
            Post post = new Post()
            {
                Person   = pers[1],
                User     = user,
                Title    = "Effect if in up no depend seemed. Ecstatic elegance gay but disposed",
                PostedOn = DateTime.Now,
                Tags     = new List <Tag>()
                {
                    tag[0], new Tag()
                    {
                        Name = "депутат"
                    }
                },
                PostFile    = "Effect_if_in_up_no_depend_seemed.",
                PostComment = postComments,
                Description = new List <PostDescription>()
                {
                    PostDescription
                }
            };

            context.Posts.Add(post);
            context.PostComments.AddRange(postComments);
            context.Tags.AddRange(tag);
            context.postDescriptions.Add(PostDescription);
            context.PeopleComments.Add(com2);
            context.Positions.Add(posit);
            context.Parties.Add(party);
            context.Cities.Add(city);
            context.Persons.AddRange(pers);
            base.Seed(context);
        }
示例#3
0
        public JsonResult Create(PostCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var  postType = db.Tags.FirstOrDefault(x => x.Id == model.PostType);
                Post postTemp;
                var  orderList = new List <PostDescription>();

                foreach (var item in model.Order)
                {
                    var type = Regex.Replace(item.Key, "[0-9]", string.Empty);
                    var temp = new PostDescription()
                    {
                        Type = type, Content = item.Value
                    };
                    orderList.Add(temp);
                }

                var tagsTemp = new List <Tag>();
                tagsTemp.Add(postType);
                foreach (var item in model.Tags.Split(','))
                {
                    tagsTemp.Add(new Tag()
                    {
                        Name = item
                    });
                }

                if (model.Files != null)
                {
                    string FileFolderPath;
                    //проверяем дерикторию создвем если нет
                    FileFolderPath = DateTime.Now.ToString("ddMMyyyyHHmmss");
                    if (!Directory.Exists(Server.MapPath(FileFolderPath)))
                    {
                        Directory.CreateDirectory(Server.MapPath("~/Content/PostContent/" + FileFolderPath));
                    }

                    //сохраняем файлы
                    foreach (HttpPostedFileBase file in model.Files)
                    {
                        if (file.ContentLength > 0)
                        {
                            file.SaveAs(Server.MapPath("~/Content/PostContent/" + FileFolderPath + "/" + file.FileName));
                        }
                    }
                    postTemp = new Post()
                    {
                        Title       = model.Title,
                        UserId      = User.Identity.GetUserId(),
                        PersonId    = model.PersonId,
                        PostedOn    = DateTime.Now,
                        Description = orderList,
                        Tags        = tagsTemp,
                        PostFile    = FileFolderPath
                    };
                }
                else
                {
                    postTemp = new Post()
                    {
                        Title       = model.Title,
                        UserId      = User.Identity.GetUserId(),
                        PersonId    = model.PersonId,
                        PostedOn    = DateTime.Now,
                        Description = orderList,
                        Tags        = tagsTemp,
                    };
                }

                foreach (var item in tagsTemp)
                {
                    if (db.Tags.FirstOrDefault(x => x.Name == item.Name) == null)
                    {
                        db.Tags.Add(item);
                    }
                }
                db.Posts.Add(postTemp);
                db.SaveChanges();

                return(Json(new { postTemp.PostId, TagId = model.PostType, message = "Пост успешно добавлен" }, JsonRequestBehavior.AllowGet));
            }

            return(ModelState.JsonValidation());
        }