Пример #1
0
        public void fralokLockSteal(DbTransaction tran, int entityId, string entityType, string lockContext, string lockTimeoutType, int userId, string sessionId, int functionTypeId, out int lockId, out DateTime lockAcquired, out DateTime lockTimeout)
        {
            string spName = "";

            try
            {
                spName = "fralokLockSteal";
                DbCommand dbCommand = base.DB.GetStoredProcCommand(spName);

                dbCommand.Parameters.Clear();
                base.DB.AddInParameter(dbCommand, "@ObjectId", DbType.Int32, entityId);
                base.DB.AddInParameter(dbCommand, "@ObjectType", DbType.String, entityType);
                base.DB.AddInParameter(dbCommand, "@LockContext", DbType.String, lockContext);
                base.DB.AddInParameter(dbCommand, "@LockTimeOutType", DbType.String, lockTimeoutType);
                base.DB.AddInParameter(dbCommand, "@UserId", DbType.Int32, userId);
                base.DB.AddInParameter(dbCommand, "@SessionId", DbType.String, sessionId);
                base.DB.AddInParameter(dbCommand, "@FunctionTypeId", DbType.Int32, functionTypeId);
                base.DB.AddOutParameter(dbCommand, "@LockId", DbType.Int32, 0);
                base.DB.AddOutParameter(dbCommand, "@LockAcquiredDateTime", DbType.DateTime, 0);
                base.DB.AddOutParameter(dbCommand, "@LockTimeoutDateTime", DbType.DateTime, 0);

                if (tran != null)
                {
                    base.DB.ExecuteNonQuery(dbCommand, tran);
                }
                else
                {
                    base.DB.ExecuteNonQuery(dbCommand);
                }

                lockId       = DataReaderHelper.GetInt(base.DB.GetParameterValue(dbCommand, "@LockId"));
                lockAcquired = DataReaderHelper.GetDateTime(base.DB.GetParameterValue(dbCommand, "@LockAcquiredDateTime"));
                lockTimeout  = DataReaderHelper.GetDateTime(base.DB.GetParameterValue(dbCommand, "@LockTimeoutDateTime"));
            }
            catch (SqlException ex)
            {
                throw new DacSqlException(ex);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                base.ReleaseConnection();
            }
        }
Пример #2
0
        /// <summary>
        /// Retrieve and populate the <see cref="IHierarchicalCodelistMutableObject.Hierarchies"/> for the HCL with specified Primary KEY
        /// </summary>
        /// <param name="hierarchicalCodelistBean">
        /// The <see cref="IHierarchicalCodelistMutableObject"/> to populate
        /// </param>
        /// <param name="sysId">
        /// The HCL Mapping store Primary KEY
        /// </param>
        private void FillHierarchy(IHierarchicalCodelistMutableObject hierarchicalCodelistBean, long sysId)
        {
            // ReSharper restore SuggestBaseTypeForParameter
            var sysIdArtefacts = new Dictionary <long, IHierarchyMutableObject>();
            var itemSqlQuery   = new ItemSqlQuery(this._hierarchyQueryInfo, sysId);

            using (DbCommand command = this._itemCommandBuilder.Build(itemSqlQuery))
            {
                using (IDataReader dataReader = this.MappingStoreDb.ExecuteReader(command))
                {
                    int sysIdIdx = dataReader.GetOrdinal("SYSID");
                    int idIdx    = dataReader.GetOrdinal("ID");

                    int txtIdx  = dataReader.GetOrdinal("TEXT");
                    int langIdx = dataReader.GetOrdinal("LANGUAGE");
                    int typeIdx = dataReader.GetOrdinal("TYPE");
                    while (dataReader.Read())
                    {
                        long hierarchySysId = DataReaderHelper.GetInt64(dataReader, sysIdIdx);
                        IHierarchyMutableObject artefact;
                        if (!sysIdArtefacts.TryGetValue(hierarchySysId, out artefact))
                        {
                            artefact = new HierarchyMutableCore {
                                Id = DataReaderHelper.GetString(dataReader, idIdx)
                            };

                            sysIdArtefacts.Add(hierarchySysId, artefact);
                        }

                        ReadLocalisedString(artefact, typeIdx, txtIdx, langIdx, dataReader);
                    }
                }
            }

            this._hierarchyAnnotationRetrieverEngine.RetrieveAnnotations(sysId, sysIdArtefacts);

            foreach (KeyValuePair <long, IHierarchyMutableObject> sysIdArtefact in sysIdArtefacts)
            {
                long hid = sysIdArtefact.Key;
                IHierarchyMutableObject artefact = sysIdArtefact.Value;

                this.FillLevel(artefact, hid);
                this.FillCodeRef(artefact, hid);
                hierarchicalCodelistBean.AddHierarchies(artefact);
            }
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="idFascicolo"></param>
        /// <returns></returns>
        private static string[] GetListaSottofascicoli(string idFascicolo)
        {
            List <string> list = new List <string>();

            using (DocsPaDB.DBProvider dbProvider = new DocsPaDB.DBProvider())
            {
                using (IDataReader reader = dbProvider.ExecuteReader(GetQueryFolders(null, idFascicolo)))
                {
                    while (reader.Read())
                    {
                        list.Add(DataReaderHelper.GetValue <object>(reader, "system_id", false).ToString());
                    }
                }
            }

            return(list.ToArray());
        }
Пример #4
0
        private Product GetProductToAdd()
        {
            int productId = 0;

            productId = DataReaderHelper.ReadIntValue("\nProduct Id : ");
            var currentStock = repository.ProductsStock;
            var stockEntry   = currentStock.StockEntries.Where(entry => entry.Product.Id == productId)
                               .SingleOrDefault();
            Product retVal = null;

            if (stockEntry != null)
            {
                retVal = stockEntry.Product;
            }

            return(retVal);
        }
Пример #5
0
        /// <summary>
        /// Populates the concept scheme per measure dimension.
        /// </summary>
        /// <param name="reader">
        /// The reader.
        /// </param>
        /// <param name="conceptSchemesPerMeasureDimension">
        /// The concept schemes per measure dimension.
        /// </param>
        private static void PopulateConceptSchemePerMeasureDimension(IDataReader reader, IDictionary <long, IMaintainableRefObject> conceptSchemesPerMeasureDimension)
        {
            int compIdIdx  = reader.GetOrdinal("COMP_ID");
            int agencyIdx  = reader.GetOrdinal("CONCEPTSCHEME_AGENCY");
            int idIdx      = reader.GetOrdinal("CONCEPTSCHEME_ID");
            int versionIdx = reader.GetOrdinal("CONCEPTSCHEME_VERSION");

            while (reader.Read())
            {
                var compId   = DataReaderHelper.GetInt64(reader, compIdIdx);
                var agencyId = DataReaderHelper.GetString(reader, agencyIdx);
                var id       = DataReaderHelper.GetString(reader, idIdx);
                var version  = DataReaderHelper.GetString(reader, versionIdx);
                var conceptSchemeReference = new MaintainableRefObjectImpl(agencyId, id, version);
                conceptSchemesPerMeasureDimension.Add(compId, conceptSchemeReference);
            }
        }
Пример #6
0
        /// <summary>
        /// Fill the components of a KeyFamilyBean object
        /// </summary>
        /// <param name="parent">
        /// The KeyFamilyBean to populate
        /// </param>
        /// <param name="parentSysId">
        /// The DSD.DSD_ID PrimaryKey
        /// </param>
        /// <returns>
        /// The <see cref="IDataStructureMutableObject"/> which will be the same as <paramref name="parent"/> unless the DSD
        ///     is cross sectional.
        /// </returns>
        private IDataStructureMutableObject FillComponents(IDataStructureMutableObject parent, long parentSysId)
        {
            var crossSectionalMeasures = new List <ICrossSectionalMeasureMutableObject>();
            var crossDataSet           = new HashSet <string>();
            var crossGroup             = new HashSet <string>();
            var crossSection           = new HashSet <string>();
            var crossObs     = new HashSet <string>();
            var componentMap = new Dictionary <long, IComponentMutableObject>();
            IStructureReference measureCodelistRepresentation = null;

            using (DbCommand command = this._commandBuilder.Build(new ItemSqlQuery(this._componentQueryInfo, parentSysId)))
                using (IDataReader dataReader = this.MappingStoreDb.ExecuteReader(command))
                {
                    var idIdx     = dataReader.GetOrdinal("ID");
                    var compIdIdx = dataReader.GetOrdinal("COMP_ID");

                    while (dataReader.Read())
                    {
                        IComponentMutableObject component = RetrieveComponentType(parent, dataReader, crossSectionalMeasures);
                        componentMap.Add(dataReader.GetInt64(compIdIdx), component);

                        component.Id = DataReaderHelper.GetString(dataReader, idIdx);

                        measureCodelistRepresentation = RetrieveRepresentationReference(dataReader, component);
                        RetrieveConceptRef(dataReader, component);

                        RetrieveCrossSectionalAttachments(dataReader, crossDataSet, component.Id, crossGroup, crossSection, crossObs);
                    }
                }

            if (parent.AttributeList != null)
            {
                this.SetupGroupAttributes(parent, parentSysId);

                SetupAttributeAttachmentLevel(parent, this.GetAttributeDimensionRefs(parentSysId));
            }

            parent = SetupCrossSectionalDsd(parent, crossDataSet, crossGroup, crossSection, crossObs, crossSectionalMeasures, measureCodelistRepresentation);
            this.SetupAttributesAttachmentCrossMeasures(parent as ICrossSectionalDataStructureMutableObject, parentSysId);

            this.GetTextFormatInformation(parentSysId, componentMap);

            this._componentAnnotationRetrieverEngine.RetrieveAnnotations(parentSysId, componentMap);

            return(parent);
        }
Пример #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="entity"></param>
 protected override void InnerLoad(IDataReader reader, ref CostFormularEntity entity)
 {
     if (reader != null && reader.IsClosed == false && entity != null)
     {
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CostFormularID"))
         {
             entity.CostFormularID = reader.GetInt32(reader.GetOrdinal("CostFormularID"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CostFormularGuid"))
         {
             entity.CostFormularGuid = reader.GetGuid(reader.GetOrdinal("CostFormularGuid"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CostFormularName"))
         {
             entity.CostFormularName = reader.GetString(reader.GetOrdinal("CostFormularName"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CostFormularValue"))
         {
             entity.CostFormularValue = reader.GetString(reader.GetOrdinal("CostFormularValue"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "EnterpriseKey"))
         {
             entity.EnterpriseKey = reader.GetString(reader.GetOrdinal("EnterpriseKey"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CostType"))
         {
             entity.CostType = (CostTypes)reader.GetInt32(reader.GetOrdinal("CostType"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CostKind"))
         {
             entity.CostKind = (CostKinds)reader.GetInt32(reader.GetOrdinal("CostKind"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "ReferanceGuid"))
         {
             entity.ReferanceGuid = reader.GetGuid(reader.GetOrdinal("ReferanceGuid"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CostFormularDesc"))
         {
             entity.CostFormularDesc = reader.GetString(reader.GetOrdinal("CostFormularDesc"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CanUsable"))
         {
             entity.CanUsable = (Logics)reader.GetInt32(reader.GetOrdinal("CanUsable"));
         }
     }
 }
Пример #8
0
        /// <summary>
        /// Retrieve annotations for the specified SDMX <paramref name="annotable"/> object
        /// </summary>
        /// <param name="sysId">The artefact primary key value.</param>
        /// <param name="annotable">The SDMX object.</param>
        public void RetrieveAnnotations(long sysId, IAnnotableMutableObject annotable)
        {
            using (var command = this._annotationCommandBuilder.Build(new PrimaryKeySqlQuery(this._annotationSqlQueryInfo, sysId)))
                using (var dataReader = this._mappingStoreDb.ExecuteReader(command))
                {
                    int annIdIdx = dataReader.GetOrdinal("ANN_ID");
                    int idIdx    = dataReader.GetOrdinal("ID");
                    int txtIdx   = dataReader.GetOrdinal("TEXT");
                    int langIdx  = dataReader.GetOrdinal("LANGUAGE");
                    int typeIdx  = dataReader.GetOrdinal("TYPE");
                    int titleIdx = dataReader.GetOrdinal("TITLE");
                    int urlIdx   = dataReader.GetOrdinal("URL");

                    IDictionary <long, IAnnotationMutableObject> annotationMap = new Dictionary <long, IAnnotationMutableObject>();

                    while (dataReader.Read())
                    {
                        var annId = dataReader.GetInt64(annIdIdx);
                        IAnnotationMutableObject annotation;
                        if (!annotationMap.TryGetValue(annId, out annotation))
                        {
                            annotation = new AnnotationMutableCore
                            {
                                Id    = DataReaderHelper.GetString(dataReader, idIdx),
                                Title = DataReaderHelper.GetString(dataReader, titleIdx),
                                Type  = DataReaderHelper.GetString(dataReader, typeIdx)
                            };
                            var url = DataReaderHelper.GetString(dataReader, urlIdx);
                            Uri uri;
                            if (!string.IsNullOrWhiteSpace(url) && Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out uri))
                            {
                                annotation.Uri = uri;
                            }

                            annotable.AddAnnotation(annotation);
                        }

                        var text = DataReaderHelper.GetString(dataReader, txtIdx);
                        if (!string.IsNullOrWhiteSpace(text))
                        {
                            annotation.AddText(DataReaderHelper.GetString(dataReader, langIdx), text);
                        }
                    }
                }
        }
Пример #9
0
        /// <summary>
        /// Creazione oggetto titolario
        /// </summary>
        /// <param name="row"></param>
        /// <param name="infoUtente"></param>
        /// <param name="amministrazione"></param>
        /// <returns></returns>
        private static OrgTitolario GetTitolario(DataRow row, InfoUtente infoUtente, InfoAmministrazione amministrazione)
        {
            OrgTitolario titolario = new OrgTitolario();

            titolario.ID     = DataReaderHelper.GetValue <object>(row, "IDRECORD", false).ToString();
            titolario.Codice = CODICE_TITOLARIO;
            titolario.CodiceAmministrazione = amministrazione.Codice;
            titolario.Descrizione           = DataReaderHelper.GetValue <string>(row, "DESCRIZIONE", false);
            titolario.SetStatoTitolario(DataReaderHelper.GetValue <string>(row, "CHA_STATO", false));
            titolario.DataAttivazione = DataReaderHelper.GetValue <DateTime>(row, "DTA_ATTIVAZIONE", false).ToString();
            if (titolario.Stato == OrgStatiTitolarioEnum.Chiuso)
            {
                titolario.DataCessazione = DataReaderHelper.GetValue <DateTime>(row, "DTA_CESSAZIONE", false).ToString();
            }
            titolario.Commento = DataReaderHelper.GetValue <string>(row, "VAR_NOTE", false);

            return(titolario);
        }
Пример #10
0
        /// <summary>
        /// Handles the extra fields of Dataflows
        /// </summary>
        /// <param name="artefact">
        ///     The maintainable reference to add the annotations to
        /// </param>
        /// <param name="reader">
        ///  reader
        /// </param>
        protected override void HandleArtefactExtraFields(IDataflowMutableObject artefact, System.Data.IDataReader reader)
        {
            base.HandleArtefactExtraFields(artefact, reader);

            // The referenced from queries do not include PRODUCTION field. So we need to check.
            // TODO pass instead the extraFields method to RetrieveArtefacts
            if (!reader.HasFieldName("PRODUCTION"))
            {
                return;
            }

            var isProduction = DataReaderHelper.GetInt32(reader, "PRODUCTION");

            if (isProduction == 0)
            {
                artefact.SetNonProduction();
            }
        }
Пример #11
0
        /// <summary>
        /// Retrieve the component representation reference.
        /// </summary>
        /// <param name="dataReader">
        /// The data reader.
        /// </param>
        /// <param name="component">
        /// The component.
        /// </param>
        /// <returns>
        /// The <see cref="IStructureReference"/> of the representation.
        /// </returns>
        private static IStructureReference RetrieveRepresentationReference(IDataRecord dataReader, IComponentMutableObject component)
        {
            IStructureReference measureCodelistRepresentation = null;
            string codelist = DataReaderHelper.GetString(dataReader, "CODELIST_ID");

            if (!string.IsNullOrWhiteSpace(codelist))
            {
                string codelistAgency         = DataReaderHelper.GetString(dataReader, "CODELIST_AGENCY");
                string codelistVersion        = DataReaderHelper.GetString(dataReader, "CODELIST_VERSION");
                var    codelistRepresentation = new StructureReferenceImpl(codelistAgency, codelist, codelistVersion, SdmxStructureEnumType.CodeList);
                component.Representation = new RepresentationMutableCore {
                    Representation = codelistRepresentation
                };
            }

            // Important. Concept scheme must be checked *after* codelist.
            var conceptSchemeRepresentation = DataReaderHelper.GetString(dataReader, "REP_CS_ID");

            if (!string.IsNullOrWhiteSpace(conceptSchemeRepresentation))
            {
                var measureDimension = component as IDimensionMutableObject;
                if (measureDimension != null && measureDimension.MeasureDimension)
                {
                    string agency  = DataReaderHelper.GetString(dataReader, "REP_CS_AGENCY");
                    string version = DataReaderHelper.GetString(dataReader, "REP_CS_VERSION");
                    if (component.Representation != null)
                    {
                        measureCodelistRepresentation = component.Representation.Representation;
                    }

                    measureDimension.Representation = new RepresentationMutableCore
                    {
                        Representation =
                            new StructureReferenceImpl(
                                agency,
                                conceptSchemeRepresentation,
                                version,
                                SdmxStructureEnumType.ConceptScheme)
                    };
                }
            }

            return(measureCodelistRepresentation);
        }
Пример #12
0
        /// <summary>
        /// This method populates the Senders and Receivers of a <see cref="IHeader"/>
        /// </summary>
        /// <param name="mappingStoreDb">
        /// The <see cref="Database"/> instance for Mapping Store database
        /// </param>
        /// <param name="headerSysId">
        /// The header system identifier. In the database the column HEADER.HEADER_ID
        /// </param>
        /// <param name="header">
        /// The <see cref="IHeader"/> to be populated in terms of Senders and Receivers
        /// </param>
        private static void PoulateHeaderSendersAndReceivers(Database mappingStoreDb, long headerSysId, IHeader header)
        {
            string paramId = mappingStoreDb.BuildParameterName(ParameterNameConstants.IdParameter);

            var sqlCommand = new StringBuilder();

            sqlCommand.Append("SELECT PARTY.PARTY_ID, PARTY.ID, PARTY.HEADER_ID, PARTY.TYPE ");
            sqlCommand.Append("FROM PARTY ");
            sqlCommand.AppendFormat("WHERE PARTY.HEADER_ID = {0} ", paramId);

            using (DbCommand command = mappingStoreDb.GetSqlStringCommand(sqlCommand.ToString()))
            {
                mappingStoreDb.AddInParameter(command, ParameterNameConstants.IdParameter, DbType.Int64, headerSysId);

                using (IDataReader dataReader = mappingStoreDb.ExecuteReader(command))
                {
                    while (dataReader.Read())
                    {
                        var    id         = DataReaderHelper.GetString(dataReader, "ID");
                        long   partySysId = DataReaderHelper.GetInt64(dataReader, "PARTY_ID");
                        string partyType  = DataReaderHelper.GetString(dataReader, "TYPE");

                        var names = new List <ITextTypeWrapper>();
                        PopulatePartyLocalisedStrings(mappingStoreDb, partySysId, names);

                        var contacts = new List <IContact>();
                        PopulatePartyContacts(mappingStoreDb, partySysId, contacts);

                        var party = new PartyCore(names, id, contacts, null);

                        // is it a sender or a receiver?
                        if (partyType.Equals(SenderText, StringComparison.OrdinalIgnoreCase))
                        {
                            header.Sender = party;
                        }
                        else if (partyType.Equals(ReceiverText, StringComparison.OrdinalIgnoreCase))
                        {
                            header.AddReciever(party);
                        }
                    }
                }
            }
        }
Пример #13
0
        /// <summary>
        /// Maps the column of the mapping to the component of this ComponentMapping1to1T object
        /// and transcodes it.
        /// </summary>
        /// <param name="reader">
        /// The DataReader for retrieving the values of the column.
        /// </param>
        /// <returns>
        /// The value of the component or null if no transcoding rule for the column values is found
        /// </returns>
        public string MapComponent(IDataReader reader)
        {
            var resultCodes = new CodeCollection();

            this.BuildOrdinals(reader);
            var    column      = this.ColumnOrdinals[0];
            string columnValue = DataReaderHelper.GetString(reader, column.Value);

            resultCodes.Add(columnValue);
            Collection <string> transcodedCodes = this.Mapping.Transcoding.TranscodingRules.GetDsdCodes(resultCodes);
            string ret = null;

            if (transcodedCodes != null && transcodedCodes.Count > 0)
            {
                ret = transcodedCodes[0];
            }

            return(ret);
        }
Пример #14
0
        /// <summary>
        /// Setups the group attributes.
        /// </summary>
        /// <param name="dataStructure">The data structure.</param>
        /// <param name="dsdId">The DSD identifier.</param>
        private void SetupAttributesAttachmentCrossMeasures(ICrossSectionalDataStructureMutableObject dataStructure, long dsdId)
        {
            if (dataStructure == null || !ObjectUtil.ValidCollection(dataStructure.Attributes) || !ObjectUtil.ValidCollection(dataStructure.CrossSectionalMeasures))
            {
                return;
            }

            var idToAttribureMap = dataStructure.Attributes.Where(o => dataStructure.CrossSectionalAttachObservation.Contains(o.Id)).ToDictionary(o => o.Id, StringComparer.Ordinal);

            if (idToAttribureMap.Count == 0)
            {
                return;
            }

            using (DbCommand command = this._commandBuilder.Build(new ItemSqlQuery(this._attributeMeasureQueryInfo, dsdId)))
            {
                using (IDataReader dataReader = this.MappingStoreDb.ExecuteReader(command))
                {
                    while (dataReader.Read())
                    {
                        var measureId   = DataReaderHelper.GetString(dataReader, "XSM_ID");
                        var attributeId = DataReaderHelper.GetString(dataReader, "ATTR_ID");
                        IAttributeMutableObject attribute;
                        if (idToAttribureMap.TryGetValue(attributeId, out attribute))
                        {
                            Debug.Assert(attribute != null, "BUG. Attribute is null");
                            IList <string> measures;
                            if (!dataStructure.AttributeToMeasureMap.TryGetValue(attributeId, out measures))
                            {
                                measures = new List <string>();
                                dataStructure.AttributeToMeasureMap.Add(attributeId, measures);
                            }

                            measures.Add(measureId);
                        }
                        else
                        {
                            _log.WarnFormat("Attribute with ID {0} of DSD {1} has measure mappings but its attachment level is not observation", attributeId, dataStructure.Id);
                        }
                    }
                }
            }
        }
Пример #15
0
        /// <summary>
        /// Maps the column of the mapping to the components of this <see cref="ComponentMappingNto1"/> object and transcodes it.
        /// </summary>
        /// <param name="reader">
        /// The DataReader for retrieving the values of the column.
        /// </param>
        /// <returns>
        /// The value of the component or null if no transcoding rule for the column values is found
        /// </returns>
        public string MapComponent(IDataReader reader)
        {
            string ret = null;

            this.BuildOrdinals(reader);
            ColumnOrdinal column      = this.ColumnOrdinals[0];
            var           resultCodes = new CodeCollection {
                DataReaderHelper.GetString(reader, column.Value)
            };

            CodeCollection transcodedCodes = this.Mapping.Transcoding.TranscodingRules.GetDsdCodes(resultCodes);

            if (transcodedCodes != null && this._componentIndex < transcodedCodes.Count)
            {
                ret = transcodedCodes[this._componentIndex];
            }

            return(ret);
        }
Пример #16
0
        private void HandleAddNewProduct()
        {
            Console.Clear();
            ListProductsInStock();
            var   productToAdd = GetProductToAdd();
            ulong qty          = DataReaderHelper.ReadLongValue("\nQty (valid number): ");

            try
            {
                currentCustomer.AddItemToOrder(productToAdd, qty);
                Console.WriteLine($"Product {productToAdd.Name} {qty} pcs added to the order");
            }
            catch (Exception e)
            {
                Console.WriteLine("Unable to add product to order. " + e.Message);
            }

            Console.ReadLine();
        }
Пример #17
0
        /// <summary>
        /// This method populates the Localized Strings (Names, Departments, Roles)
        ///     of a <see cref="IContactMutableObject"/>
        /// </summary>
        /// <param name="mappingStoreDb">
        /// The <see cref="Database"/> instance for Mapping Store database
        /// </param>
        /// <param name="contactSysId">
        /// The contact system identifier. In the database the column CONTACT.CONTACT_ID
        /// </param>
        /// <param name="contact">
        /// The <see cref="IContactMutableObject"/> to be populated in terms of Names, Departments, Roles
        /// </param>
        private static void PopulateContactLocalisedStrings(Database mappingStoreDb, long contactSysId, IContactMutableObject contact)
        {
            string paramId = mappingStoreDb.BuildParameterName(ParameterNameConstants.IdParameter);

            var sqlCommand = new StringBuilder();

            sqlCommand.Append("SELECT HLS.HLS_ID, HLS.TYPE, HLS.HEADER_ID, HLS.PARTY_ID, HLS.CONTACT_ID, HLS.LANGUAGE, HLS.TEXT ");
            sqlCommand.Append("FROM HEADER_LOCALISED_STRING HLS ");
            sqlCommand.AppendFormat("WHERE HLS.CONTACT_ID = {0} ", paramId);

            using (DbCommand command = mappingStoreDb.GetSqlStringCommand(sqlCommand.ToString()))
            {
                mappingStoreDb.AddInParameter(command, ParameterNameConstants.IdParameter, DbType.Int64, contactSysId);

                using (IDataReader dataReader = mappingStoreDb.ExecuteReader(command))
                {
                    while (dataReader.Read())
                    {
                        var text = new TextTypeWrapperMutableCore {
                            Locale = DataReaderHelper.GetString(dataReader, "LANGUAGE"), Value = DataReaderHelper.GetString(dataReader, "TEXT")
                        };
                        if (!string.IsNullOrWhiteSpace(text.Value) && !string.IsNullOrWhiteSpace(text.Locale))
                        {
                            string textType = DataReaderHelper.GetString(dataReader, "TYPE");

                            if (textType.Equals(NameText, StringComparison.OrdinalIgnoreCase))
                            {
                                contact.Names.Add(text);
                            }
                            else if (textType.Equals(DepartmentText, StringComparison.OrdinalIgnoreCase))
                            {
                                contact.Departments.Add(text);
                            }
                            else if (textType.Equals(RoleText, StringComparison.OrdinalIgnoreCase))
                            {
                                contact.Roles.Add(text);
                            }
                        }
                    }
                }
            }
        }
Пример #18
0
 /// <summary>
 /// Generic method for retrieving <see cref="IStructureReference"/> based objects
 /// </summary>
 /// <param name="outList">
 /// The output list
 /// </param>
 /// <param name="command">
 /// The current <see cref="DbCommand"/>
 /// </param>
 /// <param name="structureType">
 /// The structure Type.
 /// </param>
 protected void RetrieveRef(ICollection <IStructureReference> outList, DbCommand command, SdmxStructureEnumType structureType)
 {
     _log.DebugFormat("RetrieveRef of {0} SQL : {1}", structureType, command.CommandText);
     using (IDataReader dataReader = this._mappingStoreDb.ExecuteReader(command))
     {
         int idField      = dataReader.GetOrdinal("ID");
         int agencyField  = dataReader.GetOrdinal("AGENCY");
         int versionField = dataReader.GetOrdinal("VERSION");
         while (dataReader.Read())
         {
             var item = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(structureType))
             {
                 MaintainableId = DataReaderHelper.GetString(dataReader, idField),
                 Version        = DataReaderHelper.GetString(dataReader, versionField),
                 AgencyId       = DataReaderHelper.GetString(dataReader, agencyField)
             };
             outList.Add(item);
         }
     }
 }
Пример #19
0
        /// <summary>
        /// Gets the text format information.
        /// </summary>
        /// <param name="parentSysId">
        /// The parent system unique identifier.
        /// </param>
        /// <param name="componentMap">
        /// The component map.
        /// </param>
        private void GetTextFormatInformation(long parentSysId, IDictionary <long, IComponentMutableObject> componentMap)
        {
            var textFormats = new Dictionary <long, ITextFormatMutableObject>();

            using (var command = this.MappingStoreDb.GetSqlStringCommandFormat(DsdConstant.TextFormatQueryFormat, this.MappingStoreDb.CreateInParameter("dsdId", DbType.Int64, parentSysId)))
                using (var reader = this.MappingStoreDb.ExecuteReader(command))
                {
                    var compIdIdx     = reader.GetOrdinal("COMP_ID");
                    var enumNameIdx   = reader.GetOrdinal("ENUM_NAME");
                    var enumValueIdx  = reader.GetOrdinal("ENUM_VALUE");
                    var facetValueIdx = reader.GetOrdinal("FACET_VALUE");

                    while (reader.Read())
                    {
                        var compId = reader.GetInt64(compIdIdx);

                        ITextFormatMutableObject textFormat;
                        if (!textFormats.TryGetValue(compId, out textFormat))
                        {
                            textFormat = new TextFormatMutableCore();
                            textFormats.Add(compId, textFormat);
                        }

                        var enumName   = DataReaderHelper.GetString(reader, enumNameIdx);
                        var enumValue  = DataReaderHelper.GetString(reader, enumValueIdx);
                        var facetValue = DataReaderHelper.GetString(reader, facetValueIdx);
                        PopulateTextFormat(enumName, enumValue, textFormat, facetValue);
                    }
                }

            foreach (var textFormat in textFormats)
            {
                IComponentMutableObject component = componentMap[textFormat.Key];
                if (component.Representation == null)
                {
                    component.Representation = new RepresentationMutableCore();
                }

                component.Representation.TextFormat = textFormat.Value;
            }
        }
Пример #20
0
        //_list_condition_func
        PreSelectBuilderFunc GetPreSelectBuilderFunc(System.Type type, string value)
        {
            PreSelectBuilderFunc func;
            string key = type.AssemblyQualifiedName + "|" + value;

            if (!_list_condition_func.TryGetValue(key, out func))
            {
                ThreadHelper.Block(_list_condition_func, () => {
                    if (!_list_condition_func.TryGetValue(value, out func))
                    {
                        if (value.StartsWith("$this.", StringComparison.OrdinalIgnoreCase))
                        {
                            string path = value.Substring("$this.".Length);
                            func        = (dataContext, dataReader, entity) => {
                                return(FastObject.Path(entity, path));
                            };
                        }
                        if (value.StartsWith("$reader.", StringComparison.OrdinalIgnoreCase))
                        {
                            string p10 = value.Substring("$reader.".Length);
                            if (p10.IndexOf('.') > -1)
                            {
                                string name = p10.Split('.')[0];
                                string path = p10.Substring(name.Length + 1);
                                func        = (dataContext, dataReader, entity) => {
                                    return(FastObject.Path(DataReaderHelper.Current(dataReader, name), path));
                                };
                            }
                            else
                            {
                                func = (dataContext, dataReader, entity) => {
                                    return(DataReaderHelper.Current(dataReader, p10));
                                };
                            }
                        }
                        _list_condition_func.TryAdd(key, func);
                    }
                });
            }
            return(func);
        }
Пример #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="row"></param>
        /// <param name="infoUtente"></param>
        /// <returns></returns>
        private static DocsPaVO.fascicolazione.Fascicolo GetFascicolo(DataRow row, InfoUtente infoUtente)
        {
            DocsPaVO.fascicolazione.Fascicolo fascicolo = new DocsPaVO.fascicolazione.Fascicolo();

            fascicolo.systemID              = DataReaderHelper.GetValue <object>(row, "SYSTEM_ID", false).ToString();
            fascicolo.apertura              = DataReaderHelper.GetValue <object>(row, "DTA_APERTURA", true, string.Empty).ToString();
            fascicolo.chiusura              = DataReaderHelper.GetValue <object>(row, "DTA_CHIUSURA", true, string.Empty).ToString();
            fascicolo.codice                = DataReaderHelper.GetValue <object>(row, "VAR_CODICE", false).ToString();
            fascicolo.descrizione           = DataReaderHelper.GetValue <object>(row, "DESCRIPTION", false).ToString();
            fascicolo.stato                 = DataReaderHelper.GetValue <object>(row, "CHA_STATO", true, string.Empty).ToString();
            fascicolo.tipo                  = DataReaderHelper.GetValue <object>(row, "CHA_TIPO_FASCICOLO", false).ToString();
            fascicolo.idClassificazione     = DataReaderHelper.GetValue <object>(row, "ID_PARENT", true, string.Empty).ToString();
            fascicolo.codUltimo             = DataReaderHelper.GetValue <object>(row, "VAR_COD_ULTIMO", true, string.Empty).ToString();
            fascicolo.idRegistroNodoTit     = DataReaderHelper.GetValue <object>(row, "ID_REGISTRO", true, string.Empty).ToString();
            fascicolo.codiceRegistroNodoTit = DataReaderHelper.GetValue <object>(row, "CODREG", true, string.Empty).ToString();
            fascicolo.idTitolario           = DataReaderHelper.GetValue <object>(row, "ID_PARENT", true, string.Empty).ToString();
            fascicolo.cartaceo              = (Convert.ToInt32(DataReaderHelper.GetValue <object>(row, "CARTACEO", true, 0)) > 0);
            fascicolo.privato               = DataReaderHelper.GetValue <object>(row, "CHA_PRIVATO", true, string.Empty).ToString();

            return(fascicolo);
        }
        /// <summary>
        ///     查询分页数据-部分字段
        /// </summary>
        /// <param name="where"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public static PageResult <T> QueryPage <T, TP, TO>(this IDBContext <T> context, Expression <Func <T, TP> > expression, string where,
                                                           IDictionary <string, object> paras,
                                                           Expression <Func <TP, TO> > orderexpression, int pageIndex, int pageSize) where T : BaseEntity <T>, new()
        {
            if (SQLWordFilte.CheckKeyWord(@where))
            {
                throw new Exception("您提供的关键字有可能危害数据库,已阻止执行");
            }
            var props         = ExpressionHelper.GetProps(expression);
            var order         = orderexpression == null ? "" : ExpressionHelper.GetProps(orderexpression)[0];
            var parasList     = new List <SqlParameter>();
            var parasListData = new List <SqlParameter>();

            if (paras != null)
            {
                foreach (var para in paras)
                {
                    parasList.Add(new SqlParameter(para.Key, para.Value));
                    parasListData.Add(new SqlParameter(para.Key, para.Value));
                }
            }
            ISQLContext sqlContext = new SQLContext(context.Session);
            var         entity     = new T();
            string      sql        = entity.GetQuerySQL(@where);
            var         cols       = string.Join(",", props);

            sql = string.Format("select {0} from ( {1} ) Tab ", cols, sql);
            var total = sqlContext.GetResult <int>(string.Format("SELECT COUNT(1) FROM ({0}) a", sql), parasList.ToArray());

            int start   = (pageIndex - 1) * pageSize;
            var tempsql = "select *,ROW_NUMBER() OVER(ORDER BY " + order + ") rn from ({0}) a ";

            sql = string.Format(tempsql, sql);
            sql = "SELECT TOP " + pageSize + " * FROM (" + sql + ") query WHERE rn > " + start + " ORDER BY rn";

            var reader   = sqlContext.ExecuteQueryReader(sql, parasListData.ToArray());
            var entities = DataReaderHelper.ReaderToList <T>(reader);

            return(new PageResult <T>(entities, total));
        }
Пример #23
0
        /// <summary>
        /// The populate attributes.
        /// </summary>
        /// <param name="parent">
        /// The parent.
        /// </param>
        /// <param name="dataReader">
        /// The data reader.
        /// </param>
        /// <returns>
        /// The <see cref="IComponentMutableObject"/>.
        /// </returns>
        /// <exception cref="SdmxNotImplementedException">
        /// Unsupported attachment level at COMPONENT.ATT_ASS_LEVEL
        /// </exception>
        private static IComponentMutableObject PopulateAttributes(IDataStructureMutableObject parent, IDataRecord dataReader)
        {
            var attribute = new AttributeMutableCore {
                AssignmentStatus = DataReaderHelper.GetString(dataReader, "ATT_STATUS")
            };

            // TODO pending support already in Java
            ////attribute.TimeFormat = DataReaderHelper.GetBoolean(dataReader, "ATT_IS_TIME_FORMAT")
            ////                           ? "true"
            ////                           : "false";
            string attachmentLevel = DataReaderHelper.GetString(dataReader, "ATT_ASS_LEVEL");

            switch (attachmentLevel)
            {
            case AttachmentLevelConstants.DataSet:
                attribute.AttachmentLevel = AttributeAttachmentLevel.DataSet;
                break;

            case AttachmentLevelConstants.Group:
                attribute.AttachmentLevel = AttributeAttachmentLevel.Group;
                break;

            case AttachmentLevelConstants.Observation:
                attribute.AttachmentLevel = AttributeAttachmentLevel.Observation;
                break;

            case AttachmentLevelConstants.Series:
                attribute.AttachmentLevel = AttributeAttachmentLevel.DimensionGroup;

                break;

            default:
                throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "Attachment:" + attachmentLevel);
            }

            IComponentMutableObject component = attribute;

            parent.AddAttribute(attribute);
            return(component);
        }
Пример #24
0
        /// <summary>
        /// Read the localized string from <paramref name="dataReader"/>
        /// </summary>
        /// <param name="item">
        ///     The <see cref="INameableMutableObject"/> .
        /// </param>
        /// <param name="typeIdx">
        ///     The <c>LOCALISED_STRING.TYPE</c> ordinal
        /// </param>
        /// <param name="txtIdx">
        ///     The <c>LOCALISED_STRING.TEXT</c> ordinal
        /// </param>
        /// <param name="langIdx">
        ///     The <c>LOCALISED_STRING.LANGUAGE</c> ordinal
        /// </param>
        /// <param name="dataReader">
        ///     The MASTORE DB <see cref="IDataReader"/>
        /// </param>
        /// <param name="detail">The Structure Query Detail</param>
        protected static void ReadLocalisedString(INameableMutableObject item, int typeIdx, int txtIdx, int langIdx, IDataRecord dataReader, ComplexStructureQueryDetailEnumType detail = ComplexStructureQueryDetailEnumType.Full)
        {
            //// TODO support SDMX-ML Query detail CompleteStub versus Stub when Common API supports it.
            //// When it is stub then only name should be returned.
            //// When it is complete stub both name and description.
            //// Now we use StructureQueryDetail which is for REST queries only.
            //// According to the http://sdmx.org/wp-content/uploads/2012/05/SDMX_2_1-SECTION_07_WebServicesGuidelines_May2012.pdf
            //// page 10, footnotes 10-12 REST AllStubs == SDMX-ML Query Stub so in that case we skip description

            var    value    = DataReaderHelper.GetString(dataReader, txtIdx);
            var    locale   = DataReaderHelper.GetString(dataReader, langIdx);
            string type     = DataReaderHelper.GetString(dataReader, typeIdx);
            var    textType = new TextTypeWrapperMutableCore {
                Locale = locale, Value = value
            };

            switch (type)
            {
            case LocalisedStringType.Name:
                item.Names.Add(textType);
                break;

            case LocalisedStringType.Desc:
                if (detail != ComplexStructureQueryDetailEnumType.Stub)
                {
                    item.Descriptions.Add(textType);
                }

                break;

            default:
                _log.WarnFormat(CultureInfo.InvariantCulture, "Unknown type at LOCALISATION.TYPE : '{0}', Locale: '{1}', Text:'{2}'", type, locale, value);
                if (item.Names.Count == 0)
                {
                    item.AddName(null, !string.IsNullOrWhiteSpace(value) ? value : item.Id);
                }

                break;
            }
        }
Пример #25
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);
        }
        /// <summary>
        /// linq查询
        /// </summary>
        /// <param name="func"></param>
        /// <returns></returns>
        public static List <T> Query <T>(this IDBContext <T> context, Expression <Func <T, bool> > func) where T : BaseEntity <T>, new()
        {
            var entity = new T();

            var h = new ExpressionHelper();

            //解析表达式
            h.ResolveExpression(func);
            var sql = entity.GetQuerySQL("");

            sql = string.Format("select * from ( {0} ) Tab ", sql);
            if (!h.SqlWhere.IsNullOrEmpty())
            {
                sql += " where  " + h.SqlWhere;
            }
            var         paramters  = h.Paras;
            ISQLContext sqlContext = new SQLContext(context.Session);
            var         reader     = sqlContext.ExecuteQueryReader(sql, paramters.ToArray());
            var         entities   = DataReaderHelper.ReaderToList <T>(reader);

            return(entities);
        }
Пример #27
0
        /// <summary>
        ///     分页查询
        /// </summary>
        /// <param name="where"></param>
        /// <param name="order"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public PageResult <T> QueryPage(string @where, IDictionary <string, object> paras, string order, int pageIndex,
                                        int pageSize)
        {
            if (SQLWordFilte.CheckKeyWord(@where))
            {
                throw new Exception("您提供的关键字有可能危害数据库,已阻止执行");
            }
            var parasList     = new List <SqlParameter>();
            var parasListData = new List <SqlParameter>();

            if (paras != null)
            {
                foreach (var para in paras)
                {
                    parasList.Add(new SqlParameter(para.Key, para.Value));
                    parasListData.Add(new SqlParameter(para.Key, para.Value));
                }
            }


            ISQLContext sqlContext = new SQLContext(Session);
            var         entity     = new T();
            string      sql        = entity.GetQuerySQL(@where);

            var total = sqlContext.GetResult <int>(string.Format("SELECT COUNT(1) FROM ({0}) a", sql), parasList.ToArray());

            int start   = (pageIndex - 1) * pageSize;
            var tempsql = "select *,ROW_NUMBER() OVER(ORDER BY " + order + ") rn from ({0}) a ";

            sql = string.Format(tempsql, sql);


            sql = "SELECT TOP " + pageSize + " * FROM (" + sql + ") query WHERE rn > " + start + " ORDER BY rn";

            var reader   = sqlContext.ExecuteQueryReader(sql, parasListData.ToArray());
            var entities = DataReaderHelper.ReaderToList <T>(reader);

            return(new PageResult <T>(entities, total));
        }
Пример #28
0
        /// <summary>
        /// Transcodes the time period returned by the local database to SDMX Time period
        /// </summary>
        /// <param name="reader">
        /// The data reader reading the Dissemination database
        /// </param>
        /// <returns>
        /// The transcoded time period, as in SDMX Time period type
        /// </returns>
        public string MapComponent(IDataReader reader)
        {
            this._fieldOrdinals.BuildOrdinal(reader);
            string year = DataReaderHelper.GetString(reader, this._fieldOrdinals.YearOrdinal);

            if (this.Expression.YearLength > 0)
            {
                year = year.Substring(this.Expression.YearStart, this.Expression.YearLength);
            }

            string period = DataReaderHelper.GetString(reader, this._fieldOrdinals.PeriodOrdinal);

            if (this.Expression.PeriodLength > 0)
            {
                int rowPeriodLen = this.Expression.PeriodLength;
                if (this.Expression.PeriodLength + this.Expression.PeriodStart > period.Length)
                {
                    rowPeriodLen = period.Length - this.Expression.PeriodStart;
                }

                period = period.Substring(this.Expression.PeriodStart, rowPeriodLen);
            }

            this._periodLocalCode.Clear();
            this._periodLocalCode.Add(period);
            CodeCollection periodDsdCode = this.Expression.TranscodingRules.GetDsdCodes(this._periodLocalCode);

            if (periodDsdCode == null)
            {
                return(null); // MAT-495

                // periodDsdCode = periodLocalCode;
            }

            string ret = string.Format(CultureInfo.InvariantCulture, "{0}-{1}", year, periodDsdCode[0]);

            // ret = _timePeriodTranscoding[String.Format(CultureInfo.InvariantCulture,"{0}-{1}", year, period)];
            return(ret);
        }
Пример #29
0
        /// <summary>
        /// This method populates the Localized Strings (Names, Sources) of a <see cref="IHeader"/>
        /// </summary>
        /// <param name="mappingStoreDb">
        /// The <see cref="Database"/> instance for Mapping Store database
        /// </param>
        /// <param name="headerSysId">
        /// The header system identifier. In the database the column HEADER.HEADER_ID
        /// </param>
        /// <param name="header">
        /// The <see cref="IHeader"/> to be populated in terms of Names and Sources
        /// </param>
        private static void PopulateHeaderLocalisedStrings(Database mappingStoreDb, long headerSysId, IHeader header)
        {
            string paramId = mappingStoreDb.BuildParameterName(ParameterNameConstants.IdParameter);

            var sqlCommand = new StringBuilder();

            sqlCommand.Append("SELECT HLS.HLS_ID, HLS.TYPE, HLS.HEADER_ID, HLS.PARTY_ID, HLS.CONTACT_ID, HLS.LANGUAGE, HLS.TEXT ");
            sqlCommand.Append("FROM HEADER_LOCALISED_STRING HLS ");
            sqlCommand.AppendFormat("WHERE HLS.HEADER_ID = {0} ", paramId);

            using (DbCommand command = mappingStoreDb.GetSqlStringCommand(sqlCommand.ToString()))
            {
                mappingStoreDb.AddInParameter(command, ParameterNameConstants.IdParameter, DbType.Int64, headerSysId);

                using (IDataReader dataReader = mappingStoreDb.ExecuteReader(command))
                {
                    while (dataReader.Read())
                    {
                        var text = new TextTypeWrapperMutableCore {
                            Locale = DataReaderHelper.GetString(dataReader, "LANGUAGE"), Value = DataReaderHelper.GetString(dataReader, "TEXT")
                        };
                        string textType = DataReaderHelper.GetString(dataReader, "TYPE");

                        // is it a sender or a receiver?
                        if (textType.Equals(NameText, StringComparison.OrdinalIgnoreCase))
                        {
                            header.AddName(new TextTypeWrapperImpl(text, null));
                        }
                        else
                        {
                            if (textType.Equals(SourceText, StringComparison.OrdinalIgnoreCase))
                            {
                                header.AddSource(new TextTypeWrapperImpl(text, null));
                            }
                        }
                    }
                }
            }
        }
Пример #30
0
        public void wkfconItemIDFromMIN(DbTransaction tran, string min, string minItem, out int itemId)
        {
            string spName = "";

            try
            {
                spName = "wkfconItemIDFromMIN";
                DbCommand dbCommand = base.DB.GetStoredProcCommand(spName);

                dbCommand.Parameters.Clear();
                base.DB.AddInParameter(dbCommand, "@Min", DbType.String, min);
                base.DB.AddInParameter(dbCommand, "@MinItem", DbType.String, minItem);
                base.DB.AddOutParameter(dbCommand, "@ItemId", DbType.Int32, 0);

                if (tran != null)
                {
                    base.DB.ExecuteNonQuery(dbCommand, tran);
                }
                else
                {
                    base.DB.ExecuteNonQuery(dbCommand);
                }

                itemId = DataReaderHelper.GetInt(base.DB.GetParameterValue(dbCommand, "@ItemId"));
            }
            catch (SqlException ex)
            {
                throw new DacSqlException(ex);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                base.ReleaseConnection();
            }
        }