Ejemplo n.º 1
0
 private void Save(Models.Document record, bool isNew)
 {
     // add any code to update other fields/tables here
     record.Save();
     // save subform or related checkboxes here eg record.Lines.Save();
     //ifsubform: record.example.Save();
     //CheckLock(record);
     //lockobj.UnLockTable(record.GetTableName(),record.ID);
     ActiveRecordLoader.ClearCache("Document");
 }
Ejemplo n.º 2
0
 public static async Task <string> Put(string url, Models.Document data)
 {
     using (HttpClient client = new HttpClient())
     {
         //client.DefaultRequestHeaders.Add("Accept", "application/json");
         string encoded = "Basic " + System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes("admin:1CouchdbeBkhod"));
         client.DefaultRequestHeaders.Add("Authorization", encoded);
         var res = client.PutAsJsonAsync("http://104.192.4.168:5984" + url, data).Result;
         return(await res.Content.ReadAsStringAsync());
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 新增上传文件记录
 /// </summary>
 /// <param name="userIds"></param>
 /// <returns></returns>
 public CommonResult Add(Models.Document documentModel)
 {
     documentModel.DocumentNo = db.Database.SqlQuery <string>("select ([dbo].[GetNextTN]('Document')) ").FirstOrDefault();
     db.Document.Add(documentModel);
     if (db.SaveChanges() < 0)
     {
         return(CommonResult.Instance("新建失败"));
     }
     //AllServices.ActionLogService.AddLog("新增上传记录",model.ToJson(),Enums.ActionCategory.Add);
     Log4NetHelper.Info("新增上传记录", documentModel.ToJson());
     return(CommonResult.Instance(documentModel.UID));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Populates defaults and opens edit form to add new record
        /// GET: /Admin/Document/Create
        /// </summary>
        public ActionResult Create()
        {
            var data = new EditViewModel();

            Breadcrumbs.Current.AddBreadcrumb(data.breadcrumbLevel, "Add Document");
            var record = new Models.Document();

            // any default values can be set here or in partial class Document.InitDefaults()
            record.UpdateFromRequest();              // grab any defaults from querystring
            data.Document = record;
            return(View("DocumentEdit", data));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 加载分页数据(高级查询)
        /// </summary>
        /// <param name="intPageIndex"></param>
        /// <param name="intPageSize"></param>
        /// <param name="whereLambda"></param>
        /// <param name="dicOrderBy"></param>
        /// <returns></returns>
        //public Page<Models.Document> GetSearchByPage(int intPageIndex,int intPageSize,int intFolderUID,string strTag,DateTime dateBeginTime,DateTime dateEndTime,Dictionary<string,string> dicOrderBy = null)
        //{
        //	if(whereLambda == null)
        //	{
        //		whereLambda = u => 1 == 1;
        //	}
        //	int intFolderUID = 71;//所属系统ID
        //	string strTag = "2";//标签
        //	DateTime dateBeginTime = Convert.ToDateTime("2018-01-12");
        //	DateTime dateEndTime = Convert.ToDateTime("2018-01-13");

        //	var q = db.Document.Where(
        //		d => db.DocumentFolder.Where(df => df.FolderUID == intFolderUID).Select(s => s.DocumentUID).Contains(d.UID) &&
        //		db.DocumentTag.Where(dt => dt.Tag.Contains(strTag)).Select(s => s.DocumentUID).Contains(d.UID) &&
        //		d.CreateTime <= dateEndTime && d.CreateTime >= dateBeginTime
        //		);

        //	var q = db.Document.Where(whereLambda).OrderBy(dicOrderBy);
        //	var list = q.Skip((intPageIndex - 1) * intPageSize).Take(intPageSize).ToList();
        //	return new Page<Models.Document>(intPageIndex,intPageSize,q.Count(),list);
        //}

        /// <summary>
        /// 更新项目
        /// </summary>
        /// <param name="documentModel"></param>
        /// <returns></returns>
        public CommonResult Update(Models.Document documentModel)
        {
            if (IsRepeatDocumentName(documentModel.DocumentName, documentModel.DocumentPath))
            {
                return(CommonResult.Instance("已存在此文件名,请换一个再试"));
            }
            db.Document.Where(document => document.UID == documentModel.UID).Update(u => new Models.Document()
            {
                DocumentName = documentModel.DocumentName,
                DocumentPath = documentModel.DocumentPath,
                Editor       = documentModel.Editor,
                EditTime     = documentModel.EditTime,
                State        = documentModel.State
            });
            //AllServices.ActionLogService.AddLog("更新项目信息",model.ToJson(),Enums.ActionCategory.Update);
            Log4NetHelper.Info("更新上传记录", documentModel.ToJson());
            return(CommonResult.Instance());
        }
Ejemplo n.º 6
0
        protected ActionResult ProcessForm(Models.Document record)
        {
            try {
                record.UpdateFromRequest();
                // read subform or related checkboxes here eg record.Lines.UpdateFromRequest();
                //ifsubform: record.example.UpdateFromRequest();

                Validate(record);
                if (ModelState.IsValid)
                {
                    Save(record, record.IsNewRecord);
                    Web.InfoMessage += "Document " + record.GetName() + " saved.";
                }
            } catch (UserErrorException e) {
                ModelState.AddModelError("Record", e.Message);
            }

            if (!ModelState.IsValid)
            {
                // invalid so redisplay form with validation message(s)
                return(View("DocumentEdit", new EditViewModel()
                {
                    Document = record
                }));
            }
            else if (Web.Request["SaveAndRefreshButton"] != null)
            {
                return(RedirectToEdit(record.ID));
            }
            else if (Web.Request["DuplicateButton"] != null)
            {
                var newRecord = new Models.Document();
                newRecord.UpdateFrom(record);
                newRecord.Save();
                Web.InfoMessage += "Copy of Document " + record.GetName() + " created. You are now editing the new copy.";
                return(RedirectToEdit(newRecord.ID));
            }
            else
            {
                return(RedirectToReturnPage());
            }
        }
Ejemplo n.º 7
0
 private void Validate(Models.Document record)
 {
     // add any code to check for validity
     //ModelState.AddModelError("Record", "Suchandsuch cannot be whatever.");
 }