Пример #1
0
        public static string UPU(Guid guidUser)
        {
            //MULTIPLE USERS
            var u = _context.Users.Where(a => a.guidUser == guidUser);

            if (u.Count() == 0)
            {
                return(null);
            }

            var Users = _context.Users.Where(a => a.guidUser == guidUser).SingleOrDefault(a => a.parentId == 0);

            if (Users == null)
            {
                return(null);
            }
            ROLServiceSoapClient service = new ROLServiceSoapClient();

            if (Users.areaTestUser)
            {
                service.ClientCredentials.UserName.UserName = Users.usernamePosteAreaTest;
                service.ClientCredentials.UserName.Password = Users.pwdPosteAreaTest;
            }
            else
            {
                service.ClientCredentials.UserName.UserName = Users.usernamePoste;
                service.ClientCredentials.UserName.Password = Users.pwdPoste;
            }
            var n = service.RecuperaNomiNazioniUPU(CountryLanguage.Italiano);
            var l = n.ListaNomi;

            return(JsonConvert.SerializeObject(l));
        }
Пример #2
0
        public static ROLServiceSoapClient getNewServiceRol(Guid guidUser)
        {
            //MULTIPLE USERS
            var u = _context.Users.Where(a => a.guidUser == guidUser);

            if (u.Count() == 0)
            {
                return(null);
            }

            var Users = _context.Users.Where(a => a.guidUser == guidUser).SingleOrDefault(a => a.parentId == 0);

            if (Users == null)
            {
                return(null);
            }
            ROLServiceSoapClient service = new ROLServiceSoapClient();

            if (Users.areaTestUser)
            {
                service.ClientCredentials.UserName.UserName = Users.usernamePosteAreaTest;
                service.ClientCredentials.UserName.Password = Users.pwdPosteAreaTest;
            }
            else
            {
                service.ClientCredentials.UserName.UserName = Users.usernamePoste;
                service.ClientCredentials.UserName.Password = Users.pwdPoste;
            }
            return(service);
        }
Пример #3
0
        private static string getRequestId(Guid guid)
        {
            ROLServiceSoapClient service = new ROLServiceSoapClient();

            service = getNewServiceRol(guid);
            var IdRichiesta = service.RecuperaIdRichiesta().IDRichiesta;

            service.Close();
            return(IdRichiesta);
        }
Пример #4
0
        public async Task <bool> ValorizzaConfirm(List <Names> names, Guid guidUser)
        {
            ROLServiceSoapClient service = new ROLServiceSoapClient();

            service = getNewServiceRol(guidUser);

            Richiesta[] Richiesta = new Richiesta[names.Count];
            int         y         = 0;

            foreach (var n in names)
            {
                Richiesta r = new Richiesta();
                r.GuidUtente  = n.guidUser;
                r.IDRichiesta = n.requestId;
                Richiesta[y]  = r;
                y++;
            }

            Thread.Sleep(15000);
            var v = await service.ValorizzaAsync(Richiesta);

            int i = 0;

            if (v.ValorizzaResult.CEResult.Type != "I")
            {
                do
                {
                    Thread.Sleep(5000);
                    v = await service.ValorizzaAsync(Richiesta);

                    i++;
                } while (v.ValorizzaResult.CEResult.Type != "I" && i < 50);
            }

            if (v.ValorizzaResult.CEResult.Type != "I")
            {
                foreach (var n in names)
                {
                    var nn = _context.Names.SingleOrDefault(a => a.requestId == n.requestId);
                    nn.requestId = null;
                    _context.SaveChanges();
                }
                return(false);
            }

            var ServizioEnquiryResponse = v.ValorizzaResult.ServizioEnquiryResponse.ToList();

            var conferma = await service.PreConfermaAsync(Richiesta, true);

            int z = 0;

            foreach (var s in ServizioEnquiryResponse)
            {
                var n = _context.Names.SingleOrDefault(a => a.requestId == s.Richiesta.IDRichiesta);
                if (s.StatoLavorazione.Descrizione.ToLower() == "prezzato")
                {
                    var p = new Prices()
                    {
                        price      = Convert.ToDecimal(s.Totale.ImportoNetto),
                        vatPrice   = Convert.ToDecimal(s.Totale.ImportoIva),
                        totalPrice = Convert.ToDecimal(s.Totale.ImportoTotale)
                    };

                    if (conferma.PreConfermaResult.DestinatariRaccomandata[z] != null)
                    {
                        n.guidUser     = s.Richiesta.GuidUtente;
                        n.orderId      = conferma.PreConfermaResult.IdOrdine;
                        n.price        = Convert.ToDecimal(s.Totale.ImportoNetto);
                        n.vatPrice     = Convert.ToDecimal(s.Totale.ImportoIva);
                        n.totalPrice   = Convert.ToDecimal(s.Totale.ImportoTotale);
                        n.currentState = (int)currentState.PresoInCarico;
                        n.codice       = conferma.PreConfermaResult.DestinatariRaccomandata[z].NumeroRaccomandata;
                    }
                    else
                    {
                        n.valid = false;
                        n.stato = "Errore nella conferma dell'invio";
                    }
                }
                else
                {
                    n.valid = false;
                    n.stato = "Errore nella conferma dell'invio";
                }
                _context.SaveChanges();
                z++;
            }

            return(true);
        }
Пример #5
0
        public async Task <Names> sendNames(GetRecipent GetRecipent, int operationId, SenderDto sender, int userId)
        {
            var n = _context.Names.SingleOrDefault(a => a.id == GetRecipent.recipient.id);

            var user     = _context.Users.SingleOrDefault(a => a.id == userId);
            var guidUser = user.guidUser;

            //PREVERIFICA BOLLETTINO
            if (GetRecipent.bulletin != null)
            {
                ControlloBollettino ctrlB = GlobalClass.verificaBollettino(GetRecipent.bulletin);
                if (!ctrlB.Valido)
                {
                    n.valid = false;
                    n.stato = "Errore nella convalida del bollettino.";
                    _context.SaveChanges();
                    return(null);
                }
            }

            ROLServiceSoapClient service = new ROLServiceSoapClient();

            service = getNewServiceRol(guidUser);

            var           fileName  = GetRecipent.recipient.fileName;
            List <string> filesName = new List <string>();

            filesName.Add(fileName);

            var requestId = getRequestId(guidUser);


            tipoStampa ts = tipoStampa.colori;

            if (GetRecipent.recipient.tipoStampa)
            {
                ts = tipoStampa.biancoNero;
            }

            fronteRetro fr = fronteRetro.fronte;

            if (GetRecipent.recipient.fronteRetro)
            {
                fr = fronteRetro.fronteRetro;
            }

            Destinatario d = new Destinatario();

            d = GetDestinatarioRol(GetRecipent.recipient);
            Destinatario[] ld = new Destinatario[1];
            ld[0] = d;
            ROLSubmit rs = new ROLSubmit();

            rs.Destinatari       = ld;
            rs.Opzioni           = GetOpzioniRol(ts, fr);
            rs.Mittente          = GetMittente(sender);
            rs.NumeroDestinatari = 1;
            rs.Documento         = getDoc(filesName, 1);

            //BOLLETTINO
            if (GetRecipent.bulletin != null)
            {
                PaginaBollettino pagina = new PaginaBollettino();
                object           b      = null;
                switch (GetRecipent.bulletin.bulletinType)
                {
                case (int)bulletinType.Bollettino451:
                    b = getBollettino451(GetRecipent.bulletin);
                    pagina.Bollettino = (Bollettino451)b;
                    break;

                case (int)bulletinType.Bollettino674:
                    b = getBollettino674(GetRecipent.bulletin);
                    pagina.Bollettino = (Bollettino674)b;
                    break;

                case (int)bulletinType.Bollettino896:
                    b = getBollettino896(GetRecipent.bulletin);
                    pagina.Bollettino = (Bollettino896)b;
                    break;
                }

                PaginaBollettinoBase[] p = new PaginaBollettinoBase[1];
                p[0] = pagina;
                rs.PagineBollettini = p;
            }

            //RICEVUTA DI RITORNO
            if (GetRecipent.recipient.ricevutaRitorno)
            {
                DatiRicevuta dr = new DatiRicevuta();
                dr.Nominativo   = rs.Mittente.Nominativo;
                rs.DatiRicevuta = dr;
            }

            rs.Nazionale = (GetRecipent.recipient.state.ToUpper() == "ITALIA" ? "true" : "false");

            InvioResult esito = new InvioResult();

            try
            {
                esito = service.Invio(requestId, user.businessName, rs);

                if (esito.CEResult.Type != "I")
                {
                    n.valid = false;
                    n.stato = esito.CEResult.Description;
                    _context.SaveChanges();
                    return(n);
                }
                n.requestId = esito.IDRichiesta;
                n.guidUser  = esito.GuidUtente;
                _context.SaveChanges();
            }
            catch (Exception e)
            {
                n.valid = false;
                n.stato = "Errore nella richiesta del submit.";
                _context.SaveChanges();
                return(n);
            };

            return(n);
        }