Exemplo n.º 1
0
 ///Done by: Ganesh Bisht: Polaris
 /// <summary>
 /// This is used to get all the files available for download under specific scope and application
 /// </summary>
 /// <param name="scope">scope name</param>
 /// <param name="application">application name</param>
 /// <returns>json</returns>
 public JsonResult GetFiles(string scope, string application)
 {
     try
     {
         List <Files> files = _repository.getDownloadedList(scope, application);
         return(Json(files, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ioEx)
     {
         _logger.Error(ioEx.Message);
         _CustomErrorLog = new CustomErrorLog();
         _CustomError    = _CustomErrorLog.customErrorLogger(ErrorMessages.errUIGetFile, ioEx, _logger);
         return(Json(new { success = false, message = "[ Message Id " + _CustomError.msgId + "] - " + _CustomError.errMessage, stackTraceDescription = _CustomError.stackTraceDescription }, JsonRequestBehavior.AllowGet));
         // throw ioEx;
     }
 }
Exemplo n.º 2
0
 public PermissionGroups GetAllLDAPSecurityGroups()
 {
     try
     {
         OutgoingWebResponseContext context = WebOperationContext.Current.OutgoingResponse;
         context.ContentType = "application/xml";
         return(_adapterProvider.GetAllSecurityGroups());
     }
     catch (Exception ex)
     {
         CustomErrorLog objCustomErrorLog = new CustomErrorLog();
         _CustomError = objCustomErrorLog.customErrorLogger(ErrorMessages.errSecurityGroups, ex, _logger);
         objCustomErrorLog.throwJsonResponse(_CustomError);
         return(null);
     }
 }
Exemplo n.º 3
0
 public CacheInfo GetCacheInfo(string scope, string app)
 {
     try
     {
         OutgoingWebResponseContext context = WebOperationContext.Current.OutgoingResponse;
         context.ContentType = "application/xml";
         return(_adapterProvider.GetCacheInfo(scope, app));
     }
     catch (Exception ex)
     {
         CustomErrorLog objCustomErrorLog = new CustomErrorLog();
         _CustomError = objCustomErrorLog.customErrorLogger(ErrorMessages.errGetCacheInfo, ex, _logger);
         objCustomErrorLog.throwJsonResponse(_CustomError);
         return(null);
     }
 }
Exemplo n.º 4
0
        ///Done by: Ganesh Bisht: Polaris
        /// <summary>
        /// Used for upload any generic file for particular scope and application
        /// </summary>
        /// <param name="form"></param>
        /// <returns>json</returns>
        public JsonResult Upload(FormCollection form)
        {
            try
            {
                // string datalayer = "org.iringtools.adapter.datalayer.SpreadsheetDatalayer, SpreadsheetDatalayer";
                string savedFileName = string.Empty;

                HttpFileCollectionBase files = Request.Files;

                foreach (string file in files)
                {
                    string             filename = string.Empty;
                    HttpPostedFileBase hpf      = files[file] as HttpPostedFileBase;
                    if (hpf.ContentLength == 0)
                    {
                        continue;
                    }
                    filename = hpf.FileName;
                    if (filename.Contains("\\"))
                    {
                        filename = filename.Substring(filename.LastIndexOf('\\') + 1);
                    }
                    string   fileLocation = string.Format(@"{0}{1}.{2}.{3}", _settings["AppDataPath"], form["Scope"], form["Application"], filename);
                    Response rs           = _repository.PostFile(form["Scope"], form["Application"], hpf.InputStream, fileLocation);

                    //break;
                }
            }
            catch (Exception ex)
            {
                //return new JsonResult()
                //{
                //    ContentType = "text/html",
                //    Data = PrepareErrorResponse(ex)
                //};

                _logger.Error(ex.Message);
                _CustomErrorLog = new CustomErrorLog();
                _CustomError    = _CustomErrorLog.customErrorLogger(ErrorMessages.errUIUploadFile, ex, _logger);
                return(Json(new { success = false, message = "[ Message Id " + _CustomError.msgId + "] - " + _CustomError.errMessage, stackTraceDescription = _CustomError.stackTraceDescription }, JsonRequestBehavior.AllowGet));
            }
            return(new JsonResult()
            {
                ContentType = "text/html",
                Data = new { success = true }
            });
        }
Exemplo n.º 5
0
        public void GetDatalayers()
        {
            try
            {
                DataLayers dataLayers = _adapterProvider.GetDataLayers();
                string     xml        = Utility.Serialize <DataLayers>(dataLayers, true);

                HttpContext.Current.Response.ContentType = "application/xml";
                HttpContext.Current.Response.Write(xml);
            }
            catch (Exception e)
            {
                CustomErrorLog objCustomErrorLog = new CustomErrorLog();
                _CustomError = objCustomErrorLog.customErrorLogger(ErrorMessages.errGetDataLayer, e, _logger);
                objCustomErrorLog.throwJsonResponse(_CustomError);
            }
        }
Exemplo n.º 6
0
        public NameValueList GetUISettings()
        {
            try
            {
                OutgoingWebResponseContext context = WebOperationContext.Current.OutgoingResponse;
                context.ContentType = "application/xml";

                return(_adapterProvider.GetGlobalUISettings());
            }
            catch (Exception ex)
            {
                CustomErrorLog objCustomErrorLog = new CustomErrorLog();
                _CustomError = objCustomErrorLog.customErrorLogger(ErrorMessages.errGetUISettings, ex, _logger);
                objCustomErrorLog.throwJsonResponse(_CustomError);
                return(null);
            }
        }
Exemplo n.º 7
0
        public StoreViewModel GetGrid(string scope, string app, string graph, DataFilter filter, string start, string limit)
        {
            try
            {
                this.graph = graph;

                if (start == "0" || start == "1")
                {
                    GetDataDictionary(scope, app, false);
                }
                else
                {
                    GetDataDictionary(scope, app);
                }

                if (response != "")
                {
                    return(null);
                }

                GetDataItems(scope, app, graph, filter, start, limit);

                if (response != "")
                {
                    return(null);
                }

                GetDataGrid();

                if (response != "")
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                //response = response + " " + ex.Message.ToString();
                CustomErrorLog objCustomErrorLog = new CustomErrorLog();
                _CustomError = objCustomErrorLog.customErrorLogger(ErrorMessages.errUIGridPages, ex, _logger);
                response     = response + " " + throwJsonResponse(_CustomError);
            }

            return(dataGrid);
        }
Exemplo n.º 8
0
        ///Done by: Ganesh Bisht: Polaris
        /// <summary>
        ///  Used for downloading the file
        /// </summary>
        /// <param name="scope"> scope name</param>
        /// <param name="application"> application name</param>
        /// <param name="file"> file to be downloaded</param>
        /// <returns>action result</returns>
        public ActionResult Export(string scope, string application, string file)
        {
            try
            {
                string filename = file.Substring(0, file.LastIndexOf('.'));
                string ext      = file.Substring(file.LastIndexOf('.') + 1);

                byte[] bytes = _repository.getFile(scope, application, filename, ext);
                return(File(bytes, "application/octet-stream", string.Format("{0}.{1}", filename, ext)));
            }
            catch (Exception ioEx)
            {
                _logger.Error(ioEx.Message);
                _CustomErrorLog = new CustomErrorLog();
                _CustomError    = _CustomErrorLog.customErrorLogger(ErrorMessages.errUIExportFile, ioEx, _logger);
                return(Json(new { success = false, message = "[ Message Id " + _CustomError.msgId + "] - " + _CustomError.errMessage, stackTraceDescription = _CustomError.stackTraceDescription }, JsonRequestBehavior.AllowGet));

                //throw ioEx;
            }
        }
Exemplo n.º 9
0
        //Overloading method added by Atul

        private Response PrepareErrorResponse(Exception ex, string errMsg)
        {
            CustomErrorLog objCustomErrorLog = new CustomErrorLog();

            _CustomError = objCustomErrorLog.customErrorLogger(errMsg, ex, _logger);
            Response response = new Response
            {
                Level    = StatusLevel.Error,
                Messages = new Messages
                {
                    //ex.Message
                    "[ Message Id " + _CustomError.msgId + "] - " + errMsg
                },
                StatusText = "[ " + _CustomError.msgId + "] " + _CustomError.stackTraceDescription,
                StatusCode = HttpStatusCode.InternalServerError,
                StatusList = null
            };

            return(response);
        }
Exemplo n.º 10
0
        private void GetDataItems(string scope, string app, string graph, DataFilter dataFilter, string start, string limit)
        {
            try
            {
                string format = "json";

                string relativeUri   = "/" + app + "/" + scope + "/" + graph + "/filter?format=" + format + "&start=" + start + "&limit=" + limit;
                string dataItemsJson = string.Empty;

                WebHttpClient client  = CreateWebClient(_dataServiceUri);
                string        isAsync = _settings["Async"];

                if (isAsync != null && isAsync.ToLower() == "true")
                {
                    client.Async = true;
                    string statusUrl = client.Post <DataFilter, string>(relativeUri, dataFilter, format, true);

                    if (string.IsNullOrEmpty(statusUrl))
                    {
                        throw new Exception("Asynchronous status URL not found.");
                    }

                    dataItemsJson = WaitForRequestCompletion <string>(_dataServiceUri, statusUrl);
                }
                else
                {
                    dataItemsJson = client.Post <DataFilter, string>(relativeUri, dataFilter, format, true);
                }

                DataItemSerializer serializer = new DataItemSerializer();
                dataItems = serializer.Deserialize <DataItems>(dataItemsJson, false);
            }
            catch (Exception ex)
            {
                _logger.Error("Error getting data items." + ex);
                //response = response + " " + ex.Message.ToString();
                CustomErrorLog objCustomErrorLog = new CustomErrorLog();
                _CustomError = objCustomErrorLog.customErrorLogger(ErrorMessages.errUIGridPages, ex, _logger);
                response     = response + " " + throwJsonResponse(_CustomError);
            }
        }
Exemplo n.º 11
0
 public void RefreshAll(string scope, string app)
 {
     try
     {
         if (IsAsync())
         {
             string statusUrl = _adapterProvider.AsyncRefreshDictionary(scope, app);
             WebOperationContext.Current.OutgoingResponse.StatusCode          = HttpStatusCode.Accepted;
             WebOperationContext.Current.OutgoingResponse.Headers["location"] = statusUrl;
         }
         else
         {
             Response response = _adapterProvider.RefreshAll(scope, app);
             _adapterProvider.FormatOutgoingMessage <Response>(response, "xml", true);
         }
     }
     catch (Exception ex)
     {
         CustomErrorLog objCustomErrorLog = new CustomErrorLog();
         _CustomError = objCustomErrorLog.customErrorLogger(ErrorMessages.errRefreshAll, ex, _logger);
         objCustomErrorLog.throwJsonResponse(_CustomError);
     }
 }
Exemplo n.º 12
0
        private void GetDataItems(string scope, string app, string graph, string filter, string sort, string dir, string start, string limit)
        {
            try
            {
                string format = "json";
                if (sort != null)
                {
                    string[] sortArr = sort.Split('\"');
                    sort = sortArr[3];
                    dir  = sortArr[7];
                }

                DataFilter dataFilter    = CreateDataFilter(filter, sort, dir);
                string     relativeUri   = "/" + app + "/" + scope + "/" + graph + "/filter?format=" + format + "&start=" + start + "&limit=" + limit;
                string     dataItemsJson = string.Empty;

                WebHttpClient client  = CreateWebClient(_dataServiceUri);
                string        isAsync = _settings["Async"];


                DataItems sessionDataItem = null;
                sessionDataItem = (DataItems)Session[keyName];
                bool item = false;


                if (sessionDataItem != null)
                {
                    if (filter == null)
                    {
                        var data = (from d in sessionDataItem.items
                                    select d).Skip(int.Parse(start)).Take(int.Parse(limit)).AsEnumerable().ToList();
                        if (data.Count == 0)
                        {
                            item = true;
                        }
                        else
                        {
                            dataItems       = new DataItems();
                            dataItems.items = data;
                            dataItems.limit = data.Count;
                            dataItems.total = sessionDataItem.total;
                        }
                    }
                    else
                    {
                        item = true;
                    }
                }

                if (sessionDataItem == null || item)
                {
                    if (isAsync != null && isAsync.ToLower() == "true")
                    {
                        client.Async = true;
                        string statusUrl = client.Post <DataFilter, string>(relativeUri, dataFilter, format, true);

                        if (string.IsNullOrEmpty(statusUrl))
                        {
                            throw new Exception("Asynchronous status URL not found.");
                        }

                        dataItemsJson = WaitForRequestCompletion <string>(_dataServiceUri, statusUrl);
                    }
                    else
                    {
                        dataItemsJson = client.Post <DataFilter, string>(relativeUri, dataFilter, format, true);
                    }

                    DataItemSerializer serializer = new DataItemSerializer();
                    dataItems = serializer.Deserialize <DataItems>(dataItemsJson, false);


                    mergeSessionData(dataItems);

                    if (Convert.ToInt32(start) == 0)
                    {
                        Session.Add(keyName, dataItems);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Error getting data items." + ex);
                //response = response + " " + ex.Message.ToString();
                CustomErrorLog objCustomErrorLog = new CustomErrorLog();
                _CustomError = objCustomErrorLog.customErrorLogger("Cache entry has not been created. You need to refresh or import cache files.", ex, _logger);
                //_CustomError = objCustomErrorLog.customErrorLogger(ErrorMessages.errUIGridPages, ex, _logger);
                response = response + " " + throwJsonResponse(_CustomError);
            }
        }
Exemplo n.º 13
0
        private void GetDataDictionary(String scope, String app, bool usesCache)
        {
            try
            {
                string dictKey = string.Format("Dictionary.{0}.{1}", scope, app);

                if (usesCache)
                {
                    dataDict = (DataDictionary)Session[dictKey];
                }
                else
                {
                    dataDict = null;
                }

                if (dataDict == null)
                {
                    WebHttpClient client = CreateWebClient(_dataServiceUri);
                    dataDict = client.Get <DataDictionary>("/" + app + "/" + scope + "/dictionary?format=xml", true);

                    // sort data objects & properties
                    if (dataDict != null && dataDict.dataObjects.Count > 0)
                    {
                        dataDict.dataObjects.Sort(new DataObjectComparer());

                        foreach (DataObject dataObject in dataDict.dataObjects)
                        {
                            dataObject.dataProperties.Sort(new DataPropertyComparer());

                            // Adding Key elements to TOP of the List.
                            List <String> keyPropertyNames = new List <String>();
                            foreach (KeyProperty keyProperty in dataObject.keyProperties)
                            {
                                keyPropertyNames.Add(keyProperty.keyPropertyName);
                            }
                            var value = "";
                            for (int i = 0; i < keyPropertyNames.Count; i++)
                            {
                                value = keyPropertyNames[i];
                                // removing the property name from the list and adding at TOP
                                List <DataProperty> DataProperties = dataObject.dataProperties;
                                DataProperty        prop           = null;

                                for (int j = 0; j < DataProperties.Count; j++)
                                {
                                    if (DataProperties[j].propertyName == value)
                                    {
                                        prop = DataProperties[j];
                                        DataProperties.RemoveAt(j);
                                        break;
                                    }
                                }

                                if (prop != null)
                                {
                                    DataProperties.Insert(0, prop);
                                }
                            }
                        }
                    }

                    if (usesCache)
                    {
                        Session[dictKey] = dataDict;
                    }
                }

                if (dataDict == null || dataDict.dataObjects.Count == 0)
                {
                    response = response + "Data dictionary of [" + app + "] is empty.";
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Error getting dictionary." + ex);
                //response = response + " " + ex.Message.ToString();
                CustomErrorLog objCustomErrorLog = new CustomErrorLog();
                _CustomError = objCustomErrorLog.customErrorLogger(ErrorMessages.errUIGridPages, ex, _logger);
                response     = response + " " + throwJsonResponse(_CustomError);
            }
        }
Exemplo n.º 14
0
        public ActionResult ObjectsTreeSql(FormCollection form)
        {
            try
            {
                string scope          = form["scope"];
                string app            = form["app"];
                string selectedTables = form["selectedTables"];
                //for edit sqlconfiguration
                string dbProvider1 = Convert.ToString(form["dbProvider"].ToLower().IndexOf("mssql"));
                string dbServer    = form["dbServer"];
                string dbInstance  = form["dbInstance"];
                string dbName      = form["dbName"];
                string portNumber  = form["portNumber"];
                string serName     = form["serName"];
                string dbUserName  = form["dbUserName"];
                string dbPassword  = form["dbPassword"];
                string dbSchema    = form["dbSchema"];

                var connStr = (dbProvider1 != "-1") ? "Data Source=" + dbServer + "\\" + dbInstance + ";" + "Initial Catalog=" +
                              dbName + ";User ID=" + dbUserName + ";Password="******"Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" + dbServer + ")(PORT=" +
                              portNumber + "))(CONNECT_DATA=(" + serName + "=" + dbInstance +
                              ")));User Id=" + dbUserName + ";Password="******"Data Objects",
                    type       = "dataObjects",
                    iconCls    = "folder",
                    expanded   = true,
                    children   = new List <Node>(),
                    properties = new Dictionary <string, object>()
                };

                objectsTree.Add(root);

                DatabaseDictionary dictionary = _repository.GetDBDictionary(scope, app);

                Dictionary <string, string> conElts = null;
                if (dictionary != null && !string.IsNullOrEmpty(dictionary.ConnectionString))
                {
                    string dbProvider = dictionary.Provider;
                    string conStr     = Utility.DecodeFrom64(dictionary.ConnectionString);

                    if (connStr == "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=))(CONNECT_DATA=(=)));User Id=;Password="******"dbSchema"] = dictionary.SchemaName;
                        root.properties.Add("connectionInfo", conElts);
                    }
                    else
                    {
                        conElts             = GetConnectionElements(dbProvider, connStr);
                        conElts["dbSchema"] = dictionary.SchemaName;
                        root.properties.Add("connectionInfo", conElts);
                    }
                }
                else
                {
                    conElts = new Dictionary <string, string>();
                    conElts.Add("dbProvider", form["dbProvider"]);
                    conElts.Add("dbServer", form["dbServer"]);
                    conElts.Add("dbInstance", form["dbInstance"]);
                    conElts.Add("serName", form["serName"]);
                    conElts.Add("dbName", form["dbName"]);
                    conElts.Add("dbSchema", form["dbSchema"]);
                    conElts.Add("dbUserName", form["dbUserName"]);
                    conElts.Add("dbPassword", form["dbPassword"]);
                    conElts.Add("portNumber", form["portNumber"]);
                }

                List <DataObject> dbObjects = null;
                if (!string.IsNullOrEmpty(conElts["dbServer"]))
                {
                    //
                    // get available tables
                    //
                    List <string> availTables = _repository.GetTableNames(scope, app, conElts);
                    root.properties.Add("tableNames", availTables);

                    //
                    // get selected tables metadata
                    //
                    List <string> configTables = null;

                    if (!string.IsNullOrEmpty(selectedTables))
                    {
                        string[] array = selectedTables.Split(',');
                        configTables = new List <string>(array);
                    }
                    else if (dictionary != null && dictionary.dataObjects.Count > 0)
                    {
                        configTables = new List <string>();

                        foreach (DataObject dataObject in dictionary.dataObjects)
                        {
                            configTables.Add(dataObject.tableName);
                        }
                    }

                    if (configTables != null && configTables.Count > 0)
                    {
                        dbObjects = _repository.GetDBObjects(scope, app, conElts, configTables);
                    }
                }

                if (dbObjects != null)
                {
                    bool        checkDictionary = (dictionary != null && dictionary.dataObjects != null && dictionary.dataObjects.Count > 0);
                    List <Node> objectNodes     = root.children;

                    List <string> availTables = new List <string>();

                    foreach (DataObject dbObject in dbObjects)
                    {
                        availTables.Add(dbObject.tableName);

                        Node keyPropertiesNode = new Node()
                        {
                            text     = "Keys",
                            type     = "keys",
                            iconCls  = "folder",
                            expanded = true,
                            children = new List <Node>()
                        };

                        Node dataPropertiesNode = new Node()
                        {
                            text     = "Properties",
                            type     = "properties",
                            iconCls  = "folder",
                            expanded = true,
                            children = new List <Node>()
                        };

                        //Extention Properties___Starts
                        Node extensionPropertiesNode = new Node()
                        {
                            text     = "Extension",
                            type     = "extension",
                            iconCls  = "folder",
                            expanded = true,
                            children = new List <Node>()
                        };
                        //Extention Properties___Ends

                        Node relationshipsNode = new Node()
                        {
                            text     = "Relationships",
                            type     = "relationships",
                            iconCls  = "folder",
                            expanded = true,
                            children = new List <Node>()
                        };

                        //Creating list to contain data and key properties names
                        DataObject    tempDataObject = dictionary.dataObjects.Find(dObj => dObj.objectName == dbObject.objectName);
                        List <string> dataPropertyNamesCollection = new List <string>();
                        List <string> keyPropertyNamesCollection  = new List <string>();

                        if (tempDataObject != null && tempDataObject.dataProperties != null && tempDataObject.dataProperties.Count > 0)
                        {
                            foreach (DataProperty dProp in tempDataObject.dataProperties)
                            {
                                KeyProperty commonProperties = tempDataObject.keyProperties.Find(kProp => kProp.keyPropertyName == dProp.propertyName);

                                if (commonProperties == null)
                                {
                                    dataPropertyNamesCollection.Add(dProp.columnName);
                                }
                                else
                                {
                                    keyPropertyNamesCollection.Add(dProp.columnName);
                                }
                            }
                        }

                        // create object node
                        Node dataObjectNode = new Node()
                        {
                            text     = dbObject.tableName,
                            type     = "dataObject",
                            iconCls  = "treeObject",
                            children = new List <Node>()
                            {
                                keyPropertiesNode, dataPropertiesNode, extensionPropertiesNode, relationshipsNode
                            },
                            properties = new Dictionary <string, object>()
                            {
                                { "keyProperties", keyPropertyNamesCollection }, { "dataProperties", dbObject.dataProperties }, { "aliasDataProperties", dataPropertyNamesCollection }
                            }
                        };

                        DataObject dictObject = null;

                        //
                        // apply what has been configured in dictionary to db object
                        //
                        if (checkDictionary)
                        {
                            dictObject = dictionary.dataObjects.Find(x => x.tableName == dbObject.tableName);
                        }

                        if (dictObject == null)  // has not been configured
                        {
                            dataObjectNode.properties.Add("objectNamespace", ONS_PREFIX + scope + "." + app);
                            dataObjectNode.properties.Add("objectName", dbObject.objectName);
                            dataObjectNode.properties.Add("tableName", dbObject.tableName);
                            dataObjectNode.properties.Add("keyDelimiter", dbObject.keyDelimeter);
                            dataObjectNode.properties.Add("description", dbObject.description);

                            if (dbObject.aliasDictionary != null && dbObject.aliasDictionary.Count > 0)
                            {
                                dataObjectNode.properties.Add("aliasDictionary", dbObject.aliasDictionary["TABLE_NAME_IN"]);
                            }
                        }
                        else  // has been configured, apply object configurations
                        {
                            dataObjectNode.properties.Add("objectNamespace", ONS_PREFIX + scope + "." + app);
                            dataObjectNode.properties.Add("objectName", dictObject.objectName);
                            dataObjectNode.properties.Add("tableName", dictObject.tableName);
                            dataObjectNode.properties.Add("keyDelimiter", dictObject.keyDelimeter);
                            dataObjectNode.properties.Add("description", dictObject.description);

                            if (dictObject.aliasDictionary != null && dictObject.aliasDictionary.Count > 0)
                            {
                                dataObjectNode.properties.Add("aliasDictionary", dictObject.aliasDictionary["TABLE_NAME_IN"]);
                            }

                            // apply relationship configurations
                            foreach (DataRelationship relationship in dictObject.dataRelationships)
                            {
                                Node relationshipNode = new Node()
                                {
                                    text       = relationship.relationshipName,
                                    type       = "relationship",
                                    iconCls    = "relationship",
                                    leaf       = true,
                                    properties = new Dictionary <string, object>()
                                    {
                                        { "name", relationship.relationshipName },
                                        { "type", relationship.relationshipType.ToString() },
                                        { "sourceObject", dictObject.objectName },
                                        { "relatedObject", relationship.relatedObjectName },
                                        { "propertyMaps", relationship.propertyMaps }
                                    }
                                };

                                relationshipsNode.children.Add(relationshipNode);
                            }
                        }

                        foreach (DataProperty dbProperty in dbObject.dataProperties)
                        {
                            if (dictObject != null)
                            {
                                DataProperty dictProperty = dictObject.dataProperties.Find(x => x.columnName == dbProperty.columnName);

                                if (dictProperty != null)   // property has been configured
                                {
                                    Dictionary <string, object> properties = new Dictionary <string, object>()
                                    {
                                        { "columnName", dictProperty.columnName },
                                        { "propertyName", dictProperty.propertyName },
                                        { "aliasDictionary", dictProperty.aliasDictionary != null && dictProperty.aliasDictionary.ContainsKey("COLUMN_NAME_IN") ? dictProperty.aliasDictionary["COLUMN_NAME_IN"] : null },
                                        { "dataType", dictProperty.dataType },
                                        { "dataLength", dictProperty.dataLength },
                                        { "isNullable", dictProperty.isNullable },
                                        { "keyType", dictProperty.keyType },
                                        { "numberOfDecimals", dictProperty.numberOfDecimals },
                                        { "isReadOnly", dictProperty.isReadOnly },
                                        { "showOnIndex", dictProperty.showOnIndex },
                                        { "showOnSearch", dictProperty.showOnSearch },
                                        { "isHidden", dictProperty.isHidden },
                                        { "isVirtual", dictProperty.isVirtual },
                                        { "precision", dictProperty.precision },
                                        { "scale", dictProperty.scale }
                                    };

                                    bool isKey = false;

                                    if (dictObject.isKeyProperty(dictProperty.columnName))
                                    {
                                        Node keyPropertyNode = new Node()
                                        {
                                            text       = dictProperty.columnName,
                                            type       = "keyProperty",
                                            iconCls    = "treeKey",
                                            leaf       = true,
                                            properties = properties
                                        };

                                        keyPropertiesNode.children.Add(keyPropertyNode);
                                        isKey = true;
                                    }
                                    else if (!isKey)
                                    {
                                        Node dataPropertyNode = new Node()
                                        {
                                            text       = dictProperty.columnName,
                                            type       = "dataProperty",
                                            iconCls    = "treeProperty",
                                            leaf       = true,
                                            properties = properties
                                        };

                                        dataPropertiesNode.children.Add(dataPropertyNode);
                                    }
                                }
                            }
                        }

                        //Extension Properties___Starts
                        if (dictObject != null && dictObject.extensionProperties != null)
                        {
                            foreach (ExtensionProperty extProperty in dictObject.extensionProperties)
                            {
                                Dictionary <string, object> properties = new Dictionary <string, object>()
                                {
                                    { "columnName", extProperty.columnName },
                                    { "propertyName", extProperty.propertyName },
                                    { "dataType", extProperty.dataType },
                                    { "dataLength", extProperty.dataLength },
                                    { "isNullable", extProperty.isNullable },
                                    { "keyType", extProperty.keyType },
                                    { "showOnIndex", extProperty.showOnIndex },
                                    { "precision", extProperty.precision },
                                    { "scale", extProperty.scale },
                                    { "definition", extProperty.definition }  //[[By Deepak 12-Dec14,
                                    //{"parameters", extProperty.parameters}//Ends]]
                                };

                                Node extensionPropertyNode = new Node()
                                {
                                    text       = extProperty.columnName,
                                    type       = "extensionProperty",
                                    iconCls    = "treeExtension",
                                    leaf       = true,
                                    properties = properties
                                };

                                extensionPropertiesNode.children.Add(extensionPropertyNode);
                            }
                        }


                        objectNodes.Add(dataObjectNode);

                        List <string> extensionColoumn = new List <string>();
                        foreach (var extension in dbObject.dataProperties)
                        {
                            extensionColoumn.Add(extension.columnName);
                        }
                        dataObjectNode.properties.Add("extensionColoumn", extensionColoumn);
                        //Extension Properties___Ends
                    }

                    foreach (Node dataObjectNode in objectNodes)
                    {
                        dataObjectNode.properties.Add("tableNames", availTables);
                    }
                }

                return(Json(objectsTree));
            }
            catch (Exception e)
            {
                //return Json(new { success = false, message = e.ToString() });
                _logger.Error(e.ToString());
                _CustomErrorLog = new CustomErrorLog();
                _CustomError    = _CustomErrorLog.customErrorLogger(ErrorMessages.errUItree, e, _logger);
                return(Json(new { success = false, message = "[ Message Id " + _CustomError.msgId + "] - " + _CustomError.errMessage, stackTraceDescription = _CustomError.stackTraceDescription }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 15
0
        private DataFilter CreateDataFilter(string filter, string sortBy, string sortOrder)
        {
            DataFilter dataFilter = new DataFilter();

            // process filtering
            if (filter != null && filter.Count() > 0)
            {
                try
                {
                    JavaScriptSerializer serializer = new JavaScriptSerializer();
                    List <Dictionary <String, String> > filterExpressions =
                        (List <Dictionary <String, String> >)serializer.Deserialize(filter, typeof(List <Dictionary <String, String> >));

                    if (filterExpressions != null && filterExpressions.Count > 0)
                    {
                        List <Expression> expressions = new List <Expression>();
                        dataFilter.Expressions = expressions;

                        foreach (Dictionary <String, String> expr in filterExpressions)
                        {
                            Expression expression = new Expression();
                            expressions.Add(expression);

                            if (expr.ContainsKey("conjunction")) // new filter
                            {
                                if (expr["conjunction"] != null)
                                {
                                    if (expr["conjunction"].Length == 0)
                                    {
                                        expression.LogicalOperator = LogicalOperator.None;
                                    }
                                    else
                                    {
                                        expression.LogicalOperator = (LogicalOperator)
                                                                     Enum.Parse(typeof(LogicalOperator), expr["conjunction"]);
                                    }
                                }

                                expression.RelationalOperator = (RelationalOperator)
                                                                Enum.Parse(typeof(RelationalOperator), expr["operator"]);
                            }
                            else // legacy ux filter
                            {
                                if (expressions.Count > 1)
                                {
                                    expression.LogicalOperator = LogicalOperator.And;
                                }

                                if (expr.ContainsKey("comparison") && expr["comparison"] != null)
                                {
                                    //expression.RelationalOperator = (RelationalOperator)
                                    //Enum.Parse(typeof(RelationalOperator), expr["comparison"]);
                                    RelationalOperator optor = GetOpt(expr["comparison"]);
                                    expression.RelationalOperator = optor;
                                }
                                else
                                {
                                    expression.RelationalOperator = RelationalOperator.EqualTo;
                                }
                            }

                            expression.PropertyName = expr["field"];

                            Values values = new Values();
                            expression.Values = values;
                            string value = expr["value"];
                            values.Add(value);
                        }
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error("Error deserializing filter: " + ex);
                    //response = response + " " + ex.Message.ToString();
                    CustomErrorLog objCustomErrorLog = new CustomErrorLog();
                    _CustomError = objCustomErrorLog.customErrorLogger(ErrorMessages.errUIGridPages, ex, _logger);
                    response     = response + " " + throwJsonResponse(_CustomError);
                }
            }

            // process sorting
            if (sortBy != null && sortBy.Count() > 0 && sortOrder != null && sortOrder.Count() > 0)
            {
                List <OrderExpression> orderExpressions = new List <OrderExpression>();
                dataFilter.OrderExpressions = orderExpressions;

                OrderExpression orderExpression = new OrderExpression();
                orderExpressions.Add(orderExpression);

                if (sortBy != null)
                {
                    orderExpression.PropertyName = sortBy;
                }

                string sortOrderEnumVal = sortOrder.Substring(0, 1).ToUpper() + sortOrder.Substring(1).ToLower();

                if (sortOrderEnumVal != null)
                {
                    try
                    {
                        orderExpression.SortOrder = (SortOrder)Enum.Parse(typeof(SortOrder), sortOrderEnumVal);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(ex.ToString());
                        // response = response + " " + ex.Message.ToString();
                        CustomErrorLog objCustomErrorLog = new CustomErrorLog();
                        _CustomError = objCustomErrorLog.customErrorLogger(ErrorMessages.errUIGridPages, ex, _logger);
                        response     = response + " " + throwJsonResponse(_CustomError);
                    }
                }
            }

            return(dataFilter);
        }
Exemplo n.º 16
0
        public ActionResult ObjectsTree(FormCollection form)
        {
            try
            {
                string scope          = form["scope"];
                string app            = form["app"];
                string selectedTables = form["selectedTables"];

                _repository.Session = Session;

                List <Node> objectsTree = new List <Node>();

                Node root = new Node()
                {
                    text       = "Data Objects",
                    type       = "dataObjects",
                    iconCls    = "folder",
                    expanded   = true,
                    children   = new List <Node>(),
                    properties = new Dictionary <string, object>()
                };

                objectsTree.Add(root);

                DatabaseDictionary dictionary = _repository.GetDBDictionary(scope, app);

                Dictionary <string, string> conElts = null;
                if (dictionary != null && !string.IsNullOrEmpty(dictionary.ConnectionString))
                {
                    string dbProvider = dictionary.Provider;
                    string conStr     = Utility.DecodeFrom64(dictionary.ConnectionString);

                    conElts             = GetConnectionElements(dbProvider, conStr);
                    conElts["dbSchema"] = dictionary.SchemaName;
                    root.properties.Add("connectionInfo", conElts);
                }
                else
                {
                    conElts = new Dictionary <string, string>();
                    conElts.Add("dbProvider", form["dbProvider"]);
                    conElts.Add("dbServer", form["dbServer"]);
                    conElts.Add("dbInstance", form["dbInstance"]);
                    conElts.Add("serName", form["serName"]);
                    conElts.Add("dbName", form["dbName"]);
                    conElts.Add("dbSchema", form["dbSchema"]);
                    conElts.Add("dbUserName", form["dbUserName"]);
                    conElts.Add("dbPassword", form["dbPassword"]);
                    conElts.Add("portNumber", form["portNumber"]);
                }

                List <DataObject> dbObjects = null;
                if (!string.IsNullOrEmpty(conElts["dbServer"]))
                {
                    //
                    // get available tables
                    //
                    List <string> availTables = _repository.GetTableNames(scope, app, conElts);
                    root.properties.Add("tableNames", availTables);

                    //
                    // get selected tables metadata
                    //
                    List <string> configTables = null;

                    if (!string.IsNullOrEmpty(selectedTables))
                    {
                        string[] array = selectedTables.Split(',');
                        configTables = new List <string>(array);
                    }
                    else if (dictionary != null && dictionary.dataObjects.Count > 0)
                    {
                        configTables = new List <string>();

                        foreach (DataObject dataObject in dictionary.dataObjects)
                        {
                            configTables.Add(dataObject.tableName);
                        }
                    }

                    if (configTables != null && configTables.Count > 0)
                    {
                        dbObjects = _repository.GetDBObjects(scope, app, conElts, configTables);
                    }
                }

                if (dbObjects != null)
                {
                    bool        checkDictionary = (dictionary != null && dictionary.dataObjects != null && dictionary.dataObjects.Count > 0);
                    List <Node> objectNodes     = root.children;

                    foreach (DataObject dbObject in dbObjects)
                    {
                        Node keyPropertiesNode = new Node()
                        {
                            text     = "Keys",
                            type     = "keys",
                            iconCls  = "folder",
                            expanded = true,
                            children = new List <Node>()
                        };

                        Node dataPropertiesNode = new Node()
                        {
                            text     = "Properties",
                            type     = "properties",
                            iconCls  = "folder",
                            expanded = true,
                            children = new List <Node>()
                        };

                        Node relationshipsNode = new Node()
                        {
                            text     = "Relationships",
                            type     = "relationships",
                            iconCls  = "folder",
                            expanded = true,
                            children = new List <Node>()
                        };

                        // create object node
                        Node dataObjectNode = new Node()
                        {
                            text     = dbObject.tableName,
                            type     = "dataObject",
                            iconCls  = "treeObject",
                            children = new List <Node>()
                            {
                                keyPropertiesNode, dataPropertiesNode, relationshipsNode
                            },
                            properties = new Dictionary <string, object>()
                            {
                                { "dataProperties", dbObject.dataProperties }
                            }
                        };

                        DataObject dictObject = null;

                        //
                        // apply what has been configured in dictionary to db object
                        //
                        if (checkDictionary)
                        {
                            dictObject = dictionary.dataObjects.Find(x => x.tableName == dbObject.tableName);
                        }

                        if (dictObject == null)  // has not been configured
                        {
                            dataObjectNode.properties.Add("objectNamespace", ONS_PREFIX + scope + "." + app);
                            dataObjectNode.properties.Add("objectName", dbObject.objectName);
                            dataObjectNode.properties.Add("tableName", dbObject.tableName);
                            dataObjectNode.properties.Add("keyDelimiter", dbObject.keyDelimeter);
                            dataObjectNode.properties.Add("description", dbObject.description);
                        }
                        else  // has been configured, apply object configurations
                        {
                            dataObjectNode.properties.Add("objectNamespace", ONS_PREFIX + scope + "." + app);
                            dataObjectNode.properties.Add("objectName", dictObject.objectName);
                            dataObjectNode.properties.Add("tableName", dictObject.tableName);
                            dataObjectNode.properties.Add("keyDelimiter", dictObject.keyDelimeter);
                            dataObjectNode.properties.Add("description", dictObject.description);

                            // apply relationship configurations
                            foreach (DataRelationship relationship in dictObject.dataRelationships)
                            {
                                Node relationshipNode = new Node()
                                {
                                    text       = relationship.relationshipName,
                                    type       = "relationship",
                                    iconCls    = "relationship",
                                    leaf       = true,
                                    properties = new Dictionary <string, object>()
                                    {
                                        { "name", relationship.relationshipName },
                                        { "type", relationship.relationshipType.ToString() },
                                        { "sourceObject", dictObject.objectName },
                                        { "relatedObject", relationship.relatedObjectName },
                                        { "propertyMaps", relationship.propertyMaps }
                                    }
                                };

                                relationshipsNode.children.Add(relationshipNode);
                            }
                        }

                        foreach (DataProperty dbProperty in dbObject.dataProperties)
                        {
                            if (dictObject != null)
                            {
                                DataProperty dictProperty = dictObject.dataProperties.Find(x => x.columnName == dbProperty.columnName);

                                if (dictProperty != null)   // property has been configured
                                {
                                    Dictionary <string, object> properties = new Dictionary <string, object>()
                                    {
                                        { "columnName", dictProperty.columnName },
                                        { "propertyName", dictProperty.propertyName },
                                        { "dataType", dictProperty.dataType },
                                        { "dataLength", dictProperty.dataLength },
                                        { "isNullable", dictProperty.isNullable },
                                        { "keyType", dictProperty.keyType },
                                        { "numberOfDecimals", dictProperty.numberOfDecimals },
                                        { "isReadOnly", dictProperty.isReadOnly },
                                        { "showOnIndex", dictProperty.showOnIndex },
                                        { "showOnSearch", dictProperty.showOnSearch },
                                        { "isHidden", dictProperty.isHidden },
                                        { "isVirtual", dictProperty.isVirtual },
                                        { "precision", dictProperty.precision },
                                        { "scale", dictProperty.scale }
                                    };

                                    bool isKey = false;

                                    if (dictObject.isKeyProperty(dictProperty.columnName))
                                    {
                                        Node keyPropertyNode = new Node()
                                        {
                                            text       = dictProperty.columnName,
                                            type       = "keyProperty",
                                            iconCls    = "treeKey",
                                            leaf       = true,
                                            properties = properties
                                        };

                                        keyPropertiesNode.children.Add(keyPropertyNode);
                                        isKey = true;
                                    }
                                    else if (!isKey)
                                    {
                                        Node dataPropertyNode = new Node()
                                        {
                                            text       = dictProperty.columnName,
                                            type       = "dataProperty",
                                            iconCls    = "treeProperty",
                                            leaf       = true,
                                            properties = properties
                                        };

                                        dataPropertiesNode.children.Add(dataPropertyNode);
                                    }
                                }
                            }
                        }

                        objectNodes.Add(dataObjectNode);
                    }
                }

                return(Json(objectsTree));
            }
            catch (Exception e)
            {
                //return Json(new { success = false, message = e.ToString() });
                _logger.Error(e.ToString());
                _CustomErrorLog = new CustomErrorLog();
                _CustomError    = _CustomErrorLog.customErrorLogger(ErrorMessages.errUItree, e, _logger);
                return(Json(new { success = false, message = "[ Message Id " + _CustomError.msgId + "] - " + _CustomError.errMessage, stackTraceDescription = _CustomError.stackTraceDescription }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 17
0
        public ActionResult Pages(FormCollection form)
        {
            try
            {
                _repository.Session = Session;
                JsonContainer <Grid> container = new JsonContainer <Grid>();

                string     keyName = string.Format("{0}.{1}.{2}", form["scope"], form["app"], form["graph"]);
                DataFilter filter  = (DataFilter)Session[keyName];
                if (filter == null)
                {
                    _repository.GetFilterFile(ref filter, keyName);
                }

                if (filter == null)
                {
                    if (form["filter"] != null)
                    {
                        filter = new DataFilter();
                        Expression expression = new Expression();
                        string[]   filterVal  = form["filter"].Split(':');
                        if (filterVal.Count() == 2)
                        {
                            expression.Values = new Values()
                            {
                                filterVal[1]
                            };
                            expression.PropertyName       = filterVal[0];
                            expression.RelationalOperator = (RelationalOperator)Enum.Parse(typeof(RelationalOperator), "EqualTo");
                            filter.Expressions.Add(expression);
                            dataGrid = _repository.GetGrid(form["scope"], form["app"], form["graph"], filter, form["start"], form["limit"]);
                        }
                        else
                        {
                            dataGrid = _repository.GetGrid(form["scope"], form["app"], form["graph"], form["filter"], form["sort"], form["dir"], form["start"], form["limit"]);
                        }
                    }
                    else
                    {
                        dataGrid = _repository.GetGrid(form["scope"], form["app"], form["graph"], form["filter"], form["sort"], form["dir"], form["start"], form["limit"]);
                    }
                }

                else if (filter != null && form["filter"] != null)
                {
                    string[] filterVal = form["filter"].Split(':');
                    if (filterVal.Count() == 2)
                    {
                        filter.Expressions[0].Values[0]          = filterVal[1];
                        filter.Expressions[0].PropertyName       = filterVal[0];
                        filter.Expressions[0].RelationalOperator = (RelationalOperator)Enum.Parse(typeof(RelationalOperator), "EqualTo");
                        dataGrid = _repository.GetGrid(form["scope"], form["app"], form["graph"], filter, form["start"], form["limit"]);
                    }
                    else
                    {
                        dataGrid = _repository.GetGrid(form["scope"], form["app"], form["graph"], filter, form["start"], form["limit"]);
                    }
                }
                else
                {
                    dataGrid = _repository.GetGrid(form["scope"], form["app"], form["graph"], filter, form["start"], form["limit"]);
                }

                string response = _repository.GetResponse();
                if (response != "")
                {
                    //return Json(new { success = false, message = response }, JsonRequestBehavior.AllowGet);
                    var         jsonSerialiser = new JavaScriptSerializer();
                    CustomError json           = (CustomError)jsonSerialiser.Deserialize(response, typeof(CustomError));
                    return(Json(new { success = false, message = "[ Message Id " + json.msgId + "] - " + json.errMessage, stackTraceDescription = json.stackTraceDescription }, JsonRequestBehavior.AllowGet));
                }

                return(Json(dataGrid, JsonRequestBehavior.AllowGet));
            }

            catch (Exception e)
            {
                _CustomErrorLog = new CustomErrorLog();
                _CustomError    = _CustomErrorLog.customErrorLogger(ErrorMessages.errUIGridPages, e, _logger);
                return(Json(new { success = false, message = "[ Message Id " + _CustomError.msgId + "] - " + _CustomError.errMessage, stackTraceDescription = _CustomError.stackTraceDescription }, JsonRequestBehavior.AllowGet));
            }
        }