Ejemplo n.º 1
0
        /// <summary>
        /// 上传添加扣分记录
        /// </summary>
        /// <param name="deductsInsEntity"></param>
        /// <returns></returns>
        public string oudInsertDeductIns(ApiDeductUploadContracts deductsInsEntity)
        {
            using (var db = new RepositoryBase().BeginTrans())
            {
                var sNormEntity    = db.IQueryable <ProfileScireCriteria_NormEntity>().FirstOrDefault(d => d.SNormId == deductsInsEntity.SCNorm_Id);
                var sClassifyEntiy = db.IQueryable <ProfileScoreCriteria_ClassifyEntity>().FirstOrDefault(d => d.SClassifyId == sNormEntity.SClassifyId);
                var sTypeEntiy     = db.IQueryable <ProfileScoreCriteria_TypeEntity>().FirstOrDefault(d => d.STypeId == sClassifyEntiy.STypeId);
                var sEntiyEntity   = db.IQueryable <ProfileScoreCriteria_EntryEntity>().FirstOrDefault(d => d.SEntryId == sTypeEntiy.SEntryId);
                var userEntity     = db.IQueryable <UserEntity>().FirstOrDefault(d => d.F_Id == deductsInsEntity.CreatorUserId);

                if (sNormEntity == null)
                {
                    throw new Exception("未找到对应扣分标准!");
                }

                ProfileDeducInsEntity dbDeductIndesEntry = new ProfileDeducInsEntity()
                {
                    DeducIns_Id        = Guid.NewGuid().ToString(),
                    TaskEntry_Id       = deductsInsEntity.TaskEntry_Id,
                    SCNorm_Id          = deductsInsEntity.SCNorm_Id,
                    SCEntryName        = sEntiyEntity.Name,
                    SCTypeName         = sTypeEntiy.Name,
                    SCClassifyName     = sClassifyEntiy.SClassifyName,
                    SCNormProjectName  = sNormEntity.SNormProjectName,
                    SCNormStandardName = sNormEntity.SNormStandardName,
                    DeductionSeveral   = deductsInsEntity.DeductionSeveral,
                    DeductionScore     = deductsInsEntity.DeductionScore,
                    DeductionDescribe  = deductsInsEntity.DeductionDescribe,
                    CreateTime         = DateTime.Now,
                    CreatorUserId      = deductsInsEntity.CreatorUserId,
                    CreatorUserName    = userEntity.F_RealName,
                    SCNormIsDeduct     = sNormEntity.IsDeduct
                };

                db.Insert <ProfileDeducInsEntity>(dbDeductIndesEntry);


                try
                {
                    db.Commit();

                    return(dbDeductIndesEntry.DeducIns_Id);
                }
                catch
                {
                    return("-1");
                }
            }
        }
Ejemplo n.º 2
0
        public bool InsertDeductIns(ApiDeductUploadContracts deductsInsEntity)
        {
            using (var db = new RepositoryBase().BeginTrans())
            {
                var sNormEntity    = db.IQueryable <ProfileScireCriteria_NormEntity>().FirstOrDefault(d => d.SNormId == deductsInsEntity.SCNorm_Id);
                var sClassifyEntiy = db.IQueryable <ProfileScoreCriteria_ClassifyEntity>().FirstOrDefault(d => d.SClassifyId == sNormEntity.SClassifyId);
                var sTypeEntiy     = db.IQueryable <ProfileScoreCriteria_TypeEntity>().FirstOrDefault(d => d.STypeId == sClassifyEntiy.STypeId);
                var sEntiyEntity   = db.IQueryable <ProfileScoreCriteria_EntryEntity>().FirstOrDefault(d => d.SEntryId == sTypeEntiy.SEntryId);
                var userEntity     = db.IQueryable <UserEntity>().FirstOrDefault(d => d.F_Id == deductsInsEntity.CreatorUserId);

                if (sNormEntity == null)
                {
                    throw new Exception("未找到对应扣分标准!");
                }
                if (userEntity == null)
                {
                    throw new Exception("未找到上传用户!");
                }


                //验证判断还能不能扣分
                //查询当前所有的扣分



                ProfileDeducInsEntity dbDeductIndesEntry = new ProfileDeducInsEntity()
                {
                    DeducIns_Id        = Guid.NewGuid().ToString(),
                    TaskEntry_Id       = deductsInsEntity.TaskEntry_Id,
                    SCNorm_Id          = deductsInsEntity.SCNorm_Id,
                    SCEntryName        = sEntiyEntity.Name,
                    SCTypeName         = sTypeEntiy.Name,
                    SCClassifyName     = sClassifyEntiy.SClassifyName,
                    SCNormProjectName  = sNormEntity.SNormProjectName,
                    SCNormStandardName = sNormEntity.SNormStandardName,
                    DeductionSeveral   = deductsInsEntity.DeductionSeveral,
                    DeductionScore     = deductsInsEntity.DeductionScore,
                    DeductionDescribe  = deductsInsEntity.DeductionDescribe,
                    CreateTime         = DateTime.Now,
                    CreatorUserId      = deductsInsEntity.CreatorUserId,
                    CreatorUserName    = userEntity.F_RealName,
                    SCNormIsDeduct     = sNormEntity.IsDeduct
                };

                db.Insert <ProfileDeducInsEntity>(dbDeductIndesEntry);


                deductsInsEntity.images = js.Deserialize <string[]>(deductsInsEntity.imagesStr);

                //上传图片
                if (deductsInsEntity.images != null)
                {
                    string imageId    = string.Empty;
                    string uploadDate = DateTime.Now.ToString("yyyyddMM");
                    string filePath   = string.Empty;

                    foreach (var item in deductsInsEntity.images)
                    {
                        filePath = string.Format(@"{0}\{1}{2}", uploadDate, Guid.NewGuid().ToString(), ".png");

                        string path = imageFolderPath + filePath;

                        string directoryPath = Path.GetDirectoryName(path);
                        Directory.CreateDirectory(directoryPath);

                        if (!File.Exists(path))
                        {
                            byte[]       b = Convert.FromBase64String(item);
                            MemoryStream m = new MemoryStream(b);
                            using (FileStream fs = File.Open(path, System.IO.FileMode.Create))
                            {
                                m.WriteTo(fs);
                                m.Close();
                                fs.Close();
                            }
                        }

                        var deduimgEnity = new ProfileDeducImgEntiy()
                        {
                            DeducImg_Id  = Guid.NewGuid().ToString(),
                            DeducIns_Id  = dbDeductIndesEntry.DeducIns_Id,
                            DeducImgPath = filePath
                        };

                        db.Insert <ProfileDeducImgEntiy>(deduimgEnity);
                    }
                }

                try
                {
                    db.Commit();
                }
                catch
                {
                    return(false);
                }
            }

            return(true);
        }