En iyi yanıtlayıcılar
ASP .NET Bildirim özelliği nasıl yapılır - Yardım

Soru
-
Arkadaşlar ben sorucevap uygulaması yapıyorum birisi soruyo birisi cevaplıyo onun gibi ama bunda bide bildirim özelliği istiyorum bildirim kısmının veritabanındaki tablosu nasıl olmalıdır. örn: Ahmet, sorunu cevapladı. Mehmet, yanıtını beğendi, İbrahim, duvarına bir mesaj yazdı. Gibisinden entity framework ile çalışıyorum bir mantığı varsa lütfen söyleyin.
Yanıtlar
-
Proje içine bir backgrounworker atarak her 5 dk da bir çalışmasını sağlayarak devamlı surette canlı olarak kontrol sağlayabilen bir sistem yazabilirsiniz.
Background workünüzü bir class olarak yazıp onu global.asax içerisinden tektiklerseniz sorunsuz çalışacaktır.
BW ile ilgili döküman : http://msdn.microsoft.com/en-us/library/cc221403(v=vs.95).aspx
Örnek Class
public class Demo { private SecurityCallContext m_Context; private static Thread m_BackgroundWorker = null; private static object m_Lock = new object(); public static bool IsStarted; public static ArrayList errors = new ArrayList(); public void Start() { try { Monitor.Enter(m_Lock); if (m_BackgroundWorker == null) { m_Context = SecurityCallContext.GetCurrent; ThreadStart start = new ThreadStart(BackgroundProcessing); m_BackgroundWorker = new Thread(start); m_BackgroundWorker.Start(); IsStarted = true; } } catch (Exception ex) { } finally { Monitor.Exit(m_Lock); } } public void Stop() { try { Monitor.Enter(m_Lock); if (m_BackgroundWorker != null) { m_BackgroundWorker.Abort(); m_BackgroundWorker = null; IsStarted = false; } } catch (ThreadAbortException ex) { } catch (Exception ex) { } finally { Monitor.Exit(m_Lock); } } private void BackgroundProcessing() { while (true) { try { Monitor.Enter(m_Lock); if (m_Context != null) { SecurityCallContext.Copy(m_Context); } errors.Clear(); try { } catch (Exception ex) { } } //} //} catch (Exception ex) { if (ex is ThreadAbortException) { throw ex; } } finally { // company.Revert(); } // reminder = null; } catch (ThreadAbortException ex) { } catch (Exception ex) { } finally { Monitor.Exit(m_Lock); } try { Thread.Sleep(1000 * 60 * 1); } catch (Exception ex) { } } } }
Globalde Kullanımı
if (!Demo.Started)
{
new Demo().Start();
}gibi kullanabilirsiniz.
- Yanıt Olarak İşaretleyen Serkan Canseven 8 Ekim 2014 Çarşamba 12:25
Tüm Yanıtlar
-
Ahmet'in son login/logout zamanını kaydedersin. Bu zamandan sonra yapılan kayıtlar bildirim yapılacak kayıtlardır.
www.mvcblog.org
e-mail: onay[nokta]yalciner[at]hotmail[nokta]com
-
Proje içine bir backgrounworker atarak her 5 dk da bir çalışmasını sağlayarak devamlı surette canlı olarak kontrol sağlayabilen bir sistem yazabilirsiniz.
Background workünüzü bir class olarak yazıp onu global.asax içerisinden tektiklerseniz sorunsuz çalışacaktır.
BW ile ilgili döküman : http://msdn.microsoft.com/en-us/library/cc221403(v=vs.95).aspx
Örnek Class
public class Demo { private SecurityCallContext m_Context; private static Thread m_BackgroundWorker = null; private static object m_Lock = new object(); public static bool IsStarted; public static ArrayList errors = new ArrayList(); public void Start() { try { Monitor.Enter(m_Lock); if (m_BackgroundWorker == null) { m_Context = SecurityCallContext.GetCurrent; ThreadStart start = new ThreadStart(BackgroundProcessing); m_BackgroundWorker = new Thread(start); m_BackgroundWorker.Start(); IsStarted = true; } } catch (Exception ex) { } finally { Monitor.Exit(m_Lock); } } public void Stop() { try { Monitor.Enter(m_Lock); if (m_BackgroundWorker != null) { m_BackgroundWorker.Abort(); m_BackgroundWorker = null; IsStarted = false; } } catch (ThreadAbortException ex) { } catch (Exception ex) { } finally { Monitor.Exit(m_Lock); } } private void BackgroundProcessing() { while (true) { try { Monitor.Enter(m_Lock); if (m_Context != null) { SecurityCallContext.Copy(m_Context); } errors.Clear(); try { } catch (Exception ex) { } } //} //} catch (Exception ex) { if (ex is ThreadAbortException) { throw ex; } } finally { // company.Revert(); } // reminder = null; } catch (ThreadAbortException ex) { } catch (Exception ex) { } finally { Monitor.Exit(m_Lock); } try { Thread.Sleep(1000 * 60 * 1); } catch (Exception ex) { } } } }
Globalde Kullanımı
if (!Demo.Started)
{
new Demo().Start();
}gibi kullanabilirsiniz.
- Yanıt Olarak İşaretleyen Serkan Canseven 8 Ekim 2014 Çarşamba 12:25