/// <summary> /// Converts a DataSet to a list of PXSqlValue for time /// </summary> /// <param name="mainTable">For error message</param> /// <param name="ds">The Dataset</param> /// <param name="setSortCode">Sets SortCodePxs to a counter. True for all ((int)mPxsFile.Query.Time.TimeOption != 0). </param> /// <returns></returns> private PxSqlValues GetTimeValues(string mainTable, DataSet ds, bool setSortCode) { PxSqlValues myOut = new PxSqlValues(); DataRowCollection rows = ds.Tables[0].Rows; //Todo; fix exception if (rows.Count <= 0) { throw new ApplicationException("tabellen " + mainTable + " inneholder ikke data. (ingen tider)"); } int timeSortOrder = 0; string timeCode = ""; foreach (DataRow row in rows) { timeCode = row[this.DB.ContentsTime.TimePeriodCol.PureColumnName()].ToString(); PXSqlValue mValue = new PXSqlValue(timeCode, LanguageCodes); if (setSortCode) { mValue.SortCodePxs = timeSortOrder; timeSortOrder++; } myOut.Add(mValue.ValueCode, mValue); } return(myOut); }
//For mPxsFile.Query.Time.TimeOption == 0 public PxSqlValues GetTimeValueList(string mainTable, Dictionary <string, int> mySelectedValues) { DataSet ds = this.GetTimeValues(mainTable, mySelectedValues.Keys); PxSqlValues myOut = GetTimeValues(mainTable, ds, false); foreach (KeyValuePair <string, int> time in mySelectedValues) { // Check to se if the value exist. If it was specified in the pxs, but is not present in the // database it will not exist. Maybe this check should be replaced by an exception handling // due to preformance. if (myOut.ContainsKey(time.Key)) { myOut[time.Key].SortCodePxs = time.Value; } } return(myOut); }