// “Copyright (C) 2009-2011 Association Réseau Phast”
// This file is part of ParserIO.
// ParserIO is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// ParserIO is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with ParserIO.  If not, see <http://www.gnu.org/licenses/>.
//
//For more information, please consult the ParserIO web site at
//<http://parserio.codeplex.com>
//
// ParserIO_WS.cs (ParserIO_WS.ParserIO_WS)

// 18/10/10 NC First draft
// 01/04/11 DU Rename description from Parser to ParserIO
//
// 13/04/11 Version 0.25
// 13/04/11 DU [fr] Ajouté la WebMethod Parse_22
//             [en] Added the WebMethod Parse_22
// 22/09/11 Version 0.28
// 22/09/11 DU [fr] Ajouté la WebMethod Parse_30
//             [en] Added the WebMethod Parse_30
//
// 26-08-2013 Version 1.0.0.0
// 26-08-2013 DU [fr] Ajouté la WebMethod Parse_32
//               [en] Added the WebMethod Parse_32

using System;
using System.Web.Services;
using System.Globalization;
using System.IO;
using ParserIO_functions;

namespace ParserIO_WS
{
  [WebService(Namespace = "http://phastservices.cloudapp.net/ParserIO",
     Description = "Phast ParserIO - Version 1.0.0.0  09-27-2013")]
  public class ParserIO_WS : System.Web.Services.WebService
  {
    public ParserIO_WS()
    {
      //CODEGEN: This call is required by the ASP.NET Web Services Designer
      InitializeComponent();
    }

    #region Component Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    }
    #endregion

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>

    protected override void Dispose(bool disposing)
    {
    }

    [WebMethod(Description = "One Barcode input - 11 Values Output - Obsolete")]
    public int Parse_11(
      string Code_barres,
      out string Type,
      out string Variante,
      out string Entreprise,
      out string Produit,
      out string GTIN,
      out string LIC,
      out string PCN,
      out string Lot,
      out string DateBrute,
      out string DateNormale,
      out string Reference,
      out string Errors)
    {
      int result = 0;
      Type = "";
      Variante = "";
      Entreprise = "";
      Produit = "";
      GTIN = "";
      LIC = "";
      PCN = "";
      Lot = "";
      DateBrute = "";
      DateNormale = "";
      Reference = "";
      Errors = "";
      try
      {
        ParserIO_functions.ParserIO_func Parser = new ParserIO_functions.ParserIO_func();
        string code = Code_barres;
        string type = Parser.Type(code);
        string variante = Parser.SubType(code, type);
        Type = type;
        Variante = variante;
        Entreprise = Parser.Company(code, type, variante);
        Produit = Parser.Product(code, type, variante);
        GTIN = Parser.GTIN(code, type, variante);
        LIC = Parser.LIC(code, type, variante);
        PCN = Parser.PCN(code, type, variante);
        Lot = Parser.Lot(code, type, variante);
        DateBrute = Parser.Expiry(code, type, variante);
        DateNormale = Parser.NormalizedExpiry(code, type, variante);
        Reference = Parser.Reference(code, type, variante);
      }
      catch (Exception e)
      {
        result = -1;
        Errors = e.Message;
      }
      return result;
    }

    [WebMethod(Description = "One Barcode input - 22 Values Output - Obsolete")]
    public int Parse_22(
      string Code_barres,
      out string Type,
      out string Variante,
      out string Entreprise,
      out string Produit,
      out string GTIN,
      out string LIC,
      out string PCN,
      out string Lot,
      out string BESTBEFORE,
      out string NormalizedBESTBEFORE,
      out string Expiry,
      out string NormalizedExpiry,
      out string CONTENT,
      out string COUNT,
      out string PRODDATE,
      out string NormalizedPRODDATE,
      out string Quantite,
      out string Reference,
      out string SSCC,
      out string Serial,
      out string VARCOUNT,
      out string VARIANT,
      out string Errors
      )
    {
      int result = 0;
      Type = "";
      Variante = "";
      Entreprise = "";
      Produit = "";
      GTIN = "";
      LIC = "";
      PCN = "";
      Lot = "";
      Expiry = "";
      NormalizedExpiry = "";
      BESTBEFORE = "";
      NormalizedBESTBEFORE = "";
      CONTENT = "";
      COUNT = "";
      PRODDATE = "";
      NormalizedPRODDATE = "";
      Quantite = "";
      Reference = "";
      SSCC = "";
      Serial = "";
      VARCOUNT = "";
      VARIANT = "";
      Errors = "";
      try
      {
        ParserIO_functions.ParserIO_func Parser = new ParserIO_functions.ParserIO_func();
        string code = Code_barres;
        string type = Parser.Type(code);
        string variante = Parser.SubType(code, type);
        Type = type;
        Variante = variante;
        Entreprise = Parser.Company(code, type, variante);
        Produit = Parser.Product(code, type, variante);
        GTIN = Parser.GTIN(code, type, variante);
        LIC = Parser.LIC(code, type, variante);
        PCN = Parser.PCN(code, type, variante);
        Lot = Parser.Lot(code, type, variante);
        Expiry = Parser.Expiry(code, type, variante);

        NormalizedExpiry = Parser.NormalizedExpiry(code, type, variante);
        BESTBEFORE = Parser.BESTBEFORE(code, type, variante);
        NormalizedBESTBEFORE = Parser.NormalizedBESTBEFORE(code, type, variante);
        CONTENT = Parser.CONTENT(code, type, variante);
        COUNT = Parser.COUNT(code, type, variante);
        PRODDATE = Parser.PRODDATE(code, type, variante);
        NormalizedPRODDATE = Parser.NormalizedPRODDATE(code, type, variante);
        Quantite = Parser.Quantity(code, type, variante);
        Reference = Parser.Reference(code, type, variante);
        SSCC = Parser.SSCC(code, type, variante);
        Serial = Parser.Serial(code, type, variante);
        VARCOUNT = Parser.VARCOUNT(code, type, variante);
        VARIANT = Parser.VARIANT(code, type, variante);
      }
      catch (Exception e)
      {
        result = -1;
        Errors = e.Message;
      }
      return result;
    }

    [WebMethod(Description = "One Barcode input - 30 Values Output - Obsolete")]
    public int Parse_30(string Barcode,
      out string ACL,   //1
      out string ADDITIONALID,  //2
      out string BESTBEFORE,    //3
      out string CIP,   //4
      out string Company,   //5
      out string CONTENT,   //6
      out string COUNT,   //7
      out string Expiry,    //8
      out string Family,    //9
      out string GTIN,    //10
      out string LIC,   //11
      out string Lot,   //12
      out string LPP,   //13
      out string NaS7,  //14
      out string NormalizedBESTBEFORE,    //15
      out string NormalizedExpiry,    //16
      out string NormalizedPRODDATE,   //17
      out string PCN,       //18
      out string PRODDATE,  //19
      out string Product,   //20
      out string Quantity,  //21
      out string Reference, //22
      out string Serial,    //23
      out string SSCC,      //24
      out string SubType,   //25
      out string Type,      //26
      out string UCD,       //27
      out string UoM,       //28
      out string VARCOUNT,  //29
      out string VARIANT,   //30
      out string Erreurs
      )
    {
      int result = 0;
      ACL = "";   //1
      ADDITIONALID = "";    //2
      BESTBEFORE = "";    //3
      CIP = "";   //4
      Company = "";   //5
      CONTENT = "";   //6
      COUNT = "";   //7
      Expiry = "";    //8
      Family = "";    //9
      GTIN = "";    //10
      LIC = "";   //11
      Lot = "";   //12
      LPP = "";   //13
      NaS7 = "";    //14
      NormalizedBESTBEFORE = "";  //15
      NormalizedExpiry = "";    //16
      NormalizedPRODDATE = "";  //17
      PCN = "";   //18
      PRODDATE = "";  //19
      Product = "";   //20
      Quantity = "";   //21
      Reference = "";   //22
      Serial = "";    //23
      SSCC = "";    //24
      SubType = ""; //25
      Type = "";    //26
      UCD = "";   //27
      UoM = "";   //28
      VARCOUNT = "";  //29
      VARIANT = ""; //30
      Erreurs = "";
      try
      {
        ParserIO_functions.ParserIO_func Parser = new ParserIO_functions.ParserIO_func();
        Type = Parser.Type(Barcode); //26
        SubType = Parser.SubType(Barcode, Type); //25
        ACL = Parser.ACL(Barcode, Type, SubType);  //1
        ADDITIONALID = Parser.ADDITIONALID(Barcode, Type, SubType);  //2
        BESTBEFORE = Parser.BESTBEFORE(Barcode, Type, SubType);    //3
        CIP = Parser.CIP(Barcode, Type, SubType);    //4
        Company = Parser.Company(Barcode, Type, SubType);  //5
        CONTENT = Parser.CONTENT(Barcode, Type, SubType);   //6
        COUNT = Parser.COUNT(Barcode, Type, SubType);    //7
        Expiry = Parser.Expiry(Barcode, Type, SubType);  //8
        Family = Parser.Family(Barcode, Type, SubType);   //9
        GTIN = Parser.GTIN(Barcode, Type, SubType);    //10
        LIC = Parser.LIC(Barcode, Type, SubType);    //11
        Lot = Parser.Lot(Barcode, Type, SubType);    //12
        LPP = Parser.LPP(Barcode, Type, SubType);    //13
        NaS7 = Parser.NaS7(Barcode, Type, SubType);  //14
        NormalizedBESTBEFORE = Parser.NormalizedBESTBEFORE(Barcode, Type, SubType);  //15
        NormalizedExpiry = Parser.NormalizedExpiry(Barcode, Type, SubType);  //16
        NormalizedPRODDATE = Parser.NormalizedPRODDATE(Barcode, Type, SubType);  //17
        PCN = Parser.PCN(Barcode, Type, SubType);    //18
        PRODDATE = Parser.PRODDATE(Barcode, Type, SubType);    //19
        Product = Parser.Product(Barcode, Type, SubType);  //20
        Quantity = Parser.Quantity(Barcode, Type, SubType);  //21
        Reference = Parser.Reference(Barcode, Type, SubType);  //22
        Serial = Parser.Serial(Barcode, Type, SubType);  //23
        SSCC = Parser.SSCC(Barcode, Type, SubType);    //24
     //   UCD = Parser.UCD(Barcode, Type, SubType);    //27
        UoM = Parser.UoM(Barcode, Type, SubType);    //28
        VARCOUNT = Parser.VARCOUNT(Barcode, Type, SubType);  //29
        VARIANT = Parser.VARIANT(Barcode, Type, SubType);    //30
      }
      catch (Exception e)
      {
        result = -1;
        Erreurs = e.Message;
      }
      return result;
    }

    [WebMethod(Description = "Takes a barcode value as input and returns a full set of information")]
    public int Parse_1(string Barcode,
      out string ACL,   //1
      out string ADDITIONALID,  //2
      out string BESTBEFORE,    //3
      out string CIP,   //4
      out string Company,   //5
      out bool containsOrMayContainsId,
      out string CONTENT,   //6
      out string COUNT,   //7
      out string Expiry,    //8
      out string Family,    //9
      out string GTIN,    //10
      out string LIC,   //11
      out string Lot,   //12
      out string LPP,   //13
      out string NaS7,  //14
      out string NormalizedBESTBEFORE,    //15
      out string NormalizedExpiry,    //16
      out string NormalizedPRODDATE,   //17
      out string PCN,       //18
      out string PRODDATE,  //19
      out string Product,   //20
      out string Quantity,  //21
      out string Reference, //22
      out string Serial,    //23
      out string SSCC,      //24
      out string SubType,   //25
      out string Type,      //26
      out string UoM,       //28
      out string VARCOUNT,  //29
      out string VARIANT,   //30
      out string Errors   
      )
    {
      int result = 0;
      ACL = "";   //1
      ADDITIONALID = "";    //2
      BESTBEFORE = "";    //3
      CIP = "";   //4
      Company = "";   //5
      containsOrMayContainsId = false; //31
      CONTENT = "";   //6
      COUNT = "";   //7
      Expiry = "";    //8
      Family = "";    //9
      GTIN = "";    //10
      LIC = "";   //11
      Lot = "";   //12
      LPP = "";   //13
      NaS7 = "";    //14
      NormalizedBESTBEFORE = "";  //15
      NormalizedExpiry = "";    //16
      NormalizedPRODDATE = "";  //17
      PCN = "";   //18
      PRODDATE = "";  //19
      Product = "";   //20
      Quantity = "";   //21
      Reference = "";   //22
      Serial = "";    //23
      SSCC = "";    //24
      SubType = ""; //25
      Type = "";    //26
      UoM = "";   //28
      VARCOUNT = "";  //29
      VARIANT = ""; //30
      Errors = "";
      try
      {
        ParserIO_functions.ParserIO_func Parser = new ParserIO_functions.ParserIO_func();
        Type = Parser.Type(Barcode); //26
        SubType = Parser.SubType(Barcode, Type); //25
        ACL = Parser.ACL(Barcode, Type, SubType);  //1
        ADDITIONALID = Parser.ADDITIONALID(Barcode, Type, SubType);  //2
        BESTBEFORE = Parser.BESTBEFORE(Barcode, Type, SubType);    //3
        CIP = Parser.CIP(Barcode, Type, SubType);    //4
        Company = Parser.Company(Barcode, Type, SubType);  //5
        containsOrMayContainsId = Parser.containsOrMayContainsId(Type, SubType);
        CONTENT = Parser.CONTENT(Barcode, Type, SubType);   //6
        COUNT = Parser.COUNT(Barcode, Type, SubType);    //7
        Expiry = Parser.Expiry(Barcode, Type, SubType);  //8
        Family = Parser.Family(Barcode, Type, SubType);   //9
        GTIN = Parser.GTIN(Barcode, Type, SubType);    //10
        LIC = Parser.LIC(Barcode, Type, SubType);    //11
        Lot = Parser.Lot(Barcode, Type, SubType);    //12
        LPP = Parser.LPP(Barcode, Type, SubType);    //13
        NaS7 = Parser.NaS7(Barcode, Type, SubType);  //14
        NormalizedBESTBEFORE = Parser.NormalizedBESTBEFORE(Barcode, Type, SubType);  //15
        NormalizedExpiry = Parser.NormalizedExpiry(Barcode, Type, SubType);  //16
        NormalizedPRODDATE = Parser.NormalizedPRODDATE(Barcode, Type, SubType);  //17
        PCN = Parser.PCN(Barcode, Type, SubType);    //18
        PRODDATE = Parser.PRODDATE(Barcode, Type, SubType);    //19
        Product = Parser.Product(Barcode, Type, SubType);  //20
        Quantity = Parser.Quantity(Barcode, Type, SubType);  //21
        Reference = Parser.Reference(Barcode, Type, SubType);  //22
        Serial = Parser.Serial(Barcode, Type, SubType);  //23
        SSCC = Parser.SSCC(Barcode, Type, SubType);    //24
        UoM = Parser.UoM(Barcode, Type, SubType);    //28
        VARCOUNT = Parser.VARCOUNT(Barcode, Type, SubType);  //29
        VARIANT = Parser.VARIANT(Barcode, Type, SubType);    //30
      }
      catch (Exception e)
      {
        result = -1;
        Errors = e.Message;
      }
      return result;
    }
  }
}
