public ActionResult <ApiResult <bool> > CreateFileByProjectId([FromForm] ProjectViewModel2 model, bool disOpen = true) { var result = new ApiResult <bool>(); var tables = model.Tables; var project = ProjectDb.GetSingle(it => it.Id == model.ProjectId); base.Check(project == null, "请选择方案"); model.Tables = tables; var template = TemplateDb.GetById(project.TemplateId1).Content; var tableids = Newtonsoft.Json.JsonConvert.DeserializeObject <List <CodeTypeGridViewModel> >(model.Tables).Select(it => it.Id).ToList(); var tableList = CodeTableDb.GetList(it => tableids.Contains(it.Id)); int dbId = tableList.First().DbId; var connection = base.GetTryDb(dbId); List <EntitiesGen> genList = GetGenList(tableList, CodeTypeDb.GetList(), connection.CurrentConnectionConfig.DbType); string key = TemplateHelper.EntityKey + template.GetHashCode(); foreach (var item in genList) { item.name_space = GetNameSpace(project.FileModel, item.name_space); var html = TemplateHelper.GetTemplateValue(key, template, item); var fileName = GetFileName(project, item); FileSugar.CreateFileReplace(fileName, html, Encoding.UTF8); } OpenPath(disOpen, project); ProjectController_Common.CreateProject(project.Id, model.DbId.Value); result.IsSuccess = true; result.Message = "生成生功"; return(result); }
public ActionResult <ApiResult <string> > Copy([FromForm] ProjectViewModel2 model) { var result = new ApiResult <string>(); var tables = model.Tables; var project = ProjectDb.GetSingle(it => it.Id == model.ProjectId); base.Check(project == null, "请选择方案,没有方案可以在手动生成里面创建"); model.Tables = tables; var template = TemplateDb.GetById(project.TemplateId1).Content; var tableids = Newtonsoft.Json.JsonConvert.DeserializeObject <List <CodeTypeGridViewModel> >(model.Tables).Select(it => it.Id).ToList(); var tableList = CodeTableDb.GetList(it => tableids.Contains(it.Id)); int dbId = tableList.First().DbId; var connection = base.GetTryDb(dbId); List <EntitiesGen> genList = GetGenList(tableList, CodeTypeDb.GetList(), connection.CurrentConnectionConfig.DbType); string key = TemplateHelper.EntityKey + template.GetHashCode(); foreach (var item in genList.Take(1)) { item.name_space = GetNameSpace(project.FileModel, item.name_space); result.Data = TemplateHelper.GetTemplateValue(key, template, item); } ProjectController_Common.CreateProject(project.Id, model.DbId.Value); result.IsSuccess = true; return(result); }
public void AddProject(ProjectDto t) { var project = new ProjectDb { CreationDate = t.CreationDate, Comment = t.Comment, CreatorId = t.CreatorId, DeptId = t.DeptId, Finish = t.Finish, ManagerId = t.ManagerId, Name = t.Name, Priority = t.Priority, Start = t.Start, State = t.State, UserId = t.UserId }; using (var context = new CamozziEntities()) { context.ProjectDbs.Add(project); context.SaveChanges(); Console.WriteLine("------------------------------------------------------------"); Console.WriteLine(DateTime.Now + " Project Added by " + context.UserDbs.First(x => x.Id == project.CreatorId).Name); } UpdateClients(); }
public ActionResult <ApiResult <Project> > GetProjectById(int id) { var result = new ApiResult <Project>(); result.Data = ProjectDb.GetById(id); result.IsSuccess = true; return(result); }
protected void btnUpdateProject_Click(object sender, EventArgs e) { ProjectDb project = new ProjectDb() { IdProject = Convert.ToInt32(this.LabelProjectId.Text), Description = this.TextAreaDescription.Value, Title = this.tbProjectTitle.Text, Tag = this.tbProjectTag.Text }; if (this.CheckBoxUploadNewMainImage.Checked) { UploadImageDb img = UploadFile.UploadImage(this.FileUploadMainImage, Server.MapPath("~/Upload/")); if (img.IsUploaded) { project.MainImageLink = img.BigPictureUrl; //this.GridViewProjects.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateWithImg() { Project = project }).DbItems.Cast<ProjectDb>().ToArray(); this.GridView1.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateWithImg() { Project = project }).DbItems.Cast <ProjectDb>().ToArray(); } else { //this.GridViewProjects.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateWithoutImg() { Project = project }).DbItems.Cast<ProjectDb>().ToArray(); this.GridView1.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateWithoutImg() { Project = project }).DbItems.Cast <ProjectDb>().ToArray(); } } else { //this.GridViewProjects.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateWithoutImg() {Project = project }).DbItems.Cast<ProjectDb>().ToArray(); this.GridView1.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateWithoutImg() { Project = project }).DbItems.Cast <ProjectDb>().ToArray(); } this.PanelShowData.Visible = false; //this.GridViewProjects.DataBind(); this.GridView1.DataBind(); }
public ActionResult <ApiResult <List <TreeModel> > > GetProjectAll() { List <TreeModel> trees = new List <TreeModel>(); var databses = ProjectDb.GetList().OrderBy(it => it.ModelId).ToList(); foreach (var db in databses) { trees.Add(new TreeModel() { Id = db.Id.ToString(), Title = (GetModelId(db.ModelId)) + ":" + db.ProjentName, IsSelectable = true }); } ApiResult <List <TreeModel> > result = new ApiResult <List <TreeModel> >(); result.Data = trees; result.IsSuccess = true; return(result); }
public ActionResult <ApiResult <List <TreeModel> > > GetProject(int typeId) { List <TreeModel> trees = new List <TreeModel>(); var databses = ProjectDb.GetList(it => it.ModelId.Equals(typeId)); foreach (var db in databses) { trees.Add(new TreeModel() { Id = db.Id.ToString(), Title = db.ProjentName, IsSelectable = true }); } ApiResult <List <TreeModel> > result = new ApiResult <List <TreeModel> >(); result.Data = trees; result.IsSuccess = true; return(result); }
public ActionResult <ApiResult <TableModel <ProjectGridViewModel> > > GetProjectList([FromForm] ProjectViewModel model) { var result = new ApiResult <TableModel <ProjectGridViewModel> >(); result.Data = new TableModel <ProjectGridViewModel>(); int count = 0; var list = ProjectDb.AsSugarClient().Queryable <Project>() .WhereIF(!string.IsNullOrEmpty(model.ProjentName), it => it.ProjentName.Contains(model.ProjentName)) .WhereIF(model.ModelId > 0, it => it.ModelId == model.ModelId) .OrderBy(it => new { it.ProjentName }) .Select(it => new ProjectGridViewModel { FileSuffix = it.FileSuffix, Id = it.Id, FileInfo = it.FileInfo, ModelId = it.ModelId.GetConfigValue <TemplateType>(), Path = it.Path, ProjentName = it.ProjentName, TemplateId1 = it.TemplateId1.GetConfigValue <Template>(), FileModel = it.FileModel, Reference = it.Reference, NameFormat = it.NameFormat }) .Mapper(it => { if (!string.IsNullOrEmpty(it.FileInfo)) { var ids = it.FileInfo.Split(','); var name = Db.Queryable <FileInfo>().In(ids).Select(it => it.Name).ToList(); it.FileInfo = string.Join(",", name); } }) .ToPageList(model.PageIndex, model.PageSize, ref count); result.Data.Rows = list; result.Data.Total = count; result.Data.PageSize = model.PageSize; result.Data.PageNumber = model.PageIndex; result.IsSuccess = true; return(result); }
public ActionResult <ApiResult <bool> > DeleteProject([FromForm] string model) { var result = new ApiResult <bool>(); if (!string.IsNullOrEmpty(model)) { var list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <DatabaseViewModel> >(model); var isInit = Db.Queryable <Project>().In(list.Select(it => it.Id).ToList()).Any(it => it.IsInit == true); base.Check(isInit, "无法删除初始化数据"); var exp = Expressionable.Create <Project>(); foreach (var item in list) { exp.Or(it => it.Id == item.Id); } ProjectDb.Update(it => new Project() { IsDeleted = true }, exp.ToExpression()); } result.IsSuccess = true; return(result); }
protected void btnSubmit_Click(object sender, EventArgs e) { if (this.Page.IsValid) { if (this.CheckBoxEditing.Checked) { ProjectDb project = new ProjectDb() { IdProject = Convert.ToInt32(this.LabelEditingId.Text), IdUser = (int)Session["idUser"], Title = this.tbTitle.Text, Tag = this.tbTag.Text, Description = this.taDescription.Value }; if (this.CheckBoxEditImage.Checked) { UploadImageDb image = UploadFile.UploadImage(this.FileUploadMainImage, Server.MapPath("~/Upload/")); if (image.IsUploaded) { project.MainImageLink = image.BigPictureUrl; this.LabelMessage.ForeColor = System.Drawing.Color.Green; this.CheckBoxEditImage.Checked = false; this.CheckBoxEditImage.Visible = false; OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateOnlyWithImg() { Project = project }); } else { this.LabelMessage.ForeColor = System.Drawing.Color.Red; } } else { this.CheckBoxEditImage.Checked = false; this.CheckBoxEditImage.Visible = false; OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateOnlyWithoutImg() { Project = project }); } this.tbTitle.Text = ""; this.tbTag.Text = ""; this.taDescription.Value = ""; } else { //obradi ono za sliku prvo UploadImageDb image = UploadFile.UploadImage(this.FileUploadMainImage, Server.MapPath("~/Upload/")); if (image.IsUploaded) { ProjectDb project = new ProjectDb() { IdUser = (int)Session["idUser"], Title = this.tbTitle.Text, Tag = this.tbTag.Text, Description = this.taDescription.Value, MainImageLink = image.BigPictureUrl }; OperationManager.Singleton.izvrsiOperaciju(new OpProjectInsertOnly() { Project = project }); this.tbTitle.Text = ""; this.tbTag.Text = ""; this.taDescription.Value = ""; this.CheckBoxEditImage.Visible = false; this.LabelMessage.ForeColor = System.Drawing.Color.Green; } else { this.LabelMessage.ForeColor = System.Drawing.Color.Red; } this.LabelMessage.Visible = true; this.LabelMessage.Text = image.ErrorMessage; } } this.LabelEditingId.Text = ""; this.CheckBoxEditing.Checked = false; this.GridView1.DataBind(); }
public ProjectController(ProjectDb projectDb) { _projectDb = projectDb; }