Пример #1
0
        /// <summary>
        /// 载入站点配置
        /// </summary>
        /// <param name="siteShortName">站点短名</param>
        public static void LoadSiteConfig(string siteShortName)
        {
            if (string.IsNullOrWhiteSpace(siteShortName))
            {
                return;
            }

            string content = string.Empty, iv = content, siteini = $"{SitePacksPath}{siteShortName}.ini";

            if (string.IsNullOrWhiteSpace(siteShortName) || inis.Any(d => d.Key == siteShortName))
            {
                return;
            }

            if (File.Exists(siteini))
            {
                //读入并解压
                content = File.ReadAllText(siteini);
                if (string.IsNullOrWhiteSpace(content) || content.Length < 7)
                {
                    return;
                }
                content = Encoding.UTF8.GetString(LZ4Codec.Unwrap(Convert.FromBase64String(content)));
                iv      = content.Substring(0, 6);
                content = AESHelper.AesDecrypt(content.Substring(6), aesKey, iv);
                //解析并入库
                IniData iniData = iniParser.Parser.Parse(content);
                inis.Add(siteShortName, iniData);
                return;
            }
            inis.Add(siteShortName, new IniData());
        }
Пример #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            //请求体正文最大长度200M
            services.Configure <FormOptions>(options => options.MultipartBodyLengthLimit = 200 * 1024 * 1024);

            services.AddDbContext <EFDbContext>(option => option.UseSqlServer(AESHelper.AesDecrypt(Configuration.GetConnectionString("BookContext"))), ServiceLifetime.Scoped);

            services.AddScoped <IUnitOfWork, UnitOfWork>();
        }
        public static SystemEnvironment Decrypt(this byte[] data)
        {
            //return new SystemEnvironment();
            byte[] byteArray = AESHelper.AesDecrypt(data, AESHelper.AESKEY);

            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter serializer = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

            System.IO.MemoryStream memStream = new System.IO.MemoryStream();

            // Set the position to the beginning of the stream.
            memStream.Seek(0, SeekOrigin.Begin);

            memStream.Write(byteArray, 0, byteArray.Length);

            memStream.Close();

            SystemEnvironment result = (SystemEnvironment)serializer.Deserialize(memStream);

            return(result);
        }
Пример #4
0
        public string GetModel4Login(string UserName, string UPassword)
        {
            string sql = "sp_getModel4Login";

            SqlParameter[] pms = new SqlParameter[] {
                new SqlParameter("@UserName", SqlDbType.NVarChar)
                {
                    Value = AESHelper.AesDecrypt(UserName)
                },
                new SqlParameter("@UPassword", SqlDbType.NVarChar)
                {
                    Value = AESHelper.AesDecrypt(UPassword)
                },
                new SqlParameter("@count", SqlDbType.Int)
                {
                    Direction = ParameterDirection.Output
                }
            };
            DataTable dt;

            try
            {
                dt = SQLHelper.ExecuteDataTable(sql, CommandType.StoredProcedure, pms);
                string token = DataHelper.getToken();
                return("{\"code\":1,\"count\":" + pms[2].Value.ToString() + ",\"Token\":\"" + token + "\",\"data\":" + ConvertHelper.DataTableToJson(dt) + "}");
            }
            catch (Exception e)
            {
                //在webapi中要想抛出异常必须这样抛出,否则只抛出一个默认500的异常
                var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content      = new StringContent(e.ToString()),
                    ReasonPhrase = "error"
                };
                throw new HttpResponseException(resp);
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder <EFDbContext>();

            optionsBuilder.UseSqlServer(AESHelper.AesDecrypt("RFwcA+m9Dcqj1DQpyMqtjojDfZIz02/DUAI2GCFF6ooXb8XQawj/7QCQK/fafOQ5zaiMa0gDPPE9FUwrsjD/DU5hW6eG64sAmfSfROf9wrs"));


            using (EFDbContext context = new EFDbContext(optionsBuilder.Options))
            {
                IUnitOfWork unitOfWork = new UnitOfWork(context);
                var         bookRep    = unitOfWork.Repository <Book>();

                foreach (var item in bookRep.Table)
                {
                    //查询文件:
                    string filePath = Path.Combine("C:\\BookUpload", item.URL);
                    if (!File.Exists(filePath))
                    {
                        Console.WriteLine($"编号为{item.ID}的书籍路径为{filePath},查询不到当前书籍");
                        continue;
                    }

                    //获取文件大小
                    if (File.Exists(filePath))
                    {
                        var file = new FileInfo(filePath);
                        item.FileSize = file.Length;
                        Console.WriteLine($"编号为{item.ID}的书籍路径为{filePath},获取到的文件大小为{item.FileSize}");
                    }
                }
                unitOfWork.Commit();
            }

            Console.WriteLine("结束");
            Console.ReadKey();
        }
Пример #6
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtName.Text) || txtName.Text.Length < 1)
                {
                    ThreadPool.QueueUserWorkItem(a =>
                    {
                        CommonHelper.Instance.ShowAlert("用户名不能为空");
                    });
                    return;
                }
                if (string.IsNullOrEmpty(txtPwd.Text) || txtPwd.Text.Length < 1)
                {
                    ThreadPool.QueueUserWorkItem(a =>
                    {
                        CommonHelper.Instance.ShowAlert("密码不能为空");
                    });
                    return;
                }
                string  url        = ServicesAPIHelper.Instance.LoginUrl;
                dynamic reqUserObj = new JObject();
                reqUserObj.userName = txtName.Text.Trim();
                reqUserObj.pwd      = txtPwd.Text.Trim();
                reqUserObj.sysCode  = "TMS";

                string userParamsStr = reqUserObj.ToString();
                var    result        = NetHelper.HttpApi(url, userParamsStr, "POST");
                TmsReturnBaseObj <object> responseObj = JsonConvert.DeserializeObject <TmsReturnBaseObj <object> >(result);
                if (responseObj == null)
                {
                    ThreadPool.QueueUserWorkItem(a =>
                    {
                        CommonHelper.Instance.ShowAlert("服务器返回数据为空");
                    });
                    txtName.Focus();
                    return;
                }
                if (!responseObj.UpdateObj.Code.Equals("0000"))
                {
                    ThreadPool.QueueUserWorkItem(a =>
                    {
                        CommonHelper.Instance.ShowAlert(responseObj.UpdateObj.Msg);
                    });
                    txtName.Focus();
                    return;
                }

                string token = responseObj.UpdateObj.Obj_Json;
                if (!string.IsNullOrEmpty(token))
                {
                    string json = AESHelper.AesDecrypt(token, "1234567890123456");
                    if (!string.IsNullOrEmpty(json))
                    {
                        TmsCustomer cus           = new TmsCustomer();
                        var         DynamicObject = JsonConvert.DeserializeObject <dynamic>(json);
                        cus.CreateOpId       = DynamicObject.ID;
                        cus.CreateOpName     = DynamicObject.ID;
                        cus.CreateOpName     = DynamicObject.UserName;
                        cus.CustomerFullName = DynamicObject.UserName;
                        CacheHelper.Instance.Add("user", cus);
                        MainForm main = new MainForm();
                        this.Hide();
                        main.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                ThreadPool.QueueUserWorkItem(a => {
                    CommonHelper.Instance.ShowAlert(ex.Message);
                    CommonHelper.Instance.LogHelperInfo(LogLevel.Error, ex.Message.ToString());
                });
            }
        }
Пример #7
0
        public string AddInf4Web(CourtInf v)
        {
            string wramStr = "";

            if (v.CNumber == "" || v.CNumber == null)
            {
                wramStr = "法院编号不能为空";
                return("{\"code\":0,\"msg\":\"" + wramStr + "\"}");
            }
            if (v.CName == "" || v.CName == null)
            {
                wramStr = "法院名称不能为空";
                return("{\"code\":0,\"msg\":\"" + wramStr + "\"}");
            }
            if (v.CLinkman == "" || v.CLinkman == null)
            {
                wramStr = "联系人不能为空";
                return("{\"code\":0,\"msg\":\"" + wramStr + "\"}");
            }
            if (v.CWorkTelephone == "" || v.CWorkTelephone == null)
            {
                wramStr = "单位电话不能为空";
                return("{\"code\":0,\"msg\":\"" + wramStr + "\"}");
            }
            string linkman       = v.CLinkman.Replace(" ", "+");
            string workTelephone = v.CWorkTelephone.Replace(" ", "+");

            string p = "";

            p += "CNumber=" + v.CNumber;
            p += "&CName=" + v.CName;
            p += "&CLinkman=" + linkman;
            p += "&CWorkTelephone=" + workTelephone;
            p += "&CAddress=" + v.CAddress;
            p += "&CLongitude=" + v.CLongitude;
            p += "&CLatitude=" + v.CLatitude;

            string md5Ciphertext = v.CMD5Ciphertext;//对方传过来的所有字段的MD5密文
            //把传过来的信息再次MD5加密,和所有字段的MD5密文进行比对,保证数据在传输过程中没被修改才允许添加到数据库
            string md5P = MD5Helper._md5(p);

            if (md5Ciphertext == md5P)
            {
                string sql = "insert into T_CourtInf(CNumber, CName, CLinkman, CWorkTelephone, CAddress, CLongitude, CLatitude) values(@CNumber, @CName, @CLinkman, @WorkTelephone, @CAddress, @CLongitude, @CLatitude)";
                workTelephone = RSAHelper.DecryptWithPrivateKey(privateKey, workTelephone);
                SqlParameter[] pms = new SqlParameter[] {
                    new SqlParameter("@CNumber", SqlDbType.NVarChar)
                    {
                        Value = v.CNumber
                    },
                    new SqlParameter("@CName", SqlDbType.NVarChar)
                    {
                        Value = v.CName
                    },
                    new SqlParameter("@CLinkman", SqlDbType.NVarChar)
                    {
                        Value = AESHelper.AesDecrypt(linkman)
                    },
                    new SqlParameter("@CWorkTelephone", SqlDbType.NVarChar)
                    {
                        Value = AESHelper.AesDecrypt(workTelephone)
                    },
                    new SqlParameter("@CAddress", SqlDbType.NVarChar)
                    {
                        Value = DataHelper.IsNullReturnLine(v.CAddress)
                    },
                    new SqlParameter("@CLongitude", SqlDbType.NVarChar)
                    {
                        Value = DataHelper.IsNullReturnLine(v.CLongitude)
                    },
                    new SqlParameter("@CLatitude", SqlDbType.NVarChar)
                    {
                        Value = DataHelper.IsNullReturnLine(v.CLatitude)
                    }
                };
                try
                {
                    int result = SQLHelper.ExecuteNonQuery(sql, System.Data.CommandType.StoredProcedure, pms);
                    return(ConvertHelper.IntToJson(result));
                }
                catch (Exception e)
                {
                    //在webapi中要想抛出异常必须这样抛出,否则只抛出一个默认500的异常
                    var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                    {
                        Content      = new StringContent(e.ToString()),
                        ReasonPhrase = "error"
                    };
                    throw new HttpResponseException(resp);
                }
            }
            else
            {
                return(ConvertHelper.resultJson(0, "数据传输过程中被篡改"));
            }
        }
Пример #8
0
        public string EditInf(UserInf v)
        {
            if (v.Token == DataHelper.getToken())
            {
                string wramStr = "";
                if (string.IsNullOrEmpty(v.OldPassword))
                {
                    wramStr = "旧密码不能为空";
                    return(ConvertHelper.resultJson(0, wramStr));
                }
                else if (string.IsNullOrEmpty(v.NewPassword))
                {
                    wramStr = "新密码不能为空";
                    return(ConvertHelper.resultJson(0, wramStr));
                }
                else
                {
                    string p = "";
                    p += "UserName="******"OldPassword="******"NewPassword="******"select count(*) from T_UserInf where UserName=@UserName and UPassword=@UPassword";
                        SqlParameter[] pms1 = new SqlParameter[] {
                            new SqlParameter("@UPassword", SqlDbType.NVarChar)
                            {
                                Value = (oldPwd)
                            },
                            new SqlParameter("@UserName", SqlDbType.NVarChar)
                            {
                                Value = (username)
                            }
                        };
                        try
                        {
                            object c = SQLHelper.ExecuteScalar(sql1, System.Data.CommandType.Text, pms1);
                            if (Convert.ToInt32(c) > 0)
                            {
                                string sql2 = "update T_UserInf set UPassword=@UPassword";
                                sql2 += " where UserName=@UserName";
                                SqlParameter[] pms2 = new SqlParameter[] {
                                    new SqlParameter("@UPassword", SqlDbType.NVarChar)
                                    {
                                        Value = pwd
                                    },
                                    new SqlParameter("@UserName", SqlDbType.NVarChar)
                                    {
                                        Value = username
                                    }
                                };
                                try
                                {
                                    int result = SQLHelper.ExecuteNonQuery(sql2, System.Data.CommandType.Text, pms2);
                                    return(ConvertHelper.IntToJson(result));
                                }
                                catch (Exception e)
                                {
                                    //在webapi中要想抛出异常必须这样抛出,否则之抛出一个默认500的异常
                                    var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                                    {
                                        Content      = new StringContent(e.ToString()),
                                        ReasonPhrase = "error"
                                    };
                                    throw new HttpResponseException(resp);
                                }
                            }
                            else
                            {
                                return(ConvertHelper.resultJson(0, "旧密码不正确!"));
                            }
                        }
                        catch (Exception e)
                        {
                            //在webapi中要想抛出异常必须这样抛出,否则之抛出一个默认500的异常
                            var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                            {
                                Content      = new StringContent(e.ToString()),
                                ReasonPhrase = "error"
                            };
                            throw new HttpResponseException(resp);
                        }
                        //string sql = "insert into T_VisitorAccessInf(VName, VSex, VNation, VBirthDate, VAddress, VIssuingAuthority, VExpiryDate, VCertificatePhoto, VLocalePhoto, VCertificateType, VCertificateNumber, VType, VFromCourtId, VInTime, VOutTime, VInPost, VOutPost, VInDoorkeeper, VOutDoorkeeper, VVisitingReason, VIntervieweeDept, VInterviewee, VOffice, VOfficePhone, VExtensionPhone, VMobilePhone, VRemark) values(@VName, @VSex, @VNation, @VBirthDate, @VAddress, @VIssuingAuthority, @VExpiryDate, @VCertificatePhoto, @VLocalePhoto, @VCertificateType, @VCertificateNumber, @VType, @VFromCourtId, @VInTime, @VOutTime, @VInPost, @VOutPost, @VInDoorkeeper, @VOutDoorkeeper, @VVisitingReason, @VIntervieweeDept, @VInterviewee, @VOffice, @VOfficePhone, @VExtensionPhone, @VMobilePhone, @VRemark)";
                    }
                    else
                    {
                        return(ConvertHelper.resultJson(0, "数据在传输过程中被篡改!"));
                    }
                }
            }
            else
            {
                return(ConvertHelper.resultJson(0, "权限受限!"));
            }
        }
Пример #9
0
        public string AddInf4Web(LawyerInf v)
        {
            string wramStr = "";

            if (v.LName == "" || v.LName == null)
            {
                wramStr = "姓名不能为空";
                return("{\"code\":0,\"msg\":\"" + wramStr + "\"}");
            }
            if (v.LIdentityNumber == "" || v.LIdentityNumber == null)
            {
                wramStr = "身份证号不能为空";
                return("{\"code\":0,\"msg\":\"" + wramStr + "\"}");
            }

            //数据在传输过程中,密文中的“+”号会被替换合成“ ”空格号,把它还原回来
            string name           = v.LName.Replace(" ", "+");
            string identityNumber = v.LIdentityNumber.Replace(" ", "+");

            string p = "";

            p += "LName=" + name;
            p += "&LSex=" + v.LSex;
            p += "&LPhoto=" + DataHelper.IsNullReturnLine(v.LPhoto, true);
            p += "&LIdentityNumber=" + v.LIdentityNumber;
            p += "&LActuator=" + v.LActuator;
            p += "&LPCType=" + v.LPCType;
            p += "&LPCNumber=" + v.LPCNumber;
            p += "&LQualifityNumber=" + v.LQualifityNumber;
            p += "&LIssuingAuthority=" + v.LIssuingAuthority;
            p += "&LIssuingDate=" + v.LIssuingDate;
            p += "&LInTime=" + v.LInTime;
            p += "&LFromCourtId=" + v.LFromCourtId;
            p += "&LRemark=" + v.LRemark;

            string md5Ciphertext = v.LMD5Ciphertext;//对方传过来的所有字段的MD5密文
            //把传过来的信息再次MD5加密,和所有字段的MD5密文进行比对,保证数据在传输过程中没被修改才允许添加到数据库
            string md5P = MD5Helper._md5(p);

            if (md5Ciphertext == md5P)
            {
                string sql = "sp_addLawyerInf";
                name           = AESHelper.AesDecrypt(name);
                identityNumber = AESHelper.AesDecrypt(identityNumber);
                SqlParameter[] pms = new SqlParameter[] {
                    new SqlParameter("@LName", SqlDbType.NVarChar)
                    {
                        Value = name
                    },
                    new SqlParameter("@LSex", SqlDbType.NVarChar)
                    {
                        Value = DataHelper.IsNullReturnLine(v.LSex)
                    },
                    new SqlParameter("@LPhoto", SqlDbType.NVarChar)
                    {
                        Value = DataHelper.IsNullReturnLine(v.LPhoto)
                    },
                    new SqlParameter("@LIdentityNumber", SqlDbType.NVarChar)
                    {
                        Value = identityNumber
                    },
                    new SqlParameter("@LActuator", SqlDbType.NVarChar)
                    {
                        Value = DataHelper.IsNullReturnLine(v.LActuator)
                    },
                    new SqlParameter("@LPCType", SqlDbType.NVarChar)
                    {
                        Value = DataHelper.IsNullReturnLine(v.LPCType)
                    },
                    new SqlParameter("@LPCNumber", SqlDbType.NVarChar)
                    {
                        Value = DataHelper.IsNullReturnLine(v.LPCNumber)
                    },
                    new SqlParameter("@LQualifityNumber", SqlDbType.NVarChar)
                    {
                        Value = DataHelper.IsNullReturnLine(v.LQualifityNumber)
                    },
                    new SqlParameter("@LIssuingAuthority", SqlDbType.NVarChar)
                    {
                        Value = DataHelper.IsNullReturnLine(v.LIssuingAuthority)
                    },
                    new SqlParameter("@LIssuingDate", SqlDbType.NVarChar)
                    {
                        Value = DataHelper.IsNullReturnLine(v.LIssuingDate)
                    },
                    new SqlParameter("@LInTime", SqlDbType.NVarChar)
                    {
                        Value = DataHelper.IsNullReturnLine(v.LInTime)
                    },
                    new SqlParameter("@LFromCourtId", SqlDbType.NVarChar)
                    {
                        Value = DataHelper.IsNullReturnLine(v.LFromCourtId)
                    },
                    new SqlParameter("@LRemark", SqlDbType.NVarChar)
                    {
                        Value = DataHelper.IsNullReturnLine(v.LRemark)
                    }
                };
                try
                {
                    int result = SQLHelper.ExecuteNonQuery(sql, System.Data.CommandType.StoredProcedure, pms);
                    return(ConvertHelper.IntToJson(result));
                }
                catch (Exception e)
                {
                    //在webapi中要想抛出异常必须这样抛出,否则只抛出一个默认500的异常
                    var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                    {
                        Content      = new StringContent(e.ToString()),
                        ReasonPhrase = "error"
                    };
                    throw new HttpResponseException(resp);
                }
            }
            else
            {
                return(ConvertHelper.resultJson(0, "数据传输过程中被篡改"));
            }
        }
Пример #10
0
        public string EditInf(LawyerInf v)
        {
            if (v.Token == DataHelper.getToken())
            {
                string wramStr = "";
                if (v.LName == "" || v.LName == null)
                {
                    wramStr = "姓名不能为空";
                    return("{\"code\":0,\"msg\":\"" + wramStr + "\"}");
                }
                else if (v.LIdentityNumber == "" || v.LIdentityNumber == null)
                {
                    wramStr = "身份证号不能为空";
                    return("{\"code\":0,\"msg\":\"" + wramStr + "\"}");
                }
                //数据在传输过程中,密文中的“+”号会被替换合成“ ”空格号,把它还原回来
                string name           = v.LName.Replace(" ", "+");
                string identityNumber = v.LIdentityNumber.Replace(" ", "+");

                string p = "";
                p += "LName=" + name;
                p += "&LSex=" + v.LSex;
                p += "&LPhoto=" + DataHelper.IsNullReturnLine(v.LPhoto, true);
                p += "&LIdentityNumber=" + identityNumber;
                p += "&LActuator=" + v.LActuator;
                p += "&LPCType=" + v.LPCType;
                p += "&LPCNumber=" + v.LPCNumber;
                p += "&LQualifityNumber=" + v.LQualifityNumber;
                p += "&LIssuingAuthority=" + v.LIssuingAuthority;
                p += "&LIssuingDate=" + v.LIssuingDate;
                p += "&LInTime=" + v.LInTime;
                p += "&LFromCourtId=" + v.LFromCourtId;
                p += "&LRemark=" + v.LRemark;

                string md5Ciphertext = v.LMD5Ciphertext;//对方传过来的所有字段的MD5密文
                //把传过来的信息再次MD5加密,和所有字段的MD5密文进行比对,保证数据在传输过程中没被修改才允许添加到数据库
                string md5P = MD5Helper._md5(p);
                if (md5Ciphertext == md5P)
                {
                    //string sql = "insert into T_VisitorAccessInf(VName, VSex, VNation, VBirthDate, VAddress, VIssuingAuthority, VExpiryDate, VCertificatePhoto, VLocalePhoto, VCertificateType, VCertificateNumber, VType, VFromCourtId, VInTime, VOutTime, VInPost, VOutPost, VInDoorkeeper, VOutDoorkeeper, VVisitingReason, VIntervieweeDept, VInterviewee, VOffice, VOfficePhone, VExtensionPhone, VMobilePhone, VRemark) values(@VName, @VSex, @VNation, @VBirthDate, @VAddress, @VIssuingAuthority, @VExpiryDate, @VCertificatePhoto, @VLocalePhoto, @VCertificateType, @VCertificateNumber, @VType, @VFromCourtId, @VInTime, @VOutTime, @VInPost, @VOutPost, @VInDoorkeeper, @VOutDoorkeeper, @VVisitingReason, @VIntervieweeDept, @VInterviewee, @VOffice, @VOfficePhone, @VExtensionPhone, @VMobilePhone, @VRemark)";
                    string sql = "update T_LawyerInf set LName=@LName,LSex=@LSex,LPhoto=@LPhoto,LIdentityNumber=@LIdentityNumber,LActuator=@LActuator,";
                    sql += "LPCType=@LPCType,LPCNumber=@LPCNumber,LQualifityNumber=@LQualifityNumber,LIssuingAuthority=@LIssuingAuthority,";
                    sql += "LIssuingDate=@LIssuingDate,LInTime=@LInTime,LFromCourtId=@LFromCourtId,LRemark=@LRemark";
                    sql += " where LId=@LId";
                    SqlParameter[] pms = new SqlParameter[] {
                        new SqlParameter("@LName", SqlDbType.NVarChar)
                        {
                            Value = AESHelper.AesDecrypt(name)
                        },
                        new SqlParameter("@LSex", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.LSex)
                        },
                        new SqlParameter("@LPhoto", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.LPhoto)
                        },
                        new SqlParameter("@LIdentityNumber", SqlDbType.NVarChar)
                        {
                            Value = AESHelper.AesDecrypt(identityNumber)
                        },
                        new SqlParameter("@LActuator", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.LActuator)
                        },
                        new SqlParameter("@LPCType", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.LPCType)
                        },
                        new SqlParameter("@LPCNumber", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.LPCNumber)
                        },
                        new SqlParameter("@LQualifityNumber", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.LQualifityNumber)
                        },
                        new SqlParameter("@LIssuingAuthority", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.LIssuingAuthority)
                        },
                        new SqlParameter("@LIssuingDate", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.LIssuingDate)
                        },
                        new SqlParameter("@LInTime", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.LInTime)
                        },
                        new SqlParameter("@LFromCourtId", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.LFromCourtId)
                        },
                        new SqlParameter("@LRemark", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.LRemark)
                        },
                        new SqlParameter("@LId", SqlDbType.Int)
                        {
                            Value = v.LId
                        }
                    };
                    try
                    {
                        int result = SQLHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text, pms);
                        return(ConvertHelper.IntToJson(result));
                    }
                    catch (Exception e)
                    {
                        //在webapi中要想抛出异常必须这样抛出,否则之抛出一个默认500的异常
                        var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                        {
                            Content      = new StringContent(e.ToString()),
                            ReasonPhrase = "error"
                        };
                        throw new HttpResponseException(resp);
                    }
                }
                return(ConvertHelper.resultJson(0, "出错了!"));
            }
            else
            {
                return(ConvertHelper.resultJson(101, "权限受限!"));
            }
        }
Пример #11
0
        public string EditInf(BlacklistInf v)
        {
            if (v.Token == DataHelper.getToken())
            {
                string wramStr = "";
                if (v.BName == "" || v.BName == null)
                {
                    wramStr = "姓名不能为空";
                    return("{\"code\":0,\"msg\":\"" + wramStr + "\"}");
                }
                else if (v.BAddress == "" || v.BAddress == null)
                {
                    wramStr = "身份证中的住址不能为空";
                    return("{\"code\":0,\"msg\":\"" + wramStr + "\"}");
                }
                else if (v.BCertificateNumber == "" || v.BCertificateNumber == null)
                {
                    wramStr = "证件号不能为空";
                    return("{\"code\":0,\"msg\":\"" + wramStr + "\"}");
                }
                else
                {
                    //数据在传输过程中,密文中的“+”号会被替换合成“ ”空格号,把它还原回来
                    string name              = v.BName.Replace(" ", "+");
                    string address           = v.BAddress.Replace(" ", "+");
                    string certificateNumber = v.BCertificateNumber.Replace(" ", "+");

                    string p = "";
                    p += "BName=" + name;
                    p += "&BSex=" + v.BSex;
                    p += "&BNation=" + v.BNation;
                    p += "&BBirthDate=" + v.BBirthDate;
                    p += "&BAddress=" + address;
                    p += "&BIssuingAuthority=" + v.BIssuingAuthority;
                    p += "&BExpiryDate=" + v.BExpiryDate;
                    p += "&BCertificatePhoto=" + v.BCertificatePhoto;
                    p += "&BLocalePhoto=" + v.BLocalePhoto;
                    p += "&BCertificateType=" + v.BCertificateType;
                    p += "&BCertificateNumber=" + certificateNumber;
                    p += "&BCreateTime=" + v.BCreateTime;
                    p += "&BFromCourtId=" + v.BFromCourtId;
                    p += "&BLevel=" + v.BLevel;
                    p += "&BRemark=" + v.BRemark;

                    string md5Ciphertext = v.BMD5Ciphertext;//对方传过来的所有字段的MD5密文
                    //把传过来的信息再次MD5加密,和所有字段的MD5密文进行比对,保证数据在传输过程中没被修改才允许添加到数据库
                    string md5P = MD5Helper._md5(p);
                    if (md5Ciphertext == md5P)
                    {
                        //string sql = "insert into T_VisitorAccessInf(VName, VSex, VNation, VBirthDate, VAddress, VIssuingAuthority, VExpiryDate, VCertificatePhoto, VLocalePhoto, VCertificateType, VCertificateNumber, VType, VFromCourtId, VInTime, VOutTime, VInPost, VOutPost, VInDoorkeeper, VOutDoorkeeper, VVisitingReason, VIntervieweeDept, VInterviewee, VOffice, VOfficePhone, VExtensionPhone, VMobilePhone, VRemark) values(@VName, @VSex, @VNation, @VBirthDate, @VAddress, @VIssuingAuthority, @VExpiryDate, @VCertificatePhoto, @VLocalePhoto, @VCertificateType, @VCertificateNumber, @VType, @VFromCourtId, @VInTime, @VOutTime, @VInPost, @VOutPost, @VInDoorkeeper, @VOutDoorkeeper, @VVisitingReason, @VIntervieweeDept, @VInterviewee, @VOffice, @VOfficePhone, @VExtensionPhone, @VMobilePhone, @VRemark)";
                        string sql = "update T_BlacklistInf set BName=@BName,BSex=@BSex,BNation=@BNation,BBirthDate=@BBirthDate,BAddress=@BAddress,";
                        sql += "BIssuingAuthority=@BIssuingAuthority,BExpiryDate=@BExpiryDate,BCertificatePhoto=@BCertificatePhoto,BLocalePhoto=@BLocalePhoto,BCertificateType=@BCertificateType,BCertificateNumber=@BCertificateNumber,BCreateTime=@BCreateTime,BFromCourtId=@BFromCourtId,";
                        sql += "BLevel=@BLevel,BRemark=@BRemark";
                        sql += " where BId=@BId";
                        SqlParameter[] pms = new SqlParameter[] {
                            new SqlParameter("@BName", SqlDbType.NVarChar)
                            {
                                Value = DataHelper.IsNullReturnLine(AESHelper.AesDecrypt(name))
                            },
                            new SqlParameter("@BSex", SqlDbType.NVarChar)
                            {
                                Value = DataHelper.IsNullReturnLine(v.BSex)
                            },
                            new SqlParameter("@BNation", SqlDbType.NVarChar)
                            {
                                Value = DataHelper.IsNullReturnLine(v.BNation)
                            },
                            new SqlParameter("@BBirthDate", SqlDbType.NVarChar)
                            {
                                Value = DataHelper.IsNullReturnLine(v.BBirthDate)
                            },
                            new SqlParameter("@BAddress", SqlDbType.NVarChar)
                            {
                                Value = DataHelper.IsNullReturnLine(AESHelper.AesDecrypt(address))
                            },
                            new SqlParameter("@BIssuingAuthority", SqlDbType.NVarChar)
                            {
                                Value = DataHelper.IsNullReturnLine(v.BIssuingAuthority)
                            },
                            new SqlParameter("@BExpiryDate", SqlDbType.NVarChar)
                            {
                                Value = DataHelper.IsNullReturnLine(v.BExpiryDate)
                            },
                            new SqlParameter("@BCertificatePhoto", SqlDbType.NVarChar)
                            {
                                Value = DataHelper.IsNullReturnLine(v.BCertificatePhoto, true)
                            },
                            new SqlParameter("@BLocalePhoto", SqlDbType.NVarChar)
                            {
                                Value = DataHelper.IsNullReturnLine(v.BLocalePhoto, true)
                            },
                            new SqlParameter("@BCertificateType", SqlDbType.NVarChar)
                            {
                                Value = DataHelper.IsNullReturnLine(v.BCertificateType)
                            },
                            new SqlParameter("@BCertificateNumber", SqlDbType.NVarChar)
                            {
                                Value = DataHelper.IsNullReturnLine(AESHelper.AesDecrypt(certificateNumber))
                            },
                            new SqlParameter("@BCreateTime", SqlDbType.NVarChar)
                            {
                                Value = DataHelper.IsNullReturnLine(v.BCreateTime)
                            },
                            new SqlParameter("@BFromCourtId", SqlDbType.NVarChar)
                            {
                                Value = DataHelper.IsNullReturnLine(v.BFromCourtId)
                            },
                            new SqlParameter("@BLevel", SqlDbType.NVarChar)
                            {
                                Value = DataHelper.IsNullReturnLine(v.BLevel)
                            },
                            new SqlParameter("@BRemark", SqlDbType.NVarChar)
                            {
                                Value = DataHelper.IsNullReturnLine(v.BRemark)
                            },
                            new SqlParameter("@BId", SqlDbType.Int)
                            {
                                Value = v.BId
                            }
                        };
                        try
                        {
                            int result = SQLHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text, pms);
                            return(ConvertHelper.IntToJson(result));
                        }
                        catch (Exception e)
                        {
                            //在webapi中要想抛出异常必须这样抛出,否则之抛出一个默认500的异常
                            var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                            {
                                Content      = new StringContent(e.ToString()),
                                ReasonPhrase = "error"
                            };
                            throw new HttpResponseException(resp);
                        }
                    }
                    else
                    {
                        return(ConvertHelper.resultJson(0, "数据在传输过程中被篡改!"));
                    }
                }
            }
            else
            {
                return(ConvertHelper.resultJson(101, "权限受限!"));
            }
        }
Пример #12
0
        public string AddInf4Web(BlacklistInf v)
        {
            if (v.Token == DataHelper.getToken())
            {
                string wramStr = "";

                //数据在传输过程中,密文中的“+”号会被替换合成“ ”空格号,把它还原回来
                string name              = v.BName.Replace(" ", "+");
                string address           = v.BAddress.Replace(" ", "+");
                string certificateNumber = v.BCertificateNumber.Replace(" ", "+");

                string p = "";
                p += "BName=" + name;
                p += "&BSex=" + v.BSex;
                p += "&BNation=" + v.BNation;
                p += "&BBirthDate=" + v.BBirthDate;
                p += "&BAddress=" + address;
                p += "&BIssuingAuthority=" + v.BIssuingAuthority;
                p += "&BExpiryDate=" + v.BExpiryDate;
                p += "&BCertificatePhoto=" + v.BCertificatePhoto;
                p += "&BLocalePhoto=" + v.BLocalePhoto;
                p += "&BCertificateType=" + v.BCertificateType;
                p += "&BCertificateNumber=" + certificateNumber;
                p += "&BCreateTime=" + v.BCreateTime;
                p += "&BFromCourtId=" + v.BFromCourtId;
                p += "&BLevel=" + v.BLevel;
                p += "&BRemark=" + v.BRemark;

                string md5Ciphertext = v.BMD5Ciphertext;//对方传过来的所有字段的MD5密文
                //把传过来的信息再次MD5加密,和所有字段的MD5密文进行比对,保证数据在传输过程中没被修改才允许添加到数据库
                string md5P = MD5Helper._md5(p);
                if (md5Ciphertext == md5P)
                {
                    string sql = "sp_addBlacklistInf";
                    name              = AESHelper.AesDecrypt(name);
                    address           = AESHelper.AesDecrypt(address);
                    certificateNumber = AESHelper.AesDecrypt(certificateNumber);
                    if (name == "" || name == null || certificateNumber == "undefined")
                    {
                        wramStr = "姓名不能为空";
                        return("{\"code\":0,\"msg\":\"" + wramStr + "\"}");
                    }
                    if (address == "" || address == null || certificateNumber == "undefined")
                    {
                        wramStr = "身份证中的住址不能为空";
                        return("{\"code\":0,\"msg\":\"" + wramStr + "\"}");
                    }
                    if (certificateNumber == "" || certificateNumber == null || certificateNumber == "undefined")
                    {
                        wramStr = "证件号不能为空";
                        return("{\"code\":0,\"msg\":\"" + wramStr + "\"}");
                    }

                    SqlParameter[] pms = new SqlParameter[] {
                        new SqlParameter("@BName", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(name)
                        },
                        new SqlParameter("@BSex", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.BSex)
                        },
                        new SqlParameter("@BNation", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.BNation)
                        },
                        new SqlParameter("@BBirthDate", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.BBirthDate)
                        },
                        new SqlParameter("@BAddress", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(address)
                        },
                        new SqlParameter("@BIssuingAuthority", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.BIssuingAuthority)
                        },
                        new SqlParameter("@BExpiryDate", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.BExpiryDate)
                        },
                        new SqlParameter("@BCertificatePhoto", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.BCertificatePhoto, true)
                        },
                        new SqlParameter("@BLocalePhoto", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.BLocalePhoto, true)
                        },
                        new SqlParameter("@BCertificateType", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.BCertificateType)
                        },
                        new SqlParameter("@BCertificateNumber", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(certificateNumber)
                        },
                        new SqlParameter("@BCreateTime", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.BCreateTime)
                        },
                        new SqlParameter("@BFromCourtId", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.BFromCourtId)
                        },
                        new SqlParameter("@BLevel", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.BLevel)
                        },
                        new SqlParameter("@BRemark", SqlDbType.NVarChar)
                        {
                            Value = DataHelper.IsNullReturnLine(v.BRemark)
                        }
                    };
                    try
                    {
                        int result = SQLHelper.ExecuteNonQuery(sql, System.Data.CommandType.StoredProcedure, pms);
                        return(ConvertHelper.IntToJson(result));
                    }
                    catch (Exception e)
                    {
                        //在webapi中要想抛出异常必须这样抛出,否则只抛出一个默认500的异常
                        var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                        {
                            Content      = new StringContent(e.ToString()),
                            ReasonPhrase = "error"
                        };
                        throw new HttpResponseException(resp);
                    }
                }
                else
                {
                    return(ConvertHelper.resultJson(0, "数据传输过程中被篡改"));
                }
            }
            else
            {
                return(ConvertHelper.resultJson(101, "权限受限!"));
            }
        }