public void RemoveMailing(int mailingId)
        {
            ProcedureCall removeMailing = new ProcedureCall("pr_removeMailing", sqlConnection);

            removeMailing.parameters.Add(new ProcedureParam("@mailingId", SqlDbType.Int, 4, mailingId));
            removeMailing.Execute(false);
        }
Esempio n. 2
0
        private static void DisplayProcedureCall(ProcedureCall lastProcedureCall)
        {
            for (int i = 0; i < lastProcedureCall.ProcedureArguments.Count; i++)
            {
                Identifier id = lastProcedureCall.ProcedureArguments[i];
                switch (id.IdentifierType)
                {
                case IdentifierType.Parameter:
                    Parameter par = (Parameter)id;
                    Console.WriteLine(" argument[{0}], Parameter:", i);
                    foreach (TupleValuePair <double> tv in par.Data)
                    {
                        Console.WriteLine("  {0} : {1}", tv.tuple, tv.value);
                    }
                    break;

                case IdentifierType.StringParameter:
                    StringParameter stringPar = (StringParameter)id;
                    Console.WriteLine(" argument[{0}], StringParameter:", i);
                    foreach (TupleValuePair <string> tv in stringPar.Data)
                    {
                        Console.WriteLine("  {0} : '{1}'", tv.tuple, tv.value);
                    }
                    break;
                }
            }
        }
Esempio n. 3
0
        public void RemovePrintingDevice(int id)
        {
            ProcedureCall removePrintingDevice = new ProcedureCall("pr_removePrintingDevice", sqlConnection);

            removePrintingDevice.parameters.Add(new ProcedureParam("@id", SqlDbType.Int, 4, id));
            removePrintingDevice.Execute(false);
        }
Esempio n. 4
0
        public void RemoveTenant(int tenantId)
        {
            ProcedureCall removeTenant = new ProcedureCall("pr_removeTenant", sqlConnection);

            removeTenant.parameters.Add(new ProcedureParam("@tenantId", SqlDbType.Int, 4, tenantId));
            removeTenant.Execute(false);
        }
Esempio n. 5
0
        public void SetPrintingDevice(PrintingDevice printingDevice)
        {
            ProcedureCall storePrintingDevice = new ProcedureCall("pr_storePrintingDevice", sqlConnection);

            storePrintingDevice.parameters.Add(new ProcedureParam("@tenantId", SqlDbType.Int, 4, printingDevice.tenantId));
            storePrintingDevice.parameters.Add(new ProcedureParam("@ipAddress", SqlDbType.VarChar, 100, printingDevice.ipAddress));
            storePrintingDevice.parameters.Add(new ProcedureParam("@description", SqlDbType.VarChar, 100, printingDevice.description));
            storePrintingDevice.parameters.Add(new ProcedureParam("@serialNumber", SqlDbType.VarChar, 100, printingDevice.serialNumber));
            storePrintingDevice.parameters.Add(new ProcedureParam("@counter", SqlDbType.Int, 4, printingDevice.counter));
            storePrintingDevice.Execute(true);

            int?deviceId = storePrintingDevice.ExtractFromResultset();

            if (deviceId != null)
            {
                List <Object> counterHistory = GetCounterHistory(deviceId.Value);
                if (counterHistory.Count > 0)
                {
                    // Verifica se o contador é repetido, considera uma diferença de 50 páginas ao comparar
                    DateTime    today       = DateTime.Now;
                    PageCounter lastCounter = (PageCounter)counterHistory[0];
                    Decimal     diff        = Math.Abs(printingDevice.counter - lastCounter.counter);
                    if ((lastCounter.date.Day != today.Day) || (diff > 50))
                    {
                        SetPageCounter(deviceId.Value, printingDevice.counter);
                    }
                }
                else
                {
                    // Nenhum contador prévio, insere primeira ocorrência
                    SetPageCounter(deviceId.Value, printingDevice.counter);
                }
            }
        }
Esempio n. 6
0
        public void RemoveLogin(int loginId)
        {
            ProcedureCall removeLogin = new ProcedureCall("pr_removeLogin", sqlConnection);

            removeLogin.parameters.Add(new ProcedureParam("@loginId", SqlDbType.Int, 4, loginId));
            removeLogin.Execute(false);
        }
Esempio n. 7
0
        public static Expression Call(ProcedureCall call)
        {
            if (ReferenceEquals(call, null))
            {
                throw new ArgumentNullException(nameof(call));
            }
            var services  = Services.Instance;
            var procedure = services.GetProcedureSignature(call);

            if (!procedure.HasReturnType)
            {
                throw new InvalidOperationException(
                          "Cannot use a procedure that does not return a value.");
            }
            var arguments = services.GetArguments(procedure, call.Arguments);

            var servicesExpr      = LinqExpression.Constant(services);
            var executeCallMethod = typeof(Services).GetMethod(
                "ExecuteCall", new[] { typeof(Scanner.ProcedureSignature), typeof(object[]) });
            var procedureExpr = LinqExpression.Constant(procedure);
            var argumentsExpr = LinqExpression.Constant(arguments);

            var result = LinqExpression.Call(
                servicesExpr, executeCallMethod,
                new[] { procedureExpr, argumentsExpr });
            var value = LinqExpression.Convert(
                LinqExpression.Property(result, "Value"), procedure.ReturnType);

            return(new Expression(value));
        }
        public void RemoveAllAssociates(int costCenterId)
        {
            ProcedureCall removeAssociates = new ProcedureCall("pr_removeAssociate", sqlConnection);

            removeAssociates.parameters.Add(new ProcedureParam("@costCenterId", SqlDbType.Int, 4, costCenterId));
            removeAssociates.Execute(false);
        }
        public void RemoveAssociate(int associateId)
        {
            ProcedureCall removeAssociate = new ProcedureCall("pr_removeAssociate", sqlConnection);

            removeAssociate.parameters.Add(new ProcedureParam("@associateId", SqlDbType.Int, 4, associateId));
            removeAssociate.Execute(false);
        }
Esempio n. 10
0
        public void RemoveSmtpServer(int smtpServerId)
        {
            ProcedureCall removeSmtpServer = new ProcedureCall("pr_removeSmtpServer", sqlConnection);

            removeSmtpServer.parameters.Add(new ProcedureParam("@smtpServerId", SqlDbType.Int, 4, smtpServerId));
            removeSmtpServer.Execute(false);
        }
        public void RemoveCostCenterTree(int tenantId)
        {
            ProcedureCall removeCostCenters = new ProcedureCall("pr_removeCostCenter", sqlConnection);

            removeCostCenters.parameters.Add(new ProcedureParam("@tenantId", SqlDbType.Int, 4, tenantId));
            removeCostCenters.Execute(false);
        }
        public void RemoveCostCenter(int costCenterId)
        {
            ProcedureCall removeCostCenter = new ProcedureCall("pr_removeCostCenter", sqlConnection);

            removeCostCenter.parameters.Add(new ProcedureParam("@costCenterId", SqlDbType.Int, 4, costCenterId));
            removeCostCenter.Execute(false);
        }
Esempio n. 13
0
        internal ByteString Invoke(ProcedureCall call)
        {
            var request = new Request();

            request.Calls.Add(call);
            Response response;

            lock (invokeLock) {
                // Send request to server
                codedRpcStream.WriteLength(request.CalculateSize());
                request.WriteTo(codedRpcStream);
                codedRpcStream.Flush();
                // Receive response
                int size = ReadMessageData(rpcStream, ref responseBuffer);
                response = Response.Parser.ParseFrom(new CodedInputStream(responseBuffer, 0, size));
            }

            if (response.Error != null)
            {
                throw GetException(response.Error);
            }
            if (response.Results[0].Error != null)
            {
                throw GetException(response.Results [0].Error);
            }
            return(response.Results[0].Value);
        }
        public static Object[] Retrieve(String procedureName, SqlConnection sqlConnection, Type objectType)
        {
            // Convenções:
            // A procedure deve retornar registros compatíveis com objectType
            // objectType deve possuir campos com os atributos [ItemId] e [ItemName]
            // Estes campos devem ser publicos e de instancia (não estáticos)

            ProcedureCall procedureCall = new ProcedureCall(procedureName, sqlConnection);

            procedureCall.parameters.Add(new ProcedureParam("@tenantId", SqlDbType.Int, 4, 4));
            procedureCall.Execute(true);
            List <Object> returnList = procedureCall.ExtractFromResultset(objectType);

            ItemScaffolding itemScaffolding = new ItemScaffolding();

            itemScaffolding.FindItemFields(objectType);

            Object[] itemArray = new Object[returnList.Count + 1];
            itemArray[0] = Activator.CreateInstance(objectType);
            itemScaffolding.SetItemId(itemArray[0], 0);
            itemScaffolding.SetItemName(itemArray[0], "");
            int ndx = 1;

            foreach (Object obj in returnList)
            {
                itemArray[ndx] = Activator.CreateInstance(objectType);
                itemScaffolding.SetItemId(itemArray[ndx], itemScaffolding.GetItemId(obj));
                itemScaffolding.SetItemName(itemArray[ndx], itemScaffolding.GetItemName(obj));
                ndx++;
            }

            return(itemArray);
        }
Esempio n. 15
0
        public void SetPageCounter(int deviceId, int counter)
        {
            ProcedureCall storePageCounter = new ProcedureCall("pr_storePageCounter", sqlConnection);

            storePageCounter.parameters.Add(new ProcedureParam("@deviceId", SqlDbType.Int, 4, deviceId));
            storePageCounter.parameters.Add(new ProcedureParam("@counter", SqlDbType.Int, 4, counter));
            storePageCounter.Execute(false);
        }
        public void SetAssociate(CostCenterAssociate associate)
        {
            ProcedureCall storeAssociate = new ProcedureCall("pr_storeAssociate", sqlConnection);

            storeAssociate.parameters.Add(new ProcedureParam("@tenantId", SqlDbType.Int, 4, associate.tenantId));
            storeAssociate.parameters.Add(new ProcedureParam("@costCenterId", SqlDbType.Int, 4, associate.costCenterId));
            storeAssociate.parameters.Add(new ProcedureParam("@userId", SqlDbType.Int, 4, associate.userId));
            storeAssociate.Execute(false);
        }
Esempio n. 17
0
        public void SetLogin(AdministratorLogin login)
        {
            ProcedureCall storeLogin = new ProcedureCall("pr_storeAdministratorLogin", sqlConnection);

            storeLogin.parameters.Add(new ProcedureParam("@loginId", SqlDbType.Int, 4, login.id));
            storeLogin.parameters.Add(new ProcedureParam("@username", SqlDbType.VarChar, 100, login.username));
            storeLogin.parameters.Add(new ProcedureParam("@password", SqlDbType.VarChar, 100, login.password));
            storeLogin.Execute(false);
        }
Esempio n. 18
0
 public JITProcedure(VM vm, Scope parentScope, Chunk chunk, Procedure procedure, UpValue[] upvalues, ProcedureCall @delegate)
 {
     this.vm          = vm;
     this.parentScope = parentScope;
     this.chunk       = chunk;
     this.procedure   = procedure;
     this.upvalues    = upvalues;
     this.@delegate   = @delegate;
 }
Esempio n. 19
0
 public ProcedureCallContinuation(ProcedureCall procedureCall)
 {
     call = procedureCall;
     try {
         procedure = Services.Instance.GetProcedureSignature(call);
     } catch (System.Exception e) {
         exception = e;
     }
 }
Esempio n. 20
0
        public void SetParam(ApplicationParam param)
        {
            ProcedureCall updateAccountingParam = new ProcedureCall("pr_storeAccountingParam", sqlConnection);

            updateAccountingParam.parameters.Add(new ProcedureParam("@paramId", SqlDbType.Int, 4, param.id));
            updateAccountingParam.parameters.Add(new ProcedureParam("@name", SqlDbType.VarChar, 100, param.name));
            updateAccountingParam.parameters.Add(new ProcedureParam("@value", SqlDbType.VarChar, 255, param.value));
            updateAccountingParam.parameters.Add(new ProcedureParam("@ownerTask", SqlDbType.VarChar, 100, param.ownerTask));
            updateAccountingParam.Execute(false);
        }
        public void SetCostCenter(CostCenter costCenter)
        {
            ProcedureCall storeCostCenter = new ProcedureCall("pr_storeCostCenter", sqlConnection);

            storeCostCenter.parameters.Add(new ProcedureParam("costCenterId", SqlDbType.Int, 4, costCenter.id));
            storeCostCenter.parameters.Add(new ProcedureParam("@tenantId", SqlDbType.Int, 4, costCenter.tenantId));
            storeCostCenter.parameters.Add(new ProcedureParam("@name", SqlDbType.VarChar, 100, costCenter.name));
            storeCostCenter.parameters.Add(new ProcedureParam("@parentId", SqlDbType.Int, 4, costCenter.parentId));
            storeCostCenter.Execute(false);
        }
Esempio n. 22
0
        static ProcedureCall Call(string service, string procedure, params Argument[] args)
        {
            var call = new ProcedureCall(service, procedure);

            foreach (var arg in args)
            {
                call.Arguments.Add(arg);
            }
            return(call);
        }
Esempio n. 23
0
        public void Visit(ProcedureCall call, CommonTree tree)
        {
            Parent(tree).Children.Add(call);
            SetLine(call, tree);

            call.Name = tree.Children[0].Text;
            for (int x = 1; x < tree.ChildCount; x++)
            {
                Visit(tree.Children[x]);
            }
        }
Esempio n. 24
0
        public List <Object> GetAllTenants()
        {
            List <Object> tenantList;

            ProcedureCall retrieveTenants = new ProcedureCall("pr_retrieveTenant", sqlConnection);

            retrieveTenants.Execute(true);
            tenantList = retrieveTenants.ExtractFromResultset(typeof(Tenant));

            return(tenantList);
        }
Esempio n. 25
0
        public int?SetTenant(Tenant tenant)
        {
            ProcedureCall storeTenant = new ProcedureCall("pr_storeTenant", sqlConnection);

            storeTenant.parameters.Add(new ProcedureParam("@tenantId", SqlDbType.Int, 4, tenant.id));
            storeTenant.parameters.Add(new ProcedureParam("name", SqlDbType.VarChar, 100, tenant.name));
            storeTenant.parameters.Add(new ProcedureParam("@alias", SqlDbType.VarChar, 100, tenant.alias));
            storeTenant.Execute(true);

            return(storeTenant.ExtractFromResultset()); // retorna o id da empresa
        }
Esempio n. 26
0
        public void SetLicense(License license)
        {
            ProcedureCall storeLicense = new ProcedureCall("pr_storeLicense", sqlConnection);

            storeLicense.parameters.Add(new ProcedureParam("@licenseId", SqlDbType.Int, 4, license.id));
            storeLicense.parameters.Add(new ProcedureParam("@tenantId", SqlDbType.Int, 4, license.tenantId));
            storeLicense.parameters.Add(new ProcedureParam("@installationKey", SqlDbType.VarChar, 255, license.installationKey));
            storeLicense.parameters.Add(new ProcedureParam("@installationDate", SqlDbType.DateTime, 8, license.installationDate));
            storeLicense.parameters.Add(new ProcedureParam("@computerName", SqlDbType.VarChar, 100, license.computerName));
            storeLicense.Execute(false);
        }
Esempio n. 27
0
        public List <Object> GetAllLogins()
        {
            List <Object> administratorLogins;

            ProcedureCall retrieveLogin = new ProcedureCall("pr_retrieveAdministratorLogin", sqlConnection);

            retrieveLogin.Execute(true);
            administratorLogins = retrieveLogin.ExtractFromResultset(typeof(AdministratorLogin));

            return(administratorLogins);
        }
        public void SetTenantPreference(Preference preference)
        {
            ProcedureCall storeTenantPreference = new ProcedureCall("pr_storeTenantPreference", sqlConnection);

            storeTenantPreference.parameters.Add(new ProcedureParam("@tenantId", SqlDbType.Int, 4, preference.tenantId));
            storeTenantPreference.parameters.Add(new ProcedureParam("@preferenceId", SqlDbType.Int, 4, preference.id));
            storeTenantPreference.parameters.Add(new ProcedureParam("@name", SqlDbType.VarChar, 100, preference.name));
            storeTenantPreference.parameters.Add(new ProcedureParam("@value", SqlDbType.VarChar, 255, preference.value));
            storeTenantPreference.parameters.Add(new ProcedureParam("@type", SqlDbType.VarChar, 80, preference.type));
            storeTenantPreference.Execute(false);
        }
Esempio n. 29
0
        public List <Object> GetAllParams()
        {
            List <Object> accountingParams;

            ProcedureCall retrieveAccountingParams = new ProcedureCall("pr_retrieveAccountingParams", sqlConnection);

            retrieveAccountingParams.Execute(true);
            accountingParams = retrieveAccountingParams.ExtractFromResultset(typeof(ApplicationParam));

            return(accountingParams);
        }
Esempio n. 30
0
        public ProcedureCallStream(ProcedureCall call)
        {
            var services = Services.Instance;

            procedure = services.GetProcedureSignature(call);
            if (!procedure.HasReturnType)
            {
                throw new InvalidOperationException("Cannot create a stream for a procedure that does not return a value.");
            }
            arguments    = services.GetArguments(procedure, call.Arguments);
            continuation = new StreamContinuation(call);
        }