Creating an Event in a WebService

4

I have a Webservice that has a method that writes a new inbound record and updates the list that contains those entries. Now I need the client to sign a Webservice event so that whenever a new record is added the event is triggered on the client so that it can do the necessary checks.

    
asked by anonymous 01.02.2016 / 19:22

1 answer

4

Simply and without knowing much about your environment, you will need to create a sort of Schedule . A console program that has a timer or is scheduled to run from time to time, looking at the records in the table that your WS will insert. Whenever it finds something new there, it triggers the action you want.

Below is a very general example of how to schedule to process from time to time, according to the parameters you want.

    public void ProcessarRotinas()
    {
       try
        {

            while (true)
            {
                for (int i = 1; i <= TentativasErro; i++)
                {
                    try
                    {
                        //Aqui vai toda sua regra de negócio
                        ExecutarRegra();
                        Thread.Sleep(ValordePausa * 1000);
                        break;
                    }

                    catch (Exception ex)
                    {                                                
                        Thread.Sleep(ValordePausa * 1000);
                    }
                }


            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    
18.02.2016 / 16:51