Example #1
0
        /// <summary>
        /// Returns the final status (id and is final value) of the specified <paramref name="reference"/>; otherwise it returns null
        /// </summary>
        /// <param name="state">
        /// The state.
        /// </param>
        /// <param name="reference">
        /// The structure reference.
        /// </param>
        /// <exception cref="ArgumentException">
        /// <paramref name="reference"/> unsupported structure
        /// </exception>
        /// <returns>
        /// The <see cref="ArtefactFinalStatus"/> of the specified <paramref name="reference"/>; otherwise it returns null.
        /// </returns>
        public static ArtefactFinalStatus GetFinalStatus(DbTransactionState state, IStructureReference reference)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            if (reference == null)
            {
                throw new ArgumentNullException("reference");
            }

            var tableInfo = _tableInfoBuilder.Build(reference.MaintainableStructureEnumType.EnumType);

            if (tableInfo == null)
            {
                _log.WarnFormat("Unsupported structure type {0}", reference.MaintainableStructureEnumType.EnumType);
                return(ArtefactFinalStatus.Empty);
                ////throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.ExceptionUnsupportedStructureReferenceFormat1, reference), "reference");
            }

            var finalQueryBuilder = new IsFinalQueryBuilder(state.Database);

            var query = finalQueryBuilder.Build(tableInfo);

            var maintainableRefObject = reference.MaintainableReference;
            var version = maintainableRefObject.SplitVersion(3);
            ArtefactFinalStatus artefactFinalStatus = ArtefactFinalStatus.Empty;

            state.ExecuteReaderFormat(
                query,
                reader =>
            {
                if (reader.Read())
                {
                    var primaryKey      = DataReaderHelper.GetInt64(reader, "primaryKey");
                    var finalStatus     = DataReaderHelper.GetBoolean(reader, "isFinal");
                    artefactFinalStatus = new ArtefactFinalStatus(primaryKey, finalStatus);
                }
            },
                state.Database.CreateInParameter("id", DbType.AnsiString, maintainableRefObject.MaintainableId),
                state.Database.CreateInParameter("agency", DbType.AnsiString, maintainableRefObject.AgencyId),
                state.Database.CreateInParameter("version1", DbType.AnsiString, version[0].ToDbValue(0)),
                state.Database.CreateInParameter("version2", DbType.AnsiString, version[1].ToDbValue(0)),
                state.Database.CreateInParameter("version3", DbType.AnsiString, version[2].ToDbValue()));

            return(artefactFinalStatus);
        }
Example #2
0
        public User GetUsers(string userName, string passWord)
        {
            User        _user      = null;
            string      sqlCommand = "select * from User where Deleted=0 and LoginID=" + userName + " and Password="******"PhoneNumber");
                _user.Password              = DataReaderHelper.GetString(dr, "Password");
                _user.LoginID               = DataReaderHelper.GetString(dr, "LoginID");
                _user.UserType              = DataReaderHelper.GetInt16(dr, "UserType");
                _user.Name                  = DataReaderHelper.GetString(dr, "Name");
                _user.Deleted               = DataReaderHelper.GetBoolean(dr, "Deleted");
                _user.Notification          = DataReaderHelper.GetBoolean(dr, "Notification");
                _user.NotificationSound     = DataReaderHelper.GetBoolean(dr, "NotificationSound");
                _user.NotificationVibration = DataReaderHelper.GetBoolean(dr, "NotificationVibration");
                _user.CreateTime            = DataReaderHelper.GetDateTime(dr, "CreateTime");
                _user.UpdateTime            = DataReaderHelper.GetDateTime(dr, "UpdateTime");
            }
            return(_user);
        }
Example #3
0
        /// <summary>
        /// This method queries the mapping store for header information for a specific dataflow
        /// </summary>
        /// <param name="beginDate">For ReportingBegin element</param>
        /// <param name="endDate">For ReportingEnd element</param>
        /// <param name="dataflowReference">The dataflow reference.</param>
        /// <returns>
        /// A <see cref="IHeader" /> object. Otherwise null
        /// </returns>
        private IHeader GetHeader(DateTime?beginDate, DateTime?endDate, IMaintainableRefObject dataflowReference)
        {
            long   headerSysId;
            string paramId  = this._mappingStoreDb.BuildParameterName(ParameterNameConstants.IdParameter);
            string version1 = this._mappingStoreDb.BuildParameterName(ParameterNameConstants.VersionParameter1);
            string version2 = this._mappingStoreDb.BuildParameterName(ParameterNameConstants.VersionParameter2);
            string version3 = this._mappingStoreDb.BuildParameterName(ParameterNameConstants.VersionParameter3);
            string agency   = this._mappingStoreDb.BuildParameterName(ParameterNameConstants.AgencyParameter);

            var sqlCommand = new StringBuilder();

            sqlCommand.Append("SELECT HD.HEADER_ID, HD.TEST, HD.DATASET_AGENCY, HD.DF_ID ");
            sqlCommand.Append("FROM HEADER HD, DATAFLOW DF, ARTEFACT ART ");
            sqlCommand.Append("WHERE HD.DF_ID = DF.DF_ID ");
            sqlCommand.Append("AND DF.DF_ID = ART.ART_ID ");
            sqlCommand.AppendFormat("AND ART.ID = {0} ", paramId);
            sqlCommand.AppendFormat("AND dbo.isEqualVersion(ART.VERSION1,ART.VERSION2,ART.VERSION3,{0},{1},{2})=1 ", version1, version2, version3);
            sqlCommand.AppendFormat("AND ART.AGENCY = {0} ", agency);

            IDictionary <string, string> additionalAttributes = new Dictionary <string, string>(StringComparer.Ordinal);
            bool     test;
            DateTime currentDate    = DateTime.Now;
            var      dataflowId     = dataflowReference.MaintainableId;
            var      dataflowAgency = dataflowReference.AgencyId;
            var      version        = dataflowReference.SplitVersion(3);

            using (DbCommand command = this._mappingStoreDb.GetSqlStringCommand(sqlCommand.ToString()))
            {
                this._mappingStoreDb.AddInParameter(command, ParameterNameConstants.IdParameter, DbType.String, dataflowId);
                this._mappingStoreDb.AddInParameter(command, ParameterNameConstants.VersionParameter1, DbType.Int64, version[0].HasValue ? version[0].Value : 0);
                this._mappingStoreDb.AddInParameter(command, ParameterNameConstants.VersionParameter2, DbType.Int64, version[1].HasValue ? version[1].Value : 0);
                this._mappingStoreDb.AddInParameter(command, ParameterNameConstants.VersionParameter3, DbType.Int64, version[2].HasValue ? (object)version[2].Value : null);
                this._mappingStoreDb.AddInParameter(command, ParameterNameConstants.AgencyParameter, DbType.String, dataflowAgency);

                using (IDataReader dataReader = this._mappingStoreDb.ExecuteReader(command))
                {
                    // we expect only 1 record here
                    if (dataReader.Read())
                    {
                        headerSysId = DataReaderHelper.GetInt64(dataReader, "HEADER_ID");
                        test        = DataReaderHelper.GetBoolean(dataReader, "TEST");
                        additionalAttributes.Add("DataSetAgency", DataReaderHelper.GetString(dataReader, "DATASET_AGENCY"));
                        _log.DebugFormat(CultureInfo.InvariantCulture, "Found header information in mapping store for Dataflow {0}", dataflowId);
                    }
                    else
                    {
                        _log.DebugFormat(CultureInfo.InvariantCulture, "No header information found in mapping store for Dataflow {0}", dataflowId);
                        return(null);
                    }
                }
            }

            string datasetId = BuildDatasetId(dataflowId, currentDate);

            // DatasetAction: Information (case that is response to a query)
            DatasetAction datasetAction = DatasetAction.GetAction("Information");

            IHeader ret = new HeaderImpl(additionalAttributes, null, null, datasetAction, dataflowId, datasetId, null, currentDate, currentDate, beginDate, endDate, null, null, null, null, test);

            PopulateHeaderLocalisedStrings(this._mappingStoreDb, headerSysId, ret);
            PoulateHeaderSendersAndReceivers(this._mappingStoreDb, headerSysId, ret);
            if (ret.Sender != null)
            {
                DateTime extracted = ret.Extracted.HasValue ? ret.Extracted.Value : currentDate;

                ret.DatasetId = BuildDatasetId(ret.Id, extracted, ret.Sender.Id);
            }

            return(ret);
        }
Example #4
0
 /// <summary>
 /// The parse extra fields.
 /// </summary>
 /// <param name="artefact">
 /// The artefact.
 /// </param>
 /// <param name="dataReader">
 /// The reader.
 /// </param>
 protected override void HandleArtefactExtraFields(TMaintaible artefact, IDataReader dataReader)
 {
     artefact.IsPartial = DataReaderHelper.GetBoolean(dataReader, "IS_PARTIAL");
 }
Example #5
0
        /// <summary>
        /// Retrieve component type.
        /// </summary>
        /// <param name="parent">
        /// The parent.
        /// </param>
        /// <param name="dataReader">
        /// The data reader.
        /// </param>
        /// <param name="crossSectionalMeasures">
        /// The cross sectional measures.
        /// </param>
        /// <returns>
        /// The <see cref="IComponentMutableObject"/>.
        /// </returns>
        /// <exception cref="InvalidOperationException">
        /// Invalid DSD Component type.
        /// </exception>
        private static IComponentMutableObject RetrieveComponentType(
            IDataStructureMutableObject parent,
            IDataRecord dataReader,
            ICollection <ICrossSectionalMeasureMutableObject> crossSectionalMeasures)
        {
            string            type = DataReaderHelper.GetString(dataReader, "TYPE");
            SdmxComponentType componentType;

            if (!Enum.TryParse(type, out componentType))
            {
                componentType = SdmxComponentType.None;
            }

            IComponentMutableObject component;

            switch (componentType)
            {
            case SdmxComponentType.Dimension:
                var dimension = new DimensionMutableCore
                {
                    FrequencyDimension = DataReaderHelper.GetBoolean(dataReader, "IS_FREQ_DIM"),
                    MeasureDimension   = DataReaderHelper.GetBoolean(dataReader, "IS_MEASURE_DIM")
                };
                component = dimension;
                parent.AddDimension(dimension);
                break;

            case SdmxComponentType.Attribute:
                component = PopulateAttributes(parent, dataReader);

                break;

            case SdmxComponentType.TimeDimension:
                var timeDimension = new DimensionMutableCore {
                    TimeDimension = true
                };
                component = timeDimension;
                parent.AddDimension(timeDimension);
                break;

            case SdmxComponentType.PrimaryMeasure:
                var primaryMeasure = new PrimaryMeasureMutableCore();
                component             = primaryMeasure;
                parent.PrimaryMeasure = primaryMeasure;
                break;

            case SdmxComponentType.CrossSectionalMeasure:
            {
                var crossSectionalMeasureBean = new CrossSectionalMeasureMutableCore {
                    Code = DataReaderHelper.GetString(dataReader, "XS_MEASURE_CODE")
                };

                component = crossSectionalMeasureBean;
                crossSectionalMeasures.Add(crossSectionalMeasureBean);
            }

            break;

            default:
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Invalid DSD Component type.  Mapping Store Database,  COMPONENT.TYPE = '{0}'", type));
            }

            return(component);
        }