Exemplo n.º 1
0
 public static PrintRedirectConfigurations GetIstance()
 {
     if (_istance == null)
     {
         _istance = new PrintRedirectConfigurations();
     }
     return(_istance);
 }
Exemplo n.º 2
0
 private static void IncreasePriority(ConverterType convertType, PrintRedirectConfigurations objIstance, ServiceLog failedCount)
 {
     if (failedCount.Priority < Int32.MaxValue - 1)
     {
         failedCount.Priority += 1;
     }
     else
     {
         ResetPriority(convertType, objIstance);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Verify if extension is supported and service is alive
        /// </summary>
        /// <param name="fileExtension"></param>
        /// <returns>
        /// True id service IS Valid
        /// </returns>
        public bool IsAlive(string fileExtension)
        {
            var ext = PrintRedirectConfigurations.GetConverter(fileExtension);

            switch (ext)
            {
            case ConverterType.OpenOffice:
            case ConverterType.Redirect:
                return(new ExternalRedirectService().IsAlive(fileExtension, ext));

            case ConverterType.Tif:
            default:
                return(true);
            }
        }
Exemplo n.º 4
0
 private static void ResetPriority(ConverterType convertType, PrintRedirectConfigurations objIstance)
 {
     if (convertType == ConverterType.OpenOffice)
     {
         foreach (var item in objIstance.servicesOpenOffice.Values)
         {
             item.Priority    = 0;
             item.FailedCount = 0;
         }
     }
     else
     {
         foreach (var item in objIstance.services.Values)
         {
             item.Priority    = 0;
             item.FailedCount = 0;
         }
     }
 }
 public byte[] Convert(byte[] blob, string fileExtension, string extReq, ConverterType converterType, AttachConversionMode mode = AttachConversionMode.Default)
 {
     ConverterServiceSvc.StampaConformeConverterClient svc = null;
     try
     {
         svc = new ConverterServiceSvc.StampaConformeConverterClient("StampaConformeConverter", PrintRedirectConfigurations.GetWsUrl(converterType, lastWs));
         //svc.Url = PrintRedirectConfigurations.GetWsUrl(lastWs);
         logger.InfoFormat("Call External WS: {0}", svc.Endpoint.ListenUri.ToString());
         byte[] res = null;
         if (mode == AttachConversionMode.Default)
         {
             res = svc.Convert(blob, fileExtension);
         }
         else
         {
             res = svc.ConvertWithParameters(blob, fileExtension, (ConverterServiceSvc.AttachConversionMode)mode);
         }
         PrintRedirectConfigurations.SetWsUrlPriority(converterType, svc.Endpoint.ListenUri.ToString());
         return(res);
     }
     catch (Exception ex)
     {
         logger.Error(ex);
         if (svc != null)
         {
             PrintRedirectConfigurations.SetWsUrlFault(converterType, svc.Endpoint.ListenUri.ToString());
         }
         if (ret >= PrintRedirectConfigurations.GetIstance().ServicesCount)
         {
             throw;
         }
         lastWs = svc.Endpoint.ListenUri.ToString();
         ret   += 1;
         return(Convert(blob, fileExtension, extReq, converterType));
     }
 }
 public bool IsAlive(string fileExtension, ConverterType converterType)
 {
     ConverterServiceSvc.StampaConformeConverterClient svc = null;
     try
     {
         svc = new ConverterServiceSvc.StampaConformeConverterClient("StampaConformeConverter", PrintRedirectConfigurations.GetWsUrl(converterType, lastWs));
         logger.InfoFormat("Call External WS: {0}", svc.Endpoint.ListenUri.ToString());
         return(svc.IsAlive());
     }
     catch (Exception ex)
     {
         logger.Error(ex);
         throw;
     }
 }