public static void RemoveAllCache()
		{
			if (AccreditSection.GetConfig().AccreditSettings.ClearLocalCache)
			{
				if (false == File.Exists(InnerCacheHelper.cacheDependenceFile))
				{
					File.Create(InnerCacheHelper.cacheDependenceFile);
				}

				using (StreamWriter writer = new StreamWriter(InnerCacheHelper.cacheDependenceFile, true))
				{
					writer.WriteLine(Guid.NewGuid().ToString());
					writer.Flush();
				}
			}

			if (AccreditSection.GetConfig().AccreditSettings.ClearRemoteCache)
			{
				string[] cacheQueueType = {	"MCS.Library.OGUPermission.OguObjectIDCache, MCS.Library.OGUPermission", 
										  "MCS.Library.OGUPermission.OguObjectFullPathCache, MCS.Library.OGUPermission", 
										  "MCS.Library.OGUPermission.OguObjectLogOnNameCache, MCS.Library.OGUPermission" };

				CacheNotifyData[] data = new CacheNotifyData[cacheQueueType.Length];

				for (int i = 0; i < cacheQueueType.Length; i++)
				{
					data[i] = new CacheNotifyData();
					data[i].CacheQueueTypeDesp = cacheQueueType[i];
					data[i].NotifyType = CacheNotifyType.Clear;
				}

				UdpCacheNotifier.Instance.SendNotifyAsync(data);
                MmfCacheNotifier.Instance.SendNotify(data);
			}
		}
Exemple #2
0
        private static long InnerReadCacheNotifyData(long lastTicks, MemoryMappedViewAccessor accessor, CacheNotifyDataMapInfo mapInfo, List <CacheNotifyData> result)
        {
            int  itemSize    = Marshal.SizeOf(typeof(CacheNotifyDataMapItem));
            long returnTicks = lastTicks;

            long startPointer = Marshal.SizeOf(typeof(CacheNotifyDataMapInfo));

            for (int i = 0; i < CacheNotifyDataMapInfo.CacheDataItemCount; i++)
            {
                CacheNotifyDataMapItem item;

                accessor.Read(startPointer, out item);

                if (item.Ticks > lastTicks)
                {
                    if (item.Ticks > returnTicks)
                    {
                        returnTicks = item.Ticks;
                    }

                    byte[] data = new byte[item.Size];

                    accessor.ReadArray(startPointer + itemSize, data, 0, (int)item.Size);

                    CacheNotifyData cnd = CacheNotifyData.FromBuffer(data);

                    result.Add(cnd);
                }

                startPointer += itemSize + CacheNotifyDataMapInfo.CacheDataBlockSize;
            }

            return(returnTicks);
        }
 /// <summary>
 /// 将CacheNotifyData写入日志
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="notifyData"></param>
 protected virtual void WriteCacheNotifyDataToLog(Logger logger, CacheNotifyData notifyData)
 {
     if (logger != null)
     {
         logger.Write(CreateLogEntity(notifyData));
     }
 }
Exemple #4
0
        private static void SendOneMessage(string text)
        {
            CacheNotifyData data = new CacheNotifyData(typeof(ObjectCacheQueue), "ClientData", CacheNotifyType.Update);

            data.CacheData = text;

            UdpCacheNotifier.Instance.SendNotify(data);
        }
        public void ClearAll()
        {
            this.ClearAllXml();

            CacheNotifyData notifyData = new CacheNotifyData(typeof(WfProcessDescriptorXmlCache), null, CacheNotifyType.Clear);

            UdpCacheNotifier.Instance.SendNotifyAsync(notifyData);
            MmfCacheNotifier.Instance.SendNotify(notifyData);
        }
		/// <summary>
		/// 创建接收到消息的日志对象
		/// </summary>
		/// <param name="notifyData"></param>
		/// <returns></returns>
		protected override LogEntity CreateLogEntity(CacheNotifyData notifyData)
		{
			LogEntity logEntity = base.CreateLogEntity(notifyData);

			logEntity.EventID = 7004;
			logEntity.Title = "MemoryMappedFile接收Cache通知";

			return logEntity;
		}
		/// <summary>
		/// 创建接收到消息的日志对象
		/// </summary>
		/// <param name="notifyData"></param>
		/// <returns></returns>
		protected override LogEntity CreateLogEntity(CacheNotifyData notifyData)
		{
			LogEntity logEntity = base.CreateLogEntity(notifyData);

			logEntity.EventID = 7002;
			logEntity.Title = "Udp接收Cache通知";

			return logEntity;
		}
Exemple #8
0
        /// <summary>
        /// 创建接收到消息的日志对象
        /// </summary>
        /// <param name="notifyData"></param>
        /// <returns></returns>
        protected override LogEntity CreateLogEntity(CacheNotifyData notifyData)
        {
            LogEntity logEntity = base.CreateLogEntity(notifyData);

            logEntity.EventID = 7004;
            logEntity.Title   = "MemoryMappedFile接收Cache通知";

            return(logEntity);
        }
        /// <summary>
        /// 创建接收到消息的日志对象
        /// </summary>
        /// <param name="notifyData"></param>
        /// <returns></returns>
        protected override LogEntity CreateLogEntity(CacheNotifyData notifyData)
        {
            LogEntity logEntity = base.CreateLogEntity(notifyData);

            logEntity.EventID = 7002;
            logEntity.Title   = "Udp接收Cache通知";

            return(logEntity);
        }
        /// <summary>
        /// 创建Log项
        /// </summary>
        /// <param name="notifyData"></param>
        /// <returns></returns>
        protected virtual LogEntity CreateLogEntity(CacheNotifyData notifyData)
        {
            LogEntity logEntity = new LogEntity(notifyData.ToString());

            logEntity.EventID      = 7002;
            logEntity.LogEventType = TraceEventType.Information;

            logEntity.Source   = GetLogSource();
            logEntity.Title    = "接收Cache";
            logEntity.Priority = LogPriority.Normal;

            return(logEntity);
        }
        /// <summary>
        /// 处理Cache项的改变
        /// </summary>
        /// <param name="data"></param>
        protected void DoCacheChanged(CacheNotifyData data)
        {
            DependencyBase dependency;

            if (data.NotifyType == CacheNotifyType.Clear)
            {
                //清除所有UDP缓存相关的缓存队列
                CacheQueueBase needToClearQueue = null;

                lock (this.CacheItems)
                {
                    foreach (KeyValuePair <CacheNotifyKey, DependencyBase> kp in this.CacheItems)
                    {
                        if (kp.Key.CacheQueueType == data.CacheQueueType)
                        {
                            needToClearQueue = kp.Value.CacheItem.Queue;
                        }
                    }
                }

                if (needToClearQueue != null)
                {
                    needToClearQueue.Clear();
                }
            }
            else
            {
                CacheNotifyKey key = new CacheNotifyKey();

                key.CacheKey       = data.CacheKey;
                key.CacheQueueType = data.CacheQueueType;

                lock (this.CacheItems)
                {
                    if (this.CacheItems.TryGetValue(key, out dependency))
                    {
                        switch (data.NotifyType)
                        {
                        case CacheNotifyType.Invalid:
                            dependency.SetChanged();
                            this.CacheItems.Remove(key);
                            break;

                        case CacheNotifyType.Update:
                            dependency.CacheItem.SetValue(data.CacheData);
                            break;
                        }
                    }
                }
            }
        }
        protected void sendNotify_Click(object sender, EventArgs e)
        {
            if (ObjectCacheQueue.Instance.ContainsKey("UdpTest") == false)
                ObjectCacheQueue.Instance.Add("UdpTest", "尚未初始化", new UdpNotifierCacheDependency());

            string message = string.Format(MessageTemplate, DateTime.Now);

            CacheNotifyData notify = new CacheNotifyData(ObjectCacheQueue.Instance.GetType(), "UdpTest", CacheNotifyType.Update);

            notify.CacheData = message;

            UdpCacheNotifier.Instance.SendNotify(notify);

            sentMessage.InnerText = string.Format("发送内容: {0}", message);
        }
		/// <summary>
		/// 处理Cache项的改变
		/// </summary>
		/// <param name="data"></param>
		protected void DoCacheChanged(CacheNotifyData data)
		{
			DependencyBase dependency;

			if (data.NotifyType == CacheNotifyType.Clear)
			{
				//清除所有UDP缓存相关的缓存队列
				CacheQueueBase needToClearQueue = null;

				lock (this.CacheItems)
				{
					foreach (KeyValuePair<CacheNotifyKey, DependencyBase> kp in this.CacheItems)
					{
						if (kp.Key.CacheQueueType == data.CacheQueueType)
						{
							needToClearQueue = kp.Value.CacheItem.Queue;
						}
					}
				}

				if (needToClearQueue != null)
					needToClearQueue.Clear();
			}
			else
			{
				CacheNotifyKey key = new CacheNotifyKey();

				key.CacheKey = data.CacheKey;
				key.CacheQueueType = data.CacheQueueType;

				lock (this.CacheItems)
				{
					if (this.CacheItems.TryGetValue(key, out dependency))
					{
						switch (data.NotifyType)
						{
							case CacheNotifyType.Invalid:
								dependency.SetChanged();
								this.CacheItems.Remove(key);
								break;
							case CacheNotifyType.Update:
								dependency.CacheItem.SetValue(data.CacheData);
								break;
						}
					}
				}
			}
		}
Exemple #14
0
        private static LogEntity CreateLogEntity(CacheNotifyData notifyData)
        {
            string message = string.Format("{0}",
                                           notifyData.ToString()
                                           );

            LogEntity logEntity = new LogEntity(message);

            logEntity.EventID      = 7005;
            logEntity.LogEventType = TraceEventType.Information;
            logEntity.Source       = "MmfCache";
            logEntity.Title        = "发送MmfCache";
            logEntity.Priority     = LogPriority.Normal;

            return(logEntity);
        }
        private static LogEntity CreateLogEntity(CacheNotifyData notifyData)
        {
            string message = string.Format("{0}",
                    notifyData.ToString()
                );

            LogEntity logEntity = new LogEntity(message);

            logEntity.EventID = 7005;
            logEntity.LogEventType = TraceEventType.Information;
            logEntity.Source = "MmfCache";
            logEntity.Title = "发送MmfCache";
            logEntity.Priority = LogPriority.Normal;

            return logEntity;
        }
Exemple #16
0
        private static LogEntity CreateLogEntity(CacheNotifyData notifyData, UdpCacheNotifierTarget endPoint)
        {
            string message = string.Format("{0}, {1}",
                                           notifyData.ToString(),
                                           endPoint.ToString()
                                           );

            LogEntity logEntity = new LogEntity(message);

            logEntity.EventID      = 7001;
            logEntity.LogEventType = TraceEventType.Information;
            logEntity.Source       = "UdpCache";
            logEntity.Title        = "发送UdpCache";
            logEntity.Priority     = LogPriority.Normal;

            return(logEntity);
        }
Exemple #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="groupName"></param>
        /// <param name="notifyType"></param>
        /// <returns></returns>
        public static CacheNotifyData[] FromSettings(string groupName, CacheNotifyType notifyType)
        {
            IEnumerable <string> queueNames = CacheNotifySettings.GetConfig().GetQueueNamesInGroup(groupName);

            List <CacheNotifyData> data = new List <CacheNotifyData>();

            foreach (string queueName in queueNames)
            {
                CacheNotifyData nd = new CacheNotifyData();
                nd.CacheQueueTypeDesp = queueName;
                nd.NotifyType         = notifyType;

                data.Add(nd);
            }

            return(data.ToArray());
        }
Exemple #18
0
        private static void SendSerializedData(CacheNotifyData[] originalNotifyData, List <byte[]> serializedData, UdpCacheNotifierTargetCollection targets)
        {
            Logger logger = null;

            try
            {
                logger = LoggerFactory.Create("UdpCache");
            }
            catch (SystemSupportException)
            {
            }

            for (int i = 0; i < originalNotifyData.Length; i++)
            {
                byte[]          data       = serializedData[i];
                CacheNotifyData notifyData = originalNotifyData[i];

                foreach (UdpCacheNotifierTarget endPoint in targets)
                {
                    foreach (int port in endPoint.GetPorts())
                    {
                        using (UdpClient udp = new UdpClient())
                        {
                            IPEndPoint remoteEndPoint = new IPEndPoint(endPoint.Address, port);

                            udp.Connect(remoteEndPoint);

                            udp.Send(data, data.Length);
                        }
                    }

                    if (logger != null)
                    {
                        logger.Write(CreateLogEntity(notifyData, endPoint));
                    }
                }

                UdpCacheNotifier.TotalCounters.UdpSentItemsCounter.Increment();
                UdpCacheNotifier.TotalCounters.UdpSentCountPerSecond.Increment();

                UdpCacheNotifier.AppInstanceCounters.UdpSentItemsCounter.Increment();
                UdpCacheNotifier.AppInstanceCounters.UdpSentCountPerSecond.Increment();
            }
        }
		public static void InvalidateAllCache()
		{
			string[] cacheQueueType = {
										"MCS.Library.OGUPermission.OguObjectIDCache, MCS.Library.OGUPermission", 
										"MCS.Library.OGUPermission.OguObjectFullPathCache, MCS.Library.OGUPermission", 
										"MCS.Library.OGUPermission.OguObjectLogOnNameCache, MCS.Library.OGUPermission",
										"PermissionCenter.Extensions.PCServiceMethodCache, PermissionCenterServices"
									  };

			CacheNotifyData[] data = new CacheNotifyData[cacheQueueType.Length];

			for (int i = 0; i < cacheQueueType.Length; i++)
			{
				data[i] = new CacheNotifyData();
				data[i].CacheQueueTypeDesp = cacheQueueType[i];
				data[i].NotifyType = CacheNotifyType.Clear;
			}

			UdpCacheNotifier.Instance.SendNotify(data);
            MmfCacheNotifier.Instance.SendNotify(data);
		}
Exemple #20
0
		static void Main(string[] args)
		{
			Console.Title = "UdpCacheDependency测试客户端";

			Console.WriteLine("Please input cache data...");

			string cmd = Console.ReadLine();

			while (cmd.ToLower() != "exit")
			{
				if (string.IsNullOrEmpty(cmd) == false)
				{
					CacheNotifyData data = new CacheNotifyData(typeof(ObjectCacheQueue), "ClientData", CacheNotifyType.Update);

					data.CacheData = cmd;

					UdpCacheNotifier.Instance.SendNotify(data);
				}

				cmd = Console.ReadLine();
			}
		}
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <returns></returns>
        public override CacheNotifyData[] GetData()
        {
            CacheNotifyData[] result = CacheNotifyData.EmptyData;

            try
            {
                byte[]          recBuffer = udp.Receive(ref bindedEndPoint);
                CacheNotifyData data      = CacheNotifyData.FromBuffer(recBuffer);
                result = new CacheNotifyData[] { data };

                UdpCacheNotifier.TotalCounters.UdpReceivedItemsCounter.Increment();
                UdpCacheNotifier.TotalCounters.UdpReceivedCountPerSecond.Increment();

                UdpCacheNotifier.AppInstanceCounters.UdpReceivedItemsCounter.Increment();
                UdpCacheNotifier.AppInstanceCounters.UdpReceivedCountPerSecond.Increment();

                CacheNotifierSettings settings = CacheNotifierSettings.GetConfig();

                if (settings.ForwardUdpToMmf && settings.EnableMmfNotifier)
                {
                    CacheNotifyDataMap.WriteNotExistCacheNotifyData(DateTime.Now.Ticks, result);

                    UdpCacheNotifier.TotalCounters.ForwardedUdpToMmfItems.Increment();
                    UdpCacheNotifier.TotalCounters.ForwardUdpToMmfCountPerSecond.Increment();

                    UdpCacheNotifier.AppInstanceCounters.ForwardedUdpToMmfItems.Increment();
                    UdpCacheNotifier.AppInstanceCounters.ForwardUdpToMmfCountPerSecond.Increment();
                }
            }
            catch (SocketException ex)
            {
                if (ex.SocketErrorCode != SocketError.TimedOut)
                {
                    throw;
                }
            }

            return(result);
        }
        private void InnerSendNotify(CacheNotifyData[] notifyDataArray)
        {
			if (CacheNotifierSettings.GetConfig().EnableMmfNotifier)
			{
				Logger logger = null;

				try
				{
					logger = LoggerFactory.Create("MmfCache");
				}
				catch (SystemSupportException)
				{
				}

				CacheNotifyDataMap.WriteCacheNotifyData(notifyDataArray);

				if (logger != null)
				{
					foreach (CacheNotifyData notifyData in notifyDataArray)
						logger.Write(CreateLogEntity(notifyData));
				}
			}
        }
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <returns></returns>
        public override CacheNotifyData[] GetData()
        {
            CacheNotifyData[] result = CacheNotifyData.EmptyData;

            try
            {
                byte[] recBuffer = udp.Receive(ref bindedEndPoint);
                CacheNotifyData data = CacheNotifyData.FromBuffer(recBuffer);
                result = new CacheNotifyData[] { data };

                UdpCacheNotifier.TotalCounters.UdpReceivedItemsCounter.Increment();
                UdpCacheNotifier.TotalCounters.UdpReceivedCountPerSecond.Increment();

                UdpCacheNotifier.AppInstanceCounters.UdpReceivedItemsCounter.Increment();
                UdpCacheNotifier.AppInstanceCounters.UdpReceivedCountPerSecond.Increment();

				CacheNotifierSettings settings = CacheNotifierSettings.GetConfig();

				if (settings.ForwardUdpToMmf && settings.EnableMmfNotifier)
                {
                    CacheNotifyDataMap.WriteNotExistCacheNotifyData(DateTime.Now.Ticks, result);

                    UdpCacheNotifier.TotalCounters.ForwardedUdpToMmfItems.Increment();
                    UdpCacheNotifier.TotalCounters.ForwardUdpToMmfCountPerSecond.Increment();

                    UdpCacheNotifier.AppInstanceCounters.ForwardedUdpToMmfItems.Increment();
                    UdpCacheNotifier.AppInstanceCounters.ForwardUdpToMmfCountPerSecond.Increment();
                }
            }
            catch (SocketException ex)
            {
                if (ex.SocketErrorCode != SocketError.TimedOut)
                    throw;
            }

            return result;
        }
 private static void AssertCacheNotifyData(CacheNotifyData original, CacheNotifyData target)
 {
     Assert.AreEqual(original.CacheQueueTypeDesp, target.CacheQueueTypeDesp);
     Assert.AreEqual(original.CacheKey, target.CacheKey);
     Assert.AreEqual(original.NotifyType, target.NotifyType);
 }
Exemple #25
0
        private static void WriteOneCacheNotifyData(MemoryMappedViewAccessor accessor, ref CacheNotifyDataMapInfo mapInfo, CacheNotifyData notifyData, long currentTicks)
        {
            if (mapInfo.Pointer >= CacheNotifyDataMapInfo.CacheDataItemCount)
            {
                mapInfo.Pointer = 0;
            }

            long startPointer = Marshal.SizeOf(typeof(CacheNotifyDataMapInfo)) +
                                mapInfo.Pointer * (Marshal.SizeOf(typeof(CacheNotifyDataMapItem)) + CacheNotifyDataMapInfo.CacheDataBlockSize);

            byte[] data = notifyData.ToBytes();

            CacheNotifyDataMapItem item = new CacheNotifyDataMapItem();

            item.Ticks = currentTicks;
            item.Size  = data.Length;

            accessor.Write(startPointer, ref item);

            long dataPointer = startPointer + Marshal.SizeOf(typeof(CacheNotifyDataMapItem));

            accessor.WriteArray(dataPointer, data, 0, data.Length);

            mapInfo.Pointer++;

            accessor.Write(0, ref mapInfo);

            UdpCacheNotifier.TotalCounters.MmfSentItemsCounter.Increment();
            UdpCacheNotifier.TotalCounters.MmfSentCountPerSecond.Increment();

            UdpCacheNotifier.AppInstanceCounters.MmfSentItemsCounter.Increment();
            UdpCacheNotifier.AppInstanceCounters.MmfSentCountPerSecond.Increment();

            UdpCacheNotifier.TotalCounters.MmfCurrentPointer.RawValue       = mapInfo.Pointer;
            UdpCacheNotifier.AppInstanceCounters.MmfCurrentPointer.RawValue = mapInfo.Pointer;
        }
		private static void WriteOneCacheNotifyData(MemoryMappedViewAccessor accessor, ref CacheNotifyDataMapInfo mapInfo, CacheNotifyData notifyData, long currentTicks)
		{
			if (mapInfo.Pointer >= CacheNotifyDataMapInfo.CacheDataItemCount)
				mapInfo.Pointer = 0;

			long startPointer = Marshal.SizeOf(typeof(CacheNotifyDataMapInfo)) +
				mapInfo.Pointer * (Marshal.SizeOf(typeof(CacheNotifyDataMapItem)) + CacheNotifyDataMapInfo.CacheDataBlockSize);

			byte[] data = notifyData.ToBytes();

			CacheNotifyDataMapItem item = new CacheNotifyDataMapItem();

			item.Ticks = currentTicks;
			item.Size = data.Length;

			accessor.Write(startPointer, ref item);

			long dataPointer = startPointer + Marshal.SizeOf(typeof(CacheNotifyDataMapItem));

			accessor.WriteArray(dataPointer, data, 0, data.Length);

			mapInfo.Pointer++;

			accessor.Write(0, ref mapInfo);

			UdpCacheNotifier.TotalCounters.MmfSentItemsCounter.Increment();
			UdpCacheNotifier.TotalCounters.MmfSentCountPerSecond.Increment();

			UdpCacheNotifier.AppInstanceCounters.MmfSentItemsCounter.Increment();
			UdpCacheNotifier.AppInstanceCounters.MmfSentCountPerSecond.Increment();

			UdpCacheNotifier.TotalCounters.MmfCurrentPointer.RawValue = mapInfo.Pointer;
			UdpCacheNotifier.AppInstanceCounters.MmfCurrentPointer.RawValue = mapInfo.Pointer;
		}
        private static LogEntity CreateLogEntity(CacheNotifyData notifyData, UdpCacheNotifierTarget endPoint)
        {
            string message = string.Format("{0}, {1}",
                    notifyData.ToString(),
                    endPoint.ToString()
                );

            LogEntity logEntity = new LogEntity(message);

            logEntity.EventID = 7001;
            logEntity.LogEventType = TraceEventType.Information;
            logEntity.Source = "UdpCache";
            logEntity.Title = "发送UdpCache";
            logEntity.Priority = LogPriority.Normal;

            return logEntity;
        }
        private static List<byte[]> GetSerializedCacheData(CacheNotifyData[] notifyDataArray)
        {
            ExceptionHelper.FalseThrow<ArgumentNullException>(notifyDataArray != null, "notifyDataArray");

            UdpCacheNotifierSettings settings = UdpCacheNotifierSettings.GetConfig();

            List<byte[]> dataList = new List<byte[]>();

            foreach (CacheNotifyData notifyData in notifyDataArray)
            {
                byte[] data = notifyData.ToBytes();

                ExceptionHelper.FalseThrow(data.Length <= settings.PackageSize,
                    "Cache Key{0}的通知数据包大小为{1}字节, 必须小于等于{2}字节,可以调整udpCacheNotifierSettings配置节的packageSize属性来解决此问题",
                    notifyData.CacheKey, data.Length, settings.PackageSize);

                dataList.Add(data);
            }

            return dataList;
        }
        private static void SendCacheNotifyByProcessKey(string processKey)
        {
            string cacheKey = NormalizeCacheKey(processKey);

            CacheNotifyData notifyData = new CacheNotifyData(typeof(WfProcessDescriptorXmlCache), cacheKey, CacheNotifyType.Invalid);

            UdpCacheNotifier.Instance.SendNotifyAsync(notifyData);
            MmfCacheNotifier.Instance.SendNotify(notifyData);
        }
        public void Update(string roleID, SOARolePropertyDefinitionCollection properties)
        {
            roleID.CheckStringIsNullOrEmpty("roleID");
            properties.NullCheck("properties");

            StringBuilder strB = new StringBuilder();

            strB.AppendFormat("DELETE WF.ROLE_PROPERTIES_DEFINITIONS WHERE {0}", roleID.ToRoleIDCriteria());

            foreach (SOARolePropertyDefinition property in properties)
            {
                if (strB.Length > 0)
                    strB.Append(TSqlBuilder.Instance.DBStatementSeperator);

                property.RoleID = roleID;

                strB.AppendFormat(ORMapping.GetInsertSql(property, TSqlBuilder.Instance));
            }

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                DbHelper.RunSql(strB.ToString(), GetConnectionName());

                scope.Complete();
            }

            string cacheKey = roleID.ToRoleIDCacheKey();

            CacheNotifyData notifyData1 = new CacheNotifyData(typeof(SOARolePropertiesDefinitionCache), cacheKey, CacheNotifyType.Invalid);
            CacheNotifyData notifyData2 = new CacheNotifyData(typeof(SOARolePropertiesCache), cacheKey, CacheNotifyType.Invalid);

            UdpCacheNotifier.Instance.SendNotifyAsync(notifyData1, notifyData2);
            MmfCacheNotifier.Instance.SendNotify(notifyData1, notifyData2);
        }
        private static void Current_TransactionCompleted(TransactionEventArgs e)
        {
            try
            {
                List<CacheNotifyData> dataList = new List<CacheNotifyData>();

                foreach (KeyValuePair<string, string> kp in TaskChangedUserIDs)
                {
                    CacheNotifyData notifyData = new CacheNotifyData(typeof(UserTaskChangingCache), kp.Key, CacheNotifyType.Update);

                    notifyData.CacheData = Guid.NewGuid().ToString();

                    dataList.Add(notifyData);
                }

                CacheNotifyData[] notifyArray = dataList.ToArray();

                UdpCacheNotifier.Instance.SendNotifyAsync(notifyArray);
                MmfCacheNotifier.Instance.SendNotify(notifyArray);
            }
            finally
            {
                TaskChangedUserIDs.Clear();

                TransactionEventAttached = false;
            }
        }
 public SendDataWrapper(CacheNotifyData[] originalNotifyData, List<byte[]> dl, UdpCacheNotifierTargetCollection t)
 {
     OriginalNotifyData = originalNotifyData;
     DataList = dl;
     Targets = t;
 }
        private static void SendSerializedData(CacheNotifyData[] originalNotifyData, List<byte[]> serializedData, UdpCacheNotifierTargetCollection targets)
        {
            Logger logger = null;

            try
            {
                logger = LoggerFactory.Create("UdpCache");
            }
            catch (SystemSupportException)
            {
            }

            for (int i = 0; i < originalNotifyData.Length; i++)
            {
                byte[] data = serializedData[i];
                CacheNotifyData notifyData = originalNotifyData[i];

                foreach (UdpCacheNotifierTarget endPoint in targets)
                {
                    foreach (int port in endPoint.GetPorts())
                    {
                        using (UdpClient udp = new UdpClient())
                        {
                            IPEndPoint remoteEndPoint = new IPEndPoint(endPoint.Address, port);

                            udp.Connect(remoteEndPoint);

                            udp.Send(data, data.Length);
                        }
                    }

                    if (logger != null)
                        logger.Write(CreateLogEntity(notifyData, endPoint));
                }

                UdpCacheNotifier.TotalCounters.UdpSentItemsCounter.Increment();
                UdpCacheNotifier.TotalCounters.UdpSentCountPerSecond.Increment();

                UdpCacheNotifier.AppInstanceCounters.UdpSentItemsCounter.Increment();
                UdpCacheNotifier.AppInstanceCounters.UdpSentCountPerSecond.Increment();
            }
        }
        public void Update(string roleID, SOARolePropertyRowCollection rows)
        {
            roleID.CheckStringIsNullOrEmpty("roleID");
            rows.NullCheck("rows");

            StringBuilder strB = new StringBuilder(1024);

            strB.AppendFormat("DELETE WF.ROLE_PROPERTIES_ROWS WHERE {0}", roleID.ToRoleIDCriteria());

            strB.Append(TSqlBuilder.Instance.DBStatementSeperator);

            strB.AppendFormat("DELETE WF.ROLE_PROPERTIES_CELLS WHERE {0}", roleID.ToRoleIDCriteria());

            strB.Append(TSqlBuilder.Instance.DBStatementSeperator);

            strB.AppendFormat("DELETE WF.ROLE_PROPERTIES_USER_CONTAINERS WHERE {0}", roleID.ToRoleIDCriteria());

            PrepareRowsSql(roleID, rows, strB);

            SOARolePropertyRowUsersCollection rowsUsers = rows.GenerateRowsUsersDirectly();
            SOARolePropertyRowRolesCollection rowsRoles = rows.GenerateRowsRolesDirectly();

            PrepareUserContainers(roleID, rowsUsers, strB);
            PrepareRoleContainers(roleID, rowsRoles, strB);

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                DbHelper.RunSql(strB.ToString(), GetConnectionName());
                scope.Complete();
            }

            CacheNotifyData notifyData = new CacheNotifyData(typeof(SOARolePropertiesCache), roleID.ToRoleIDCacheKey(), CacheNotifyType.Invalid);
            UdpCacheNotifier.Instance.SendNotifyAsync(notifyData);
            MmfCacheNotifier.Instance.SendNotify(notifyData);
        }
        public void Delete(string roleID)
        {
            roleID.CheckStringIsNullOrEmpty("roleID");

            StringBuilder strB = new StringBuilder(1024);

            strB.AppendFormat("DELETE WF.ROLE_PROPERTIES_ROWS WHERE {0}", roleID.ToRoleIDCriteria());

            strB.Append(TSqlBuilder.Instance.DBStatementSeperator);

            strB.AppendFormat("DELETE WF.ROLE_PROPERTIES_CELLS WHERE {0}", roleID.ToRoleIDCriteria());

            strB.Append(TSqlBuilder.Instance.DBStatementSeperator);

            strB.AppendFormat("DELETE WF.ROLE_PROPERTIES_USER_CONTAINERS WHERE {0}", roleID.ToRoleIDCriteria());

            DbHelper.RunSqlWithTransaction(strB.ToString(), GetConnectionName());

            CacheNotifyData notifyData = new CacheNotifyData(typeof(SOARolePropertiesCache), roleID.ToRoleIDCacheKey(), CacheNotifyType.Invalid);
            UdpCacheNotifier.Instance.SendNotifyAsync(notifyData);
            MmfCacheNotifier.Instance.SendNotify(notifyData);
        }
        protected void Save_Click(object sender, EventArgs e)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "ResetSubmitButton", "top.SubmitButton.resetAllStates();", true);

            try
            {
                Util.EnsureOperationSafe();
                SchemaObjectBase parent = null;

                if (this.currentParentID.Value.IsNotEmpty())
                    parent = SchemaObjectAdapter.Instance.Load(this.currentParentID.Value);

                SCObjectOperations.InstanceWithPermissions.DoOperation(this.OperationMode, this.Data, parent);

                SchemaObjectPhotoKey photoCacheKey = new SchemaObjectPhotoKey() { ObjectID = this.Data.ID, PropertyName = "PhotoKey", TimePoint = DateTime.MinValue };

                CacheNotifyData notifyData = new CacheNotifyData(typeof(SchemaObjectPhotoCache), photoCacheKey, CacheNotifyType.Invalid);

                UdpCacheNotifier.Instance.SendNotify(notifyData);
                MmfCacheNotifier.Instance.SendNotify(notifyData);

                WebUtility.ResponseCloseWindowScriptBlock();

                //ScriptManager.RegisterClientScriptBlock(this.panelContainer, this.GetType(), "master", "top.window.close();", true);
            }
            catch (System.Exception ex)
            {
                WebUtility.ShowClientError(ex.GetRealException());
            }
        }
		/// <summary>
		/// 将CacheNotifyData写入日志
		/// </summary>
		/// <param name="logger"></param>
		/// <param name="notifyData"></param>
		protected virtual void WriteCacheNotifyDataToLog(Logger logger, CacheNotifyData notifyData)
		{
			if (logger != null)
				logger.Write(CreateLogEntity(notifyData));
		}
		/// <summary>
		/// 创建Log项
		/// </summary>
		/// <param name="notifyData"></param>
		/// <returns></returns>
		protected virtual LogEntity CreateLogEntity(CacheNotifyData notifyData)
		{
			LogEntity logEntity = new LogEntity(notifyData.ToString());

			logEntity.EventID = 7002;
			logEntity.LogEventType = TraceEventType.Information;

			logEntity.Source = GetLogSource();
			logEntity.Title = "接收Cache";
			logEntity.Priority = LogPriority.Normal;

			return logEntity;
		}