Skip to content

Instantly share code, notes, and snippets.

View alcabanillas-engh's full-sized avatar

Alvaro Cabanillas alcabanillas-engh

View GitHub Profile
#Note: did not work with SQL Server, will work with Oracle, MySQL
#require AR
require 'rubygems'
require 'active_record'
# connect to the Database
ActiveRecord:: Base.establish_connection(
:adapter => "oracle",
:host => "10.0.1.22",
:database => "xe",
#Oracle Config Example for the MRI/ActiveRecord
ActiveRecord:: Base.establish_connection(
:adapter => "oracle",
:database => "10.0.1.22/se",
:username => "prep",
:password => "prep"
)
#Oracle config example for JRuby/ActiveRecord-JDBC
16:11:21 T:2691018656 M:204390400 NOTICE: Mapping drive Z to /tmp/boxee
16:11:21 T:2691018656 M:204390400 NOTICE: Mapping drive Q to /Applications/Boxee.app/Contents/Resources/Boxee
16:11:21 T:2691018656 M:204386304 NOTICE: Mapping drive H to /Users/jsgoecke
16:11:21 T:2691018656 M:204386304 NOTICE: Mapping drive T to /Users/jsgoecke/Library/Application Support/BOXEE/UserData
16:11:21 T:2691018656 M:204386304 NOTICE: Mapping drive U to /Users/jsgoecke/Library/Application Support/BOXEE/UserData
16:11:21 T:2691018656 M:204374016 NOTICE: -----------------------------------------------------------------------
16:11:21 T:2691018656 M:204374016 NOTICE: Starting XBMC, Platform: Mac OS X. Built on Nov 10 2008
16:11:21 T:2691018656 M:204369920 NOTICE: Q is mapped to: /Applications/Boxee.app/Contents/Resources/Boxee
16:11:21 T:2691018656 M:204369920 NOTICE: The executable running is: /Applications/Boxee.app/Contents/MacOS/Boxee
16:11:21 T:2691018656 M:204365824 NOTICE: Log File is located: /Users/js
<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<n1:set_entry xmlns:n1="http://www.sugarcrm.com/sugarcrm"
env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<session xsi:type="xsd:string">6f3fefe702be584ddcf92d8c4555f1ff</session>
<module_name xsi:type="xsd:string">Leads</module_name>
<name_value_list n2:arrayType="n1:name_value[17]"
#Build the record to be inserted from the CSV row
def build_lead lead
address = build_address(lead)
description = build_description(lead)
built_lead = [
{ :name => "lead_status", :value => $config["global_settings"]["lead_status"] },
{ :name => "lead_source", :value => $config["global_settings"]["lead_source"] },
{ :name => "lead_source_description", :value => $config["global_settings"]["lead_source_description"] },
{ :name => "assigned_to", :value => $config["global_settings"]["assigned_to"] },
{ :name => "first_name", :value => lead[$config["field_associations"]["first_name"]] },
#Require the library for SOAP
require 'rubygems'
require 'configatron'
require 'soap/wsdlDriver'
require 'digest/md5'
require 'active_support'
#Build our credentials hash to be passed to the SOAP factory and converted to XML to pass to Sugar CRM
credentials = { "user_name" => $config["global_settings"]["username"],
"password" => Digest::MD5.hexdigest($config["global_settings"]["password"]) }
#Build the record to be inserted from the CSV row
def build_lead lead
address = build_address(lead)
description = build_description(lead)
built_lead = []
built_lead = { :name_value_list =>
{ :lead_status => $config["global_settings"]["lead_status"],
:lead_source => $config["global_settings"]["lead_source"],
:lead_source_description => $config["global_settings"]["lead_source_description"],
:assigned_to => $config["global_settings"]["assigned_to"],
<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<n1:set_entry xmlns:n1="http://www.sugarcrm.com/sugarcrm"
env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<session xsi:type="xsd:string">9b007dfdb6e9efa717af86f38a65ea73</session>
<module_name xsi:type="xsd:string">Leads</module_name>
<name_value_list n2:arrayType="n1:name_value[33]"
#If 11-digit numbers simply pass with a 9 pre-pended to allow for 1 + 10 digits from the api request
if $config["allow_11_digit_dialing"] == true && phone_number.to_s.length == 11
phone_number = $config["dial_prefix"].to_s + phone_number.to_s
else
#See if the number is on the exception list and then either add only a dial prefix if it is
#or a long distance prefix if it is not
if phone_number.to_s.match($config["exception_list"])
phone_number = $config["dial_prefix"].to_s + phone_number.to_s
else
phone_number = $config["dial_prefix"].to_s + $config["long_distance_prefix"].to_s + phone_number.to_s
new_email = TMail::Mail.new
new_email.to = $config["smtp_config"]["to_address"]
new_email.subject = $config["smtp_config"]["subject"]
new_email.date = Time.now
new_email.set_content_type("multipart", "mixed")
new_email.mime_version = "1.0"
new_email.set_content_type("image", "tiff", "name" => "#{filename}.tiff")
new_email.header["Content-Disposition"] = "attachment; filename=" + "#{filename}.tiff"
new_email.body = fetched_email.body
#new_email.transfer_encoding = '7bit'