//Client #region MenuVideos public void MenuVideos(Menu menu, int iParentID, string _lang) { try { DataTable table = new DataTable(); BaseDAO baseDAO = new BaseDAO(); using (SqlConnection connection = baseDAO.GetConnection()) { SqlCommand command = new SqlCommand("_VideosCateGetClient", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@VideosCateID", iParentID); command.Parameters.AddWithValue("@Language", _lang); connection.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(table); command.Dispose(); } } if (table.Rows.Count > 0) { foreach (DataRow row in table.Rows) { MenuItem menuitem = new MenuItem(row["VideosCateName"].ToString()); menuitem.NavigateUrl = "~/Default.aspx?go=videoscate&id=" + row["VideosCateID"].ToString(); this.SubMenuNews(menuitem, Convert.ToInt32(row["VideosCateID"]), _lang); menu.Items.Add(menuitem); } } } catch (Exception ex) { throw new DataAccessException(ex.Message.ToString()); } }
private void SubMenuNews(MenuItem _parentNote, int iCate_ID, string _lang) { try { BaseDAO baseDAO = new BaseDAO(); DataTable datatable = new DataTable(); using (SqlConnection connection = baseDAO.GetConnection()) { SqlCommand command = new SqlCommand("_VideosCateGetClient", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@VideosCateID", iCate_ID); command.Parameters.AddWithValue("@Language", _lang); connection.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(datatable); command.Dispose(); } } if (datatable.Rows.Count > 0) { foreach (DataRow row in datatable.Rows) { MenuItem _childNote = new MenuItem(row["VideosCateName"].ToString()); _childNote.NavigateUrl = "~/Default.aspx?go=videoscate&id=" + row["VideosCateID"].ToString(); _parentNote.ChildItems.Add(_childNote); this.SubMenuNews(_childNote, Convert.ToInt32(row["VideosCateID"]), _lang); } } } catch (Exception ex) { throw new DataAccessException(ex.Message.ToString()); } }
public DataTable getCateClientGroupUrl(int iCate, string lang, int group, bool status) { BaseDAO baseDAO = new BaseDAO(); DataTable table = new DataTable(); using (SqlConnection connection = baseDAO.GetConnection()) { string SQL = "select * from tblCateNews where ParentNewsID = @CateNewsID and Language = @Language and GroupCate = @GroupCate and Status=@Status order by CateNewsOrder ASC"; SqlCommand command = new SqlCommand(SQL, connection); command.CommandText = SQL; command.Parameters.AddWithValue("@CateNewsID", iCate); command.Parameters.AddWithValue("@Language", lang); command.Parameters.AddWithValue("@GroupCate", group); command.Parameters.AddWithValue("@Status", status); connection.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(table); command.Dispose(); } } return(table); }
public bool ExistName(string catename) { BaseDAO baseDAO = new BaseDAO(); using (SqlConnection connection = baseDAO.GetConnection()) { SqlCommand command = new SqlCommand("_AlbumsCateCheck", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@AlbumsCateName", catename); connection.Open(); using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection)) { return(reader.HasRows); } } }
//public string enCode(string Pass) //{ // EDData.clsEDData EDD = new EDData.clsEDData(); // string s = null; // object s1 = null; // EDD.SetKey("EVNIT_16LDH", EDData.EDKeyTypeEnum.eEDString, ref s1); // s = EDD.EncryptStr(Pass, EDData.EDDataType.eHex); // return EDD.EncryptStr(Pass, EDData.EDDataType.eHex); //} //public string DeCode(string Pass) //{ // EDData.clsEDData EDD = new EDData.clsEDData(); // string s = null; // object s1 = null; // EDD.SetKey("EVNIT_16LDH", EDData.EDKeyTypeEnum.eEDString, ref s1); // s = EDD.DecryptStr(Pass, EDData.EDDataType.eHex); // return EDD.DecryptStr(Pass, EDData.EDDataType.eHex); //} public DataTable CreateDataView(string SQL) { BaseDAO baseDAO = new BaseDAO(); DataTable table = new DataTable(); table = null; using (SqlConnection connection = baseDAO.GetConnection()) { try { SqlCommand command = new SqlCommand(SQL, connection); command.CommandText = SQL; command.CommandTimeout = 5; connection.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { try { table = new DataTable(); adapter.Fill(table); command.Dispose(); } catch { table = null; } } } catch { table = null; } finally { if (connection != null) { connection.Close(); } } } return(table); }
//Cate Company #region getFaqsCateLevel public DataTable getFaqsCateLevel(int iCate) { DataTable table = new DataTable(); BaseDAO baseDAO = new BaseDAO(); using (SqlConnection connection = baseDAO.GetConnection()) { SqlCommand command = new SqlCommand("_FaqsCateGet", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@FaqsCateID", iCate); connection.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(table); command.Dispose(); } } return(table); }
public DataTable getVideosCateClient(int iCate, string _lang) { BaseDAO baseDAO = new BaseDAO(); DataTable table = new DataTable(); using (SqlConnection connection = baseDAO.GetConnection()) { SqlCommand command = new SqlCommand("_VideosCateGetClient", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@VideosCateID", iCate); command.Parameters.AddWithValue("@Language", _lang); connection.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(table); command.Dispose(); } } return(table); }
//Lay Cate theo nhom URL #region getCateClientGroupUrl public DataTable getCateClientGroupUrl(int iCate, string lang, int group) { BaseDAO baseDAO = new BaseDAO(); DataTable table = new DataTable(); using (SqlConnection connection = baseDAO.GetConnection()) { SqlCommand command = new SqlCommand("_CateNewsGetClientUrl", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@CateNewsID", iCate); command.Parameters.AddWithValue("@Language", lang); command.Parameters.AddWithValue("@GroupCate", group); connection.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(table); command.Dispose(); } } return(table); }
public async Task <string> GET() { try { SanitaLog.Method("GET", "TestController"); // this will leave the account unlucked for 2 minutes string contractName = "King.sol"; int accountUnlockTime = 120; string accountPublicKey = "0xd6b37e4590c65787437f57e1ad7bb6b9a6f7ba8f"; string accountPassword = "******"; HexBigInteger gas = new HexBigInteger(3000000); //HexBigInteger balance = new HexBigInteger(120); var multiplier = 7; // Unlock the caller's account with the given password bool unlockResult = await Web3Api.UnlockAccount(accountPublicKey, accountPassword, accountUnlockTime); //Get abi of contract TheContract mTheContract = await Web3Api.GetTheContract(contractName); if (mTheContract != null) { string abi = mTheContract.Abi; string byteCode = "0x" + mTheContract.Bytecode; BaseDAO baseDAO = new BaseDAO(); //Get connection using (NpgsqlConnection connection = baseDAO.GetConnection()) { try { //Open connection connection.Open(); HexBigInteger estimateGas = await Web3Api.mWeb3.Eth.DeployContract.EstimateGasAsync(abi, byteCode, accountPublicKey); SanitaLog.Log("Estimate gas", estimateGas); //TODO: Add code to save address of transactionHash => not deploy multiple times //Find contract is deployed ContractInfo mContractInfo = ContractPresenter.GetContract(contractName); //If contract is not exist or not update if (mContractInfo == null || !String.Equals(mContractInfo.ByteCode, byteCode)) { string transactionHash = await Web3Api.WaitDeploy(abi, byteCode, accountPublicKey, gas, multiplier); //Minner TransactionReceipt receipt = await Web3Api.WaitMiner(transactionHash); //Insert or update contract mContractInfo = new ContractInfo(); mContractInfo.Name = contractName; mContractInfo.Address = receipt.ContractAddress; mContractInfo.Abi = abi; mContractInfo.ByteCode = byteCode; mContractInfo.Active = DataTypeModel.ACTIVE; int _result = ContractPresenter.SaveContract(connection, null, mContractInfo); if (_result == DataTypeModel.RESULT_NG) { SanitaLog.Error("No save contract to databse"); return("Error occur. Please try again."); } } //Close connection connection.Close(); //Get contract Nethereum.Contracts.Contract contract = Web3Api.GetContract(abi, mContractInfo.Address); #region Error //Get event //Event multiplyEvent = contract.GetEvent("Multiplied"); //var filterAll = await multiplyEvent.CreateFilterAsync(); //var filter7 = await multiplyEvent.CreateFilterAsync(7); //var gasFunc = await multiplyFunction.EstimateGasAsync(accountPublicKey, null, null, newAddress, amountToSend); //Call event //transactionHash = await multiplyFunction.SendTransactionAsync(accountPublicKey, 7); //SanitaLog.Log("transaction hash", transactionHash); //Call event //transactionHash = await multiplyFunction.SendTransactionAsync(accountPublicKey, 8); //SanitaLog.Log("transaction hash", transactionHash); //Minner //receipt = await Web3Api.WaitMiner(transactionHash); #endregion Error Function funct = null; funct = Web3Api.getFunction(contract, "getOwner"); var result = await funct.CallAsync <string>(); SanitaLog.Log("Result of function getOwner", result); funct = Web3Api.getFunction(contract, "showListShareHolders"); var mListShareHolders = await funct.CallAsync <List <string> >(); SanitaLog.Log("Result of function showListShareHolders", Utility.ToStringList(mListShareHolders)); funct = Web3Api.getFunction(contract, "addListShareHolders"); await funct.CallAsync <object>("0x5e98ff12d889945488ddd53ffb71f6580cae1571"); funct = Web3Api.getFunction(contract, "addListShareHolders"); await funct.CallAsync <object>("0x9bb7f17d1d53774e0fdfa4b76ba68c48e8a4daba"); funct = Web3Api.getFunction(contract, "addListShareHolders"); await funct.CallAsync <object>("0xee2d522d8f10769a5f150ed55f40f305c8d0595f"); funct = Web3Api.getFunction(contract, "showListShareHolders"); mListShareHolders = await funct.CallAsync <List <string> >(); SanitaLog.Log("Result of function showListShareHolders", Utility.ToStringList(mListShareHolders)); SanitaLog.Success("Success deploy contract"); return("success"); } catch (Exception exception1) { //Close connection connection.Close(); SanitaLog.Exception(exception1); return("Error occur. Please try again."); } } } else { SanitaLog.Error("Fail deploy contract"); return("fail"); } } catch (Exception exception2) { SanitaLog.Exception(exception2); return("Error occur. Please try again."); } }