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");
                }
            }
        }
Пример #2
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;
        }
Пример #3
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;
            }
        }