private void Select()
 {
     try
     {
         Node nodeSelect = treeDepartment.SelectedNode;
         if (nodeSelect != null)
         {
             if (nodeSelect.Name.IndexOf("DEPARTMENT_") > -1)
             {
                 if (!nodeSelect.HasChildNodes)
                 {
                     DepartmentEntity department = (DepartmentEntity)nodeSelect.Tag;
                     DepartmentTree.CreateDepartmentUser(nodeSelect, department.Id, "");
                 }
             }
             if (nodeSelect.Name.IndexOf("DEPARTMENTUSER_") > -1)
             {
                 if (DepartmentInterface != null)
                 {
                     DepartmentUserEntity departmentUser = (DepartmentUserEntity)nodeSelect.Tag;
                     DepartmentEntity     department     = (DepartmentEntity)nodeSelect.Parent.Tag;
                     DepartmentInterface.DepartmentCallBack(departmentUser, department);
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show("调用界面没有定义DepartmentCallBack接口,请联系系统管理员!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Exemplo n.º 2
0
        public IEnumerable <DrugEntity> GetPageList(string name, string deptid, int page, int pagesize, out int total)
        {
            var query = this.BaseRepository().IQueryable();
            //query = query.Where(x => x.BZId == deptid);
            var dpservice = new DepartmentService();
            var dept      = new DepartmentEntity();

            var bzids = new WorkOrderService().GetWorkOrderGroup(deptid).Select(x => x.departmentid).ToList();

            if (bzids.Count == 0)
            {
                query = query.Where(x => x.BZId == deptid);
            }
            else
            {
                query = query.Where(x => bzids.Contains(x.BZId));
            }
            if (!string.IsNullOrEmpty(name))
            {
                query = query.Where(x => x.DrugName.Contains(name));
            }
            total = query.Count();
            return(query.OrderByDescending(x => x.CreateDate).Skip(pagesize * (page - 1)).Take(pagesize).ToList());
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="queryJson">查询参数</param>
        /// <returns>返回列表</returns>
        public IEnumerable <ToolTypeEntity> GetList(string deptid)
        {
            var query = this.BaseRepository().IQueryable();

            //Operator user = OperatorProvider.Provider.Current();
            if (deptid != null)
            {
                //string deptid = user.DeptId;
                var dpservice = new DepartmentService();
                var dept      = new DepartmentEntity();

                var bzids = new WorkOrderService().GetWorkOrderGroup(deptid).Select(x => x.departmentid).ToList();

                if (bzids.Count == 0)
                {
                    query = query.Where(x => x.BZId == deptid);
                }
                else
                {
                    query = query.Where(x => bzids.Contains(x.BZId));
                }
            }
            return(query.OrderBy(x => x.CreateDate).ToList());
        }
        /// <summary>
        ///     Updates the department.
        /// </summary>
        /// <param name="departmentEntity">The department entity.</param>
        /// <returns></returns>
        public DepartmentResponse UpdateDepartment(DepartmentEntity departmentEntity)
        {
            var response = new DepartmentResponse {
                Acknowledge = AcknowledgeType.Success
            };

            try
            {
                if (!departmentEntity.Validate())
                {
                    foreach (var error in departmentEntity.ValidationErrors)
                    {
                        response.Message += error + Environment.NewLine;
                    }
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
                using (var scope = new TransactionScope())
                {
                    response.Message = DepartmentDao.UpdateDepartment(departmentEntity);
                    if (!string.IsNullOrEmpty(response.Message))
                    {
                        response.Acknowledge = AcknowledgeType.Failure;
                        return(response);
                    }
                    scope.Complete();
                }
                response.DepartmentId = departmentEntity.DepartmentId;
                return(response);
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                return(response);
            }
        }
 public ActionResult EditDepartment(DepartmentEntity data)
 {
     data.CreatedBy = ApplicationSession.CurrentUser.Id;
     try
     {
         if (ModelState.IsValid)
         {
             bool result = _departmentservice.UpdateDepartment(data.Id, data);
             if (result)
             {
                 return(Json(new { success = true }));
             }
             else
             {
                 ModelState.AddModelError("", "Network Error Try Again ");
             }
         }
     }
     catch
     {
         ModelState.AddModelError("", "Unable to Save. Try again, and if the problem persists see your system administrator.");// handle for database troble
     }
     return(PartialView("_UserEdit", data));
 }
Exemplo n.º 6
0
        public async Task <_ <DepartmentEntity> > Update(DepartmentEntity model)
        {
            model.Should().NotBeNull("dept update model");
            model.Id.Should().NotBeNullOrEmpty("dept update uid");
            model.NodeName.Should().NotBeNullOrEmpty("dept update dept name");

            var res = new _ <DepartmentEntity>();

            var data = await this._deptRepo.QueryOneAsync(x => x.Id == model.Id);

            data.Should().NotBeNull();

            if (await this._deptRepo.ExistAsync(x => x.NodeName == model.NodeName && x.Id != model.Id))
            {
                return(res.SetErrorMsg("部门名称已经存在"));
            }

            data.NodeName    = model.NodeName;
            data.Description = model.Description;

            await this._deptRepo.UpdateAsync(data);

            return(res.SetSuccessData(data));
        }
Exemplo n.º 7
0
        public List <DepartmentEntity> FetchAllDepartments(DataAccess dataAccess)
        {
            List <DepartmentEntity> departments = new List <DepartmentEntity>();

            try {
                command = new SqlCommand(FECTH_ALL_DEPARTMENTS, dataAccess.GetConnection());
                reader  = command.ExecuteReader();

                while (reader.Read())
                {
                    DepartmentEntity departmentEntity = new DepartmentEntity();

                    departmentEntity.Id   = reader.GetInt32(reader.GetOrdinal("id"));
                    departmentEntity.Name = reader.GetString(reader.GetOrdinal("name"));

                    departments.Add(departmentEntity);
                }
                reader.Close();
            } catch (SqlException exc) {
            }

            eventsCount = departments.Count;
            return(departments);
        }
Exemplo n.º 8
0
 /// <summary>
 /// 保存部门表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="departmentEntity">机构实体</param>
 /// <returns></returns>
 public void AddDepartment(string keyValue, DepartmentEntity departmentEntity)
 {
     _departmentService.AddDepartment(keyValue, departmentEntity);
 }
 public void SaveDepartment(DepartmentEntity department)
 {
     SaveEntity(department);
 }
Exemplo n.º 10
0
 /// <summary>
 /// 保存部门信息
 /// </summary>
 /// <param name="Department">部门信息实体</param>
 /// <returns></returns>
 public int SaveDepartment(DepartmentEntity Department)
 {
     return(DataAccess.SaveDepartment(Department));
 }
Exemplo n.º 11
0
        /// <summary>
        /// 获得指定模块或者编号的单据号(直接使用)
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="moduleId">模块ID</param>
        /// <param name="enCode">模板编码</param>
        /// <returns>单据号</returns>
        public string SetBillCode(string userId, string moduleId, string enCode, IRepository db = null)
        {
            IRepository dbc = null;

            if (db == null)
            {
                dbc = new RepositoryFactory().BaseRepository();
            }
            else
            {
                dbc = db;
            }
            UserEntity     userEntity     = db.FindEntity <UserEntity>(userId);
            CodeRuleEntity coderuleentity = db.FindEntity <CodeRuleEntity>(t => t.ModuleId == moduleId || t.EnCode == enCode);
            //判断种子是否已经产生,如果没有产生种子先插入一条初始种子
            CodeRuleSeedEntity initSeed = db.FindEntity <CodeRuleSeedEntity>(t => t.RuleId == coderuleentity.RuleId);

            if (initSeed == null)
            {
                initSeed = new CodeRuleSeedEntity();
                initSeed.Create();
                initSeed.SeedValue  = 1;
                initSeed.RuleId     = coderuleentity.RuleId;
                initSeed.CreateDate = null;
                //db.Insert<CodeRuleSeedEntity>(initSeed);
            }
            //获得模板ID
            string billCode     = "";    //单据号
            string nextBillCode = "";    //单据号
            bool   isOutTime    = false; //是否已过期

            if (coderuleentity != null)
            {
                try
                {
                    int nowSerious = 0;
                    //取得流水号种子
                    List <CodeRuleSeedEntity> codeRuleSeedlist = db.IQueryable <CodeRuleSeedEntity>(t => t.RuleId == coderuleentity.RuleId).ToList();
                    //取得最大种子
                    CodeRuleSeedEntity maxSeed = db.FindEntity <CodeRuleSeedEntity>(t => t.UserId == null);
                    #region 处理隔天流水号归0
                    //首先确定最大种子是否是隔天未归0的
                    if ((maxSeed.ModifyDate).ToDateString() != DateTime.Now.ToString("yyyy-MM-dd"))
                    {
                        isOutTime          = true;
                        maxSeed.SeedValue  = 1;
                        maxSeed.ModifyDate = DateTime.Now;
                    }
                    #endregion
                    if (maxSeed == null)
                    {
                        maxSeed = initSeed;
                    }
                    List <CodeRuleFormatEntity> codeRuleFormatList = coderuleentity.RuleFormatJson.ToList <CodeRuleFormatEntity>();
                    foreach (CodeRuleFormatEntity codeRuleFormatEntity in codeRuleFormatList)
                    {
                        switch (codeRuleFormatEntity.ItemType.ToString())
                        {
                        //自定义项
                        case "0":
                            billCode     = billCode + codeRuleFormatEntity.FormatStr;
                            nextBillCode = nextBillCode + codeRuleFormatEntity.FormatStr;
                            break;

                        //日期
                        case "1":
                            //日期字符串类型
                            billCode     = billCode + DateTime.Now.ToString(codeRuleFormatEntity.FormatStr.Replace("m", "M"));
                            nextBillCode = nextBillCode + DateTime.Now.ToString(codeRuleFormatEntity.FormatStr.Replace("m", "M"));

                            break;

                        //流水号
                        case "2":
                            //查找当前用户是否已有之前未用掉的种子
                            CodeRuleSeedEntity codeRuleSeedEntity = codeRuleSeedlist.Find(t => t.UserId == userId && t.RuleId == coderuleentity.RuleId);
                            //删除已过期的用户未用掉的种子
                            if (codeRuleSeedEntity != null && isOutTime)
                            {
                                db.Delete <CodeRuleSeedEntity>(codeRuleSeedEntity);
                                codeRuleSeedEntity = null;
                            }
                            //如果没有就取当前最大的种子
                            if (codeRuleSeedEntity == null)
                            {
                                //取得系统最大的种子
                                int maxSerious = (int)maxSeed.SeedValue;
                                nowSerious         = maxSerious;
                                codeRuleSeedEntity = new CodeRuleSeedEntity();
                                codeRuleSeedEntity.Create();
                                codeRuleSeedEntity.SeedValue = maxSerious;
                                codeRuleSeedEntity.UserId    = userId;
                                codeRuleSeedEntity.RuleId    = coderuleentity.RuleId;
                                //db.Insert<CodeRuleSeedEntity>(codeRuleSeedEntity);
                                //处理种子更新
                                maxSeed.SeedValue += 1;
                                if (maxSeed.CreateDate != null)
                                {
                                    db.Update <CodeRuleSeedEntity>(maxSeed);
                                }
                                else
                                {
                                    maxSeed.CreateDate = DateTime.Now;
                                    db.Insert <CodeRuleSeedEntity>(maxSeed);
                                }
                            }
                            else
                            {
                                nowSerious = (int)codeRuleSeedEntity.SeedValue;
                            }
                            string seriousStr     = new string('0', (int)(codeRuleFormatEntity.FormatStr.Length - nowSerious.ToString().Length)) + nowSerious.ToString();
                            string NextSeriousStr = new string('0', (int)(codeRuleFormatEntity.FormatStr.Length - nowSerious.ToString().Length)) + maxSeed.SeedValue.ToString();
                            billCode     = billCode + seriousStr;
                            nextBillCode = nextBillCode + NextSeriousStr;

                            break;

                        //部门
                        case "3":
                            DepartmentEntity departmentEntity = db.FindEntity <DepartmentEntity>(userEntity.DepartmentId);
                            if (codeRuleFormatEntity.FormatStr == "code")
                            {
                                billCode     = billCode + departmentEntity.EnCode;
                                nextBillCode = nextBillCode + departmentEntity.EnCode;
                            }
                            else
                            {
                                billCode     = billCode + departmentEntity.FullName;
                                nextBillCode = nextBillCode + departmentEntity.FullName;
                            }
                            break;

                        //公司
                        case "4":
                            OrganizeEntity organizeEntity = db.FindEntity <OrganizeEntity>(userEntity.OrganizeId);
                            if (codeRuleFormatEntity.FormatStr == "code")
                            {
                                billCode     = billCode + organizeEntity.EnCode;
                                nextBillCode = nextBillCode + organizeEntity.EnCode;
                            }
                            else
                            {
                                billCode     = billCode + organizeEntity.FullName;
                                nextBillCode = nextBillCode + organizeEntity.FullName;
                            }
                            break;

                        //用户
                        case "5":
                            if (codeRuleFormatEntity.FormatStr == "code")
                            {
                                billCode     = billCode + userEntity.EnCode;
                                nextBillCode = nextBillCode + userEntity.EnCode;
                            }
                            else
                            {
                                billCode     = billCode + userEntity.Account;
                                nextBillCode = nextBillCode + userEntity.Account;
                            }
                            break;

                        default:
                            break;
                        }
                    }
                    coderuleentity.CurrentNumber = nextBillCode;
                    db.Update <CodeRuleEntity>(coderuleentity);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(billCode);
        }
Exemplo n.º 12
0
 public ActionResult SaveForm(string keyValue, DepartmentEntity departmentEntity)
 {
     departmentBLL.SaveForm(keyValue, departmentEntity);
     return(Success("操作成功。"));
 }
Exemplo n.º 13
0
 public bool Save(DepartmentEntity entity)
 {
     return(depAccess.Save(entity));
 }
Exemplo n.º 14
0
        public string ImportStandard(string refid, string refname, string deptcode)
        {
            try
            {
                if (OperatorProvider.Provider.Current().IsSystem)
                {
                    return("超级管理员无此操作权限");
                }
                string orgId        = OperatorProvider.Provider.Current().OrganizeId;//所属公司
                int    error        = 0;
                int    success      = 0;
                string message      = "请选择文件格式正确的文件再导入!";
                string falseMessage = "";
                int    count        = HttpContext.Request.Files.Count;
                if (count > 0)
                {
                    if (HttpContext.Request.Files.Count != 2)
                    {
                        return("请按正确的方式导入两个文件.");
                    }
                    HttpPostedFileBase file  = HttpContext.Request.Files[0];
                    HttpPostedFileBase file2 = HttpContext.Request.Files[1];
                    if (string.IsNullOrEmpty(file.FileName) || string.IsNullOrEmpty(file2.FileName))
                    {
                        return(message);
                    }
                    Boolean isZip1 = file.FileName.Substring(file.FileName.IndexOf('.')).Contains("zip");   //第一个文件是否为Zip格式
                    Boolean isZip2 = file2.FileName.Substring(file2.FileName.IndexOf('.')).Contains("zip"); //第二个文件是否为Zip格式
                    if ((isZip1 || isZip2) == false || (isZip1 && isZip2) == true)
                    {
                        return(message);
                    }
                    string fileName1 = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName);
                    file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName1));
                    string fileName2 = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file2.FileName);
                    file2.SaveAs(Server.MapPath("~/Resource/temp/" + fileName2));
                    string decompressionDirectory = Server.MapPath("~/Resource/decompression/") + DateTime.Now.ToString("yyyyMMddhhmmssfff") + "\\";
                    Aspose.Cells.Workbook wb      = new Aspose.Cells.Workbook();
                    if (isZip1)
                    {
                        UnZip(Server.MapPath("~/Resource/temp/" + fileName1), decompressionDirectory, "", true);
                        wb.Open(Server.MapPath("~/Resource/temp/" + fileName2));
                    }
                    else
                    {
                        UnZip(Server.MapPath("~/Resource/temp/" + fileName2), decompressionDirectory, "", true);
                        wb.Open(Server.MapPath("~/Resource/temp/" + fileName1));
                    }

                    Aspose.Cells.Cells cells = wb.Worksheets[0].Cells;
                    DataTable          dt    = cells.ExportDataTable(1, 0, cells.MaxDataRow, cells.MaxColumn, false);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        StdsysFilesEntity standard = new StdsysFilesEntity();
                        standard.ID = Guid.NewGuid().ToString();

                        //文件名称
                        string filename = dt.Rows[i][0].ToString();
                        //文件编号
                        string fileno = dt.Rows[i][1].ToString();



                        //---****值存在空验证*****--
                        if (string.IsNullOrEmpty(filename) || string.IsNullOrEmpty(dt.Rows[i][2].ToString()))
                        {
                            falseMessage += "</br>" + "第" + (i + 1) + "行值存在空,未能导入.";
                            error++;
                            continue;
                        }

                        bool conbool = false;


                        //文件路径
                        string[] filepaths = dt.Rows[i][2].ToString().Split(';');

                        var filepath = "";
                        for (int j = 0; j < filepaths.Length; j++)
                        {
                            filepath = filepaths[j];

                            if (string.IsNullOrEmpty(filepath))
                            {
                                continue;
                            }

                            //---****文件格式验证*****--
                            if (!(filepath.Substring(filepath.IndexOf('.')).Contains("doc") || filepath.Substring(filepath.IndexOf('.')).Contains("docx") || filepath.Substring(filepath.IndexOf('.')).Contains("pdf")))
                            {
                                falseMessage += "</br>" + "第" + (i + 1) + "行指定附件格式不正确,未能导入.";
                                error++;
                                conbool = true;
                                continue;
                            }

                            //---****文件是否存在验证*****--
                            if (!System.IO.File.Exists(decompressionDirectory + filepath))
                            {
                                falseMessage += "</br>" + "第" + (i + 1) + "行指定附件不存在,未能导入.";
                                error++;
                                conbool = true;
                                continue;
                            }
                            var            fileinfo       = new FileInfo(decompressionDirectory + filepath);
                            FileInfoEntity fileInfoEntity = new FileInfoEntity();
                            string         fileguid       = Guid.NewGuid().ToString();
                            fileInfoEntity.Create();
                            fileInfoEntity.RecId          = standard.ID; //关联ID
                            fileInfoEntity.FileName       = filepath;
                            fileInfoEntity.FilePath       = "~/Resource/StandardSystem/" + fileguid + fileinfo.Extension;
                            fileInfoEntity.FileSize       = (Math.Round(decimal.Parse(fileinfo.Length.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb)
                            fileInfoEntity.FileExtensions = fileinfo.Extension;
                            fileInfoEntity.FileType       = fileinfo.Extension.Replace(".", "");
                            TransportRemoteToServer(Server.MapPath("~/Resource/StandardSystem/"), decompressionDirectory + filepath, fileguid + fileinfo.Extension);
                            fileinfobll.SaveForm("", fileInfoEntity);
                        }

                        if (conbool)
                        {
                            continue;
                        }

                        standard.FileName = filename;
                        standard.FileNo   = fileno;
                        standard.RefId    = refid;
                        standard.RefName  = refname;
                        DepartmentEntity deptEntity = deptBll.GetEntityByCode(deptcode);
                        if (deptEntity != null)
                        {
                            standard.PubDepartId   = deptEntity.DepartmentId;
                            standard.PubDepartName = deptEntity.FullName;
                        }
                        else
                        {
                            standard.PubDepartId   = OperatorProvider.Provider.Current().DeptId;
                            standard.PubDepartName = OperatorProvider.Provider.Current().DeptName;
                        }


                        if (!string.IsNullOrEmpty(dt.Rows[i][3].ToString()))
                        {
                            standard.PubDate = Convert.ToDateTime(dt.Rows[i][3].ToString());
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[i][4].ToString()))
                        {
                            standard.ReviseDate = Convert.ToDateTime(dt.Rows[i][4].ToString());
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[i][5].ToString()))
                        {
                            standard.UseDate = Convert.ToDateTime(dt.Rows[i][5].ToString());
                        }
                        standard.Remark = !string.IsNullOrEmpty(dt.Rows[i][6].ToString()) ? dt.Rows[i][6].ToString() : "";

                        try
                        {
                            stdsysfilesbll.SaveForm(standard.ID, standard);
                            success++;
                        }
                        catch
                        {
                            error++;
                        }
                    }
                    message  = "共有" + dt.Rows.Count + "条记录,成功导入" + success + "条,失败" + error + "条";
                    message += "</br>" + falseMessage;
                }
                return(message);
            }
            catch (Exception e)
            {
                return("导入的Excel数据格式不正确,请下载标准模板重新填写!");
            }
        }
Exemplo n.º 15
0
        public object getSafetyLawList([FromBody] JObject json)
        {
            try
            {
                string  res    = json.Value <string>("json");
                dynamic dy     = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userId = dy.userid;
                //获取用户基本信息
                OperatorProvider.AppUserId = userId;  //设置当前用户
                Operator user     = OperatorProvider.Provider.Current();
                var      reqParam = JsonConvert.DeserializeAnonymousType(res, new
                {
                    data = new
                    {
                        ORGANIZECODE = string.Empty
                    }
                });
                string filename     = dy.data.filename; //文件名称
                string type         = dy.data.type;     //类型(1:生产法律法规 2.安全管理制度 3.安全操作规程 4.安全法律法规最新五条数据)
                string organizecode = string.IsNullOrEmpty(reqParam.data.ORGANIZECODE) ? user.OrganizeCode : reqParam.data.ORGANIZECODE;
                string orgcode      = reqParam.data.ORGANIZECODE;
                string strwhere     = "";
                string sql          = "";
                if (!string.IsNullOrEmpty(filename))
                {
                    strwhere += " and filename like '%" + filename + "%'";
                }
                string codewhere = "";
                if (user.DeptCode == user.OrganizeCode)
                {
                    codewhere = "";
                }
                else
                {
                    var provdata = departmentBLL.GetList().Where(t => t.Nature == "省级" && !t.FullName.Contains("各电厂") && t.FullName != "区域子公司" && t.DeptCode.StartsWith(user.NewDeptCode.Substring(0, 3)));
                    DepartmentEntity provEntity = null;
                    //省级根节点
                    if (provdata.Count() > 0)
                    {
                        provEntity = provdata.FirstOrDefault();
                        codewhere  = string.Format(" or createuserorgcode='{0}'", provEntity.EnCode);
                    }
                }

                if (type == "1") //安全生产法律法规
                {
                    if (!string.IsNullOrEmpty(orgcode))
                    {
                        if (orgcode == "省级")
                        {
                            sql = string.Format(@"select id as fileid,filename,issuedept,to_char(carrydate,'yyyy-mm-dd') as carrydate  from bis_safetylaw  where (createuserorgcode='00' {1}) {0} order by createdate desc", strwhere, codewhere);
                        }
                        else
                        {
                            sql = string.Format(@"select id as fileid,filename,issuedept,to_char(carrydate,'yyyy-mm-dd') as carrydate  from bis_safetylaw  where (createuserorgcode='{1}') {0} order by createdate desc", strwhere, orgcode);
                        }
                    }
                    else
                    {
                        if (user.RoleName.Contains("省级用户"))
                        {
                            sql = string.Format(@"select id as fileid,filename,issuedept,to_char(carrydate,'yyyy-mm-dd') as carrydate  from bis_safetylaw  where (createuserorgcode='00' or createuserorgcode='{1}') {0} order by createdate desc", strwhere, user.OrganizeCode);
                        }
                        else
                        {
                            sql = string.Format(@"select id as fileid,filename,issuedept,to_char(carrydate,'yyyy-mm-dd') as carrydate  from bis_safetylaw  where (createuserorgcode='{1}' {2} or createuserorgcode='00') {0} order by createdate desc", strwhere, user.OrganizeCode, codewhere);
                        }
                    }
                }
                if (type == "2")
                {
                    if (!string.IsNullOrEmpty(orgcode))
                    {
                        if (orgcode == "省级")
                        {
                            sql = string.Format(@"select id as fileid,filename,b.itemname as lawtypecode,to_char(carrydate,'yyyy-mm-dd') as carrydate  from  bis_safeinstitution a left join base_dataitemdetail b on a.lawtypecode=b.itemvalue where itemid =(select  itemid from base_dataitem where itemcode='InstitutionLaw') and  (a.createuserorgcode='00' {1}) {0} order by a.createdate desc", strwhere, codewhere);
                        }
                        else
                        {
                            sql = string.Format(@"select id as fileid,filename,b.itemname as lawtypecode,to_char(carrydate,'yyyy-mm-dd') as carrydate  from  bis_safeinstitution a left join base_dataitemdetail b on a.lawtypecode=b.itemvalue where itemid =(select  itemid from base_dataitem where itemcode='InstitutionLaw') and  (a.createuserorgcode='{1}')  {0} order by a.createdate desc", strwhere, orgcode);
                        }
                    }
                    else
                    {
                        //安全管理制度
                        if (user.RoleName.Contains("省级用户"))
                        {
                            sql = string.Format(@"select id as fileid,filename,b.itemname as lawtypecode,to_char(carrydate,'yyyy-mm-dd') as carrydate  from  bis_safeinstitution a left join base_dataitemdetail b on a.lawtypecode=b.itemvalue where itemid =(select  itemid from base_dataitem where itemcode='InstitutionLaw') and  (a.createuserorgcode in (select encode from base_department where deptcode like '{1}%') or a.createuserorgcode='00') {0} order by a.createdate desc", strwhere, organizecode);
                        }
                        else
                        {
                            sql = string.Format(@"select id as fileid,filename,b.itemname as lawtypecode,to_char(carrydate,'yyyy-mm-dd') as carrydate  from  bis_safeinstitution a left join base_dataitemdetail b on a.lawtypecode=b.itemvalue where itemid =(select  itemid from base_dataitem where itemcode='InstitutionLaw') and  (a.createuserorgcode='{1}' {2} or a.createuserorgcode='00') {0} order by a.createdate desc", strwhere, user.OrganizeCode, codewhere);
                        }
                    }
                }

                if (type == "3")
                {
                    if (!string.IsNullOrEmpty(orgcode))
                    {
                        if (orgcode == "省级")
                        {
                            sql = string.Format(@"select id as fileid,filename,b.itemname as lawtypecode,to_char(carrydate,'yyyy-mm-dd') as carrydate  from  bis_safestandards a left join base_dataitemdetail b on a.lawtypecode=b.itemvalue where itemid =(select  itemid from base_dataitem where itemcode='StandardsLaw') and (a.createuserorgcode='00' {1}) {0} order by a.createdate desc", strwhere, codewhere);
                        }
                        else
                        {
                            sql = string.Format(@"select id as fileid,filename,b.itemname as lawtypecode,to_char(carrydate,'yyyy-mm-dd') as carrydate  from  bis_safestandards a left join base_dataitemdetail b on a.lawtypecode=b.itemvalue where itemid =(select  itemid from base_dataitem where itemcode='StandardsLaw') and (a.createuserorgcode='{1}') {0} order by a.createdate desc", strwhere, orgcode);
                        }
                    }
                    else
                    {
                        if (user.RoleName.Contains("省级用户"))
                        {
                            sql = string.Format(@"select id as fileid,filename,b.itemname as lawtypecode,to_char(carrydate,'yyyy-mm-dd') as carrydate  from  bis_safestandards a left join base_dataitemdetail b on a.lawtypecode=b.itemvalue where itemid =(select  itemid from base_dataitem where itemcode='StandardsLaw') and (a.createuserorgcode in (select encode from base_department where deptcode  like '{1}%') or a.createuserorgcode='00') {0} order by a.createdate desc", strwhere, organizecode);
                        }
                        else
                        {
                            sql = string.Format(@"select id as fileid,filename,b.itemname as lawtypecode,to_char(carrydate,'yyyy-mm-dd') as carrydate  from  bis_safestandards a left join base_dataitemdetail b on a.lawtypecode=b.itemvalue where itemid =(select  itemid from base_dataitem where itemcode='StandardsLaw') and (a.createuserorgcode='{1}' {2} or a.createuserorgcode='00') {0} order by a.createdate desc", strwhere, user.OrganizeCode, codewhere);
                        }
                    }
                }

                if (type == "4")
                {
                    sql = string.Format(@"select a.* from (select  id as fileid,filename,issuedept,to_char(carrydate,'yyyy-mm-dd') as carrydate  from bis_safetylaw where createuserorgcode='{1}' {0}  order by createdate desc)a where rownum <=5 ", strwhere, user.OrganizeCode);
                }
                DataTable dt = pbll.GetPerilEngineeringList(sql);
                return(new
                {
                    Code = 0,
                    Count = dt.Rows.Count,
                    Info = "获取数据成功",
                    data = dt
                });
            }
            catch (Exception ex)
            {
                return(new { Code = -1, Count = 0, Info = ex.Message });
            }
        }
Exemplo n.º 16
0
 public ActionResult SaveForm(string keyValue, DepartmentEntity entity)
 {
     departmentIBLL.SaveEntity(keyValue, entity);
     return(Success("保存成功!"));
 }
Exemplo n.º 17
0
        public async Task <IActionResult> SaveFormJson(DepartmentEntity entity)
        {
            TData <string> obj = await departmentBLL.SaveForm(entity);

            return(Json(obj));
        }
Exemplo n.º 18
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="pagination">分页</param>
        /// <param name="queryJson">查询参数</param>
        /// <returns>返回分页列表</returns>
        public DataTable GetPageDataTable(Pagination pagination, string queryJson)
        {
            DatabaseType dataType   = DbHelper.DbType;
            Operator     user       = ERCHTMS.Code.OperatorProvider.Provider.Current();
            var          queryParam = queryJson.ToJObject();

            //查询条件
            if (!queryParam["filename"].IsEmpty())
            {
                pagination.conditionJson += string.Format(" and FileName like '%{0}%'", queryParam["filename"].ToString());
            }

            if (user.RoleName.Contains("省级用户"))
            {
                if (!queryParam["orgcode"].IsEmpty())
                {
                    pagination.conditionJson += string.Format(" and createuserorgcode ='{0}'", queryParam["orgcode"].ToString());
                }
            }
            else
            {
                //0本级,1上级
                if (!queryParam["state"].IsEmpty())
                {
                    if (queryParam["state"].ToString() == "0")
                    {
                        pagination.conditionJson += string.Format(" and createuserorgcode ='{0}'", user.OrganizeCode);
                    }
                    else
                    {
                        var provdata = DepartmentService.GetList().Where(t => user.NewDeptCode.StartsWith(t.DeptCode) && t.Nature == "省级" && string.IsNullOrWhiteSpace(t.Description));
                        if (provdata.Count() > 0)
                        {
                            DepartmentEntity provEntity = provdata.FirstOrDefault();
                            pagination.conditionJson += string.Format(" and createuserorgcode ='{0}'", provEntity.EnCode);
                        }
                    }
                }
            }
            //时间范围
            if (!queryParam["sTime"].IsEmpty() || !queryParam["eTime"].IsEmpty())
            {
                string startTime = queryParam["sTime"].ToString();
                string endTime   = queryParam["eTime"].ToString();
                if (queryParam["sTime"].IsEmpty())
                {
                    startTime = "1899-01-01";
                }
                if (queryParam["eTime"].IsEmpty())
                {
                    endTime = DateTime.Now.ToString("yyyy-MM-dd");
                }
                pagination.conditionJson += string.Format(" and ReleaseDate between to_date('{0}','yyyy-MM-dd') and  to_date('{1}','yyyy-MM-dd')", startTime, endTime);
            }
            //选择的类型
            if (!queryParam["treeCode"].IsEmpty())
            {
                if (!queryParam["flag"].IsEmpty())
                {
                    if (queryParam["flag"].ToString() == "0")
                    {
                        pagination.conditionJson += string.Format(" and  LawTypeCode='{0}'", queryParam["treeCode"].ToString());
                    }
                    else
                    {
                        pagination.conditionJson += string.Format(@" and LawTypeCode like '{0}%'", queryParam["treeCode"].ToString());
                    }
                }
                else
                {
                    pagination.conditionJson += string.Format(" and  LawTypeCode='{0}'", queryParam["treeCode"].ToString());
                }
            }
            //选中的数据
            if (!queryParam["idsData"].IsEmpty())
            {
                var    ids    = queryParam["idsData"].ToString();
                string idsarr = "";
                if (ids.Contains(','))
                {
                    string[] array = ids.TrimEnd(',').Split(',');
                    foreach (var item in array)
                    {
                        idsarr += "'" + item + "',";
                    }
                    if (idsarr.Contains(","))
                    {
                        idsarr = idsarr.TrimEnd(',');
                    }
                }
                pagination.conditionJson += string.Format(" and id in({0})", idsarr);
            }
            if (!queryParam["code"].IsEmpty())
            {
                pagination.conditionJson += string.Format(" and ISSUEDEPT in (select departmentid from base_department where encode like '{0}%')", queryParam["code"].ToString());
            }
            return(this.BaseRepository().FindTableByProcPager(pagination, dataType));
        }
Exemplo n.º 19
0
 /// <summary>
 /// 添加部门
 /// </summary>
 public int AddDepartment(DepartmentEntity department)
 {
     return(dal.AddDepartment(department));
 }
Exemplo n.º 20
0
 public bool Update(DepartmentEntity entity)
 {
     return(depAccess.Update(entity));
 }
Exemplo n.º 21
0
 /// <summary>
 /// 修改部门
 /// </summary>
 public bool EditDepartment(DepartmentEntity department)
 {
     return(dal.EditDepartment(department));
 }
Exemplo n.º 22
0
 public async Task Create(DepartmentEntity entity)
 {
     var entry = db.Add(entity);
     await context.SaveChangesAsync();
 }
Exemplo n.º 23
0
        /// <summary>
        /// Inserts the department.
        /// </summary>
        /// <param name="department">The department.</param>
        /// <returns></returns>
        public int InsertDepartment(DepartmentEntity department)
        {
            const string sql = @"uspInsert_Department";

            return(Db.Insert(sql, true, Take(department)));
        }
Exemplo n.º 24
0
        public ActionResult SubmitForm(string keyValue, SafetyCollectEntity entity)
        {
            Operator curUser = ERCHTMS.Code.OperatorProvider.Provider.Current();

            string state = string.Empty;

            string flowid = string.Empty;

            string moduleName = "竣工安全验收";

            // <param name="state">是否有权限审核 1:能审核 0 :不能审核</param>
            ManyPowerCheckEntity mpcEntity = dailyexaminebll.CheckAuditPower(curUser, out state, moduleName, curUser.DeptId);

            //新增时会根据角色自动审核
            List <ManyPowerCheckEntity> powerList  = new ManyPowerCheckBLL().GetListBySerialNum(curUser.OrganizeCode, "竣工安全验收");
            List <ManyPowerCheckEntity> checkPower = new List <ManyPowerCheckEntity>();
            var outsouringengineer = outsouringengineerbll.GetEntity(entity.EngineerId);

            //先查出执行部门编码
            for (int i = 0; i < powerList.Count; i++)
            {
                if (powerList[i].CHECKDEPTCODE == "-1" || powerList[i].CHECKDEPTID == "-1")
                {
                    var createdeptentity  = new DepartmentBLL().GetEntity(outsouringengineer.ENGINEERLETDEPTID);
                    var createdeptentity2 = new DepartmentEntity();
                    while (createdeptentity.Nature == "专业" || createdeptentity.Nature == "班组")
                    {
                        createdeptentity2 = new DepartmentBLL().GetEntity(createdeptentity.ParentId);
                        if (createdeptentity2.Nature != "专业" || createdeptentity2.Nature != "班组")
                        {
                            break;
                        }
                    }
                    powerList[i].CHECKDEPTCODE = createdeptentity.DeptCode;
                    powerList[i].CHECKDEPTID   = createdeptentity.DepartmentId;
                    if (createdeptentity2 != null)
                    {
                        powerList[i].CHECKDEPTCODE = createdeptentity.DeptCode + "," + createdeptentity2.DeptCode;
                        powerList[i].CHECKDEPTID   = createdeptentity.DepartmentId + "," + createdeptentity2.DepartmentId;
                    }
                }
                //创建部门
                if (powerList[i].CHECKDEPTCODE == "-3" || powerList[i].CHECKDEPTID == "-3")
                {
                    var createdeptentity = new DepartmentBLL().GetEntityByCode(curUser.DeptCode);
                    while (createdeptentity.Nature == "专业" || createdeptentity.Nature == "班组")
                    {
                        createdeptentity = new DepartmentBLL().GetEntity(createdeptentity.ParentId);
                    }
                    powerList[i].CHECKDEPTCODE = createdeptentity.DeptCode;
                    powerList[i].CHECKDEPTID   = createdeptentity.DepartmentId;
                }
            }
            //登录人是否有审核权限--有审核权限直接审核通过
            for (int i = 0; i < powerList.Count; i++)
            {
                if (powerList[i].CHECKDEPTID.Contains(curUser.DeptId))
                {
                    var rolelist = curUser.RoleName.Split(',');
                    for (int j = 0; j < rolelist.Length; j++)
                    {
                        if (powerList[i].CHECKROLENAME.Contains(rolelist[j]))
                        {
                            checkPower.Add(powerList[i]);
                            break;
                        }
                    }
                }
            }
            if (checkPower.Count > 0)
            {
                state = "1";
                ManyPowerCheckEntity check = checkPower.Last();//当前

                for (int i = 0; i < powerList.Count; i++)
                {
                    if (check.ID == powerList[i].ID)
                    {
                        flowid = powerList[i].ID;
                    }
                }
            }
            else
            {
                state     = "0";
                mpcEntity = powerList.First();
            }
            if (null != mpcEntity)
            {
                entity.FLOWDEPT     = mpcEntity.CHECKDEPTID;
                entity.FLOWDEPTNAME = mpcEntity.CHECKDEPTNAME;
                entity.FLOWROLE     = mpcEntity.CHECKROLEID;
                entity.FLOWROLENAME = mpcEntity.CHECKROLENAME;
                entity.ISSAVED      = "1"; //标记已经从登记到审核阶段
                entity.ISOVER       = "0"; //流程未完成,1表示完成
                //entity.FLOWNAME = entity.FLOWDEPTNAME + "审核中";
                if (mpcEntity.CHECKDEPTNAME == "执行部门" && mpcEntity.CHECKROLENAME == "负责人")
                {
                    entity.FLOWNAME = outsouringengineer.ENGINEERLETDEPT + "审批中";
                }
                else
                {
                    entity.FLOWNAME = mpcEntity.CHECKDEPTNAME + "审批中";
                }
                entity.FlowId = mpcEntity.ID;
            }
            else  //为空则表示已经完成流程
            {
                entity.FLOWDEPT     = "";
                entity.FLOWDEPTNAME = "";
                entity.FLOWROLE     = "";
                entity.FLOWROLENAME = "";
                entity.ISSAVED      = "1"; //标记已经从登记到审核阶段
                entity.ISOVER       = "1"; //流程未完成,1表示完成
                entity.FLOWNAME     = "";
                entity.FlowId       = flowid;
            }
            SafetyCollectbll.SaveForm(keyValue, entity);

            //添加审核记录
            if (state == "1")
            {
                //审核信息表
                AptitudeinvestigateauditEntity aidEntity = new AptitudeinvestigateauditEntity();
                aidEntity.AUDITRESULT   = "0"; //通过
                aidEntity.AUDITTIME     = DateTime.Now;
                aidEntity.AUDITPEOPLE   = curUser.UserName;
                aidEntity.AUDITPEOPLEID = curUser.UserId;
                aidEntity.APTITUDEID    = entity.ID; //关联的业务ID
                aidEntity.AUDITOPINION  = "";        //审核意见
                aidEntity.AUDITSIGNIMG  = curUser.SignImg;
                if (null != mpcEntity)
                {
                    aidEntity.REMARK = (powerList[0].AUTOID.Value - 1).ToString(); //备注 存流程的顺序号

                    //aidEntity.FlowId = mpcEntity.ID;
                }
                else
                {
                    aidEntity.REMARK = "7";
                }
                aidEntity.FlowId      = flowid;
                aidEntity.AUDITDEPTID = curUser.DeptId;
                aidEntity.AUDITDEPT   = curUser.DeptName;

                aptitudeinvestigateauditbll.SaveForm(aidEntity.ID, aidEntity);
            }

            return(Success("操作成功!"));
        }
Exemplo n.º 25
0
        /// <summary>
        /// Updates the department.
        /// </summary>
        /// <param name="department">The department.</param>
        /// <returns></returns>
        public string UpdateDepartment(DepartmentEntity department)
        {
            const string sql = @"uspUpdate_Department";

            return(Db.Update(sql, true, Take(department)));
        }
Exemplo n.º 26
0
 /// <summary>
 /// 删除部门信息
 /// </summary>
 /// <param name="Department">部门信息实体</param>
 /// <returns></returns>
 public int DeleteDepartment(DepartmentEntity Department)
 {
     return(DataAccess.DeleteDepartment(Department));
 }
Exemplo n.º 27
0
        public ActionResult CopyInfo(CopyRequestModel model)
        {
            if (!string.IsNullOrWhiteSpace(model.DeptId) && !string.IsNullOrWhiteSpace(model.Id))
            {
                //先查询出授权信息
                MenuAuthorizeEntity entity = authorizeBLL.GetEntity(model.Id);
                if (entity != null)
                {
                    DepartmentBLL departmentBll = new DepartmentBLL();
                    var           deptIdArry    = model.DeptId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    var           deptCodeArry  = model.DeptCode.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    var           deptNameArry  = model.DeptName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    //菜单授权信息
                    DeptMenuAuthBLL           deptMenuAuthBll  = new DeptMenuAuthBLL();
                    List <DeptMenuAuthEntity> deptMenuAuthList = deptMenuAuthBll.GetList(entity.DepartId);
                    //界面设置
                    List <AppMenuSettingEntity> appMenuSettingEntities =
                        new AppMenuSettingBLL().GetListByDeptId(entity.DepartId);
                    //栏目与菜单的关联关系
                    List <AppSettingAssociationEntity> appSettingAssociationList =
                        new AppSettingAssociationBLL().GetList(entity.DepartId);

                    List <DeptMenuAuthEntity>          insetDeptMenuAuthList     = new List <DeptMenuAuthEntity>();
                    List <MenuAuthorizeEntity>         authorizeEntities         = new List <MenuAuthorizeEntity>();         //复制之后要保存到数据库中的单位授权数据
                    List <AppMenuSettingEntity>        insertMenuSettingEntities = new List <AppMenuSettingEntity>();        //界面设置
                    List <AppSettingAssociationEntity> insertAssociationEntities = new List <AppSettingAssociationEntity>(); //关联关系

                    for (int i = 0; i < deptIdArry.Length; i++)
                    {
                        //1、先复制单位的授权信息
                        DepartmentEntity    deptEntity   = departmentBll.GetEntity(deptIdArry[i]);
                        MenuAuthorizeEntity insertEntity = new MenuAuthorizeEntity()
                        {
                            Id             = Guid.NewGuid().ToString(),
                            DepartId       = deptIdArry[i],
                            DepartCode     = deptCodeArry[i],
                            DepartName     = deptNameArry[i],
                            DisplayName    = deptNameArry[i],
                            BZApiUrl       = entity.BZApiUrl,
                            CreateDate     = entity.CreateDate,
                            CreateUserId   = entity.CreateUserId,
                            CreateUserName = entity.CreateUserName,
                            CulturalUrl    = entity.CulturalUrl,
                            ModifyDate     = entity.ModifyDate,
                            ModifyUserId   = entity.ModifyUserId,
                            ModifyUserName = entity.ModifyUserName,
                            PXApiUrl       = entity.PXApiUrl,
                            RegistCode     = entity.RegistCode,
                            SKApiUrl       = entity.SKApiUrl,
                            TerminalCode   = entity.TerminalCode,
                            ThemeType      = entity.ThemeType,
                            VersionCode    = entity.VersionCode,
                            ParentId       = deptEntity != null? deptEntity.ParentId : "",
                            ParentName     =
                                deptEntity != null && deptEntity.ParentId == "0"
                                    ? ""
                                    : departmentBll.GetEntity(deptEntity.ParentId).FullName
                        };
                        authorizeEntities.Add(insertEntity);
                        //2、复制界面设置
                        appMenuSettingEntities.ForEach(setting =>
                        {
                            AppMenuSettingEntity appMenu = setting.Clone(deptIdArry[i], deptNameArry[i], deptCodeArry[i], appSettingAssociationList, insertAssociationEntities);
                            insertMenuSettingEntities.Add(appMenu);
                        });
                        //3、  复制关联关系
                        //appSettingAssociationList.ForEach(e =>
                        //{
                        //    AppSettingAssociationEntity association = e.Clone(deptIdArry[i], ,insetDeptMenuAuthList);
                        //    insertAssociationEntities.Add(association);
                        //});
                        //4、复制菜单授权信息
                        deptMenuAuthList.ForEach(p =>
                        {
                            DeptMenuAuthEntity deptMenu = p.Clone(deptIdArry[i], deptCodeArry[i], deptNameArry[i]);
                            insetDeptMenuAuthList.Add(deptMenu);
                        });
                    }
                    authorizeBLL.InsertEntity(authorizeEntities.ToArray());
                    new AppMenuSettingBLL().InsertList(insertMenuSettingEntities);
                    new AppSettingAssociationBLL().InsertList(insertAssociationEntities);
                    new DeptMenuAuthBLL().InsertList(insetDeptMenuAuthList);
                }
            }
            return(Success("操作成功"));
        }
Exemplo n.º 28
0
        /// <summary>
        /// 获得指定模块或者编号的单据号
        /// </summary>
        /// <param name="enCode">编码</param>
        /// <param name="userId">用户ID</param>
        /// <returns>单据号</returns>
        public string GetBillCode(string enCode, string userId = "")
        {
            try
            {
                string billCode     = "";    //单据号
                string nextBillCode = "";    //单据号
                bool   isOutTime    = false; //是否已过期


                CodeRuleEntity coderuleentity = GetEntityByCode(enCode);
                if (coderuleentity != null)
                {
                    UserInfo userInfo = null;
                    if (string.IsNullOrEmpty(userId))
                    {
                        userInfo = LoginUserInfo.Get();
                    }
                    else
                    {
                        UserEntity userEntity = userIBLL.GetEntityByUserId(userId);
                        userInfo = new UserInfo
                        {
                            userId       = userEntity.F_UserId,
                            enCode       = userEntity.F_EnCode,
                            password     = userEntity.F_Password,
                            secretkey    = userEntity.F_Secretkey,
                            realName     = userEntity.F_RealName,
                            nickName     = userEntity.F_NickName,
                            headIcon     = userEntity.F_HeadIcon,
                            gender       = userEntity.F_Gender,
                            mobile       = userEntity.F_Mobile,
                            telephone    = userEntity.F_Telephone,
                            email        = userEntity.F_Email,
                            oICQ         = userEntity.F_OICQ,
                            weChat       = userEntity.F_WeChat,
                            companyId    = userEntity.F_CompanyId,
                            departmentId = userEntity.F_DepartmentId,
                            openId       = userEntity.F_OpenId,
                            isSystem     = userEntity.F_SecurityLevel == 1 ? true : false
                        };
                    }

                    int nowSerious = 0;
                    List <CodeRuleFormatModel> codeRuleFormatList = coderuleentity.F_RuleFormatJson.ToList <CodeRuleFormatModel>();
                    string dateFormatStr = "";
                    foreach (CodeRuleFormatModel codeRuleFormatEntity in codeRuleFormatList)
                    {
                        switch (codeRuleFormatEntity.itemType.ToString())
                        {
                        //自定义项
                        case "0":
                            billCode     = billCode + codeRuleFormatEntity.formatStr;
                            nextBillCode = nextBillCode + codeRuleFormatEntity.formatStr;
                            break;

                        //日期
                        case "1":
                            //日期字符串类型
                            dateFormatStr = codeRuleFormatEntity.formatStr;
                            billCode      = billCode + DateTime.Now.ToString(codeRuleFormatEntity.formatStr.Replace("m", "M"));
                            nextBillCode  = nextBillCode + DateTime.Now.ToString(codeRuleFormatEntity.formatStr.Replace("m", "M"));
                            break;

                        //流水号
                        case "2":
                            CodeRuleSeedEntity maxSeed            = null;
                            CodeRuleSeedEntity codeRuleSeedEntity = null;


                            List <CodeRuleSeedEntity> seedList = GetSeedList(coderuleentity.F_RuleId, userInfo);
                            maxSeed = seedList.Find(t => t.F_UserId.IsEmpty());


                            int seedStep  = codeRuleFormatEntity.stepValue == null ? 1 : int.Parse(codeRuleFormatEntity.stepValue.ToString());   //如果步长为空默认1
                            int initValue = codeRuleFormatEntity.initValue == null ? 1 : int.Parse(codeRuleFormatEntity.initValue.ToString());   //如果初始值为空默认1

                            if (maxSeed.IsInit)
                            {
                                maxSeed.F_SeedValue = initValue;
                            }

                            #region 处理流水号归0
                            // 首先确定最大种子是否未归0的
                            if (dateFormatStr.Contains("dd"))
                            {
                                if ((maxSeed.F_ModifyDate).ToDateString() != DateTime.Now.ToString("yyyy-MM-dd"))
                                {
                                    isOutTime            = true;
                                    nowSerious           = initValue;
                                    maxSeed.F_SeedValue  = initValue + seedStep;
                                    maxSeed.F_ModifyDate = DateTime.Now;
                                }
                            }
                            else if (dateFormatStr.Contains("mm"))
                            {
                                if (((DateTime)maxSeed.F_ModifyDate).ToString("yyyy-MM") != DateTime.Now.ToString("yyyy-MM"))
                                {
                                    isOutTime            = true;
                                    nowSerious           = initValue;
                                    maxSeed.F_SeedValue  = initValue + seedStep;
                                    maxSeed.F_ModifyDate = DateTime.Now;
                                }
                            }
                            else if (dateFormatStr.Contains("yy"))
                            {
                                if (((DateTime)maxSeed.F_ModifyDate).ToString("yyyy") != DateTime.Now.ToString("yyyy"))
                                {
                                    isOutTime            = true;
                                    nowSerious           = initValue;
                                    maxSeed.F_SeedValue  = initValue + seedStep;
                                    maxSeed.F_ModifyDate = DateTime.Now;
                                }
                            }
                            #endregion
                            // 查找当前用户是否已有之前未用掉的种子做更新
                            codeRuleSeedEntity = seedList.Find(t => t.F_UserId == userInfo.userId && t.F_RuleId == coderuleentity.F_RuleId && (t.F_CreateDate).ToDateString() == DateTime.Now.ToString("yyyy-MM-dd"));
                            string keyvalue = codeRuleSeedEntity == null ? "" : codeRuleSeedEntity.F_RuleSeedId;
                            if (isOutTime)
                            {
                                SaveSeed(maxSeed.F_RuleSeedId, maxSeed, userInfo);
                            }
                            else if (codeRuleSeedEntity == null)
                            {
                                nowSerious           = (int)maxSeed.F_SeedValue;
                                maxSeed.F_SeedValue += seedStep;    //种子加步长
                                maxSeed.Modify(maxSeed.F_RuleSeedId, userInfo);
                                SaveSeed(maxSeed.F_RuleSeedId, maxSeed, userInfo);
                            }
                            else
                            {
                                nowSerious = (int)codeRuleSeedEntity.F_SeedValue;
                            }

                            codeRuleSeedEntity = new CodeRuleSeedEntity();
                            codeRuleSeedEntity.Create(userInfo);
                            codeRuleSeedEntity.F_SeedValue = nowSerious;
                            codeRuleSeedEntity.F_UserId    = userInfo.userId;
                            codeRuleSeedEntity.F_RuleId    = coderuleentity.F_RuleId;
                            SaveSeed(keyvalue, codeRuleSeedEntity, userInfo);
                            // 最大种子已经过期
                            string seriousStr     = new string('0', (int)(codeRuleFormatEntity.formatStr.Length - nowSerious.ToString().Length)) + nowSerious.ToString();
                            string NextSeriousStr = new string('0', (int)(codeRuleFormatEntity.formatStr.Length - nowSerious.ToString().Length)) + maxSeed.F_SeedValue.ToString();
                            billCode     = billCode + seriousStr;
                            nextBillCode = nextBillCode + NextSeriousStr;
                            break;

                        //部门
                        case "3":
                            DepartmentEntity departmentEntity = departmentIBLL.GetEntity(userInfo.companyId, userInfo.departmentId);
                            if (codeRuleFormatEntity.formatStr == "code")
                            {
                                billCode     = billCode + departmentEntity.F_EnCode;
                                nextBillCode = nextBillCode + departmentEntity.F_EnCode;
                            }
                            else
                            {
                                billCode     = billCode + departmentEntity.F_FullName;
                                nextBillCode = nextBillCode + departmentEntity.F_FullName;
                            }
                            break;

                        //公司
                        case "4":
                            CompanyEntity companyEntity = companyIBLL.GetEntity(userInfo.companyId);
                            if (codeRuleFormatEntity.formatStr == "code")
                            {
                                billCode     = billCode + companyEntity.F_EnCode;
                                nextBillCode = nextBillCode + companyEntity.F_EnCode;
                            }
                            else
                            {
                                billCode     = billCode + companyEntity.F_FullName;
                                nextBillCode = nextBillCode + companyEntity.F_FullName;
                            }
                            break;

                        //用户
                        case "5":
                            if (codeRuleFormatEntity.formatStr == "code")
                            {
                                billCode     = billCode + userInfo.enCode;
                                nextBillCode = nextBillCode + userInfo.enCode;
                            }
                            else
                            {
                                billCode     = billCode + userInfo.account;
                                nextBillCode = nextBillCode + userInfo.account;
                            }
                            break;

                        default:
                            break;
                        }
                    }
                    coderuleentity.F_CurrentNumber = nextBillCode;
                    SaveEntity(coderuleentity.F_RuleId, coderuleentity, userInfo);
                }
                return(billCode);
            }
            catch (Exception ex)
            {
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowBusinessException(ex);
                }
            }
        }
Exemplo n.º 29
0
 public ActionResult SubmitForm(DepartmentEntity infoEntity, string keyValue)
 {
     app.SubmitForm(infoEntity, keyValue);
     return(Success("操作成功。"));
 }
Exemplo n.º 30
0
        /// <summary>
        /// 同步用户
        /// </summary>
        public bool ErchtmsSynchronoous(string type, object o, string account)
        {
            var baseUrl = Config.GetValue("ErchtmsApiUrl");

            if (Config.GetValue("SyncBool") == "f")
            {
                return(true);
            }

            string    id = "";
            WebClient wc = new WebClient();

            wc.Credentials = CredentialCache.DefaultCredentials;
            //发送请求到web api并获取返回值,默认为post方式
            try
            {
                System.Collections.Specialized.NameValueCollection nc = new System.Collections.Specialized.NameValueCollection();
                if (type == "SaveUser")
                {
                    UserEntity user = (UserEntity)o;
                    id = user.UserId;
                    nc.Add("account", account);
                    nc.Add("json", Newtonsoft.Json.JsonConvert.SerializeObject(user));
                }
                else if (type == "SaveDept")
                {
                    DepartmentEntity d = (DepartmentEntity)o;
                    id = d.DepartmentId;
                    nc.Add("account", BSFramework.Application.Code.OperatorProvider.Provider.Current().Account);
                    nc.Add("json", Newtonsoft.Json.JsonConvert.SerializeObject(d));
                }
                else if (type == "SaveRole")
                {
                    RoleEntity r = (RoleEntity)o;
                    id = r.RoleId;
                    nc.Add("account", BSFramework.Application.Code.OperatorProvider.Provider.Current().Account);
                    nc.Add("json", Newtonsoft.Json.JsonConvert.SerializeObject(r));
                }
                if (type == "DeleteUser")
                {
                    UserEntity user = (UserEntity)o;
                    id = user.UserId;
                    nc.Add("account", account);
                    nc.Add("json", Newtonsoft.Json.JsonConvert.SerializeObject(user));
                }
                else if (type == "DeleteDept")
                {
                    DepartmentEntity d = (DepartmentEntity)o;
                    id = d.DepartmentId;
                    nc.Add("account", BSFramework.Application.Code.OperatorProvider.Provider.Current().Account);
                    nc.Add("json", Newtonsoft.Json.JsonConvert.SerializeObject(d));
                }
                else if (type == "DeleteRole")
                {
                    RoleEntity r = (RoleEntity)o;
                    id = r.RoleId;
                    nc.Add("account", BSFramework.Application.Code.OperatorProvider.Provider.Current().Account);
                    nc.Add("json", Newtonsoft.Json.JsonConvert.SerializeObject(r));
                }
                else if (type == "UpdatePwd")
                {
                    string[] r = (string[])o;
                    nc.Add("userId", r[0]);
                    nc.Add("pwd", r[1]);
                    string path = baseUrl + "syncdata/" + type + "?userId=" + r[0] + "&pwd=" + r[1];
                    wc.UploadValuesCompleted += wc_UploadValuesCompleted;
                    wc.UploadValuesAsync(new Uri(path), nc);
                    return(true);
                }


                wc.UploadValuesCompleted += wc_UploadValuesCompleted;
                string a = baseUrl + "syncdata/" + type + "?keyValue=" + id;
                wc.UploadValuesAsync(new Uri(baseUrl + "syncdata/" + type + "?keyValue=" + id), nc);
            }
            catch (Exception ex)
            {
                //将同步结果写入日志文件
                string fileName = DateTime.Now.ToString("yyyyMMdd") + ".log";
                if (!Directory.Exists(System.Web.HttpContext.Current.Server.MapPath("~/logs")))
                {
                    Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath("~/logs"));
                }

                System.IO.File.AppendAllText(System.Web.HttpContext.Current.Server.MapPath("~/logs/" + fileName), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":同步数据失败,同步信息" + Newtonsoft.Json.JsonConvert.SerializeObject(o) + ",异常信息:" + ex.Message + "\r\n");
                return(false);
            }
            return(true);
        }
Exemplo n.º 31
0
 public DepartmentEntity Insert(DepartmentEntity entity);