예제 #1
0
 public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (!string.IsNullOrEmpty("" + value) && Configurazione.UserConfigLumen.compNumFoto)
     {
         return(CompNumFoto.getLongValue("" + value));
     }
     return(value);
 }
예제 #2
0
        public void CompNumFotoTest1()
        {
            string enc = CompNumFoto.getStringValue(36);
            long   dec = CompNumFoto.getLongValue(enc);

            Assert.IsTrue(36 == dec);
            Console.WriteLine("From {0}, to {1}, to {2}", 36, enc, dec);
        }
예제 #3
0
 public void CompNumFotoTest2()
 {
     for (long i = 0; i < 400000; ++i)
     {
         string enc = CompNumFoto.getStringValue(i);
         long   dec = CompNumFoto.getLongValue(enc);
         Assert.IsTrue(i == dec);
         Console.WriteLine("From {0}, to {1}, to {2}", i, enc, dec);
     }
 }
예제 #4
0
        private string generaUnIdCorto()
        {
            string idCorto = null;
            bool   esiste;
            int    tentativi = 0;

            do
            {
                idCorto = CompNumFoto.getRandomString(4);

                // Verifico se esiste già
                esiste = UnitOfWorkScope.currentDbContext.Carrelli.Any(c => c.idCortoSelfService == idCorto);
                ++tentativi;
            } while(esiste);

            _giornale.Debug(String.Format("Generato idCorto carrello {0} in {1} tentativi", idCorto, tentativi));
            return(idCorto);
        }
예제 #5
0
        public static int[] rangeToString(string value)
        {
            List <int> range = new List <int>();

            try
            {
                if (Configurazione.UserConfigLumen.compNumFoto)
                {
                    if (value.Contains('-'))
                    {
                        IEnumerable <int> v = ((string)value).Split('-').Select(nn => CompNumFoto.getIntValue(nn));
                        return(v.ToArray <int>());
                    }
                    else
                    {
                        IEnumerable <int> v = ((string)value).Split(',').Select(nn => CompNumFoto.getIntValue(nn));
                        return(v.ToArray <int>());
                    }
                }
                else
                {
                    if (value.Contains('-'))
                    {
                        return(value.Split('-').Select(nn => (nn.Equals("") ? 0 : Convert.ToInt32(nn))).ToArray());
                    }
                    else
                    {
                        return(value.Split(',').Select(nn => (nn == null ? 0 : Convert.ToInt32(nn))).ToArray());
                    }
                }
            }
            catch (Exception ee)
            {
                throw new ArgumentOutOfRangeException("Intervallo numerico non valido", ee);
            }
        }