Exemplo n.º 1
0
        private void SetTimeValues()
        {
            // time variable values
            //lage flere overloads databasespørringer avhengig av timeopt
            //mValues = new Dictionary<string, PXSqlValue>();



            PxSqlValues tmpValues = null;

            if (meta.MainTable.ContainsOnlyMetaData)
            {
                PXSqlValue fictiveValue = new PXSqlValue("Time01", meta.LanguageCodes);
                this.mValues.Add("Time01", fictiveValue);
            }

            else
            {
                if (meta.ConstructedFromPxs && ((int)meta.PxsFile.Query.Time.TimeOption != 4))
                {
                    switch ((int)meta.PxsFile.Query.Time.TimeOption)
                    {
                    case 0:
                        Dictionary <string, int> mySelectedValues = new Dictionary <string, int>();
                        int docOrder = 1;
                        TimeTypeTimeValues timevalues = (TimeTypeTimeValues)meta.PxsFile.Query.Time.Item;
                        foreach (BasicValueType time in timevalues.TimeValue)
                        {
                            mySelectedValues.Add(time.code, docOrder++);
                        }

                        tmpValues = meta.MetaQuery.GetTimeValueList(meta.MainTable.MainTable, mySelectedValues);
                        break;

                    case 1:
                        tmpValues = meta.MetaQuery.GetTimeValueList(meta.MainTable.MainTable);
                        break;

                    case 2:
                        int NoOfTimeValues = (int)meta.PxsFile.Query.Time.Item;
                        tmpValues = meta.MetaQuery.GetTimeValueList(meta.MainTable.MainTable, NoOfTimeValues);
                        break;

                    case 3:
                        string StartTimeValue = (string)meta.PxsFile.Query.Time.Item;
                        tmpValues = meta.MetaQuery.GetTimeValueList(meta.MainTable.MainTable, StartTimeValue);
                        break;
                    }



                    this.mValues = tmpValues;
                }
                else
                {
                    this.mValues = meta.MetaQuery.GetAllTimeValuesList(meta.MainTable.MainTable, "desc");
                }
            }
        }
Exemplo n.º 2
0
        // when no pxs
        internal void SetValues(StringCollection selSubTables)
        {
            ValueRow2HMDictionary            mValueRowDictionary = meta.MetaQuery.GetValueRowDictionary(meta.MainTable.MainTable, selSubTables, this.Name, this.ValuePool.ValueTextExists);
            Dictionary <string, ValueRow2HM> mValueRows          = mValueRowDictionary.ValueRows;

            this.Values = new PxSqlValues();

            foreach (ValueRow2HM myValueRow in mValueRows.Values)
            {
                PXSqlValue mValue = new PXSqlValue(myValueRow, meta.LanguageCodes, meta.MainLanguageCode);
                this.Values.Add(mValue.ValueCode, mValue);
            }
        }
Exemplo n.º 3
0
        private List <PXSqlValue> GetValuesForParsingWhenSelection()
        {
            PXSqlVariable     var            = variable;
            List <PXSqlValue> tempValuesList = new List <PXSqlValue>();

            if (this.isHierarchy)
            {
                tempValuesList = GetHierarchicalValues(rootGroup, tempValuesList);
            }
            else
            {
                if (this.mIncludeType == GroupingIncludesType.AggregatedValues)
                {
                    foreach (PXSqlGroup group in this.mGroups)
                    {
                        tempValuesList.Add(var.Values[group.ParentCode]);   //todo; sortert etter gruppe sorteringskode
                    }
                }
                else if (this.mIncludeType == GroupingIncludesType.SingleValues)
                {
                    foreach (PXSqlGroup group in this.mGroups)
                    {
                        foreach (string childCode in group.ChildCodes)
                        {
                            tempValuesList.Add(var.Values[childCode]);   //todo; sortert etter gruppe sorteringskode
                        }
                    }
                }
                else if (this.IncludeType == GroupingIncludesType.All)
                {
                    foreach (PXSqlGroup group in this.mGroups)
                    {
                        tempValuesList.Add(var.Values[group.ParentCode]);   //todo; sortert etter gruppe sorteringskode
                        foreach (string childCode in group.ChildCodes)
                        {
                            tempValuesList.Add(var.Values[childCode]);   //todo; sortert etter gruppe sorteringskode
                        }
                    }
                }
                //tempValuesList.Sort(PXSqlValue.SortByVsValue());


                //TODO; Hvorfor hadde Linja under en   if ( this.meta.MetaQuery.metaVersionLE("2.1")) { rundt seg
                tempValuesList.Sort(PXSqlValue.SortByValue());
            }

            return(tempValuesList);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get values from valuetable in database an add them to the the variables valuecollection
        /// </summary>
        /// <param name="valuePoolId"></param>
        /// <param name="valueList"></param>
        /// <param name="valuePoolValueTextExists"></param>
        private void AddValues(string valuePoolId, StringCollection valueList, string valuePoolValueTextExists)
        {
            PXSqlValue tempValue;

            foreach (ValueRowHM row in this.meta.MetaQuery.GetValueRowsByValuePool(valuePoolId, valueList, valuePoolValueTextExists))
            {
                tempValue = new PXSqlValue(row, meta.LanguageCodes, meta.MainLanguageCode);
                if (this.variable.Values.ContainsKey(tempValue.ValueCode))
                {
                    log.Debug("Already contains code =" + tempValue.ValueCode);
                }
                else
                {
                    this.variable.Values.Add(tempValue.ValueCode, tempValue);
                }
            }
        }
Exemplo n.º 5
0
 public int CompareTo(object obj)
 {
     if (this.GetType() != obj.GetType())
     {
         throw new PCAxis.Sql.Exceptions.BugException(10000);
     }
     else
     {
         PXSqlValue SqlValueCompare   = (PXSqlValue)obj;
         int        primaryComparison = this.SortCodePxs.CompareTo(SqlValueCompare.SortCodePxs);
         if (primaryComparison == 0)
         {
             return(this.SortCodeDb.CompareTo(SqlValueCompare.SortCodeDb));
         }
         else
         {
             return(primaryComparison);
         }
     }
 }
Exemplo n.º 6
0
        private void SetContents()
        {
            BasicValueType[] contentsInPxs = new BasicValueType[0];
            if (this.ConstructedFromPxs)
            {
                contentsInPxs = mPxsFile.Query.Contents.Content;
            }
            List <PXSqlContent> mTempContentsList = GetSortedContentsList(mMainTableId, this.ConstructedFromPxs, contentsInPxs);

            mFirstContents = mTempContentsList[0].Contents;



            this.mContents = new Dictionary <string, PXSqlContent>();
            foreach (PXSqlContent sortedCont in mTempContentsList)
            {
                sortedCont.AdjustPresDecimalsToCommonDecimals(this.mDecimalHandler.ShowDecimals);
                mContents.Add(sortedCont.Contents, sortedCont);
            }



            PxSqlValues mValues = new PxSqlValues();
            int         counter = 0;

            foreach (PXSqlContent content in mContents.Values)
            {
                mValue = new PXSqlValue(content, counter);
                mValues.Add(mValue.ValueCode, mValue);
                counter++;
            }


            mSqlVariable        = new PXSqlVariableContents(mContVariableCode, this);
            mSqlVariable.Values = mValues;

            mVariables.Add(mSqlVariable.Name, mSqlVariable);
            mContentsVariable = mSqlVariable;
        }
Exemplo n.º 7
0
        protected override void SetElimForPresentation()
        {
            string     tmpElim;
            PXSqlValue mValue;

            this.IsEliminatedByValue = false;

            List <decimal> NumberOfValuesInValuesets = new List <decimal>();


            if (pxsQueryVariable != null)
            {
                if (!string.IsNullOrEmpty(this.pxsQueryVariable.StructureId))
                {
                    int valueSetCount = this.ValueSets.Count();

                    if (valueSetCount > 1)
                    {
                        var           valuesetsWithEliminationValue = this.ValueSets.Where(x => x.Value.Elimination != meta.Config.Codes.EliminationN && x.Value.Elimination != meta.Config.Codes.EliminationA);
                        PXSqlValueSet onlyVsWithEliminationValue    = valuesetsWithEliminationValue.Count() == 1 ? valuesetsWithEliminationValue.First().Value : null;

                        if (this.ValueSets.Keys.Any(x => x == PXSqlKeywords.FICTIONAL_ID_ALLVALUESETS))
                        {
                            selectedValueset = PXSqlKeywords.FICTIONAL_ID_ALLVALUESETS;
                            PXSqlValueSet vs = this.ValueSets[PXSqlKeywords.FICTIONAL_ID_ALLVALUESETS];
                            NumberOfValuesInValuesets.Add(vs.NumberOfValues);
                            tmpElim = vs.Elimination;
                        }
                        else if (onlyVsWithEliminationValue != null)
                        {
                            NumberOfValuesInValuesets.Add(onlyVsWithEliminationValue.NumberOfValues);
                            tmpElim = onlyVsWithEliminationValue.Elimination;
                        }
                        else
                        {
                            tmpElim = meta.Config.Codes.EliminationN;
                        }
                    }
                    else if (valueSetCount == 1 && this.ValueSets.First().Value.Elimination != meta.Config.Codes.EliminationN)
                    {
                        PXSqlValueSet vs = this.ValueSets.First().Value;
                        NumberOfValuesInValuesets.Add(vs.NumberOfValues);
                        tmpElim = vs.Elimination;
                    }
                    else
                    {
                        tmpElim = meta.Config.Codes.EliminationN;
                    }
                }
                else
                {
                    PXSqlValueSet vs = this.ValueSets[selectedValueset];
                    NumberOfValuesInValuesets.Add(vs.NumberOfValues);
                    tmpElim = vs.Elimination;
                }
            }
            else
            {
                PXSqlValueSet vs = this.ValueSets[selectedValueset];
                NumberOfValuesInValuesets.Add(vs.NumberOfValues);
                tmpElim = vs.Elimination;
            }

            if (tmpElim == meta.Config.Codes.EliminationN || tmpElim.Length == 0)
            {
                if (!this.isSelected)
                {
                    throw new PCAxis.Sql.Exceptions.PxsException(11, this.Name);
                }
                else
                {
                    this.PaxiomElimination = PXConstant.NO;
                }
            }
            else if (tmpElim == meta.Config.Codes.EliminationA)
            {
                if (this.isSelected)
                {
                    // We have to compare values in the valuepool(s) with the values selected in the PxsFile

                    if (this.Values.Count == NumberOfValuesInValuesets[0])
                    {
                        this.PaxiomElimination = PXConstant.YES;
                    }
                    else
                    {
                        this.PaxiomElimination = PXConstant.NO;
                    }
                }
            }
            else
            { // An elimination value exist for the variable.
                if (this.isSelected)
                {
                    if (this.Values.TryGetValue(tmpElim, out mValue))
                    { // the elimination value is selected
                        this.PaxiomElimination = mValue.ValueCode;
                    }



                    else
                    { // The Elimination value is not selected.  Elimination in Paxiom should be NO.
                        this.PaxiomElimination = PXConstant.NO;
                    }
                }
                // If an elimiantion value exists and no values are selected for the variable, the elimination
                // value should be used when selecting data, and metadata should be marked as eliminated by value.
                else
                {
                    mValue           = new PXSqlValue();
                    mValue.ValueCode = tmpElim;

                    this.Values.Add(mValue.ValueCode, mValue);
                    this.IsEliminatedByValue = true;
                }
            }
        }
Exemplo n.º 8
0
        //when pxs
        internal void SetValues(StringCollection selSubTables, PQVariable var)
        {
            log.Debug("PQVariable code = " + var.code);
            StringCollection mSelectedValues = new StringCollection();
            // Defines a dictionary to hold all the sortorders. Necessary because of the wildcards
            Dictionary <string, int> mDefinedSortorder = new Dictionary <string, int>();

            DataSet           mValueInfoTbl;
            DataRowCollection mValueInfo;
            string            mPxsSubTableId = meta.PxsFile.Query.SubTable;


            #region foreach var.Values.Items
            if (var.Values.Items.Length > 0)
            {
                int documentOrder = 0;

                foreach (PCAxis.Sql.Pxs.ValueTypeWithGroup val in var.Values.Items)
                {
                    if (val.Group != null)
                    {
                        //currentGrouping = ...
                        //TODO; PXSqlVariableClassification, SetValues: group not implemented yet"
                        throw new NotImplementedException("PXSqlVariableClassification, SetValues: group not implemented yet");
                    }
                    if (val.code.Contains("*") || val.code.Contains("?"))
                    {
                        if (mPxsSubTableId == null)
                        {
                            mValueInfoTbl = meta.MetaQuery.GetValueWildCardBySubTable(meta.MainTable.MainTable, var.code, null, val.code);
                        }
                        else
                        {
                            mValueInfoTbl = meta.MetaQuery.GetValueWildCardBySubTable(meta.MainTable.MainTable, var.code, mPxsSubTableId, val.code);
                        }
                        mValueInfo = mValueInfoTbl.Tables[0].Rows;

                        foreach (DataRow row in mValueInfo)
                        {
                            string mTempCode = row[meta.MetaQuery.DB.Value.ValueCodeCol.PureColumnName()].ToString();
                            mSelectedValues.Add(mTempCode);
                            if (!mDefinedSortorder.ContainsKey(mTempCode))
                            {
                                mDefinedSortorder.Add(mTempCode, documentOrder);
                            }
                            documentOrder++;
                        }
                    }
                    else
                    {
                        mSelectedValues.Add(val.code);
                        if (!mDefinedSortorder.ContainsKey(val.code))
                        {
                            mDefinedSortorder.Add(val.code, documentOrder);
                        }
                    }

                    documentOrder++;
                }
                #endregion foreach var.Values.Items


                // mSelectedValues now contains all the selected values, including those defined by wildcards

                Dictionary <string, PXSqlValue> mTempPXSqlValues = new Dictionary <string, PXSqlValue>();
                List <PXSqlValue> mSortedValues = new List <PXSqlValue>();

                ValueRow2HMDictionary mValueRowDictionary = meta.MetaQuery.GetValueRowDictionary(meta.MainTable.MainTable, selSubTables, var.code, mSelectedValues, this.ValuePool.ValueTextExists);


                //todo; fortsette her
                Dictionary <string, ValueRow2HM> mValueRows = mValueRowDictionary.ValueRows;

                #region foreach mValueRows
                foreach (ValueRow2HM myValueRow in mValueRows.Values)
                {
                    PXSqlValue mValue = new PXSqlValue(myValueRow, meta.LanguageCodes, meta.MainLanguageCode);

                    // jfi: kommentaren sto i en kodeblock som forsvant inn i PXSqlValue
                    // todo; legge til sjekk om koden finnes blandt valgte i basen.
                    mValue.SortCodePxs = mDefinedSortorder[myValueRow.ValueCode];
                    mSortedValues.Add(mValue);
                }
                #endregion foreach mValueRows

                mValues = new PxSqlValues();

                foreach (PXSqlValue sortedValue in mSortedValues)
                {
                    mValues.Add(sortedValue.ValueCode, sortedValue);
                }

                this.Values = mValues;
            }
        }