public static InstallationCreateCommand FromResponse(GetInstallationsNearestResponse response)
 => InstallationCreateCommand.Create(
     response.Id,
     response.Airly,
     LocationAdapter.FromResponse(response),
     AddressAdapter.FromResponse(response.Address),
     SponsorAdapter.FromResponse(response.Sponsor));
Ejemplo n.º 2
0
 public FTPLocation(LocationSwitchboard listener) : this()
 {
     InitializeComponent();
     this.listener      = listener;
     adapter            = new LocationAdapter();
     adapter.SaveError += onSaveErrorHandler;
     adapter.TestConnectionComplete += onTestConnectionCompleteHandler;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Call this constructor to load FTPconfig into the components
 /// </summary>
 /// <param name="listener">The Location switchboard instance</param>
 /// <param name="isEditor">If true on save it will try to update the save location when Save is clicked else it will try to insert</param>
 /// <param name="ftplocation">DataRow from backup_locations table that contains the ftp location to load</param>
 public FTPLocation(LocationSwitchboard listener, bool isEditor, DataRow ftplocation) : this()
 {
     InitializeComponent();
     this.listener      = listener;
     this.isEditor      = isEditor;
     this.ftplocation   = ftplocation;
     doLoadConfig       = true;
     adapter            = new LocationAdapter();
     adapter.SaveError += onSaveErrorHandler;
     adapter.TestConnectionComplete += onTestConnectionCompleteHandler;
 }
        private void OnSerachChange(object sender, SearchView.QueryTextChangeEventArgs e)
        {
            var dataset = locationDb.GetLocationsAsync().Result;

            if (string.IsNullOrWhiteSpace(e.NewText))
            {
                LocationAdapter myAdapter = new LocationAdapter(this, dataset);
                listView.Adapter = myAdapter;
            }
            else
            {
                LocationAdapter myAdapter = new LocationAdapter(this, dataset.Where(us => us.Name.ToLower().StartsWith(e.NewText.ToLower())).ToList());
                listView.Adapter = myAdapter;
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // check if user is login
            if (App.username == null)
            {
                Intent ints = new Intent(this, typeof(LoginActivity));
                StartActivity(ints);
            }

            SetContentView(Resource.Layout.locationPage);

            // on logout button click
            FindViewById <Button>(Resource.Id.btnLocationLogout)
            .Click += (s, arg) =>
            {
                App.username = null;
                Intent ints = new Intent(this, typeof(LoginActivity));
                StartActivity(ints);
            };

            // on checkout button click
            FindViewById <Button>(Resource.Id.btnLoactionCheckout)
            .Click += (s, arg) =>
            {
                Intent ints = new Intent(this, typeof(CheckoutActivity));
                StartActivity(ints);
            };

            // Create your application here
            locationDb = new LocationDataBase(SharedHelper.DbPath);

            //var checkout = FindViewById<>(Resource.Id.checkout);
            listView    = FindViewById <ListView>(Resource.Id.listView1);
            searchView1 = FindViewById <SearchView>(Resource.Id.searchView1);

            LocationAdapter lp = new LocationAdapter(this, locationDb.GetLocationsAsync().Result);

            listView.Adapter             = lp;
            listView.ItemClick          += OnListClicked;
            searchView1.QueryTextChange += OnSerachChange;
        }
Ejemplo n.º 6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.checkout);
            // initialize databases
            trDb  = new TravelingLocationDataBase(SharedHelper.DbPath);
            locDb = new LocationDataBase(SharedHelper.DbPath);

            //  get resource variables
            listViewCheckout = FindViewById <ListView>(Resource.Id.listViewCheckout);
            txtTotalPrice    = FindViewById <TextView>(Resource.Id.txtTotalPrice);

            // add value to list adapter
            var travelLocation = trDb.GetTravelLocationByUserIdAsync(App.username).Result;

            if (travelLocation.Count <= 0)
            {
                new MessageHelper().alertFunction("Error", "Please select the locations", this);
                Intent ints = new Intent(this, typeof(LocationActivity));
                StartActivity(ints);
            }

            List <Location> selectedLoc = new List <Location>();

            for (int trvLoc = 0; trvLoc < travelLocation.Count; trvLoc++)
            {
                selectedLoc.Add(locDb.GetLocationAsync(travelLocation[trvLoc].LocationId).Result);
            }
            LocationAdapter lp = new LocationAdapter(this, selectedLoc);

            listViewCheckout.Adapter    = lp;
            listViewCheckout.ItemClick += OnListClicked;

            // calculate total price
            txtTotalPrice.Text = selectedLoc.Select(sa => sa.Price).Sum().ToString();
        }
Ejemplo n.º 7
0
        public Guid Insert(ModelDTO modelDto)
        {
            var model = LocationAdapter.ToDomain(modelDto);

            return(locationRepository.Insert(model));
        }
Ejemplo n.º 8
0
        public void startImport()
        {
            if (isLocal)
            {
                if (!File.Exists(path + filename))
                {
                    onImportError("File doesnt exist, path: " + path);
                    return;
                }
                templocalpath     = path;
                templocalfilename = filename;
                startDecompression();
            }
            else
            {
                //set config
                locationadapter               = new LocationAdapter();
                locationadapter.Progress     += downloadProgressHandler;
                locationadapter.SaveComplete += downloadCompleteHandler;
                locationadapter.SaveError    += downloadErrorHandler;
                LocationCredentialsConfig config;
                templocalpath = ConfigurationManager.getInstance().mysqlDumpConfigInstance.getSettings().tempSavePath;
                //calculate local path
                if (!File.Exists(path + filename))
                {
                    templocalfilename = filename;
                }
                else
                {
                    Random rnd       = new Random();
                    string extension = StringUtils.getExtension(filename);
                    templocalfilename = "Temp" + rnd.Next(1000000, 9999999) + extension;

                    Directory.CreateDirectory(templocalpath);


                    //checking if file exists
                    while (File.Exists(templocalpath + templocalfilename))
                    {
                        templocalfilename = "Temp" + rnd.Next(1000000, 9999999) + extension;
                    }
                }
                try
                {
                    long type = (Int64)locationdata["service_type"];
                    switch (type) //edw gemizei to config apo to database prepei na kanei diaforetiko query gia kathe diaforetiko type kai na gemisei to config prin to settarei ston adapter
                    {
                    case 0:       //file system
                        //De ginete na einai file system kai na erthei edw
                        break;

                    case 1:     //FTP
                        config              = new FTPCredentialsConfig();
                        config.sourcePath   = path + filename;
                        config.locationPath = templocalpath + templocalfilename;
                        ((FTPCredentialsConfig)config).id   = (Int64)locationdata["id"];
                        ((FTPCredentialsConfig)config).host = (string)locationdata["host"];
                        config.port     = unchecked ((int)(Int64)locationdata["port"]);
                        config.username = (string)locationdata["username"];
                        config.password = EncryptionUtils.sDecrypt((string)locationdata["password"]);
                        Int64 useSFTP = (Int64)locationdata["usesftp"];
                        if (useSFTP == 1)
                        {
                            ((FTPCredentialsConfig)config).useSFTP = true;
                            ((FTPCredentialsConfig)config).SshHostKeyFingerprint = (string)locationdata["ssh_key_fingerprint"];
                        }
                        string keypath = (string)locationdata["ssh_key"];
                        if (!string.IsNullOrEmpty(keypath))
                        {
                            ((FTPCredentialsConfig)config).usePrivateKey  = true;
                            ((FTPCredentialsConfig)config).privateKeyPath = keypath;
                        }
                        locationadapter.setFtpLocation(config);
                        break;

                    case 2:     //Dropbox
                        DropBoxCredentials boxcreds = new DropBoxCredentials();
                        //EDW SETUP TO CONFIG
                        locationadapter.setCloudBoxLocation(boxcreds);
                        break;

                    case 3:     //Google drive
                        config = new LocationCredentialsConfig();
                        //EDW SETUP TO CONFIG
                        locationadapter.setCloudDriveLocation(config);
                        break;

                    default:
                        onImportError("Location type unknown");
                        return;
                    }

                    onInnerProccessInit(Convert.ToInt32(type), 100);
                    locationadapter.getFile();
                }
                catch (InvalidCastException ex)
                {
                    onImportError("Save location data load failed:\n" + ex.Message);
                }
            }
        }