Пример #1
0
        protected CountryRecord getCountryRecord(Rbr_Db pDb, RouteRow pBaseRouteRow)
        {
            CountryRow _countryRow = pDb.CountryCollection.GetByPrimaryKey(pBaseRouteRow.Country_id);

            if (_countryRow == null)
            {
                throw new Exception(string.Format("Country NOT FOUND CountryId: {0}", pBaseRouteRow.Country_id));
            }

            CountryRecord _countryRecord;

            if (countries.ContainsKey(_countryRow.Name))
            {
                _countryRecord = countries[_countryRow.Name];
            }
            else
            {
                _countryRecord = new CountryRecord(_countryRow.Country_code, _countryRow.Name);
                countries.Add(_countryRecord.Name, _countryRecord);
            }

            if (_countryRecord.Routes.ContainsKey(pBaseRouteRow.Name))
            {
                throw new Exception(string.Format("Unexpected: Route already processed? {0}", pBaseRouteRow.Name));
            }
            return(_countryRecord);
        }
Пример #2
0
        public static void ToRow(Country bean, CountryRow row)
        {
            if (bean == null)
            {
                return;
            }

            row.Id        = bean.Id;
            row.ShortName = bean.ShortName;
            row.Name      = bean.Name;
        }
Пример #3
0
            public CountryRow AddCountryRow(string Primary, string Common, string Abbreviation)
            {
                CountryRow rowCountryRow = ((CountryRow)(this.NewRow()));

                rowCountryRow.ItemArray = new object[] {
                    Primary,
                    Common,
                    Abbreviation
                };
                this.Rows.Add(rowCountryRow);
                return(rowCountryRow);
            }
Пример #4
0
        /// <summary>
        /// Initialize the province list.
        /// </summary>
        private static void InitializeProvince()
        {
            lock (DataModel.SyncRoot)
            {
                CountryRow countryRow = DataModel.Country.CountryKeyExternalId0.Find("US");

                Application.Current.Dispatcher.BeginInvoke(new WaitCallback(delegate(object data)
                {
                    StateComboBox.stateList = new ProvinceList((Guid)data);
                }), countryRow.CountryId);
            }
        }
Пример #5
0
        public static Country ToBean(CountryRow row)
        {
            if (row == null)
            {
                return(null);
            }

            var bean = new Country();

            bean.Id        = row.Id;
            bean.ShortName = row.ShortName;
            bean.Name      = row.Name;
            return(bean);
        }
Пример #6
0
        /// <summary>
        /// Create data in database
        /// </summary>
        /// <param name="country">Data</param>
        /// <returns>insert data</returns>
        public Country Create(Country country)
        {
            if (country == null || country.Id == 0)
            {
                return(null);
            }

            var row = new CountryRow();

            CountryTransformer.ToRow(country, row);
            _dbContext.Insert(row);

            return(CountryTransformer.ToBean(row));
        }
Пример #7
0
        static CountryRow mapToCountryRow(CountryDto pCountry)
        {
            if (pCountry == null)
            {
                return(null);
            }

            var _countryRow = new CountryRow();

            _countryRow.Country_id   = pCountry.CountryId;
            _countryRow.Name         = pCountry.Name;
            _countryRow.Country_code = pCountry.CountryCode;
            _countryRow.Status       = (byte)pCountry.Status;
            _countryRow.Version      = pCountry.Version;
            return(_countryRow);
        }
Пример #8
0
        static CountryDto mapToCountry(CountryRow pCountryRow)
        {
            if (pCountryRow == null)
            {
                return(null);
            }

            var _country = new CountryDto();

            _country.CountryId   = pCountryRow.Country_id;
            _country.Name        = pCountryRow.Name;
            _country.CountryCode = pCountryRow.Country_code;
            _country.Status      = (Status)pCountryRow.Status;
            _country.Version     = pCountryRow.Version;
            return(_country);
        }
        /// <summary>
        /// Updates a record in the <c>Country</c> table.
        /// </summary>
        /// <param name="value">The <see cref="CountryRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(CountryRow value)
        {
            string sqlStr = "UPDATE [dbo].[Country] SET " +
                            "[name]=" + _db.CreateSqlParameterName("Name") + ", " +
                            "[country_code]=" + _db.CreateSqlParameterName("Country_code") + ", " +
                            "[status]=" + _db.CreateSqlParameterName("Status") +
                            " WHERE " +
                            "[country_id]=" + _db.CreateSqlParameterName("Country_id");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Name", value.Name);
            AddParameter(cmd, "Country_code", value.Country_code);
            AddParameter(cmd, "Status", value.Status);
            AddParameter(cmd, "Country_id", value.Country_id);
            return(0 != cmd.ExecuteNonQuery());
        }
        /// <summary>
        /// Reads data from the provided data reader and returns
        /// an array of mapped objects.
        /// </summary>
        /// <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param>
        /// <param name="startIndex">The index of the first record to map.</param>
        /// <param name="length">The number of records to map.</param>
        /// <param name="totalRecordCount">A reference parameter that returns the total number
        /// of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param>
        /// <returns>An array of <see cref="CountryRow"/> objects.</returns>
        protected virtual CountryRow[] MapRecords(IDataReader reader,
                                                  int startIndex, int length, ref int totalRecordCount)
        {
            if (0 > startIndex)
            {
                throw new ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero.");
            }
            if (0 > length)
            {
                throw new ArgumentOutOfRangeException("length", length, "Length cannot be less than zero.");
            }

            int country_idColumnIndex   = reader.GetOrdinal("country_id");
            int nameColumnIndex         = reader.GetOrdinal("name");
            int country_codeColumnIndex = reader.GetOrdinal("country_code");
            int statusColumnIndex       = reader.GetOrdinal("status");
            int versionColumnIndex      = reader.GetOrdinal("version");

            System.Collections.ArrayList recordList = new System.Collections.ArrayList();
            int ri = -startIndex;

            while (reader.Read())
            {
                ri++;
                if (ri > 0 && ri <= length)
                {
                    CountryRow record = new CountryRow();
                    recordList.Add(record);

                    record.Country_id   = Convert.ToInt32(reader.GetValue(country_idColumnIndex));
                    record.Name         = Convert.ToString(reader.GetValue(nameColumnIndex));
                    record.Country_code = Convert.ToInt32(reader.GetValue(country_codeColumnIndex));
                    record.Status       = Convert.ToByte(reader.GetValue(statusColumnIndex));
                    record.Version      = Convert.ToInt32(reader.GetValue(versionColumnIndex));

                    if (ri == length && 0 != totalRecordCount)
                    {
                        break;
                    }
                }
            }

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((CountryRow[])(recordList.ToArray(typeof(CountryRow))));
        }
        /// <summary>
        /// Adds a new record into the <c>Country</c> table.
        /// </summary>
        /// <param name="value">The <see cref="CountryRow"/> object to be inserted.</param>
        public virtual void Insert(CountryRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[Country] (" +
                            "[country_id], " +
                            "[name], " +
                            "[country_code], " +
                            "[status]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("Country_id") + ", " +
                            _db.CreateSqlParameterName("Name") + ", " +
                            _db.CreateSqlParameterName("Country_code") + ", " +
                            _db.CreateSqlParameterName("Status") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Country_id", value.Country_id);
            AddParameter(cmd, "Name", value.Name);
            AddParameter(cmd, "Country_code", value.Country_code);
            AddParameter(cmd, "Status", value.Status);
            cmd.ExecuteNonQuery();
        }
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="CountryRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="CountryRow"/> object.</returns>
        protected virtual CountryRow MapRow(DataRow row)
        {
            CountryRow mappedObject = new CountryRow();
            DataTable  dataTable    = row.Table;
            DataColumn dataColumn;

            // Column "Country_id"
            dataColumn = dataTable.Columns["Country_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Country_id = (int)row[dataColumn];
            }
            // Column "Name"
            dataColumn = dataTable.Columns["Name"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Name = (string)row[dataColumn];
            }
            // Column "Country_code"
            dataColumn = dataTable.Columns["Country_code"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Country_code = (int)row[dataColumn];
            }
            // Column "Status"
            dataColumn = dataTable.Columns["Status"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Status = (byte)row[dataColumn];
            }
            // Column "Version"
            dataColumn = dataTable.Columns["Version"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Version = (int)row[dataColumn];
            }
            return(mappedObject);
        }
Пример #13
0
        /*
         * /// <summary>
         * /// Poutpulate data with http://www.geonames.org/export/ open datas
         * /// </summary>
         * private void CreateCities()
         * {
         *  try
         *  {
         *      int rowCount = 0;
         *      Dictionary<string, int> duplicateCityZipCodes = new Dictionary<string, int>();
         *      string line;
         *      string[] splitLine;
         *      string dataFilePath = Path.Combine(_env.WebRootPath, "databasedata", "frenchCities.csv");
         *      if (_context.Cities.Count() == 0 && File.Exists(dataFilePath))
         *      {
         *          _logger.LogInformation("Begin of Populate cities in database");
         *
         *          using (var fileStream = File.OpenRead(dataFilePath))
         *          {
         *              using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
         *              {
         *                  while ((line = streamReader.ReadLine()) != null)
         *                  {
         *                      if (line.StartsWith("#"))
         *                          continue;
         *
         *                      splitLine = line.Split(';');
         *                      if (splitLine != null && splitLine.Length > 2)
         *                      {
         *                          var city = new CityRow();
         *                          city.Name = splitLine[3];
         *                          city.ZipCode = splitLine[2];
         *                          if (!string.IsNullOrWhiteSpace(city.Name) && !string.IsNullOrWhiteSpace(city.ZipCode))
         *                          { //Manage duplicate name with different zip code
         *                              if(duplicateCityZipCodes.ContainsKey(city.ZipCode))
         *                              {
         *                                  city.Id = duplicateCityZipCodes[city.ZipCode] + 1;
         *                                  duplicateCityZipCodes[city.ZipCode] = city.Id;
         *                              }
         *                              else
         *                              {
         *                                  city.Id = 0;
         *                                  duplicateCityZipCodes.Add(city.ZipCode, city.Id);
         *                              }
         *
         *                              _context.Cities.Add(city);
         *                              rowCount++;
         *                              if (rowCount % 5000 == 0) //Commit all 500 row
         *                                  _context.SaveChanges();
         *                          }
         *                      }
         *                  }
         *                  //Security save change
         *                  _context.SaveChanges();
         *              }
         *          }
         *          _logger.LogInformation(string.Format("End of Populate cities in database : number row={0}", rowCount));
         *      }
         *  }
         *  catch(Exception exception)
         *  {
         *      _logger.LogCritical("Unable populate cities in database", exception);
         *  }
         * }
         */

        private void CreateCountries()
        {
            string rootPath = Path.Combine(_env.WebRootPath, "databasedata");

            if (!Directory.Exists(rootPath))
            {
                return;
            }

            try
            {
                int      countryId;
                string[] splitLine;
                string[] countryLines = File.ReadAllLines(Path.Combine(rootPath, "countries.txt"));
                foreach (string countryLine in countryLines)
                {
                    splitLine = countryLine.Split(';');
                    countryId = int.Parse(splitLine[0]);
                    var countryRow = _context.Country.Where(c => c.Id == countryId).FirstOrDefault();
                    if (countryRow == null)
                    {
                        countryRow = new CountryRow()
                        {
                            Id        = countryId,
                            ShortName = splitLine[1],
                            Name      = splitLine[2]
                        };
                        _context.Country.Add(countryRow);
                    }
                }
                _context.SaveChanges();
            }
            catch (Exception exception)
            {
                _logger.LogCritical("Unable populate countries in database", exception);
            }
        }
Пример #14
0
 public void AddCountryRow(CountryRow row) {
     this.Rows.Add(row);
 }
Пример #15
0
 public CountryRowChangeEvent(CountryRow row, global::System.Data.DataRowAction action) {
     this.eventRow = row;
     this.eventAction = action;
 }
Пример #16
0
 public StateRow AddStateRow(CountryRow parentCountryRowByFK_Country_State_Country_ID, string Name) {
     StateRow rowStateRow = ((StateRow)(this.NewRow()));
     rowStateRow.ItemArray = new object[] {
             null,
             parentCountryRowByFK_Country_State_Country_ID[0],
             Name};
     this.Rows.Add(rowStateRow);
     return rowStateRow;
 }
Пример #17
0
 public void AddCountryRow(CountryRow row)
 {
     this.Rows.Add(row);
 }
Пример #18
0
 public void RemoveCountryRow(CountryRow row)
 {
     this.Rows.Remove(row);
 }
Пример #19
0
 public CountryRowChangeEvent(CountryRow row, DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
 /// <summary>
 /// Deletes the specified object from the <c>Country</c> table.
 /// </summary>
 /// <param name="value">The <see cref="CountryRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(CountryRow value)
 {
     return(DeleteByPrimaryKey(value.Country_id));
 }
Пример #21
0
 public ManufacturerRow AddManufacturerRow(string Name, CountryRow parentCountryRowByFK_Manufacturer_Country, string AuthorCreate, string AuthorLastModif, System.DateTime DateLastModif, System.DateTime DateCreate, byte[] RowVersion, string CountryName) {
     ManufacturerRow rowManufacturerRow = ((ManufacturerRow)(this.NewRow()));
     rowManufacturerRow.ItemArray = new object[] {
             null,
             Name,
             parentCountryRowByFK_Manufacturer_Country[0],
             AuthorCreate,
             AuthorLastModif,
             DateLastModif,
             DateCreate,
             RowVersion,
             CountryName};
     this.Rows.Add(rowManufacturerRow);
     return rowManufacturerRow;
 }
Пример #22
0
 public void RemoveCountryRow(CountryRow row) {
     this.Rows.Remove(row);
 }
Пример #23
0
 public RegionRow AddRegionRow(string Name, string Code, string RegionType, CountryRow parentCountryRowByCountry_Region) {
     RegionRow rowRegionRow = ((RegionRow)(this.NewRow()));
     object[] columnValuesArray = new object[] {
             Name,
             Code,
             RegionType,
             null,
             null};
     if ((parentCountryRowByCountry_Region != null)) {
         columnValuesArray[4] = parentCountryRowByCountry_Region[2];
     }
     rowRegionRow.ItemArray = columnValuesArray;
     this.Rows.Add(rowRegionRow);
     return rowRegionRow;
 }
Пример #24
0
        /// <summary>
        /// Create working orders.
        /// </summary>
        /// <param name="sender">The generic thread initialization parameter.</param>
        public static void CreateOrders(object state)
        {
            GenerateTradeInfo generateTradeInfo = state as GenerateTradeInfo;

            // Create a random number generator with about as random a number as possible.
            Random random = new Random(DateTime.Now.TimeOfDay.Milliseconds);

            XDocument xDocument = new XDocument();

            lock (DataModel.SyncRoot)
            {
                // This is the selected blotter for the orders.
                BlotterRow blotterRow = DataModel.Blotter.BlotterKey.Find(generateTradeInfo.BlotterId);
                if (blotterRow == null)
                {
                    throw new Exception(String.Format("Blotter {0} not found", generateTradeInfo.BlotterId));
                }

                // This is the current user creating the orders.
                UserRow userRow = DataModel.User.UserKey.Find(Information.UserId);
                if (userRow == null)
                {
                    throw new Exception("The current user isn't mapped to a database user.");
                }

                CountryRow countryRow = DataModel.Country.CountryKeyExternalId0.Find("US");
                if (countryRow == null)
                {
                    throw new Exception("The country isn't part of the database.");
                }

                //<script name="Automatically Generated Orders">
                XElement elementRoot = new XElement("script", new XAttribute("name", "Automatically Generated Orders"));
                xDocument.Add(elementRoot);

                //  <client name="DataModelClient" type="DataModelClient, Client Data Model" endpoint="TcpDataModelEndpoint" />
                elementRoot.Add(
                    new XElement("client",
                                 new XAttribute("name", "DataModelClient"),
                                 new XAttribute("type", "DataModelClient, Client Data Model"),
                                 new XAttribute("endpoint", "TcpDataModelEndpoint")));

                for (int index = 0; index < generateTradeInfo.OrderCount; index++)
                {
                    //  <transaction>
                    XElement elementTransaction = new XElement("transaction");
                    elementRoot.Add(elementTransaction);

                    // Generate a working order identifier.
                    Guid workingOrderId = Guid.NewGuid();

                    // Generate the status of the new order.
                    StatusRow statusRow = DataModel.Status.StatusKeyStatusCode.Find(Status.New);

                    // Generate a random US Fixed Income Instrument.
                    SecurityRow securityRow           = null;
                    SecurityRow settlementCurrencyRow = null;
                    while (true)
                    {
                        // Select a random equity.
                        DebtRow debtRow = DataModel.Debt[random.Next(DataModel.Debt.Count - 1)];
                        securityRow = debtRow.SecurityRowByFK_Security_Debt_DebtId;

                        // Generate the settlement currency
                        EntityRow usdEntityRow = DataModel.Entity.EntityKeyExternalId0.Find("USD");
                        settlementCurrencyRow = DataModel.Security.SecurityKey.Find(usdEntityRow.EntityId);

                        PriceRow priceRow = DataModel.Price.PriceKey.Find(securityRow.SecurityId, settlementCurrencyRow.SecurityId);
                        if (priceRow != null)
                        {
                            break;
                        }
                    }

                    // Generate the side for the order.
                    Side    side    = random.Next(2) == 0 ? Side.Buy : Side.Sell;
                    SideRow sideRow = DataModel.Side.SideKeySideCode.Find(side);

                    // Generate the time in force for this order.
                    TimeInForceRow timeInForceRow = DataModel.TimeInForce.TimeInForceKeyTimeInForceCode.Find(TimeInForce.GoodTillCancel);

                    // Generate trade and settlement dates.
                    DateTime tradeDate      = DateTime.Now;
                    DateTime settlementDate = DateTime.Now;
                    for (int dayIndex = 0; dayIndex < 3; dayIndex++)
                    {
                        settlementDate += TimeSpan.FromDays(1.0);
                        if (settlementDate.DayOfWeek == DayOfWeek.Saturday)
                        {
                            settlementDate += TimeSpan.FromDays(1.0);
                        }
                        if (settlementDate.DayOfWeek == DayOfWeek.Sunday)
                        {
                            settlementDate += TimeSpan.FromDays(1.0);
                        }
                    }

                    // Generate matching selections.
                    Boolean isBrokerMatch      = random.Next(10) == 0;
                    Boolean isHedgeMatch       = random.Next(5) == 0;
                    Boolean isInstitutionMatch = true;
                    if (random.Next(5) == 0)
                    {
                        isBrokerMatch      = true;
                        isHedgeMatch       = true;
                        isInstitutionMatch = true;
                    }
                    if (random.Next(10) == 0)
                    {
                        isBrokerMatch      = false;
                        isHedgeMatch       = false;
                        isInstitutionMatch = false;
                    }

                    // Generate a submission type for crossing.
                    Crossing    crossing    = Crossing.NeverMatch;
                    CrossingRow crossingRow = DataModel.Crossing.CrossingKeyCrossingCode.Find(crossing);

                    //    <method name="CreateWorkingOrderEx" client="DataModelClient">
                    XElement elementWorkingOrder = new XElement(
                        "method",
                        new XAttribute("name", "CreateWorkingOrderEx"),
                        new XAttribute("client", "DataModelClient"));
                    elementTransaction.Add(elementWorkingOrder);

                    //      <parameter name="blotterKey" value="TONY DE SILVA BLOTTER" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "blotterKey"),
                                     new XAttribute("value", blotterRow.EntityRow.ExternalId0)));

                    //      <parameter name="configurationId" value="CUSIP" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "configurationId"),
                                     new XAttribute("value", "CUSIP")));

                    //      <parameter name="createdTime" value="5/26/2006 11:57:19 AM" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "createdTime"),
                                     new XAttribute("value", DateTime.Now.ToString("G"))));

                    //      <parameter name="crossingKey" value="ALWAYS" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "crossingKey"),
                                     new XAttribute("value", crossingRow.ExternalId0)));

                    //      <parameter name="externalId0" value="{fed508fb-b2a9-44df-8aa9-760f43a5d768}" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "externalId0"),
                                     new XAttribute("value", workingOrderId.ToString("B"))));

                    //      <parameter name="isBrokerMatch" value="True" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "isBrokerMatch"),
                                     new XAttribute("value", isBrokerMatch)));

                    //      <parameter name="isHedgeMatch" value="True" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "isHedgeMatch"),
                                     new XAttribute("value", isHedgeMatch)));

                    //      <parameter name="isInstitutionMatch" value="True" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "isInstitutionMatch"),
                                     new XAttribute("value", isInstitutionMatch)));

                    //      <parameter name="modifiedTime" value="5/26/2006 11:57:19 AM" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "modifiedTime"),
                                     new XAttribute("value", DateTime.Now.ToString("G"))));

                    //      <parameter name="orderTypeKey" value="MKT" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "orderTypeKey"),
                                     new XAttribute("value", "MKT")));

                    //      <parameter name="securityKeyBySecurityId" value="LMT" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "securityKeyBySecurityId"),
                                     new XAttribute("value", securityRow.EntityRow.ExternalId4)));

                    //      <parameter name="securityKeyBySettlementId" value="USD" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "securityKeyBySettlementId"),
                                     new XAttribute("value", settlementCurrencyRow.EntityRow.ExternalId0)));

                    //		<parameter name="settlementDate" value="3/31/2008 10:00:00 AM" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "settlementDate"),
                                     new XAttribute("value", settlementDate.ToString("G"))));

                    //      <parameter name="sideKey" value="BUY" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "sideKey"),
                                     new XAttribute("value", sideRow.ExternalId0)));

                    //      <parameter name="statusKey" value="PARTIALFILL" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "statusKey"),
                                     new XAttribute("value", statusRow.ExternalId0)));

                    //      <parameter name="timeInForceKey" value="DAY" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "timeInForceKey"),
                                     new XAttribute("value", timeInForceRow.ExternalId0)));

                    //		<parameter name="tradeDate" value="3/28/2008 10:00:00 AM" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "tradeDate"),
                                     new XAttribute("value", tradeDate.ToString("G"))));

                    //      <parameter name="userKeyByCreatedUserId" value="TONY DE SILVA" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "userKeyByCreatedUserId"),
                                     new XAttribute("value", userRow.EntityRow.ExternalId0)));

                    //      <parameter name="userKeyByModifiedUserId" value="TONY DE SILVA" />
                    elementWorkingOrder.Add(
                        new XElement("parameter",
                                     new XAttribute("name", "userKeyByModifiedUserId"),
                                     new XAttribute("value", userRow.EntityRow.ExternalId0)));

                    // Most working orders have only a single source order but occationally they are blocked together and
                    // allocated as a single ticket.
                    Int32 sourceOrderCount = random.Next(6) == 0 ? random.Next(4) + 1 : 1;
                    for (int sourceOrderIndex = 0; sourceOrderIndex < sourceOrderCount; sourceOrderIndex++)
                    {
                        // Generate the source order identifier.
                        Guid sourceOrderId = Guid.NewGuid();

                        // Generate the quantity of this order.
                        Decimal orderedQuantity = Convert.ToDecimal(random.Next(1, 100)) * 100.0M;
                        if (orderedQuantity == 0.0M)
                        {
                            throw new Exception("The Quantity is zero!!");
                        }

                        //    <method name="CreateSourceOrderEx" client="DataModelClient">
                        XElement elementSourceOrder = new XElement(
                            "method",
                            new XAttribute("name", "CreateSourceOrderEx"),
                            new XAttribute("client", "DataModelClient"));
                        elementTransaction.Add(elementSourceOrder);

                        //      <parameter name="blotterKey" value="TONY DE SILVA BLOTTER" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "blotterKey"),
                                         new XAttribute("value", blotterRow.EntityRow.ExternalId0)));

                        //      <parameter name="configurationId" value="CUSIP" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "configurationId"),
                                         new XAttribute("value", "CUSIP")));

                        //      <parameter name="createdTime" value="5/26/2006 11:57:19 AM" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "createdTime"),
                                         new XAttribute("value", DateTime.Now)));

                        //      <parameter name="externalId0" value="{3d289495-9c66-4582-b50f-3548c8c260f1}" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "externalId0"),
                                         new XAttribute("value", sourceOrderId.ToString("B"))));

                        //      <parameter name="modifiedTime" value="5/26/2006 11:57:19 AM" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "modifiedTime"),
                                         new XAttribute("value", DateTime.Now.ToString("G"))));

                        //      <parameter name="orderedQuantity" value="4300.0000000" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "orderedQuantity"),
                                         new XAttribute("value", orderedQuantity)));

                        //      <parameter name="orderTypeKey" value="MKT" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "orderTypeKey"),
                                         new XAttribute("value", "MKT")));

                        //      <parameter name="securityKeyBySecurityId" value="LMT" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "securityKeyBySecurityId"),
                                         new XAttribute("value", securityRow.EntityRow.ExternalId4)));

                        //      <parameter name="securityKeyBySettlementId" value="USD" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "securityKeyBySettlementId"),
                                         new XAttribute("value", settlementCurrencyRow.EntityRow.ExternalId0)));

                        //		<parameter name="settlementDate" value="3/31/2008 10:00:00 AM" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "settlementDate"),
                                         new XAttribute("value", settlementDate)));

                        //      <parameter name="sideKey" value="BUY" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "sideKey"),
                                         new XAttribute("value", sideRow.ExternalId0)));

                        //      <parameter name="statusKey" value="PARTIALFILL" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "statusKey"),
                                         new XAttribute("value", statusRow.ExternalId0)));
                        //      <parameter name="timeInForceKey" value="DAY" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "timeInForceKey"),
                                         new XAttribute("value", timeInForceRow.ExternalId0)));

                        //		<parameter name="tradeDate" value="3/28/2008 10:00:00 AM" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "tradeDate"),
                                         new XAttribute("value", tradeDate.ToString("G"))));

                        //      <parameter name="userKeyByCreatedUserId" value="TONY DE SILVA" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "userKeyByCreatedUserId"),
                                         new XAttribute("value", userRow.EntityRow.ExternalId0)));

                        //      <parameter name="userKeyByModifiedUserId" value="TONY DE SILVA" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "userKeyByModifiedUserId"),
                                         new XAttribute("value", userRow.EntityRow.ExternalId0)));

                        //      <parameter name="workingOrderKey" value="{fed508fb-b2a9-44df-8aa9-760f43a5d768}" />
                        elementSourceOrder.Add(
                            new XElement("parameter",
                                         new XAttribute("name", "workingOrderKey"),
                                         new XAttribute("value", workingOrderId.ToString("B"))));
                    }
                }

                // Fill out the file name with a default directory and an extension if they are required before saving the
                // generated orders.
                String fileName = generateTradeInfo.FileName;
                if (!Path.IsPathRooted(fileName))
                {
                    fileName = Path.Combine(Environment.ExpandEnvironmentVariables(FixedIncomeOrders.DefaultDirectory), fileName);
                }
                if (!Path.HasExtension(fileName))
                {
                    fileName = Path.ChangeExtension(fileName, FixedIncomeOrders.DefaultFileExtension);
                }
                xDocument.Save(fileName);
            }
        }