Example #1
0
        /// <summary>
        /// Creates the injector class.
        /// </summary>
        /// <param name="typeInformationManager">The type information manager</param>
        /// <param name="objectCreationManager">The object creation manager</param>
        /// <param name="singletonCache">The cache for singletons</param>
        /// <param name="scannedTypeManager">The scanned type manager</param>
        protected internal Injector(TypeInformationManager typeInformationManager, FactoryManager objectCreationManager, SingletonCache singletonCache, ScannedTypeManager scannedTypeManager)
        {
            if (typeInformationManager == null)
            {
                throw new ArgumentNullException(nameof(typeInformationManager));
            }
            if (objectCreationManager == null)
            {
                throw new ArgumentNullException(nameof(objectCreationManager));
            }
            if (singletonCache == null)
            {
                throw new ArgumentNullException(nameof(singletonCache));
            }
            if (scannedTypeManager == null)
            {
                throw new ArgumentNullException(nameof(scannedTypeManager));
            }

            registrations = new ConcurrentDictionary <Type, Dictionary <string, ContainerRegistration> >();
            registered    = new List <EventHandler <RegistrationEventArgs> >();
            resolved      = new List <EventHandler <ResolutionEventArgs> >();

            this.lifetimeOnDiscovery = LifetimeOnDiscovery.Transcient;

            this.typeInformationManager = typeInformationManager;
            this.objectCreationManager  = objectCreationManager;
            this.singletonCache         = singletonCache;
            this.scannedTypeManager     = scannedTypeManager;
            this.autoDiscovery          = true;
        }
        public async Task AcquireWithSameKeyOnManyDifferentThreadsReturnsSameValue()
        {
            int count = 0;

            var cache = new SingletonCache <string, object>();

            int maxConcurrency = Environment.ProcessorCount + 1;

            Task[] tasks = new Task[maxConcurrency];
            for (int concurrency = 0; concurrency < maxConcurrency; concurrency++)
            {
                tasks[concurrency] = Task.Run(() =>
                {
                    for (int i = 0; i < 100000; i++)
                    {
                        using (var lifetime = cache.Acquire("Foo"))
                        {
                            lock (lifetime.Value)
                            {
                                int result = Interlocked.Increment(ref count);
                                result.Should().Be(1);
                                Interlocked.Decrement(ref count);
                            }
                        }
                    }
                });
            }

            await Task.WhenAll(tasks);
        }
        private void SignInAsync(LoginModel user, bool isPersistent)
        {
            AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
            using (var conn = new TimchurDatabaseEntities())
            {
                Users  User = conn.Users.Where(s => (s.IDCardNumber).ToString() == user.Username).FirstOrDefault <Users>();
                string role = "User";
                if (User.Roles.ID == 1)
                {
                    role = "User";
                }
                else
                {
                    role = "Admin";
                }
                var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, User.IDCardNumber), new Claim(ClaimTypes.GivenName, User.FullName), new Claim(ClaimTypes.Role, role) }, "ApplicationCookie");
                SingletonCache.Instance().last_msg[User.IDCardNumber] = null;


                AuthenticationManager.SignIn(
                    new AuthenticationProperties()
                {
                    IsPersistent = isPersistent
                }, identity);
            }
            //צריך להוסיף להוציא שם מהמסד
        }
Example #4
0
        public object GetService(Type serviceType, string name)
        {
            if (disposedValue)
            {
                throw new ObjectDisposedException("Has been disposed.");
            }
            var defintion = Defintions.TryGet(serviceType, name);

            if (defintion != null)
            {
                switch (defintion.Lifetime)
                {
                case Lifetime.Singleton:
                    return(SingletonCache.GetOrAdd(defintion, d => d.ImplementationFactory(Root)));

                case Lifetime.Scoped:
                    return(scopedCache.GetOrAdd(defintion, d => d.ImplementationFactory(this)));

                case Lifetime.Transient:
                    return(defintion.ImplementationFactory(this));

                default:
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Example #5
0
        public void UnregisterInstance()
        {
            var t        = new TypeInformationManager();
            var o        = new FactoryManager();
            var c        = new SingletonCache();
            var injector = Activator.CreateInstance(typeof(Injector),
                                                    BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new object[] { t, o, c, new ScannedTypeManager() }, null)
                           as Injector;

            var item2 = new Item {
                myString = "with k1"
            };

            injector.RegisterType(typeof(Item));
            injector.RegisterInstance(typeof(Item), "k1", item2);

            Assert.IsTrue(injector.IsRegistered <Item>());
            Assert.IsTrue(injector.IsRegistered <Item>("k1"));

            Assert.IsTrue(injector.Unregister <Item>());

            Assert.IsFalse(injector.IsRegistered <Item>());
            Assert.IsTrue(injector.IsRegistered <Item>("k1"));

            Assert.IsTrue(injector.Unregister <Item>("k1"));
            Assert.IsFalse(injector.IsRegistered <Item>("k1"));
        }
Example #6
0
        public void AddAuctionOperation()
        {
            int?id = -1;

            Cache.gen_lock.WaitOne();
            try
            {
                using (TimchurDatabaseEntities entity = new TimchurDatabaseEntities())
                {
                    entity.Auctions.Add(((Auctions)SingletonCache.Instance().Storage[Context.User.Identity.Name]));
                    entity.SaveChanges();
                }
                using (TimchurDatabaseEntities entity2 = new TimchurDatabaseEntities())
                {
                    string strm = ((Auctions)(SingletonCache.Instance().Storage[Context.User.Identity.Name])).AuctionNumber;
                    id = entity2.Auctions.Where(x => x.AuctionNumber == strm).First().ID;
                }
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה,מכרז נוסף למערכת";
            }
            catch (Exception e)
            {
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה,הוספת מכרז נכשלה";
            }
            Cache.gen_lock.ReleaseMutex();
            string str = Context.User.Identity.Name;
            string msg = "";

            if (SingletonCache.Instance().last_msg.Keys.Contains(str))
            {
                msg = SingletonCache.Instance().last_msg[str];
            }
            string to_s = string.Format("סטאטוס:" + msg);

            Clients.Caller.sendMessage(id.Value.ToString());
        }
        public SingletonCache_Tests()
        {
            _singletonCache = new SingletonCache();

            _singletonCache.Add("TestKey1", "TestValue1");
            _singletonCache.Add("TestKey2", "TestValue2");
        }
        /// <summary>
        /// Saves the stored update of a unit into the database,
        /// and sends a cache message of the operation's completion status.
        /// </summary>
        public void editUnitOperation()
        {
            int?id = -1;

            Cache.gen_lock.WaitOne();
            UnitFModel mf = null;

            if (SingletonCache.Instance().Storage.ContainsKey(Context.User.Identity.Name))
            {
                mf = ((UnitFModel)SingletonCache.Instance().Storage[Context.User.Identity.Name]);
            }
            try
            {
                using (TimchurDatabaseEntities entity = new TimchurDatabaseEntities())
                {
                    var original = entity.Units.Find(mf.unit.ID);


                    if (original != null)
                    {
                        entity.UnitsAuctions.RemoveRange(entity.UnitsAuctions.Where(x => x.UnitID == mf.unit.ID));
                        if (mf.Limitations != null)
                        {
                            foreach (int i in mf.Limitations)
                            {
                                UnitsAuctions ua = new UnitsAuctions();
                                ua.AuctionID = i;
                                ua.UnitID    = mf.unit.ID;
                                entity.UnitsAuctions.Add(ua);
                            }
                        }
                        entity.Entry(original).CurrentValues.SetValues(((UnitFModel)SingletonCache.Instance().Storage[Context.User.Identity.Name]).unit);
                        entity.SaveChanges();
                    }
                }
                using (TimchurDatabaseEntities entity2 = new TimchurDatabaseEntities())
                {
                    int strm = mf.unit.ID;
                    id = entity2.Units.Where(x => x.ID == strm).First().ID;
                }
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, יחידה עודכה במערכת";
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.Write(e.ToString());
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, עדכון יחידה נכשל במערכת";
            }
            SingletonCache.Instance().Storage[Context.User.Identity.Name] = null;
            Cache.gen_lock.ReleaseMutex();
            string str = Context.User.Identity.Name;
            string msg = "";

            if (SingletonCache.Instance().last_msg.Keys.Contains(str))
            {
                msg = SingletonCache.Instance().last_msg[str];
            }
            string to_s = string.Format("סטאטוס:" + msg);

            Clients.Caller.sendMessage(id.Value.ToString());
        }
        private void updateStatistics()
        {
            SingletonCache singleton = SingletonCache.Instance;

            if (singleton.indMasAptoGen.diferencia < singleton.indMasAptoHist.diferencia)
            {
                singleton.indMasAptoHist = singleton.indMasAptoGen;
            }
            if (singleton.indMenosAptoGen.diferencia > singleton.indMenosAptoHist.diferencia)
            {
                singleton.indMenosAptoHist = singleton.indMenosAptoGen;
            }
            imagenGenerada.Image = SingletonCache.Instance.poblacion[0].image;
            // update current gen stats
            lblGenNumber.Text   = "Generación #" + singleton.numGeneracion;
            indMasAptoGen.Text  = "Individuo más apto: " + (100.00 - singleton.poblacion[0].diferencia).ToString("0.000");
            indPromedioGen.Text = "Individuo promedio: " + (100.00 - singleton.indPromedioAptoGen).ToString("0.000");
            indMenosGen.Text    = "Individuo menos apto: " + (100.00 - singleton.poblacion[SingletonCache.Instance.tamPoblacion - 1].diferencia).ToString("0.000");

            // update historic stats
            indMasHistor.Text      = "Individuo más apto: " + (100.00 - singleton.indMasAptoHist.diferencia).ToString("0.000");
            indPromedioHistor.Text = "Individuo promedio: " + (100.00 - singleton.indPromedioAptoHist).ToString("0.000");
            indMenosHistor.Text    = "Individuo menos apto: " + (100.00 - singleton.indMenosAptoHist.diferencia).ToString("0.000");
            Application.DoEvents();
        }
Example #10
0
 public void SendNotification()
 {
     if (SingletonCache.Instance().last_msg[Context.User.Identity.Name] != null)
     {
         string message = (string)(SingletonCache.Instance().last_msg[Context.User.Identity.Name].Clone());
         SingletonCache.Instance().last_msg[Context.User.Identity.Name] = null;
         Clients.Caller.broadcastNotification(message);
     }
 }
        public void AcquireWithSameKeyReturnsSameLifetime()
        {
            var cache = new SingletonCache <string, object>();

            var lifetime1 = cache.Acquire("Foo");
            var lifetime2 = cache.Acquire("Foo");

            lifetime1.Value.Should().BeSameAs(lifetime2.Value);
            lifetime1.Dispose();
            lifetime2.Dispose();
        }
        public void WhenValueIsDisposableItIsDisposedWhenReleased()
        {
            var cache = new SingletonCache <string, DisposeTest>();

            using (var lifetime = cache.Acquire("Foo"))
            {
                DisposeTest.WasDisposed.Should().BeFalse();
            }

            DisposeTest.WasDisposed.Should().BeTrue();
        }
        public void AcquireWithSameKeyUsingCustomComparerReturnsSameLifetime()
        {
            var cache = new SingletonCache <string, object>(1, 3, StringComparer.OrdinalIgnoreCase);

            var lifetime1 = cache.Acquire("foo");
            var lifetime2 = cache.Acquire("FOO");

            lifetime1.Value.Should().BeSameAs(lifetime2.Value);
            lifetime1.Dispose();
            lifetime2.Dispose();
        }
        public static object GetOrThrowException(this SingletonCache singletonCache, string key)
        {
            var value = singletonCache.GetOrNull(key);

            if (value == null)
            {
                throw new ApplicationException("Given key was not present in the cache: " + key);
            }

            return(value);
        }
        public static void primeraGeneracion(int pixel)
        {
            SingletonCache singleton = SingletonCache.Instance;

            Utils.generarImagenAleatoria(singleton.tamPoblacion, pixel);
            SingletonCache.calcularDiferencias();
            singleton.indMasAptoGen      = singleton.poblacion[0];
            singleton.indPromedioAptoGen = SingletonCache.getDiferenciaPromedio();
            singleton.indMenosAptoGen    = singleton.poblacion[SingletonCache.Instance.tamPoblacion - 1];
            singleton.numGeneracion      = 1;
        }
Example #16
0
 public ActionResult EditAuction(Auctions auc)
 {
     if (ModelState.IsValid)
     {
         SingletonCache.Instance().Storage[User.Identity.Name] = auc;
         return(RedirectToAction("EAuctionLoadingScreen", "Main"));
     }
     else
     {
         return(View(auc));
     }
 }
 public void Configuration(IAppBuilder app)
 {
     app.UseCookieAuthentication(new CookieAuthenticationOptions
     {
         AuthenticationType = "ApplicationCookie",
         LoginPath          = new PathString("/Login/Index"),
         ExpireTimeSpan     = TimeSpan.FromMinutes(3)
     });
     SingletonCache.Instance();
     // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
     app.MapSignalR();
 }
Example #18
0
 public ActionResult EditClusetr(Clusetrs clu)
 {
     if (ModelState.IsValid)
     {
         SingletonCache.Instance().Storage[User.Identity.Name] = clu;
         return(RedirectToAction("EClusetrLoadingScreen", "Main"));
     }
     else
     {
         return(View(clu));
     }
 }
Example #19
0
 public ActionResult EditUnit(UnitFModel uni)
 {
     if (ModelState.IsValid)
     {
         SingletonCache.Instance().Storage[User.Identity.Name] = uni;
         return(RedirectToAction("EUnitLoadingScreen", "Main"));
     }
     else
     {
         return(View(uni));
     }
 }
Example #20
0
 public ActionResult EditUser(Users use)
 {
     if (ModelState.IsValid)
     {
         SingletonCache.Instance().Storage[User.Identity.Name] = use;
         return(RedirectToAction("EUserLoadingScreen", "Main"));
     }
     else
     {
         return(View(use));
     }
 }
Example #21
0
 public ActionResult EditSupplier(SupplierFModel sup)
 {
     if (ModelState.IsValid)
     {
         SingletonCache.Instance().Storage[User.Identity.Name] = sup;
         return(RedirectToAction("ESupplierLoadingScreen", "Main"));
     }
     else
     {
         return(View(sup));
     }
 }
        /// <summary>
        /// Saves the stored creation of a unit into the database,
        /// and sends a cache message of the operation's completion status.
        /// </summary>
        public void AddUnitOperation()
        {
            int?id = -1;

            Cache.gen_lock.WaitOne();
            UnitFModel mf = ((UnitFModel)SingletonCache.Instance().Storage[Context.User.Identity.Name]);

            try
            {
                using (TimchurDatabaseEntities entity = new TimchurDatabaseEntities())
                {
                    entity.Units.Add(mf.unit);
                    entity.SaveChanges();
                }
                using (TimchurDatabaseEntities entity2 = new TimchurDatabaseEntities())
                {
                    string strm = mf.unit.Name;
                    id = entity2.Units.Where(x => x.Name == strm).First().ID;
                    if (mf.Limitations != null)
                    {
                        foreach (int i in mf.Limitations)
                        {
                            UnitsAuctions ua = new UnitsAuctions();
                            ua.AuctionID = i;
                            ua.UnitID    = id;
                            entity2.UnitsAuctions.Add(ua);
                        }
                    }
                    entity2.SaveChanges();
                }
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, יחידה נוספה למערכת";
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.Write(e.ToString());
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, הוספת יחידה נכשלה";
            }
            SingletonCache.Instance().Storage[Context.User.Identity.Name] = null;
            Cache.gen_lock.ReleaseMutex();
            string str = Context.User.Identity.Name;
            string msg = "";

            if (SingletonCache.Instance().last_msg.Keys.Contains(str))
            {
                msg = SingletonCache.Instance().last_msg[str];
            }
            string to_s = string.Format("סטאטוס:" + msg);

            Clients.Caller.sendMessage(id.Value.ToString());
        }
        public void AcquireReleaseAcquireReturnsDifferentValue()
        {
            var cache = new SingletonCache <string, object>();

            var lifetime1 = cache.Acquire("Foo");

            lifetime1.Dispose();

            var lifetime2 = cache.Acquire("Foo");

            lifetime2.Dispose();

            lifetime1.Value.Should().NotBeSameAs(lifetime2.Value);
        }
        /// <summary>
        /// Saves the stored update of an auction into the database,
        /// and sends a cache message of the operation's completion status.
        /// </summary>
        public void EditAuctionOperation()
        {
            int?id = -1;

            Cache.gen_lock.WaitOne();
            try
            {
                using (TimchurDatabaseEntities entity = new TimchurDatabaseEntities())
                {
                    var original = entity.Auctions.Find(((Auctions)SingletonCache.Instance().Storage[Context.User.Identity.Name]).ID);

                    if (original != null)
                    {
                        Auctions curr = ((Auctions)SingletonCache.Instance().Storage[Context.User.Identity.Name]);

                        entity.Entry(original).CurrentValues.SetValues(((Auctions)SingletonCache.Instance().Storage[Context.User.Identity.Name]));
                        entity.SaveChanges();
                    }

                    entity.SaveChanges();
                }
                using (TimchurDatabaseEntities entity2 = new TimchurDatabaseEntities())
                {
                    string strm = ((Auctions)(SingletonCache.Instance().Storage[Context.User.Identity.Name])).AuctionNumber;
                    id = entity2.Auctions.Where(x => x.AuctionNumber == strm).First().ID;
                }
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, מכרז עודכן במערכת";
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.Write(e.ToString());
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, עדכון מכרז נכשל";
            }
            SingletonCache.Instance().Storage[Context.User.Identity.Name] = null;
            Cache.gen_lock.ReleaseMutex();
            string str = Context.User.Identity.Name;
            string msg = "";

            if (SingletonCache.Instance().last_msg.Keys.Contains(str))
            {
                msg = SingletonCache.Instance().last_msg[str];
            }
            string to_s = string.Format("סטאטוס:" + msg);

            Clients.Caller.sendMessage(id.Value.ToString());
        }
Example #25
0
        public void calcularDiferencia(Imagen objetivo)
        {
            SingletonCache singleton = SingletonCache.Instance;

            if (singleton.histColorChecked && singleton.histFormaChecked)
            {
                if (singleton.DistGChecked)
                {
                    diferencia  = histColor.distanciaO(objetivo);
                    diferencia += histForma.distanciaO(objetivo) * 2;

                    diferencia /= 3;
                }
                if (singleton.DistManChecked)
                {
                    diferencia  = histColor.distanciaManhattan(objetivo);
                    diferencia += histForma.distanciaManhattan(objetivo) * 2;

                    diferencia /= 3;
                }
            }
            else if (singleton.histColorChecked)
            {
                if (singleton.DistGChecked)
                {
                    diferencia = histColor.distanciaO(objetivo);
                }
                if (singleton.DistManChecked)
                {
                    diferencia = histColor.distanciaManhattan(objetivo);
                }
            }
            else
            {
                if (singleton.DistGChecked)
                {
                    diferencia = histForma.distanciaO(objetivo);
                }
                if (singleton.DistManChecked)
                {
                    diferencia = histForma.distanciaManhattan(objetivo);
                }
            }
        }
Example #26
0
        public void EditClusetrOperation()
        {
            int?id = -1;

            Cache.gen_lock.WaitOne();
            try
            {
                using (TimchurDatabaseEntities entity = new TimchurDatabaseEntities())
                {
                    var original = entity.Clusetrs.Find(((Clusetrs)SingletonCache.Instance().Storage[Context.User.Identity.Name]).ID);

                    if (original != null)
                    {
                        entity.Entry(original).CurrentValues.SetValues(((Clusetrs)SingletonCache.Instance().Storage[Context.User.Identity.Name]));
                        entity.SaveChanges();
                    }

                    entity.SaveChanges();
                }
                using (TimchurDatabaseEntities entity2 = new TimchurDatabaseEntities())
                {
                    byte strm = ((Clusetrs)(SingletonCache.Instance().Storage[Context.User.Identity.Name])).DisplayNumber.Value;
                    id = entity2.Clusetrs.Where(x => x.DisplayNumber == strm).First().ID;
                }
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה,סל עודכן במערכת";
            }
            catch (Exception e)
            {
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה,עדכון סל נכשל";
            }
            Cache.gen_lock.ReleaseMutex();
            string str = Context.User.Identity.Name;
            string msg = "";

            if (SingletonCache.Instance().last_msg.Keys.Contains(str))
            {
                msg = SingletonCache.Instance().last_msg[str];
            }
            string to_s = string.Format("סטאטוס:" + msg);

            Clients.Caller.sendMessage(id.Value.ToString());
        }
        protected override bool AuthorizeCore(HttpContextBase context)
        {
            var isAuthorized = base.AuthorizeCore(context);

            if (!isAuthorized)
            {
                return(false);
            }
            var claimsIdentity = context.User.Identity as System.Security.Claims.ClaimsIdentity;
            var name           = claimsIdentity.FindFirst(System.Security.Claims.ClaimTypes.Name);

            string[] prem_list = SingletonCache.Instance().role_map[Name].Split(',');
            string   role      = claimsIdentity.FindFirst(System.Security.Claims.ClaimTypes.Role).Value;

            //redirection to error page in this case
            if (!prem_list.Contains(role))
            {
                return(false);
            }
            return(true);
        }
Example #28
0
        public void UnregisterType()
        {
            var t = new TypeInformationManager();
            var o = new FactoryManager();
            var c = new SingletonCache();

            var injector = Activator.CreateInstance(typeof(Injector),
                                                    BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new object[] { t, o, c, new ScannedTypeManager() }, null)
                           as Injector;

            injector.RegisterSingleton <Item>();

            Assert.IsTrue(injector.IsRegistered <Item>());

            var instance = injector.GetInstance <Item>();

            Assert.IsTrue(c.Cache.ContainsKey(typeof(Item)));

            Assert.IsTrue(injector.Unregister <Item>());

            Assert.IsFalse(injector.IsRegistered <Item>());
            Assert.IsFalse(c.Cache.ContainsKey(typeof(Item)));
        }
        public void AcquireWithSameKeyMaintainsReferenceCount()
        {
            var cache = new SingletonCache <string, object>();

            using (var lifetime1 = cache.Acquire("Foo"))
            {
                using (var lifetime2 = cache.Acquire("Foo"))
                {
                    lifetime1.ReferenceCount.Should().Be(1);
                    lifetime2.ReferenceCount.Should().Be(2);
                }

                using (var lifetime3 = cache.Acquire("Foo"))
                {
                    lifetime3.ReferenceCount.Should().Be(2);
                }
            }

            using (var lifetime4 = cache.Acquire("Foo"))
            {
                lifetime4.ReferenceCount.Should().Be(1);
            }
        }
        /// <summary>
        /// Saves the stored creation of a cluster into the database,
        /// and sends a cache message of the operation's completion status.
        /// </summary>
        public void AddClusterOperation()
        {
            int?id = -1;

            Cache.gen_lock.WaitOne();
            try
            {
                using (TimchurDatabaseEntities entity = new TimchurDatabaseEntities())
                {
                    entity.Clusters.Add(((Clusters)SingletonCache.Instance().Storage[Context.User.Identity.Name]));
                    entity.SaveChanges();
                }
                using (TimchurDatabaseEntities entity2 = new TimchurDatabaseEntities())
                {
                    byte strm = ((Clusters)(SingletonCache.Instance().Storage[Context.User.Identity.Name])).DisplayNumber.Value;
                    id = entity2.Clusters.Where(x => x.DisplayNumber == strm).First().ID;
                }
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, סל נוסף למערכת";
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.Write(e.ToString());
                SingletonCache.Instance().last_msg[Context.User.Identity.Name] = "בפעולה האחרונה, הוספת סל נכשלה";
            }
            SingletonCache.Instance().Storage[Context.User.Identity.Name] = null;
            Cache.gen_lock.ReleaseMutex();
            string str = Context.User.Identity.Name;
            string msg = "";

            if (SingletonCache.Instance().last_msg.Keys.Contains(str))
            {
                msg = SingletonCache.Instance().last_msg[str];
            }
            string to_s = string.Format("סטאטוס:" + msg);

            Clients.Caller.sendMessage(id.Value.ToString());
        }