예제 #1
0
        private bool Delete(Framework.Task.Task task, ref string errmsg)
        {
            XtmUser delModel = new XtmUser();

            delModel.SysKey = task.CommandArgument;
            BaseDao baseDao = new BaseDao();

            this.BeginTran();
            try
            {
                XtmMenuPri delMenuPri = new XtmMenuPri();
                delMenuPri.UserId = int.Parse(task.CommandArgument);
                baseDao.Delete(delMenuPri);

                XtmUserPri delUserPri = new XtmUserPri();
                delUserPri.UserId = int.Parse(task.CommandArgument);
                baseDao.DeleteUdf("XtmUserPriDeleteAll", delUserPri);

                baseDao.Delete(delModel);
                this.CommitTran();
            }
            catch (Exception ex)
            {
                this.RollbackTran();
                errmsg = ex.Message;
                return(false);
            }
            if (errmsg != "")
            {
                return(false);
            }
            errmsg      = "删除成功";
            task.Rebind = true;
            return(true);
        }
예제 #2
0
        private bool YwySubmit(Framework.Task.Task task, ref string errmsg)
        {
            bool result = true;

            this.BeginTran();
            try
            {
                YwData  entity  = task.Entity as YwData;
                BaseDao baseDao = new BaseDao();

                YwAttach att = new YwAttach();
                att.Type   = "1";
                att.Dataid = entity.Did;
                IList <YwAttach> attList = baseDao.List(att);
                if (attList != null && attList.Count > 0)
                {
                    entity.AttachmentCount = attList.Count;
                }
                else
                {
                    entity.AttachmentCount = 0;
                }
                entity.Status    = "3";
                entity.YwySubmit = DateTime.Now;
                if (entity.Bbr.Length <= 4)
                {
                    if (entity.Sfypz == "是")
                    {
                        YwDataService service = new YwDataService();
                        service.FirstCalculate(1, entity);
                        service.SeconeCalculate(entity);
                    }
                }
                else
                {
                    YwDataService service = new YwDataService();
                    service.FirstCalculate(1, entity);
                    service.SeconeCalculate(entity);
                }
                int count = baseDao.Update(entity);
                if (count <= 0)
                {
                    errmsg            = "数据在页面显示后被其他人修改过,请重新打开编辑";
                    task.ParentRebind = true;
                    task.Rebind       = true;
                    task.IsClose      = true;
                    return(false);
                }

                //文件压缩
                //删除压缩文件

                att.Type = "2";

                baseDao.DeleteUdf("YwAttachDeleteByType", att);
                //重新压缩附件
                if (attList != null && attList.Count > 0)
                {
                    string zipdic   = attList[0].Dic;
                    string zipFileN = Guid.NewGuid().ToString() + ".zip";
                    string path     = zipdic + zipFileN;
                    using (ZipFile zip = ZipFile.Create(@path))
                    {
                        zip.BeginUpdate();
                        foreach (YwAttach attTemp in attList)
                        {
                            string pathT = attTemp.Dic + attTemp.FileN;
                            zip.Add(@pathT, attTemp.FileN);
                        }
                        zip.CommitUpdate();
                    }
                    att.Type     = "2";
                    att.Dic      = zipdic;
                    att.FileN    = zipFileN;
                    att.RealName = zipFileN;
                    att.Dataid   = entity.Did;
                    baseDao.Insert(att);
                }
                if (result == true)
                {
                    errmsg            = "保存成功";
                    task.ParentRebind = true;
                    task.IsClose      = true;
                }
                this.CommitTran();
            }
            catch (Exception ex)
            {
                this.RollbackTran();
                errmsg = ex.Message;
            }
            return(result);
        }