public JsonResult SwitchDataMode(FormCollection form) { try { string context = form["nodeid"]; string mode = form["mode"]; string[] names = context.Split('/'); string scopeName = names[0]; string applicationName = names[1]; Response response = _repository.SwitchDataMode(scopeName, applicationName, mode); List <JsonTreeNode> nodes = new List <JsonTreeNode>(); JsonTreeNode dataObjectsNode = new JsonTreeNode { nodeType = "async", type = "DataObjectsNode", iconCls = "folder", id = context + "/DataObjects", text = "Data Objects", expanded = false, leaf = false, children = null, property = new Dictionary <string, string>() }; ScopeProject scope = _repository.GetScope(scopeName); if (scope != null) { ScopeApplication application = scope.Applications.Find(x => x.Name.ToLower() == applicationName.ToLower()); if (application != null) { // dataObjectsNode.property.Add("Data Mode", application.DataMode.ToString()); dataObjectsNode.property.Add("Data Mode", mode.ToString()); } } nodes.Add(dataObjectsNode); if (response.Level == StatusLevel.Success) { return(Json(new { success = true, response, nodes }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = response.Messages, stackTraceDescription = response.StatusText }, JsonRequestBehavior.AllowGet)); } //return Json(response, JsonRequestBehavior.AllowGet); } catch (Exception e) { _CustomErrorLog = new CustomErrorLog(); _CustomError = _CustomErrorLog.customErrorLogger(ErrorMessages.errUISwitchDataMode, e, _logger); return(Json(new { success = false, message = "[ Message Id " + _CustomError.msgId + "] - " + _CustomError.errMessage, stackTraceDescription = _CustomError.stackTraceDescription }, JsonRequestBehavior.AllowGet)); } }
public Response UpdateApplication(string scope, string app, ScopeApplication updatedApplication) { try { return(_adapterProvider.UpdateApplication(scope, app, updatedApplication)); } catch (Exception ex) { // return PrepareErrorResponse(ex); return(PrepareErrorResponse(ex, ErrorMessages.errUpdateApplication)); } }
public Response AddApplication(string scope, ScopeApplication application) { try { return(_adapterProvider.AddApplication(scope, application)); } catch (Exception ex) { //return PrepareErrorResponse(ex); return(PrepareErrorResponse(ex, ErrorMessages.errAddNewApplication)); } }
private void comboBoxAppName_SelectionChanged(object sender, RoutedEventArgs e) { try { _application = (ScopeApplication)comboBoxAppName.SelectedItem; if (_application != null && _application.Name != null && _application.Name != String.Empty) { WebClient client = new WebClient(); #region Prepare proxy and facade credentials if required if (!String.IsNullOrEmpty(_proxyHost) && !String.IsNullOrEmpty(_proxyPort)) { WebProxy proxy = new WebProxy(_proxyHost, Convert.ToInt16(_proxyPort)); proxy.Credentials = CredentialCache.DefaultCredentials; client.Proxy = proxy; } else { client.Proxy.Credentials = CredentialCache.DefaultCredentials; } if (chkboxAdapterCredentials.IsChecked == true) { NetworkCredential credential = new NetworkCredential(_adapterCredentialUsername, _adapterCredentialPassword, _adapterCredentialDomain); client.Credentials = credential; } else { client.Credentials = CredentialCache.DefaultCredentials; } #endregion client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_GetMappingCompleted); Uri mappingURI = new Uri(textBoxAdapterURL.Text + "/" + _project.Name + "/" + _application.Name + "/mapping"); client.DownloadStringAsync(mappingURI); } } catch (Exception ex) { _messages.Clear(); _messages.Add(new StatusMessage { Message = ex.ToString(), ImageName = "Resources/error_22.png" }); } }
public string UpdateApplication(string scopeName, string applicationName, ScopeApplication application) { string obj = null; try { string uri = String.Format("/scopes/{0}/apps/{1}", scopeName, applicationName); WebHttpClient client = CreateWebClient(_adapterServiceUri); obj = client.Post <ScopeApplication>(uri, application, true); } catch (Exception ex) { _logger.Error(ex.ToString()); throw; } return(obj); }
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 ActionResult GetNode(FormCollection form) { try { _logger.Debug("GetNode type: " + form["type"]); _repository.Session = Session; switch (form["type"]) { case "ScopesNode": { System.Collections.IEnumerator ie = Session.GetEnumerator(); while (ie.MoveNext()) { Session.Remove(ie.Current.ToString()); ie = Session.GetEnumerator(); } List <JsonTreeNode> nodes = new List <JsonTreeNode>(); var contexts = _repository.GetScopes(); if (contexts != null) { foreach (ScopeProject scope in contexts) { JsonTreeNode node = new JsonTreeNode { nodeType = "async", type = "ScopeNode", iconCls = "scope", id = scope.Name, text = scope.DisplayName, expanded = false, leaf = false, children = null, record = scope }; node.property = new Dictionary <string, string>(); node.property.Add("Internal Name", scope.Name); node.property.Add("Display Name", scope.DisplayName); node.property.Add("Description", scope.Description); nodes.Add(node); } } return(Json(nodes, JsonRequestBehavior.AllowGet)); } case "ScopeNode": { List <JsonTreeNode> nodes = new List <JsonTreeNode>(); ScopeProject scope = _repository.GetScope(form["node"]); foreach (ScopeApplication application in scope.Applications) { Configuration config = _repository.GetConfig(scope.Name, application.Name); application.Configuration = config; DataLayer dataLayer = _repository.GetDataLayer(scope.Name, application.Name); if (dataLayer != null) { JsonTreeNode node = new JsonTreeNode { nodeType = "async", type = "ApplicationNode", iconCls = "application", id = scope.Name + "/" + application.Name, text = application.DisplayName, expanded = false, leaf = false, children = null, record = new { Name = application.Name, DisplayName = application.DisplayName, Description = application.Description, DataLayer = dataLayer.Name, Assembly = dataLayer.Assembly, Configuration = application.Configuration, CacheImportURI = application.CacheInfo == null ? "" : application.CacheInfo.ImportURI, CacheTimeout = application.CacheInfo == null ? "" : Convert.ToString(application.CacheInfo.Timeout), PermissionGroups = application.PermissionGroup } }; node.property = new Dictionary <string, string>(); node.property.Add("Internal Name", application.Name); node.property.Add("Display Name", application.DisplayName); node.property.Add("Description", application.Description); node.property.Add("Data Layer", dataLayer.Name); node.property.Add("LightweightDataLayer", dataLayer.IsLightweight ? "Yes" : "No"); nodes.Add(node); } } ActionResult result = Json(nodes, JsonRequestBehavior.AllowGet); return(result); } case "ApplicationNode": { string context = form["node"]; string[] contextParts = context.Split(new char[] { '/' }); string scopeName = contextParts[0]; string applicationName = contextParts[1]; List <JsonTreeNode> nodes = new List <JsonTreeNode>(); JsonTreeNode dataObjectsNode = new JsonTreeNode { nodeType = "async", type = "DataObjectsNode", iconCls = "folder", id = context + "/DataObjects", text = "Data Objects", expanded = false, leaf = false, children = null, property = new Dictionary <string, string>() }; ScopeProject scope = _repository.GetScope(scopeName); if (scope != null) { ScopeApplication application = scope.Applications.Find(x => x.Name.ToLower() == applicationName.ToLower()); if (application != null) { dataObjectsNode.property.Add("Data Mode", application.DataMode.ToString()); } } JsonTreeNode graphsNode = new JsonTreeNode { nodeType = "async", type = "GraphsNode", iconCls = "folder", id = context + "/Graphs", text = "Graphs", expanded = false, leaf = false, children = null }; JsonTreeNode ValueListsNode = new JsonTreeNode { nodeType = "async", type = "ValueListsNode", iconCls = "folder", id = context + "/ValueLists", text = "ValueLists", expanded = false, leaf = false, children = null }; nodes.Add(dataObjectsNode); nodes.Add(graphsNode); nodes.Add(ValueListsNode); return(Json(nodes, JsonRequestBehavior.AllowGet)); } case "ValueListsNode": { string context = form["node"]; string scopeName = context.Split('/')[0]; string applicationName = context.Split('/')[1]; Mapping mapping = GetMapping(scopeName, applicationName); List <JsonTreeNode> nodes = new List <JsonTreeNode>(); foreach (ValueListMap valueList in mapping.valueListMaps) { JsonTreeNode node = new JsonTreeNode { nodeType = "async", type = "ValueListNode", iconCls = "valuemap", id = context + "/ValueList/" + valueList.name, text = valueList.name, expanded = false, leaf = false, children = null, record = valueList }; node.property = new Dictionary <string, string>(); node.property.Add("Name", valueList.name); nodes.Add(node); } return(Json(nodes, JsonRequestBehavior.AllowGet)); } case "ValueListNode": { string context = form["node"]; string scopeName = context.Split('/')[0]; string applicationName = context.Split('/')[1]; string valueList = context.Split('/')[4]; List <JsonTreeNode> nodes = new List <JsonTreeNode>(); Mapping mapping = GetMapping(scopeName, applicationName); ValueListMap valueListMap = mapping.valueListMaps.Find(c => c.name == valueList); foreach (var valueMap in valueListMap.valueMaps) { string classLabel = String.Empty; if (!String.IsNullOrEmpty(valueMap.uri)) { string valueMapUri = valueMap.uri.Split(':')[1]; if (!String.IsNullOrEmpty(valueMap.label)) { classLabel = valueMap.label; } else if (Session[valueMapUri] != null) { classLabel = (string)Session[valueMapUri]; } else { classLabel = GetClassLabel(valueMapUri); Session[valueMapUri] = classLabel; } } JsonTreeNode node = new JsonTreeNode { nodeType = "async", type = "ListMapNode", iconCls = "valuelistmap", id = context + "/ValueMap/" + valueMap.internalValue, text = classLabel + " [" + valueMap.internalValue + "]", expanded = false, leaf = true, children = null, record = valueMap }; node.property = new Dictionary <string, string>(); node.property.Add("Name", valueMap.internalValue); node.property.Add("Class Label", classLabel); nodes.Add(node); } return(Json(nodes, JsonRequestBehavior.AllowGet)); } case "DataObjectsNode": { string context = form["node"]; string scopeName = context.Split('/')[0]; string applicationName = context.Split('/')[1]; string dataLayer = form["datalayer"]; string refresh = form["refresh"]; if (refresh == "true") { Response response = _repository.Refresh(scopeName, applicationName); _logger.Info(Utility.Serialize <Response>(response, true)); } List <JsonTreeNode> nodes = new List <JsonTreeNode>(); DataDictionary dictionary = _repository.GetDictionary(scopeName, applicationName); if (dictionary != null && dictionary.dataObjects != null) { foreach (DataObject dataObject in dictionary.dataObjects) { JsonTreeNode node = new JsonTreeNode { nodeType = "async", type = "DataObjectNode", iconCls = "treeObject", id = context + "/DataObject/" + dataObject.objectName, text = dataObject.objectName, expanded = false, leaf = false, children = null, hidden = dataObject.isHidden, record = new { Name = dataObject.objectName, DataLayer = dataLayer } }; if (dataObject.isRelatedOnly) { node.hidden = true; } node.property = new Dictionary <string, string>(); node.property.Add("Object Name", dataObject.objectName); node.property.Add("Is Readonly", dataObject.isReadOnly.ToString()); node.property.Add("Properties Count", dataObject.dataProperties.Count.ToString()); nodes.Add(node); } } return(Json(nodes, JsonRequestBehavior.AllowGet)); } case "DataObjectNode": { string keyType, dataType; string context = form["node"]; string scopeName = context.Split('/')[0]; string applicationName = context.Split('/')[1]; string dataObjectName = context.Split('/')[4]; DataDictionary dictionary = _repository.GetDictionary(scopeName, applicationName); DataObject dataObject = dictionary.dataObjects.FirstOrDefault(o => o.objectName == dataObjectName); List <JsonTreeNode> nodes = new List <JsonTreeNode>(); foreach (DataProperty property in dataObject.dataProperties) { keyType = getKeyType(property.propertyName, dataObject.dataProperties); dataType = property.dataType.ToString(); bool isKeyProp = dataObject.isKeyProperty(property.propertyName); JsonTreeNode node = new JsonTreeNode { nodeType = "async", type = isKeyProp ? "KeyDataPropertyNode" : "DataPropertyNode", iconCls = isKeyProp ? "treeKey" : "treeProperty", id = context + "/" + dataObject.objectName + "/" + property.propertyName, text = property.propertyName, expanded = true, leaf = true, children = new List <JsonTreeNode>(), record = new { Name = property.propertyName, Keytype = keyType, Datatype = dataType } }; node.property = new Dictionary <string, string>(); node.property.Add("Name", property.propertyName); node.property.Add("Datatype", dataType); node.property.Add("Data Length", property.dataLength.ToString()); //node.property.Add("isVirtual", property.isVirtual.ToString()); if (isKeyProp) { node.property.Add("Keytype", keyType); } nodes.Add(node); } if (dataObject.dataRelationships.Count > 0) { foreach (DataRelationship relation in dataObject.dataRelationships) { JsonTreeNode node = new JsonTreeNode { nodeType = "async", type = "RelationshipNode", iconCls = "treeRelation", id = context + "/" + dataObject.objectName + "/" + relation.relationshipName, text = relation.relationshipName, expanded = false, leaf = false, children = null, record = new { Name = relation.relationshipName, Type = relation.relationshipType, Related = relation.relatedObjectName } }; node.property = new Dictionary <string, string>(); node.property.Add("Name", relation.relationshipName); node.property.Add("Type", relation.relationshipType.ToString()); node.property.Add("Related", relation.relatedObjectName); nodes.Add(node); } } return(Json(nodes, JsonRequestBehavior.AllowGet)); } case "RelationshipNode": { string keytype, datatype; string context = form["node"]; string related = form["related"]; List <JsonTreeNode> nodes = new List <JsonTreeNode>(); if (!String.IsNullOrEmpty(related)) { string scopeName = context.Split('/')[0]; string applicationName = context.Split('/')[1]; DataDictionary dictionary = _repository.GetDictionary(scopeName, applicationName); DataObject dataObject = dictionary.dataObjects.FirstOrDefault(o => o.objectName.ToUpper() == related.ToUpper()); foreach (DataProperty property in dataObject.dataProperties) { keytype = getKeyType(property.propertyName, dataObject.dataProperties); datatype = property.dataType.ToString(); JsonTreeNode node = new JsonTreeNode { nodeType = "async", type = (dataObject.isKeyProperty(property.propertyName)) ? "KeyDataPropertyNode" : "DataPropertyNode", iconCls = (dataObject.isKeyProperty(property.propertyName)) ? "treeKey" : "treeProperty", id = context + "/" + property.propertyName, text = property.propertyName, expanded = true, leaf = true, children = new List <JsonTreeNode>(), record = new { Name = property.propertyName, Keytype = keytype, Datatype = datatype } }; node.property = new Dictionary <string, string>(); node.property.Add("Name", property.propertyName); node.property.Add("Type", keytype); node.property.Add("Related", datatype); nodes.Add(node); } } return(Json(nodes, JsonRequestBehavior.AllowGet)); } case "GraphsNode": { string context = form["node"]; string scopeName = context.Split('/')[0]; string applicationName = context.Split('/')[1]; Mapping mapping = GetMapping(scopeName, applicationName); List <JsonTreeNode> nodes = new List <JsonTreeNode>(); foreach (GraphMap graph in mapping.graphMaps) { JsonTreeNode node = new JsonTreeNode { nodeType = "async", type = "GraphNode", iconCls = "treeGraph", id = context + "/Graph/" + graph.name, text = graph.name, expanded = true, leaf = true, children = new List <JsonTreeNode>(), record = graph }; ClassMap classMap = graph.classTemplateMaps[0].classMap; node.property = new Dictionary <string, string>(); node.property.Add("Data Object", graph.dataObjectName); node.property.Add("Root Class", classMap.name); nodes.Add(node); } return(Json(nodes, JsonRequestBehavior.AllowGet)); } default: { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } } } catch (Exception e) { _logger.Error(e.ToString()); throw e; } }