/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, NosatrafilesEntity entity) { try { service.SaveForm(keyValue, entity); } catch (Exception) { throw; } }
public ActionResult SaveForm(string keyValue, NosatrafilesEntity entity) { var isNew = nosatrafilesbll.GetEntity(keyValue) == null; nosatrafilesbll.SaveForm(keyValue, entity); if (isNew == true) { SendMessage(entity); } return(Success("操作成功。")); }
private KeyValuePair <NosatrafilesEntity, FileInfoEntity> GenEntity(object[] vals, UserBLL userbll, NosatratypeBLL nosatratypebll, string filePath) { var user = ERCHTMS.Code.OperatorProvider.Provider.Current(); NosatrafilesEntity entity = new NosatrafilesEntity() { ID = Guid.NewGuid().ToString() }; entity.FileName = vals[1].ToString().Trim(); object obj = vals[2].ToString().Trim(); var list = nosatratypebll.GetList(String.Format(" and createuserorgcode='{0}' and name='{1}'", user.OrganizeCode, obj.ToString())).ToList(); entity.RefId = list[0].ID; entity.RefName = list[0].Name; entity.PubDepartName = vals[3].ToString().Trim(); entity.PubUserName = vals[4].ToString().Trim(); var uEntity = userbll.GetUserInfoByName(entity.PubDepartName, entity.PubUserName); entity.PubUserId = uEntity.UserId; entity.PubDepartId = uEntity.DepartmentId; entity.PubDate = DateTime.Parse(vals[5].ToString()); obj = vals[6]; string fn = System.IO.Path.Combine(filePath, obj.ToString().Trim()); var fileinfo = new FileInfo(fn); FileInfoEntity fileInfoEntity = new FileInfoEntity(); fileInfoEntity.RecId = entity.ID; //关联ID fileInfoEntity.FolderId = "NosaTraFiles"; fileInfoEntity.FileName = obj.ToString().Trim(); fileInfoEntity.FilePath = string.Format("~/Resource/NosaTraFiles/{0}/{1}", DateTime.Now.ToString("yyyyMMdd"), obj.ToString().Trim()); fileInfoEntity.FileSize = (Math.Round(decimal.Parse(fileinfo.Length.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb) fileInfoEntity.FileExtensions = fileinfo.Extension; fileInfoEntity.FileType = fileinfo.Extension.Replace(".", ""); return(new KeyValuePair <NosatrafilesEntity, FileInfoEntity>(entity, fileInfoEntity)); }
private void SendMessage(NosatrafilesEntity entity) { if (!entity.MsgUserId.IsNullOrWhiteSpace()) { var user = ERCHTMS.Code.OperatorProvider.Provider.Current(); var aList = new UserBLL().GetListForCon(x => entity.MsgUserId.Contains(x.UserId)).Select(x => x.Account); MessageEntity msg = new MessageEntity() { Id = Guid.NewGuid().ToString(), UserId = string.Join(",", aList), UserName = entity.MsgUserName, SendTime = DateTime.Now, SendUser = user.Account, SendUserName = entity.CREATEUSERNAME, Title = "新的NOSA培训文件提醒", Content = string.Format("您有新的NOSA培训文件“{0}”,请即时查阅。", entity.FileName), Category = "其它" }; if (new MessageBLL().SaveForm("", msg)) { JPushApi.PublicMessage(msg); } } }