private static byte[] GetCachedIcon(Models.Site s) { CacheInfo rval; if (icons.TryGetValue(s.Id, out rval)) { if (DateTime.UtcNow.AddMinutes(-720) < rval.CacheDate) { return rval.Image; } } rval = new CacheInfo { CacheDate = DateTime.UtcNow }; try { lock(icons) { using (var client = new WebClient()) { var stream = client.OpenRead(s.IconUrl); rval.Image = ReadFully(stream); icons.TryAdd(s.Id, rval); } } } catch { icons.TryAdd(s.Id, rval); } return rval.Image; }
public DealDAO() { dependency = new SqlCacheDependency("anythinglk", "Deals"); allDealsQuery = from deal in db.Deals orderby deal.PlacedOn descending select deal; cacheInfo = new CacheInfo(); HttpContext.Current.Cache.Insert("CacheValid", cacheInfo, dependency); }
public static CacheInfo Get(string key, ProcessModule module) { CacheInfo result; if( CachedInfos.TryGetValue(key, out result)) { return result; } result = new CacheInfo(module); CachedInfos[key] = result; return result; }
public void AddMoviesToCache(DataSearchRequest q, IEnumerable<Movie> movieList, int totalResults, string nextPageToken) { CacheInfo cachedResult = _appCache.Get(GetCacheKey(q)) as CacheInfo; if (cachedResult == null) { cachedResult = new CacheInfo() { Movies = new List<Movie>() }; } cachedResult.NextPageToken = nextPageToken; cachedResult.TotalResults = totalResults; cachedResult.Movies.AddRange(movieList); _appCache.Put(GetCacheKey(q), cachedResult); }
public static string GetFileName(string url) { lock (Cache.m_cache) { for (int i = 0; i < Cache.m_cache.Count; ++i) if (Cache.m_cache[i].Url == url) return Cache.m_cache[i].Name; var info = new CacheInfo(url); Cache.m_cache.Add(info); Cache.Save(); return info.Name; } }
/// <summary> /// Initialize a phoenix with provided cacheDuration and staleWhileRevalidate values /// </summary> /// <param name="invocation"></param> /// <param name="info"></param> public Phoenix(_IInvocation invocation, CacheInfo info) { _info = info; _phoenixState = _info.StaleWhileRevalidate > 0 ? (IPhoenixState)new RaisingPhoenix() : new DisposingPhoenix(Die); if (invocation.Proxy != null) { // It is really a dynamic proxy _instanceTargetField = invocation.Proxy.GetType().GetField("__target", BindingFlags.Public | BindingFlags.Instance); } Arguments = invocation.Arguments; MethodInfo = invocation.Method; _timer = new Timer(_ => Reborn(), null, _info.GetRefreshTime(), TimeSpan.Zero); }
public void Load(int scheduleId) { _cacheInfo = Cache.Current.Info(CacheKey); LogInstance.LogInfo("Schedule cache state is {0}, duration is {1} hrs", _cacheInfo.State, this.CacheDuration.TotalHours); if (_cacheInfo.State == CacheStates.Exists) { LoadFromCache(); return; } var url = string.Format(URL, scheduleId); MakeRequest(url); }
public void AddToCache(string fileName, Texture2D tex) { CacheInfo info = new CacheInfo(); info.texture = tex; info.staleTime = 0; info.usageCount = 1; try { this.cacheDict.Add (fileName, info); } catch (System.ArgumentException) { // The fileName is already in the dictionary. // Can happen a lot if using multiple WWW threads // to load images this.cacheDict[fileName].usageCount += 1; } //Debug.Log (fileName + " usage count: " + this.cacheDict[fileName].usageCount); }
public String file2Md5(string fullFilePath) { var md5 = ""; var lastWrite = File.GetLastWriteTime(fullFilePath); if ((cacheTable.ContainsKey(fullFilePath)) && (lastWrite == cacheTable[fullFilePath].lastAccess)) md5 = cacheTable[fullFilePath].md5; else { md5 = file2Md5Uncached(fullFilePath); var cinfo = new CacheInfo(); cinfo.fullFilePath = fullFilePath; cinfo.lastAccess = lastWrite; cinfo.md5 = md5; if (cacheTable.ContainsKey(fullFilePath)) cacheTable.Remove(fullFilePath); cacheTable.Add(fullFilePath, cinfo); } return md5; }
public override PyObject Run(PyTuple args, object client) { Log.Debug("objectCaching", "Called GetCachableObject stub"); CacheInfo cache = new CacheInfo(); if (cache.Decode(args) == false) { return null; } Log.Debug("GetCachableObject", "Got cache request for cache " + cache.objectID.As<PyString>().Value); if (Cache.LoadCacheFor(cache.objectID.As<PyString>().Value) == false) { return null; } return Cache.GetCache(cache.objectID.As<PyString>().Value); }
private void CacheObject(CacheInfo cacheInfo) { switch (cacheInfo.Type) { case ObjType.Object: m_Cache.CacheUnknown(cacheInfo.Hvo, cacheInfo.Flid, cacheInfo.Object); break; case ObjType.BasicTsString: m_Cache.CacheStringProp(cacheInfo.Hvo, cacheInfo.Flid, cacheInfo.Object as ITsString); break; case ObjType.ExtendedTsString: m_Cache.CacheStringAlt(cacheInfo.Hvo, cacheInfo.Flid, cacheInfo.Ws, cacheInfo.Object as ITsString); break; case ObjType.ByteArray: byte[] array = cacheInfo.Object as byte[]; m_Cache.CacheBinaryProp(cacheInfo.Hvo, cacheInfo.Flid, array, array.Length); break; case ObjType.String: var str = cacheInfo.Object as string; m_Cache.CacheUnicodeProp(cacheInfo.Hvo, cacheInfo.Flid, str, str.Length); break; case ObjType.Guid: m_Cache.CacheGuidProp(cacheInfo.Hvo, cacheInfo.Flid, (Guid)cacheInfo.Object); break; case ObjType.Int: m_Cache.CacheIntProp(cacheInfo.Hvo, cacheInfo.Flid, (int)cacheInfo.Object); break; case ObjType.Long: m_Cache.CacheInt64Prop(cacheInfo.Hvo, cacheInfo.Flid, (long)cacheInfo.Object); break; case ObjType.Bool: m_Cache.CacheBooleanProp(cacheInfo.Hvo, cacheInfo.Flid, (bool)cacheInfo.Object); break; case ObjType.Vector: int[] vector = cacheInfo.Object as int[]; m_Cache.CacheVecProp(cacheInfo.Hvo, cacheInfo.Flid, vector, vector.Length); break; case ObjType.Time: m_Cache.CacheTimeProp(cacheInfo.Hvo, cacheInfo.Flid, (long)cacheInfo.Object); break; } }
/// <summary> /// Load all the config sections from the configuration file. /// </summary> static private void LoadConfiguration() { CacheInfo cacheInfo = null; try { CacheServerConfig[] configs = CacheConfigManager.GetConfiguredCaches(); //Just need to call the static block - stupid logik i know Alachisoft.NCache.Util.MiscUtil.RegisterCompactTypes(); for (int i = 0; i < configs.Length; i++) { CacheServerConfig config = configs[i]; ///[Ata] Until we completely move to using dom based configuration ///we have to convert it to string props string props = GetProps(config); // all but the listed cache types are loaded in s_caches table. string cacheId = config.Name.ToLower(); if (!s_caches.Contains(cacheId)) { cacheInfo = new CacheInfo(); cacheInfo.Cache = new LeasedCache(props); cacheInfo.CacheProps = config; s_caches.Add(cacheId, cacheInfo); } else { cacheInfo = s_caches[cacheId] as CacheInfo; cacheInfo.CacheProps = config; } } } catch (Exception e) { string msg = String.Format("CacheServer failed to load configuration information, Error {0}", e.Message); AppUtil.LogEvent(msg, EventLogEntryType.Warning); } }
public static ProcessorDeviceInfo[] EnumProcessors() { var p = _internalEnumerateDevices <ProcessorDeviceInfo>(DevProp.GUID_DEVCLASS_PROCESSOR, ClassDevFlags.Present); if (p != null && p.Length > 0) { if (p is null) { return(null); } var procs = SysInfo.LogicalProcessors; Array.Sort(procs, new Comparison <SystemLogicalProcessorInformation>((x, y) => { if (x.Relationship == y.Relationship) { return((int)(x.ProcessorMask - y.ProcessorMask)); } else { return((int)x.Relationship - (int)y.Relationship); } })); Array.Sort(p, new Comparison <ProcessorDeviceInfo>((x, y) => { return(string.Compare(x.InstanceId, y.InstanceId)); })); int c = p.Length; int d = procs.Length; List <CacheInfo>[] pci = new List <CacheInfo> [c]; for (int i = 0; i < c; i++) { ProcessorDeviceInfo pInfo = p[i]; pInfo.LogicalProcessor = (i + 1); int ccore = 1; foreach (var proc in procs) { if ((proc.ProcessorMask & (1 << i)) == (1 << i)) { if ((proc.Relationship | LogicalProcessorRelationship.RelationProcessorCore) == LogicalProcessorRelationship.RelationProcessorCore) { pInfo.Core = ccore; pInfo.Source = proc; } else if ((proc.Relationship | LogicalProcessorRelationship.RelationCache) == LogicalProcessorRelationship.RelationCache) { var cd = new CacheInfo(proc.CacheDescriptor); if (pci[i] == null) { pci[i] = new List <CacheInfo>(); } switch (cd.Level) { case 1: pInfo.HasL1Cache = true; break; case 2: pInfo.HasL2Cache = true; break; case 3: pInfo.HasL3Cache = true; break; } pInfo.TotalCacheSize += cd.Size; pInfo.TotalLineSize += cd.LineSize; pci[i].Add(cd); } } if ((proc.Relationship | LogicalProcessorRelationship.RelationProcessorCore) == LogicalProcessorRelationship.RelationProcessorCore) { ccore++; } } pInfo.Caches = new ReadOnlyCollection <CacheInfo>(pci[i]); } } return(p); }
public object Get(Type type, CacheInfo info) => OnlinePlayDependencies?.Get(type, info) ?? parent.Get(type, info);
public object Get(Type type, CacheInfo info) => dependencies.Get(type, info);
private CacheInfo TryLoadFromDisk(string url) { if (_directoryOnDisk == null) { return null; // no place to cache } CacheInfo found = null; // look for all files matching the prefix // looking for the one matching url that is not expired // removing expired (or invalid) ones string pattern = GetTempFileNamePrefixFromUrl(url) + "_*.feed"; string[] files = Directory.GetFiles(_directoryOnDisk, pattern, SearchOption.TopDirectoryOnly); foreach (string feedFilename in files) { XmlDocument feedDoc = null; bool isFeedFileValid = false; DateTime utcExpiryFromFeedFile = DateTime.MinValue; string urlFromFeedFile = null; try { feedDoc = new XmlDocument(); feedDoc.Load(feedFilename); // look for special XML comment (before the root tag)' // containing expiration and url XmlComment comment = feedDoc.DocumentElement.PreviousSibling as XmlComment; if (comment != null) { string c = comment.Value ?? string.Empty; int i = c.IndexOf('@'); long expiry; if (i >= 0 && long.TryParse(c.Substring(0, i), out expiry)) { utcExpiryFromFeedFile = DateTime.FromBinary(expiry); urlFromFeedFile = c.Substring(i + 1); isFeedFileValid = true; } } } catch (XmlException) { // error processing one file shouldn't stop processing other files } // remove invalid or expired file if (!isFeedFileValid || utcExpiryFromFeedFile < DateTime.UtcNow) { TryDeleteFile(feedFilename); // try next file continue; } // match url if (urlFromFeedFile == url) { // keep the one that expires last if (found == null || found.Expiry < utcExpiryFromFeedFile) { // if we have a previously found older expiration, kill it... if (found != null) { found.Dispose(); TryDeleteFile(found.FeedFilename); } // create DOM and set expiry (as found on disk) found = new CacheInfo(feedDoc, utcExpiryFromFeedFile, feedFilename); } } } // return best fit return found; }
/// <summary> /// Member CacheBinaryProp /// </summary> /// <param name="obj">obj</param><param name="tag">tag</param><param name="rgb">rgb</param><param name="cb">cb</param> /// <remarks> /// IVwCacheDa method /// </remarks> public void CacheBinaryProp(int obj, int tag, byte[] rgb, int cb) { var before = new CacheInfo(ObjType.ByteArray, obj, tag, m_cache.get_Prop(obj, tag)); var after = new CacheInfo(ObjType.ByteArray, obj, tag, rgb); ActionHandler.AddAction(new CacheUndoAction(m_cache, before, after)); m_cache.CacheBinaryProp(obj, tag, rgb, cb); }
/// <summary> /// 登录成功 添加缓存 /// </summary> /// <param name="result"></param> public void CacheAdd(CacheInfo result) { GetLoginCache().Add(GetAuthKey(result.AuthorizationCode), result, 240);//时间为分钟 }
public JsonResult Application(FormCollection form) { string success = String.Empty; string scopeName = form["Scope"]; string cacheImportURI = form["cacheImportURI"]; long cacheTimeout = String.IsNullOrWhiteSpace(form["cacheTimeout"]) ? 0 : Convert.ToInt64(form["cacheTimeout"]); string permissions = form["permissions"]; library.Configuration configuration = new Configuration { AppSettings = new AppSettings { Settings = new List <Setting>() } }; CacheInfo cacheInfo = new CacheInfo { ImportURI = cacheImportURI, Timeout = cacheTimeout }; for (int i = 0; i < form.AllKeys.Length; i++) { //if (form.GetKey(i).ToLower() != "scope" && form.GetKey(i).ToLower() != "name" && form.GetKey(i).ToLower() != "description" && // form.GetKey(i).ToLower() != "assembly" && form.GetKey(i).ToLower() != "application" && form.GetKey(i).ToLower().Substring(0, 3) != "val" // && form.GetKey(i).ToLower() != "cacheimporturi" && form.GetKey(i).ToLower() != "cachetimeout") if (form.GetKey(i).ToLower().StartsWith("key")) { String key = form[i]; if (i + 1 < form.AllKeys.Length) { String value = form[i + 1]; configuration.AppSettings.Settings.Add(new Setting() { Key = key, Value = value }); } } } List <string> groups = new List <string>(); if (permissions.Contains(",")) { string[] arrstring = permissions.Split(','); groups = new List <string>(arrstring); } else { groups.Add(permissions); } ScopeApplication application = new ScopeApplication() { DisplayName = form["displayName"],//form["Name"], Name = form["Name"], Description = form["Description"], Assembly = form["assembly"], Configuration = configuration, CacheInfo = cacheInfo, PermissionGroup = new PermissionGroups() }; if (!string.IsNullOrEmpty(permissions)) { application.PermissionGroup.AddRange(groups); } if (String.IsNullOrEmpty(form["Application"])) { success = _repository.AddApplication(scopeName, application); } else { success = _repository.UpdateApplication(scopeName, form["Application"], application); } JsonResult result = Json(new { success = true }, JsonRequestBehavior.AllowGet); return(result); }
public ICacheEntry <T> GetEntry <T>(string key) where T : class { return(CacheInfo.GetCacheEntry <T>(key)); }
//??? public ICacheEntry GetEntry(string key) { return(CacheInfo.GetCacheEntry(key)); }
private static CacheInfo UpdateValueFactory(T existing, CacheInfo existingCacheInfo) => existingCacheInfo.Touch();
private void ResetCacheInfo() => _compiledQueryCacheInfo = new CacheInfo();
/// <summary> /// Member CacheGuidProp /// </summary> /// <param name="obj">obj</param><param name="tag">tag</param><param name="uid">uid</param> /// <remarks> /// IVwCacheDa method /// </remarks> public void CacheGuidProp(int obj, int tag, Guid uid) { var before = new CacheInfo(ObjType.Guid, obj, tag, m_cache.get_Prop(obj, tag)); var after = new CacheInfo(ObjType.Guid, obj, tag, uid); ActionHandler.AddAction(new CacheUndoAction(m_cache, before, after)); m_cache.CacheGuidProp(obj, tag, uid); }
/// <summary> /// Member CacheInt64Prop /// </summary> /// <param name="obj">obj</param><param name="tag">tag</param><param name="val">val</param> /// <remarks> /// IVwCacheDa method /// </remarks> public void CacheInt64Prop(int obj, int tag, long val) { var before = new CacheInfo(ObjType.Long, obj, tag, m_cache.get_Prop(obj, tag)); var after = new CacheInfo(ObjType.Long, obj, tag, val); ActionHandler.AddAction(new CacheUndoAction(m_cache, before, after)); m_cache.CacheInt64Prop(obj, tag, val); }
private CacheInfo TryLoadFromDisk(string url) { if (_directoryOnDisk == null) { return(null); // no place to cache } CacheInfo found = null; // look for all files matching the prefix // looking for the one matching url that is not expired // removing expired (or invalid) ones string pattern = GetTempFileNamePrefixFromUrl(url) + "_*.feed"; string[] files = Directory.GetFiles(_directoryOnDisk, pattern, SearchOption.TopDirectoryOnly); foreach (string feedFilename in files) { XmlDocument feedDoc = null; bool isFeedFileValid = false; DateTime utcExpiryFromFeedFile = DateTime.MinValue; string urlFromFeedFile = null; try { feedDoc = new XmlDocument(); feedDoc.Load(feedFilename); // look for special XML comment (before the root tag)' // containing expiration and url XmlComment comment = feedDoc.DocumentElement.PreviousSibling as XmlComment; if (comment != null) { string c = comment.Value ?? string.Empty; int i = c.IndexOf('@'); long expiry; if (i >= 0 && long.TryParse(c.Substring(0, i), out expiry)) { utcExpiryFromFeedFile = DateTime.FromBinary(expiry); urlFromFeedFile = c.Substring(i + 1); isFeedFileValid = true; } } } catch (XmlException) { // error processing one file shouldn't stop processing other files } // remove invalid or expired file if (!isFeedFileValid || utcExpiryFromFeedFile < DateTime.UtcNow) { TryDeleteFile(feedFilename); // try next file continue; } // match url if (urlFromFeedFile == url) { // keep the one that expires last if (found == null || found.Expiry < utcExpiryFromFeedFile) { // if we have a previously found older expiration, kill it... if (found != null) { found.Dispose(); TryDeleteFile(found.FeedFilename); } // create DOM and set expiry (as found on disk) found = new CacheInfo(feedDoc, utcExpiryFromFeedFile, feedFilename); } } } // return best fit return(found); }
/// <summary> /// Member CacheStringAlt /// </summary> /// <param name="obj">obj</param><param name="tag">tag</param><param name="ws">ws</param><param name="tss">tss</param> /// <remarks> /// IVwCacheDa method /// </remarks> public void CacheStringAlt(int obj, int tag, int ws, ITsString tss) { var before = new CacheInfo(ObjType.ExtendedTsString, obj, tag, ws, m_cache.get_IsPropInCache(obj, tag, (int)CellarPropertyType.MultiString, ws) ? m_cache.get_MultiStringAlt(obj, tag, ws) : null); var after = new CacheInfo(ObjType.ExtendedTsString, obj, tag, ws, tss); ActionHandler.AddAction(new CacheUndoAction(m_cache, before, after)); m_cache.CacheStringAlt(obj, tag, ws, tss); }
private static bool CacheReadable(CacheInfo dom) { return(dom != null && dom.Data != null && dom.Data.CanRead); }
public static HtdocsCacheSystem CreateNew(string directory, string htdocsDirectory, CacheInfo cacheInfo) { if (Directory.Exists(directory)) { throw new InvalidOperationException("Cannot create new cache system because directory with this name already exist"); } // Just write empty cache config to say, that this dir was opened by cache system before. // Currently, this config file do not contain any sensible data CreateConfigFile(directory, cacheInfo); return(new HtdocsCacheSystem(directory, htdocsDirectory, cacheInfo)); }
private int DateSort(CacheInfo _a, CacheInfo _b) { return _a.Date.CompareTo(_b.Date); }
public HtdocsCacheSystem(string cacheDirectory, string htdocsRootDirectory, CacheInfo cacheInfo) { pathResolver = new PathResolver(htdocsRootDirectory); this.cacheInfo = cacheInfo; this.cacheDirectory = cacheDirectory; }
public void SetCacheInfo(Uri uri, CacheInfo cacheInfo, Stream stream) { XmlElement cacheElm = getCacheElm(uri); if (cacheInfo != null) { if (cacheInfo.ETag != null) { cacheElm.SetAttribute("etag", cacheInfo.ETag); } else { cacheElm.RemoveAttribute("etag"); } if (cacheInfo.ContentType != null) { cacheElm.SetAttribute("content-type", cacheInfo.ContentType); } else { cacheElm.RemoveAttribute("content-type"); } if (cacheInfo.Expires != DateTime.MinValue) { cacheElm.SetAttribute("expires", cacheInfo.Expires.ToString("s")); } else { cacheElm.RemoveAttribute("expires"); } if (cacheInfo.LastModified != DateTime.MinValue) { cacheElm.SetAttribute("last-modified", cacheInfo.LastModified.ToString("s")); } else { cacheElm.RemoveAttribute("last-modified"); } } if (stream != null) { string localPath; if (cacheElm.HasAttribute("local-path")) { localPath = cacheElm.GetAttribute("local-path"); } else { localPath = Guid.NewGuid().ToString() + ".cache"; cacheElm.SetAttribute("local-path", localPath); } stream.Position = 0; int count; byte[] buffer = new byte[4096]; FileStream fs = File.OpenWrite(Path.Combine(_cacheDir, localPath)); while ((count = stream.Read(buffer, 0, 4096)) > 0) { fs.Write(buffer, 0, count); } fs.Flush(); fs.Close(); } saveDoc(); }
private static IEnumerable <T> ExecuteReader <T>(IDataReader reader, Identity identity, CacheInfo info) { var tuple = info.Deserializer; int hash = GetColumnHash(reader); if (tuple.Func == null || tuple.Hash != hash) { tuple = info.Deserializer = new DeserializerState(hash, GetDeserializer(typeof(T), reader, 0, -1, false)); SetQueryCache(identity, info); } var func = tuple.Func; while (reader.Read()) { yield return((T)func(reader)); } }
protected void Page_Load(object sender, EventArgs e) { string Good_Code = Request.QueryString["code"]; if (string.IsNullOrEmpty(Good_Code)) { Response.Redirect("/Banknet/", true); } CacheInfo oCache = (CacheInfo)CacheProvider.Get(string.Format(KeyCache.KeyUserBanknet, Good_Code)); if (oCache == null) { Response.Redirect("/Banknet/", true); } string sRedirection = "/Banknet/"; SubmitVoucherInfo oSVInfo = new SubmitVoucherInfo() { GatePayId = Config.ClientIdBanknet, UserId = oCache.User.subnum, Amount = int.Parse(oCache.Voucher.vouchervalue), CreateDate = DateTime.Now, TransId = Good_Code }; try { WSClient wsclient = new WSClient(); var cred = new credential { clientId = Config.ClientIdBanknet }; var wsResult = wsclient.submitVoucher(cred, oSVInfo.UserId, oSVInfo.Amount.ToString(), oSVInfo.TransId); oSVInfo.returnCode = wsResult.returnCode; oSVInfo.returnCodeDescription = wsResult.returnCodeDescription; string sResultDate = XMLReader.ReadResultVocher(wsResult.responseData);//dt oSVInfo.responseData = sResultDate; oSVInfo.signature = wsResult.signature; if (oSVInfo.returnCode == "") { Session[Config.GetSessionsResultDate] = sResultDate;//ss //confirm ThreadStart newThread = delegate { Confirm(oCache.Merchant_trans_id, oCache.sTrans_Id); }; Thread myThread = new Thread(newThread); myThread.Start(); sRedirection = "/Banknet/#" + Good_Code + "|T"; } else { Session[Config.GetSessionsResultFail] = wsResult.returnCodeDescription;//ss sRedirection = "/Banknet/#" + Good_Code + "|F|Y"; } } catch (Exception ex) { //log error Session[Config.GetSessionsResultFail] = ex.Message; oSVInfo.returnCode = ex.GetHashCode().ToString(); oSVInfo.returnCodeDescription = ex.Message; sRedirection = "/Banknet/#" + Good_Code + "|F|Y"; } finally { SubmitVoucherData.instance.Add(oSVInfo); Response.Redirect(sRedirection); } }
/// <summary> /// Parse the equation text into in IEquation, or obtain from the cache if available /// </summary> /// <param name="equationText"></param> protected void ParseEquation(string equationText) { CheckForSimpleNumber(equationText); if (IsJustNumber) { return; } equationText = CheckForEvenOdd(equationText); if (!ParsedEquationCache.TryGetValue(equationText, out cacheInfo)) { cacheInfo = new CacheInfo(); Equation = cacheInfo.Equation = GetEquation(equationText); ParsedEquationCache.TryAdd(equationText, cacheInfo); } else { Equation = cacheInfo.Equation; } }
/// <summary> /// The public constructor for the DM637x device AIS generator. /// The constructor is where the device differentiation is defined. /// </summary> public AISGen_OMAP_L138() { // Define the device name - used for default file names devNameShort = "OMAP-L138"; devNameLong = "OMAPL138"; // Define the device caches (they are considered internal memories since // bootrom turns off caching) - two identical sets since the memory map // has the caches at two locations Cache = new CacheInfo[6]; Cache[0].level = CacheLevel.L2; Cache[0].type = CacheType.Program | CacheType.Data; Cache[0].startAddr = 0x00800000; Cache[0].size = 0x40000; Cache[1].level = CacheLevel.L1; Cache[1].type = CacheType.Program; Cache[1].startAddr = 0x00E08000; Cache[1].size = 0x8000; Cache[2].level = CacheLevel.L1; Cache[2].type = CacheType.Data; Cache[2].startAddr = 0x00F10000; Cache[2].size = 0x8000; Cache[3].level = CacheLevel.L2; Cache[3].type = CacheType.Program | CacheType.Data; Cache[3].startAddr = 0x10800000; Cache[3].size = 0x40000; Cache[4].level = CacheLevel.L1; Cache[4].type = CacheType.Program; Cache[4].startAddr = 0x10E08000; Cache[4].size = 0x8000; Cache[5].level = CacheLevel.L1; Cache[5].type = CacheType.Data; Cache[5].startAddr = 0x10F10000; Cache[5].size = 0x8000; // Define the IDMA channels for internal memory transfers IDMA = new IDMARegisters[2]; IDMA[0] = new IDMARegisters(0, 0x01820000); IDMA[1] = new IDMARegisters(1, 0x01820100); // Define OMAP-L138 ROM boot loader functions ROMFunc = new ROMFunction[13]; ROMFunc[0].funcName = ROMFunctionNames.PLL0Config; ROMFunc[0].iniSectionName = "PLL0CONFIG"; ROMFunc[0].numParams = 2; ROMFunc[0].paramNames = new String[2] { "PLL0CFG0", "PLL0CFG1" }; ROMFunc[1].funcName = ROMFunctionNames.PLL1Config; ROMFunc[1].iniSectionName = "PLL1CONFIG"; ROMFunc[1].numParams = 2; ROMFunc[1].paramNames = new String[2] { "PLL1CFG0", "PLL1CFG1" }; ROMFunc[2].funcName = ROMFunctionNames.PeriphClockConfig; ROMFunc[2].iniSectionName = "PERIPHCLKCFG"; ROMFunc[2].numParams = 1; ROMFunc[2].paramNames = new String[1] { "PERIPHCLKCFG" }; ROMFunc[3].funcName = ROMFunctionNames.EMIF3AConfigDDR; ROMFunc[3].iniSectionName = "EMIF3DDR"; ROMFunc[3].numParams = 8; ROMFunc[3].paramNames = new String[8] { "PLL1CFG0", "PLL1CFG1", "DDRPHYC1R", "SDCR", "SDTIMR", "SDTIMR2", "SDRCR", "CLK2XSRC" }; ROMFunc[4].funcName = ROMFunctionNames.EMIF25ConfigSDRAM; ROMFunc[4].iniSectionName = "EMIF25SDRAM"; ROMFunc[4].numParams = 5; ROMFunc[4].paramNames = new String[5] { "SDBCR", "SDTIMR", "SDRSRPDEXIT", "SDRCR", "DIV4p5_CLK_ENABLE" }; ROMFunc[5].funcName = ROMFunctionNames.EMIF25ConfigAsync; ROMFunc[5].iniSectionName = "EMIF25ASYNC"; ROMFunc[5].numParams = 5; ROMFunc[5].paramNames = new String[5] { "A1CR", "A2CR", "A3CR", "A4CR", "NANDFCR" }; ROMFunc[6].funcName = ROMFunctionNames.PLLandClockConfig; ROMFunc[6].iniSectionName = "PLLANDCLOCKCONFIG"; ROMFunc[6].numParams = 3; ROMFunc[6].paramNames = new String[3] { "PLL0CFG0", "PLL0CFG1", "PERIPHCLKCFG" }; ROMFunc[7].funcName = ROMFunctionNames.PSCConfig; ROMFunc[7].iniSectionName = "PSCCONFIG"; ROMFunc[7].numParams = 1; ROMFunc[7].paramNames = new String[1] { "LPSCCFG" }; ROMFunc[8].funcName = ROMFunctionNames.PINMUXConfig; ROMFunc[8].iniSectionName = "PINMUX"; ROMFunc[8].numParams = 3; ROMFunc[8].paramNames = new String[3] { "REGNUM", "MASK", "VALUE" }; ROMFunc[9].funcName = ROMFunctionNames.FastBoot; ROMFunc[9].iniSectionName = "FASTBOOT"; ROMFunc[9].numParams = 0; ROMFunc[9].paramNames = null; ROMFunc[10].funcName = ROMFunctionNames.IOPUConfig; ROMFunc[10].iniSectionName = "IOPUCONFIG"; ROMFunc[10].numParams = 2; ROMFunc[10].paramNames = new String[2] { "IOPUSELECT", "MPPAVALUE" }; ROMFunc[11].funcName = ROMFunctionNames.MPUConfig; ROMFunc[11].iniSectionName = "MPUCONFIG"; ROMFunc[11].numParams = 4; ROMFunc[11].paramNames = new String[4] { "MPUSELECT", "STARTADDR", "ENDADDR", "MPPAVALUE" }; ROMFunc[12].funcName = ROMFunctionNames.TAPSConfig; ROMFunc[12].iniSectionName = "TAPSCONFIG"; ROMFunc[12].numParams = 1; ROMFunc[12].paramNames = new String[1] { "TAPSCFG" }; // Configuration info for the AISExtras functions (provided in AISExtraFileName COFF file) /* AISExtraFileName = null; * * AISExtraFunc = null;*/ AISExtraFileName = "AISExtra_" + devNameShort + ".out"; AISExtraFunc = new AISExtraFunction[1]; AISExtraFunc[0].funcName = "MakeROMEmulatableAndWait"; AISExtraFunc[0].iniSectionName = "OPENROMFORDEBUG"; AISExtraFunc[0].numParams = 0; AISExtraFunc[0].paramNames = null; AISExtraFunc[0].isInitFunc = true; // OMAP-L138 is little endian devEndian = Endian.LittleEndian; // OMAP-L138 AIS data is little endian; devAISEndian = Endian.LittleEndian; // Default settings for UARTSendDONE function UARTSendDONEAddr = 0x0; SendUARTSendDONE = false; // Default boot mode (can be changed from INI file) for this device bootMode = BootModes.NONE; // Create default CRC object for this device devCRC = new CRC32(0x04C11DB7, 0xFFFFFFFF, 0xFFFFFFFF, true, 1, UtilLib.CRC.CRCType.INCREMENTAL, UtilLib.CRC.CRCCalcMethod.LUT); crcType = CRCCheckType.NO_CRC; }
protected void ParseEquation(string equation) { equation = CheckForEvenOdd(equation); formula = Equations.CreateEquation<int>(equation); if (!ParsedEquationCache.TryGetValue(equation, out cacheInfo)) { cacheInfo = new CacheInfo(); cacheInfo.MatchingIndices = new HashSet<int>(); ParsedEquationCache[equation] = cacheInfo; } }
/// <summary> /// 接收数据 /// </summary> /// <param name="SID"></param> /// <param name="XML"></param> /// <returns></returns> public static string ReceiveXMLData(string SID, string xmlStr) { xmlStr = xmlStr.TrimStart(''); // if (xmlStr == string.Empty) // { // xmlStr = @" // <data><datarow> // <uniquecode >TY0008</uniquecode > // <dictcustomerid>1396</dictcustomerid> // <barcode>380003772900</barcode> // <realname>马昌武3</realname> // <sex>男</sex> // <birthday></birthday> // <age>41</age> // <ismarried>未知</ismarried> // <mobile>13096786113</mobile> // <idnumber></idnumber> // <address>地址</address> // <section>遵义</section> // <remark>备注</remark> // <phone></phone> // <email></email> // <samplingdate>2014-12-18</samplingdate> // <province>广东</province> // <city>广州市</city> // <county>天河区</county> // <dictlabid>3</dictlabid> // </datarow></data> // "; // } string str = "<?xml version='1.0' encoding='utf-8'?>" + StringToXML(xmlStr); string strMessage = string.Empty; //缓存取登录用户 Cache cache = new Cache(); CacheInfo info = cache.GetCacheData(SID); DataTable dt = new DataTable(); try { dt = GetDataTable(str); } catch (Exception ex) { return(String.Format("{0} {1}", ErrorCode.Rec_1002, ex.Message)); } if (dt == null || dt.Rows.Count == 0 || dt.Columns.Count != 20) { return(ErrorCode.Rec_1003); } List <Dicttestitem> TestItemList = loginservice.GetLoginDicttestitemList(); //项目字典表 List <Dictproductdetail> ProductDetail = loginservice.GetLoginDictproductdetail(); //套餐组合字典 string _productname = string.Empty; foreach (DataRow dr in dt.Rows) { #region 必填项 //套餐代码 string productTestCode = dr["uniquecode"].ToString().Replace('_', ' ').Trim(); //客户代码 string dictcustomercode = dr["dictcustomerid"].ToString().Trim(); //条码号 string barcode = dr["barcode"].ToString().Trim(); //姓名 string realname = dr["realname"].ToString().Trim(); //性别 string sex = dr["sex"].ToString().Replace('_', ' ').Trim() == "女" ? "F" : (dr["sex"].ToString().Replace('_', ' ').Trim() == "男" ? "M" : "U"); //婚否 string ismarried = dr["ismarried"].ToString().Trim(); //手机 string mobile = dr["mobile"].ToString().Trim(); //住址 string address = dr["address"].ToString().Trim(); //省 string province = dr["province"].ToString().Trim(); //市 string city = dr["city"].ToString().Trim(); //分点实验室 string dictlabid = dr["dictlabid"].ToString().Trim(); if (string.IsNullOrEmpty(productTestCode) || string.IsNullOrEmpty(dictcustomercode) || string.IsNullOrEmpty(dictlabid) || string.IsNullOrEmpty(realname) || string.IsNullOrEmpty(sex) || string.IsNullOrEmpty(ismarried) || string.IsNullOrEmpty(mobile) || string.IsNullOrEmpty(address) || string.IsNullOrEmpty(province) || string.IsNullOrEmpty(city)) { strMessage = ErrorCode.Rec_1005; break; } #endregion #region 二者不可都为空 //出生日期 string birthday = dr["birthday"].ToString().Trim(); //年龄 string age = dr["age"].ToString().Trim(); if (string.IsNullOrEmpty(birthday) && string.IsNullOrEmpty(age)) { strMessage = ErrorCode.Rec_1006; break; } #endregion #region 可空字段 //身份证 string idnumber = dr["idnumber"].ToString().Trim(); //部门 string section = dr["section"].ToString().Trim(); //备注 string remark = dr["remark"].ToString().Trim(); //电话 string phone = dr["phone"].ToString().Trim(); //邮箱 string email = dr["email"].ToString().Trim(); //采样日期 string samplingdate = dr["samplingdate"].ToString().Trim(); //区 string county = dr["county"].ToString().Trim(); #endregion DateTime datebirthday; bool datebirthdayb = DateTime.TryParse(birthday, out datebirthday); DateTime datesamplingdate; bool datesamplingdateb = DateTime.TryParse(samplingdate, out datesamplingdate); if ((birthday != string.Empty && !datebirthdayb) || (samplingdate != string.Empty && !datesamplingdateb)) { strMessage = ErrorCode.Rec_1013; break; } //检查单位是否在体检系统中有维护 string dictcustomerid = string.Empty; try { using (DataTable d = customerservice.CheckHasCustomer(dictcustomercode)) { if (d == null || d.Rows.Count == 0 || d.Rows.Count > 1) { strMessage = ErrorCode.Up_0011; break; } else { dictcustomerid = d.Rows[0][0].ToString(); } } } catch (Exception ee) { strMessage = ErrorCode.Up_0015 + " " + ee.Message; break; } #region 添加套餐 //查询分点+公用套餐 List <Dicttestitem> productlistTemp = new DicttestitemService().GetProduct(TypeParse.StrToDouble(dictcustomerid, 0)); List <Dicttestitem> productList = productlistTemp.Where <Dicttestitem>(c => c.Testcode == productTestCode && (c.Forsex == sex || c.Forsex == "B")).ToList <Dicttestitem>(); List <Dicttestitem> grouptestList = new List <Dicttestitem>(); Dicttestitem productinfo = null; if (productList.Count == 0) { strMessage = ErrorCode.Rec_1008; break; } else if (productList.Count > 1) { strMessage = ErrorCode.Rec_1009; break; } else { productinfo = productList.First <Dicttestitem>(); List <OrderRegister> _gridtestList = null; #region 添加套餐 string msg = registerservice.AddProduct(ref _gridtestList, sex, productinfo.Dicttestitemid, false, null, ref _productname, null); if (msg != string.Empty) { strMessage = ErrorCode.Rec_1017; break; } #endregion if (barcode != string.Empty && barcode.Length != 12)//条码号必须为12位数字 { strMessage = ErrorCode.Rec_1010; break; } if (barcode != string.Empty && barcode.Substring(barcode.Length - 2) != "00")//条码号必须以00结尾 { strMessage = ErrorCode.Rec_1011; break; } if (barcodeservice.CheckBarCode(barcode))//条码号已在系统中存在 { strMessage = ErrorCode.Rec_1012; break; } //套餐下组合项目 IEnumerable <Dictproductdetail> IEgroup = ProductDetail.Where <Dictproductdetail>(c => c.Productid == productinfo.Dicttestitemid); bool iscontinue = true; int count = IEgroup.Count <Dictproductdetail>(); int k = 0; foreach (Dictproductdetail item in IEgroup) { IEnumerable <Dicttestitem> IEgruptest = TestItemList.Where <Dicttestitem>(c => c.Dicttestitemid == item.Testgroupid); if (IEgruptest.Count() <= 0) { //没有找到套餐下组合 k++; continue; } Dicttestitem groupinfo = IEgruptest.First <Dicttestitem>(); //校验性别是否符合 string res = registerservice.checkSex(groupinfo.Dicttestitemid, sex); if (res != string.Empty) { //性别项目不合 strMessage = ErrorCode.Rec_1015; iscontinue = false; break; } groupinfo.Productid = productinfo.Dicttestitemid; groupinfo.Productname = productinfo.Testname; ///套餐名 groupinfo.IsActive = "1"; //是否停止测试 groupinfo.Isadd = "0"; ///是否追加 groupinfo.Billed = "0"; groupinfo.Sendbilled = "0"; groupinfo.Adduserid = null;//追加人ID if (barcode == string.Empty) { IEnumerable <Dicttestitem> IEtempbarcodeList = grouptestList.Where <Dicttestitem>(c => c.Tubegroup == groupinfo.Tubegroup); if (IEtempbarcodeList.Count() > 0) { groupinfo.Barcode = IEtempbarcodeList.First <Dicttestitem>().Barcode; } else { groupinfo.Barcode = registerservice.GetBarCode(); } } else { groupinfo.Barcode = barcode; } //获取外包客户 Dictproductdetail detail = ProductDetail.Where <Dictproductdetail>(c => c.Productid == productinfo.Dicttestitemid && c.Testgroupid == groupinfo.Dicttestitemid).First <Dictproductdetail>(); groupinfo.Sendoutcustomerid = detail.Sendoutcustomerid; grouptestList.Add(groupinfo); } if (!iscontinue) { continue; } else { if (k >= count) { strMessage = ErrorCode.Rec_1016; break; } } } #endregion #region 添加会员 Dictmember member = new Dictmember() { Realname = realname, Idnumber = idnumber, Nickname = realname, Sex = sex, Addres = address, Phone = phone, Mobile = mobile, Email = email }; if (datebirthdayb) { member.Birthday = datebirthday; } registerservice.checkmember(null, ref member); #endregion #region 添加订单 double year = 0, month = 0, day = 0; double hours = 0; double aged = 0; string agestr = age; bool ageb = double.TryParse(agestr, out aged); if (member.Birthday == null) { if (agestr != string.Empty && ageb) { year = aged; day = aged * 365; member.Birthday = datebirthday = DateTime.Now.AddDays((0 - day)); } else { strMessage = ErrorCode.Rec_1006; break; } } TimeSpan ts = DateTime.Now - Convert.ToDateTime(member.Birthday);//时间差 year = Math.Truncate((double)(ts.Days / 365)); month = (ts.Days % 365) / 30; day = (ts.Days % 365) % 30; hours = ts.TotalHours; Orders _orders = new Orders() { Ordernum = new ProRegisterService().GetOrderNum(), Dictmemberid = member.Dictmemberid, Dictcustomerid = Convert.ToDouble(dictcustomerid), Realname = realname, Sex = sex, Caculatedage = hours, Remarks = remark, Age = string.Format("{0}岁{1}月{2}日{3}时", year, month, day, 0), Enterby = "admin", Ordertestlst = _productname + ",", Dictlabid = Convert.ToDouble(dictlabid), Ordersource = "1", Ismarried = ismarried == "未婚" ? "0" : (ismarried == "已婚" ? "1" : "2"), Section = section, Status = ((int)daan.service.common.ParamStatus.OrdersStatus.BarCodePrint).ToString(), Province = province, City = city, County = county }; if (datesamplingdateb) { _orders.SamplingDate = datesamplingdate; } string errstr = string.Empty; bool b = registerservice.insertUpdateOrders("易感基因对接订单", "", true, productList, grouptestList, member, _orders, "", ref errstr); if (!b) { strMessage = String.Format("{0} {1}", ErrorCode.Rec_1018, errstr); } #endregion } return(strMessage); }
private int SizeSort(CacheInfo _a, CacheInfo _b) { return (_a.Size < _b.Size) ? -1 : 1; }
protected void Page_Load(object sender, EventArgs e) { string sTranId = Request.QueryString["vpc_MerchTxnRef"]; if (string.IsNullOrEmpty(sTranId)) { Response.Redirect("/SmartLink/", true); } //Check info Smartlink Hashtable hash = new Hashtable(); foreach (String key in Request.QueryString.AllKeys) { if (key.StartsWith("vpc_")) { hash.Add(key, Request.QueryString[key]); } } bool isEmptysecureSecret; bool isValidsecureHash = SmartLinkHelper.checkSum(hash, out isEmptysecureSecret); if (isEmptysecureSecret) { Response.Redirect("/SmartLink/", true); } if (!isValidsecureHash) { Response.Redirect("/SmartLink/", true); } //check info AV CacheInfo oCache = (CacheInfo)CacheProvider.Get(string.Format(KeyCache.KeyUserSmartlink, sTranId)); if (oCache == null) { Response.Redirect("/SmartLink/", true); } string sDerection = ""; SmartlinkQueryInfo oQueryInfo = new SmartlinkQueryInfo() { CreateDate = DateTime.Now }; try { string sStatus = SmartLinkHelper.GetQuery(sTranId, ref oQueryInfo);//chư thấy trả về if (!string.IsNullOrEmpty(sStatus)) { String[] arr = sStatus.Split('&'); foreach (String item in arr) { String[] temp = item.Split('='); if ("vpc_DRExists".ToUpper().Equals(temp[0].ToUpper())) { oQueryInfo.vpc_DRExists = temp[1]; } if ("vpc_FoundMultipleDRs".ToUpper().Equals(temp[0].ToUpper())) { oQueryInfo.vpc_FoundMultipleDRs = temp[1]; } if ("vpc_Message".ToUpper().Equals(temp[0].ToUpper())) { oQueryInfo.vpc_Message = temp[1]; } if ("vpc_SecureHash".ToUpper().Equals(temp[0].ToUpper())) { oQueryInfo.vpc_SecureHash = temp[1]; } if ("vpc_TxnResponseCode".ToUpper().Equals(temp[0].ToUpper())) { oQueryInfo.vpc_TxnResponseCode = temp[1]; } } //giao dịch thành công if (oQueryInfo.vpc_TxnResponseCode == "0") { //submit voucher SubmitVoucherInfo oSVInfo = new SubmitVoucherInfo() { GatePayId = Config.ClientIdSmartLink, UserId = oCache.User.subnum, Amount = int.Parse(oCache.Voucher.vouchervalue), CreateDate = DateTime.Now, TransId = sTranId }; try { WSClient wsclient = new WSClient(); var cred = new credential { clientId = Config.ClientIdSmartLink }; var wsResult = wsclient.submitVoucher(cred, oSVInfo.UserId, oSVInfo.Amount.ToString(), oSVInfo.TransId); oSVInfo.returnCode = wsResult.returnCode; oSVInfo.returnCodeDescription = wsResult.returnCodeDescription; string sResultDate = XMLReader.ReadResultVocher(wsResult.responseData);//dt oSVInfo.responseData = sResultDate; oSVInfo.signature = wsResult.signature; if (oSVInfo.returnCode == "") { Session[Config.GetSessionsResultDate] = sResultDate;//ss sDerection = "/SmartLink/#" + sTranId + "|T"; } else { //Session[Config.GetSessionsResultFail] = wsResult.returnCodeDescription;//ss Session[Config.GetSessionsResultFail] = "Giao dịch không thành công"; sDerection = "/SmartLink/#" + sTranId + "|F|Y"; } } catch (Exception ex) { //log error Session[Config.GetSessionsResultFail] = ex.Message; oSVInfo.returnCode = ex.GetHashCode().ToString(); oSVInfo.returnCodeDescription = ex.Message; sDerection = "/SmartLink/#" + sTranId + "|F|Y"; } finally { SubmitVoucherData.instance.Add(oSVInfo); //Response.Redirect(sDerection); } } else { //Session[Config.GetSessionsResultFail] = SmartLinkHelper.getResponseDescription(oQueryInfo.vpc_TxnResponseCode??""); Session[Config.GetSessionsResultFail] = "Giao dịch không thành công"; sDerection = "/SmartLink/#" + sTranId + "|F"; } } else { sDerection = "/SmartLink/#" + sTranId + "|F"; } } catch (Exception ex) { oQueryInfo.vpc_TxnResponseCode = ex.GetHashCode().ToString(); oQueryInfo.vpc_Message = ex.Message; sDerection = "/SmartLink/#" + sTranId + "|F"; } finally { CacheProvider.Remove(string.Format(KeyCache.KeyUserSmartlink, sTranId)); SmartlinkQueryData.instance.Add(oQueryInfo); if (sDerection != "") { Response.Redirect(sDerection); } } }
public bool CreateMessage301(string orderNo) { bool success = true; OrderHead orderHead = null; List <OrderList> orderLists = null; XElement xele = null; XNamespace ns = null; MessageSql mssql = null; string logisticsNo = null; string logisticsCode = null; MessageService msService = null; try { orderHead = new OrderHead(); orderLists = new List <OrderList>(); mssql = new MessageSql(); mssql.QueryData301(orderNo, ref orderHead, ref orderLists, ref logisticsNo, ref logisticsCode); if (orderHead.guid != new Guid()) { ns = "http://www.chinaport.gov.cn/ceb"; xele = new XElement(ns + "CEB301Message"); xele.SetAttributeValue(XNamespace.Xmlns + "ceb", ns); xele = orderHead.ToXElememt(xele, ns); foreach (var a in orderLists) { xele = a.ToXElememt(xele, ns); } FileUtilities.CreateFolder(ConfigurationInfo.PathSend); string destPath = FileUtilities.GetNewFolderName(true, ConfigurationInfo.PathBackUp, "301") + "\\" + FileUtilities.GetNewFileName(orderNo) + ".xml"; msService = new MessageService(); success = msService.DealMessage301(orderNo, orderHead.orderNo, logisticsNo, false, true, orderHead.guid.ToString(), destPath, logisticsCode); if (!success) { destPath = FileUtilities.GetNewFolderName(true, ConfigurationInfo.PathBackUpError, "301") + "\\" + FileUtilities.GetNewFileName(orderNo) + ".xml"; } xele.Save(ConfigurationInfo.PathSend + "\\" + FileUtilities.GetNewFileName(orderNo) + ".xml"); xele.Save(destPath); if (CheckNeedSendLogistics(logisticsCode)) { MessageCache.AddMessageCache("501_" + orderHead.orderNo, CacheInfo.SetCacheInfo("501", Utilities.SetArrayList(orderHead.orderNo, logisticsCode))); CacheInfo cache503R = CacheInfo.SetCacheInfo("503R", Utilities.SetArrayList(logisticsNo, logisticsCode)); cache503R.createTime = DateTime.Now.AddMinutes(1); MessageCache.AddMessageCache("503R_" + logisticsNo, cache503R); CacheInfo cache601 = CacheInfo.SetCacheInfo("601", Utilities.SetArrayList(logisticsNo, logisticsCode)); cache601.createTime = DateTime.Now.AddMinutes(2); MessageCache.AddMessageCache("601_" + logisticsNo, cache601); } } else { Logs.Info("Does not exist in database: " + orderNo); success = false; } } catch (Exception ex) { Logs.Error("Create301Message Exception:" + ex.ToString()); success = false; } return(success); }
public static PyObject GetUserCacheData(int user, string name) { if (LoadUserCacheFor(user, name) == false) { return null; } PyTuple cache = userCacheData[user][name]; if (cache == null) { return null; } CacheInfo data = new CacheInfo(); data.objectID = new PyString(name); data.cacheTime = cache.Items[1].As<PyLongLong>().Value; data.nodeID = cache.Items[2].As<PyIntegerVar>().Value; data.version = cache.Items[3].As<PyIntegerVar>().Value; // This is a CRC of the buffer return data.Encode(); }
public bool RegisterCache(string cacheId, CacheServerConfig config, string partId, bool overwrite, bool hotApply, bool isLocalNode) { if (cacheId == null) throw new ArgumentNullException("cacheId"); //We load configuration before applying the new changes to preserve some old values in the config. cacheId = cacheId.ToLower(); CacheInfo cacheInfo = null; _rwLock.AcquireWriterLock(Timeout.Infinite); try { if (s_partitionedCaches.Contains(cacheId.ToLower())) throw new Runtime.Exceptions.ManagementException("A cache with same cacheId already exists"); if (s_caches.Contains(cacheId.ToLower())) { if (!overwrite) { return false; } cacheInfo = (CacheInfo)s_caches[cacheId.ToLower()]; //(WARNING) This code is here to save the old value of connection-retries //in the cluster configuration to avoid override by NCManager. //This code should be removed after these options appears on UI. //props = GetChangedConfigForTemp(cacheId.ToLower(), cacheInfo.CacheProps, props); } else { ///This is until we change the use of properties in Cache ///from props stirng or hashtable to Dom /// string props = GetProps(config); ClientConfigManager.LocalCacheId = this.LocalCacheIP; ClientConfigManager.AddCache(cacheId, config); cacheInfo = new CacheInfo(); cacheInfo.Cache = new LeasedCache(props); s_caches[cacheId.ToLower()] = cacheInfo; } cacheInfo.CacheProps = config; if (hotApply && cacheInfo != null && cacheInfo.Cache != null && cacheInfo.Cache.IsRunning) { CacheConfig cc = CacheConfig.FromConfiguration(config); Alachisoft.NCache.Caching.Util.HotConfig hotConfig = new Alachisoft.NCache.Caching.Util.HotConfig(); hotConfig.IsErrorLogsEnabled = cc.IsErrorLogsEnabled; hotConfig.IsDetailedLogsEnabled = cc.IsDetailedLogsEnabled; hotConfig.CacheMaxSize = cc.CacheMaxSize; hotConfig.CleanInterval = cc.CleanInterval; hotConfig.EvictRatio = cc.EvictRatio; cacheInfo.Cache.ApplyHotConfiguration(hotConfig); } SaveConfiguration(); } catch (Exception) { throw; } finally { _rwLock.ReleaseWriterLock(); } return true; }
/// <summary> /// The public constructor for the DM637x device AIS generator. /// The constructor is where the device differentiation is defined. /// </summary> public AISGen_DM643x() { // Define the device name - used for default file names devNameShort = "DM643x"; devNameLong = "TMS320DM643x"; // Define the device caches (they are considered internal memories since // bootrom turns off caching) - two identical sets since the memory map // has the caches at two locations Cache = new CacheInfo[6]; Cache[0].level = CacheLevel.L2; Cache[0].type = CacheType.Program | CacheType.Data; Cache[0].startAddr = 0x00800000; Cache[0].size = 0x20000; Cache[1].level = CacheLevel.L1; Cache[1].type = CacheType.Program; Cache[1].startAddr = 0x00E08000; Cache[1].size = 0x8000; Cache[2].level = CacheLevel.L1; Cache[2].type = CacheType.Data; Cache[2].startAddr = 0x00F10000; Cache[2].size = 0x8000; Cache[3].level = CacheLevel.L2; Cache[3].type = CacheType.Program | CacheType.Data; Cache[3].startAddr = 0x10800000; Cache[3].size = 0x20000; Cache[4].level = CacheLevel.L1; Cache[4].type = CacheType.Program; Cache[4].startAddr = 0x10E08000; Cache[4].size = 0x8000; Cache[5].level = CacheLevel.L1; Cache[5].type = CacheType.Data; Cache[5].startAddr = 0x10F10000; Cache[5].size = 0x8000; // Define the IDMA channels for internal memory transfers IDMA = new IDMARegisters[2]; IDMA[0] = new IDMARegisters(0, 0x01820000); IDMA[1] = new IDMARegisters(1, 0x01820100); // Define DM643x ROM boot loader functions ROMFunc = new ROMFunction[4]; ROMFunc[0].funcName = AISGen_DM643x.ROMFunctionNames.PLLConfig; ROMFunc[0].iniSectionName = "PLL"; ROMFunc[0].numParams = 3; ROMFunc[0].paramNames = new String[3] { "PLLM", "PLLDIV1", "CLK_SRC" }; ROMFunc[1].funcName = AISGen_DM643x.ROMFunctionNames.EMIFConfig; ROMFunc[1].iniSectionName = "EMIF"; ROMFunc[1].numParams = 5; ROMFunc[1].paramNames = new String[5] { "AB1CR", "AB2CR", "AB3CR", "AB4CR", "NANDFCR" }; ROMFunc[2].funcName = AISGen_DM643x.ROMFunctionNames.DDRConfig; ROMFunc[2].iniSectionName = "DDR"; ROMFunc[2].numParams = 9; ROMFunc[2].paramNames = new String[9] { "DDRPLLM", "DDRCLKDIV", "VPFECLKDIV", "CLK_SRC", "DDRPHYCR", "SDBCR", "SDTIMR", "SDTIMR2", "SDRCR" }; ROMFunc[3].funcName = AISGen_DM643x.ROMFunctionNames.PINMUXConfig; ROMFunc[3].iniSectionName = "PINMUX"; ROMFunc[3].numParams = 2; ROMFunc[3].paramNames = new String[2] { "PINMUX0", "PINMUX1" }; // Configuration info for the AISExtras functions (provided in AISExtraFileName COFF file) AISExtraFileName = "AISExtra_" + devNameShort + ".out"; AISExtraFunc = new AISExtraFunction[1]; AISExtraFunc[0].funcName = AISGen_DM643x.AISExtraFunctionNames.LPSCTransition; AISExtraFunc[0].iniSectionName = "LPSC"; AISExtraFunc[0].numParams = 2; AISExtraFunc[0].paramNames = new String[2] { "MODNUM", "STATE" }; AISExtraFunc[0].isInitFunc = true; // DM643x is little endian devEndian = Endian.LittleEndian; // DM643x AIS data is big endian (this is important for CRC calcs) devAISEndian = Endian.BigEndian; // INI file describes ROM function parameters devINIFileName = devNameShort + ".ini"; // Default settings for UARTSendDONE function UARTSendDONEAddr = 0x0; SendUARTSendDONE = false; // Default boot mode (can be changed from INI file) for this device bootMode = BootModes.NONE; // Create default CRC object for this device devCRC = new CRC32(0x04C11DB7, 0x00000000, 0x00000000, false, 1, UtilLib.CRC.CRCType.INCREMENTAL, UtilLib.CRC.CRCCalcMethod.BITWISE); crcType = CRCCheckType.NO_CRC; }
/// <summary/> public CacheUndoAction(IRealDataCache cache, CacheInfo before, CacheInfo after) { m_Cache = cache; m_Before = before; m_After = after; }
/// <param name="defaultCacheLifespan">How long items should be cached by default</param> /// <param name="cache">The cache to use, default is a thread safe dictionary</param> public RedisCachingService(ICacheProviderSettings settings, ILoggingService loggingService, CacheInfo cacheInfo = null, bool useStaticProvider = true) { _settings = settings; _cacheInfo = cacheInfo ?? _settings.ServiceSettings.ProviderInfo; _loggingService = loggingService; UseStaticProvider = useStaticProvider; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Caches the boolean prop. /// </summary> /// <param name="hvo">The hvo.</param><param name="tag">The tag.</param><param name="value">if set to <c>true</c> [value].</param> /// <remarks> /// IVwCacheDa method /// </remarks> /// ------------------------------------------------------------------------------------ public void CacheBooleanProp(int hvo, int tag, bool value) { var before = new CacheInfo(ObjType.Bool, hvo, tag, m_cache.get_Prop(hvo, tag)); var after = new CacheInfo(ObjType.Bool, hvo, tag, value); ActionHandler.AddAction(new CacheUndoAction(m_cache, before, after)); m_cache.CacheBooleanProp(hvo, tag, value); }
private static async Task <int> ExecuteMultiImplAsync(IDbConnection cnn, CommandDefinition command, IEnumerable multiExec) { bool isFirst = true; int total = 0; bool wasClosed = cnn.State == ConnectionState.Closed; try { if (wasClosed) { await((DbConnection)cnn).OpenAsync(command.CancellationToken).ConfigureAwait(false); } CacheInfo info = null; string masterSql = null; if ((command.Flags & CommandFlags.Pipelined) != 0) { const int MAX_PENDING = 100; var pending = new Queue <AsyncExecState>(MAX_PENDING); DbCommand cmd = null; try { foreach (var obj in multiExec) { if (isFirst) { isFirst = false; cmd = (DbCommand)command.SetupCommand(cnn, null); masterSql = cmd.CommandText; var identity = new Identity(command.CommandText, cmd.CommandType, cnn, null, obj.GetType(), null); info = GetCacheInfo(identity, obj, command.AddToCache); } else if (pending.Count >= MAX_PENDING) { var recycled = pending.Dequeue(); total += await recycled.Task.ConfigureAwait(false); cmd = recycled.Command; cmd.CommandText = masterSql; // because we do magic replaces on "in" etc cmd.Parameters.Clear(); // current code is Add-tastic } else { cmd = (DbCommand)command.SetupCommand(cnn, null); } info.ParamReader(cmd, obj); var task = cmd.ExecuteNonQueryAsync(command.CancellationToken); pending.Enqueue(new AsyncExecState(cmd, task)); cmd = null; // note the using in the finally: this avoids a double-dispose } while (pending.Count != 0) { var pair = pending.Dequeue(); using (pair.Command) { } // dispose commands total += await pair.Task.ConfigureAwait(false); } } finally { // this only has interesting work to do if there are failures using (cmd) { } // dispose commands while (pending.Count != 0) { // dispose tasks even in failure using (pending.Dequeue().Command) { } // dispose commands } } } else { using (var cmd = (DbCommand)command.SetupCommand(cnn, null)) { foreach (var obj in multiExec) { if (isFirst) { masterSql = cmd.CommandText; isFirst = false; var identity = new Identity(command.CommandText, cmd.CommandType, cnn, null, obj.GetType(), null); info = GetCacheInfo(identity, obj, command.AddToCache); } else { cmd.CommandText = masterSql; // because we do magic replaces on "in" etc cmd.Parameters.Clear(); // current code is Add-tastic } info.ParamReader(cmd, obj); total += await cmd.ExecuteNonQueryAsync(command.CancellationToken).ConfigureAwait(false); } } } command.OnCompleted(); } finally { if (wasClosed) { cnn.Close(); } } return(total); }
/// <summary> /// Member CacheUnicodeProp /// </summary> /// <param name="obj">obj</param><param name="tag">tag</param><param name="val">val</param><param name="cch">cch</param> /// <remarks> /// IVwCacheDa method /// </remarks> public void CacheUnicodeProp(int obj, int tag, string val, int cch) { var before = new CacheInfo(ObjType.String, obj, tag, m_cache.get_Prop(obj, tag)); var after = new CacheInfo(ObjType.String, obj, tag, val); ActionHandler.AddAction(new CacheUndoAction(m_cache, before, after)); m_cache.CacheUnicodeProp(obj, tag, val, cch); }
public RedisCache(CacheInfo cacheInfo) { _cacheInfo = cacheInfo; }
/// <summary> /// Member CacheUnknown /// </summary> /// <param name="obj">obj</param><param name="tag">tag</param><param name="unk">unk</param> /// <remarks> /// IVwCacheDa method /// </remarks> public void CacheUnknown(int obj, int tag, object unk) { var before = new CacheInfo(ObjType.Object, obj, tag, m_cache.get_Prop(obj, tag)); var after = new CacheInfo(ObjType.Object, obj, tag, unk); ActionHandler.AddAction(new CacheUndoAction(m_cache, before, after)); m_cache.CacheUnknown(obj, tag, unk); }
private static IObservable <T> ExecuteReader <T>(DbDataReader reader, Identity identity, CacheInfo info) { var tuple = info.Deserializer; int hash = GetColumnHash(reader); if (tuple.Func == null || tuple.Hash != hash) { tuple = info.Deserializer = new DeserializerState(hash, GetDeserializer(typeof(T), reader, 0, -1, false)); SetQueryCache(identity, info); } var func = tuple.Func; return(Observable.Create <T>(async observer => { while (await reader.ReadAsync()) { observer.OnNext((T)func(reader)); } }).Publish().RefCount()); }
/// <summary> /// Member CacheStringProp /// </summary> /// <param name="obj">obj</param><param name="tag">tag</param><param name="tss">_tss</param> /// <remarks> /// IVwCacheDa method /// </remarks> public void CacheStringProp(int obj, int tag, ITsString tss) { var before = new CacheInfo(ObjType.BasicTsString, obj, tag, m_cache.get_Prop(obj, tag)); var after = new CacheInfo(ObjType.BasicTsString, obj, tag, tss); ActionHandler.AddAction(new CacheUndoAction(m_cache, before, after)); m_cache.CacheStringProp(obj, tag, tss); }
public override void Process(ProcessContext context) { MvcEventPublisher.Instance.BeginProcessAction(context.ctx); if (context.ctx.utils.isSkipCurrentProcessor()) { return; } MvcContext ctx = context.ctx; ControllerBase controller = context.getController(); // 检查缓存 CacheInfo ci = CacheInfo.Init(ctx); Object cacheContent = ci.CheckCache(); if (cacheContent != null) { logger.Info("load from actionCache=" + ci.CacheKey); context.setContent(cacheContent.ToString()); getPageMetaFromCache(ctx, ci.CacheKey); return; } MethodInfo actionMethod = ctx.ActionMethodInfo; // context.getActionMethod(); // 设值模板并载入全局变量 setControllerView(controller, actionMethod); // 运行并处理post值 ActionRunner.runAction(ctx, controller, actionMethod, controller.utils.runAction); String actionContent = controller.utils.getActionResult(); // 加入缓存 if (ci.IsActionCache) { ci.AddContentToCache(actionContent); // 加入PageMeta addPageMetaToCache(ctx, ci.CacheKey); } actionContent = PostValueProcessor.ProcessPostValue(actionContent, ctx); if (ctx.utils.isAjax) { context.showEnd(actionContent); } else if (ctx.utils.isFrame()) { int intNoLayout = ctx.utils.getNoLayout(); if (intNoLayout == 0) { String content = MvcUtil.getFrameContent(actionContent); context.showEnd(content); } else { context.setContent(actionContent); } } else if (ctx.utils.isEnd()) { context.showEnd(actionContent); } else { context.setContent(actionContent); } updateActionCache(ctx); MvcEventPublisher.Instance.EndProcessAction(context.ctx); }
/// <summary> /// Member CacheVecProp /// </summary> /// <param name="obj">obj</param><param name="tag">tag</param><param name="rghvo">rghvo</param><param name="chvo">chvo</param> public void CacheVecProp(int obj, int tag, int[] rghvo, int chvo) { var before = new CacheInfo(ObjType.Vector, obj, tag, m_cache.get_Prop(obj, tag)); var after = new CacheInfo(ObjType.Vector, obj, tag, rghvo); ActionHandler.AddAction(new CacheUndoAction(m_cache, before, after)); m_cache.CacheVecProp(obj, tag, rghvo, chvo); }
protected void Page_Load(object sender, EventArgs e) { string sTranId = Request.QueryString["code"]; if (string.IsNullOrEmpty(sTranId)) { Response.Redirect("/SmartLink/", true); } CacheInfo oCache = (CacheInfo)CacheProvider.Get(string.Format(KeyCache.KeyUserSmartlink, sTranId)); if (oCache == null) { Response.Redirect("/SmartLink/", true); } SmartlinkQueryInfo oQueryInfo = new SmartlinkQueryInfo() { CreateDate = DateTime.Now }; try { string sStatus = SmartLinkHelper.GetQuery(sTranId, ref oQueryInfo); if (!string.IsNullOrEmpty(sStatus)) { String[] arr = sStatus.Split('&'); foreach (String item in arr) { String[] temp = item.Split('='); if ("vpc_DRExists".ToUpper().Equals(temp[0].ToUpper())) { oQueryInfo.vpc_DRExists = temp[1]; } if ("vpc_FoundMultipleDRs".ToUpper().Equals(temp[0].ToUpper())) { oQueryInfo.vpc_FoundMultipleDRs = temp[1]; } if ("vpc_Message".ToUpper().Equals(temp[0].ToUpper())) { oQueryInfo.vpc_Message = temp[1]; } if ("vpc_SecureHash".ToUpper().Equals(temp[0].ToUpper())) { oQueryInfo.vpc_SecureHash = temp[1]; } if ("vpc_TxnResponseCode".ToUpper().Equals(temp[0].ToUpper())) { oQueryInfo.vpc_TxnResponseCode = temp[1]; } } } } catch (Exception ex) { oQueryInfo.vpc_TxnResponseCode = ex.GetHashCode().ToString(); oQueryInfo.vpc_Message = ex.Message; //throw; } finally { CacheProvider.Remove(string.Format(KeyCache.KeyUserSmartlink, sTranId)); SmartlinkQueryData.instance.Add(oQueryInfo); //Session[Config.GetSessionsResultFail] =oQueryInfo.vpc_TxnResponseCode==null?"Giao dịch bị hủy bỏ": SmartLinkHelper.getResponseDescription(oQueryInfo.vpc_TxnResponseCode); Session[Config.GetSessionsResultFail] = "Giao dịch không thành công"; Response.Redirect("/SmartLink/#" + sTranId + "|F", false); } }
private static bool CacheReadable(CacheInfo dom) { return (dom != null && dom.Data != null && dom.Data.CanRead); }
public void Init(IDbContextBase context, IQueryable query, CacheInfo cacheInfo) { }