Ejemplo n.º 1
0
        public EntityResponse <List <CustomerAutomaticOptionExercisingInformation> > GetAutomaticOptionExercisingParameters(string customerCode, string customerAccountCode, string tradeSector, string tradeAccount, List <string> optionNumbers)
        {
            if (string.IsNullOrWhiteSpace(customerAccountCode))
            {
                return(EntityResponse <List <CustomerAutomaticOptionExercisingInformation> > .Error(
                           ErrorCode.SZKingdomLibraryError,
                           ErrorMessages.SZKingdom_CustomerCodeEmpty));
            }
            List <CustomerAutomaticOptionExercisingInformation> result = new List <CustomerAutomaticOptionExercisingInformation>();

            foreach (string optionNumber in optionNumbers)
            {
                var arguments = new List <SZKingdomArgument>();
                arguments.Add(SZKingdomArgument.CustomerAccountCode(customerAccountCode));

                arguments.Add(SZKingdomArgument.OptionNumber(optionNumber));

                EntityResponse <CustomerAutomaticOptionExercisingInformation> item =
                    _marketDataLibrary.ExecuteCommandSingleEntity <CustomerAutomaticOptionExercisingInformation>(SZKingdomRequest.AutomaticOptionExercisingParameters, arguments);
                if (item.Entity == null)
                {
                    item = EntityResponse <CustomerAutomaticOptionExercisingInformation> .Success(
                        new CustomerAutomaticOptionExercisingInformation()
                    {
                        ContractNumber     = optionNumber,
                        ExercisingQuantity = 0
                    });
                }

                result.Add(item);
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get ConfigSection by Id or All Root Sections
        /// </summary>
        public EntityResponse <IQueryable <ConfigDirectory> > GetConfigDirectoryById(long?id)
        {
            IQueryable <ConfigDirectory> configSectionQueryable;

            if (id.HasValue)
            {
                ConfigDirectory configSection = Uow.ConfigDirectories.GetById(id.Value);
                if (configSection == null)
                {
                    return(ErrorCode.ConfigurationSectionNotFound);
                }

                configSectionQueryable = (new List <ConfigDirectory> {
                    configSection
                }).AsQueryable();
            }
            else
            {
                configSectionQueryable = Uow.ConfigDirectories.GetAllRoots();
            }

            EntityResponse <IQueryable <ConfigDirectory> > result = EntityResponse <IQueryable <ConfigDirectory> > .Success(configSectionQueryable);

            return(result);
        }
Ejemplo n.º 3
0
        private EntityResponse <DataTable> ExecuteInternal(SZKingdomRequest function, List <SZKingdomArgument> inputParamenters)
        {
            SetFixedParameters(function, inputParamenters);
            EnsureConnected();
            _wrapper.BeginWrite();
            foreach (SZKingdomArgument input in inputParamenters)
            {
                if (!string.IsNullOrWhiteSpace(input.Value))
                {
                    _wrapper.SetValue(input.Name, input.Value);
                }
            }

            _wrapper.CallProgramAndCommit(function.InternalValue);

            // Get the first ResultSet, refer to 2.1.3 Response package
            _wrapper.RsOpen();

            // There is only one row in the first response status ResultSet
            _wrapper.RsFetchRow();             //skip first row with responseStatus

            int    messageCode = int.Parse(_wrapper.RsGetCol("MSG_CODE"));
            string messageText = _wrapper.RsGetCol("MSG_TEXT");

            // MSG_CODE: 0 means successful, others are error code.
            if (messageCode != 0)
            {
                _wrapper.RsClose();
                if (messageCode == 100)
                {
                    return(EntityResponse <DataTable> .Success(new DataTable()));
                }
                return(EntityResponse <DataTable> .Error(ErrorCode.SZKingdomLibraryError,
                                                         string.Format(messageText)));

                //string.Format("KCBP error code: {0}. Message: {1}.", messageCode, messageText));
            }

            DataTable tableResult = new DataTable();

            // Get the second ResultSet, which is the output of the request.
            if (_wrapper.RsMore())
            {
                // Get number of rows.
                int numberOfrows    = _wrapper.RsGetRowNum() - 1;
                int numberOfColumns = _wrapper.RsGetColNum();

                for (int i = 1; i <= numberOfColumns; i++)
                {
                    // Get column name by column index, column index starts from 1.
                    string columnName = _wrapper.RsGetColName(i);
                    tableResult.Columns.Add(columnName.Trim());
                }

                // Get results row by row
                for (int i = 0; i < numberOfrows; i++)
                {
                    if (!_wrapper.RsFetchRow())
                    {
                        continue;
                    }

                    object[] items = new object[numberOfColumns];
                    for (int j = 1; j <= numberOfColumns; j++)
                    {
                        items[j - 1] = _wrapper.RsGetCol(j);
                    }
                    tableResult.Rows.Add(items);
                }
            }
            _wrapper.RsClose();
            return(tableResult);
        }