コード例 #1
0
        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));
            }
        }
コード例 #2
0
        public string UpdateScope(string oldName, string displayName, string newDescription, string cacheDBConnStr, string permissions)
        {
            string obj = null;

            try
            {
                List <string> groups = new List <string>();
                if (permissions.Contains(","))
                {
                    string[] arrstring = permissions.Split(',');
                    groups = new List <string>(arrstring);
                }
                else
                {
                    groups.Add(permissions);
                }
                ScopeProject scope = new ScopeProject()
                {
                    Name          = oldName,
                    DisplayName   = displayName,
                    Description   = newDescription,
                    Configuration = new org.iringtools.library.Configuration()
                    {
                        AppSettings = new AppSettings()
                    },
                    PermissionGroup = new PermissionGroups()
                };
                if (!string.IsNullOrEmpty(permissions))
                {
                    scope.PermissionGroup.AddRange(groups);
                }

                if (!String.IsNullOrWhiteSpace(cacheDBConnStr))
                {
                    scope.Configuration.AppSettings.Settings = new List <Setting>()
                    {
                        new Setting()
                        {
                            Key   = "iRINGCacheConnStr",
                            Value = cacheDBConnStr
                        }
                    };
                }

                string        uri    = string.Format("/scopes/{0}", oldName);
                WebHttpClient client = CreateWebClient(_adapterServiceUri);
                obj = client.Post <ScopeProject>(uri, scope, true);
            }
            catch (Exception ex)
            {
                _logger.Error(ex.ToString());
                throw;
            }

            return(obj);
        }
コード例 #3
0
ファイル: AdapterService.cs プロジェクト: heyena/iring-tools
 public Response UpdateScope(string scope, ScopeProject updatedScope)
 {
     try
     {
         return(_adapterProvider.UpdateScope(scope, updatedScope));
     }
     catch (Exception ex)
     {
         //return PrepareErrorResponse(ex);
         return(PrepareErrorResponse(ex, ErrorMessages.errUpdateScope));
     }
 }
コード例 #4
0
ファイル: AdapterService.cs プロジェクト: heyena/iring-tools
 public Response AddScope(ScopeProject scope)
 {
     try
     {
         return(_adapterProvider.AddScope(scope));
     }
     catch (Exception ex)
     {
         // return PrepareErrorResponse(ex);
         return(PrepareErrorResponse(ex, ErrorMessages.errAddScope));
     }
 }
コード例 #5
0
        public ScopeProject GetScope(string scopeName)
        {
            ScopeProject scope = null;

            try
            {
                WebHttpClient client = CreateWebClient(_adapterServiceUri);
                scope = client.Get <ScopeProject>("/scopes/" + scopeName);
            }
            catch (Exception ex)
            {
                _logger.Error(ex.ToString());
                throw;
            }



            return(scope);
        }
コード例 #6
0
        private void comboBoxProjectName_SelectionChanged(object sender, RoutedEventArgs e)
        {
            try
            {
                if (comboBoxProjectName.SelectedIndex != -1)
                {
                    _project = (ScopeProject)comboBoxProjectName.SelectedItem;
                    comboBoxAppName.DisplayMemberPath = "Name";
                    comboBoxAppName.ItemsSource       = _project.Applications;
                    comboBoxAppName.SelectionChanged += new SelectionChangedEventHandler(comboBoxAppName_SelectionChanged);
                    comboBoxAppName.SelectedIndex     = 0;
                }
            }
            catch (Exception ex)
            {
                _messages.Clear();

                _messages.Add(new StatusMessage {
                    Message = ex.ToString(), ImageName = "Resources/error_22.png"
                });
            }
        }
コード例 #7
0
        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;
            }
        }