/// <summary> /// 预创建Instance /// </summary> /// <param name="collection"></param> /// <returns></returns> private IEnumerator PreCreateInstance(InstanceCollection collection) { if (collection == null) { yield break; } if (m_EditorLog) { Debug.LogFormat( "{0} -> {1} -> Start pre-load instances. Count('{2}').", poolName, collection.prefabName, collection.preCount ); } yield return(null); while (collection.Count < collection.preCount) { int count = Mathf.Min(collection.preCount - collection.Count, collection.preCountPerFrame); for (int i = 0; i < count; i++) { GameObject go = GameObject.Instantiate(collection.prefab); ReusableObject reusable = GetOrAddReusableObject(go); reusable.Despawn(false); collection.Add(go); } yield return(null); } }
/// <summary> /// 加入到Pool中,并预读 /// </summary> /// <param name="collection"></param> public void AddCollection(InstanceCollection collection) { if (collection == null) { Debug.LogError("{0} -> Argument named 'collection' is null."); return; } if (collection.ownerPool != null) { Debug.LogErrorFormat("{0} -> Collection has belonged to a pool({1}).", poolName, collection.ownerPool.poolName); return; } if (m_PrefabDict.ContainsKey(collection.prefabName)) { Debug.LogErrorFormat("{0} -> The prefab of collection is exist.", poolName); return; } collection.ownerPool = this; m_PrefabDict.Add(collection.prefabName, collection.prefab); m_InstanceCollections.Add(collection); StartCoroutine(PreCreateInstance(collection)); }
/// <summary> /// 立即Destroy未使用的Instance, /// count: 数量,小于或等于0时Destroy所有未使用Instance /// </summary> public void DestroyRecycledImmediate(GameObject prefab, int count = 0) { if (prefab == null) { Debug.LogErrorFormat("{0} -> Argument named 'prefab' is null.", poolName); return; } InstanceCollection collection = m_InstanceCollections.Find(c => c.prefab == prefab); if (collection == null) { Debug.LogWarningFormat("{0} -> 'prefab' is not in this pool.", poolName); return; } if (m_EditorLog) { Debug.LogFormat( "{0} -> {1} -> Destroy {2} recycled instances.", poolName, prefab.name, count <= 0 ? collection.recycledCount : count ); } collection.DestroyRecycledImmediate(count); }
private void DeployUpdate(HttpContext context) { // Get the name of the instance where to deploy to. string instance = context.Request.Params["Instance"]; // Get the software version of the deployment. string version = context.Request.Params["Version"]; InstanceCollection instances = new InstanceCollection(); if (!instances.Instances.ContainsKey(instance)) { return; } HttpContext.Current.Session["DeploymentStep"] = 0; context.Response.Write(GetDeploymentSteps( instances.Instances[instance], version )); ParameterizedThreadStart threadStart = new ParameterizedThreadStart(DeployUpdateAsynch); Thread thread = new Thread(threadStart); thread.Start(new object[] { instances.Instances[instance], HttpContext.Current.Session, version, context.Request.PhysicalApplicationPath }); }
private void RegisterService(Type service, Factory factory, Func <Factory, InstanceLifetime> lifetime, string key, bool createimmediate) { lock (sync) { if (false == registration.TryGetValue(service, out var collection)) { collection = new InstanceCollection(); registration.Add(service, collection); } else if (null == key) { Throw.MissingServiceRegistration(service, nameof(service)); } var manager = lifetime ?? InstanceLifetime.Singleton; collection[key] = manager(factory); if (createimmediate) { var queue = new Stack <ServiceTypeReference>(); collection[key].ResolveInstance(queue); } } }
/// <summary> /// Gets the Instance of the given Map of either the Leader or any member /// if anyone is already in it. /// </summary> public BaseInstance GetActiveInstance(MapTemplate map) { GroupMember leader = m_leader; if (leader != null) { Character character = leader.Character; if (character != null) { InstanceCollection instances = character.Instances; if (instances != null) { BaseInstance activeInstance = instances.GetActiveInstance(map); if (activeInstance != null) { return(activeInstance); } } } } foreach (Character allCharacter in GetAllCharacters()) { BaseInstance activeInstance = allCharacter.GetActiveInstance(map); if (activeInstance != null) { return(activeInstance); } } return(null); }
private void GetInstances(HttpContext context) { InstanceCollection instances = new InstanceCollection( ConfigurationManager.AppSettings["InstanceRoot"] ); context.Response.Write(instances.ToXml()); }
private void CreateUser(HttpContext context) { // Get the client name from // the http request's parameters. string clientName = context.Request.Params["Client"]; // Get the source instance name from // the http request's parameters. string instanceName = context.Request.Params["Instance"]; InstanceCollection instances = new InstanceCollection( ConfigurationManager.AppSettings["InstanceRoot"] ); if (!instances.Instances.ContainsKey(instanceName)) { context.Response.Write("__ERROR__Instance does not exist on the server."); return; } Instance instance = instances.Instances[instanceName]; ClientManager clientManager = new ClientManager(Path.Combine( ConfigurationManager.AppSettings["InstanceRoot"], instanceName, "App_Data", "Clients.xml" )); Client client = clientManager.GetSingle(clientName); if (client == null) { context.Response.Write("__ERROR__Client does not exist on this instance."); return; } ExecuteQuery(client.Database, "INSERT INTO [Users] (Id, CreationDate, Name, FirstName, LastName, Mail, Password, Language) " + "VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7})", context.Request.Params["Id"], DateTime.Now, context.Request.Params["Name"], context.Request.Params["FirstName"], context.Request.Params["LastName"], context.Request.Params["Mail"], context.Request.Params["Password"], "English" ); ExecuteQuery(client.Database, "INSERT INTO [UserRoles] (Id, IdUser, IdRole, CreationDate) " + "VALUES (NEWID(), {0}, {1}, {2})", context.Request.Params["Id"], context.Request.Params["IdRole"], DateTime.Now ); }
public InstanceCollection UpdateFrustumSelection(InstanceCollection InstanceList) { InstanceCollection selected_items = new InstanceCollection(); WorldInstance wi; Plane[] fplanes; MdxRender.Camera.GetFrustumPlanes(selectionBoxStartX, selectionBoxStartY, selectionBoxEndX, selectionBoxEndY, out fplanes); float test; //there seems to be a little bit of a plane calculation bug, objects within the bounding box are //not always selected perfectly bool bInsideFrustum = false; int sel_count = 0; for (int i = 0; i < InstanceList.Count; i++) { wi = (WorldInstance)InstanceList[i]; bInsideFrustum = true; for (int p = 0; p < fplanes.Length; p++) { test = wi.ObjectTransform.X * fplanes[p].A + wi.ObjectTransform.Y * fplanes[p].B + wi.ObjectTransform.Z * fplanes[p].C + fplanes[p].D; if (test < 0) //test for behind plane (outside of frustum) (normals point to inside of frustum) { bInsideFrustum = false; break; } } wi.Selected = bInsideFrustum; if (bInsideFrustum) { selected_items.Add(wi); sel_count++; } else { } } //Trace.WriteLine("---------------------------------"); //Trace.WriteLine(string.Format("selected: {0}/{1}", sel_count, this.Count)); //Trace.WriteLine(string.Format("near Nx={0:N3} Ny={1:N3} Nz={2:N3} D={3:N3}", fplanes[0].A, fplanes[0].B, fplanes[0].C, fplanes[0].D)); //Trace.WriteLine(string.Format("far Nx={0:N3} Ny={1:N3} Nz={2:N3} D={3:N3}", fplanes[1].A, fplanes[1].B, fplanes[1].C, fplanes[1].D)); //Trace.WriteLine(string.Format("right Nx={0:N3} Ny={1:N3} Nz={2:N3} D={3:N3}", fplanes[2].A, fplanes[2].B, fplanes[2].C, fplanes[2].D)); //Trace.WriteLine(string.Format("left Nx={0:N3} Ny={1:N3} Nz={2:N3} D={3:N3}", fplanes[3].A, fplanes[3].B, fplanes[3].C, fplanes[3].D)); //Trace.WriteLine(string.Format("top Nx={0:N3} Ny={1:N3} Nz={2:N3} D={3:N3}", fplanes[4].A, fplanes[4].B, fplanes[4].C, fplanes[4].D)); //Trace.WriteLine(string.Format("Bottom Nx={0:N3} Ny={1:N3} Nz={2:N3} D={3:N3}", fplanes[5].A, fplanes[5].B, fplanes[5].C, fplanes[5].D)); return(selected_items); }
public void ForeachInstanceHolder(Action <InstanceCollection> callback) { foreach (Character allCharacter in GetAllCharacters()) { InstanceCollection instances = allCharacter.Instances; if (instances != null) { callback(instances); } } }
public Instance GetPermutation(int[] permutations) { if (instances == null) { instances = new InstanceCollection(); } else { instances.Clear(); } for (int i = 0; i < gbxmodelValues.Regions.Count; i++) { switch (lod) { case LevelOfDetail.SuperLow: for (int j = 0; j < superLow[i][permutations[i]].Count; j++) { instances.Add(superLow[i][permutations[i]][j]); } break; case LevelOfDetail.Low: for (int j = 0; j < low[i][permutations[i]].Count; j++) { instances.Add(low[i][permutations[i]][j]); } break; case LevelOfDetail.Medium: for (int j = 0; j < medium[i][permutations[i]].Count; j++) { instances.Add(medium[i][permutations[i]][j]); } break; case LevelOfDetail.High: for (int j = 0; j < high[i][permutations[i]].Count; j++) { instances.Add(high[i][permutations[i]][j]); } break; case LevelOfDetail.SuperHigh: for (int j = 0; j < superHigh[i][permutations[i]].Count; j++) { instances.Add(superHigh[i][permutations[i]][j]); } break; } } return(instances); }
/// <summary> /// 获取未使用Instance,如果没有,则创建一个Instance /// </summary> /// <param name="prefab"></param> /// <returns></returns> private GameObject GetOrCreateRecycledInstance(GameObject prefab) { InstanceCollection collection = m_InstanceCollections.Find(c => c.prefab == prefab); if (collection == null) { //throw new KeyNotFoundException(string.Format("{0}: The collection of prefab '{1}' is not found.", poolName, prefab.name)); collection = new InstanceCollection(prefab); AddCollection(collection); } return(collection.GetOrCreateRecycledInstance()); }
/// <summary> /// 回收一个Instance。 /// true:回收成功。 /// 有debug warning:参数instance为null,return false。 /// 有debug error:这个GameObject不是由Pool创建的,return false。 /// false:当没有error和warning时,instance是从其它pool里生成的,或者是没有添加到pool的外部instance。 /// </summary> /// <param name="instance"></param> /// <returns></returns> public bool Despawn(GameObject instance) { if (instance == null) { Debug.LogWarningFormat("{0} -> You tryed despawn a 'null' instance.", poolName); return(false); } ReusableObject reusable = instance.GetComponent <ReusableObject>(); if (reusable == null) { Debug.LogErrorFormat("{0} -> This GameObject is not a instance from pool."); return(false); } // 外部instance,没有加入任何pool if (!reusable.isFromPool) { return(false); } // 找到存在这个instance的collection InstanceCollection collection = m_InstanceCollections.Find(c => c.Contains(instance)); // 没有找到,说明是其它pool里生成的 if (collection == null) { return(false); } reusable.Despawn(true); if (m_EditorLog) { Debug.LogFormat( "{0} -> Despawn a instance named '{1}'.", poolName, instance.name ); } return(true); }
private async Task <bool> ProcessJobs(InstanceCollection collection) { Guard.Against.Null(collection, nameof(collection)); using (_logger.BeginScope(new Dictionary <string, object> { { "AE Title", _configuration.AeTitle } })) { _logger.Log(LogLevel.Information, "Processing a new job with grouping={0}, key={1}", _grouping, collection.Key); _instances.Remove(collection.Key, out _); // Setup a new job for each of the defined pipelines foreach (var pipelineKey in _pipelines.Keys) { try { if (!_pipelines.TryGetValue(pipelineKey, out string pipelineId)) { _logger.Log(LogLevel.Warning, "Something went wrong, pipeline was removed? '{0}'", pipelineKey); continue; } var jobName = GenerateJobName(pipelineKey, collection.First()); _logger.Log(LogLevel.Information, "Job generated {0} for pipeline {1}", jobName, pipelineId); using (_logger.BeginScope(new Dictionary <string, object> { { "JobName", jobName } })) { var basePath = collection.First().AeStoragePath; await SubmitPipelineJob(jobName, pipelineId, _priority, basePath, collection); } } catch (System.Exception ex) { _logger.Log(LogLevel.Error, "Failed to submit a new pipeline ({0}) job: {1}", pipelineKey, ex); return(false); } } // Cleanup instance RemoveInstances(collection); collection.Dispose(); return(true); } }
private void Awake() { if (string.IsNullOrEmpty(poolName)) { m_PoolName = gameObject.name; } if (m_PrePrefabs != null && m_PrePrefabs.Length > 0) { for (int i = 0; i < m_PrePrefabs.Length; i++) { InstanceCollection pre = m_PrePrefabs[i]; if (pre.prefab == null) { Debug.LogWarningFormat("{0} -> Pre-prefab is null.", poolName); continue; } if (m_PrefabDict.ContainsKey(pre.prefabName)) { Debug.LogWarningFormat("{0} -> Pre-prefab is exist.", poolName); continue; } InstanceCollection collection = new InstanceCollection(pre.prefab) { preCount = pre.preCount, preCountPerFrame = pre.preCountPerFrame }; AddCollection(collection); } } if (!PoolManager.instance.AddPoolInternal(this)) { Debug.LogError("Destroying..."); Destroy(gameObject); } }
public override void HandleInstance(InstanceStorageInfo value) { if (value is null) { throw new ArgumentNullException(nameof(value)); } ; if (!value.CalledAeTitle.Equals(_configuration.AeTitle)) { throw new InstanceNotSupportedException(value); } ; if (!_dicomToolkit.TryGetString(value.InstanceStorageFullPath, _grouping, out string key) || string.IsNullOrWhiteSpace(key)) { _logger.Log(LogLevel.Error, "Instance missing required DICOM key for grouping by {0}, ignoring", _grouping.ToString()); return; } InstanceCollection collection = null; lock (SyncRoot) { if (_instances.TryGetValue(key, out InstanceCollection val)) { collection = val; } else { collection = new InstanceCollection(key); _instances.Add(key, collection); _logger.Log(LogLevel.Debug, "New collection created for {0}", key); } collection.AddInstance(value); } _logger.Log(LogLevel.Debug, "Instance received and added with key {0}", key); }
/// <summary> /// 加入外部Instance,由RuntimePrePoolObject组件调用 /// </summary> /// <param name="runtime"></param> /// <returns></returns> internal bool AddUnpooledObject(RuntimePrePoolObject runtime) { if (!m_PrefabDict.ContainsKey(runtime.m_PrefabName)) { Debug.LogErrorFormat( "{0} -> Add unpooled object '{1}' The prefab is not found.", poolName, runtime.gameObject.name ); return(false); } InstanceCollection collection = m_InstanceCollections.Find(c => c.prefabName == runtime.m_PrefabName); if (collection == null) { Debug.LogErrorFormat("{0} -> UNEXPECTED ERROR! May be the pool name was changed at runtime.", poolName); return(false); } collection.Add(runtime.gameObject); return(true); }
private void Application_Startup(object sender, StartupEventArgs e) { DispatcherUnhandledException += ExceptionDialog.Handler; AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; _instanceCollection = new InstanceCollection(Settings.InstanceSources.Cast<IInstanceSource>().ToList()); if (Settings.IsFirstTimeConfiguration) { ShutdownMode = ShutdownMode.OnExplicitShutdown; var dialog = new SettingsDialog(); if (dialog.ShowDialog() == true) { Settings.IsFirstTimeConfiguration = false; ShutdownMode = ShutdownMode.OnMainWindowClose; } else { Shutdown(); return; } } new MainWindow().Show(); }
private void DeployUpdate(HttpContext context) { context.Response.Write("<Errors>"); // Get the source instance name from // the http request's parameters. string instanceName = context.Request.Params["Instance"]; InstanceVersion toVersion = new InstanceVersion(context.Request.Params["Version"]); string instanceRoot = ConfigurationManager.AppSettings["InstanceRoot"]; InstanceCollection instances = new InstanceCollection(instanceRoot); if (!instances.Instances.ContainsKey(instanceName)) { return; } InstanceVersion version = new InstanceVersion(instances.Instances[instanceName].Version); version += 1; while (version.ToInt() <= toVersion.ToInt()) { string directory = Path.Combine( context.Request.PhysicalApplicationPath, "App_Data", "SoftwareUpdate", version.ToString() ); if (!Directory.Exists(directory)) { continue; } string fileArchive = Path.Combine( directory, "Files.zip" ); if (File.Exists(fileArchive)) { try { string tempDirectory = Path.Combine( Path.GetTempPath(), Guid.NewGuid().ToString() ); Directory.CreateDirectory(tempDirectory); System.IO.Compression.ZipFile.ExtractToDirectory( fileArchive, tempDirectory ); DeployDirectory(tempDirectory, Path.Combine( instanceRoot, instanceName ), version.ToString()); } catch (Exception ex) { context.Response.Write(string.Format( "<Error Type=\"Software\" Version=\"{1}\">{0}</Error>", ex.ToString(), version.ToString() )); } } string databaseScripts = Path.Combine( directory, "DATABASE" ); if (!Directory.Exists(databaseScripts)) { version += 1; continue; } Client[] clients = instances.Instances[instanceName].GetClients(); foreach (Client client in clients) { foreach (string script in Directory.GetFiles(databaseScripts)) { try { ExecuteQuery(client.Database, File.ReadAllText(script)); } catch (Exception ex) { context.Response.Write(string.Format( "<Error Type=\"Database\" Version=\"{1}\" Client=\"{2}\">{0}</Error>", ex.ToString(), version.ToString(), client.Name )); } } } version += 1; } context.Response.Write("</Errors>"); }
public override void Render() { string instanceSelection = ""; InstanceCollection instances = new InstanceCollection(); foreach (string instance in instances.Instances.Keys) { instanceSelection += "<option>" + (instance) + "</option>"; } Random test = new Random(); StringBuilder result = new StringBuilder(); result.Append("<table class=\"TableContent\" cellspacing=\"0\" cellpadding=\"0\">"); result.Append(string.Format( "<tr class=\"TableHeadline\"><td>{0}</td>" + "<td></td>" + "<td style=\"width:200px;\">{1}</td>" + "<td style=\"width:200px;\">{3}</td>" + "<td style=\"width:50%;\">{2}</td></tr>", Global.LanguageManager.GetText("InstanceName"), Global.LanguageManager.GetText("InstanceVersion"), Global.LanguageManager.GetText("InstanceServers"), Global.LanguageManager.GetText("InstanceClients") )); foreach (string instanceName in instances.Instances.Keys) { List <string> servers = new List <string>(); foreach (string server in instances.Instances[instanceName].Servers) { if (instances.Servers.Items[server].State == ServerState.Offline) { servers.Add(string.Format( "<span style=\"color:#CC0000;\">{0}</span>", instances.Servers.Items[server].Description )); } else { servers.Add(string.Format( "{0}", instances.Servers.Items[server].Description )); } } result.Append(string.Format( "<tr><td>{0}</td>" + "<td class=\"TdHoverOnly\" style=\"width:110px;\" onclick=\"DeployUpdate('{0}');\"><div class=\"Button\">{3}</div></td>" + "<td style=\"width:200px;\">{1}</td>" + "<td style=\"width:200px;\">{4}</td>" + "<td style=\"width:50%;\">{2}</td></tr>", instanceName, instances.Instances[instanceName].Version, string.Join(",", servers), Global.LanguageManager.GetText("InstanceDeployUpdate"), instances.Instances[instanceName].Portals.Count )); } result.Append(string.Format( "<tr><td class=\"TableCellNew\" colspan=\"5\" onclick=\"\">+</td></tr>" )); result.Append("</table>"); this.Controls.Add(new LiteralControl(result.ToString())); }
private void CreateClient(HttpContext context) { // Get the client name from // the http request's parameters. string clientName = context.Request.Params["Client"]; // Get the source instance name from // the http request's parameters. string instanceName = context.Request.Params["Instance"]; string hostname = string.Format( ConfigurationManager.AppSettings["Hostname"], clientName ); InstanceCollection instances = new InstanceCollection( ConfigurationManager.AppSettings["InstanceRoot"] ); if (!instances.Instances.ContainsKey(instanceName)) { context.Response.Write("__ERROR__Instance does not exist on the server."); return; } Instance instance = instances.Instances[instanceName]; ClientManager clientManager = new ClientManager(Path.Combine( ConfigurationManager.AppSettings["InstanceRoot"], instanceName, "App_Data", "Clients.xml" )); clientManager.Append( clientName.ToLower(), clientName, hostname, "#6CAEE0", "#FCB040", DateTime.Today.ToString("dd-MM-yyyy"), context.Request.Params["Servers"] ); InstanceVersion version = new InstanceVersion(instance.Version); string databaseScriptsDirectory = Path.Combine( context.Request.PhysicalApplicationPath, "App_Data", "ClientCreation", version.ToString(), "DATABASE" ); while (!Directory.Exists(databaseScriptsDirectory)) { version -= 1; if (version.ToString() == "0.0.0.0") { return; } databaseScriptsDirectory = Path.Combine( context.Request.PhysicalApplicationPath, "App_Data", "ClientCreation", version.ToString(), "DATABASE" ); } string databaseRoot = ConfigurationManager.AppSettings["DatabaseRoot"]; int i = 0; foreach (string scriptFile in Directory.GetFiles(databaseScriptsDirectory)) { string script = File.ReadAllText(scriptFile); script = script.Replace("###CLIENTNAME###", clientName); script = script.Replace("###DATABASEROOT###", databaseRoot); ExecuteQuery( i == 0 ? "master" : clientName, script ); i++; } string fileSystemRoot = Path.Combine( context.Request.PhysicalApplicationPath, "App_Data", "ClientCreation", version.ToString(), "FILESYSTEM" ); foreach (string directory in Directory.GetDirectories(fileSystemRoot)) { string target = directory.Replace( fileSystemRoot, Path.Combine( ConfigurationManager.AppSettings["InstanceRoot"], instanceName )); CopyDirectory( directory, target, clientName ); } try { IISBindings iisBindings = new IISBindings(); iisBindings.AddBindings(instanceName, hostname); } catch { } string caseDataDirectory = Path.Combine( ConfigurationManager.AppSettings["CaseDataPath"], clientName ); if (!Directory.Exists(caseDataDirectory)) { Directory.CreateDirectory(caseDataDirectory); } ExecuteQuery(clientName, "INSERT INTO [Roles] (Id, CreationDate, Name, Description) " + "VALUES ({0}, {1}, {2}, {3})", Guid.Parse("00000000-0000-0000-0000-000000000000"), DateTime.Now, "Administrators", "Blueocean administrators" ); XmlDocument document = new XmlDocument(); document.Load(Path.Combine( ConfigurationManager.AppSettings["InstanceRoot"], instanceName, "App_Data", "Permissions.xml" )); foreach (XmlNode xmlNodePermission in document.SelectNodes("//Permission")) { ExecuteQuery(clientName, "INSERT INTO [RolePermissions] (Id, IdRole, Permission, CreationDate) " + "VALUES (NEWID(), {0}, {1}, {2})", Guid.Parse("00000000-0000-0000-0000-000000000000"), int.Parse(xmlNodePermission.Attributes["Id"].Value), DateTime.Now ); } }
private void CreateNewOrganization() { if (string.Compare((string)Session["NewOrg"], "1", StringComparison.OrdinalIgnoreCase) == 0) { string url = null; UserContext user = UserContext.Current; if (user != null) { if (string.Compare(user.Email, Email.Text, StringComparison.OrdinalIgnoreCase) == 0) { url = LoginProvider.Current.GetLoginUrl(user.Email, true, user.OrganizationId, user.InstanceId, null); Response.Redirect(url); } } url = LoginProvider.Current.GetLoginUrl(); Response.Redirect(url); } else { Instance templateInstance = null; InstanceCollection insts = Micajah.Common.Bll.Providers.InstanceProvider.GetTemplateInstances(); if (insts.Count == 0) { throw new NotImplementedException(Resources.SignupOrganizationControl_NoActiveTemplateInstances); } else { templateInstance = insts[0]; } string howYouHearAboutUs = null; bool isGoogleProviderRequest = GoogleProvider.IsGoogleProviderRequest(this.Request); if (isGoogleProviderRequest) { howYouHearAboutUs = Resources.SignupOrganizationControl_HowYouHearAboutUs_Text; } Guid orgId = OrganizationProvider.InsertOrganization(OrganizationName.Text, null, null , null, null, null, null, null, null, string.Empty, howYouHearAboutUs , templateInstance.TimeZoneId, templateInstance.InstanceId , Email.Text, null, this.UserFirstName, this.UserLastName, null, null, null , OrganizationUrl.Text, this.Request , true); Session["NewOrg"] = "1"; Instance inst = InstanceProvider.GetFirstInstance(orgId); if (isGoogleProviderRequest) { string returnUrl = null; OAuth2Parameters parameters = JsonConvert.DeserializeObject <OAuth2Parameters>(this.OAuth2Parameters); GoogleProvider.ProcessAuthorization(this.Context, ref parameters, ref returnUrl); } string url = LoginProvider.Current.GetLoginUrl(Email.Text, true, orgId, inst.InstanceId, null); Response.Redirect(url); } }
private void GetFileSynchStates(HttpContext context) { StringBuilder result = new StringBuilder(); result.Append("<Files>"); InstanceCollection instances = new InstanceCollection( ConfigurationManager.AppSettings["InstanceRoot"] ); XmlDocument document = new XmlDocument(); document.Load(Path.Combine( context.Request.PhysicalApplicationPath, "App_Data", "Filesystem.xml" )); XmlNodeList xmlNodesDirectories = document.DocumentElement.SelectNodes("Directory"); XmlNodeList xmlNodesFiles = document.DocumentElement.SelectNodes("File"); foreach (Instance instance in instances.Instances.Values) { foreach (XmlNode xmlNode in xmlNodesDirectories) { string directory = Path.Combine( instance.Name, string.Format(xmlNode.Attributes["Path"].Value, "") ); if (!Directory.Exists(Path.Combine(instances.Source, directory))) { continue; } foreach (Client client in instance.GetClients()) { if (client.SynchServers.Length == 0) { continue; } GetDirectorySynchState(instances.Source, Path.Combine(instances.Source, directory), result); } } foreach (XmlNode xmlNode in xmlNodesFiles) { foreach (Client client in instance.GetClients()) { if (client.SynchServers.Length == 0) { continue; } string directory = Path.GetDirectoryName(Path.Combine( instance.Name, string.Format(xmlNode.Attributes["Path"].Value, client.Name) )); if (!Directory.Exists(Path.Combine(instances.Source, directory))) { continue; } GetDirectorySynchState(instances.Source, Path.Combine(instances.Source, directory), result); } } } result.Append("</Files>"); context.Response.Write(result.ToString()); }
internal List <ApprovalAssignment> GetAssignmentByAssignedRole(string toRoleName, InstanceCollection instances) { var ret = from a in _approvalAssignmentRepository.Table join b in _nHStateMachineInstanceRepository.Table on a.WorkflowInstanceId equals b.Id where a.ToRole == toRoleName select a; return(ret.ToList()); // StringBuilder queryHQL = new StringBuilder(); //queryHQL.Append("select assignment from " + persitentType.Name + " as assignment, NHStateMachineInstance as instance where"); //queryHQL.Append(" assignment.WorkflowInstanceId=instance.Id and assignment.ToRole='" + toRoleName + "'"); //StringBuilder temp = new StringBuilder(); //for (int i = 0; i < instances.Count; i++) //{ // if (temp.Length > 0) // temp.Append(" or "); // temp.Append("( instance.WorkflowName='" + instances[i].Instance.WorkflowName + "'"); // temp.Append(" and assignment.WorkflowInstanceId='" + instances[i].Instance.Id + "'"); // temp.Append(" and assignment.AssignState='" + instances[i].Instance.StateName + "')"); //} //if (temp.Length > 0) // queryHQL.AppendFormat(" and ({0})", temp.ToString()); //return ConvertToGenericList(session.CreateQuery(queryHQL.ToString()).List()); }
private void GetDeploymentDetails(HttpContext context) { // Get the name of the instance where to deploy to. string instance = context.Request.Params["Instance"]; InstanceCollection instances = new InstanceCollection(); if (!instances.Instances.ContainsKey(instance)) { return; } InstanceVersion instanceVerion = new InstanceVersion( instances.Instances[instance].Version ); // Create a new string builder that // contains the result JSON string. StringBuilder result = new StringBuilder(); result.Append("{"); result.Append(string.Format( "\"FromVersion\": \"{0}\",", instances.Instances[instance].Version )); result.Append(string.Format( "\"Errors\": [", instances.Instances[instance].Version )); bool hasErrors = false; foreach (string server in instances.Instances[instance].Servers) { if (instances.Servers.Items.ContainsKey(server) == false || instances.Servers.Items[server].State == ServerState.Offline) { hasErrors = true; result.Append(string.Format("\"{0}\",", string.Format(Global.LanguageManager.GetText( "SoftwareUpdateError_ServerOffline"), instances.Servers.Items.ContainsKey(server) ? instances.Servers.Items[server].Description : server ))); } } if (hasErrors) { result = result.Remove(result.Length - 1, 1); result.Append("]}"); context.Response.Write(result.ToString()); return; } result.Append("],"); result.Append("\"AvailableUpdates\": ["); ServiceLink service = new ServiceLink(string.Format( "http://{0}:8080/Handler.ashx", instances.Instances[instance].Servers[0] )); XmlDocument document = new XmlDocument(); document.LoadXml(service.Request(new string[] { "Method=GetAvailableUpdates" })); foreach (XmlNode xmlNode in document.DocumentElement.SelectNodes("Update")) { InstanceVersion version = new InstanceVersion( xmlNode.Attributes["Version"].Value ); if (version.ToInt() <= instanceVerion.ToInt()) { continue; } result.Append(string.Format( "\"{0}\",", (version).ToString() )); } if (result.ToString().EndsWith(",")) { result = result.Remove(result.Length - 1, 1); } result.Append("]"); result.Append("}"); context.Response.Write(result.ToString()); }
public override void Render() { string instanceSelection = ""; InstanceCollection instances = new InstanceCollection(); foreach (string instance in instances.Instances.Keys) { instanceSelection += "<option>" + (instance) + "</option>"; } Random test = new Random(); StringBuilder result = new StringBuilder(); foreach (string instanceName in instances.Instances.Keys) { result.Append("<div class=\"Instance\"><h1>"); result.Append(instanceName + " - " + instances.Instances[instanceName].Version); result.Append("</h1><table class=\"TableContent\" cellspacing=\"0\" cellpadding=\"0\">"); result.Append(string.Format( "<tr class=\"TableHeadline\"><td>{0}</td><td style=\"width:50%;\">{1}</td>" + "<td></td><td style=\"width:100px;\">{2}</td><td style=\"width:100px;\">{4}</td><td style=\"width:100px;\">{3}</td></tr>", Global.LanguageManager.GetText("PortalName"), Global.LanguageManager.GetText("HostName"), Global.LanguageManager.GetText("DataSize"), Global.LanguageManager.GetText("InstanceName"), Global.LanguageManager.GetText("Servers") )); foreach (string portalName in instances.Instances[instanceName].Portals.Keys) { List <string> servers = new List <string>(); foreach (Server server in instances.Instances[instanceName].Portals[portalName].Servers) { if (server.State == ServerState.Offline) { servers.Add(string.Format( "<span style=\"color:#CC0000;\">{0}</span>", server.Description )); } else { servers.Add(string.Format( "{0}", server.Description )); } } result.Append(string.Format( "<tr><td>{0}</td><td style=\"width:50%;\">{1}</td>" + "<td class=\"TdHoverOnly\" style=\"width:110px;\" onclick=\"GetUsers('{5}', '{0}', '{7}');\"><div class=\"Button\">{4}</div></td>" + "<td style=\"width:100px;\">{2}</td>" + "<td style=\"width:100px;\">{6}</td><td style=\"width:100px;\">" + "<select onchange=\"MovePortal('{5}', this.value)\">{3}</select></td></tr>", portalName, instances.Instances[instanceName].Portals[portalName].Host, Math.Round((test.Next(1024, 100024) / 1024.0), 2) + " GB", instanceSelection.Replace("<option>" + instanceName + "</option>", "<option SELECTED=\"selected\">" + instanceName + "</option>"), "show users", instanceName, string.Join(",", servers), instances.Instances[instanceName].Portals[portalName].Servers[0].IP )); } result.Append(string.Format( "<tr><td class=\"TableCellNew\" colspan=\"6\" onclick=\"CreatePortal('{0}', '{1}')\">+</td></tr>", instanceName, instanceSelection )); result.Append("</table></div>"); } this.Controls.Add(new LiteralControl(result.ToString())); }
/// <summary> /// 移除集合和prefab /// </summary> /// <param name="collection"></param> internal void RemoveCollectionInternal(InstanceCollection collection) { m_PrefabDict.Remove(collection.prefabName); m_InstanceCollections.Remove(collection); }
/// <summary> /// 按被指定专办的角色和立项状态获取专办信息 /// </summary> /// <param name="assignToRole">别指定的角色</param> /// <param name="instances">The instances.</param> /// <returns></returns> public List <ApprovalAssignment> GetAssignmentByAssignToRole(string assignToRole, InstanceCollection instances) { return(GetAssignmentDao().GetAssignmentByAssignedRole(assignToRole, instances)); }
public static int UpdateChargifyAllocations() { if (!Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Integration.Chargify.Enabled) { throw new InvalidOperationException("Chargify integration is not enabled in the application configuration file."); } ChargifyConnect _chargify = ChargifyProvider.CreateChargify(); if (_chargify == null) { throw new InvalidOperationException("No Chargify configuration settings found."); } DateTime?lastUpdatedAt = CounterSettingProvider.GetDateTimeMark(1); int updatedCount = 0; OrganizationCollection _orgs = OrganizationProvider.GetOrganizations(false, false); foreach (Organization _org in _orgs) { InstanceCollection _insts = InstanceProvider.GetInstances(_org.OrganizationId, false); foreach (Instance _inst in _insts) { if (_inst.BillingPlan == BillingPlan.Custom) { continue; } SettingCollection modifiedSettings = CounterSettingProvider.GetLastModifiedPaidSettings(_org.OrganizationId, _inst.InstanceId, lastUpdatedAt); if (modifiedSettings.Count == 0) { continue; } SettingCollection paidSettings = lastUpdatedAt.HasValue ? CounterSettingProvider.GetCalculatedPaidSettings(_org.OrganizationId, _inst.InstanceId) : modifiedSettings; ISubscription _custSubscr = ChargifyProvider.GetCustomerSubscription(_chargify, _org.OrganizationId, _inst.InstanceId); ChargifyProvider.UpdateSubscriptionAllocations(_chargify, _custSubscr != null ? _custSubscr.SubscriptionID : 0, _inst, modifiedSettings, paidSettings); if (_custSubscr != null) { updatedCount++; } if (_custSubscr == null && _inst.CreditCardStatus != CreditCardStatus.NotRegistered) { InstanceProvider.UpdateInstance(_inst, CreditCardStatus.NotRegistered); } else if (_custSubscr != null && _custSubscr.State == SubscriptionState.Expired && _inst.CreditCardStatus != CreditCardStatus.Expired) { InstanceProvider.UpdateInstance(_inst, CreditCardStatus.Expired); } else if (_custSubscr != null && _custSubscr.State == SubscriptionState.Active && _inst.CreditCardStatus != CreditCardStatus.Registered) { InstanceProvider.UpdateInstance(_inst, CreditCardStatus.Registered); } else if (_custSubscr != null && _custSubscr.State != SubscriptionState.Active && _custSubscr.State != SubscriptionState.Expired && _inst.CreditCardStatus != CreditCardStatus.Declined) { InstanceProvider.UpdateInstance(_inst, CreditCardStatus.Declined); } } } CounterSettingProvider.SetDateTimeMark(1); return(updatedCount); }
private void CreatePortalGetServers(HttpContext context) { // Get the name of the instance from // the http request's parameters. string instance = context.Request.Params["Instance"]; // Create a new string builder that // holds the result html string. StringBuilder result = new StringBuilder(); result.Append("<table class=\"TableContent\" cellspacing=\"0\" cellpadding=\"0\">"); ServerCollection servers = new ServerCollection(Path.Combine( HttpContext.Current.Request.PhysicalApplicationPath, "App_Data", "Servers.xml" )); InstanceCollection instances = new InstanceCollection(servers); if (instances.Instances.ContainsKey(instance)) { // Run through all defined servers. foreach (string ip in instances.Instances[instance].Servers) { if (!servers.Items.ContainsKey(ip)) { continue; } Server server = servers.Items[ip]; if (server.State == ServerState.Offline) { continue; } result.Append("<tr>"); result.Append(string.Format( "<td><input type=\"checkbox\" name=\"chkCreateClientServer\" Server=\"{0}\" checked=\"CHECKED\" /></td>", server.IP )); result.Append(string.Format( "<td>{0}</td>", server.Description )); result.Append(string.Format( "<td>{0}</td>", Global.LanguageManager.GetText("ServerRole" + server.Role) )); result.Append("</tr>"); } } result.Append("</table>"); context.Response.Write(result.ToString()); }
public IUnityContainer Build(InstanceCollection instances) { container.RegisterInstance<IEventHandler>(new EventHandler()); foreach (var i in instances) { // // Core DB objects container.RegisterType<IDatabaseFactory, DatabaseFactory>( i.Name, new PerResolveLifetimeManager(), new InjectionConstructor(i.ConnStringName)); container.RegisterType<IUnitOfWork, UnitOfWork>( i.Name, new PerResolveLifetimeManager(), new InjectionConstructor(new ResolvedParameter<IDatabaseFactory>(i.Name))); // // Repositories container.RegisterType<IEmailRepository, EmailRepository>( i.Name, new PerResolveLifetimeManager(), new InjectionConstructor(new ResolvedParameter<IDatabaseFactory>(i.Name))); container.RegisterType<IWorkOrderRepository, WorkOrderRepository>( i.Name, new PerResolveLifetimeManager(), new InjectionConstructor(new ResolvedParameter<IDatabaseFactory>(i.Name))); container.RegisterType<IWorkAssignmentRepository, WorkAssignmentRepository>( i.Name, new PerResolveLifetimeManager(), new InjectionConstructor(new ResolvedParameter<IDatabaseFactory>(i.Name))); container.RegisterType<IWorkerRepository, WorkerRepository>( i.Name, new PerResolveLifetimeManager(), new InjectionConstructor( new ResolvedParameter<IDatabaseFactory>(i.Name) ) ); container.RegisterType<IWorkerSigninRepository, WorkerSigninRepository>( i.Name, new PerResolveLifetimeManager(), new InjectionConstructor(new ResolvedParameter<IDatabaseFactory>(i.Name))); container.RegisterType<ILookupRepository, LookupRepository>( i.Name, new PerResolveLifetimeManager(), new InjectionConstructor(new ResolvedParameter<IDatabaseFactory>(i.Name))); container.RegisterType<ILookupCache, LookupCache>( i.Name, new PerResolveLifetimeManager(), new InjectionConstructor(new ResolvedParameter<IDatabaseFactory>(i.Name))); container.RegisterType<IWorkerCache, WorkerCache>( i.Name, new PerResolveLifetimeManager(), new InjectionConstructor(new ResolvedParameter<Func<IDatabaseFactory>>(i.Name)) ); // // Services container.RegisterType<IEmailService, EmailService>( i.Name, new PerResolveLifetimeManager(), new InjectionConstructor( new ResolvedParameter<IEmailRepository>(i.Name), new ResolvedParameter<IWorkOrderService>(i.Name), new ResolvedParameter<IUnitOfWork>(i.Name) ) ); container.RegisterType<IWorkOrderService, WorkOrderService>( i.Name, new PerResolveLifetimeManager(), new InjectionConstructor( new ResolvedParameter<IWorkOrderRepository>(i.Name), new ResolvedParameter<IWorkAssignmentService>(i.Name), new ResolvedParameter<IUnitOfWork>(i.Name) ) ); container.RegisterType<IWorkAssignmentService, WorkAssignmentService>( i.Name, new PerResolveLifetimeManager(), new InjectionConstructor( new ResolvedParameter<IWorkAssignmentRepository>(i.Name), new ResolvedParameter<IWorkerRepository>(i.Name), new ResolvedParameter<ILookupRepository>(i.Name), new ResolvedParameter<IWorkerSigninRepository>(i.Name), new ResolvedParameter<IWorkerCache>(i.Name), new ResolvedParameter<ILookupCache>(i.Name), new ResolvedParameter<IUnitOfWork>(i.Name) ) ); container.RegisterType<IEmailServiceProvider, EmailServiceProvider>( i.Name, new PerResolveLifetimeManager(), new InjectionConstructor( new ResolvedParameter<Func<IEmailQueueManager>>(i.Name), new ResolvedParameter<Func<IDatabaseFactory>>(i.Name) ) ); container.RegisterType<IEmailQueueManager, EmailQueueManager>( i.Name, new PerResolveLifetimeManager(), new InjectionConstructor( new ResolvedParameter<IEmailService>(i.Name), new ResolvedParameter<IUnitOfWork>(i.Name) ) ); //container.RegisterType<IWorkerService, WorkerService>(); //container.RegisterType<IWorkerSigninService, WorkerSigninService>(); //container.RegisterType<ILookupService, LookupService>(); //// LookupCache will populate static values in the domain for service lookups } return container; }
public override void Render() { StringBuilder result = new StringBuilder(); InstanceCollection instances = new InstanceCollection(); StoredPortalCredentials credentials = new StoredPortalCredentials(); foreach (string instance in instances.Instances.Keys) { result.Append("<div class=\"Instance\">"); result.Append(string.Format( "<h1>{0}</h1>", instance )); foreach (string portal in instances.Instances[instance].Portals.Keys) { string host = instances.Instances[instance].Portals[portal].Host; if (credentials.Credentials.ContainsKey(host)) { result.Append(string.Format( "<div class=\"Portal\" onclick=\"if(event.target.nodeName == 'IMG')return;SingleSignOn('{0}', '{1}', '{2}')\"><table>", host, credentials.Credentials[host].Username, credentials.Credentials[host].Password )); } else { result.Append(string.Format( "<div class=\"Portal\" onclick=\"CreateSingleSignOn('{0}')\"><table>", host )); } result.Append(string.Format( "<tr><td colspan=\"2\"><b>{0}</b></td>", host )); if (credentials.Credentials.ContainsKey(host)) { result.Append(string.Format( "<tr><td><b>{0}</b></td><td>{1}</td><td><img src=\"/Images/Icons/Delete.png\" onclick=\"DeleteSingleSignOn('{2}')\" /></td></tr>", Global.LanguageManager.GetText("Username"), credentials.Credentials[host].Username, host )); } else { result.Append(string.Format( "<tr><td><td>{0}</td></tr>", Global.LanguageManager.GetText("PortalCredentialsNotExist") )); } result.Append("</table></div>"); } result.Append("</div>"); } this.Controls.Add(new LiteralControl(result.ToString())); }