public WebDataTable(string name, string sortIndex, string sortOrder, long pageIndex, long pageSize, FilterDataObject filterData, WebISGDatabaseType databaseType)
        {
            Name = name;
            Rows = new List<WebDataTableRow>();

            // The "Actions" column will be the same across every table
            Columns =
                new List<WebDataTableColumn>
                    {
                        new WebDataTableColumn("act")
                            {
                                ParentTable = name,
                                DatabaseType = databaseType
                            }
                    };

            using (var serviceClient = new NeonISGDataServiceClient(Configuration.ActiveNeonDataServiceEndpoint))
            {
                var database = Mapper.Map<WebISGDatabaseType, NeonISGDatabaseType>(databaseType);
                var rtrn = serviceClient.GetData(Name, sortIndex, sortOrder, pageIndex, pageSize, filterData.FilterQuery, database);

                foreach (var column in rtrn.Columns)
                {
                    Columns.Add(
                        new WebDataTableColumn(column.Name)
                            {
                                IsNullable = column.IsNullable,
                                Length = column.Length,
                                Precision = column.Precision,
                                Scale = column.Scale,
                                TypeName = column.TypeName,
                                ParentTable = name,
                                IsPrimaryKey = column.IsPrimaryKey,
                                IsReadonlyIdentity = column.IsReadonlyIdentity,
                                DatabaseType = databaseType
                            });
                }
                Columns = Columns.OrderBy(x => x.Order).ThenBy(x => x.FriendlyName).ToList();

                foreach (var row in rtrn.Rows)
                {
                    var dataRow = new WebDataTableRow(row.RowId);
                    foreach (var column in Columns.Where(c => !c.Name.Equals("act")))
                    {
                        var cell = row.Cells.FirstOrDefault(x => string.Equals(x.ColumnName, column.Name, StringComparison.CurrentCultureIgnoreCase));
                        var value = (cell != null) ? cell.Value : string.Empty;

                        dataRow.Cells.Add(
                            new WebDataTableCell(column)
                            {
                                Value = value
                            });
                    }
                    Rows.Add(dataRow);
                }
            }
        }
 public static long GetRowCount(string tableName, FilterDataObject filterData, WebISGDatabaseType databaseType)
 {
     long rtrn;
     using (var serviceClient = new NeonISGDataServiceClient(Configuration.ActiveNeonDataServiceEndpoint))
     {
         var database = Mapper.Map<WebISGDatabaseType, NeonISGDatabaseType>(databaseType);
         rtrn = serviceClient.GetRowCount(tableName, filterData.FilterQuery, database);
     }
     return rtrn;
 }
 /// <summary>
 /// Attempt to login the user by matching their AD account to a registered user in the system
 /// </summary>
 /// <param name="userName"></param>
 /// <returns></returns>
 public int? Login(string userName)
 {
     try
     {
         int? rtrn;
         using (var serviceClient = new NeonISGDataServiceClient(Configuration.ActiveNeonDataServiceEndpoint))
         {
             rtrn = serviceClient.Login(userName);
         }
         return rtrn;
     }
     catch (Exception ex)
     {
         throw new Exception(string.Format("Error in SecurityVM.Login() userName:{0}", userName), ex);
     }
 }
 /// <summary>
 /// Check that the user has access
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="functionId"></param>
 /// <returns></returns>
 public bool UserHasFunction(int userId, int functionId)
 {
     try
     {
         bool rtrn;
         using (var serviceClient = new NeonISGDataServiceClient(Configuration.ActiveNeonDataServiceEndpoint))
         {
             rtrn = serviceClient.UserHasFunction(userId, functionId);
         }
         return rtrn;
     }
     catch (Exception ex)
     {
         throw new Exception(string.Format("Error in SecurityVM.UserHasFunction() userId:{0} functionId:{1}", userId, functionId), ex);
     }
 }
 public static bool SaveData(string tableName, NeonDataTableRowMetaData row, WebISGDatabaseType databaseType)
 {
     try
     {
         using (var serviceClient = new NeonISGDataServiceClient(Configuration.ActiveNeonDataServiceEndpoint))
         {
             var neonDatabase = Mapper.Map<WebISGDatabaseType, NeonISGDatabaseType>(databaseType);
             // ReSharper disable once UnusedVariable
             var rtrn = serviceClient.SaveRow(tableName, row, neonDatabase);
         }
         return true;
     }
     catch (Exception ex)
     {
         throw new Exception(string.Format("Unable to save information to database for table {0}", tableName), ex);
     }
 }
 public ActionResult GetDropdownOptions(string table, string column, WebISGDatabaseType databaseType)
 {
     List<string> distinctValues;
     using (var serviceClient = new NeonISGDataServiceClient(Configuration.ActiveNeonDataServiceEndpoint))
     {
         var database = Mapper.Map<WebISGDatabaseType, NeonISGDatabaseType>(databaseType);
         distinctValues = serviceClient.GetDistinctValues(table, column, database);
     }
     var jsonData = Json(distinctValues, JsonRequestBehavior.AllowGet);
     return jsonData;
 }