/// <summary> /// 在本地创建新的通道(特殊 等于是在本地创建创世区块) /// </summary> /// <param name="request"></param> /// <returns></returns> private ChainCodeInvokeResponse CreateNewChannel(IChaincodeStub stub) { var identity = stub.GetPeerIdentity(); var args = stub.GetArgs(); if (args.Length != 1) { return(stub.Response("参数个数不正确", StatusCode.BAD_ARGS_NUMBER)); } //组织 var OrgConfig = new OrgConfig(); OrgConfig.OrgId = identity.OrgId; OrgConfig.Name = identity.Name; OrgConfig.Certificate = identity.Certificate; OrgConfig.Address = identity.Address; //通道 var channel = new ChannelConfig(); channel.ChannelID = args[0]; channel.OrgConfigs.Add(OrgConfig); //初始化系统链码 InitSystemChainCode(channel); stub.SetChannelConfig(channel); return(stub.Response("", StatusCode.Successful)); }
protected void ImageButtonLogin_Click(object sender, ImageClickEventArgs e) { OrgConfigBLL orgConfigBLL = new OrgConfigBLL(); OrgConfig orgConfig = orgConfigBLL.GetOrgConfig(); if (ddlOrg.SelectedValue != orgConfig.OrgID.ToString()) { SessionSet.PageMessage = "当前所选单位与数据库中标识单位不一致,请核对后重新选择!"; return; } System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.Load(Server.MapPath("web.config")); System.Xml.XmlNode node; node = doc.SelectSingleNode("//appSettings/add[@key='StationID']"); node.Attributes["value"].Value = ddlOrg.SelectedValue; doc.Save(Server.MapPath("web.config")); if (Request.QueryString.Get("Type") == "teacher") { Response.Redirect("LoginTeacher.aspx"); } else { Response.Redirect("Login.aspx"); } }
/// <summary> /// 更新组织 只能更改自己的组织节点 /// </summary> /// <param name="stub"></param> /// <returns></returns> private ChainCodeInvokeResponse UpdateOrg(IChaincodeStub stub) { if (stub.GetArgs().Count() != 1) { return(stub.Response("", StatusCode.BAD_ARGS_NUMBER)); } var arg = stub.GetArgs()[0]; OrgConfig newOrg = Newtonsoft.Json.JsonConvert.DeserializeObject <OrgConfig>(arg); #region 数据完整性校验 if (string.IsNullOrEmpty(newOrg.OrgId)) { return(stub.Response("组织ID不能为空", StatusCode.BAD_OTHERS)); } if (string.IsNullOrEmpty(newOrg.Name)) { return(stub.Response("组织名称不能为空", StatusCode.BAD_OTHERS)); } if (string.IsNullOrEmpty(newOrg.Address)) { return(stub.Response("组织链接地址不能为空", StatusCode.BAD_OTHERS)); } if (newOrg.Certificate == null) { return(stub.Response("组织证书不能为空", StatusCode.BAD_OTHERS)); } if (!newOrg.Certificate.Check()) { return(stub.Response("证书数据不完整", StatusCode.BAD_OTHERS)); } if (newOrg.Certificate.TBSCertificate.CAType != CAType.Peer) { return(stub.Response("证书类型不正确", StatusCode.BAD_OTHERS)); } #endregion var channelconfig = stub.GetChannelConfig(); //获取旧的组织配置 var oldorg = channelconfig.OrgConfigs.Where(p => p.OrgId == newOrg.OrgId).FirstOrDefault(); if (oldorg == null) { return(stub.Response("组织不存在", StatusCode.BAD_OTHERS)); } oldorg.Address = newOrg.Address; oldorg.Name = newOrg.Name; oldorg.Certificate = newOrg.Certificate; stub.SetChannelConfig(channelconfig); return(stub.Response("", StatusCode.Successful)); }
public void UpdateOrgConfig(OrgConfig orgconfig) { Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_ORG_CONFIG_U"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_org_id", DbType.Int32, orgconfig.OrgID); db.AddInParameter(dbCommand, "p_hour", DbType.Int32, orgconfig.Hour); db.ExecuteNonQuery(dbCommand); }
public static bool OrgConfigUpdate(OrgConfigViewModel entrada, out OrgConfig modelo) { modelo = new OrgConfig(); //************ Objetos de controle de acesso ******************* modelo = entrada.orgConfig; modelo.modificadoEm = DateTime.Now; modelo.modificadoPor = entrada.contexto.idUsuario; modelo.modificadoPorName = entrada.contexto.nomeUsuario; //************ FIM Objetos de controle de acesso *************** return(true); }
public BalcaoVendasAPIController(SqlGeneric _sqlGeneric, SqlGenericRules _sqlRules, IHttpContextAccessor httpContext, ContexDataService db) { this.balcaoVendasData = new BalcaoVendasData(db); this.contaReceberData = new ContasReceberData(db); this.produtoData = new ProdutoData(db); this.orgConfigData = new OrgConfigData(db); this.sqlServices = _sqlRules; this.sqlGeneric = _sqlGeneric; this.contexto = new ContextPage().ExtractContext(httpContext); this.clienteData = new ClienteData(db); this.orgConfig = this.orgConfigData.Get(this.contexto.idOrganizacao); }
public async Task <TxResponse> AddOrg(string orgId, string name, string address, string cert) { var config = new OrgConfig() { OrgId = orgId, Name = name, Address = address, Certificate = Newtonsoft.Json.JsonConvert.DeserializeObject <QMBlockSDK.Idn.Certificate>(cert) }; return(await _config.AddOrg(_channelId, config)); }
public OrgConfig GetOrgConfig() { OrgConfig obj = null; Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_ORG_CONFIG_G"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { obj = CreateModelObject(dataReader); } } return(obj); }
public ViewResult FormUpdateOrgConfig() { OrgConfigViewModel modelo = new OrgConfigViewModel(); modelo.orgConfig = new OrgConfig(); OrgConfig retorno = new OrgConfig(); if (contexto.idOrganizacao != null) { retorno = modeloData.Get(contexto.idOrganizacao); if (retorno != null) { modelo.orgConfig = retorno; //apresenta mensagem de registro atualizado com sucesso modelo.StatusMessage = StatusMessage; } } return(View(modelo)); }
public async Task <TxResponse> AddOrg(string channelid, OrgConfig config) { if (string.IsNullOrEmpty(config.Address)) { throw new Exception("请输入组织地址"); } if (string.IsNullOrEmpty(config.Name)) { throw new Exception("请输入组织名称"); } if (string.IsNullOrEmpty(config.OrgId)) { throw new Exception("请输入组织ID"); } if (config.Certificate == null) { throw new Exception("未找到组织证书"); } var checkRs = RSAHelper.VerifyData(config.Certificate.TBSCertificate.PublicKey, Newtonsoft.Json.JsonConvert.SerializeObject(config.Certificate.TBSCertificate), config.Certificate.SignatureValue); if (!checkRs) { throw new Exception("证书校验不通过"); } var txHeader = new TxHeader { Args = new string[] { Newtonsoft.Json.JsonConvert.SerializeObject(config) }, ChaincodeName = ConfigKey.SysNetConfigChaincode, FuncName = ConfigKey.AddOrgFunc, Type = TxType.Invoke, ChannelId = channelid }; return(await _service.InvokeTx(txHeader)); //return await _client.TxInvoke(txHeader); }
public void CreateOrgConfig(ContextPage contexto, ContexDataService dbContext) { OrgConfig modelo = new OrgConfig(); //sessão Produto modelo.quantidadeMinimaProduto = 5; modelo.margemBaseProduto = 25; //sessão contas Receber modelo.qtdDiasCartaoCredito = 28; modelo.qtdDiasCartaoDebito = 1; modelo.creditoGeraContasReceber = false; modelo.debitoGeraContasReceber = false; //sessão Cupom modelo.cupom_altura = "90%"; modelo.cupom_largura = "450px"; modelo.cupom_fontesize = "12px"; modelo.cupom_altura = "90%"; modelo.mensagemCupom = "Defina sua mensagem personalizada"; //sessão Pedido Retirada modelo.mensagemPedido = " Defina a sua mensagem personalidada no caminhjo Configurações - Parametros - Configurações do Sistema"; modelo.tituloImpressao = "Defina o seu titulo"; //************ Objetos de controle de acesso ****************** modelo.criadoEm = DateTime.Now; modelo.criadoPor = contexto.idUsuario; modelo.criadoPorName = contexto.nomeUsuario; modelo.modificadoEm = DateTime.Now; modelo.modificadoPor = contexto.idUsuario; modelo.modificadoPorName = contexto.nomeUsuario; modelo.idOrganizacao = contexto.idOrganizacao; //************ FIM Objetos de controle de acesso *************** OrgConfigData orgConfigData = new OrgConfigData(dbContext); orgConfigData.Add(modelo); }
public IActionResult FormUpdateOrgConfig(OrgConfigViewModel entrada) { OrgConfig modelo = new OrgConfig(); entrada.contexto = this.contexto; try { if (OrgConfigRules.OrgConfigUpdate(entrada, out modelo)) { modeloData.Update(modelo); StatusMessage = "Registro Atualizado com Sucesso!"; return(RedirectToAction("FormUpdateOrgConfig", new { id = modelo.id.ToString(), idOrg = contexto.idOrganizacao })); } } catch (Exception ex) { LogOsca log = new LogOsca(); log.GravaLog(1, 34, this.contexto.idUsuario, this.contexto.idOrganizacao, "FormUpdateOrgConfig-post", ex.Message); } return(RedirectToAction("FormUpdateOrgConfig", new { id = modelo.id.ToString() })); }
public void Update(OrgConfig modelo) { db.Attach(modelo); db.Entry(modelo).Property("mensagemPedido").IsModified = true; db.Entry(modelo).Property("margemBaseProduto").IsModified = true; db.Entry(modelo).Property("qtdDiasCartaoCredito").IsModified = true; db.Entry(modelo).Property("qtdDiasCartaoDebito").IsModified = true; db.Entry(modelo).Property("mensagemCupom").IsModified = true; db.Entry(modelo).Property("tituloImpressao").IsModified = true; db.Entry(modelo).Property("quantidadeMinimaProduto").IsModified = true; db.Entry(modelo).Property("cupom_altura").IsModified = true; db.Entry(modelo).Property("cupom_largura").IsModified = true; db.Entry(modelo).Property("cupom_fontesize").IsModified = true; db.Entry(modelo).Property("creditoGeraContasReceber").IsModified = true; db.Entry(modelo).Property("debitoGeraContasReceber").IsModified = true; db.Entry(modelo).Property("modificadoPor").IsModified = true; db.Entry(modelo).Property("modificadoPorName").IsModified = true; db.Entry(modelo).Property("modificadoEm").IsModified = true; db.SaveChanges(); }
public static bool OrgConfigCreate(OrgConfigViewModel entrada, out OrgConfig modelo, ContextPage contexto) { modelo = new OrgConfig(); modelo = entrada.orgConfig; SqlGeneric sqlServic = new SqlGeneric(); if (modelo.idOrganizacao != null) { //************ Objetos de controle de acesso ****************** modelo.criadoEm = DateTime.Now; modelo.criadoPor = contexto.idUsuario; modelo.criadoPorName = contexto.nomeUsuario; modelo.modificadoEm = DateTime.Now; modelo.modificadoPor = contexto.idUsuario; modelo.modificadoPorName = contexto.nomeUsuario; modelo.idOrganizacao = contexto.idOrganizacao; //************ FIM Objetos de controle de acesso *************** return(true); } return(false); }
public void UpdateOrgConfig(OrgConfig orgconfig) { dal.UpdateOrgConfig(orgconfig); }
/// <summary> /// 添加组织 /// </summary> /// <param name="stub"></param> /// <returns></returns> private ChainCodeInvokeResponse AddOrg(IChaincodeStub stub) { if (stub.GetArgs().Count() != 1) { return(stub.Response("", StatusCode.BAD_ARGS_NUMBER)); } var arg = stub.GetArgs()[0]; OrgConfig org = Newtonsoft.Json.JsonConvert.DeserializeObject <OrgConfig>(arg); #region 数据完整性校验 if (string.IsNullOrEmpty(org.OrgId)) { return(stub.Response("组织ID不能为空", StatusCode.BAD_OTHERS)); } if (string.IsNullOrEmpty(org.Name)) { return(stub.Response("组织名称不能为空", StatusCode.BAD_OTHERS)); } if (string.IsNullOrEmpty(org.Address)) { return(stub.Response("组织链接地址不能为空", StatusCode.BAD_OTHERS)); } if (org.Certificate == null) { return(stub.Response("组织证书不能为空", StatusCode.BAD_OTHERS)); } if (!org.Certificate.Check()) { return(stub.Response("证书数据不完整", StatusCode.BAD_OTHERS)); } if (org.Certificate.TBSCertificate.CAType != CAType.Peer) { return(stub.Response("证书类型不正确", StatusCode.BAD_OTHERS)); } //证书自签名校验 var checkRs = RSAHelper.VerifyData(org.Certificate.TBSCertificate.PublicKey, Newtonsoft.Json.JsonConvert.SerializeObject(org.Certificate.TBSCertificate), org.Certificate.SignatureValue); if (!checkRs) { throw new Exception("证书校验非自签名证书"); } #endregion var channelconfig = stub.GetChannelConfig(); //组织重复检验 if (channelconfig.OrgConfigs.Any(p => p.OrgId == org.OrgId)) { return(stub.Response("组织已加入通道", StatusCode.BAD_OTHERS)); } //组织地址校验 if (channelconfig.OrgConfigs.Any(p => p.Address == org.Address)) { return(stub.Response("组织Address已配置在通道", StatusCode.BAD_OTHERS)); } var orgconfig = new OrgConfig(); orgconfig.OrgId = org.OrgId; orgconfig.Address = org.Address; orgconfig.Name = org.Name; orgconfig.Certificate = org.Certificate; //组织加入通道 channelconfig.OrgConfigs.Add(orgconfig); //更新系统链码的背书策略 channelconfig.ChainCodeConfigs.Where(p => p.Name == ConfigKey.SysBlockQueryChaincode).FirstOrDefault().Policy.OrgIds.Add(org.OrgId); channelconfig.ChainCodeConfigs.Where(p => p.Name == ConfigKey.SysBlockQueryChaincode).FirstOrDefault().Policy.Number++; channelconfig.ChainCodeConfigs.Where(p => p.Name == ConfigKey.SysCodeLifeChaincode).FirstOrDefault().Policy.OrgIds.Add(org.OrgId); channelconfig.ChainCodeConfigs.Where(p => p.Name == ConfigKey.SysCodeLifeChaincode).FirstOrDefault().Policy.Number++; channelconfig.ChainCodeConfigs.Where(p => p.Name == ConfigKey.SysNetConfigChaincode).FirstOrDefault().Policy.OrgIds.Add(org.OrgId); channelconfig.ChainCodeConfigs.Where(p => p.Name == ConfigKey.SysNetConfigChaincode).FirstOrDefault().Policy.Number++; //保存数据 stub.SetChannelConfig(channelconfig); return(stub.Response("", StatusCode.Successful)); }
public static void GravaParcela(BalcaoVendas balcaoVendas, IContasReceberData contaReceberData, ContextPage contexto, OrgConfig orgConfig) { decimal valorParcela = balcaoVendas.valorTotal / balcaoVendas.parcelas; DateTime dataCredito = DateTime.Now.AddDays(orgConfig.qtdDiasCartaoCredito); int parcela = 1; for (int i = 0; i < balcaoVendas.parcelas; i++) { ContasReceber contaReceber = new ContasReceber(); contaReceber.valor = valorParcela; contaReceber.valorRestante = valorParcela; contaReceber.tipoLancamento = CustomEnum.TipoLancamento.automatico; contaReceber.statusContaReceber = CustomEnumStatus.StatusContaReceber.agendado; contaReceber.origemContaReceber = CustomEnum.OrigemContaReceber.BalcaoVendas; contaReceber.idReference = balcaoVendas.id; if (balcaoVendas.idCliente != Guid.Empty) { contaReceber.idCliente = balcaoVendas.idCliente; } contaReceber.numeroReferencia = balcaoVendas.codigo; if (balcaoVendas.tipoPagamento == CustomEnum.tipoPagamento.Boleto || balcaoVendas.tipoPagamento == CustomEnum.tipoPagamento.Cheque) { contaReceber.titulo = "Parcela Boleto/Cheque -" + parcela.ToString() + "/" + balcaoVendas.parcelas.ToString() + " - Venda Balcão"; contaReceber.dataPagamento = new DateTime(DateTime.Now.Year, DateTime.Now.Month, balcaoVendas.diaVencimento); contaReceber.dataPagamento = contaReceber.dataPagamento.AddMonths(parcela); ContasReceberRules.ContasReceberCreate(contaReceber, contaReceberData, contexto); } if (balcaoVendas.tipoPagamento == CustomEnum.tipoPagamento.CartaoCredito & orgConfig.creditoGeraContasReceber == true) { contaReceber.titulo = "Parcela Cartão Crédito -" + parcela.ToString() + "/" + balcaoVendas.parcelas.ToString() + " - Venda Balcão"; if (i == 0) { contaReceber.dataPagamento = dataCredito; } else { dataCredito = dataCredito.AddMonths(1); contaReceber.dataPagamento = dataCredito; } ContasReceberRules.ContasReceberCreate(contaReceber, contaReceberData, contexto); } parcela++; } }
public static void GravaConsignado(BalcaoVendas balcaoVendas, IContasReceberData contaReceberData, ContextPage contexto, OrgConfig orgConfig) { ContasReceber contaReceber = new ContasReceber(); contaReceber.valor = balcaoVendas.valorTotal; contaReceber.valorRestante = balcaoVendas.valorTotal; contaReceber.idReference = balcaoVendas.id; contaReceber.tipoLancamento = CustomEnum.TipoLancamento.automatico; contaReceber.statusContaReceber = CustomEnumStatus.StatusContaReceber.agendado; contaReceber.origemContaReceber = CustomEnum.OrigemContaReceber.BalcaoVendas; if (balcaoVendas.idCliente != Guid.Empty) { contaReceber.idCliente = balcaoVendas.idCliente; } contaReceber.numeroReferencia = balcaoVendas.codigo; contaReceber.titulo = "Consignado - Venda Balcão"; contaReceber.dataPagamento = DateTime.Now; contaReceber.dataPagamento = contaReceber.dataPagamento.AddDays(1); ContasReceberRules.ContasReceberCreate(contaReceber, contaReceberData, contexto); }
public void Add(OrgConfig modelo) { db.Add(modelo); db.SaveChanges(); }
public void AddOrgConfig(OrgConfig orgconfig) { dal.AddOrgConfig(orgconfig); }