コード例 #1
0
        public static void ConstructRecordObjectFromPostSaveRequest(JSONRecord jr, ref PrimaryKeyRecord rec)
        {
            PrimaryKeyTable t = (PrimaryKeyTable)DatabaseObjects.GetTableObject(jr.TableName);

            t.ResetSelectedColumns();

            rec = new PrimaryKeyRecord(t);
            rec.IsExistsInDatabase = jr.IsExistsInDatabase;

            if ((jr.JRecordValues != null))
            {
                foreach (JRecordValue jRecordValue in jr.JRecordValues)
                {
                    BaseColumn bc = t.TableDefinition.ColumnList.GetByCodeName(jRecordValue.ColumnName);
                    if (!bc.IsValuesReadOnly)
                    {
                        rec.Parse(jRecordValue.ColumnValue, bc);
                    }
                    else if (t.TableDefinition.IsPrimaryKeyElement(bc))
                    {
                        KeyValue kv = new KeyValue();
                        kv.AddElement(jRecordValue.ColumnName, jRecordValue.ColumnValue.ToString());
                        rec.PrimaryKeyValue = kv;
                    }
                }
            }
        }
コード例 #2
0
        public static void ConstructTableObjectFromPostRequest(JSONTable jt, ref BaseTable bt, ref int pageIndex, ref int pageSize, ref int totalRows,
                                                               ref SqlFilter whereFilter, ref BaseFilter join, ref OrderBy orderBy)
        {
            pageIndex = jt.PageIndex;
            pageSize  = jt.PageSize;
            totalRows = jt.TotalRows;

            bt = (BaseTable)DatabaseObjects.GetTableObject(jt.TableName);

            ColumnList selCols = new ColumnList();

            foreach (JTableSelectColumn col in jt.JSelectColumns)
            {
                selCols.Add(bt.TableDefinition.ColumnList.GetByCodeName(col.ColumnName), true);
            }

            bt.SelectedColumns.Clear();
            bt.SelectedColumns.AddRange(selCols);

            if ((jt.JOrderByList != null))
            {
                foreach (JOrderBy jOrderBy in jt.JOrderByList)
                {
                    orderBy = new OrderBy(true, false);
                    orderBy.Add(bt.TableDefinition.ColumnList.GetByCodeName(jOrderBy.ColumnName), OrderByItem.ToOrderDir(jOrderBy.OrderDirection));
                }
            }

            if (jt.JWhereClause != null && jt.JWhereClause.Trim() != "")
            {
                whereFilter = new SqlFilter(jt.JWhereClause);
            }
        }
コード例 #3
0
        /// <summary>
        /// This method takes a keyValue and a Column and returns an evaluated value of DFKA formula.
        /// </summary>
        public static string GetDFKA(String keyValue, BaseColumn col, String formatPattern)
        {
            if (keyValue == null)
            {
                return(null);
            }
            ForeignKey fkColumn = AreasTable.Instance.TableDefinition.GetExpandableNonCompositeForeignKey(col);

            if (fkColumn == null)
            {
                return(null);
            }
            String _DFKA = fkColumn.PrimaryKeyDisplayColumns;

            if (_DFKA.Trim().StartsWith("="))
            {
                String          tableName = fkColumn.PrimaryKeyTableDefinition.TableCodeName;
                PrimaryKeyTable t         = (PrimaryKeyTable)DatabaseObjects.GetTableObject(tableName);
                BaseRecord      rec       = null;

                if (t != null)
                {
                    try
                    {
                        rec = (BaseRecord)t.GetRecordData(keyValue, false);
                    }
                    catch
                    {
                        rec = null;
                    }
                }
                if (rec == null)
                {
                    return("");
                }

                // if the formula is in the format of "= <Primary table>.<Field name>, then pull out the data from the rec object instead of doing formula evaluation
                string tableCodeName = fkColumn.PrimaryKeyTableDefinition.TableCodeName;
                string column        = _DFKA.Trim('=').Trim();
                if (column.StartsWith(tableCodeName + ".", StringComparison.InvariantCultureIgnoreCase))
                {
                    column = column.Substring(tableCodeName.Length + 1);
                }

                foreach (BaseColumn c in fkColumn.PrimaryKeyTableDefinition.Columns)
                {
                    if (column == c.CodeName)
                    {
                        return(rec.Format(c));
                    }
                }
                return(EvaluateFormula(_DFKA, rec, null, tableName));
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
 public BaseClasses.Data.BaseTable GetTable()
 {
     try
     {
         return(DatabaseObjects.GetTableObject(this.TableName));
     }
     catch (System.Exception)
     {
         return(DatabaseObjects.GetTableObject(this.TableName));
     }
 }
コード例 #5
0
        public static void ConstructRecordObjectFromPostDeleteRequest(JSONRecord jr, ref PrimaryKeyTable pk, ref List <KeyValue> kvList)
        {
            pk = (PrimaryKeyTable)DatabaseObjects.GetTableObject(jr.TableName);

            if ((jr.JRecordValues != null))
            {
                foreach (JRecordValue jRecordValue in jr.JRecordValues)
                {
                    KeyValue kv = new KeyValue();
                    kv.AddElement(jRecordValue.ColumnName, jRecordValue.ColumnValue.ToString());
                    kvList.Add(kv);
                }
            }
        }
コード例 #6
0
        public static SelectItem ConstructSelectItemFromPostRequest(JDataSourceSelectItem jsonSItem)
        {
            SelectItem sItem = null;

            if (!string.IsNullOrEmpty(jsonSItem.ColumnName) && !string.IsNullOrEmpty(jsonSItem.TableName))
            {
                BaseTable table = DatabaseObjects.GetTableObject(jsonSItem.TableName);
                sItem = new SelectItem(table.TableDefinition.ColumnList.GetByCodeName(jsonSItem.ColumnName), table, jsonSItem.Distinct, jsonSItem.AsClause, jsonSItem.TableAlias);
            }
            else if (!string.IsNullOrEmpty(jsonSItem.ItemType) && !string.IsNullOrEmpty(jsonSItem.TableName))
            {
                if (!string.IsNullOrEmpty(jsonSItem.AsClause))
                {
                    if (!string.IsNullOrEmpty(jsonSItem.TableAlias))
                    {
                        sItem = new SelectItem(BaseClasses.Data.SelectItem.ItemTypeDefinition.GetItemType(jsonSItem.ItemType), DatabaseObjects.GetTableObject(jsonSItem.TableName), jsonSItem.AsClause, jsonSItem.TableAlias);
                    }
                    else
                    {
                        sItem = new SelectItem(BaseClasses.Data.SelectItem.ItemTypeDefinition.GetItemType(jsonSItem.ItemType), DatabaseObjects.GetTableObject(jsonSItem.TableName), jsonSItem.AsClause);
                    }
                }
                else
                {
                    sItem = new SelectItem(BaseClasses.Data.SelectItem.ItemTypeDefinition.GetItemType(jsonSItem.ItemType), DatabaseObjects.GetTableObject(jsonSItem.TableName));
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(jsonSItem.Operation))
                {
                    if ((jsonSItem.LeftItem != null) && (jsonSItem.RightItem == null))
                    {
                        sItem = new SelectItem(jsonSItem.Operation, ConstructSelectItemFromPostRequest(jsonSItem.LeftItem), jsonSItem.AsClause);
                    }
                    else if ((jsonSItem.LeftItem != null) && (jsonSItem.RightItem != null))
                    {
                        sItem = new SelectItem(jsonSItem.Operation, ConstructSelectItemFromPostRequest(jsonSItem.LeftItem), ConstructSelectItemFromPostRequest(jsonSItem.RightItem), jsonSItem.AsClause);
                    }
                }
            }

            return(sItem);
        }
コード例 #7
0
        public static void ConstructDataSourceObjectFromPostRequest(JSONDataSource jsonDS, ref SqlBuilderColumnSelection requestedCols, ref SqlBuilderColumnSelection workingSelCols,
                                                                    ref SqlBuilderColumnSelection distinctSelCols, ref OrderBy orderBy, ref KeylessVirtualTable table)
        {
            DataSource ds = new DataSource();

            ds.Initialize(jsonDS.Name, DatabaseObjects.GetTableObject(jsonDS.Table), jsonDS.PageSize, jsonDS.PageIndex, jsonDS.GenerateTotal);

            if ((jsonDS.JSelectItems != null))
            {
                foreach (JDataSourceSelectItem jsonSItem in jsonDS.JSelectItems)
                {
                    ds.AddSelectItem(ConstructSelectItemFromPostRequest(jsonSItem));
                }
            }

            requestedCols   = new SqlBuilderColumnSelection(jsonDS.ExpandForeignKeyColumns, jsonDS.IsDistinct);
            workingSelCols  = new SqlBuilderColumnSelection(jsonDS.ExpandForeignKeyColumns, jsonDS.IsDistinct);
            distinctSelCols = new SqlBuilderColumnSelection(jsonDS.ExpandForeignKeyColumns, jsonDS.IsDistinct);

            List <BaseColumn> columnsList = null;

            if (jsonDS.isTotalRecordArray)
            {
                columnsList = ds.CreateColumnSelectionsForTotal(ref requestedCols, ref workingSelCols, ref distinctSelCols);
            }
            else
            {
                columnsList = ds.CreateColumnSelections(ref requestedCols, ref workingSelCols, ref distinctSelCols);
            }
            table = ds.CreateVirtualTable(columnsList.ToArray());

            if ((jsonDS.JOrderByList != null))
            {
                foreach (JOrderBy jsonOrderBy in jsonDS.JOrderByList)
                {
                    ds.AddAggregateOrderBy(jsonOrderBy.ColumnName, OrderByItem.ToOrderDir(jsonOrderBy.OrderDirection));
                }
            }
            ds.UpdateOrderBy(columnsList);
            orderBy = ds.OrderBy;
        }
コード例 #8
0
 protected void ExportData()
 {
     if (string.IsNullOrEmpty(this.TableId))
     {
         return;
     }
     try
     {
         PrimaryKeyTable t   = (PrimaryKeyTable)DatabaseObjects.GetTableObject(this.TableId);
         BaseRecord      rec = (BaseRecord)t.GetRecordData(this.RecordId, false);
         if ((this.ImagePercentSize != 100.0 && !(this.ImagePercentSize == 0.0)) || !((this.ImageHeight == 0) || (this.ImageWidth == 0)))
         {
             //To display image with shrinking according to user specified height/width or ImagePercentSize
             ColumnValue fieldData  = MiscUtils.GetData(rec, t.TableDefinition.ColumnList.GetByAnyName(this.FieldId));
             byte[]      binaryData = MiscUtils.GetBinaryData(t.TableDefinition.ColumnList.GetByAnyName(this.FieldId), fieldData);
             if (binaryData == null || binaryData.Length == 0)
             {
                 MiscUtils.RegisterJScriptAlert(this, "No Content", "Field " + this.FieldId + " does not contain any binary data.", false, true);
                 return;
             }
             byte[] thumbNailSizeImage = GetThumbNailSizeImage(binaryData);
             string filName            = MiscUtils.GetFileNameWithExtension(t.TableDefinition.ColumnList.GetByAnyName(this.FieldId), binaryData, null);
             MiscUtils.SendToWriteResponse(this.Response, thumbNailSizeImage, filName, t.TableDefinition.ColumnList.GetByAnyName(this.FieldId), fieldData, this.Offset);
         }
         else
         {
             //Calling ExportFieldData method without image shrinking.
             if (!MiscUtils.ExportFieldData(this.Response, rec, t.TableDefinition.ColumnList.GetByAnyName(this.FieldId), this.FileName, this.Offset))
             {
                 MiscUtils.RegisterJScriptAlert(this, "No Content", "Field " + this.FieldId + " does not contain any binary data.", false, true);
                 return;
             }
         }
     }
     catch
     {
     }
 }