//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f. pragma solidity ^0.4.9; contract DebianRules { struct systemStruct { bytes32 unidadAcademica; bytes32 nombreSistema; bytes32 apellidoEncargado; bytes32 emailEncargado; bytes32 descripcion; uint anoCreacion; uint index; } mapping(address => systemStruct) private systemStructs; address[] private systemIndex; event LogNewSystem (address indexed systemAddress, uint index, bytes32 unidadAcademica, bytes32 nombreSistema, bytes32 apellidoEncargado, bytes32 emailEncargado, bytes32 descripcion, uint anoCreacion); event LogUpdateSystem(address indexed systemAddress, uint index, bytes32 unidadAcademica, bytes32 nombreSistema, bytes32 apellidoEncargado, bytes32 emailEncargado, bytes32 descripcion, uint anoCreacion); event LogDeleteSystem(address indexed systemAddress, uint index); function isLoad(address systemAddress) public constant returns(bool isIndeed) { if(systemIndex.length == 0) return false; return (systemIndex[systemStructs[systemAddress].index] == systemAddress); } function insertSystem( address systemAddress, bytes32 unidadA, bytes32 nombreS, bytes32 apellidoE, bytes32 emailE, bytes32 descrip, uint anoC) public returns(uint index) { if(isLoad(systemAddress)) throw; systemStructs[systemAddress].emailEncargado = emailE; systemStructs[systemAddress].anoCreacion = anoC; systemStructs[systemAddress].unidadAcademica = unidadA; systemStructs[systemAddress].nombreSistema = nombreS; systemStructs[systemAddress].apellidoEncargado = apellidoE; systemStructs[systemAddress].descripcion = descrip; systemStructs[systemAddress].index = systemIndex.push(systemAddress)-1; LogNewSystem( systemAddress, systemStructs[systemAddress].index, unidadA, nombreS, apellidoE, emailE, descrip, anoC); return systemIndex.length-1; } function deleteSystem(address systemAddress) public returns(uint index) { if(!isLoad(systemAddress)) throw; uint rowToDelete = systemStructs[systemAddress].index; address keyToMove = systemIndex[systemIndex.length-1]; systemIndex[rowToDelete] = keyToMove; systemStructs[keyToMove].index = rowToDelete; systemIndex.length--; LogDeleteSystem( systemAddress, rowToDelete); LogUpdateSystem( keyToMove, rowToDelete, systemStructs[keyToMove].unidadAcademica, systemStructs[keyToMove].nombreSistema, systemStructs[keyToMove].apellidoEncargado, systemStructs[keyToMove].emailEncargado, systemStructs[keyToMove].descripcion, systemStructs[keyToMove].anoCreacion ); return rowToDelete; } function getSystem(address systemAddress) public constant returns(bytes32 userEmail, uint userAge, uint index) { if(!isLoad(systemAddress)) throw; return( systemStructs[systemAddress].emailEncargado, systemStructs[systemAddress].anoCreacion, systemStructs[systemAddress].index); } function updateSystemEmail(address systemAddress, bytes32 userEmail) public returns(bool success) { if(!isLoad(systemAddress)) throw; systemStructs[systemAddress].emailEncargado = userEmail; LogUpdateSystem( systemAddress, systemStructs[systemAddress].index, systemStructs[systemAddress].unidadAcademica, systemStructs[systemAddress].nombreSistema, systemStructs[systemAddress].apellidoEncargado, userEmail, systemStructs[systemAddress].descripcion, systemStructs[systemAddress].anoCreacion); return true; } function updateSystemDescripcion(address systemAddress, bytes32 descrip) public returns(bool success) { if(!isLoad(systemAddress)) throw; systemStructs[systemAddress].descripcion = descrip; LogUpdateSystem( systemAddress, systemStructs[systemAddress].index, systemStructs[systemAddress].unidadAcademica, systemStructs[systemAddress].nombreSistema, systemStructs[systemAddress].apellidoEncargado, systemStructs[systemAddress].emailEncargado, descrip, systemStructs[systemAddress].anoCreacion); return true; } function getSystemCount() public constant returns(uint count) { return systemIndex.length; } function getSystemAtIndex(uint index) public constant returns(address systemAddress) { return systemIndex[index]; } }
0.4.9