コード例 #1
0
        protected bool CheckStatusRol(string idRichiesta, string status, TimeSpan timeout, TimeSpan retryInterval)
        {
            bool result = false;

            Stopwatch sw = new Stopwatch();

            sw.Start();
            while (sw.Elapsed <= timeout)
            {
                using (var ctx = new NPCEROLEntities())
                {
                    ctx.Database.Connection.ConnectionString = ambiente.RolConnectionString;
                    var richiesta = ctx.ROL.Where(r => r.IdRichiesta == new Guid(idRichiesta)).FirstOrDefault();

                    if (richiesta != null)
                    {
                        if (richiesta.IdStatoLavorazione == status)
                        {
                            result = true;
                            break;
                        }
                        else
                        {
                            Thread.Sleep(retryInterval);
                        }
                    }
                }
            }
            return(result);
        }
コード例 #2
0
        public void Confirm_Service()
        {
            string idRichiesta = "549551eb-4c76-4e6a-aba1-c37e4c83d8b4";
            string guidUtente  = string.Empty;

            using (var ctx = new NPCEROLEntities())
            {
                ctx.Database.Connection.ConnectionString = ambiente.RolConnectionString;
                var rol = ctx.ROL.Where(r => r.IdRichiesta.ToString() == idRichiesta).FirstOrDefault();
                guidUtente = rol.GuidUtente;
            }

            var proxy = GetProxy <ROLServiceSoap>(ambiente.RolUri);
            var fake  = new OperationContextScope((IContextChannel)proxy);
            HttpRequestMessageProperty headers = GetHttpHeaders(ambiente);

            OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = headers;
            var listRichieste = new List <ServiceReference.ROL.Richiesta>();

            listRichieste.Add(new Richiesta()
            {
                GuidUtente = guidUtente, IDRichiesta = idRichiesta
            });
            PreConfermaRequest request = new PreConfermaRequest {
                Richieste = listRichieste.ToArray(), autoConferma = true
            };

            proxy   = GetProxy <ROLServiceSoap>(ambiente.RolUri);
            fake    = new OperationContextScope((IContextChannel)proxy);
            headers = GetHttpHeaders(ambiente);
            OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = headers;
            var preConfermaResult = proxy.PreConferma(request);

            Assert.AreEqual(preConfermaResult.PreConfermaResult.CEResult.Type, "I");

            CheckStatusRol(idRichiesta, "L", TimeSpan.FromMinutes(3), TimeSpan.FromSeconds(20));
        }