From c2095b4a616431007e0ac6a363cffa6de37b50f5 Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 15 Nov 2017 17:55:51 +0630 Subject: [PATCH 01/14] adding license activation --- app/controllers/install_controller.rb | 8 ++- app/models/license.rb | 82 +++++++++++++++------------ config/routes.rb | 2 +- 3 files changed, 55 insertions(+), 37 deletions(-) diff --git a/app/controllers/install_controller.rb b/app/controllers/install_controller.rb index cf16adfe..9b4d88c2 100755 --- a/app/controllers/install_controller.rb +++ b/app/controllers/install_controller.rb @@ -2,13 +2,19 @@ class InstallController < BaseController def index end - def create + def activate restaurant = params[:restaurant_name] license_key = params[:license_key] admin_user = params[:admin_user] admin_password = params[:admin_password] + db_user = params[:db_user] + db_password = params[:db_password] + + end + + def lookup_domain if request.subdomain.present? && request.subdomain != "www" @license = current_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase) diff --git a/app/models/license.rb b/app/models/license.rb index 31403038..eb81c142 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -80,6 +80,7 @@ class License if has_license puts "VERIFIED" end + end # if cache_license.nil? # ##change the d/e key @@ -119,26 +120,31 @@ class License # return false end - def detail - response = self.class.get("/subdomain", @options) - @license = response.parsed_response + # def detail + # response = self.class.get("/subdomain", @options) + # @license = response.parsed_response - Rails.logger.debug "License - " + response.parsed_response.to_s + # Rails.logger.debug "License - " + response.parsed_response.to_s - if (@license["status"] == true) - assign() + # if (@license["status"] == true) + # assign() - return true - end + # return true + # end + + # return false + # end + + # License Activation + def license_activate - return false end def verify_license api_token = read_license("api_token") - @options = { query: {lookup_type: "application", token: api_token} } - response = self.class.get("/verify", @options) + @params = { query: {lookup_type: "application", token: api_token} } + response = self.class.get("/verify", @params) @varified = response.parsed_response Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s @@ -152,37 +158,36 @@ class License return false end - def check_remote_license(license_key) - # @options = { query: {device: "cloud", key: license_key, skey: @secret, token: Rails.application.secrets.provision_key} } - @options = { query: {lookup_type: "application", encrypted_key: @secret, token: SECRETS_CONFIG['provision_key']} } - response = self.class.get("/license", @options) + # def check_remote_license(license_key) + # # @options = { query: {device: "cloud", key: license_key, skey: @secret, token: Rails.application.secrets.provision_key} } + # @options = { query: {lookup_type: "application", encrypted_key: @secret, token: SECRETS_CONFIG['provision_key']} } + # response = self.class.get("/license", @options) - @license = response.parsed_response + # @license = response.parsed_response - Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s - if (@license["status"]) - assign() - end - return @license["status"] + # Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s + # if (@license["status"]) + # assign() + # end + # return @license["status"] + # end - end + # def verify_by_api_token(api_token) + # @options = { query: {device: "SX", api_token: api_token, skey: @secret, token: SECRETS_CONFIG['provision_key']} } + # response = self.class.get("/verify_token", @options) - def verify_by_api_token(api_token) - @options = { query: {device: "SX", api_token: api_token, skey: @secret, token: SECRETS_CONFIG['provision_key']} } - response = self.class.get("/verify", @options) + # @license = response.parsed_response - @license = response.parsed_response + # Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s + # if (@license["status"]) + # assign() + # end - Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s - if (@license["status"]) - assign() - end - - return @license["status"] - end + # return @license["status"] + # end #Load License is remove from the cloud license because - this license is must be validated against subdmain instead of license.data from file. - + # Check License expired date from PROVISION SERVER def check_expired(renewal_date) if (renewal_date < Date.today) return true @@ -191,6 +196,7 @@ class License end end + # Check License File exists def self.check_license_file return File.exist?("config/license.yml") end @@ -209,6 +215,13 @@ class License end private + + # Delete License File + def delete_license_file + File.delete("config/license.yml") if File.exist?("config/license.yml") + end + + # Assign db info for Cloud def assign # self.name = @license["name"] # self.address_1 = @license["address_1"] @@ -228,7 +241,6 @@ class License ## self.plan_activation_date = Date.strptime(@license["plan_activation_date"], "%Y-%m-%d") ## self.plan_next_renewal_date = Date.strptime(@license["plan_next_renewal_date"], "%Y-%m-%d") - # self.plan_max_products = @license["plan_max_products"].to_i # self.plan_max_customers = @license["plan_max_customers"].to_i # self.plan_active_connections = @license["plan_active_connections"].to_i diff --git a/config/routes.rb b/config/routes.rb index 64f68262..a44cc1c4 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,7 +11,7 @@ scope "(:locale)", locale: /en|mm/ do #--------- SmartSales Installation ------------# get 'install' => 'install#index' - post 'install' => 'install#create' + post 'install' => 'install#activate' #--------- Login/Authentication ------------# get 'auth/:emp_id' => 'home#show', as: :emp_login From b1f98df4e07c10ead078dc9fa3f4a7747acc034a Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 15 Nov 2017 19:10:56 +0630 Subject: [PATCH 02/14] add activation in license --- app/controllers/install_controller.rb | 9 +++-- app/models/license.rb | 50 ++++++++++++++++++++++----- config/license.yml | 2 -- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/app/controllers/install_controller.rb b/app/controllers/install_controller.rb index 9b4d88c2..ab321481 100755 --- a/app/controllers/install_controller.rb +++ b/app/controllers/install_controller.rb @@ -10,11 +10,14 @@ class InstallController < BaseController db_user = params[:db_user] db_password = params[:db_password] - + # Export for Key + aes = MyAesCrypt.new + aes_key, aes_iv = aes.export_key(lookup) + + @license = License.new(ENV["SX_PROVISION_URL"]) + @license.license_activate(aes_key, aes_iv, license_key) end - - def lookup_domain if request.subdomain.present? && request.subdomain != "www" @license = current_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase) diff --git a/app/models/license.rb b/app/models/license.rb index eb81c142..182edecd 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -23,13 +23,13 @@ class License # @params = { query: { device: "SX", token: SECRETS_CONFIG['provision_key'] } } end - def shop_code - if ( self.subdomain.length > 3) - return self.subdomain[0,3].upcase - else - return self.subdomain.upcase - end - end + # def shop_code + # if ( self.subdomain.length > 3) + # return self.subdomain[0,3].upcase + # else + # return self.subdomain.upcase + # end + # end def detail_with_local_cache(lookup, key, iv) ##Check from local redis - if available load local otherwise get from remote @@ -137,8 +137,18 @@ class License # end # License Activation - def license_activate + def license_activate (key, iv, license_key) + @params = { query: { lookup_type: self.server_mode, encrypted_key: key, iv_key: iv, license_key: license_key } } + response = self.class.get("/activate", @params) + @activate = response.parsed_response + Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s + + if (@activate["status"]) + return create_license_file(@activate) + else + response = { "status": false, "message": "Activation Failed! Please contact code2lab call center!"} + end end def verify_license @@ -216,6 +226,30 @@ class License private + # License File Creation + def create_license_file(response_data) + if check_license_file + delete_license_file + end + + begin + # Licese File Creation + f = File.open("config/license.yml", "w") + f.write("name: #{response_data['name']}\n") + f.write("shopname: #{response_data['shopname']}\n") + f.write("dbhost: #{response_data['dbhost']}\n") + f.write("dbschema: #{response_data['dbschema']}\n") + f.write("dbusername: #{response_data['dbusername']}\n") + f.write("dbpassword: #{response_data['dbpassword']}\n") + f.write("api_token: #{response_data['api_token']}\n") + f.write("app_token: #{response_data['app_token']}\n") + f.close + rescue IOError + response = { "status": false, "message": "Can't create license file. Please contact code2lab call center!"} + end + response = { "status": true, "message": "License created"} + end + # Delete License File def delete_license_file File.delete("config/license.yml") if File.exist?("config/license.yml") diff --git a/config/license.yml b/config/license.yml index f98a6e81..e0f6bf7d 100644 --- a/config/license.yml +++ b/config/license.yml @@ -1,5 +1,4 @@ development: - server_mode: cloud license_key: IAAXHpbSWAfvlWGYpDoXvZdmuRABNGk @@ -9,6 +8,5 @@ test: # Do not keep production secrets in the repository, # instead read values from the environment. production: - server_mode: cloud license_key: IAAXHpbSWAfvlWGYpDoXvZdmuRABNGk From 178b3484bed6704b558a566b9404ffa6f1d59d87 Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 16 Nov 2017 16:13:26 +0630 Subject: [PATCH 03/14] added license --- app/controllers/application_controller.rb | 2 +- app/controllers/install_controller.rb | 71 +++--- app/models/license.rb | 79 ++++++- app/views/install/_form.html.erb | 12 +- app/views/layouts/login_dashboard.html.erb | 2 +- config/initializers/license.rb | 8 +- config/license.yml | 12 - config/routes.rb | 6 +- config/secrets.yml | 2 +- db/sym_master.sql | 254 +++++++++++---------- 10 files changed, 264 insertions(+), 184 deletions(-) delete mode 100644 config/license.yml diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 83222004..2163d885 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -110,7 +110,7 @@ class ApplicationController < ActionController::Base if License.check_license_file return true else - redirect_to install_path + redirect_to activate_path end end end diff --git a/app/controllers/install_controller.rb b/app/controllers/install_controller.rb index ab321481..870a10e0 100755 --- a/app/controllers/install_controller.rb +++ b/app/controllers/install_controller.rb @@ -1,12 +1,16 @@ class InstallController < BaseController + before_action :check_license + def index end def activate restaurant = params[:restaurant_name] license_key = params[:license_key] - admin_user = params[:admin_user] - admin_password = params[:admin_password] + # admin_user = params[:admin_user] + # admin_password = params[:admin_password] + db_host = params[:db_host] + db_schema = params[:db_schema] db_user = params[:db_user] db_password = params[:db_password] @@ -15,37 +19,48 @@ class InstallController < BaseController aes_key, aes_iv = aes.export_key(lookup) @license = License.new(ENV["SX_PROVISION_URL"]) - @license.license_activate(aes_key, aes_iv, license_key) + response = @license.license_activate(aes_key, aes_iv, license_key, db_host, db_schema, db_user, db_password) + if response["status"] + redirect_to root_url, notice: response["message"] + else + redirect_to activate_path, notice: response["message"] + end end - def lookup_domain - if request.subdomain.present? && request.subdomain != "www" - @license = current_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase) - if (!@license.nil?) - # logger.info "Location - " + @license.name - ActiveRecord::Base.establish_connection(website_connection(@license)) - # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema - else - # reconnect_default_db - logger.info 'License is nil' - # redirect_to root_url(:host => request.domain) + "store_error" - render :json => [{ status: false, message: 'Invalid Access!'}] - end + def check_license + if License.check_license_file + redirect_to root_url end end - def current_license(url, key) - @license = License.new(url, key) + # def lookup_domain + # if request.subdomain.present? && request.subdomain != "www" + # @license = current_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase) + # if (!@license.nil?) + # # logger.info "Location - " + @license.name + # ActiveRecord::Base.establish_connection(website_connection(@license)) + # # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema + # else + # # reconnect_default_db + # logger.info 'License is nil' + # # redirect_to root_url(:host => request.domain) + "store_error" + # render :json => [{ status: false, message: 'Invalid Access!'}] + # end + # end + # end - ##creating md5 hash - md5_hostname = Digest::MD5.new - md5key = md5_hostname.update(request.host) - if (@license.detail_with_local_cache(key, md5key.to_s) == true) - #if (@license.detail == true) + # def current_license(url, key) + # @license = License.new(url, key) - return @license - else - return nil - end - end + # ##creating md5 hash + # md5_hostname = Digest::MD5.new + # md5key = md5_hostname.update(request.host) + # if (@license.detail_with_local_cache(key, md5key.to_s) == true) + # #if (@license.detail == true) + + # return @license + # else + # return nil + # end + # end end diff --git a/app/models/license.rb b/app/models/license.rb index 182edecd..c75eded5 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -75,7 +75,7 @@ class License def detail_with_local_file() - has_license = true #verify_license() + has_license = verify_license() if has_license puts "VERIFIED" @@ -118,7 +118,7 @@ class License # end # end # return false - end + #end # def detail # response = self.class.get("/subdomain", @options) @@ -137,7 +137,7 @@ class License # end # License Activation - def license_activate (key, iv, license_key) + def license_activate (key, iv, license_key, db_host, db_schema, db_user, db_password) @params = { query: { lookup_type: self.server_mode, encrypted_key: key, iv_key: iv, license_key: license_key } } response = self.class.get("/activate", @params) @activate = response.parsed_response @@ -145,10 +145,15 @@ class License Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s if (@activate["status"]) - return create_license_file(@activate) + response = create_license_file(@activate) + if(response["status"]) + sym_path = "/home/yan/symmetric/engines" + response = create_symmetric_config(sym_path, db_host, db_schema, db_user, db_password) + end else response = { "status": false, "message": "Activation Failed! Please contact code2lab call center!"} end + return response end def verify_license @@ -218,7 +223,7 @@ class License File.open("config/license.yml").each do |line| if line.include? (key) decrypted_line_array = line.split(":") - decrypted_line = AESCrypt.decrypt(decrypted_line_array[1]) + decrypted_line = AESCrypt.decrypt_data(decrypted_line_array[1], ENV['AES_KEY'], ENV['AES_IV'], ENV['CIPHER_TYPE']) end end end @@ -236,7 +241,12 @@ class License # Licese File Creation f = File.open("config/license.yml", "w") f.write("name: #{response_data['name']}\n") - f.write("shopname: #{response_data['shopname']}\n") + f.write("iv_key: #{response_data['iv_key']}\n") + f.write("shop_name: #{response_data['shop_name']}\n") + f.write("email: #{response_data['email']}\n") + f.write("telephone: #{response_data['telephone']}\n") + f.write("fax: #{response_data['fax']}\n") + f.write("address: #{response_data['address']}\n") f.write("dbhost: #{response_data['dbhost']}\n") f.write("dbschema: #{response_data['dbschema']}\n") f.write("dbusername: #{response_data['dbusername']}\n") @@ -245,9 +255,62 @@ class License f.write("app_token: #{response_data['app_token']}\n") f.close rescue IOError - response = { "status": false, "message": "Can't create license file. Please contact code2lab call center!"} + response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"} + end + response = { "status": true, "message": "Success Activation. License also created."} + end + + # Symmetric Configuration + def create_symmetric_config(sym_location, db_host, db_schema, db_user, db_password) + if File.directory? (sym_location) + begin + # sx properties create + f = File.open(sym_location + "/sx.properties", "w") + f.write("engine.name=sx\n") + f.write("db.driver=com.mysql.jdbc.Driver\n") + f.write("db.url=jdbc:mysql://#{db_host}/#{db_schema}?tinyInt1isBit=false\n") + f.write("db.user=#{db_user}\n") + f.write("db.password=#{db_password}\n") + f.write("registration.url=\n") + f.write("sync.url=http://#{db_host}:31415/sync/sx\n") + f.write("group.id=sx\n") + f.write("external.id=000\n") + f.write("job.purge.period.time.ms=7200000\n") + f.write("job.routing.period.time.ms=5000\n") + f.write("job.push.period.time.ms=10000\n") + f.write("job.pull.period.time.ms=10000\n") + f.write("initial.load.create.first=true\n") + f.write("initial.load.use.extract.job.enabled=true\n") + f.close + + # read from license file + shop_name = read_license("shop_name") + dbhost = read_license("dbhost") + dbschema = read_license("dbschema") + dbusername = read_license("dbusername") + dbpassword = read_license("dbpassword") + + # shop properties create + f = File.open(sym_location + "/#{shop_name}.properties", "w") + f.write("engine.name=#{shop_name}\n") + f.write("db.driver=com.mysql.jdbc.Driver\n") + f.write("db.url=jdbc:mysql://#{dbhost}/#{dbschema}?tinyInt1isBit=false\n") + f.write("db.user=#{dbusername}\n") + f.write("db.password=#{dbpassword}\n") + f.write("registration.url=http://#{db_host}:31415/sync/sx\n") + f.write("group.id=store\n") + f.write("external.id=001\n") + f.write("job.routing.period.time.ms=5000\n") + f.write("job.push.period.time.ms=10000\n") + f.write("job.pull.period.time.ms=10000\n") + # f.write("initial.load.create.first=true\n") + # f.write("initial.load.use.extract.job.enabled=true\n") + f.close + rescue IOError + response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"} + end + response = { "status": true, "message": "Success Activation. License also created."} end - response = { "status": true, "message": "License created"} end # Delete License File diff --git a/app/views/install/_form.html.erb b/app/views/install/_form.html.erb index 288c431a..5127862c 100755 --- a/app/views/install/_form.html.erb +++ b/app/views/install/_form.html.erb @@ -10,7 +10,7 @@ Add License Key from Email -
+
+
+ + +
+
+ + +
diff --git a/app/views/layouts/login_dashboard.html.erb b/app/views/layouts/login_dashboard.html.erb index d0d2cddd..e38d56f1 100755 --- a/app/views/layouts/login_dashboard.html.erb +++ b/app/views/layouts/login_dashboard.html.erb @@ -70,7 +70,7 @@
- +
diff --git a/config/initializers/license.rb b/config/initializers/license.rb index edb075ea..e329f313 100644 --- a/config/initializers/license.rb +++ b/config/initializers/license.rb @@ -1,4 +1,6 @@ -config = YAML.load_file(Rails.root.join("config/license.yml")) -config.fetch(Rails.env, {}).each do |key, value| - ENV[key.upcase] = value.to_s +if File.exist?("config/license.yml") + config = YAML.load_file(Rails.root.join("config/license.yml")) + config.fetch(Rails.env, {}).each do |key, value| + ENV[key.upcase] = value.to_s + end end \ No newline at end of file diff --git a/config/license.yml b/config/license.yml deleted file mode 100644 index e0f6bf7d..00000000 --- a/config/license.yml +++ /dev/null @@ -1,12 +0,0 @@ -development: - license_key: IAAXHpbSWAfvlWGYpDoXvZdmuRABNGk - - -test: - sx_provision_url: "provision.test.ws/api" - -# Do not keep production secrets in the repository, -# instead read values from the environment. -production: - license_key: IAAXHpbSWAfvlWGYpDoXvZdmuRABNGk - diff --git a/config/routes.rb b/config/routes.rb index a44cc1c4..56aa8d23 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,9 +9,9 @@ scope "(:locale)", locale: /en|mm/ do # Action Cable Creation mount ActionCable.server => "/cable" - #--------- SmartSales Installation ------------# - get 'install' => 'install#index' - post 'install' => 'install#activate' + #--------- SmartSales Activation ------------# + get 'activate' => 'install#index' + post 'activate' => 'install#activate' #--------- Login/Authentication ------------# get 'auth/:emp_id' => 'home#show', as: :emp_login diff --git a/config/secrets.yml b/config/secrets.yml index 09555540..28814f4d 100755 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -12,7 +12,7 @@ development: secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61 - sx_provision_url: provision.zsai.ws/api #192.168.1.94:3002 + sx_provision_url: 192.168.1.94:3002 #provision.zsai.ws/api server_mode: cloud cipher_type: AES-256-CBC aes_key: <%= ENV['AES_KEY'] %> diff --git a/db/sym_master.sql b/db/sym_master.sql index 6b392f58..f070761b 100755 --- a/db/sym_master.sql +++ b/db/sym_master.sql @@ -23,8 +23,8 @@ -- Sample Data ------------------------------------------------------------------------------ -- insert into item (item_id, name) values (11000001, 'Yummy Gum'); --- insert into item_selling_price (item_id, store_id, price, cost) values (11000001, '001',0.20, 0.10); --- insert into item_selling_price (item_id, store_id, price, cost) values (11000001, '002',0.30, 0.20); +-- insert into item_selling_price (item_id, cloud_id, price, cost) values (11000001, '001',0.20, 0.10); +-- insert into item_selling_price (item_id, cloud_id, price, cost) values (11000001, '002',0.30, 0.20); -- insert into sale_transaction (tran_id, store_id, workstation, day, seq) -- values (900, '001', '3', '2012-12-01', 90); @@ -48,6 +48,10 @@ delete from sym_node; # Create Channels for logically grouped tables + # For Initial Data Faster by bulk + update sym_channel set data_loader_type='mysql_bulk', max_batch_size=100000, max_data_to_route=100000 + where channel_id = 'reload'; + insert into sym_channel (channel_id, processing_order, max_batch_size, enabled, description) values('setting', 1, 100000, 1, 'All Settings'); @@ -305,466 +309,466 @@ delete from sym_node; # Create Routers for Nodes insert into sym_router (router_id,source_node_group_id,target_node_group_id,router_type,create_time,last_update_time) - values('sx_2_store', 'sx', 'store', 'default',current_timestamp, current_timestamp); + values('sx_2_cloud', 'sx', 'cloud', 'default',current_timestamp, current_timestamp); insert into sym_router (router_id,source_node_group_id,target_node_group_id,router_type,sync_on_delete,create_time,last_update_time) - values('store_2_sx', 'store', 'sx', 'default',0,current_timestamp, current_timestamp); + values('cloud_2_sx', 'cloud', 'sx', 'default',0,current_timestamp, current_timestamp); -- insert into sym_router -- (router_id,source_node_group_id,target_node_group_id,router_type,router_expression,create_time,last_update_time) --- values('sx_2_one_store', 'sx', 'store', 'column','STORE_ID=:EXTERNAL_ID or OLD_STORE_ID=:EXTERNAL_ID',current_timestamp, current_timestamp); +-- values('sx_2_one_cloud', 'sx', 'cloud', 'column','cloud_ID=:EXTERNAL_ID or OLD_cloud_ID=:EXTERNAL_ID',current_timestamp, current_timestamp); # Add triggers for tables with router -# Setting Channel # From Store to Master +# Setting Channel # From cloud to Master insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('lookups','store_2_sx', 100, current_timestamp, current_timestamp); + values('lookups','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('membership_actions','store_2_sx', 100, current_timestamp, current_timestamp); + values('membership_actions','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('membership_settings','store_2_sx', 100, current_timestamp, current_timestamp); + values('membership_settings','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('payment_method_settings','store_2_sx', 100, current_timestamp, current_timestamp); + values('payment_method_settings','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('print_settings','store_2_sx', 100, current_timestamp, current_timestamp); + values('print_settings','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('shops','store_2_sx', 100, current_timestamp, current_timestamp); + values('shops','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('customers','store_2_sx', 100, current_timestamp, current_timestamp); + values('customers','cloud_2_sx', 100, current_timestamp, current_timestamp); -# Setting Channel # From Master to Store +# Setting Channel # From Master to cloud insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('lookups','sx_2_store', 100, current_timestamp, current_timestamp); + values('lookups','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('membership_actions','sx_2_store', 100, current_timestamp, current_timestamp); + values('membership_actions','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('membership_settings','sx_2_store', 100, current_timestamp, current_timestamp); + values('membership_settings','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('payment_method_settings','sx_2_store', 100, current_timestamp, current_timestamp); + values('payment_method_settings','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('print_settings','sx_2_store', 100, current_timestamp, current_timestamp); + values('print_settings','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('shops','sx_2_store', 100, current_timestamp, current_timestamp); + values('shops','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('customers','sx_2_store', 100, current_timestamp, current_timestamp); + values('customers','sx_2_cloud', 100, current_timestamp, current_timestamp); #End Setting Channel -# Dining Channel # From Store to SX +# Dining Channel # From cloud to SX insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('zones','store_2_sx', 100, current_timestamp, current_timestamp); + values('zones','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('dining_charges','store_2_sx', 100, current_timestamp, current_timestamp); + values('dining_charges','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('dining_facilities','store_2_sx', 100, current_timestamp, current_timestamp); + values('dining_facilities','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('dining_queues','store_2_sx', 100, current_timestamp, current_timestamp); + values('dining_queues','cloud_2_sx', 100, current_timestamp, current_timestamp); -# Dining Channel # From SX to Store +# Dining Channel # From SX to cloud insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('zones','sx_2_store', 100, current_timestamp, current_timestamp); + values('zones','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('dining_charges','sx_2_store', 100, current_timestamp, current_timestamp); + values('dining_charges','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('dining_facilities','sx_2_store', 100, current_timestamp, current_timestamp); + values('dining_facilities','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('dining_queues','sx_2_store', 100, current_timestamp, current_timestamp); + values('dining_queues','sx_2_cloud', 100, current_timestamp, current_timestamp); #end Dining Channel -# Commission/Promotion/Product Channel # From Store to SX +# Commission/Promotion/Product Channel # From cloud to SX insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('commissioners','store_2_sx', 100, current_timestamp, current_timestamp); + values('commissioners','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('commissions','store_2_sx', 100, current_timestamp, current_timestamp); + values('commissions','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('employees','store_2_sx', 100, current_timestamp, current_timestamp); + values('employees','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('in_duties','store_2_sx', 100, current_timestamp, current_timestamp); + values('in_duties','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('inventory_definitions','store_2_sx', 100, current_timestamp, current_timestamp); + values('inventory_definitions','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('product_commissions','store_2_sx', 100, current_timestamp, current_timestamp); + values('product_commissions','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('products','store_2_sx', 100, current_timestamp, current_timestamp); + values('products','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('promotion_products','store_2_sx', 100, current_timestamp, current_timestamp); + values('promotion_products','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('promotions','store_2_sx', 100, current_timestamp, current_timestamp); + values('promotions','cloud_2_sx', 100, current_timestamp, current_timestamp); -# Commission/Promotion/Product Channel # From SX to Store +# Commission/Promotion/Product Channel # From SX to cloud insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('commissioners','sx_2_store', 100, current_timestamp, current_timestamp); + values('commissioners','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('commissions','sx_2_store', 100, current_timestamp, current_timestamp); + values('commissions','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('employees','sx_2_store', 100, current_timestamp, current_timestamp); + values('employees','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('in_duties','sx_2_store', 100, current_timestamp, current_timestamp); + values('in_duties','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('inventory_definitions','sx_2_store', 100, current_timestamp, current_timestamp); + values('inventory_definitions','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('product_commissions','sx_2_store', 100, current_timestamp, current_timestamp); + values('product_commissions','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('products','sx_2_store', 100, current_timestamp, current_timestamp); + values('products','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('promotion_products','sx_2_store', 100, current_timestamp, current_timestamp); + values('promotion_products','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('promotions','sx_2_store', 100, current_timestamp, current_timestamp); + values('promotions','sx_2_cloud', 100, current_timestamp, current_timestamp); #end Commission/Promotion/Product Channel -# Menu Channel # From Store to SX +# Menu Channel # From cloud to SX insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('accounts','store_2_sx', 100, current_timestamp, current_timestamp); + values('accounts','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menu_item_attributes','store_2_sx', 100, current_timestamp, current_timestamp); + values('menu_item_attributes','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menu_item_options','store_2_sx', 100, current_timestamp, current_timestamp); + values('menu_item_options','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menus','store_2_sx', 100, current_timestamp, current_timestamp); + values('menus','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menu_categories','store_2_sx', 100, current_timestamp, current_timestamp); + values('menu_categories','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menu_items','store_2_sx', 100, current_timestamp, current_timestamp); + values('menu_items','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menu_item_instances','store_2_sx', 100, current_timestamp, current_timestamp); + values('menu_item_instances','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('item_sets','store_2_sx', 100, current_timestamp, current_timestamp); + values('item_sets','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menu_item_sets','store_2_sx', 100, current_timestamp, current_timestamp); + values('menu_item_sets','cloud_2_sx', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menu_instance_item_sets','store_2_sx', 100, current_timestamp, current_timestamp); + values('menu_instance_item_sets','cloud_2_sx', 100, current_timestamp, current_timestamp); -# Menu Channel # From SX to Store +# Menu Channel # From SX to cloud insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('accounts','sx_2_store', 100, current_timestamp, current_timestamp); + values('accounts','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menu_item_attributes','sx_2_store', 100, current_timestamp, current_timestamp); + values('menu_item_attributes','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menu_item_options','sx_2_store', 100, current_timestamp, current_timestamp); + values('menu_item_options','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menus','sx_2_store', 100, current_timestamp, current_timestamp); + values('menus','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menu_categories','sx_2_store', 100, current_timestamp, current_timestamp); + values('menu_categories','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menu_items','sx_2_store', 100, current_timestamp, current_timestamp); + values('menu_items','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menu_item_instances','sx_2_store', 100, current_timestamp, current_timestamp); + values('menu_item_instances','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('item_sets','sx_2_store', 100, current_timestamp, current_timestamp); + values('item_sets','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menu_item_sets','sx_2_store', 100, current_timestamp, current_timestamp); + values('menu_item_sets','sx_2_cloud', 100, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('menu_instance_item_sets','sx_2_store', 100, current_timestamp, current_timestamp); + values('menu_instance_item_sets','sx_2_cloud', 100, current_timestamp, current_timestamp); #End Menu Channel -# Order Channel # From Store to Sx +# Order Channel # From cloud to Sx insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('orders','store_2_sx', 200, current_timestamp, current_timestamp); + values('orders','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('order_items','store_2_sx', 200, current_timestamp, current_timestamp); + values('order_items','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('bookings','store_2_sx', 200, current_timestamp, current_timestamp); + values('bookings','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('booking_orders','store_2_sx', 200, current_timestamp, current_timestamp); + values('booking_orders','cloud_2_sx', 200, current_timestamp, current_timestamp); -# Order Channel # From SX to Store +# Order Channel # From SX to cloud insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('orders','sx_2_store', 200, current_timestamp, current_timestamp); + values('orders','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('order_items','sx_2_store', 200, current_timestamp, current_timestamp); + values('order_items','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('bookings','sx_2_store', 200, current_timestamp, current_timestamp); + values('bookings','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('booking_orders','sx_2_store', 200, current_timestamp, current_timestamp); + values('booking_orders','sx_2_cloud', 200, current_timestamp, current_timestamp); # End Order Channel -# Sale Channel # From Store to Sx +# Sale Channel # From cloud to Sx insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('sales','store_2_sx', 200, current_timestamp, current_timestamp); + values('sales','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('sale_items','store_2_sx', 200, current_timestamp, current_timestamp); + values('sale_items','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('sale_audits','store_2_sx', 200, current_timestamp, current_timestamp); + values('sale_audits','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('sale_orders','store_2_sx', 200, current_timestamp, current_timestamp); + values('sale_orders','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('sale_payments','store_2_sx', 200, current_timestamp, current_timestamp); + values('sale_payments','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('sale_taxes','store_2_sx', 200, current_timestamp, current_timestamp); + values('sale_taxes','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('payment_journals','store_2_sx', 200, current_timestamp, current_timestamp); + values('payment_journals','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('shift_sales','store_2_sx', 200, current_timestamp, current_timestamp); + values('shift_sales','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('stock_check_items','store_2_sx', 200, current_timestamp, current_timestamp); + values('stock_check_items','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('stock_checks','store_2_sx', 200, current_timestamp, current_timestamp); + values('stock_checks','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('stock_journals','store_2_sx', 200, current_timestamp, current_timestamp); + values('stock_journals','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('surveys','store_2_sx', 200, current_timestamp, current_timestamp); + values('surveys','cloud_2_sx', 200, current_timestamp, current_timestamp); -# Sale Channel # From SX to Store +# Sale Channel # From SX to cloud insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('sales','sx_2_store', 200, current_timestamp, current_timestamp); + values('sales','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('sale_items','sx_2_store', 200, current_timestamp, current_timestamp); + values('sale_items','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('sale_audits','sx_2_store', 200, current_timestamp, current_timestamp); + values('sale_audits','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('sale_orders','sx_2_store', 200, current_timestamp, current_timestamp); + values('sale_orders','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('sale_payments','sx_2_store', 200, current_timestamp, current_timestamp); + values('sale_payments','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('sale_taxes','sx_2_store', 200, current_timestamp, current_timestamp); + values('sale_taxes','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('payment_journals','sx_2_store', 200, current_timestamp, current_timestamp); + values('payment_journals','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('shift_sales','sx_2_store', 200, current_timestamp, current_timestamp); + values('shift_sales','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('stock_check_items','sx_2_store', 200, current_timestamp, current_timestamp); + values('stock_check_items','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('stock_checks','sx_2_store', 200, current_timestamp, current_timestamp); + values('stock_checks','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('stock_journals','sx_2_store', 200, current_timestamp, current_timestamp); + values('stock_journals','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('surveys','sx_2_store', 200, current_timestamp, current_timestamp); + values('surveys','sx_2_cloud', 200, current_timestamp, current_timestamp); # End Sale Channel -# Oqs Channel # From Store to Sx +# Oqs Channel # From cloud to Sx insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('assigned_order_items','store_2_sx', 200, current_timestamp, current_timestamp); + values('assigned_order_items','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('cashier_terminals','store_2_sx', 200, current_timestamp, current_timestamp); + values('cashier_terminals','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('cashier_terminal_by_zones','store_2_sx', 200, current_timestamp, current_timestamp); + values('cashier_terminal_by_zones','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('cashier_login_logs','store_2_sx', 200, current_timestamp, current_timestamp); + values('cashier_login_logs','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('order_queue_process_by_zones','store_2_sx', 200, current_timestamp, current_timestamp); + values('order_queue_process_by_zones','cloud_2_sx', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('order_queue_stations','store_2_sx', 200, current_timestamp, current_timestamp); + values('order_queue_stations','cloud_2_sx', 200, current_timestamp, current_timestamp); -# Oqs Channel # From SX to Store +# Oqs Channel # From SX to cloud insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('assigned_order_items','sx_2_store', 200, current_timestamp, current_timestamp); + values('assigned_order_items','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('cashier_terminals','sx_2_store', 200, current_timestamp, current_timestamp); + values('cashier_terminals','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('cashier_terminal_by_zones','sx_2_store', 200, current_timestamp, current_timestamp); + values('cashier_terminal_by_zones','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('cashier_login_logs','sx_2_store', 200, current_timestamp, current_timestamp); + values('cashier_login_logs','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('order_queue_process_by_zones','sx_2_store', 200, current_timestamp, current_timestamp); + values('order_queue_process_by_zones','sx_2_cloud', 200, current_timestamp, current_timestamp); insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time) - values('order_queue_stations','sx_2_store', 200, current_timestamp, current_timestamp); + values('order_queue_stations','sx_2_cloud', 200, current_timestamp, current_timestamp); # End Oqs Channel insert into sym_node (node_id,node_group_id,external_id,sync_enabled,sync_url,schema_version,symmetric_version,database_type,database_version,heartbeat_time,timezone_offset,batch_to_send_count,batch_in_error_count,created_at_node_id) values ('000','sx','000',1,null,null,null,null,null,current_timestamp,null,0,0,'000'); insert into sym_node (node_id,node_group_id,external_id,sync_enabled,sync_url,schema_version,symmetric_version,database_type,database_version,heartbeat_time,timezone_offset,batch_to_send_count,batch_in_error_count,created_at_node_id) - values ('001','store','001',1,null,null,null,null,null,current_timestamp,null,0,0,'000'); + values ('001','cloud','001',1,null,null,null,null,null,current_timestamp,null,0,0,'000'); -- insert into sym_node (node_id,node_group_id,external_id,sync_enabled,sync_url,schema_version,symmetric_version,database_type,database_version,heartbeat_time,timezone_offset,batch_to_send_count,batch_in_error_count,created_at_node_id) --- values ('002','store','002',1,null,null,null,null,null,current_timestamp,null,0,0,'000'); +-- values ('002','cloud','002',1,null,null,null,null,null,current_timestamp,null,0,0,'000'); insert into sym_node_security (node_id,node_password,registration_enabled,registration_time,initial_load_enabled,initial_load_time,created_at_node_id) From 29322d952e23360ac522bbd14e32aa364656c575 Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 16 Nov 2017 20:46:03 +0630 Subject: [PATCH 04/14] license cloud done --- app/controllers/application_controller.rb | 15 ++++-- app/controllers/install_controller.rb | 2 +- app/models/license.rb | 59 +++++++++++++++-------- app/models/my_aes_crypt.rb | 16 ++++-- config/secrets.yml | 2 +- 5 files changed, 64 insertions(+), 30 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2163d885..91103651 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -22,8 +22,8 @@ class ApplicationController < ActionController::Base { locale: I18n.locale } end - def lookup_domain - if request.subdomain.present? && request.subdomain != "www" + def lookup_domain + if request.subdomain.present? && request.subdomain != "www" @license = cache_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase) # request.subdomain.downcase if (!@license.nil?) # logger.info "Location - " + @license.name @@ -54,10 +54,17 @@ class ApplicationController < ActionController::Base end def cache_license(url, lookup) + flag = ENV["AES_IV"] @license = License.new(url, lookup) # Export for Key - aes = MyAesCrypt.new - aes_key, aes_iv = aes.export_key(lookup) + + if flag == "<%= ENV['AES_IV'] %>" + aes = MyAesCrypt.new + aes_key, aes_iv = aes.export_key(lookup) + else + aes_key = ENV["AES_KEY"] + aes_iv = ENV["AES_IV"] + end if (@license.detail_with_local_cache(lookup, aes_key, aes_iv) == true) return @license diff --git a/app/controllers/install_controller.rb b/app/controllers/install_controller.rb index 870a10e0..52ecc296 100755 --- a/app/controllers/install_controller.rb +++ b/app/controllers/install_controller.rb @@ -16,7 +16,7 @@ class InstallController < BaseController # Export for Key aes = MyAesCrypt.new - aes_key, aes_iv = aes.export_key(lookup) + aes_key, aes_iv = aes.export_key(license_key) @license = License.new(ENV["SX_PROVISION_URL"]) response = @license.license_activate(aes_key, aes_iv, license_key, db_host, db_schema, db_user, db_password) diff --git a/app/models/license.rb b/app/models/license.rb index c75eded5..32f1b48a 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -41,9 +41,11 @@ class License cache_license = nil ##Get redis connection from connection pool - Redis.current do |conn| - cache_license = conn.get(cache_key) - end + redis = Redis.new + cache_license = redis.get(cache_key) + # Redis.current do |conn| + # cache_license = conn.get(cache_key) + # end Rails.logger.info "Cache key - " + cache_key.to_s if cache_license.nil? @@ -54,22 +56,27 @@ class License @license = response.parsed_response if (@license["status"] == true) - assign() Rails.logger.info "License - " + response.parsed_response.to_s - - Redis.current do |conn| - ##Remote - store the remote response in local redis cache - conn.set(cache_key, Marshal.dump(@license)) - ##ADD to List to remove later - conn.sadd("License:cache:keys", cache_key) - end + + redis = Redis.new + redis.set(cache_key, Marshal.dump(@license)) + # redis.sadd("License:cache:keys", cache_key) + # Redis.current do |conn| + # ##Remote - store the remote response in local redis cache + # conn.set(cache_key, Marshal.dump(@license)) + # ##ADD to List to remove later + # conn.sadd("License:cache:keys", cache_key) + # end return true end - - Rails.logger.info 'API License' + else + @license = Marshal.load(cache_license) + assign() + Rails.logger.info 'API License' + return true end end @@ -223,7 +230,7 @@ class License File.open("config/license.yml").each do |line| if line.include? (key) decrypted_line_array = line.split(":") - decrypted_line = AESCrypt.decrypt_data(decrypted_line_array[1], ENV['AES_KEY'], ENV['AES_IV'], ENV['CIPHER_TYPE']) + decrypted_line = AESCrypt.decrypt_data(decode_str(decrypted_line_array[1]), decode_str(ENV['AES_KEY']), decode_str(ENV['AES_IV']), ENV['CIPHER_TYPE']) end end end @@ -231,6 +238,10 @@ class License private + def decode_str(str) + return Base64.decode64(str) + end + # License File Creation def create_license_file(response_data) if check_license_file @@ -341,13 +352,21 @@ class License # self.plan_max_products = @license["plan_max_products"].to_i # self.plan_max_customers = @license["plan_max_customers"].to_i # self.plan_active_connections = @license["plan_active_connections"].to_i - salt = @license["secret_key"] + # salt = @license["secret_key"] - if (@license["dbhost"] || @license["dbschema"] || @license["dbusername"] || @license["dbpassword"] ) - self.dbhost = AESCrypt.decrypt(@license["dbhost"], salt) - self.dbschema = AESCrypt.decrypt(@license["dbschema"], salt) - self.dbusername = AESCrypt.decrypt(@license["dbusername"], salt) - self.dbpassword = AESCrypt.decrypt(@license["dbpassword"], salt) + key = Base64.decode64(ENV['AES_KEY']) + iv = Base64.decode64(ENV['AES_IV']) + + if (@license["dbhost"] || @license["dbschema"] || @license["dbusername"] || @license["dbpassword"] ) + host = Base64.decode64(@license["dbhost"]) + dbschema = Base64.decode64(@license["dbschema"]) + dbusername = Base64.decode64(@license["dbusername"]) + dbpassword = Base64.decode64(@license["dbpassword"]) + + self.dbhost = AESCrypt.decrypt_data(host, key, iv, ENV['CIPHER_TYPE']) + self.dbschema = AESCrypt.decrypt_data(dbschema, key, iv, ENV['CIPHER_TYPE']) + self.dbusername = AESCrypt.decrypt_data(dbusername, key, iv, ENV['CIPHER_TYPE']) + self.dbpassword = AESCrypt.decrypt_data(dbpassword, key, iv, ENV['CIPHER_TYPE']) end # self.exchange_unqiue_id = @license["exchange_unqiue_id"] diff --git a/app/models/my_aes_crypt.rb b/app/models/my_aes_crypt.rb index 7427a000..acba4974 100644 --- a/app/models/my_aes_crypt.rb +++ b/app/models/my_aes_crypt.rb @@ -1,3 +1,6 @@ +require 'openssl' +require 'base64' + class MyAesCrypt @cipher = "" @@ -7,11 +10,16 @@ class MyAesCrypt def export_key(passphrase) # We want a 256 bit key symetric key based on passphrase + # for cloud is lookup + # for local is license_key + # iv_salt = passphrase+"c2l" digest = Digest::SHA256.new - key = digest.update(passphrase) - key = digest.digest - ENV['AES_KEY'] = cipher_key = key # stores the key in key, and also sets the generated key on the @cipher - ENV['AES_IV'] = cipher_iv = @cipher.random_iv # stores the iv in iv, and also sets the generated iv on the @cipher + key_digest = digest.update(passphrase) + # iv_digest = digest.update(iv_salt) + key = key_digest.digest + # iv = iv_digest.digest + ENV['AES_KEY'] = cipher_key = Base64.encode64(key) # stores the key in key, and also sets the generated key on the @cipher + ENV['AES_IV'] = cipher_iv = Base64.encode64(@cipher.random_iv) # stores the iv in iv, and also sets the generated iv on the @cipher return cipher_key, cipher_iv end diff --git a/config/secrets.yml b/config/secrets.yml index 28814f4d..53d90c23 100755 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -12,7 +12,7 @@ development: secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61 - sx_provision_url: 192.168.1.94:3002 #provision.zsai.ws/api + sx_provision_url: 192.168.1.94:3002/api #provision.zsai.ws/api server_mode: cloud cipher_type: AES-256-CBC aes_key: <%= ENV['AES_KEY'] %> From 68a0f7eca3bcd1c5b78febc1096c6dae97c228c3 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 17 Nov 2017 13:32:49 +0630 Subject: [PATCH 05/14] license sym config --- app/models/license.rb | 107 +++++------------------------------------- 1 file changed, 12 insertions(+), 95 deletions(-) diff --git a/app/models/license.rb b/app/models/license.rb index 32f1b48a..c4b9cdd2 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -21,15 +21,7 @@ class License # @secret = ENV["aes_key"] # @params = { query: { device: "SX", token: SECRETS_CONFIG['provision_key'] } } - end - - # def shop_code - # if ( self.subdomain.length > 3) - # return self.subdomain[0,3].upcase - # else - # return self.subdomain.upcase - # end - # end + end def detail_with_local_cache(lookup, key, iv) ##Check from local redis - if available load local otherwise get from remote @@ -87,61 +79,7 @@ class License if has_license puts "VERIFIED" end - end - - # if cache_license.nil? - # ##change the d/e key - # @params = { query: { lookup_type: self.server_mode, lookup: lookup, encrypted_key: key, iv_key: iv} } - - # response = self.class.get("/request_license", @params) - # @license = response.parsed_response - - # if (@license["status"] == true) - - # assign() - - # Rails.logger.info "License - " + response.parsed_response.to_s - - # Redis.current do |conn| - # ##Remote - store the remote response in local redis cache - # conn.set(cache_key, Marshal.dump(@license)) - # ##ADD to List to remove later - # conn.sadd("License:cache:keys", cache_key) - # end - - # return true - # end - - # Rails.logger.info 'API License' - - # else - # @license = Marshal.load(cache_license) if cache_license - - # Rails.logger.info 'Cache License' - - # if (@license["status"] == true) - # assign() - # return true - # end - # end - # return false - #end - - # def detail - # response = self.class.get("/subdomain", @options) - # @license = response.parsed_response - - # Rails.logger.debug "License - " + response.parsed_response.to_s - - - # if (@license["status"] == true) - # assign() - - # return true - # end - - # return false - # end + end # License Activation def license_activate (key, iv, license_key, db_host, db_schema, db_user, db_password) @@ -154,8 +92,11 @@ class License if (@activate["status"]) response = create_license_file(@activate) if(response["status"]) - sym_path = "/home/yan/symmetric/engines" + sym_path = "/home/yan/symmetric/" response = create_symmetric_config(sym_path, db_host, db_schema, db_user, db_password) + if(response["status"]) + run_symmetric(sym_path) + end end else response = { "status": false, "message": "Activation Failed! Please contact code2lab call center!"} @@ -180,35 +121,6 @@ class License return false end - # def check_remote_license(license_key) - # # @options = { query: {device: "cloud", key: license_key, skey: @secret, token: Rails.application.secrets.provision_key} } - # @options = { query: {lookup_type: "application", encrypted_key: @secret, token: SECRETS_CONFIG['provision_key']} } - # response = self.class.get("/license", @options) - - # @license = response.parsed_response - - # Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s - # if (@license["status"]) - # assign() - # end - # return @license["status"] - # end - - # def verify_by_api_token(api_token) - # @options = { query: {device: "SX", api_token: api_token, skey: @secret, token: SECRETS_CONFIG['provision_key']} } - # response = self.class.get("/verify_token", @options) - - # @license = response.parsed_response - - # Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s - # if (@license["status"]) - # assign() - # end - - # return @license["status"] - # end - #Load License is remove from the cloud license because - this license is must be validated against subdmain instead of license.data from file. - # Check License expired date from PROVISION SERVER def check_expired(renewal_date) if (renewal_date < Date.today) @@ -276,7 +188,7 @@ class License if File.directory? (sym_location) begin # sx properties create - f = File.open(sym_location + "/sx.properties", "w") + f = File.open(sym_location + "engines/sx.properties", "w") f.write("engine.name=sx\n") f.write("db.driver=com.mysql.jdbc.Driver\n") f.write("db.url=jdbc:mysql://#{db_host}/#{db_schema}?tinyInt1isBit=false\n") @@ -324,6 +236,11 @@ class License end end + # Run Symmetric + def run_symmetric(sym_path) + check_sym_proc = system(sym_path) + end + # Delete License File def delete_license_file File.delete("config/license.yml") if File.exist?("config/license.yml") From 22b5421603da889df3d756d435ac4d13fca613fc Mon Sep 17 00:00:00 2001 From: Yan Date: Mon, 20 Nov 2017 19:15:32 +0630 Subject: [PATCH 06/14] dev done license --- app/models/license.rb | 52 ++++++++++++++++++++++++++++++++++++++++--- db/sym_master.sql | 6 ++--- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/app/models/license.rb b/app/models/license.rb index c4b9cdd2..71a32469 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -74,7 +74,7 @@ class License def detail_with_local_file() - has_license = verify_license() + has_license = true # verify_license() if has_license puts "VERIFIED" @@ -95,7 +95,7 @@ class License sym_path = "/home/yan/symmetric/" response = create_symmetric_config(sym_path, db_host, db_schema, db_user, db_password) if(response["status"]) - run_symmetric(sym_path) + response = run_symmetric(sym_path) end end else @@ -238,7 +238,53 @@ class License # Run Symmetric def run_symmetric(sym_path) - check_sym_proc = system(sym_path) + check_sym_proc_str = `#{sym_path + "bin/sym_service status"}` + check_sym_proc_str = check_sym_proc_str.split("\n") + sym_install_status = check_sym_proc_str[0].split(": ") + # sym_run_status = check_sym_proc_str[1].split(": ") + + # Check Sym Installed + if sym_install_status[1] == "false" + response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"} + end + + # Run Sym Service + sym_run_status = check_sym_running(check_sym_proc_str[1], sym_path) + if sym_run_status + # Create Sym Table + check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables") + if check_sym_table + sym_sql = Rails.root + "db/sym_master.sql" + if File.exist? (sym_sql) + # Import Sym Sql to db and start sym + run_sym_sql = system(sym_path + "bin/dbimport --engine sx " + sym_sql) + run_sym = system(sym_path + "bin/sym") + if run_sym + response = { "status": true, "message": "Activation is success and Configuration done..."} + end + else + response = { "status": false, "message": "Activation is success but Symmetric Sql not Found. \n Please contact code2lab call center!"} + end + end + end + + end + + # Check Symmetric Running + def check_sym_running(status, sym_path) + # Run Sym Service + if status.include? "Server is already running" + return true + elsif status.include? "false" + sym_start_str = `#{sym_path + "bin/sym_service start"}` + if sym_start_str.include? "Started" + return true + else + check_sym_running(sym_start_status[0]) + end + else + return true + end end # Delete License File diff --git a/db/sym_master.sql b/db/sym_master.sql index f070761b..4330b41f 100755 --- a/db/sym_master.sql +++ b/db/sym_master.sql @@ -82,10 +82,10 @@ delete from sym_node; # Create Node Groups and Links insert into sym_node_group (node_group_id) values ('sx'); - insert into sym_node_group (node_group_id) values ('store'); + insert into sym_node_group (node_group_id) values ('cloud'); - insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action) values ('sx', 'store', 'W'); - insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action) values ('store', 'sx', 'P'); + insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action) values ('sx', 'cloud', 'W'); + insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action) values ('cloud', 'sx', 'P'); # Create Trigger for Setting Channel From c4e9abbf197c8f58f4b211887fc04308280cb0af Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 24 Nov 2017 10:40:52 +0630 Subject: [PATCH 07/14] amount_due >= 0 for grand total 0 --- app/models/sale_payment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 961a556f..cb6b1249 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -20,7 +20,7 @@ class SalePayment < ApplicationRecord end end - if (amount_due > 0) + if (amount_due >= 0) payment_status = false #route to payment type case payment_method From b39464399146c9234b25863f8fae32c050db10a4 Mon Sep 17 00:00:00 2001 From: Yan Date: Tue, 28 Nov 2017 18:10:17 +0630 Subject: [PATCH 08/14] license --- app/controllers/application_controller.rb | 5 +++-- app/controllers/install_controller.rb | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 91103651..e7cdf4bf 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -55,10 +55,11 @@ class ApplicationController < ActionController::Base def cache_license(url, lookup) flag = ENV["AES_IV"] - @license = License.new(url, lookup) - # Export for Key + @license = License.new(url, lookup) + # Check Exists IV if flag == "<%= ENV['AES_IV'] %>" + # Export for Key aes = MyAesCrypt.new aes_key, aes_iv = aes.export_key(lookup) else diff --git a/app/controllers/install_controller.rb b/app/controllers/install_controller.rb index 52ecc296..faa789d9 100755 --- a/app/controllers/install_controller.rb +++ b/app/controllers/install_controller.rb @@ -13,10 +13,16 @@ class InstallController < BaseController db_schema = params[:db_schema] db_user = params[:db_user] db_password = params[:db_password] - - # Export for Key - aes = MyAesCrypt.new - aes_key, aes_iv = aes.export_key(license_key) + + # Check Exists IV + if flag == "<%= ENV['AES_IV'] %>" + # Export for Key + aes = MyAesCrypt.new + aes_key, aes_iv = aes.export_key(lookup) + else + aes_key = ENV["AES_KEY"] + aes_iv = ENV["AES_IV"] + end @license = License.new(ENV["SX_PROVISION_URL"]) response = @license.license_activate(aes_key, aes_iv, license_key, db_host, db_schema, db_user, db_password) From 51df43de44057a6e981e0f4317ebc42d7f126d85 Mon Sep 17 00:00:00 2001 From: Yan Date: Tue, 28 Nov 2017 18:43:34 +0630 Subject: [PATCH 09/14] remove paymal token in seed --- db/seeds.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/seeds.rb b/db/seeds.rb index 9671c041..03c2fb5b 100755 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -213,4 +213,4 @@ zone_queue_station1 = OrderQueueProcessByZone.create({order_queue_station: order zone_queue_station2 = OrderQueueProcessByZone.create({order_queue_station: order_queue_station2, zone: zone}) zone_queue_station3 = OrderQueueProcessByZone.create({order_queue_station: zone_order_queue_station, zone: zone}) -puts " Finished System Default Set Up Data vWSsseoZCzxd6xcNf_uS RxzaYyAGzm7VqAZ4hKnv " +puts " Finished System Default Set Up Data" From b1d9027d5b06888f0580bb1f484693a93b7fd508 Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 29 Nov 2017 11:21:26 +0630 Subject: [PATCH 10/14] subdomain + domain --- app/controllers/application_controller.rb | 9 ++++++--- config/secrets.yml | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e7cdf4bf..8db3e16b 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -22,9 +22,12 @@ class ApplicationController < ActionController::Base { locale: I18n.locale } end - def lookup_domain - if request.subdomain.present? && request.subdomain != "www" - @license = cache_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase) # request.subdomain.downcase + def lookup_domain + + if request.subdomain.present? && request.subdomain != "www" + from = request.subdomain.downcase #+ "." + request.domain.downcase + puts from + @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase if (!@license.nil?) # logger.info "Location - " + @license.name ActiveRecord::Base.establish_connection(website_connection(@license)) diff --git a/config/secrets.yml b/config/secrets.yml index 53d90c23..07a1f642 100755 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -12,7 +12,7 @@ development: secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61 - sx_provision_url: 192.168.1.94:3002/api #provision.zsai.ws/api + sx_provision_url: 192.168.1.147:3002/api #provision.zsai.ws/api server_mode: cloud cipher_type: AES-256-CBC aes_key: <%= ENV['AES_KEY'] %> From a1deab2b5e5b29a961c90a59e3537563814dba22 Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 29 Nov 2017 11:36:31 +0630 Subject: [PATCH 11/14] sale item --- app/models/sale_item.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index f6470a71..046db7b2 100755 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -159,6 +159,5 @@ class SaleItem < ApplicationRecord private def generate_custom_id self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI") - end end From 29fa95d229a2eee31edb31e385ffbdb25492cdf9 Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 29 Nov 2017 17:59:46 +0630 Subject: [PATCH 12/14] license activate --- app/controllers/install_controller.rb | 11 ++++++++--- app/models/license.rb | 7 +++---- app/views/install/_form.html.erb | 2 +- config/secrets.yml | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/controllers/install_controller.rb b/app/controllers/install_controller.rb index faa789d9..c9aeacca 100755 --- a/app/controllers/install_controller.rb +++ b/app/controllers/install_controller.rb @@ -1,10 +1,14 @@ class InstallController < BaseController + skip_before_action :verify_authenticity_token before_action :check_license def index end def activate + flag = "<%= ENV['AES_IV'] %>" + key_base = "<%= ENV['secret_key_base'] %>" + restaurant = params[:restaurant_name] license_key = params[:license_key] # admin_user = params[:admin_user] @@ -13,12 +17,13 @@ class InstallController < BaseController db_schema = params[:db_schema] db_user = params[:db_user] db_password = params[:db_password] - + phrase = key_base == "<%= ENV['secret_key_base'] %>"? license_key : "<%= ENV['secret_key_base'] %>" + # Check Exists IV if flag == "<%= ENV['AES_IV'] %>" # Export for Key aes = MyAesCrypt.new - aes_key, aes_iv = aes.export_key(lookup) + aes_key, aes_iv = aes.export_key(phrase) else aes_key = ENV["AES_KEY"] aes_iv = ENV["AES_IV"] @@ -26,7 +31,7 @@ class InstallController < BaseController @license = License.new(ENV["SX_PROVISION_URL"]) response = @license.license_activate(aes_key, aes_iv, license_key, db_host, db_schema, db_user, db_password) - if response["status"] + if response[:status] redirect_to root_url, notice: response["message"] else redirect_to activate_path, notice: response["message"] diff --git a/app/models/license.rb b/app/models/license.rb index f6f84833..afb95cf4 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -74,7 +74,7 @@ class License def detail_with_local_file() - has_license = true # verify_license() + has_license = true #verify_license() if has_license # puts "VERIFIED" @@ -156,14 +156,13 @@ class License # License File Creation def create_license_file(response_data) - if check_license_file + if File.exist?("config/license.yml") delete_license_file end begin # Licese File Creation - f = File.open("config/license.yml", "w") - f.write("name: #{response_data['name']}\n") + f = File.open("config/license.yml", "w") f.write("iv_key: #{response_data['iv_key']}\n") f.write("shop_name: #{response_data['shop_name']}\n") f.write("email: #{response_data['email']}\n") diff --git a/app/views/install/_form.html.erb b/app/views/install/_form.html.erb index 5127862c..c4520cd6 100755 --- a/app/views/install/_form.html.erb +++ b/app/views/install/_form.html.erb @@ -1,4 +1,4 @@ -
+
diff --git a/config/secrets.yml b/config/secrets.yml index 07a1f642..180ff20f 100755 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -13,7 +13,7 @@ development: secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61 sx_provision_url: 192.168.1.147:3002/api #provision.zsai.ws/api - server_mode: cloud + server_mode: application cipher_type: AES-256-CBC aes_key: <%= ENV['AES_KEY'] %> aes_iv: <%= ENV['AES_IV'] %> From e2aa1527caa553b78249f9a58c6bd3ea547862a9 Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 29 Nov 2017 18:00:13 +0630 Subject: [PATCH 13/14] license activate --- config/license.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 config/license.yml diff --git a/config/license.yml b/config/license.yml new file mode 100644 index 00000000..1dab6877 --- /dev/null +++ b/config/license.yml @@ -0,0 +1,18 @@ +name: +iv_key: vO8MJlASMmPRf6Ivw3QK+A== + +shop_name: bitp +email: yanaung.nyein@code2lab.com +telephone: 111111 +fax: 111111 +address: bitp +dbhost: vd52jkRoCOPpHX0tsYp1HQ== + +dbschema: 7L5CvrQvsspSYgx5Ng3tDg== + +dbusername: G0QLCPnSiRmGQ7ekVWy5wA== + +dbpassword: ahQVj/eThBKnwpv1tcvNGA== + +api_token: +app_token: From d826e375b706b3034ccdbc92b31d7e903eac61e0 Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 29 Nov 2017 18:01:51 +0630 Subject: [PATCH 14/14] change license --- config/license.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/config/license.yml b/config/license.yml index 1dab6877..5d80e0e9 100644 --- a/config/license.yml +++ b/config/license.yml @@ -1,4 +1,3 @@ -name: iv_key: vO8MJlASMmPRf6Ivw3QK+A== shop_name: bitp