├── .gitignore ├── LICENSE ├── consumers ├── android_ecommerce │ ├── .gitignore │ ├── .idea │ │ ├── codeStyles │ │ │ └── Project.xml │ │ ├── gradle.xml │ │ ├── misc.xml │ │ └── runConfigurations.xml │ ├── .project │ ├── .settings │ │ └── org.eclipse.buildship.core.prefs │ ├── app │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── androidTest │ │ │ └── java │ │ │ │ └── msdemo │ │ │ │ └── ayhan │ │ │ │ └── com │ │ │ │ └── ecommerce │ │ │ │ └── ExampleInstrumentedTest.java │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── msdemo │ │ │ │ │ └── ayhan │ │ │ │ │ └── com │ │ │ │ │ └── ecommerce │ │ │ │ │ ├── LoginFragment.java │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ ├── OrderModel.java │ │ │ │ │ ├── OrdersAdapter.java │ │ │ │ │ ├── OrdersFragment.java │ │ │ │ │ ├── ProductModel.java │ │ │ │ │ ├── ProductsAdapter.java │ │ │ │ │ ├── ProductsFragment.java │ │ │ │ │ ├── RegisterFragment.java │ │ │ │ │ ├── RestClientTask.java │ │ │ │ │ └── SettingsFragment.java │ │ │ └── res │ │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ │ ├── drawable │ │ │ │ ├── buttonshape.xml │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ ├── ic_login.xml │ │ │ │ ├── ic_logout.xml │ │ │ │ ├── ic_menu_send.xml │ │ │ │ ├── ic_myinfo.xml │ │ │ │ ├── ic_orders.xml │ │ │ │ ├── ic_products.xml │ │ │ │ ├── ic_register.xml │ │ │ │ ├── side_nav_bar.xml │ │ │ │ ├── simplicity.png │ │ │ │ └── text_background.xml │ │ │ │ ├── layout │ │ │ │ ├── activity_main.xml │ │ │ │ ├── app_bar_main.xml │ │ │ │ ├── content_main.xml │ │ │ │ ├── fragment_login.xml │ │ │ │ ├── fragment_orders.xml │ │ │ │ ├── fragment_products.xml │ │ │ │ ├── fragment_register.xml │ │ │ │ ├── fragment_settings.xml │ │ │ │ ├── listview_orders_row.xml │ │ │ │ ├── listview_products_row.xml │ │ │ │ └── nav_header_main.xml │ │ │ │ ├── menu │ │ │ │ ├── activity_main_drawer.xml │ │ │ │ └── main.xml │ │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── values-v21 │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ └── test │ │ │ └── java │ │ │ └── msdemo │ │ │ └── ayhan │ │ │ └── com │ │ │ └── ecommerce │ │ │ └── ExampleUnitTest.java │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── website_ecommerce │ ├── Dockerfile │ ├── app.py │ ├── docker-compose.yml │ ├── requirements.txt │ ├── run.sh │ ├── static │ │ └── w3.css │ └── templates │ │ ├── base.html │ │ ├── categories.html │ │ ├── index.html │ │ ├── login.html │ │ ├── orders.html │ │ ├── products.html │ │ ├── register.html │ │ └── userinfo.html └── website_manager │ ├── Dockerfile │ ├── app.py │ ├── docker-compose.yml │ ├── requirements.txt │ ├── run.sh │ ├── static │ └── w3.css │ └── templates │ ├── addcategory.html │ ├── addproduct.html │ ├── base.html │ ├── categories.html │ ├── customers.html │ ├── deletecategory.html │ ├── deleteproduct.html │ ├── editcategory.html │ ├── editcustomercredit.html │ ├── editproduct.html │ ├── index.html │ ├── login.html │ ├── products.html │ └── test.html ├── databases ├── db_accounting │ ├── .env │ ├── .gitignore │ ├── Dockerfile │ └── docker-compose.yml ├── db_customer │ ├── .env │ ├── .gitignore │ ├── Dockerfile │ └── docker-compose.yml ├── db_event_store │ ├── .env │ ├── .gitignore │ ├── Dockerfile │ └── docker-compose.yml └── db_order │ ├── .env │ ├── .gitignore │ ├── Dockerfile │ └── docker-compose.yml ├── img ├── allsystem.png └── ordersaga.png ├── readme.md ├── service_tests.txt ├── tools ├── event_bus │ ├── .env │ ├── .gitignore │ ├── Dockerfile │ └── docker-compose.yml ├── event_store │ ├── .gitignore │ ├── DbOperations.cs │ ├── Dockerfile │ ├── Program.cs │ ├── build.sh │ ├── docker-compose.yml │ ├── event_store.csproj │ └── event_store_deployment │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── docker-compose.yml │ │ └── run.sh └── reverse_proxy │ ├── Dockerfile │ ├── docker-compose.yml │ ├── favicon.ico │ ├── index.html │ ├── nginx.conf │ └── w3.css └── webservices ├── .gitignore ├── service_accounting ├── .gitignore ├── Dockerfile ├── accounting.js ├── docker-compose.yml ├── package-lock.json ├── package.json └── run.sh ├── service_customer ├── Dockerfile ├── customer.py ├── docker-compose.yml ├── requirements.txt └── run.sh ├── service_order ├── .classpath ├── .gitignore ├── .project ├── Dockerfile ├── build.sh ├── docker-compose.yml ├── notes.txt ├── pom.xml ├── src │ └── main │ │ └── java │ │ └── com │ │ └── ms_demo │ │ ├── DatabaseOperations.java │ │ ├── EventBus.java │ │ ├── Main.java │ │ └── Order.java └── target │ ├── classes │ └── com │ │ └── ms_demo │ │ ├── DatabaseOperations.class │ │ ├── EventBus$1.class │ │ ├── EventBus$2.class │ │ ├── EventBus.class │ │ ├── Main.class │ │ └── Order.class │ ├── maven-archiver │ └── pom.properties │ ├── maven-status │ └── maven-compiler-plugin │ │ ├── compile │ │ └── default-compile │ │ │ ├── createdFiles.lst │ │ │ └── inputFiles.lst │ │ └── testCompile │ │ └── default-testCompile │ │ ├── createdFiles.lst │ │ └── inputFiles.lst │ ├── service_order-1.0-SNAPSHOT.jar │ └── surefire-reports │ ├── TEST-com.ms_demo.MyResourceTest.xml │ └── com.ms_demo.MyResourceTest.txt └── service_product ├── .gitignore ├── Dockerfile ├── docker-compose.yml ├── product.py ├── requirements.txt └── run.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Ayhan AVCI 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches/build_file_checksums.ser 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | .DS_Store 9 | /build 10 | /captures 11 | .externalNativeBuild 12 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 31 | 32 | 33 | 34 | 35 | 36 | 38 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | android_ecommerce 4 | Project android_ecommerce created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.buildship.core.gradleprojectbuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.buildship.core.gradleprojectnature 16 | 17 | 18 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | connection.project.dir= 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "msdemo.ayhan.com.ecommerce" 7 | minSdkVersion 23 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | compileOptions { 20 | sourceCompatibility JavaVersion.VERSION_1_8 21 | targetCompatibility JavaVersion.VERSION_1_8 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation 'com.google.code.gson:gson:2.8.5' 27 | implementation fileTree(include: ['*.jar'], dir: 'libs') 28 | implementation 'com.android.support:appcompat-v7:28.0.0' 29 | implementation 'com.android.support:support-v4:28.0.0' 30 | implementation 'com.android.support:design:28.0.0' 31 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 32 | testImplementation 'junit:junit:4.12' 33 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 34 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 35 | } 36 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/androidTest/java/msdemo/ayhan/com/ecommerce/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package msdemo.ayhan.com.ecommerce; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("msdemo.ayhan.com.ecommerce", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/java/msdemo/ayhan/com/ecommerce/LoginFragment.java: -------------------------------------------------------------------------------- 1 | package msdemo.ayhan.com.ecommerce; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.os.AsyncTask; 6 | import android.os.Bundle; 7 | import android.support.design.widget.Snackbar; 8 | import android.support.v4.app.Fragment; 9 | import android.util.JsonReader; 10 | import android.util.Log; 11 | import android.view.LayoutInflater; 12 | import android.view.View; 13 | import android.view.ViewGroup; 14 | import android.widget.Button; 15 | import android.widget.EditText; 16 | import android.widget.TextView; 17 | import android.widget.Toast; 18 | 19 | import com.google.gson.JsonObject; 20 | import com.google.gson.JsonParser; 21 | 22 | import org.json.JSONObject; 23 | 24 | import java.io.InputStream; 25 | import java.io.InputStreamReader; 26 | import java.net.HttpURLConnection; 27 | import java.net.URL; 28 | 29 | import javax.net.ssl.HttpsURLConnection; 30 | 31 | 32 | public class LoginFragment extends Fragment { 33 | Button btn_login; 34 | EditText txt_username; 35 | EditText txt_password; 36 | View mView; 37 | View mMainView; 38 | 39 | public LoginFragment() { 40 | // Required empty public constructor 41 | } 42 | 43 | public static LoginFragment newInstance() { 44 | LoginFragment fragment = new LoginFragment(); 45 | Bundle args = new Bundle(); 46 | 47 | fragment.setArguments(args); 48 | return fragment; 49 | } 50 | 51 | @Override 52 | public void onCreate(Bundle savedInstanceState) { 53 | super.onCreate(savedInstanceState); 54 | if (getArguments() != null) { 55 | 56 | } 57 | } 58 | 59 | @Override 60 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 61 | Bundle savedInstanceState) { 62 | mView = inflater.inflate(R.layout.fragment_login, container, false); 63 | mMainView = getActivity().findViewById(android.R.id.content); 64 | 65 | txt_username = mView.findViewById(R.id.txt_user_name); 66 | txt_password = mView.findViewById(R.id.txt_password); 67 | btn_login = mView.findViewById(R.id.sign_in_button); 68 | 69 | btn_login.setOnClickListener((View v) -> { 70 | OnLoginClick(v); 71 | }); 72 | 73 | 74 | return mView; 75 | } 76 | 77 | private void OnLoginClick(View view) { 78 | String user_name = txt_username.getText().toString(); 79 | String password = txt_password.getText().toString(); 80 | try { 81 | JsonObject post_json = new JsonObject(); 82 | post_json.addProperty("UserName", user_name); 83 | post_json.addProperty("Password", password); 84 | 85 | String [] params = {"customer/login-user/", "POST", post_json.toString()}; 86 | 87 | 88 | new RestClientTask() { 89 | protected void onPostExecute(String result) { 90 | 91 | JsonObject response_json = new JsonParser().parse(result).getAsJsonObject(); 92 | String result_string = response_json.get("Result").toString().replaceAll("\"", ""); 93 | if (result_string.equals("Success")) { 94 | String data_string = response_json.get("Data").toString(); 95 | JsonObject data_json = new JsonParser().parse(data_string).getAsJsonObject(); 96 | String status_string = data_json.get("result").toString(); 97 | JsonObject status_json = new JsonParser().parse(status_string).getAsJsonObject(); 98 | String login_status = status_json.get("Status").toString().replaceAll("\"", ""); 99 | if (login_status.equals("Success")) { 100 | SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); 101 | SharedPreferences.Editor editor = sharedPref.edit(); 102 | editor.putString(getString(R.string.saved_login_name), user_name); 103 | editor.putString(getString(R.string.saved_login_password), password); 104 | editor.commit(); 105 | 106 | } 107 | else { 108 | 109 | } 110 | Snackbar.make(mView, "Login: " + login_status, Snackbar.LENGTH_LONG) 111 | .setAction("No action", null).show(); 112 | 113 | } 114 | else { 115 | Snackbar.make(mView, "Login Fail " + result, Snackbar.LENGTH_LONG) 116 | .setAction("No action", null).show(); 117 | } 118 | 119 | } 120 | }.execute(params); 121 | } 122 | catch (Exception ex) { 123 | 124 | } 125 | } 126 | 127 | @Override 128 | public void onDetach() { 129 | super.onDetach(); 130 | } 131 | 132 | 133 | } 134 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/java/msdemo/ayhan/com/ecommerce/MainActivity.java: -------------------------------------------------------------------------------- 1 | package msdemo.ayhan.com.ecommerce; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.os.Bundle; 6 | import android.support.design.widget.FloatingActionButton; 7 | import android.support.design.widget.Snackbar; 8 | import android.support.v4.app.Fragment; 9 | import android.support.v4.app.FragmentTransaction; 10 | import android.support.v7.app.ActionBar; 11 | import android.view.View; 12 | import android.support.design.widget.NavigationView; 13 | import android.support.v4.view.GravityCompat; 14 | import android.support.v4.widget.DrawerLayout; 15 | import android.support.v7.app.ActionBarDrawerToggle; 16 | import android.support.v7.app.AppCompatActivity; 17 | import android.support.v7.widget.Toolbar; 18 | import android.view.Menu; 19 | import android.view.MenuItem; 20 | 21 | public class MainActivity extends AppCompatActivity 22 | implements NavigationView.OnNavigationItemSelectedListener { 23 | static String proxy_server_ip = ""; 24 | 25 | @Override 26 | protected void onCreate(Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | setContentView(R.layout.activity_main); 29 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 30 | setSupportActionBar(toolbar); 31 | 32 | 33 | SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE); 34 | String proxy_ip = sharedPref.getString(getString(R.string.saved_proxy_ip), null); 35 | if (proxy_ip == null || proxy_ip == "") { 36 | proxy_ip = "http://192.168.0.21"; 37 | SharedPreferences.Editor editor = sharedPref.edit(); 38 | editor.putString(getString(R.string.saved_proxy_ip), proxy_ip); 39 | editor.commit(); 40 | } 41 | proxy_server_ip = proxy_ip; 42 | 43 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 44 | ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( 45 | this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); 46 | drawer.addDrawerListener(toggle); 47 | toggle.syncState(); 48 | 49 | NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); 50 | navigationView.setNavigationItemSelectedListener(this); 51 | displayView(R.id.nav_login); 52 | } 53 | 54 | @Override 55 | public void onBackPressed() { 56 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 57 | if (drawer.isDrawerOpen(GravityCompat.START)) { 58 | drawer.closeDrawer(GravityCompat.START); 59 | } else { 60 | super.onBackPressed(); 61 | } 62 | } 63 | 64 | 65 | @Override 66 | public boolean onCreateOptionsMenu(Menu menu) { 67 | // Inflate the menu; this adds items to the action bar if it is present. 68 | getMenuInflater().inflate(R.menu.main, menu); 69 | return true; 70 | } 71 | 72 | @Override 73 | public boolean onOptionsItemSelected(MenuItem item) { 74 | // Handle action bar item clicks here. The action bar will 75 | // automatically handle clicks on the Home/Up button, so long 76 | // as you specify a parent activity in AndroidManifest.xml. 77 | int id = item.getItemId(); 78 | Fragment fragment = null; 79 | String title = getString(R.string.app_name); 80 | 81 | //noinspection SimplifiableIfStatement 82 | if (id == R.id.action_settings) { 83 | fragment = SettingsFragment.newInstance(); 84 | 85 | } 86 | 87 | if (fragment != null) { 88 | FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); 89 | ft.replace(R.id.content_frame, fragment); 90 | ft.commit(); 91 | } 92 | 93 | // set the toolbar title 94 | if (getSupportActionBar() != null) { 95 | getSupportActionBar().setTitle(title); 96 | } 97 | return true; 98 | //return super.onOptionsItemSelected(item); 99 | } 100 | 101 | @SuppressWarnings("StatementWithEmptyBody") 102 | @Override 103 | public boolean onNavigationItemSelected(MenuItem item) { 104 | // Handle navigation view item clicks here. 105 | displayView(item.getItemId()); 106 | 107 | return true; 108 | } 109 | public void displayView(int viewId) { 110 | 111 | Fragment fragment = null; 112 | String title = getString(R.string.app_name); 113 | 114 | 115 | switch (viewId) { 116 | case R.id.nav_logout: 117 | SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE); 118 | SharedPreferences.Editor editor = sharedPref.edit(); 119 | editor.remove(getString(R.string.saved_login_name)); 120 | editor.remove(getString(R.string.saved_login_password)); 121 | editor.commit(); 122 | case R.id.nav_login: 123 | fragment = LoginFragment.newInstance(); 124 | title = "Login"; 125 | break; 126 | case R.id.nav_register: 127 | fragment = RegisterFragment.newInstance(); 128 | title = "Register"; 129 | break; 130 | case R.id.nav_products: 131 | fragment = ProductsFragment.newInstance(); 132 | title = "Products"; 133 | break; 134 | case R.id.nav_orders: 135 | fragment = OrdersFragment.newInstance(); 136 | title = "Orders"; 137 | break; 138 | 139 | 140 | } 141 | 142 | if (fragment != null) { 143 | FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); 144 | ft.replace(R.id.content_frame, fragment); 145 | ft.commit(); 146 | } 147 | 148 | // set the toolbar title 149 | if (getSupportActionBar() != null) { 150 | getSupportActionBar().setTitle(title); 151 | } 152 | 153 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 154 | drawer.closeDrawer(GravityCompat.START); 155 | 156 | } 157 | 158 | 159 | } 160 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/java/msdemo/ayhan/com/ecommerce/OrderModel.java: -------------------------------------------------------------------------------- 1 | package msdemo.ayhan.com.ecommerce; 2 | 3 | public class OrderModel { 4 | int Id; 5 | String Code; 6 | String UserId; 7 | String ProductId; 8 | String ProductName; 9 | Float Price; 10 | int OrderStatus; 11 | int StockStatus; 12 | int CreditStatus; 13 | int Stock; 14 | String OrderTime; 15 | Float Credit; 16 | //{"GUID":"7a837981-4a1b-4a21-b226-8e2947d08e60","USERID":"jon","PRODUCT":"fcc6fe7b-1784-4f47-8efa-137b19a876ed", 17 | // "PRODUCTNAME":"Hot Laptop","PRICE":19.0,"ORDERSTATUS":1,"STOCKSTATUS":3,"CREDITSTATUS":2,"TIME":"2018-24-12 01:36:53","CREDIT":5.0,"STOCK":43} 18 | public OrderModel(String Code, String UserId, String ProductId, String ProductName, Float Price, 19 | int OrderStatus, int StockStatus, int CreditStatus, String OrderTime, int Stock, Float Credit) { 20 | this.Code = Code; 21 | this.UserId = UserId; 22 | this.ProductId = ProductId; 23 | this.ProductName = ProductName; 24 | this.Price = Price; 25 | this.OrderStatus = OrderStatus; 26 | this.StockStatus = StockStatus; 27 | this.CreditStatus = CreditStatus; 28 | this.OrderTime = OrderTime; 29 | this.Stock = Stock; 30 | this.Credit = Credit; 31 | } 32 | 33 | public int getId() {return Id;} 34 | public String getCode() { 35 | return Code; 36 | } 37 | public String getProductId() { return ProductId; } 38 | public String getProductName() { return ProductName; } 39 | public Float getPrice() { 40 | return Price; 41 | } 42 | public int getOrderStatus() { 43 | return OrderStatus; 44 | } 45 | public int getStockStatus() { 46 | return StockStatus; 47 | } 48 | public int getCreditStatus() { 49 | return CreditStatus; 50 | } 51 | public Float getCredit() {return Credit;} 52 | public int getStock() { 53 | return Stock; 54 | } 55 | public String getOrderTime() { return OrderTime; } 56 | } 57 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/java/msdemo/ayhan/com/ecommerce/OrdersAdapter.java: -------------------------------------------------------------------------------- 1 | package msdemo.ayhan.com.ecommerce; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.SharedPreferences; 6 | import android.support.design.widget.Snackbar; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.ArrayAdapter; 11 | import android.widget.Button; 12 | import android.widget.TextView; 13 | 14 | import com.google.gson.JsonObject; 15 | import com.google.gson.JsonParser; 16 | 17 | import java.util.ArrayList; 18 | 19 | public class OrdersAdapter extends ArrayAdapter { 20 | 21 | private ArrayList dataSet; 22 | Context mContext; 23 | View mView; 24 | public static final int ORDER_STATUS_PENDING = 0; 25 | public static final int ORDER_STATUS_CANCELED = 1; 26 | public static final int ORDER_STATUS_APPROVED = 2; 27 | public static final int ORDER_STATUS_FINALIZED = 3; 28 | 29 | public static final int PRICEANDSTOCK_STATUS_PENDING = 0; 30 | public static final int PRICEANDSTOCK_STATUS_RECEIVED = 1; 31 | public static final int PRICEANDSTOCK_STATUS_DENIED = 2; 32 | public static final int PRICEANDSTOCK_STATUS_APPROVED = 3; 33 | 34 | public static final int CREDIT_STATUS_PENDING = 0; 35 | public static final int CREDIT_STATUS_RECEIVED = 1; 36 | public static final int CREDIT_STATUS_DENIED = 2; 37 | public static final int CREDIT_STATUS_APPROVED = 3; 38 | 39 | public OrdersAdapter(ArrayList data, Context context, View view) { 40 | super(context, R.layout.listview_orders_row, data); 41 | this.dataSet = data; 42 | this.mContext=context; 43 | this.mView = view; 44 | } 45 | 46 | @Override 47 | public int getCount() { 48 | return dataSet.size(); 49 | } 50 | 51 | @Override 52 | public long getItemId(int position) { 53 | return dataSet.get(position).getId(); 54 | } 55 | 56 | @Override 57 | public OrderModel getItem(int position) { 58 | return dataSet.get(position); 59 | } 60 | 61 | 62 | @Override 63 | public View getView(int position, View convertView, ViewGroup parent) { 64 | LayoutInflater inflater = (LayoutInflater) mContext 65 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 66 | View rowView = inflater.inflate(R.layout.listview_orders_row, parent, false); 67 | TextView txt_product_name = rowView.findViewById(R.id.txt_product_name); 68 | TextView txt_order_date = rowView.findViewById(R.id.txt_order_date); 69 | TextView txt_order_status = rowView.findViewById(R.id.txt_order_status); 70 | TextView txt_extra_data = rowView.findViewById(R.id.txt_extra_data); 71 | 72 | OrderModel item = dataSet.get(position); 73 | txt_product_name.setText(item.getProductName()); 74 | txt_order_date.setText(item.getOrderTime()); 75 | 76 | if (item.getOrderStatus() == ORDER_STATUS_PENDING) { 77 | txt_order_status.setText("Pending"); 78 | } 79 | else if (item.getOrderStatus() == ORDER_STATUS_CANCELED) { 80 | String message = "Fail"; 81 | String extra_message = ""; 82 | if (item.getCreditStatus() == PRICEANDSTOCK_STATUS_DENIED) { 83 | message = "Out of stock. "; 84 | } 85 | if (item.getCreditStatus() == CREDIT_STATUS_DENIED) { 86 | message = "Low credit"; 87 | extra_message += String.format("%.1f - %.1f", item.getPrice(), item.getCredit()); 88 | txt_extra_data.setText(extra_message); 89 | } 90 | txt_order_status.setText(message); 91 | } 92 | else if (item.getOrderStatus() == ORDER_STATUS_APPROVED) { 93 | txt_order_status.setText("Approved"); 94 | } 95 | else if (item.getOrderStatus() == ORDER_STATUS_FINALIZED) { 96 | txt_order_status.setText("On Shipment"); 97 | } 98 | 99 | return rowView; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/java/msdemo/ayhan/com/ecommerce/OrdersFragment.java: -------------------------------------------------------------------------------- 1 | package msdemo.ayhan.com.ecommerce; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.SharedPreferences; 6 | import android.os.Bundle; 7 | import android.support.design.widget.Snackbar; 8 | import android.support.v4.app.Fragment; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.ListView; 13 | 14 | import com.google.gson.JsonArray; 15 | import com.google.gson.JsonObject; 16 | import com.google.gson.JsonParser; 17 | 18 | import java.util.ArrayList; 19 | 20 | 21 | public class OrdersFragment extends Fragment { 22 | 23 | ArrayList orders = new ArrayList<>(); 24 | ListView orders_listview; 25 | OrdersAdapter orders_adapter; 26 | View mView; 27 | View mMainView; 28 | public OrdersFragment() { 29 | // Required empty public constructor 30 | } 31 | 32 | public static OrdersFragment newInstance() { 33 | OrdersFragment fragment = new OrdersFragment(); 34 | Bundle args = new Bundle(); 35 | 36 | fragment.setArguments(args); 37 | return fragment; 38 | } 39 | 40 | @Override 41 | public void onCreate(Bundle savedInstanceState) { 42 | super.onCreate(savedInstanceState); 43 | if (getArguments() != null) { 44 | 45 | } 46 | 47 | } 48 | 49 | @Override 50 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 51 | Bundle savedInstanceState) { 52 | mView = inflater.inflate(R.layout.fragment_orders, container, false); 53 | 54 | mMainView = getActivity().findViewById(android.R.id.content); 55 | GetOrders(); 56 | return mView; 57 | } 58 | private void GetOrders() { 59 | 60 | try { 61 | SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); 62 | String user_name = sharedPref.getString(getString(R.string.saved_login_name), null); 63 | if (user_name == null) { 64 | Snackbar.make(mMainView, "Login first", Snackbar.LENGTH_LONG) 65 | .setAction("No action", null).show(); 66 | return; 67 | } 68 | String proxy_ip = sharedPref.getString(getString(R.string.saved_proxy_ip), null); 69 | if (proxy_ip == null) { 70 | 71 | } 72 | 73 | JsonObject post_json = new JsonObject(); 74 | post_json.addProperty("Type", "Customer"); 75 | post_json.addProperty("Id", user_name); 76 | 77 | String [] params = {"order/get-orders/", "POST", post_json.toString()}; 78 | 79 | 80 | new RestClientTask() { 81 | protected void onPostExecute(String result) { 82 | try { 83 | JsonObject response_json = new JsonParser().parse(result).getAsJsonObject(); 84 | String result_string = response_json.get("Result").toString().replaceAll("\"", ""); 85 | if (result_string.equals("Success")) { 86 | String data_string = response_json.get("Data").toString(); 87 | JsonObject data_json = new JsonParser().parse(data_string).getAsJsonObject(); 88 | String status_string = data_json.get("result").toString().replaceAll("\"", ""); 89 | //{"GUID":"7a837981-4a1b-4a21-b226-8e2947d08e60","USERID":"jon","PRODUCT":"fcc6fe7b-1784-4f47-8efa-137b19a876ed", 90 | // "PRODUCTNAME":"Hot Laptop","PRICE":19.0,"ORDERSTATUS":1,"STOCKSTATUS":3,"CREDITSTATUS":2,"TIME":"2018-24-12 01:36:53","CREDIT":5.0,"STOCK":43} 91 | if (status_string.equals("Success")) { 92 | JsonArray orders_json = data_json.get("Data").getAsJsonArray(); 93 | for (int i = 0; i < orders_json.size(); ++i) { 94 | JsonObject next_order = orders_json.get(i).getAsJsonObject(); 95 | String Guid = next_order.get("GUID").getAsString(); 96 | String UserId = next_order.get("USERID").getAsString(); 97 | String ProductId = next_order.get("PRODUCT").getAsString(); 98 | String ProductName = next_order.get("PRODUCTNAME").getAsString(); 99 | Float Price = next_order.get("PRICE").getAsFloat(); 100 | int OrderStatus = next_order.get("ORDERSTATUS").getAsInt(); 101 | int StockStatus = next_order.get("STOCKSTATUS").getAsInt(); 102 | int CreditStatus = next_order.get("CREDITSTATUS").getAsInt(); 103 | String TimeString = next_order.get("TIME").getAsString(); 104 | Float Credit = next_order.get("CREDIT").getAsFloat(); 105 | int Stock = next_order.get("STOCK").getAsInt(); 106 | orders.add(new OrderModel( 107 | Guid, 108 | UserId, 109 | ProductId, 110 | ProductName, 111 | Price, 112 | OrderStatus, 113 | StockStatus, 114 | CreditStatus, 115 | TimeString, 116 | Stock, 117 | Credit 118 | 119 | )); 120 | } 121 | 122 | orders_adapter = new OrdersAdapter(orders, getActivity(), getView()); 123 | orders_listview = mView.findViewById(R.id.listview_orders); 124 | orders_listview.setAdapter(orders_adapter); 125 | } 126 | else { 127 | 128 | } 129 | Snackbar.make(mMainView, "GetOrders: " + status_string, Snackbar.LENGTH_LONG) 130 | .setAction("No action", null).show(); 131 | 132 | } 133 | else { 134 | Snackbar.make(mMainView, "GetOrders Fail " + result, Snackbar.LENGTH_LONG) 135 | .setAction("No action", null).show(); 136 | } 137 | } 138 | catch (Exception ex) { 139 | Snackbar.make(mMainView, "GetOrders Fail (execute)" + ex.getMessage(), Snackbar.LENGTH_LONG) 140 | .setAction("No action", null).show(); 141 | } 142 | 143 | 144 | } 145 | }.execute(params); 146 | } 147 | catch (Exception ex) { 148 | String hede = ex.getMessage(); 149 | 150 | } 151 | } 152 | 153 | 154 | @Override 155 | public void onDetach() { 156 | super.onDetach(); 157 | } 158 | 159 | 160 | } 161 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/java/msdemo/ayhan/com/ecommerce/ProductModel.java: -------------------------------------------------------------------------------- 1 | package msdemo.ayhan.com.ecommerce; 2 | 3 | public class ProductModel { 4 | int ID; 5 | String Code; 6 | String Name; 7 | String Description; 8 | String Supplier; 9 | String CategoryId; 10 | Float Price; 11 | int Stock; 12 | String CategoryName; 13 | 14 | public ProductModel(int ID, String Code, String Name, String Description, String Supplier, String CategoryId, Float Price, int Stock, String CategoryName) { 15 | this.ID = ID; 16 | this.Code = Code; 17 | this.Name = Name; 18 | this.Description = Description; 19 | this.Supplier = Supplier; 20 | this.CategoryId = CategoryId; 21 | this.Price = Price; 22 | this.Stock = Stock; 23 | this.CategoryName = CategoryName; 24 | } 25 | 26 | public String getName() { 27 | return Name; 28 | } 29 | public String getCode() { 30 | return Code; 31 | } 32 | public Float getPrice() { 33 | return Price; 34 | } 35 | public int getID() { 36 | return ID; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/java/msdemo/ayhan/com/ecommerce/ProductsAdapter.java: -------------------------------------------------------------------------------- 1 | package msdemo.ayhan.com.ecommerce; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.SharedPreferences; 6 | import android.graphics.Color; 7 | import android.support.design.widget.Snackbar; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.ArrayAdapter; 12 | import android.widget.Button; 13 | 14 | import android.widget.TextView; 15 | 16 | 17 | import com.google.gson.JsonObject; 18 | import com.google.gson.JsonParser; 19 | 20 | import java.util.ArrayList; 21 | 22 | public class ProductsAdapter extends ArrayAdapter { 23 | 24 | private ArrayList dataSet; 25 | Context mContext; 26 | View mView; 27 | 28 | // 1 29 | public ProductsAdapter(ArrayList data, Context context, View view) { 30 | super(context, R.layout.listview_products_row, data); 31 | this.dataSet = data; 32 | this.mContext=context; 33 | this.mView = view; 34 | 35 | } 36 | 37 | @Override 38 | public int getCount() { 39 | return dataSet.size(); 40 | } 41 | 42 | @Override 43 | public long getItemId(int position) { 44 | return dataSet.get(position).getID(); 45 | } 46 | 47 | @Override 48 | public ProductModel getItem(int position) { 49 | return dataSet.get(position); 50 | } 51 | 52 | 53 | @Override 54 | public View getView(int position, View convertView, ViewGroup parent) { 55 | LayoutInflater inflater = (LayoutInflater) mContext 56 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 57 | View rowView = inflater.inflate(R.layout.listview_products_row, parent, false); 58 | TextView txt_product_name = rowView.findViewById(R.id.txt_product_name); 59 | TextView txt_product_price = rowView.findViewById(R.id.txt_product_price); 60 | Button btn_product_price = rowView.findViewById(R.id.txt_product_buy); 61 | 62 | ProductModel item = dataSet.get(position); 63 | txt_product_name.setText(item.getName()); 64 | txt_product_price.setText(Float.toString(item.getPrice())); 65 | 66 | btn_product_price.setOnClickListener((View v) -> { 67 | //LinearLayout vwParentRow = (LinearLayout)v.getParent(); 68 | //TextView child = (TextView)vwParentRow.getChildAt(0); 69 | PlaceOrder(dataSet.get(position)); 70 | 71 | }); 72 | return rowView; 73 | } 74 | private void PlaceOrder(ProductModel product_item) { 75 | try { 76 | //json={"ProductId":id, "ProductName":name, "CustomerId":session['username'], "TimeStamp":time.strftime("%Y-%d-%m %H:%M:%S", time.localtime())}) 77 | SharedPreferences sharedPref = ((Activity)mContext).getPreferences(Context.MODE_PRIVATE); 78 | String user_name = sharedPref.getString(mContext.getString(R.string.saved_login_name), null); 79 | if (user_name == null) { 80 | Snackbar.make(mView, "Login first", Snackbar.LENGTH_LONG) 81 | .setAction("No action", null).show(); 82 | return; 83 | } 84 | java.util.Calendar calendar = java.util.Calendar.getInstance(); 85 | java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-dd-MM hh:mm:ss"); 86 | String formated_date = df.format(calendar.getTime()); 87 | 88 | 89 | JsonObject post_json = new JsonObject(); 90 | post_json.addProperty("ProductId", product_item.Code); 91 | post_json.addProperty("ProductName", product_item.Name); 92 | post_json.addProperty("CustomerId", user_name); 93 | post_json.addProperty("TimeStamp", formated_date); 94 | 95 | 96 | String [] params = {"order/place-order/", "POST", post_json.toString()}; 97 | 98 | 99 | new RestClientTask() { 100 | protected void onPostExecute(String result) { 101 | 102 | JsonObject response_json = new JsonParser().parse(result).getAsJsonObject(); 103 | String result_string = response_json.get("Result").toString().replaceAll("\"", ""); 104 | if (result_string.equals("Success")) { 105 | String data_string = response_json.get("Data").toString(); 106 | JsonObject data_json = new JsonParser().parse(data_string).getAsJsonObject(); 107 | String order_status = data_json.get("result").toString().replaceAll("\"", "");; 108 | if (order_status.equals("Success")) { 109 | //Do nothing 110 | Snackbar.make(mView, "Order Placed. Checking credit and stocks. Check My Orders to watch status", Snackbar.LENGTH_LONG) 111 | .setAction("No action", null).show(); 112 | } 113 | else { 114 | Snackbar.make(mView, "Order Place Fail: " + order_status, Snackbar.LENGTH_LONG) 115 | .setAction("No action", null).show(); 116 | } 117 | 118 | 119 | } 120 | else { 121 | Snackbar.make(mView, "Order Fail " + result, Snackbar.LENGTH_LONG) 122 | .setAction("No action", null).show(); 123 | } 124 | 125 | } 126 | }.execute(params); 127 | } 128 | catch (Exception ex) { 129 | 130 | } 131 | } 132 | 133 | } -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/java/msdemo/ayhan/com/ecommerce/ProductsFragment.java: -------------------------------------------------------------------------------- 1 | package msdemo.ayhan.com.ecommerce; 2 | 3 | import android.os.Bundle; 4 | import android.support.design.widget.Snackbar; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.AdapterView; 10 | import android.widget.GridView; 11 | import android.widget.ListView; 12 | import android.widget.Toast; 13 | 14 | import com.google.gson.JsonArray; 15 | import com.google.gson.JsonObject; 16 | import com.google.gson.JsonParser; 17 | 18 | import java.lang.reflect.Array; 19 | import java.util.ArrayList; 20 | 21 | 22 | public class ProductsFragment extends Fragment { 23 | 24 | ArrayList products = new ArrayList<>(); 25 | ListView products_listview; 26 | ProductsAdapter products_adapter; 27 | View mView; 28 | View mMainView; 29 | public ProductsFragment() { 30 | // Required empty public constructor 31 | } 32 | 33 | public static ProductsFragment newInstance() { 34 | ProductsFragment fragment = new ProductsFragment(); 35 | Bundle args = new Bundle(); 36 | 37 | fragment.setArguments(args); 38 | return fragment; 39 | } 40 | 41 | @Override 42 | public void onCreate(Bundle savedInstanceState) { 43 | super.onCreate(savedInstanceState); 44 | if (getArguments() != null) { 45 | 46 | } 47 | 48 | } 49 | 50 | @Override 51 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 52 | Bundle savedInstanceState) { 53 | mView = inflater.inflate(R.layout.fragment_products, container, false); 54 | mMainView = getActivity().findViewById(android.R.id.content); 55 | GetProducts(); 56 | return mView; 57 | } 58 | private void GetProducts() { 59 | 60 | try { 61 | String [] params = {"product/get-all-products/", "GET", ""}; 62 | 63 | 64 | new RestClientTask() { 65 | protected void onPostExecute(String result) { 66 | try { 67 | JsonObject response_json = new JsonParser().parse(result).getAsJsonObject(); 68 | String result_string = response_json.get("Result").toString().replaceAll("\"", ""); 69 | if (result_string.equals("Success")) { 70 | String data_string = response_json.get("Data").toString(); 71 | JsonObject data_json = new JsonParser().parse(data_string).getAsJsonObject(); 72 | String status_string = data_json.get("result").toString(); 73 | JsonObject status_json = new JsonParser().parse(status_string).getAsJsonObject(); 74 | String register_status = status_json.get("Status").toString().replaceAll("\"", ""); 75 | if (register_status.equals("Success")) { 76 | //String products_string = status_json.get("Products").toString().replaceAll("\"", ""); 77 | JsonArray products_json = status_json.get("Products").getAsJsonArray(); 78 | for (int i = 0; i < products_json.size(); ++i) { 79 | JsonArray next_product = products_json.get(i).getAsJsonArray(); 80 | Integer product_id = next_product.get(0).getAsInt(); 81 | String product_code = next_product.get(1).toString().replaceAll("\"", "");; 82 | String product_name = next_product.get(2).toString().replaceAll("\"", "");; 83 | String product_description = next_product.get(3).toString().replaceAll("\"", "");; 84 | String product_supplier = next_product.get(4).toString().replaceAll("\"", "");; 85 | String product_category_code = next_product.get(5).toString().replaceAll("\"", "");; 86 | Float product_price = next_product.get(6).getAsFloat(); 87 | Integer product_stock = next_product.get(7).getAsInt(); 88 | String product_category_name = next_product.get(8).toString().replaceAll("\"", "");; 89 | products.add(new ProductModel( 90 | product_id, 91 | product_code, 92 | product_name, 93 | product_description, 94 | product_supplier, 95 | product_category_code, 96 | product_price, 97 | product_stock, 98 | product_category_name)); 99 | 100 | 101 | } 102 | 103 | products_adapter = new ProductsAdapter(products, getActivity(), getView()); 104 | products_listview = mView.findViewById(R.id.listview_products); 105 | products_listview.setAdapter(products_adapter); 106 | } 107 | else { 108 | 109 | } 110 | Snackbar.make(mMainView, "GetProducts: " + register_status, Snackbar.LENGTH_LONG) 111 | .setAction("No action", null).show(); 112 | 113 | } 114 | else { 115 | Snackbar.make(mMainView, "GetProducts Fail " + result, Snackbar.LENGTH_LONG) 116 | .setAction("No action", null).show(); 117 | } 118 | } 119 | catch (Exception ex) { 120 | 121 | } 122 | 123 | 124 | } 125 | }.execute(params); 126 | } 127 | catch (Exception ex) { 128 | 129 | } 130 | } 131 | 132 | 133 | @Override 134 | public void onDetach() { 135 | super.onDetach(); 136 | } 137 | 138 | 139 | } 140 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/java/msdemo/ayhan/com/ecommerce/RegisterFragment.java: -------------------------------------------------------------------------------- 1 | package msdemo.ayhan.com.ecommerce; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.os.Bundle; 6 | import android.support.design.widget.Snackbar; 7 | import android.support.v4.app.Fragment; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.Button; 12 | import android.widget.EditText; 13 | 14 | import com.google.gson.JsonObject; 15 | import com.google.gson.JsonParser; 16 | 17 | import org.json.JSONObject; 18 | 19 | 20 | public class RegisterFragment extends Fragment { 21 | Button btn_register; 22 | EditText txt_username; 23 | EditText txt_fullname; 24 | EditText txt_password; 25 | EditText txt_email; 26 | View mView; 27 | View mMainView; 28 | 29 | public RegisterFragment() { 30 | // Required empty public constructor 31 | } 32 | 33 | public static RegisterFragment newInstance() { 34 | RegisterFragment fragment = new RegisterFragment(); 35 | Bundle args = new Bundle(); 36 | 37 | fragment.setArguments(args); 38 | return fragment; 39 | } 40 | 41 | @Override 42 | public void onCreate(Bundle savedInstanceState) { 43 | super.onCreate(savedInstanceState); 44 | if (getArguments() != null) { 45 | 46 | } 47 | } 48 | 49 | @Override 50 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 51 | Bundle savedInstanceState) { 52 | mView = inflater.inflate(R.layout.fragment_register, container, false); 53 | mMainView = getActivity().findViewById(android.R.id.content); 54 | 55 | txt_username = mView.findViewById(R.id.txt_user_name); 56 | txt_password = mView.findViewById(R.id.txt_password); 57 | txt_fullname = mView.findViewById(R.id.txt_full_name); 58 | txt_email = mView.findViewById(R.id.txt_email); 59 | btn_register = mView.findViewById(R.id.btn_register); 60 | 61 | btn_register.setOnClickListener((View v) -> { 62 | OnRegisterClick(v); 63 | }); 64 | 65 | 66 | return mView; 67 | } 68 | private void OnRegisterClick(View view) { 69 | String user_name = txt_username.getText().toString(); 70 | String password = txt_password.getText().toString(); 71 | String full_name = txt_fullname.getText().toString(); 72 | String email = txt_email.getText().toString(); 73 | 74 | try { 75 | /*String jsonString = new JSONObject() 76 | .put("UserName", user_name) 77 | .put("Password", password).toString();*/ 78 | JsonObject post_json = new JsonObject(); 79 | post_json.addProperty("UserName", user_name); 80 | post_json.addProperty("Password", password); 81 | post_json.addProperty("FullName", full_name); 82 | post_json.addProperty("Email", email); 83 | post_json.addProperty("Credit", 100); 84 | 85 | String [] params = {"customer/add-user/", "POST", post_json.toString()}; 86 | 87 | 88 | new RestClientTask() { 89 | protected void onPostExecute(String result) { 90 | 91 | JsonObject response_json = new JsonParser().parse(result).getAsJsonObject(); 92 | String result_string = response_json.get("Result").toString().replaceAll("\"", ""); 93 | if (result_string.equals("Success")) { 94 | String data_string = response_json.get("Data").toString(); 95 | JsonObject data_json = new JsonParser().parse(data_string).getAsJsonObject(); 96 | String status_string = data_json.get("result").toString(); 97 | JsonObject status_json = new JsonParser().parse(status_string).getAsJsonObject(); 98 | String register_status = status_json.get("Status").toString().replaceAll("\"", ""); 99 | if (register_status.equals("Success")) { 100 | //Not doing anything special 101 | } 102 | else { 103 | 104 | } 105 | Snackbar.make(mView, "Register: " + register_status, Snackbar.LENGTH_LONG) 106 | .setAction("No action", null).show(); 107 | 108 | } 109 | else { 110 | Snackbar.make(mView, "Register Fail " + result, Snackbar.LENGTH_LONG) 111 | .setAction("No action", null).show(); 112 | } 113 | 114 | } 115 | }.execute(params); 116 | } 117 | catch (Exception ex) { 118 | 119 | } 120 | } 121 | 122 | @Override 123 | public void onDetach() { 124 | super.onDetach(); 125 | } 126 | 127 | 128 | } 129 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/java/msdemo/ayhan/com/ecommerce/RestClientTask.java: -------------------------------------------------------------------------------- 1 | package msdemo.ayhan.com.ecommerce; 2 | 3 | import android.os.AsyncTask; 4 | import android.preference.PreferenceManager; 5 | 6 | import com.google.gson.JsonObject; 7 | import com.google.gson.JsonParser; 8 | import java.io.BufferedReader; 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | import java.io.InputStreamReader; 12 | import java.net.HttpURLConnection; 13 | import java.net.URL; 14 | 15 | 16 | public class RestClientTask extends AsyncTask 17 | { 18 | 19 | @Override 20 | protected void onPreExecute() { 21 | super.onPreExecute(); 22 | 23 | 24 | } 25 | @Override 26 | protected String doInBackground(String... params) { 27 | 28 | String proxy_address = MainActivity.proxy_server_ip; 29 | JsonObject return_object = new JsonObject(); 30 | HttpURLConnection service_connection = null; 31 | try { 32 | String endpoint_address = String.format("%s/%s", proxy_address, params[0]); 33 | URL reverse_proxy_endpoint = new URL(endpoint_address); 34 | service_connection = (HttpURLConnection) reverse_proxy_endpoint.openConnection(); 35 | service_connection.setRequestMethod(params[1]); 36 | service_connection.setDoInput(true); 37 | service_connection.setRequestProperty("Content-Type", "application/json"); 38 | service_connection.setRequestProperty("Accept", "application/json"); 39 | if (params[1].equals("POST")) { 40 | String post_json = params[2]; 41 | service_connection.setDoOutput(true); 42 | service_connection.getOutputStream().write(post_json.getBytes()); 43 | } 44 | int response_code = service_connection.getResponseCode(); 45 | if (response_code == 200) { 46 | InputStream responseBody = service_connection.getInputStream(); 47 | String data = Convert(responseBody); 48 | return_object.addProperty("Result", "Success"); 49 | return_object.add("Data", new JsonParser().parse(data).getAsJsonObject()); 50 | 51 | } else { 52 | return_object.addProperty("Result", "Fail"); 53 | return_object.addProperty("Data", response_code); 54 | 55 | } 56 | 57 | } 58 | catch (Exception ex) { 59 | return_object.addProperty("Result", "Fail"); 60 | return_object.addProperty("Data", ex.getMessage()); 61 | 62 | } 63 | finally { 64 | if (service_connection != null) 65 | service_connection.disconnect(); 66 | 67 | } 68 | 69 | return return_object.toString(); 70 | } 71 | public String Convert(InputStream inputStream) throws IOException { 72 | 73 | StringBuilder stringBuilder = new StringBuilder(); 74 | String line = null; 75 | 76 | try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"))) { 77 | while ((line = bufferedReader.readLine()) != null) { 78 | stringBuilder.append(line); 79 | } 80 | } 81 | 82 | return stringBuilder.toString(); 83 | } 84 | @Override 85 | protected void onPostExecute(String result) { 86 | super.onPostExecute(result); 87 | 88 | } 89 | 90 | 91 | } -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/java/msdemo/ayhan/com/ecommerce/SettingsFragment.java: -------------------------------------------------------------------------------- 1 | package msdemo.ayhan.com.ecommerce; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.os.Bundle; 6 | import android.support.design.widget.Snackbar; 7 | import android.support.v4.app.Fragment; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.Button; 12 | import android.widget.EditText; 13 | 14 | import com.google.gson.JsonObject; 15 | import com.google.gson.JsonParser; 16 | 17 | 18 | public class SettingsFragment extends Fragment { 19 | Button btn_save; 20 | EditText txt_proxy_ip; 21 | View mView; 22 | View mMainView; 23 | 24 | public SettingsFragment() { 25 | // Required empty public constructor 26 | } 27 | 28 | public static SettingsFragment newInstance() { 29 | SettingsFragment fragment = new SettingsFragment(); 30 | Bundle args = new Bundle(); 31 | 32 | fragment.setArguments(args); 33 | return fragment; 34 | } 35 | 36 | @Override 37 | public void onCreate(Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | if (getArguments() != null) { 40 | 41 | } 42 | } 43 | 44 | @Override 45 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 46 | Bundle savedInstanceState) { 47 | mView = inflater.inflate(R.layout.fragment_settings, container, false); 48 | mMainView = getActivity().findViewById(android.R.id.content); 49 | 50 | txt_proxy_ip = mView.findViewById(R.id.txt_proxy_ip); 51 | btn_save = mView.findViewById(R.id.save_settings_button); 52 | 53 | SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); 54 | String proxy_ip = sharedPref.getString(getString(R.string.saved_proxy_ip), null); 55 | if (proxy_ip != null) 56 | txt_proxy_ip.setText(proxy_ip); 57 | 58 | 59 | btn_save.setOnClickListener((View v) -> { 60 | SharedPreferences.Editor editor = sharedPref.edit(); 61 | editor.putString(getString(R.string.saved_proxy_ip), txt_proxy_ip.getText().toString()); 62 | editor.commit(); 63 | MainActivity.proxy_server_ip = txt_proxy_ip.getText().toString(); 64 | Snackbar.make(mMainView, "Settings Saved", Snackbar.LENGTH_LONG) 65 | .setAction("No action", null).show(); 66 | }); 67 | 68 | 69 | return mView; 70 | } 71 | 72 | 73 | @Override 74 | public void onDetach() { 75 | super.onDetach(); 76 | } 77 | 78 | 79 | } 80 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/drawable/buttonshape.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 15 | 16 | 20 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/drawable/ic_login.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/drawable/ic_logout.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/drawable/ic_menu_send.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/drawable/ic_myinfo.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/drawable/ic_orders.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/drawable/ic_products.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/drawable/ic_register.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/drawable/simplicity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayhanavci/Microservices/c69808a8676982c67e70d7e56a7653ed4c6cffdf/consumers/android_ecommerce/app/src/main/res/drawable/simplicity.png -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/drawable/text_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/layout/app_bar_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/layout/fragment_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | 24 | 30 | 37 | 43 | 50 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/layout/nav_header_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 22 | 23 | 29 | 30 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/menu/activity_main_drawer.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 13 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayhanavci/Microservices/c69808a8676982c67e70d7e56a7653ed4c6cffdf/consumers/android_ecommerce/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayhanavci/Microservices/c69808a8676982c67e70d7e56a7653ed4c6cffdf/consumers/android_ecommerce/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayhanavci/Microservices/c69808a8676982c67e70d7e56a7653ed4c6cffdf/consumers/android_ecommerce/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayhanavci/Microservices/c69808a8676982c67e70d7e56a7653ed4c6cffdf/consumers/android_ecommerce/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayhanavci/Microservices/c69808a8676982c67e70d7e56a7653ed4c6cffdf/consumers/android_ecommerce/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayhanavci/Microservices/c69808a8676982c67e70d7e56a7653ed4c6cffdf/consumers/android_ecommerce/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayhanavci/Microservices/c69808a8676982c67e70d7e56a7653ed4c6cffdf/consumers/android_ecommerce/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayhanavci/Microservices/c69808a8676982c67e70d7e56a7653ed4c6cffdf/consumers/android_ecommerce/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayhanavci/Microservices/c69808a8676982c67e70d7e56a7653ed4c6cffdf/consumers/android_ecommerce/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayhanavci/Microservices/c69808a8676982c67e70d7e56a7653ed4c6cffdf/consumers/android_ecommerce/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | #bbe7de 7 | #43ABC9 8 | 9 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 8dp 6 | 176dp 7 | 16dp 8 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Ecommerce 3 | Open navigation drawer 4 | Close navigation drawer 5 | Microservices Demo 6 | ayhanavci@gmail.com 7 | Navigation header 8 | Settings 9 | Please enter your credentials 10 | User Name 11 | Password 12 | Sign In 13 | Full Name 14 | Email 15 | Register 16 | Buy 17 | login_name 18 | proxy_ip 19 | login_password 20 | Save Settings 21 | Proxy IP 22 | Please enter server ip address 23 | 24 | 25 | Hello blank fragment 26 | 27 | -------------------------------------------------------------------------------- /consumers/android_ecommerce/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |