Esempio n. 1
0
        private void UpdateDocFile(DocRecordFile file, string path)
        {
            string storedPath = Path.Combine(_docRecordFolder, file.Path);

            if (storedPath == path)
            {
                return;
            }
            string newPath = CopyDocFile(file.DocRecordId, file.DocFollowId, path);

            file.Path = newPath;
        }
Esempio n. 2
0
 protected override void Save()
 {
     if (!IsValid())
     {
         string msg = string.Empty;
         foreach (var error in Errors)
         {
             msg += error.Value?.FirstOrDefault() ?? "";
             msg += "\n";
         }
         Helper.ShowMessage(msg);
         return;
     }
     try
     {
         using (IUnitOfWork unit = new UnitOfWork())
         {
             DocRecordFollow follow = null;
             if (string.IsNullOrEmpty(FollowId))
             {
                 follow = CreateNewDocFollow();
                 unit.DocRecordFollows.Add(follow);
                 DocRecordFile file = CreateDocFile(DocId, follow.Id, FollowPath);
                 unit.DocRecordFiles.Add(file);
             }
             else
             {
                 follow = unit.DocRecordFollows.GetById(FollowId);
                 DocRecordFile file = unit.DocRecordFiles.Query(x => x.DocFollowId == FollowId).SingleOrDefault();
                 if (file != null)
                 {
                     UpdateDocFile(file, FollowPath);
                 }
                 else
                 {
                     var docFile = CreateDocFile(follow.DocRecodId, follow.Id, FollowPath);
                     unit.DocRecordFiles.Add(docFile);
                 }
                 UpdateDocFollow(follow);
             }
             unit.Save();
             FollowId = follow.Id;
             ControlState(ControllerStates.Saved);
         }
     }
     catch (Exception ex)
     {
         Helper.LogShowError(ex);
     }
 }