public override void Input0_ProcessInputRow(Input0Buffer Row)
 {
     /*
       Add your code here
     */
     if(isNumeric(Row.DAHDRSHIPTONUM, out num))
     {
         Row.DAHDRSHIPTONUM = num.ToString();
     }
     if(isNumeric(Row.PRODDTLPRODCODE, out num))
     {
         Row.PRODDTLPRODCODE = num.ToString();
     }
     if(isNumeric(Row.PRODDTLBRNDCODE, out num))
     {
         Row.PRODDTLBRNDCODE = num.ToString();
     }
     if(isNumeric(Row.DAHDRPRIMBRKRCODE, out num))
     {
         Row.DAHDRPRIMBRKRCODE = num.ToString();
     }
     if(isNumeric(Row.DAHDRSALESMANCODE, out num))
     {
         Row.DAHDRSALESMANCODE = num.ToString();
     }
     if(isNumeric(Row.DAHDRBILLTONUM, out num))
     {
         Row.DAHDRBILLTONUM = num.ToString();
     }
 }
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        //MessageBox.Show("PROD_CODE: " + Row.PRODCODE + "\nBRND_CODE: " + Row.BRNDCODE);
        oledbCmd.Parameters.Add("@p1", OleDbType.Numeric).Value = Row.PRODCODE;
        oledbCmd.Parameters.Add("@p2", OleDbType.Numeric).Value = Row.BRNDCODE;
        oledbCmd.Parameters.Add("@p3", OleDbType.Char).Value = oraDate;
        oledbCmd.Parameters.Add("@p4", OleDbType.Char).Value = oraDate;

        //        writeSqlCmdToFile(oledbCmd.CommandText);
        //        MessageBox.Show(Convert.ToString(count));

        try
        {
            //writeSqlCmdToFile(oledbCmd.CommandText);
            rowsAffected = oledbCmd.ExecuteNonQuery();
            //MessageBox.Show(Convert.ToString(rowsAffected));
        }
        catch(Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }

        oledbCmd.Parameters.Clear();
        count++;
    }
 /// <summary>
 /// This method is called once for every row that passes through the component from Input0.
 ///
 /// Example of reading a value from a column in the the row:
 ///  string zipCode = Row.ZipCode
 ///
 /// Example of writing a value to a column in the row:
 ///  Row.ZipCode = zipCode
 /// </summary>
 /// <param name="Row">The row that is currently passing through the component</param>
 public override void Input0_ProcessInputRow(Input0Buffer Row)
 {
     /*
      * Add your code here
      */
     try
     {
         Row.agencySTAGING = (Row.agencySTAGING == "-" ? null: Row.agencySTAGING);
         // Row.yearSTAGING = (Row.yearSTAGING == "-" ? null: Row.yearSTAGING);
         Row.departmentSTAGING         = (Row.departmentSTAGING == "-" ? null: Row.departmentSTAGING);
         Row.expensecategorySTAGING    = (Row.expensecategorySTAGING == "-" ? null: Row.expensecategorySTAGING);
         Row.budgetcodeSTAGING         = (Row.budgetcodeSTAGING == "-" ? null: Row.budgetcodeSTAGING);
         Row.budgetnameSTAGING         = (Row.budgetnameSTAGING == "-" ? null: Row.budgetnameSTAGING);
         Row.budgetamountsSTAGING      = (Row.budgetamountsSTAGING == "-" ? null: Row.budgetamountsSTAGING);
         Row.expenditureamountsSTAGING = (Row.expenditureamountsSTAGING == "-" ? null: Row.expenditureamountsSTAGING);
     }
     catch (Exception ex)
     {
         Row.agencySTAGING = "ERROR";
         // Row.yearSTAGING = "ERROR";
         Row.departmentSTAGING         = "ERROR";
         Row.expensecategorySTAGING    = "ERROR";
         Row.budgetcodeSTAGING         = "ERROR";
         Row.budgetnameSTAGING         = "ERROR";
         Row.budgetamountsSTAGING      = "ERROR";
         Row.expenditureamountsSTAGING = "ERROR";
     }
 }
Esempio n. 4
0
    /// <summary>
    /// Accumulate all the input rows into an internal LINQ-able
    /// collection
    /// </summary>
    /// <param name="Row">The buffer holding the current row</param>
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        // there is probably a more graceful mechanism of spinning
        // up this struct.
        // You must also worry about fields that have null types.
        Data d = new Data();

        d.ID          = Row.ID;
        d.Title       = Row.Title;
        d.OneToManyId = Row.OneToManyDataID;
        this.data.Add(d);
    }
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        // Create a SqlGeometry object representing the given data
        SqlGeometry g = SqlGeometry.STPointFromText(new SqlChars("POINT (" + Row.Northing + " " + Row.Easting + ")"), 0);

        // Serialize to a memory stream
        ms.SetLength(0);
        g.Write(bw);
        bw.Flush();

        // Copy data from memory stream to output column with DT_IMAGE format
        Row.pt.AddBlobData(ms.GetBuffer(), (int)ms.Length);
    }
    /// <summary>
    /// This method is called once for every row that passes through the component from Input0.
    ///
    /// Example of reading a value from a column in the the row:
    ///  string zipCode = Row.ZipCode
    ///
    /// Example of writing a value to a column in the row:
    ///  Row.ZipCode = zipCode
    /// </summary>
    /// <param name="Row">The row that is currently passing through the component</param>
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        /*
         * Add your code here
         */

        for (int columnIndex = 0; columnIndex < ColumnCount; columnIndex++)
        {
            this.WriteFieldContent(inputBuffer[ColumnNameArray[columnIndex].Index], (columnIndex != LastColumnIndex));
        }

        textWriter.WriteLine();
    }
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        Regex reg = new Regex(toreplace);

        // Test for nulls otherwise Replace will blow up
        if (!Row.Na_IsNull)
        {
            Row.NaN = reg.Replace(Row.Na, replacewith);
        }
        else
        {
            Row.NaN_IsNull = true;
        }
    }
    private void ReadResponseDistance(Input0Buffer Row, XmlDocument xmlDoc, WebResponse response)
    {
        // Open the stream using a StreamReader for easy access.
        StreamReader reader = new StreamReader(response.GetResponseStream());

        // Read the content fully up to the end.
        string responseFromServer = reader.ReadToEnd();

        // Clean up the streams.
        reader.Close();

        xmlDoc.LoadXml(responseFromServer);

        string sts = xmlDoc.DocumentElement.SelectSingleNode("status").InnerText;

        if (sts == "OK")
        {
            try
            {
                string dist = xmlDoc.DocumentElement.SelectSingleNode("row/element/distance/value").InnerText;

                if (dist != null)
                {
                    decimal distance = decimal.Parse(dist);
                    distance     = distance / 1000;
                    distance     = Math.Round(distance, 1, MidpointRounding.AwayFromZero);
                    Row.Distance = distance;

                    if (distance <= 20)
                    {
                        Row.DeliveryZone = 1;
                    }
                    else if (distance > 20 && distance <= 50)
                    {
                        Row.DeliveryZone = 2;
                    }
                    else if (distance > 50)
                    {
                        Row.DeliveryZone = 3;
                    }
                }
            }
            catch (Exception ex)
            {
                bool pbCancel = false;
                this.ComponentMetaData.FireWarning(0, "Goggle Lookup[CRM_ID=" + Row.AccountGUID + "]", "Error message: " + ex.Message + "|  " + ex.InnerException.Message, String.Empty, 0);
            }
        }
    }
Esempio n. 9
0
 public override void Input0_ProcessInputRow(Input0Buffer Row)
 {
     if (Row.Header.ToString().Trim() == customer)
     {
         Row.SNumber = Convert.ToInt32(Row.Value.Substring(customerPosition, customerLength));
     }
     else if (Row.Header.ToString().Trim() == vendor)
     {
         Row.SNumber = Convert.ToInt32(Row.Value.Substring(vendorPosition, vendorLength));
     }
     else
     {
         Row.SNumber = 0;
     }
 }
    /// <summary>
    /// Country abbreviations
    /// </summary>


    #region Help:  Using Integration Services variables and parameters

    /* To use a variable in this script, first ensure that the variable has been added to
     * either the list contained in the ReadOnlyVariables property or the list contained in
     * the ReadWriteVariables property of this script component, according to whether or not your
     * code needs to write into the variable.  To do so, save this script, close this instance of
     * Visual Studio, and update the ReadOnlyVariables and ReadWriteVariables properties in the
     * Script Transformation Editor window.
     * To use a parameter in this script, follow the same steps. Parameters are always read-only.
     *
     * Example of reading from a variable or parameter:
     *  DateTime startTime = Variables.MyStartTime;
     *
     * Example of writing to a variable:
     *  Variables.myStringVariable = "new value";
     */
    #endregion

    #region Help:  Using Integration Services Connnection Managers

    /* Some types of connection managers can be used in this script component.  See the help topic
     * "Working with Connection Managers Programatically" for details.
     *
     * To use a connection manager in this script, first ensure that the connection manager has
     * been added to either the list of connection managers on the Connection Managers page of the
     * script component editor.  To add the connection manager, save this script, close this instance of
     * Visual Studio, and add the Connection Manager to the list.
     *
     * If the component needs to hold a connection open while processing rows, override the
     * AcquireConnections and ReleaseConnections methods.
     *
     * Example of using an ADO.Net connection manager to acquire a SqlConnection:
     *  object rawConnection = Connections.SalesDB.AcquireConnection(transaction);
     *  SqlConnection salesDBConn = (SqlConnection)rawConnection;
     *
     * Example of using a File connection manager to acquire a file path:
     *  object rawConnection = Connections.Prices_zip.AcquireConnection(transaction);
     *  string filePath = (string)rawConnection;
     *
     * Example of releasing a connection manager:
     *  Connections.SalesDB.ReleaseConnection(rawConnection);
     */
    #endregion

    #region Help:  Firing Integration Services Events

    /* This script component can fire events.
     *
     * Example of firing an error event:
     *  ComponentMetaData.FireError(10, "Process Values", "Bad value", "", 0, out cancel);
     *
     * Example of firing an information event:
     *  ComponentMetaData.FireInformation(10, "Process Values", "Processing has started", "", 0, fireAgain);
     *
     * Example of firing a warning event:
     *  ComponentMetaData.FireWarning(10, "Process Values", "No rows were received", "", 0);
     */
    #endregion



    /// <summary>
    /// This method is called once for every row that passes through the component from Input0.
    ///
    /// Example of reading a value from a column in the the row:
    ///  string zipCode = Row.ZipCode
    ///
    /// Example of writing a value to a column in the row:
    ///  Row.ZipCode = zipCode

    /// </summary>
    /// <param name="Row">The row that is currently passing through the component</param>
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        /// <summary>
        /// Static country name arrays
        /// </summary>


        String locationAsString = Convert.ToString(Row.location);

        Row.DerivedCountry = "TBD";
        Row.DerivedCity    = "TBD";
        if (!(locationAsString.Equals(null)))
        {
            locationAsString = locationAsString.ToLower();
            foreach (string value in Names)
            {
                String check = value.ToLower();
                String city;
                if (locationAsString.Contains(check))
                {
                    Row.DerivedCountry = value;
                    if (locationAsString.Contains(check) && !(locationAsString.Contains(",")))
                    {
                        city = locationAsString.Replace(check, "");
                    }
                    city = locationAsString.Replace(", " + check, "");

                    String checkcity = city.Trim();
                    if (checkcity.Equals(""))
                    {
                        Row.DerivedCity = "TBD";
                    }
                    else
                    {
                        Row.DerivedCity = city;
                    }
                }
            }
        }
        else
        {
            Row.DerivedCity    = "TBD";
            Row.DerivedCountry = "TBD";
        }
    }
    /// <summary>
    /// This method is called once for every row that passes through the component from Input0.
    ///
    /// Example of reading a value from a column in the the row:
    ///  string zipCode = Row.ZipCode
    ///
    /// Example of writing a value to a column in the row:
    ///  Row.ZipCode = zipCode
    /// </summary>
    /// <param name="Row">The row that is currently passing through the component</param>
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        string previousName = "test";

        while (!Row.name.Equals(previousName) && !Row.EndOfRowset())
        {
            previousName = Row.name;
            if (Row.accountid_IsNull)
            {
                Output0Buffer.AddRow();
                Output0Buffer.accountnumber = Row.accountnumber;
                Output0Buffer.name          = Row.name;
                Output0Buffer.ownerid       = Row.ownerid;
                Output0Buffer.ownertype     = Row.ownertype;
            }
            Row.NextRow();
        }
    }
 /// <summary>
 /// This method is called once for every row that passes through the component from Input0.
 ///
 /// Example of reading a value from a column in the the row:
 ///  string zipCode = Row.ZipCode
 ///
 /// Example of writing a value to a column in the row:
 ///  Row.ZipCode = zipCode
 /// </summary>
 /// <param name="Row">The row that is currently passing through the component</param>
 public override void Input0_ProcessInputRow(Input0Buffer Row)
 {
     if (Row.name.EndsWith("(sample)"))
     {
         //ignore
     }
     else if (Row.name.Contains("(sample)"))
     {
         string previousAccountnumber = Row.accountnumber;
         string previousName          = Row.name;
         Guid   previousOwnerid       = Row.ownerid;
         string previousOwnertype     = Row.ownertype;
         Row.NextRow();
         string accountnumber = Row.accountnumber;
         string name          = Row.name;
         Guid   ownerid       = Row.ownerid;
         string ownertype     = Row.ownertype;
         if (previousName.Equals(name))
         {
             //ignore both
         }
         else
         {
             int number  = Int32.Parse(Regex.Match(previousName, @"\d+$").Value);
             int number2 = Int32.Parse(Regex.Match(name, @"\d+$").Value);
             if (number + 1 == number2)
             {
                 //add both
                 addRow(previousAccountnumber, previousName, previousOwnerid, previousOwnertype);
                 addRow(accountnumber, name, ownerid, ownertype);
             }
             else if (number > number2)
             {
                 //add previous
                 addRow(previousAccountnumber, previousName, previousOwnerid, previousOwnertype);
             }
             else
             {
                 //add current
                 addRow(accountnumber, name, ownerid, ownertype);
             }
         }
     }
 }
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        /*
          Add your code here
        */
        bool type1Change = false;
        bool type2Change = false;
        bool fireAgain = true;

        /* Rows directed to Update output */
        if (!compareStrings(Row.Type1Hash, Row.TYPE1HASHDIM))
        {

            /* Debugging Stuff */
            if (Variables.blnDebug)
            {
                ComponentMetaData.FireInformation(0, "Separate Updates and Inserts", "Hash1 changed to: [" + Row.Type1Hash + "] from: [" + Row.TYPE1HASHDIM + "]", "", 0, ref fireAgain);
            }

            type1Change = true;
            Row.DirectRowToType1();

            /* Rows directed to Historical Insert output */
            if (!compareStrings(Row.Type2Hash, Row.TYPE2HASHDIM))
            {
                // Debugging
                if (Variables.blnDebug)
                {
                    ComponentMetaData.FireInformation(0, "Separate Updates and Inserts", "Hash2 changed to: [" + Row.Type2Hash + "] from: [" + Row.TYPE2HASHDIM + "]", "", 0, ref fireAgain);
                }
                type2Change = true;
                Row.DirectRowToType2();
            }

            /* Rows directed to unchanged output */
            if (!type1Change && !type2Change)
            {
                Row.DirectRowToUnchanged();
            }
        }
    }
Esempio n. 14
0
 /// <summary>
 /// This method is called once for every row that passes through the component from Input0.
 ///
 /// Example of reading a value from a column in the the row:
 ///  string zipCode = Row.ZipCode
 ///
 /// Example of writing a value to a column in the row:
 ///  Row.ZipCode = zipCode
 /// </summary>
 /// <param name="Row">The row that is currently passing through the component</param>
 public override void Input0_ProcessInputRow(Input0Buffer Row)
 {
     /*
      * Add your code here
      */
     try
     {
         Row.agency = (Row.agency == "-" ? null : Row.agency);
         Row.associatedprimevendor = (Row.associatedprimevendor == "-" ? null : Row.associatedprimevendor);
         Row.capitalproject        = (Row.capitalproject == "-" ? null : Row.capitalproject);
         Row.contractid            = (Row.contractid == "-" ? null : Row.contractid);
         Row.contractpurpose       = (Row.contractpurpose == "-" ? null : Row.contractpurpose);
         Row.department            = (Row.department == "-" ? null : Row.department);
         Row.documentid            = (Row.documentid == "-" ? null : Row.documentid);
         Row.expensecategory       = (Row.expensecategory == "-" ? null : Row.expensecategory);
         Row.industry               = (Row.industry == "-" ? null : Row.industry);
         Row.mwbecategory           = (Row.mwbecategory == "-" ? null : Row.mwbecategory);
         Row.payeename              = (Row.payeename == "-" ? null : Row.payeename);
         Row.spendingcategory       = (Row.spendingcategory == "-" ? null : Row.spendingcategory);
         Row.subcontractreferenceid = (Row.subcontractreferenceid == "-" ? null : Row.subcontractreferenceid);
         Row.subvendor              = (Row.subvendor == "-" ? null : Row.subvendor);
     }
     catch (Exception ex)
     {
         Row.agency = "ERROR";
         Row.associatedprimevendor = "ERROR";
         Row.capitalproject        = "ERROR";
         Row.contractid            = "ERROR";
         Row.contractpurpose       = "ERROR";
         Row.department            = "ERROR";
         Row.documentid            = "ERROR";
         Row.expensecategory       = "ERROR";
         Row.industry               = "ERROR";
         Row.mwbecategory           = "ERROR";
         Row.payeename              = "ERROR";
         Row.spendingcategory       = "ERROR";
         Row.subcontractreferenceid = "ERROR";
         Row.subvendor              = "ERROR";
     }
 }
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        string userName = getADName(Row.USERID);
        int delimiter = userName.IndexOf(",");
        string firstName, lastName;

        if (delimiter != -1)
        {
            lastName = userName.Substring(0, delimiter);
            firstName = userName.Substring(delimiter + 2);
        }
        else
        {
            lastName = "N/A (Service Account)";
            firstName = "N/A (Service Account)";
        }

        Output0Buffer.AddRow();
        Output0Buffer.USERID = Row.USERID;
        Output0Buffer.FIRSTNAME = firstName;
        Output0Buffer.LASTNAME = lastName;
        Output0Buffer.MODUSERID = Variables.UserName;
        Output0Buffer.MODDATE = Row.MODDATE;
    }
    /* To use a variable in this script, first ensure that the variable has been added to
     * either the list contained in the ReadOnlyVariables property or the list contained in
     * the ReadWriteVariables property of this script component, according to whether or not your
     * code needs to write into the variable.  To do so, save this script, close this instance of
     * Visual Studio, and update the ReadOnlyVariables and ReadWriteVariables properties in the
     * Script Transformation Editor window.
     * To use a parameter in this script, follow the same steps. Parameters are always read-only.
     *
     * Example of reading from a variable or parameter:
     *  DateTime startTime = Variables.MyStartTime;
     *
     * Example of writing to a variable:
     *  Variables.myStringVariable = "new value";
     */
    #endregion

    #region Help:  Using Integration Services Connnection Managers

    /* Some types of connection managers can be used in this script component.  See the help topic
     * "Working with Connection Managers Programatically" for details.
     *
     * To use a connection manager in this script, first ensure that the connection manager has
     * been added to either the list of connection managers on the Connection Managers page of the
     * script component editor.  To add the connection manager, save this script, close this instance of
     * Visual Studio, and add the Connection Manager to the list.
     *
     * If the component needs to hold a connection open while processing rows, override the
     * AcquireConnections and ReleaseConnections methods.
     *
     * Example of using an ADO.Net connection manager to acquire a SqlConnection:
     *  object rawConnection = Connections.SalesDB.AcquireConnection(transaction);
     *  SqlConnection salesDBConn = (SqlConnection)rawConnection;
     *
     * Example of using a File connection manager to acquire a file path:
     *  object rawConnection = Connections.Prices_zip.AcquireConnection(transaction);
     *  string filePath = (string)rawConnection;
     *
     * Example of releasing a connection manager:
     *  Connections.SalesDB.ReleaseConnection(rawConnection);
     */
    #endregion

    #region Help:  Firing Integration Services Events

    /* This script component can fire events.
     *
     * Example of firing an error event:
     *  ComponentMetaData.FireError(10, "Process Values", "Bad value", "", 0, out cancel);
     *
     * Example of firing an information event:
     *  ComponentMetaData.FireInformation(10, "Process Values", "Processing has started", "", 0, fireAgain);
     *
     * Example of firing a warning event:
     *  ComponentMetaData.FireWarning(10, "Process Values", "No rows were received", "", 0);
     */
    #endregion

    /// <summary>
    /// This method is called once for every row that passes through the component from Input0.
    ///
    /// Example of reading a value from a column in the the row:
    ///  string zipCode = Row.ZipCode
    ///
    /// Example of writing a value to a column in the row:
    ///  Row.ZipCode = zipCode
    /// </summary>
    /// <param name="Row">The row that is currently passing through the component</param>
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        string place_id = null;

        try
        {
            //if (Row.AccountGUID == new Guid("826EA96C-ABD3-E811-A96D-000D3AFF2E34"))
            //{
            //    place_id = null;
            //}

            // check for full establishment name and address
            var    xmlDoc  = new XmlDocument();
            string url     = "https://maps.googleapis.com/maps/api/geocode/xml?address={0}&fields=&key={1}";
            string address = Regex.Replace(Row.FullInternalAddress, @"['\/~`\!@#\$%\^&\*\(\)_\-\+=\{\}\[\]\|;:""\<\>,\.\?\\]", "");
            var    wGet    = WebRequest.Create(String.Format(url, address, Variables.webApiKey));
            wGet.Method = WebRequestMethods.Http.Get;
            var response = wGet.GetResponse();
            var status   = ((HttpWebResponse)response).StatusDescription;
            if (status == "OK")
            {
                ReadResponseAddress(Row, xmlDoc, response, true, out place_id);
                response.Close();
            }

            // check only address
            if (place_id == null)
            {
                xmlDoc      = new XmlDocument();
                url         = "https://maps.googleapis.com/maps/api/geocode/xml?address={0}&key={1}";
                address     = Row.InternalAddress1 + " " + Row.InternalAddress2 + " " + Row.InternalCity + " " + Row.InternalPostalCode;
                address     = Regex.Replace(address, @"['\/~`\!@#\$%\^&\*\(\)_\-\+=\{\}\[\]\|;:""\<\>,\.\?\\]", "");
                wGet        = WebRequest.Create(String.Format(url, address, Variables.webApiKey));
                wGet.Method = WebRequestMethods.Http.Get;
                response    = wGet.GetResponse();
                status      = ((HttpWebResponse)response).StatusDescription;

                if (status == "OK")
                {
                    ReadResponseAddress(Row, xmlDoc, response, false, out place_id);
                    response.Close();
                }
            }

            // mark error if no place found
            if (place_id == null || place_id.Trim() == "")
            {
                Row.GoogleID = "error";
            }
        }
        catch (Exception ex)
        {
            this.ComponentMetaData.FireWarning(0, "Goggle Lookup", "Error message: " + ex.Message, String.Empty, 0);
        }

        if (Row.MarketID == 6)
        {
            try
            {
                // LCBO 33 Freeland St, Toronto, ON M5E 1L7
                double oLat = 43.643510, oLng = -79.373114;

                string dLat = !Row.Lat_IsNull ? Row.Lat : null;
                string dLng = !Row.Long_IsNull ? Row.Long : null;

                if (dLat != null && dLng != null)
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    String      url    = String.Format("https://maps.googleapis.com/maps/api/distancematrix/xml?origins={0},{1}&destinations={2},{3}&mode=driving&sensor=false&key={4}", oLat, oLng, dLat, dLng, Variables.webApiKey);
                    var         wGet   = WebRequest.Create(url);
                    wGet.Method = WebRequestMethods.Http.Get;
                    var response = wGet.GetResponse();
                    var status   = ((HttpWebResponse)response).StatusDescription;
                    if (status == "OK")
                    {
                        ReadResponseDistance(Row, xmlDoc, response);
                        response.Close();
                    }
                }
            }
            catch { }
        }
        // google limits 50 requests per second
        Thread.Sleep(20);
    }
Esempio n. 17
0
    /// <summary>
    /// This method is called once for every row that passes through the component from Input0.
    ///
    /// Example of reading a value from a column in the the row:
    ///  string zipCode = Row.ZipCode
    ///
    /// Example of writing a value to a column in the row:
    ///  Row.ZipCode = zipCode
    /// </summary>
    /// <param name="Row">The row that is currently passing through the component</param>
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        /*
         * Add your code here
         */
        string contractid = Row.contractid;

        try
        {
            if (contractid != null && contractid.Length >= 9)
            {
                if (contractid.Substring(0, 3) == "CT1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 3);
                    Row.DeptSTAGINGDerived         = contractid.Substring(3, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(6);
                }
                else if (contractid.Substring(0, 4) == "CTA1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 3) == "DO1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 3);
                    Row.DeptSTAGINGDerived         = contractid.Substring(3, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(6);
                }
                else if (contractid.Substring(0, 4) == "MMA1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 4) == "RCT1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 4) == "PRC2")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 3) == "POD")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 3);
                    Row.DeptSTAGINGDerived         = contractid.Substring(3, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(6);
                }
                else if (contractid.Substring(0, 3) == "POC")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 3);
                    Row.DeptSTAGINGDerived         = contractid.Substring(3, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(6);
                }
                else if (contractid.Substring(0, 4) == "PON1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 4) == "PRM1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 4) == "PCC1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 4) == "CTA2")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 5) == "RTGPF")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 5);
                    Row.DeptSTAGINGDerived         = contractid.Substring(5, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(8);
                }
                else
                {
                    Row.CodeSTAGINGDerived         = "N/A";
                    Row.DeptSTAGINGDerived         = "N/A";
                    Row.RegistrationSTAGINGDerived = "N/A";
                }
            }
            else if (contractid != null && contractid.Length < 9)
            {
                Row.CodeSTAGINGDerived         = "N/A";
                Row.DeptSTAGINGDerived         = "N/A";
                Row.RegistrationSTAGINGDerived = "N/A";
            }
            else if (contractid == null)
            {
                Row.CodeSTAGINGDerived         = null;
                Row.DeptSTAGINGDerived         = null;
                Row.RegistrationSTAGINGDerived = null;
            }
            else
            {
                Row.CodeSTAGINGDerived         = "N/A";
                Row.DeptSTAGINGDerived         = "N/A";
                Row.RegistrationSTAGINGDerived = "N/A";
            }
        }
        catch (Exception ex)
        {
            Row.CodeSTAGINGDerived         = "ERROR: an exception has occured";
            Row.DeptSTAGINGDerived         = "ERROR: an exception has occured";
            Row.RegistrationSTAGINGDerived = "ERROR: an exception has occured";
            //MessageBox.Show(ex.ToString());
        }

        string capital_project = Row.capitalproject;

        try
        {
            if (capital_project != null && capital_project.Length >= 13)
            {
                Row.ProjectAgencySTAGINGDerived = capital_project.Substring(0, 3);
                Row.CapProjSTAGINGDerived       = capital_project.Substring(3, 9).TrimEnd();
                Row.OccSTAGINGDerived           = capital_project.Substring(Math.Max(0, capital_project.Length - 3));
            }
            else if (capital_project != null && capital_project.Length < 13)
            {
                Row.ProjectAgencySTAGINGDerived = "N/A";
                Row.CapProjSTAGINGDerived       = "N/A";
                Row.OccSTAGINGDerived           = "N/A";
            }
            else if (capital_project == null)
            {
                Row.ProjectAgencySTAGINGDerived = null;
                Row.CapProjSTAGINGDerived       = null;
                Row.OccSTAGINGDerived           = null;
            }
            else
            {
                Row.ProjectAgencySTAGINGDerived = "N/A";
                Row.CapProjSTAGINGDerived       = "N/A";
                Row.OccSTAGINGDerived           = "N/A";
            }
        }
        catch (Exception ex)
        {
            Row.ProjectAgencySTAGINGDerived = "ERROR: an exception has occured";
            Row.CapProjSTAGINGDerived       = "ERROR: an exception has occured";
            Row.OccSTAGINGDerived           = "ERROR: an exception has occured";
        }
    }
    private void ReadResponseAddress(Input0Buffer Row, XmlDocument xmlDoc, WebResponse response, bool getDetails, out string place_id)
    {
        place_id = null;
        // Open the stream using a StreamReader for easy access.
        StreamReader reader = new StreamReader(response.GetResponseStream());

        // Read the content fully up to the end.
        string responseFromServer = reader.ReadToEnd();

        // Clean up the streams.
        reader.Close();

        xmlDoc.LoadXml(responseFromServer);

        string sts = xmlDoc.DocumentElement.SelectSingleNode("status").InnerText;

        if (sts != "ZERO_RESULTS")
        {
            try
            {
                place_id = xmlDoc.DocumentElement.SelectSingleNode("/GeocodeResponse/result/place_id").InnerText;

                if (place_id != null)
                {
                    string streetNumber = null;
                    string streetName   = null;
                    string subpremise   = null;
                    string city         = null;
                    string province     = null;
                    string country      = null;
                    string postal       = null;
                    string lat          = null;
                    string lng          = null;
                    string icon         = null;
                    string phone;
                    string webUrl;
                    string name = "Internal Address";

                    var address = xmlDoc.DocumentElement.SelectNodes("/GeocodeResponse/result/address_component");
                    foreach (XmlNode node in address)
                    {
                        string type = node.SelectSingleNode("type").InnerText;
                        switch (type)
                        {
                        case "street_number":
                            streetNumber = node.SelectSingleNode("long_name").InnerText;
                            break;

                        case "subpremise":
                            subpremise = node.SelectSingleNode("long_name").InnerText;
                            break;

                        case "route":
                            streetName = node.SelectSingleNode("long_name").InnerText;
                            break;

                        case "locality":
                            city = node.SelectSingleNode("long_name").InnerText;
                            break;

                        case "administrative_area_level_1":
                            province = node.SelectSingleNode("short_name").InnerText;
                            break;

                        case "country":
                            country = node.SelectSingleNode("long_name").InnerText;
                            break;

                        case "postal_code":
                            postal = node.SelectSingleNode("long_name").InnerText;
                            break;
                        }
                    }
                    lat = xmlDoc.DocumentElement.SelectSingleNode("/GeocodeResponse/result/geometry/location/lat").InnerText;
                    lng = xmlDoc.DocumentElement.SelectSingleNode("/GeocodeResponse/result/geometry/location/lng").InnerText;

                    getPlaceDetails(place_id, out name, out phone, out webUrl, out icon);
                    if (getDetails)
                    {
                        Row.Phone   = phone;
                        Row.WebSite = webUrl;
                    }

                    Row.Lat      = lat;
                    Row.Long     = lng;
                    Row.Address1 = streetNumber + " " + streetName;
                    if (subpremise != null)
                    {
                        Row.Address2 = "#" + subpremise;
                    }
                    Row.City     = city;
                    Row.Province = province;
                    Row.Country  = country;
                    Row.Postal   = postal;
                    Row.Name     = name;
                    Row.Icon     = icon;

                    Row.GoogleID = place_id;
                }
            }
            catch (Exception ex)
            {
                bool pbCancel = false;
                this.ComponentMetaData.FireError(0, "Goggle Lookup[CRM_ID=" + Row.AccountGUID + "]", "Error message: " + ex.Message + "|  " + ex.InnerException.Message, String.Empty, 0, out pbCancel);
            }
        }
    }
    /// <summary>
    /// This method is called once for every row that passes through the component from Input0.
    ///
    /// Example of reading a value from a column in the the row:
    ///  string zipCode = Row.ZipCode
    ///
    /// Example of writing a value to a column in the row:
    ///  Row.ZipCode = zipCode
    /// </summary>
    /// <param name="Row">The row that is currently passing through the component</param>
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        /*
         * Add your code here
         */
        string contractid = Row.primecontractidSTAGING;

        try
        {
            if (contractid != null && contractid.Length >= 9)
            {
                if (contractid.Substring(0, 3) == "CT1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 3);
                    Row.DeptSTAGINGDerived         = contractid.Substring(3, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(6);
                }
                else if (contractid.Substring(0, 4) == "CTA1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 3) == "DO1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 3);
                    Row.DeptSTAGINGDerived         = contractid.Substring(3, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(6);
                }
                else if (contractid.Substring(0, 4) == "MMA1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 4) == "RCT1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 4) == "PRC2")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 3) == "POD")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 3);
                    Row.DeptSTAGINGDerived         = contractid.Substring(3, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(6);
                }
                else if (contractid.Substring(0, 3) == "POC")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 3);
                    Row.DeptSTAGINGDerived         = contractid.Substring(3, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(6);
                }
                else if (contractid.Substring(0, 4) == "PON1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 4) == "PRM1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 4) == "PCC1")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 4) == "CTA2")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 4);
                    Row.DeptSTAGINGDerived         = contractid.Substring(4, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(7);
                }
                else if (contractid.Substring(0, 5) == "RTGPF")
                {
                    Row.CodeSTAGINGDerived         = contractid.Substring(0, 5);
                    Row.DeptSTAGINGDerived         = contractid.Substring(5, 3);
                    Row.RegistrationSTAGINGDerived = contractid.Substring(8);
                }
                else
                {
                    Row.CodeSTAGINGDerived         = "N/A";
                    Row.DeptSTAGINGDerived         = "N/A";
                    Row.RegistrationSTAGINGDerived = "N/A";
                }
            }
            else if (contractid != null && contractid.Length < 9)
            {
                Row.CodeSTAGINGDerived         = "N/A";
                Row.DeptSTAGINGDerived         = "N/A";
                Row.RegistrationSTAGINGDerived = "N/A";
            }
            else if (contractid == null)
            {
                Row.CodeSTAGINGDerived         = null;
                Row.DeptSTAGINGDerived         = null;
                Row.RegistrationSTAGINGDerived = null;
            }
            else
            {
                Row.CodeSTAGINGDerived         = "N/A";
                Row.DeptSTAGINGDerived         = "N/A";
                Row.RegistrationSTAGINGDerived = "N/A";
            }
        }
        catch (Exception ex)
        {
            Row.CodeSTAGINGDerived         = "ERROR: an exception has occured";
            Row.DeptSTAGINGDerived         = "ERROR: an exception has occured";
            Row.RegistrationSTAGINGDerived = "ERROR: an exception has occured";
            //MessageBox.Show(ex.ToString());
        }
    }
Esempio n. 20
0
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        var badData = new List<object>(_listOfColumns.Count);
        typeof(Input0Buffer).GetProperties().Where(p => _listOfColumnsMod.Contains(p.Name)).ToList().ForEach(y => badData.Add(GetRowValue(y, Row)));

        _rejectedRows.Add(badData.ToArray());
    }
Esempio n. 21
0
    public object GetRowValue(PropertyInfo pi, Input0Buffer row)
    {
        var piCheckNull = (bool)typeof(Input0Buffer).GetProperty(pi.Name + "_IsNull").GetValue(row, null);

        if (piCheckNull)
            return "-";
        else
            return pi.GetValue(row, null);
    }
Esempio n. 22
0
 /// <summary>
 /// This method is called once for every row that passes through the component from Input0.
 ///
 /// Example of reading a value from a column in the the row:
 ///  string zipCode = Row.ZipCode
 ///
 /// Example of writing a value to a column in the row:
 ///  Row.ZipCode = zipCode
 /// </summary>
 /// <param name="Row">The row that is currently passing through the component</param>
 public override void Input0_ProcessInputRow(Input0Buffer Row)
 {
     /*
      * Add your code here
      */
     try
     {
         Row.documentcodeSTAGING               = (Row.documentcodeSTAGING == "-" ? null : Row.documentcodeSTAGING);
         Row.primecontractidSTAGING            = (Row.primecontractidSTAGING == "-" ? null : Row.primecontractidSTAGING);
         Row.contractincludessubvendorsSTAGING = (Row.contractincludessubvendorsSTAGING == "-" ? null : Row.contractincludessubvendorsSTAGING);
         Row.vendorrecordtypeSTAGING           = (Row.vendorrecordtypeSTAGING == "-" ? null : Row.vendorrecordtypeSTAGING);
         Row.primevendorSTAGING                   = (Row.primevendorSTAGING == "-" ? null : Row.primevendorSTAGING);
         Row.primevendormwbecategorySTAGING       = (Row.primevendormwbecategorySTAGING == "-" ? null : Row.primevendormwbecategorySTAGING);
         Row.primecontractpurposeSTAGING          = (Row.primecontractpurposeSTAGING == "-" ? null : Row.primecontractpurposeSTAGING);
         Row.primecontractcurrentamountSTAGING    = (Row.primecontractcurrentamountSTAGING == "-" ? null : Row.primecontractcurrentamountSTAGING);
         Row.primecontractoriginalamountSTAGING   = (Row.primecontractoriginalamountSTAGING == "-" ? null : Row.primecontractoriginalamountSTAGING);
         Row.primevendorspenttodateSTAGING        = (Row.primevendorspenttodateSTAGING == "-" ? null : Row.primevendorspenttodateSTAGING);
         Row.primecontractstartdateSTAGING        = (Row.primecontractstartdateSTAGING == "-" ? null : Row.primecontractstartdateSTAGING);
         Row.primecontractenddateSTAGING          = (Row.primecontractenddateSTAGING == "-" ? null : Row.primecontractenddateSTAGING);
         Row.primecontractregistrationdateSTAGING = (Row.primecontractregistrationdateSTAGING == "-" ? null : Row.primecontractregistrationdateSTAGING);
         Row.primecontractingagencySTAGING        = (Row.primecontractingagencySTAGING == "-" ? null : Row.primecontractingagencySTAGING);
         Row.primecontractversionSTAGING          = (Row.primecontractversionSTAGING == "-" ? null : Row.primecontractversionSTAGING);
         Row.parentcontractidSTAGING              = (Row.parentcontractidSTAGING == "-" ? null : Row.parentcontractidSTAGING);
         Row.primecontracttypeSTAGING             = (Row.primecontracttypeSTAGING == "-" ? null : Row.primecontracttypeSTAGING);
         Row.primecontractawardmethodSTAGING      = (Row.primecontractawardmethodSTAGING == "-" ? null : Row.primecontractawardmethodSTAGING);
         Row.primecontractexpensecategorySTAGING  = (Row.primecontractexpensecategorySTAGING == "-" ? null : Row.primecontractexpensecategorySTAGING);
         Row.primecontractindustrySTAGING         = (Row.primecontractindustrySTAGING == "-" ? null : Row.primecontractindustrySTAGING);
         Row.primecontractpinSTAGING              = (Row.primecontractpinSTAGING == "-" ? null : Row.primecontractpinSTAGING);
         Row.primecontractaptpinSTAGING           = (Row.primecontractaptpinSTAGING == "-" ? null : Row.primecontractaptpinSTAGING);
         Row.subvendorSTAGING                 = (Row.subvendorSTAGING == "-" ? null : Row.subvendorSTAGING);
         Row.subvendormwbecategorySTAGING     = (Row.subvendormwbecategorySTAGING == "-" ? null : Row.subvendormwbecategorySTAGING);
         Row.subcontractpurposeSTAGING        = (Row.subcontractpurposeSTAGING == "-" ? null : Row.subcontractpurposeSTAGING);
         Row.subvendorstatusinpipSTAGING      = (Row.subvendorstatusinpipSTAGING == "-" ? null : Row.subvendorstatusinpipSTAGING);
         Row.subcontractindustrySTAGING       = (Row.subcontractindustrySTAGING == "-" ? null : Row.subcontractindustrySTAGING);
         Row.subcontractcurrentamountSTAGING  = (Row.subcontractcurrentamountSTAGING == "-" ? null : Row.subcontractcurrentamountSTAGING);
         Row.subcontractoriginalamountSTAGING = (Row.subcontractoriginalamountSTAGING == "-" ? null : Row.subcontractoriginalamountSTAGING);
         Row.subvendorpaidtodateSTAGING       = (Row.subvendorpaidtodateSTAGING == "-" ? null : Row.subvendorpaidtodateSTAGING);
         Row.subcontractstartdateSTAGING      = (Row.subcontractstartdateSTAGING == "-" ? null : Row.subcontractstartdateSTAGING);
         Row.subcontractenddateSTAGING        = (Row.subcontractenddateSTAGING == "-" ? null : Row.subcontractenddateSTAGING);
         Row.subcontractreferenceidSTAGING    = (Row.subcontractreferenceidSTAGING == "-" ? null : Row.subcontractreferenceidSTAGING);
     }
     catch (Exception ex)
     {
         Row.documentcodeSTAGING               = "ERROR";
         Row.primecontractidSTAGING            = "ERROR";
         Row.contractincludessubvendorsSTAGING = "ERROR";
         Row.vendorrecordtypeSTAGING           = "ERROR";
         Row.primevendorSTAGING                   = "ERROR";
         Row.primevendormwbecategorySTAGING       = "ERROR";
         Row.primecontractpurposeSTAGING          = "ERROR";
         Row.primecontractcurrentamountSTAGING    = "ERROR";
         Row.primecontractoriginalamountSTAGING   = "ERROR";
         Row.primevendorspenttodateSTAGING        = "ERROR";
         Row.primecontractstartdateSTAGING        = "ERROR";
         Row.primecontractenddateSTAGING          = "ERROR";
         Row.primecontractregistrationdateSTAGING = "ERROR";
         Row.primecontractingagencySTAGING        = "ERROR";
         Row.primecontractversionSTAGING          = "ERROR";
         Row.parentcontractidSTAGING              = "ERROR";
         Row.primecontracttypeSTAGING             = "ERROR";
         Row.primecontractawardmethodSTAGING      = "ERROR";
         Row.primecontractexpensecategorySTAGING  = "ERROR";
         Row.primecontractindustrySTAGING         = "ERROR";
         Row.primecontractpinSTAGING              = "ERROR";
         Row.primecontractaptpinSTAGING           = "ERROR";
         Row.subvendorSTAGING                 = "ERROR";
         Row.subvendormwbecategorySTAGING     = "ERROR";
         Row.subcontractpurposeSTAGING        = "ERROR";
         Row.subvendorstatusinpipSTAGING      = "ERROR";
         Row.subcontractindustrySTAGING       = "ERROR";
         Row.subcontractcurrentamountSTAGING  = "ERROR";
         Row.subcontractoriginalamountSTAGING = "ERROR";
         Row.subvendorpaidtodateSTAGING       = "ERROR";
         Row.subcontractstartdateSTAGING      = "ERROR";
         Row.subcontractenddateSTAGING        = "ERROR";
         Row.subcontractreferenceidSTAGING    = "ERROR";
     }
 }
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        // reset before processing each row
        aYear         = "0000";
        aMonth        = "00";
        aDay          = "00";
        bYear         = "0000";
        bMonth        = "00";
        bDay          = "00";
        aDayTrans     = "00";
        bDayTrans     = "00";
        aMonthTrans   = "00";
        bMonthTrans   = "00";
        aYearTrans    = "0000";
        bYearTrans    = "0000";
        aYearNum      = 0;
        bYearNum      = 0;
        aYearTransNum = 0;
        bYearTransNum = 0;
        score         = 0;


        // split up the first date
        if (Row.PADOB.Length > 0)
        {
            aYear         = Row.PADOB.Split('-')[0];
            aMonth        = Row.PADOB.Split('-')[1];
            aDay          = Row.PADOB.Split('-')[2];
            aDayTrans     = Reverse(aDay);
            aMonthTrans   = Reverse(aMonth);
            aYearTrans    = Row.PADOB.Substring(0, 2) + Row.PADOB.Substring(3, 1) + Row.PADOB.Substring(2, 1);
            aYearNum      = Int32.Parse(aYear);
            aYearTransNum = Int32.Parse(aYearTrans);
        }

        // split up the second date
        if (Row.DDDOB.Length > 0)
        {
            bYear         = Row.DDDOB.Split('-')[0];
            bMonth        = Row.DDDOB.Split('-')[1];
            bDay          = Row.DDDOB.Split('-')[2];
            bDayTrans     = Reverse(bday);
            bMonthTrans   = Reverse(bMonth);
            bYearTrans    = Row.DDDOB.Substring(0, 2) + Row.DDDOB.Substring(3, 1) + Row.DDDOB.Substring(2, 1);
            bYearNum      = Int32.Parse(bYear);
            bYearTransNum = Int32.Parse(bYearTrans);
        }


        //determine score
        if (Row.PADOB == Row.DDDOB) //a
        {
            score = 100;
        }
        else if ((aYear == "0000") || (bYear == "0000")) //b
        {
            score = 80;
        }
        else if (((aMonth == bMonth) && ((aDay == bDay) || (aDay == "00") || (bDay == "00"))) || ((aDay == bDay) && ((aMonth == bMonth) || (aMonth == "00") || (bMonth == "00")))) //c
        {
            if ((Math.Abs(aYearNum - bYearNum)) <= yearRanges[1])
            {
                score = 75;
            }
            else if (aYearTrans == bYearTrans)
            {
                score = 40;
            }
            else if ((Math.Abs(aYearNum - bYearNum)) <= yearRanges[2])
            {
                score = 55;
            }
            else if ((Math.Abs(aYearTransNum - bYearTransNum)) <= yearRanges[2])
            {
                score = 30;
            }
            else if ((Math.Abs(aYearNum - bYearNum)) <= yearRanges[3])
            {
                score = 10;
            }
        }
        else if ((aYear == bYear) && ((aDay == bDay) || (aDay == "00") || (bDay == "00")))
        {
            if (aMonthTrans == bMonthTrans)
            {
                score = 40;
            }
            else
            {
                score = 60;
            }
        }
        else if ((aYear == bYear) && ((aMonth == bMonth) || (aMonth == "00") || (bMonth == "00")))
        {
            if (aDayTrans == bDayTrans)
            {
                score = 70;
            }
            else
            {
                score = 60;
            }
        }
        else if ((aMonth == bDay) || (bMonth == aDay))
        {
            if (aYear == bYear)
            {
                score = 70;
            }
            else if ((Math.Abs(aYearNum - bYearNum)) <= yearRanges[2])
            {
                score = 30;
            }
        }
        else if (aYear == bYear)
        {
            score = 50;
        }
        else if ((Math.Abs(aYearNum - bYearNum)) <= yearRanges[1])
        {
            score = 30;
        }

        Row.dobScore = score;
    }
Esempio n. 24
0
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        List <string> firstSet     = new List <string>();
        List <string> secondSet    = new List <string>();
        List <string> qGrams       = new List <string>();
        List <string> firstQGrams  = new List <string>();
        List <string> secondQGrams = new List <string>();
        var           firstScore   = 0;
        var           secondScore  = 0;

        //add inputput strings to a list
        firstSet.Add(Row.fNameA);
        firstSet.Add(Row.gNameA);
        secondSet.Add(Row.fNameB);
        secondSet.Add(Row.gNameB);

        for (var lnx = 0; lnx < firstSet.Count; lnx++)
        {
            for (var inx = 0; inx < firstSet[lnx].Length - 1; inx++)
            {
                qGrams.Add(firstSet[lnx].Substring(inx, qGramSize));
                firstQGrams.Add(firstSet[lnx].Substring(inx, qGramSize));
            }
        }

        for (var lnx = 0; lnx < secondSet.Count; lnx++)
        {
            for (var inx = 0; inx < secondSet[lnx].Length - 1; inx++)
            {
                qGrams.Add(secondSet[lnx].Substring(inx, qGramSize));
                secondQGrams.Add(secondSet[lnx].Substring(inx, qGramSize));
            }
        }


        qGrams       = qGrams.Distinct().ToList();
        firstQGrams  = firstQGrams.Distinct().ToList();
        secondQGrams = secondQGrams.Distinct().ToList();


        // compare set 1
        for (var knx = 0; knx < qGrams.Count; knx++)
        {
            for (var bnx = 0; bnx < firstQGrams.Count; bnx++)
            {
                if (qGrams[knx] == firstQGrams[bnx])
                {
                    firstScore++;
                }
            }
        }

        // compare set 2
        for (var knx = 0; knx < qGrams.Count; knx++)
        {
            for (var bnx = 0; bnx < secondQGrams.Count; bnx++)
            {
                if (qGrams[knx] == secondQGrams[bnx])
                {
                    secondScore++;
                }
            }
        }

        Row.score = (((double)firstScore + secondScore) / (qGrams.Count * 2)) * 100;
    }