public ActionResult ChangeTaskStatus(string shortCode, string newTaskStatus, string comment)
        {
            return(ActionUtils.Json(() =>
            {
                var task = m_dbAdapter.Task.GetTask(shortCode);
                var logicModel = Platform.GetProject(task.ProjectId);

                var oldStatus = task.TaskStatus;
                var newStatus = CommUtils.ParseEnum <TaskStatus>(newTaskStatus);

                if (newStatus == TaskStatus.Waitting && IsOverdue(task))
                {
                    newStatus = TaskStatus.Overdue;
                }

                var taskEx = CheckChangeTaskStatus(task, newStatus);

                //如果当前工作状态从完成修改为开始,修改后续工作的状态为未完成
                if (oldStatus == TaskStatus.Finished && newStatus != TaskStatus.Finished)
                {
                    var subsequentTasks = m_dbAdapter.Task.GetSubsequentTasksRecursively(shortCode);
                    subsequentTasks = subsequentTasks.Where(x => x.TaskStatus == TaskStatus.Finished).ToList();
                    subsequentTasks.ForEach(x => new TaskLogicModel(logicModel, x).Stop(comment));
                }

                var taskLogicModel = new TaskLogicModel(logicModel, task);

                //修改当前工作状态
                if ((task.TaskStatus == TaskStatus.Error ||
                     task.TaskStatus == TaskStatus.Waitting ||
                     task.TaskStatus == TaskStatus.Overdue) &&
                    newStatus == TaskStatus.Finished)
                {
                    taskLogicModel.Start(comment).Finish(comment);
                }
                else
                {
                    m_dbAdapter.Task.ChangeTaskStatus(task, newStatus, comment);
                }

                //增加Activity
                logicModel.Activity.Add(task.ProjectId, ActivityObjectType.Task, task.ShortCode, "修改工作[" + task.Description + "]的工作状态为:" + Toolkit.ToCnString(newStatus));

                //触发工作状态改变事件
                if (taskEx != null)
                {
                    taskEx.InvokeStatusChanged(oldStatus, newStatus);
                }

                return ActionUtils.Success(Toolkit.ToCnString(newStatus));
            }));
        }
        public ActionResult CreateFile(string shortCode, string folderGuid, List <string> fileSeriesNames, string description)
        {
            return(ActionUtils.Json(() =>
            {
                var dms = GetDMSAndCheckPermission(shortCode, PermissionType.Execute);
                var folder = dms.FindFolder(folderGuid);
                CommUtils.AssertNotNull(folder, "找不到文件夹[FolderGuid={0} DMSGuid={1}],请刷新后再试",
                                        folderGuid, dms.Instance.Guid);

                ValidateUtils.Name(fileSeriesNames, "文档名称", 100).FileName();

                var dict = new Dictionary <RepositoryFile, HttpPostedFileBase>();
                var files = Request.Files;
                var fileGuids = new List <string>();
                for (int i = 0; i < files.Count; i++)
                {
                    var file = files[i];

                    var index = Math.Max(file.FileName.LastIndexOf('\\'), file.FileName.LastIndexOf('/'));
                    var fileName = index < 0 ? file.FileName : file.FileName.Substring(index + 1);

                    CommUtils.AssertHasContent(fileName, "文件名不能为空");
                    CommUtils.Assert(fileName.Length <= 100, "选择的文件名称[{0}]不能超过100个字符数", fileName);
                    CommUtils.Assert(!folder.Files.Any(x => x.FileSeries.Name == fileSeriesNames[i]),
                                     "文件[{0}]已经存在", fileSeriesNames[i]);

                    var memoryStream = new MemoryStream(new BinaryReader(file.InputStream).ReadBytes(file.ContentLength));
                    var newFile = Platform.Repository.AddFile(fileName, memoryStream);
                    fileGuids.Add(newFile.Guid);

                    dict[newFile] = file;
                }

                var result = new List <DMSFile>();
                string operationType = "上传";

                if (dict.Keys.Count == 0)
                {
                    operationType = "创建";
                    fileSeriesNames.ForEach(x =>
                    {
                        NewFileSeries(x, folder);
                    });
                }


                for (int i = 0; i < dict.Keys.Count; i++)
                {
                    var repoFile = dict.Keys.ElementAt(i);
                    var fileSeriesName = fileSeriesNames[i];
                    var dmsFileSeries = new DMSFileSeries();
                    dmsFileSeries = NewFileSeries(fileSeriesName, folder);

                    var now = DateTime.Now;
                    DMSFile dmsFile = new DMSFile();
                    dmsFile.DMSId = dms.Instance.Id;
                    dmsFile.DMSFileSeriesId = dmsFileSeries.Id;

                    dmsFile.RepoFileId = repoFile.Id;
                    dmsFile.Name = repoFile.Name;
                    dmsFile.Description = description ?? string.Empty;

                    dmsFile.Size = dict[repoFile].ContentLength;
                    dmsFile.Version = 1;

                    dmsFile.LastModifyUserName = CurrentUserName;
                    dmsFile.LastModifyTime = now;
                    dmsFile.CreateUserName = CurrentUserName;
                    dmsFile.CreateTime = now;

                    result.Add(m_dbAdapter.DMSFile.Create(dmsFile));
                }

                var task = new TaskLogicModel(dms.ProjectLogicModel, shortCode);
                task.Start();

                var fileSeriesNamesArray = fileSeriesNames.ConvertAll(x => "[" + x + "]").ToArray();
                m_dbAdapter.Task.AddTaskLog(task.Instance, "文件夹[" + folder.Instance.Name + "]中" + operationType + "文件" + string.Join(",", fileSeriesNamesArray));

                return ActionUtils.Success(result.Select(x => x.Guid));
            }));
        }