public override ServiceMethodList GetServiceMethods(DbSource dbSource) { VerifyArgument.IsNotNull("dbSource", dbSource); // Check the cache for a value ;) ServiceMethodList cacheResult; if (!dbSource.ReloadActions) { if (GetCachedResult(dbSource, out cacheResult)) { return(cacheResult); } } // else reload actions ;) var serviceMethods = new ServiceMethodList(); // // Get stored procedures and functions for this database source // using (var server = CreateDbServer(dbSource)) { server.Connect(dbSource.ConnectionString); } // Add to cache ;) TheCache.AddOrUpdate(dbSource.ConnectionString, serviceMethods, (s, list) => serviceMethods); return(GetCachedResult(dbSource, out cacheResult) ? cacheResult : serviceMethods); }
public override ServiceMethodList GetServiceMethods(DbSource dbSource) { VerifyArgument.IsNotNull("dbSource", dbSource); // Check the cache for a value ;) ServiceMethodList cacheResult; if (!dbSource.ReloadActions) { if (GetCachedResult(dbSource, out cacheResult)) { return(cacheResult); } } // else reload actions ;) var serviceMethods = new ServiceMethodList(); // // Function to handle procedures returned by the data broker // Func <IDbCommand, IList <IDbDataParameter>, IList <IDbDataParameter>, string, string, bool> procedureFunc = (command, parameters, outparameters, helpText, executeAction) => { var serviceMethod = CreateServiceMethod(command, parameters, outparameters, helpText, executeAction); serviceMethods.Add(serviceMethod); return(true); }; // // Function to handle functions returned by the data broker // Func <IDbCommand, IList <IDbDataParameter>, IList <IDbDataParameter>, string, string, bool> functionFunc = (command, parameters, outparameters, helpText, executeAction) => { var serviceMethod = CreateServiceMethod(command, parameters, outparameters, helpText, executeAction); serviceMethods.Add(serviceMethod); return(true); }; // // Get stored procedures and functions for this database source // using (var server = CreateDbServer(dbSource)) { server.Connect(dbSource.ConnectionString); server.FetchStoredProcedures(procedureFunc, functionFunc, false, dbSource.DatabaseName); } // Add to cache ;) TheCache.AddOrUpdate(dbSource.ConnectionString, serviceMethods, (s, list) => serviceMethods); return(GetCachedResult(dbSource, out cacheResult) ? cacheResult : serviceMethods); }
/// <summary> /// 保存视图状态 /// </summary> public override void Save() { Pair pair = new Pair(); if (base.ViewState != null) { pair.First = base.ViewState; } if (base.ControlState != null) { pair.Second = base.ControlState; } // //TheCache.Insert("__Houfeng_AjaxEngine_" + this.GetUniqueKey(), pair); TheCache.Insert("__Houfeng_AjaxEngine_" + this.GetUniqueKey(), pair, null, DateTime.Now.AddMinutes(this.Timeout), Cache.NoSlidingExpiration, CacheItemPriority.Default, null); }
public override ServiceMethodList GetServiceMethods(DbSource dbSource) { VerifyArgument.IsNotNull("dbSource", dbSource); ServiceMethodList cacheResult; if (!dbSource.ReloadActions && GetCachedResult(dbSource, out cacheResult)) { return(cacheResult); } var serviceMethods = new ServiceMethodList(); Func <IDbCommand, IList <IDbDataParameter>, IList <IDbDataParameter>, string, string, bool> procedureFunc = (command, parameters, outparameters, helpText, executeAction) => { var serviceMethod = CreateServiceMethod(command, parameters, outparameters, helpText, executeAction); serviceMethods.Add(serviceMethod); return(true); }; Func <IDbCommand, IList <IDbDataParameter>, IList <IDbDataParameter>, string, string, bool> functionFunc = (command, parameters, outparameters, helpText, executeAction) => { var serviceMethod = CreateServiceMethod(command, parameters, outparameters, helpText, executeAction); serviceMethods.Add(serviceMethod); return(true); }; using (var server = CreateDbServer(dbSource)) { server.Connect(dbSource.ConnectionString); server.FetchStoredProcedures(procedureFunc, functionFunc, false, dbSource.DatabaseName); } TheCache.AddOrUpdate(dbSource.ConnectionString, serviceMethods, (s, list) => serviceMethods); return(GetCachedResult(dbSource, out cacheResult) ? cacheResult : serviceMethods); }
public static RunStatus InteractionMovement(object ret) { //Move to nice open space! if (!ZetaDia.IsInGame || ZetaDia.IsLoadingWorld || ZetaDia.Me == null || ZetaDia.Me.CommonData == null) { Logger.DBLog.InfoFormat("[Funky] Town Run Behavior Failed! (Not In Game/Invalid Actor/misc)"); return(RunStatus.Failure); } Act curAct = ZetaDia.CurrentAct; if (curAct == Act.Invalid || curAct == Act.OpenWorld || curAct == Act.Test) { curAct = TheCache.FindActByLevelID(FunkyGame.Hero.iCurrentLevelID); } var vectorLocation = ReturnMovementVector(curAct); Vector3 vectorPlayerPosition = ZetaDia.Me.Position; float fDistance = Vector3.Distance(vectorPlayerPosition, vectorLocation); if (fDistance > 7.5f) { //Wait until we are not moving to send click again.. if (FunkyGame.Hero.IsMoving) { return(RunStatus.Running); } Navigator.PlayerMover.MoveTowards(vectorLocation); return(RunStatus.Running); } iCurrentItemLoops = 0; RandomizeTheTimer(); Logger.DBLog.Info("Interaction Town Run Movement Finished."); return(RunStatus.Success); }
/// <summary> /// Import an IFC file into a given document for Reference only. /// </summary> /// <param name="document">The host document for the import.</param> /// <param name="origFullFileName">The full file name of the document.</param> /// <param name="options">The list of configurable options for this import.</param> public void ReferenceIFC(Document document, string origFullFileName, IDictionary <String, String> options) { // We need to generate a local file name for all of the intermediate files (the log file, the cache file, and the shared parameters file). string localFileName = ImporterIFCUtils.GetLocalFileName(document, origFullFileName); if (localFileName == null) { throw new InvalidOperationException("Could not generate local file name for: " + origFullFileName); } // An early check, based on the options set - if we are allowed to use an up-to-date existing file on disk, use it. // It is possible that the log file may have been created in CreateImporter above, // if it is used by an external developer. if (TheLog == null) { m_ImportLog = IFCImportLog.CreateLog(localFileName, "log.html", !m_ImportOptions.DisableLogging); } Document originalDocument = document; Document ifcDocument = null; if (TheOptions.Action == IFCImportAction.Link) { string linkedFileName = IFCImportFile.GetRevitFileName(localFileName); ifcDocument = LoadOrCreateLinkDocument(originalDocument, linkedFileName); } else { ifcDocument = originalDocument; } bool useCachedRevitFile = DocumentUpToDate(ifcDocument, localFileName); // In the case where the document is already opened as a link, but it has been updated on disk, // give the user a warning and use the cached value. if (!useCachedRevitFile && ifcDocument.IsLinked) { useCachedRevitFile = true; Importer.AddDelayedLinkError(BuiltInFailures.ImportFailures.IFCCantUpdateLinkedFile); } if (!useCachedRevitFile) { m_ImportCache = IFCImportCache.Create(ifcDocument, localFileName); // Limit creating the cache to Link, but may either remove limiting or make it more restrict (reload only) later. if (TheOptions.Action == IFCImportAction.Link) { TheCache.CreateExistingElementMaps(ifcDocument); } // TheFile will contain the same value as the return value for this function. IFCImportFile.Create(localFileName, m_ImportOptions, ifcDocument); } if (useCachedRevitFile || IFCImportFile.TheFile != null) { IFCImportFile theFile = IFCImportFile.TheFile; if (theFile != null) { if (theFile.IFCProject != null) { IFCObjectDefinition.CreateElement(ifcDocument, theFile.IFCProject); } // Also process any other entities to create. foreach (IFCObjectDefinition objDef in IFCImportFile.TheFile.OtherEntitiesToCreate) { IFCObjectDefinition.CreateElement(ifcDocument, objDef); } theFile.EndImport(ifcDocument, localFileName); } if (TheOptions.Action == IFCImportAction.Link) { // If we have an original Revit link file name, don't create a new RevitLinkType - // we will use the existing one. bool useExistingType = (TheOptions.RevitLinkFileName != null); ElementId revitLinkTypeId = IFCImportFile.LinkInFile(origFullFileName, localFileName, ifcDocument, originalDocument, useExistingType, !useCachedRevitFile); } } if (m_ImportCache != null) { m_ImportCache.Reset(ifcDocument); } }
/// <summary> /// Import an IFC file into a given document for Reference only. /// </summary> /// <param name="document">The host document for the import.</param> /// <param name="fullFileName">The full file name of the document.</param> /// <param name="options">The list of configurable options for this import.</param> public void ReferenceIFC(Document document, string fullFileName, IDictionary <String, String> options) { // An early check, based on the options set - if we are allowed to use an up-to-date existing file on disk, use it. m_ImportLog = IFCImportLog.CreateLog(fullFileName, "log.html"); Document originalDocument = document; Document ifcDocument = null; if (TheOptions.Action == IFCImportAction.Link) { string linkedFileName = IFCImportFile.GetRevitFileName(fullFileName); ifcDocument = LoadOrCreateLinkDocument(originalDocument, linkedFileName); if (ifcDocument == null) { return; } } else { ifcDocument = originalDocument; } bool useCachedRevitFile = DocumentUpToDate(ifcDocument, fullFileName); // In the case where the document is already opened as a link, but it has been updated on disk, // give the user a warning and use the cached value. if (!useCachedRevitFile && ifcDocument.IsLinked) { useCachedRevitFile = true; Importer.AddDelayedLinkError(BuiltInFailures.ImportFailures.IFCCantUpdateLinkedFile); } if (!useCachedRevitFile) { m_ImportCache = IFCImportCache.Create(ifcDocument, fullFileName); // Limit creating the cache to Link, but may either remove limiting or make it more restrict (reload only) later. if (TheOptions.Action == IFCImportAction.Link) { TheCache.CreateExistingElementMaps(ifcDocument); } // TheFile will contain the same value as the return value for this function. IFCImportFile.Create(fullFileName, m_ImportOptions, ifcDocument); } if (useCachedRevitFile || IFCImportFile.TheFile != null) { IFCImportFile theFile = IFCImportFile.TheFile; if (theFile != null) { if (theFile.IFCProject != null) { IFCObjectDefinition.CreateElement(ifcDocument, theFile.IFCProject); } // Also process any other entities to create. foreach (IFCObjectDefinition objDef in IFCImportFile.TheFile.OtherEntitiesToCreate) { IFCObjectDefinition.CreateElement(ifcDocument, objDef); } theFile.EndImport(ifcDocument, fullFileName); } if (TheOptions.Action == IFCImportAction.Link) { // If we have an original Revit link file name, don't create a new RevitLinkType - // we will use the existing one. bool useExistingType = (TheOptions.RevitLinkFileName != null); ElementId revitLinkTypeId = IFCImportFile.LinkInFile(fullFileName, ifcDocument, originalDocument, useExistingType, !useCachedRevitFile); } } if (m_ImportCache != null) { m_ImportCache.Reset(ifcDocument); } }
public void ImportIFC(ImporterIFC importer) { TheImporter = this; IDictionary <String, String> options = importer.GetOptions(); TheOptions = m_ImportOptions = IFCImportOptions.Create(options); // An early check, based on the options set - if we are allowed to use an up-to-date existing file on disk, use it. try { string revitFileName = IFCImportFile.GetRevitFileName(importer.FullFileName); if (!TheOptions.ForceImport && !NeedsReload(importer.FullFileName, revitFileName)) { return; } // Clear the category mapping table, to force reload of options. IFCCategoryUtil.Clear(); if (TheOptions.Intent != IFCImportIntent.Reference) { IFCImportFile.Import(importer); } else { Document originalDocument = importer.Document; Document ifcDocument = null; if (TheOptions.Action == IFCImportAction.Link) { string linkedFileName = IFCImportFile.GetRevitFileName(importer.FullFileName); ifcDocument = LoadOrCreateLinkDocument(originalDocument, linkedFileName); if (ifcDocument == null) { return; } } else { ifcDocument = originalDocument; } bool useCachedRevitFile = DocumentUpToDate(ifcDocument, importer.FullFileName); // In the case where the document is already opened as a link, but it has been updated on disk, // give the user a warning and use the cached value. if (!useCachedRevitFile && ifcDocument.IsLinked) { useCachedRevitFile = true; Importer.AddDelayedLinkError(BuiltInFailures.ImportFailures.IFCCantUpdateLinkedFile); } if (!useCachedRevitFile) { m_ImportCache = IFCImportCache.Create(ifcDocument, importer.FullFileName); // Limit creating the cache to Link, but may either remove limiting or make it more restrict (reload only) later. if (TheOptions.Action == IFCImportAction.Link) { TheCache.CreateExistingElementMaps(ifcDocument); } // TheFile will contain the same value as the return value for this function. IFCImportFile.Create(importer.FullFileName, m_ImportOptions, ifcDocument); } if (useCachedRevitFile || IFCImportFile.TheFile != null) { if (IFCImportFile.TheFile != null) { if (IFCImportFile.TheFile.IFCProject != null) { IFCObjectDefinition.CreateElement(ifcDocument, IFCImportFile.TheFile.IFCProject); } IFCImportFile.TheFile.EndImport(ifcDocument, importer.FullFileName); } if (TheOptions.Action == IFCImportAction.Link) { // If we have an original Revit link file name, don't create a new RvtLinkSymbol - // we will use the existing one. bool useExistingType = (TheOptions.RevitLinkFileName != null); IFCImportFile.LinkInFile(importer.FullFileName, ifcDocument, originalDocument, useExistingType, !useCachedRevitFile); } } m_ImportCache.Reset(ifcDocument); } } catch (Exception ex) { if (IFCImportFile.TheFile != null) { IFCImportFile.TheFile.Log.LogError(-1, ex.Message, false); } } finally { if (IFCImportFile.TheFile != null) { IFCImportFile.TheFile.Close(); } } }