public static void UpdatInternalClientByParameter(InternalClientProperties Property, object Value, string ClientID)
        {
            InternalClient client = null;

            using (var db = new LiteDatabase(AppKeys.GetDataContextString()))
            {
                var clients = db.GetCollection <InternalClient>("clients");
                client = clients.Find(x => x.clientID == ClientID).FirstOrDefault();
                if (client != null)
                {
                    var value = new object();
                    if (Property == InternalClientProperties.ClientStyles)
                    {
                        value = (List <InternalClientStyle>)Value;
                    }
                    else
                    {
                        value = Value.ToString();
                    }

                    client.GetType().GetProperty(Property.ToString()).SetValue(client, value);
                    clients.Update(client);
                }
            }
        }
        /// <summary>
        /// Returns true if new InternalClient is created. Returns false if InternalClient with ClientID is found
        /// </summary>
        /// <param name="ClientID"></param>
        /// <param name="ClientName"></param>
        /// <returns></returns>
        public static bool CreateInternalClient(string ClientID, string ClientName)
        {
            try
            {
                using (var db = new LiteDatabase(AppKeys.GetDataContextString()))
                {
                    var clients = db.GetCollection <InternalClient>("clients");

                    var newclient = clients.Find(x => x.clientID == ClientID).FirstOrDefault();
                    if (newclient == null)
                    {
                        newclient            = new InternalClient();
                        newclient.clientID   = ClientID;
                        newclient.clientName = ClientName;

                        clients.Insert(newclient);
                        clients.EnsureIndex(x => x.clientID);

                        return(true);
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An Error has happened in the CreateInternalClient Method : {0}", ex.ToString());
                return(false);
            }
        }
Пример #3
0
 protected override System.Data.Common.DbConnection getDbConnection(
     string connectionString,
     bool fromConfig)
 {
     try
     {
         SqlConnection sqlConnection = new SqlConnection(connectionString);
         if (fromConfig)
         {
             if (AppKeys.GetKey("validateDbConnection") == "true")
             {
                 this.validateConnection(sqlConnection.ConnectionString);
             }
         }
         else
         {
             this.validateConnection(sqlConnection.ConnectionString);
         }
         return((System.Data.Common.DbConnection)sqlConnection);
     }
     catch (HADataException ex)
     {
         throw ex;
     }
     catch (System.Exception ex)
     {
         throw new HADataException(ex.Message);
     }
 }
 public EmailService(IOptions <AppKeys> appKeys, IWebHostEnvironment env, IAuthenticationService <int> authService, IConfiguration config)
 {
     _appKeys     = appKeys.Value;
     _env         = env;
     _authService = authService;
     _config      = config;
 }
Пример #5
0
 public PaymentsApiController(IStripeCustomerService service, ILogger <PaymentsApiController> logger, IAuthenticationService <int> authService, IOptions <AppKeys> appKeys) : base(logger)
 {
     _appKeys     = appKeys.Value;
     _service     = service;
     _authService = authService;
     StripeConfiguration.ApiKey = _appKeys.StripeApiKey;
 }
Пример #6
0
 public ConnectApiController(IStripeConnectService service, ILogger <ConnectApiController> logger, IAuthenticationService <int> authService, IOptions <AppKeys> appKeys) : base(logger)
 {
     _service     = service;
     _authService = authService;
     _appKeys     = appKeys.Value;
     _client      = new StripeClient(_appKeys.StripeApiKey);
 }
Пример #7
0
        public static List <CountryShippingMethod> GetAllCountryShippingMethod()
        {
            using (var db = new LiteDatabase(AppKeys.GetDataContextString()))
            {
                var countries = db.GetCollection <CountryShippingMethod>("countries");

                return(countries.FindAll().ToList());
            }
        }
Пример #8
0
        public static CountryShippingMethod GetCountryShippingMethodByCountry(string Country)
        {
            CountryShippingMethod country = null;

            using (var db = new LiteDatabase(AppKeys.GetDataContextString()))
            {
                var countries = db.GetCollection <CountryShippingMethod>("countries");
                country = countries.Find(x => x.Country == Country).FirstOrDefault();
            }


            return(country);
        }
Пример #9
0
        public static void RegisterHotKeys(AppKeys appKeys)
        {
            UnregisterAllHotKeys();

            RegisterHotKey(HotKeys.Exit, appKeys.Exit);
            RegisterHotKey(HotKeys.LifeCycle, appKeys.LifeCycle);
            RegisterHotKey(HotKeys.OpenUi, appKeys.OpenUi);
            RegisterHotKey(HotKeys.OpenTurboHud, appKeys.OpenTurboHud);

            RegisterHotKey(HotKeys.Cube, appKeys.Cube);
            RegisterHotKey(HotKeys.Destroy, appKeys.Destroy);
            RegisterHotKey(HotKeys.Clicker, appKeys.Clicker);
            RegisterHotKey(HotKeys.LeftAutoRepeat, appKeys.LeftAutoRepeat);
            RegisterHotKey(HotKeys.RightAutoRepeat, appKeys.RightAutoRepeat);
        }
 public static List <InternalClient> GetAllInternalClients()
 {
     try
     {
         using (var db = new LiteDatabase(AppKeys.GetDataContextString()))
         {
             var clients = db.GetCollection <InternalClient>("clients");
             return(clients.FindAll().ToList());
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("An Error has happened in the GetAllInternalClients Method : {0}", ex.ToString());
         return(null);
     }
 }
 public static InternalClient GetInternalClientByEtsyID(string EtsyID)
 {
     try
     {
         using (var db = new LiteDatabase(AppKeys.GetDataContextString()))
         {
             var clients = db.GetCollection <InternalClient>("clients");
             return(clients.Find(x => x.EtsyID == EtsyID).FirstOrDefault());
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("An Error has happened in the GetInternalClientByEtsyID Method : {0}", ex.ToString());
         return(null);
     }
 }
Пример #12
0
        public Listing GetListing(RestClient RestClient, string listingid)
        {
            Listing listing = new Listing();

            RestRequest request = new RestRequest();

            request.Resource = string.Format("listings/{1}?method=GET&api_key={0}", AppKeys.GetApiKey(), listingid);
            IRestResponse response = RestClient.Execute(request);
            JObject       o        = JObject.Parse(response.Content);

            listing = JsonConvert.DeserializeObject <Listing>(o["results"][0].ToString());

            GetListingVariations(RestClient, listing);

            return(listing);
        }
        public static bool UpdateInternalClient(InternalClient Client)
        {
            try
            {
                using (var db = new LiteDatabase(AppKeys.GetDataContextString()))
                {
                    var clients  = db.GetCollection <InternalClient>("clients");
                    var dbclient = clients.Find(x => x.clientID == Client.clientID).FirstOrDefault();

                    //if there is no clientID and no clientName it's not a valid client to update from
                    if (!string.IsNullOrEmpty(Client.clientID) && !string.IsNullOrEmpty(Client.clientName))
                    {
                        //if it is not in the database add it
                        if (dbclient == null)
                        {
                            dbclient            = new InternalClient();
                            dbclient.clientID   = Client.clientID;
                            dbclient.clientName = Client.clientName;

                            clients.Insert(dbclient);
                            clients.EnsureIndex(x => x.clientID);
                        }

                        //never update the client ID or client name after the item has been created.
                        dbclient.EtsyID          = Client.EtsyID;
                        dbclient.EtsyUserName    = Client.EtsyUserName;
                        dbclient.AccessToken     = Client.AccessToken;
                        dbclient.AccessSecretKey = Client.AccessSecretKey;
                        dbclient.ClientStyles    = Client.ClientStyles;
                        dbclient.ClientDesigns   = Client.ClientDesigns;
                        dbclient.EtsyShopIDs     = Client.EtsyShopIDs;
                        clients.Update(dbclient);

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An Error has happened in the GetInternalClientByID Method : {0}", ex.ToString());
                return(false);
            }
            return(false);
        }
Пример #14
0
        /// <summary>
        /// Returns true if new CountryShippingMethod is created. Returns false if CountryShippingMethod with Country is found
        /// </summary>
        /// <param name="ClientID"></param>
        /// <param name="ClientName"></param>
        /// <returns></returns>
        public static bool CreateCountyShippingMethod(string Country, string ShippingMethod)
        {
            using (var db = new LiteDatabase(AppKeys.GetDataContextString()))
            {
                var countries = db.GetCollection <CountryShippingMethod>("countries");

                var newcountry = countries.Find(x => x.Country == Country).FirstOrDefault();
                if (newcountry == null)
                {
                    newcountry                 = new CountryShippingMethod();
                    newcountry.Country         = Country;
                    newcountry.Shipping_Method = ShippingMethod;

                    countries.Insert(newcountry);
                    countries.EnsureIndex(x => x.Country);

                    return(true);
                }
            }
            return(false);
        }
 public RedisClient(IOptions <AppKeys> value)
 {
     classname = value.Value;
 }
Пример #16
0
 public UserService(IAuthenticationService <int> authSerice, IDataProvider dataProvider, IOptions <AppKeys> appKeys)
 {
     _authenticationService = authSerice;
     _dataProvider          = dataProvider;
     _appKeys = appKeys.Value;
 }
Пример #17
0
 public EmailService(IOptions <AppKeys> apiKey)
 {
     _apiKey = apiKey.Value;
 }
Пример #18
0
 public SendGridService(IOptions <AppKeys> appKeys)
 {
     _appKeys   = appKeys.Value;
     _directory = Directory.GetCurrentDirectory();
 }
Пример #19
0
 public RESTClient(AppKeys appKeys)
 {
     Client = new HttpClient();
     ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
     Client.BaseAddress = new Uri($"{appKeys.BackendUrl}/");
 }
Пример #20
0
 public EmailService(IOptions <AppKeys> appKeys, IWebHostEnvironment env, IConfiguration config)/*pss in instance of dataprovider*/
 {
     _appKeys = appKeys.Value;
     _env     = env;
     _config  = config;
 }
Пример #21
0
        static void Main(string[] args)
        {
            //Just here for the purposes of alpha prototype stuff
            //UserService US = new UserService();
            //User ushi = US.GetUser(client, "ushi84", true, false);
            const string consumerKey       = "";
            const string consumerSecret    = "";
            const string accessToken       = "";
            const string accessTokenSecret = "";



            var client = new RestClient();

            client.BaseUrl       = AppKeys.GetBaseUri();
            client.Authenticator = OAuth1Authenticator.ForProtectedResource(consumerKey, consumerSecret, accessToken, accessTokenSecret);
            ShopService    SS         = new ShopService();
            ListingService LS         = new ListingService();
            UserService    US         = new UserService();
            var            Company    = InternalClientService.GetInternalClientByID("646");
            bool           consoleApp = false;

            if (consoleApp)
            {
                //RestRequest request = new RestRequest("/oauth/scopes", Method.GET);
                //IRestResponse response = client.Execute(request);
                //JObject oq = JObject.Parse(response.Content);
                //Console.WriteLine(oq.ToString());
                var command = Console.ReadLine();
                var user    = US.GetUser(client, "threadedtees", true, false);


                if (command.ToLower() == "getlistings")
                {
                    RestRequest request = new RestRequest();
                    request.Resource = string.Format("/taxonomy/seller/get");
                    IRestResponse response = client.Execute(request);
                    JObject       o        = JObject.Parse(response.Content);
                    Console.WriteLine(o.ToString());

                    LS.ImportListing(client);

                    Authorization.GetAccessToken();

                    var listings = SS.GetShopListings(client, Company.EtsyShopIDs.First());
                    //listring id
                    //title
                    //variation name
                    //variation value

                    ExportHelpers.ExportListingIdAndVariations(user.shops.FirstOrDefault().listings, @"C:\Internal\Etsy\ListingIdAndVariation.txt", true);
                }
                if (command.ToLower() == "createlistings")
                {
                    ListingHelper.CreateEtsyListingFromCustomMapping(client, Company, @"C:\Internal\Etsy\CalculatedFailure_FirstTest_Amazon_Feed.txt");
                }
                #region Listing Tool Code

                #endregion

                if (command.ToLower() == "download")
                {
                    string path = @"C:\Internal\Etsy.txt";

                    var receipts = SS.GetOpenShopReceipts(client, Company.EtsyShopIDs.FirstOrDefault());
                    Console.WriteLine("Exporting...");
                    ExportHelpers.ExtractionExport(receipts, path, CountryService.GetCountryMapping(client), true);
                    Console.Write("Export Complete");
                }

                if (command.ToLower() == "upload")
                {
                    ImportHelpers.ShippingSummaries();
                    Console.Write("Upload Complete");
                    Console.ReadLine();
                }
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new DownloadUploadForm());
            }


            #region Listing Creation Stuff

            #endregion
        }
Пример #22
0
 public EmailService(IOptions <AppKeys> appKeys, IWebHostEnvironment env)
 {
     _appKeys = appKeys.Value;
     _env     = env;
 }
 public EmailAPIController(IEmailService emailServices, IOptions <AppKeys> appKeys, ILogger <EmailAPIController> logger) : base(logger)
 {
     _emailService = emailServices;
     _appKeys      = appKeys.Value;
 }
Пример #24
0
        public static List <ExtractionModel> CreateExtractionFromReceipt(InternalClient GClient, bool allReceipts)
        {
            //Creation New Rest Client
            var client = new RestClient();

            client.BaseUrl       = AppKeys.GetBaseUri();
            client.Authenticator = OAuth1Authenticator.ForProtectedResource(AppKeys.GetApiKey(), AppKeys.GetSharedSecretKey(), GClient.AccessToken, GClient.AccessSecretKey);

            //The shop servce is where we pull receipts because functionally
            //The call is related to the shop object and te shop id
            ShopService    shopservice = new ShopService();
            List <Receipt> receipts;

            //This is just in case for some reason we want every transaction from a shop
            if (allReceipts)
            {
                receipts = shopservice.GetShopReceipts(client, GClient.EtsyShopIDs.FirstOrDefault());
            }
            else
            {
                receipts = shopservice.GetOpenShopReceipts(client, GClient.EtsyShopIDs.FirstOrDefault());
            }

            //Get the country list from etsy in advance so it doesn't
            //Have to be called per receipt request
            var countries = CountryService.GetCountryMapping(client);

            List <ExtractionModel> extractions = new List <ExtractionModel>();

            //make sure we actually pulled back client data
            if (GClient != null)
            {
                //iteract through receipts
                foreach (Receipt r in receipts)
                {
                    //iterrate through transactions of receipts
                    foreach (var t in r.transactions)
                    {
                        string country = countries[int.Parse(r.country_id)];

                        ExtractionModel em = new ExtractionModel();
                        em.company_id             = GClient.clientID;
                        em.Order_ID               = r.receipt_id;
                        em.date_purchased         = FormattingHelpers.FromEpochUnixTime(t.creation_tsz).ToString("g");
                        em.customer_email_address = r.buyer_email;
                        var FirstnameLastname = FormattingHelpers.FirstNameLastNameFormatter(r.name);
                        em.first_name = FirstnameLastname.Item1;
                        em.last_name  = FirstnameLastname.Item2;

                        em.delivery_address_1 = r.first_line;
                        em.delivery_address_2 = r.second_line;
                        em.delivery_city      = r.city;
                        em.delivery_state     = r.state;
                        em.delivery_zipCode   = r.zip;
                        em.country            = country;

                        //This is for the variation that is assuming
                        //it follows the format "Color - Design"
                        string[] color_design = t.variations.Where(x => x.formatted_name == "Color").FirstOrDefault().formatted_value.Split('-');

                        //If there is not a "-" then it automatically
                        //is the wrong format
                        if (color_design.Length > 1)
                        {
                            //This is making sure that the Design actually is associated
                            //with the client
                            //TODO: Eventually check that the design is actually available in the color
                            //that is provided.
                            if (GClient.ClientDesigns.Where(x => x.design_number.Trim() == color_design[1].Trim()).Any())
                            {
                                em.color         = color_design[0].Trim();
                                em.design_number = FormattingHelpers.DesignNumberFormatCheck(color_design[1].Trim());
                            }
                            else
                            {
                                em.color         = color_design[0].Trim();
                                em.design_number = string.Format("{0} Is Not a Correct Design Id", color_design[1]);
                            }
                        }
                        else
                        {
                            em.color         = color_design[0].Trim();
                            em.design_number = "Color_Design Incorrect Format";
                        }
                        em.design_description = "TBD";
                        em.print_location     = "TBD";


                        //This is for the variation that is assuming
                        //it follows the format "Style - Size"
                        string[] size_style = t.variations.Where(x => x.formatted_name == "Size").FirstOrDefault().formatted_value.Split('-');

                        if (size_style.Length > 1)
                        {
                            string etsystyle = size_style[1].Trim();
                            em.size = size_style[0].Trim();

                            //Check to see if the style from the variation
                            //has a mapping otherwise we can't know what
                            //prodct style its suposed to be
                            var style = GClient.ClientStyles.Where(x => x.etsy_style_descripion == etsystyle).FirstOrDefault();
                            if (style != null)
                            {
                                em.style_number      = style.style_number;
                                em.style_description = style.style_description;
                            }
                            else
                            {
                                em.style_number      = "ESTY STYLE '" + etsystyle + "' NOT FOUND";
                                em.style_description = "ESTY STYLE '" + etsystyle + "' NOT FOUND";
                            }
                        }
                        else
                        {
                            em.style_number      = size_style[0].Trim();
                            em.style_description = "Size_Style Incorrect Format";
                        }

                        em.product_quantity = t.quantity;
                        em.gift_message     = r.message_from_buyer;
                        em.Insured_Order    = "No";
                        em.shipping_method  = CountryService.GetCountryShippingMethodByCountry(country).Shipping_Method;
                        em.order_status     = "2";

                        extractions.Add(em);
                    }
                }
            }
            return(extractions);
        }