public void WriteOneNotifyData() { CacheNotifyDataMap.ResetMap(); CacheNotifyData data = PrepareData("Test"); CacheNotifyDataMap.WriteCacheNotifyData(data); long lastTicks = 0; CacheNotifyData[] dataRead = CacheNotifyDataMap.ReadCacheNotifyData(ref lastTicks); CacheNotifyDataMapInfo mapInfo = CacheNotifyDataMap.GetCacheNotifyDataMapInfo(); Console.WriteLine(mapInfo.Pointer); Console.WriteLine(lastTicks); Assert.AreEqual(1, mapInfo.Pointer); Assert.IsTrue(dataRead.Length > 0); Assert.IsTrue(lastTicks > 0); AssertCacheNotifyData(data, dataRead[0]); CacheNotifyData[] dataReadAgain = CacheNotifyDataMap.ReadCacheNotifyData(ref lastTicks); Assert.AreEqual(0, dataReadAgain.Length); }
private static void UpdateDESchemaObjectByIDCache(string id) { CacheNotifyData notifyData = new CacheNotifyData(typeof(DESchemaObjectByIDCache), CalculateIDCacheKey(id), 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()); } }
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); } }
protected override void AfterInnerUpdate(WfMatrixDefinition data, Dictionary <string, object> context) { StringBuilder strB = new StringBuilder(); WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder(); builder.AppendItem("MATRIX_DEF_KEY", data.Key); builder.AppendTenantCode(typeof(WfMatrixDimensionDefinition)); strB.AppendFormat("{0} {1}", DELETE_DIMENSION_SQL_CLAUSE, builder.ToSqlString(TSqlBuilder.Instance)); foreach (WfMatrixDimensionDefinition dd in data.Dimensions) { if (strB.Length > 0) { strB.Append(TSqlBuilder.Instance.DBStatementSeperator); } strB.Append(ORMapping.GetInsertSql(dd, TSqlBuilder.Instance)); } if (strB.Length > 0) { DbHelper.RunSql(strB.ToString(), GetConnectionName()); } CacheNotifyData notifyData = new CacheNotifyData(typeof(WfMatrixDefinitionCache), CalculateCacheKey(data.Key), CacheNotifyType.Invalid); UdpCacheNotifier.Instance.SendNotifyAsync(notifyData); MmfCacheNotifier.Instance.SendNotify(notifyData); }
private static void UpdateCache(WfDelegation data) { CacheNotifyData notifyData = new CacheNotifyData(typeof(WfDelegationCache), data.SourceUserID, CacheNotifyType.Invalid); UdpCacheNotifier.Instance.SendNotifyAsync(notifyData); MmfCacheNotifier.Instance.SendNotify(notifyData); }
public void Update() { XElementFormatter formatter = new XElementFormatter(); formatter.OutputShortType = false; string settings = formatter.Serialize(this).ToString(); string updateSQL = string.Format("UPDATE USER_SETTINGS SET SETTINGS = {0} WHERE USER_ID = {1}", TSqlBuilder.Instance.CheckQuotationMark(settings, true), TSqlBuilder.Instance.CheckQuotationMark(this.UserID, true)); using (DbContext context = DbContext.GetContext(ConnectionDefine.UserRelativeInfoConnectionName)) { using (TransactionScope scope = TransactionScopeFactory.Create()) { if (DbHelper.RunSql(updateSQL, ConnectionDefine.UserRelativeInfoConnectionName) == 0) { string insertSQL = string.Format("INSERT INTO USER_SETTINGS(USER_ID, SETTINGS) VALUES({0}, {1})", TSqlBuilder.Instance.CheckQuotationMark(this.UserID, true), TSqlBuilder.Instance.CheckQuotationMark(settings, true)); DbHelper.RunSql(insertSQL, ConnectionDefine.UserRelativeInfoConnectionName); } scope.Complete(); } } CacheNotifyData notifyData = new CacheNotifyData(typeof(UserSettingsCache), this.UserID, CacheNotifyType.Invalid); UdpCacheNotifier.Instance.SendNotifyAsync(notifyData); MmfCacheNotifier.Instance.SendNotify(notifyData); }
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; } }
protected override void AfterInnerUpdate(UserReportInfo data, Dictionary <string, object> context) { CacheNotifyData notifyData = new CacheNotifyData(typeof(UserReportInfoCache), data.User.ID, CacheNotifyType.Invalid); UdpCacheNotifier.Instance.SendNotifyAsync(notifyData); MmfCacheNotifier.Instance.SendNotify(notifyData); }
private static void SendOneMessage(string text) { CacheNotifyData data = new CacheNotifyData(typeof(ObjectCacheQueue), "ClientData", CacheNotifyType.Update); data.CacheData = text; UdpCacheNotifier.Instance.SendNotify(data); }
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 override void ClearAll() { base.ClearAll(); CacheNotifyData notifyData = new CacheNotifyData(typeof(WfMatrixProcessKeyCache), null, CacheNotifyType.Clear); UdpCacheNotifier.Instance.SendNotifyAsync(notifyData); MmfCacheNotifier.Instance.SendNotify(notifyData); }
public void ClearAll() { this.ClearAllXml(); CacheNotifyData notifyData = new CacheNotifyData(typeof(WfProcessDescriptorXmlCache), null, CacheNotifyType.Clear); UdpCacheNotifier.Instance.SendNotifyAsync(notifyData); MmfCacheNotifier.Instance.SendNotify(notifyData); }
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); }
protected override void AfterInnerDelete(WfMatrixDefinition data, Dictionary <string, object> context) { WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder(); builder.AppendItem("MATRIX_DEF_KEY", data.Key); builder.AppendTenantCode(typeof(WfMatrixDimensionDefinition)); string sql = string.Format("{0} {1}", DELETE_DIMENSION_SQL_CLAUSE, builder.ToSqlString(TSqlBuilder.Instance)); DbHelper.RunSql(sql, GetConnectionName()); CacheNotifyData notifyData = new CacheNotifyData(typeof(WfMatrixDefinitionCache), CalculateCacheKey(data.Key), CacheNotifyType.Invalid); UdpCacheNotifier.Instance.SendNotifyAsync(notifyData); MmfCacheNotifier.Instance.SendNotify(notifyData); }
protected override void AfterInnerUpdate(WfMatrix data, Dictionary <string, object> context) { DeleteRelatedData(data.MatrixID); WfMatrixRowUsersCollection rowsUsers = (WfMatrixRowUsersCollection)context["MatrixRowsUsers"]; string rowsUsersSql = BuildRowsUsersSql(rowsUsers); if (rowsUsersSql.IsNotEmpty()) { DbHelper.RunSql(rowsUsersSql, GetConnectionName()); } StringBuilder sqlClause = new StringBuilder(); foreach (var row in data.Rows) { if (sqlClause.Length > 0) { sqlClause.Append(TSqlBuilder.Instance.DBStatementSeperator); } sqlClause.Append(BuildInsertRowSql(data.MatrixID, row)); foreach (var cell in row.Cells) { sqlClause.Append(BuildInsertCellSql(data.MatrixID, row, cell)); } } if (sqlClause.Length > 0) { DbHelper.RunSql(sqlClause.ToString(), GetConnectionName()); } CacheNotifyData notifyData = new CacheNotifyData(typeof(WfMatrixProcessKeyCache), CalculateCacheKey(data.ProcessKey), CacheNotifyType.Invalid); UdpCacheNotifier.Instance.SendNotifyAsync(notifyData); MmfCacheNotifier.Instance.SendNotify(notifyData); }
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); }
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(); } }
public void Update() { XElementFormatter formatter = new XElementFormatter(); formatter.OutputShortType = WorkflowSettings.GetConfig().OutputShortType; string properties = formatter.Serialize(this).ToString(); string updateSQL = string.Format("UPDATE WF.GLOBAL_PARAMETERS SET [PROPERTIES] = {0} WHERE {1}", TSqlBuilder.Instance.CheckQuotationMark(properties, true), GetWhereSqlClauseBuilder(this.Key).ToSqlString(TSqlBuilder.Instance)); using (DbContext context = DbContext.GetContext(WorkflowSettings.GetConfig().ConnectionName)) { using (TransactionScope scope = TransactionScopeFactory.Create()) { if (DbHelper.RunSql(updateSQL, WorkflowSettings.GetConfig().ConnectionName) == 0) { InsertSqlClauseBuilder iBuilder = new InsertSqlClauseBuilder(); iBuilder.AppendItem("[KEY]", this.Key); iBuilder.AppendItem("[PROPERTIES]", properties); iBuilder.AppendTenantCode(typeof(WfGlobalParameters)); string insertSQL = string.Format("INSERT INTO WF.GLOBAL_PARAMETERS {0}", iBuilder.ToSqlString(TSqlBuilder.Instance)); DbHelper.RunSql(insertSQL, WorkflowSettings.GetConfig().ConnectionName); } scope.Complete(); } } CacheNotifyData notifyData = new CacheNotifyData(typeof(WfGlobalParametersCache), CalculateCacheKey(this.Key), CacheNotifyType.Invalid); UdpCacheNotifier.Instance.SendNotifyAsync(notifyData); MmfCacheNotifier.Instance.SendNotify(notifyData); }
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; //} CacheNotifyData[] data = CacheNotifyData.FromSettings("permissionCenter", CacheNotifyType.Clear); UdpCacheNotifier.Instance.SendNotifyAsync(data); MmfCacheNotifier.Instance.SendNotifyAsync(data); }
public void SaveChanges(string userId) { XElementFormatter formatter = new XElementFormatter(); formatter.OutputShortType = false; string settings = formatter.Serialize(this).ToString(); string updateSQL = string.Format("UPDATE USER_RECENT_DATA SET DATA = {0} WHERE USER_ID = {1} AND CATEGORY = {2}", TSqlBuilder.Instance.CheckUnicodeQuotationMark(settings), TSqlBuilder.Instance.CheckUnicodeQuotationMark(userId), TSqlBuilder.Instance.CheckUnicodeQuotationMark(this.Name)); using (DbContext context = DbContext.GetContext(ConnectionDefine.UserRelativeInfoConnectionName)) { using (TransactionScope scope = TransactionScopeFactory.Create()) { if (DbHelper.RunSql(updateSQL, ConnectionDefine.UserRelativeInfoConnectionName) == 0) { string insertSQL = string.Format("INSERT INTO USER_RECENT_DATA(USER_ID,CATEGORY, DATA) VALUES({0}, {1}, {2})", TSqlBuilder.Instance.CheckUnicodeQuotationMark(userId), TSqlBuilder.Instance.CheckUnicodeQuotationMark(this.Name), TSqlBuilder.Instance.CheckUnicodeQuotationMark(settings)); DbHelper.RunSql(insertSQL, ConnectionDefine.UserRelativeInfoConnectionName); } scope.Complete(); } } CacheNotifyData notifyData = new CacheNotifyData(typeof(UserRecentDataCategoryCache), new UserRecentDataCategoryCacheKey(userId, this.Name), CacheNotifyType.Invalid); UdpCacheNotifier.Instance.SendNotifyAsync(notifyData); MmfCacheNotifier.Instance.SendNotify(notifyData); //可有可无,在NLB环境下意义不大。沈峥 UserRecentDataCategoryCache.Instance.Remove(new UserRecentDataCategoryCacheKey(userId, this.Name)); }
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); }
public void WriteOverflowNotifyData() { CacheNotifyDataMap.ResetMap(); long lastTicks = DateTime.Now.Ticks; //会比最大项多写一项 for (int i = 0; i <= CacheNotifyDataMapInfo.CacheDataItemCount; i++) { CacheNotifyData data = PrepareData("Test" + i.ToString()); CacheNotifyDataMap.WriteCacheNotifyData(data); } CacheNotifyData[] dataRead = CacheNotifyDataMap.ReadCacheNotifyData(ref lastTicks); Assert.AreEqual(CacheNotifyDataMapInfo.CacheDataItemCount, dataRead.Length); bool existZeroItem = false; bool existLastItem = false; for (int i = 0; i < dataRead.Length; i++) { if (dataRead[i].CacheKey.ToString() == "Test0") { existZeroItem = true; } else if (dataRead[i].CacheKey.ToString() == "Test" + CacheNotifyDataMapInfo.CacheDataItemCount) { existLastItem = true; } } Assert.IsFalse(existZeroItem, "第0项应该被挤掉"); Assert.IsTrue(existLastItem, "最后一项应该被保留"); }
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); }
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); }
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); }