public string ShowFinished() { int intPageIndex = Request["PageIndex"].ToInt32(); int intPageSize = Request["PageSize"].ToInt32(); int intState = Request["State"].ToInt(); var listFilter = new List <Utility.Filter>(); //动态查询表达式 if (intState <= 10 && intState >= 0) { listFilter.Add(Utility.Filter.Add("State", Op.Equals, Convert.ToString((int)ItemState.Enable), true)); } else { listFilter.Add(Utility.Filter.Add("State", Op.Equals, Convert.ToString((int)ItemState.Disable), true)); } //动态查询表达式 listFilter.Add(Utility.Filter.Add(string.Empty, Op.Contains, string.Empty, true)); var expTask = LambdaExpressionBuilder.GetExpressionByAndAlso <Task>(listFilter); //排序所需字典 Dictionary <string, string> dicOrderBy = new Dictionary <string, string>(); dicOrderBy.Add("UID", "desc"); //分页获取数据 Page <Temp> listTaskTemp = AllServices.TaskService.GetFinishedByPage(intPageIndex, intPageSize); return(CommonResult.Instance(1, null, listTaskTemp).ToJson()); }
public string Add() { var userModel = AllServices.UserService.GetUserBySession(); string strFolder = Request["Folder"].ToStr(); var res = CommonResult.Instance(); Folder folder = JsonHelper.FromJson <Folder>(strFolder); if (folder == null) { return(CommonResult.ToJsonStr("数据为空")); } Folder newFolder = new Folder(); newFolder.FolderName = folder.FolderName; newFolder.FatherID = folder.FatherID; newFolder.Creater = userModel.UserName; newFolder.Editor = userModel.UserName; newFolder.CreateTime = DateTime.Now; newFolder.EditTime = DateTime.Now; newFolder.Remark = folder.Remark; newFolder.State = Convert.ToInt32(ItemState.Enable); res = (CommonResult)AllServices.FolderService.Add(newFolder); if (res.code < 1) { return(res.ToJson()); } return(res.ToJson()); }
public string Add() { var userModel = AllServices.UserService.GetUserBySession(); string strProject = Request["Project"].ToStr(); var res = CommonResult.Instance(); Project project = JsonHelper.FromJson <Project>(strProject); if (project == null) { return(CommonResult.ToJsonStr("数据为空")); } Project NewProject = new Project(); NewProject.ProjectNo = ServiceHelper.GetKeyNum(); NewProject.ProjectName = project.ProjectName; NewProject.Creater = userModel.UserName; NewProject.Editor = userModel.UserName; NewProject.CreateTime = DateTime.Now; NewProject.EditTime = DateTime.Now; NewProject.Remark = project.Remark; NewProject.State = Convert.ToInt32(ItemState.Enable); res = (CommonResult)AllServices.ProjectService.Add(NewProject); if (res.code < 1) { return(res.ToJson()); } return(res.ToJson()); }
/// <summary> /// 还原图片状态(修改图片状态) /// </summary> /// <param name="strTag"></param> /// <param name="intDocumentUID"></param> /// <returns></returns> public string RestoreImage() { var userModel = AllServices.UserService.GetUserBySession(); int intUID = Request["UID"].ToInt32(); //关联表状态改禁用 AllServices.DocumentTagService.UpdateState(intUID, ItemState.Enable); AllServices.DocumentFolderService.UpdateState(intUID, ItemState.Enable); AllServices.DocumentService.UpdateState(intUID, ItemState.Enable); return(CommonResult.Instance().ToJson()); }
/// <summary> /// 删除图片集合(修改图片状态) /// </summary> /// <param name="strTag"></param> /// <param name="intDocumentUID"></param> /// <returns></returns> public string DeleteImages() { var userModel = AllServices.UserService.GetUserBySession(); string strUIDs = Request["UIDs"].ToStr(); int[] intUIDs = ArrayHelper.ToIntArray(strUIDs); //关联表状态改禁用 AllServices.DocumentTagService.UpdateState(intUIDs, ItemState.Disable); AllServices.DocumentFolderService.UpdateState(intUIDs, ItemState.Disable); AllServices.DocumentService.UpdateState(intUIDs, ItemState.Disable); return(CommonResult.Instance().ToJson()); }
public string Show() { var userModel = AllServices.UserService.GetUserBySession(); List <Project> listProject = AllServices.ProjectService.Show(); if (listProject != null) { return(CommonResult.Instance(1, "新建成功", listProject).ToJson()); } return(CommonResult.Instance(0, "新建失败", null).ToJson()); }
/// <summary> /// 重新关联所属系统 /// </summary> /// <param name="strTag"></param> /// <param name="intDocumentUID"></param> /// <returns></returns> public string MoveImages() { var userModel = AllServices.UserService.GetUserBySession(); string strSysID = Request["SysID"].ToStr(); string strUIDs = Request["UIDs"].ToStr(); int[] intUIDs = ArrayHelper.ToIntArray(strUIDs); int[] intSysIDs = ArrayHelper.ToIntArray(strSysID); //关联表 AddDocumentFolder(intSysIDs, intUIDs); return(CommonResult.Instance().ToJson()); }
public string GetTask() { int intUID = Request["UID"].ToInt32(); var listFilter = new List <Utility.Filter>(); //动态查询表达式 listFilter.Add(Utility.Filter.Add(string.Empty, Op.Contains, string.Empty, true)); var expTask = LambdaExpressionBuilder.GetExpressionByAndAlso <Task>(listFilter); //排序所需字典 Dictionary <string, string> dicOrderBy = new Dictionary <string, string>(); dicOrderBy.Add("UID", "desc"); //分页获取数据 Task task = AllServices.TaskService.GetByID(intUID); return(CommonResult.Instance(1, null, task).ToJson()); }
public string Show() { var userModel = AllServices.UserService.GetUserBySession(); CommonResult.Instance(); List <Folder> listFolder = AllServices.FolderService.Show(); if (listFolder.Count > 0) { return(CommonResult.Instance(1, null, listFolder).ToJson()); } else { return(CommonResult.Instance(0, "数据为空", null).ToJson()); } }
public string Show() { int intPageIndex = Request["PageIndex"].ToInt32(); int intPageSize = Request["PageSize"].ToInt32(); var listFilter = new List <Utility.Filter>(); //动态查询表达式 listFilter.Add(Utility.Filter.Add(string.Empty, Op.Contains, string.Empty, true)); var expTask = LambdaExpressionBuilder.GetExpressionByAndAlso <Task>(listFilter); //排序所需字典 Dictionary <string, string> dicOrderBy = new Dictionary <string, string>(); dicOrderBy.Add("UID", "desc"); //分页获取数据 Page <Task> listTask = AllServices.TaskService.GetByPage(intPageIndex, intPageSize, expTask, dicOrderBy); return(CommonResult.Instance(1, null, listTask).ToJson()); }
/// <summary> /// 获取指定文件的已上传的文件块 /// </summary> /// <returns></returns> public string GetMaxChunk() { if (IsDeBug) { return(CommonResult.Instance(0, string.Empty, 0).ToJson()); } string strConfig = Request["config"].ToStr("ImageUploadBaseConfig"); var configInstance = ConfigHelper.GetConfig <Foundation.SiteConfig.Models.ImageUploadBaseConfig>(strConfig); string strRoot = Server.MapPath(configInstance.SavePath); try { var md5 = Convert.ToString(Request["md5"]); var ext = Convert.ToString(Request["ext"]); int chunk = 0; var fileName = md5 + "." + ext; FileInfo file = new FileInfo(string.Format("{0}/{1}", strRoot, fileName)); if (file.Exists) { chunk = Int32.MaxValue; } else { if (Directory.Exists(string.Format("{0}/{1}", strRoot, "chunk\\" + md5))) { DirectoryInfo dicInfo = new DirectoryInfo(string.Format("{0}/{1}", strRoot, "chunk\\" + md5)); var files = dicInfo.GetFiles(); chunk = files.Count(); if (chunk > 1) { chunk = chunk - 1; //当文件上传中时,页面刷新,上传中断,这时最后一个保存的块的大小可能会有异常,所以这里直接删除最后一个块文件 } } } return(CommonResult.Instance(0, string.Empty, chunk).ToJson()); } catch { return(CommonResult.Instance(0, string.Empty, 0).ToJson()); } }
public ActionResult ModifyTasks() { int intUID = Request["UID"].ToInt32(); //分页获取数据 Task task = AllServices.TaskService.GetByID(intUID); if (task != null) { List <TaskList> listTaskList = AllServices.TaskListService.GetByTaskUID(task.UID); DataModel dataModel = new DataModel(); dataModel.Add("Task", task); dataModel.Add("ListTaskList", listTaskList); ViewBag.CommonResult = CommonResult.Instance(1, null, dataModel).ToJson(); } else { ViewBag.CommonResult = CommonResult.Instance().ToJson(); } return(View("ModifyTasks")); }
public ActionResult UploadDetial() { int intUID = Request["UID"].ToInt32(); Document document = AllServices.DocumentService.GetByUID(intUID); if (document != null) { DocumentTag documentTag = AllServices.DocumentTagService.GetByDocumentUID(document.UID); List <DocumentFolder> listDocumentFolder = AllServices.DocumentFolderService.GetByDocumentUID(document.UID); DataModel dataModel = new DataModel(); dataModel.Add("Document", document); dataModel.Add("DocumentTag", documentTag); dataModel.Add("ListDocumentFolder", listDocumentFolder); ViewBag.CommonResult = CommonResult.Instance(1, null, dataModel).ToJson(); } else { ViewBag.CommonResult = CommonResult.Instance().ToJson(); } return(View("UploadDetial")); }
public string Update() { var userModel = AllServices.UserService.GetUserBySession(); string strTaskList = Request["TaskList"].ToStr(); int intUID = Request["UID"].ToInt(); List <TaskList> listTaskList = JsonHelper.FromJsonList <TaskList>(strTaskList); foreach (TaskList tasklist in listTaskList) { tasklist.Editor = userModel.UserName; tasklist.EditTime = DateTime.Now; if (tasklist.UID == 0) { AllServices.TaskListService.Add(tasklist).ToJson(); } else { AllServices.TaskListService.Update(tasklist).ToJson(); } } return(CommonResult.Instance().ToJson()); }
public string QueryByDocumentFolderUID() { var userModel = AllServices.UserService.GetUserBySession(); int intSysID = Request["UID"].ToInt32(); List <DocumentFolder> listDocumentFolder = AllServices.DocumentFolderService.GetByDocumentUID(intSysID); if (listDocumentFolder.Count > 0) { List <Folder> listFolder = new List <Folder>(); foreach (DocumentFolder documentFolder in listDocumentFolder) { listFolder.Add(AllServices.FolderService.GetByID(documentFolder.FolderUID)); } //拿到所属系统id if (listFolder != null) { return(CommonResult.Instance(1, null, listFolder).ToJson()); } } return(CommonResult.Instance("操作失败,请联系管理员").ToJson()); }
public string AddList() { var userModel = AllServices.UserService.GetUserBySession(); string strTaskList = Request["TaskList"].ToStr(); var res = CommonResult.Instance(); List <TaskList> listTaskList = JsonHelper.FromJsonList <TaskList>(strTaskList); if (listTaskList == null) { return(CommonResult.ToJsonStr("数据为空")); } foreach (TaskList tasklistModel in listTaskList) { TaskList tasklist = new TaskList(); tasklist.TaskListNo = ServiceHelper.GetRandom(); tasklist.TaskListName = tasklistModel.TaskListName; tasklist.TaskUID = tasklistModel.TaskUID; tasklist.DocumentUID = 0; //tasklistModel.DocumentUID; tasklist.PictureSize = tasklistModel.PictureSize; tasklist.PictureResolution = tasklistModel.PictureResolution; tasklist.PictureBackground = tasklistModel.PictureBackground; tasklist.DocumentType = tasklistModel.DocumentType; tasklist.Creater = userModel.UserName; tasklist.Editor = userModel.UserName; tasklist.CreateTime = DateTime.Now; tasklist.EditTime = DateTime.Now; tasklist.Remark = tasklistModel.Remark; tasklist.State = Convert.ToInt32(ItemState.Enable); tasklist.ProjectId = 0; //Convert.ToInt32(ItemState.Enable); res = (CommonResult)AllServices.TaskListService.Add(tasklist); if (res.code < 1) { return(res.ToJson()); } } return(res.ToJson()); }
/// <summary> /// 分页展示图片 /// </summary> /// <returns></returns> public string Show() { int intPageIndex = Request["PageIndex"].ToInt32(); int intPageSize = Request["PageSize"].ToInt32(); int intState = Request["State"].ToInt32(); string strQueryList = Request["QueryList"].ToStr(); string strOrder = Request["Order"].ToStr() == string.Empty ? "asc" : Request["Order"].ToStr(); string strCond = Request["Cond"].ToStr() == string.Empty ? "DocumentName" : Request["Cond"].ToStr();//默认排序 姓名 a-z递增 List <DataModel> listDataModel = JsonHelper.ToListDataModel(strQueryList); var listFilter1 = new List <Utility.Filter>(); var listFilter2 = new List <Utility.Filter>(); var listFilter3 = new List <Utility.Filter>(); foreach (DataModel dataModel in listDataModel) { string strField = dataModel["Field"].ToStr(); string strOperation = dataModel["Operation"].ToStr(); string strFieldValue = dataModel["FieldValue"].ToStr(); if (!Enum.IsDefined(typeof(Op), strOperation)) //第二个参数也可以传入intValue { strOperation = Op.Equals.ToString(); //没有 } Op op = (Op)Enum.Parse(typeof(Op), strOperation); if (strField == "Tag") { listFilter2.Add(Utility.Filter.Add(strField, op, strFieldValue, true)); } else if (strField == "FolderUID") { listFilter3.Add(Utility.Filter.Add(strField, op, strFieldValue, true)); } else if (strField == "CreateTime") { listFilter1.Add(Utility.Filter.Add(strField, op, Convert.ToDateTime(strFieldValue), true)); } else { listFilter1.Add(Utility.Filter.Add(strField, op, strFieldValue, true)); } } //,string strTag,DateTime dateBeginTime,DateTime dateEndTime //动态查询表达式 if (intState <= 10) { listFilter1.Add(Utility.Filter.Add("State", Op.Equals, Convert.ToString((int)ItemState.Enable), true)); } else { listFilter1.Add(Utility.Filter.Add("State", Op.Equals, Convert.ToString((int)ItemState.Disable), true)); } var expTaskList = LambdaExpressionBuilder.GetExpressionByAndAlso <Document>(listFilter1); var expTagTaskList = LambdaExpressionBuilder.GetExpressionByAndAlso <DocumentTag>(listFilter2); var expDocumentFolderTaskList = LambdaExpressionBuilder.GetExpressionByAndAlso <DocumentFolder>(listFilter3); //排序所需字典 Dictionary <string, string> dicOrderBy = new Dictionary <string, string>(); dicOrderBy.Add(strCond, strOrder); //分页获取数据 Page <Document> listDocumentList = AllServices.DocumentService.GetByPage(intPageIndex, intPageSize, expTaskList, dicOrderBy, expTagTaskList, expDocumentFolderTaskList); return(CommonResult.Instance(1, null, listDocumentList).ToJson()); }
/// <summary> /// 合并文件 /// </summary> /// <returns></returns> public string MergeFiles() { var userModel = AllServices.UserService.GetUserBySession(); string strTag = Request["tag"].ToStr(); string strSize = Request["size"].ToStr(); string strSysID = Request["sysID"].ToStr(); int intDpiID = Request["dpi"].ToInt32(); string definedName = Request["definedName"].ToStr(); string strGuid = Request["md5"]; string strExt = Request["ext"]; DataModel dataModel = new DataModel(); dataModel.Add("DpiID", intDpiID); dataModel.Add("Size", strSize); dataModel.Add("Guid", strGuid); dataModel.Add("Ext", strExt); dataModel.Add("DefinedName", definedName); string strConfig = Request["config"].ToStr("ImageUploadBaseConfig"); var configInstance = ConfigHelper.GetConfig <Foundation.SiteConfig.Models.ImageUploadBaseConfig>(strConfig); CommonResult commonResult = AllServices.ImageUploadService.ChunkImageHandler(configInstance, userModel.UserName, dataModel, ActionType.Add); //合并保存文件 if (commonResult.code < 0) { return(CommonResult.Instance(0, string.Empty, "{\"chunked\" : false}").ToJson()); } CommonResult commonResult1 = new CommonResult("请选择所属系统"); if (!string.IsNullOrEmpty(strSysID)) { int[] intSysIDs = ArrayHelper.ToIntArray(strSysID); commonResult1 = AddDocumentFolder(intSysIDs, (int)commonResult.data); } CommonResult commonResult2 = new CommonResult("请选择标签"); if (!string.IsNullOrWhiteSpace(strTag)) { commonResult2 = AddTag(strTag, (int)commonResult.data); } CommonResult commonResult3 = new CommonResult("任务列表清单关联失败"); if (commonResult.data.ToInt32() != 0) { commonResult3 = AddTaskList((int)commonResult.data); } if (commonResult1.code < 1) { commonResult = new CommonResult("文件上传成功,标签新增失败"); } else if (commonResult2.code < 1) { commonResult = new CommonResult("文件上传成功,所属系统失败"); } else if (commonResult3.code < 1) { commonResult = new CommonResult("文件上传成功,所属系统成功,任务列表清单关联失败"); } else if (commonResult1.code < 1 && commonResult2.code < 1 && commonResult3.code < 1) { commonResult = new CommonResult("文件上传成功,标签新增失败,所属系统失败"); } return(commonResult.ToJson()); }
readonly bool IsDeBug = false; //Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["IsDeBug"].ToString()); /// <summary> /// 文件分块上传 /// </summary> /// <param name="fileData"></param> /// <returns></returns> public string ChunkUpload(HttpPostedFileBase file) { var userModel = AllServices.UserService.GetUserBySession(); //if(IsDeBug) //{ // return CommonResult.Instance(0,string.Empty,"{\"chunked\" : true, \"ext\" : \"" + Path.GetExtension(file.FileName) + "\"}").ToJson(); //} if (file == null) //当用户在上传文件时突然刷新页面,可能造成这种情况 { return(CommonResult.Instance(-1, "HttpPostedFileBase对象为null", "{\"chunked\" : " + Request.Form.AllKeys.Any(m => m == "chunk") + "}").ToJson()); } string strConfig = Request["config"].ToStr("ImageUploadBaseConfig"); var configInstance = ConfigHelper.GetConfig <Foundation.SiteConfig.Models.ImageUploadBaseConfig>(strConfig); string strRoot = PathHelper.GetMapPath(configInstance.SavePath); //拿到保存图片绝对路径 string strTag = Request["tag"].ToStr(); string strSize = Request["size"].ToStr(); string strSysID = Request["sysID"].ToStr(); int intDpiID = Request["dpi"].ToInt32(); string definedName = Request["definedName"].ToStr(); string strExt = Request["ext"].ToStr(); DataModel dataModel = new DataModel(); dataModel.Add("DpiID", intDpiID); dataModel.Add("Size", strSize); dataModel.Add("DpiID", intDpiID); dataModel.Add("Size", strSize); dataModel.Add("Ext", strExt); dataModel.Add("DefinedName", definedName); //如果进行了分片 if (Request.Form.AllKeys.Any(m => m == "chunk")) { //取得chunk和chunks int intChunk = Convert.ToInt32(Request.Form["chunk"]); //当前分片在上传分片中的顺序(从0开始) int intChunks = Convert.ToInt32(Request.Form["chunks"]); //总分片数 //根据GUID创建用该GUID命名的临时文件夹 //string folder = Server.MapPath("~/Upload/" + Request["md5"] + "/"); string strFolder = string.Format("{0}/{1}", strRoot, "chunk\\" + Request["md5"] + "\\"); //临时文件夹 string strPath = strFolder + intChunk; //建立临时传输文件夹 if (!Directory.Exists(Path.GetDirectoryName(strFolder))) { Directory.CreateDirectory(strFolder); } FileStream addFile = null; BinaryWriter AddWriter = null; Stream stream = null; BinaryReader TempReader = null; try { //addFile = new FileStream(path, FileMode.Append, FileAccess.Write); addFile = new FileStream(strPath, FileMode.Create, FileAccess.Write); AddWriter = new BinaryWriter(addFile); //获得上传的分片数据流 stream = file.InputStream; TempReader = new BinaryReader(stream); //将上传的分片追加到临时文件末尾 AddWriter.Write(TempReader.ReadBytes((int)stream.Length)); } finally { if (addFile != null) { addFile.Close(); addFile.Dispose(); } if (AddWriter != null) { AddWriter.Close(); AddWriter.Dispose(); } if (stream != null) { stream.Close(); stream.Dispose(); } if (TempReader != null) { TempReader.Close(); TempReader.Dispose(); } } //context.Response.Write("{\"chunked\" : true, \"hasError\" : false, \"f_ext\" : \"" + Path.GetExtension(file.FileName) + "\"}"); //return CommonResult.ToJsonStr(0, string.Empty, "{\"chunked\" : true, \"ext\" : \"" + Path.GetExtension(file.FileName) + "\"}"); return(CommonResult.Instance(0, string.Empty, new ChunkTemp() { chunked = true, ext = Path.GetExtension(file.FileName), }).ToJson()); } else //没有分片直接保存 { CommonResult commonResult = AllServices.ImageUploadService.ImageHandler(Request.Files[0], configInstance, userModel.UserName, dataModel, ActionType.Add); //string path = string.Format("{0}/{1}",strRoot,Request["md5"] + Path.GetExtension(Request.Files[0].FileName)); //Request.Files[0].SaveAs(path); if (commonResult.code < 0) { //context.Response.Write("{\"chunked\" : false, \"hasError\" : false}"); return(CommonResult.Instance(0, string.Empty, "{\"chunked\" : false}").ToJson()); } CommonResult commonResult1 = new CommonResult("请选择所属系统"); if (!string.IsNullOrEmpty(strSysID)) { int[] intSysIDs = ArrayHelper.ToIntArray(strSysID); commonResult1 = AddDocumentFolder(intSysIDs, (int)commonResult.data); } CommonResult commonResult2 = AddTag(strTag, (int)commonResult.data); CommonResult commonResult3 = AddTaskList((int)commonResult.data); if (commonResult1.code < 1) { commonResult = new CommonResult("文件上传成功,标签新增失败"); } else if (commonResult2.code < 1) { commonResult = new CommonResult("文件上传成功,所属系统失败"); } else if (commonResult3.code < 1) { commonResult = new CommonResult("文件上传成功,所属系统成功,任务列表清单关联失败"); } else if (commonResult1.code < 1 && commonResult2.code < 1 && commonResult3.code < 1) { commonResult = new CommonResult("文件上传成功,标签新增失败,所属系统失败"); } return(commonResult.ToJson()); } }