コード例 #1
0
        public static void TempImportStyleDesc()
        {
            string path  = @"C:\Internal\StyleDescriptions.xls";
            string sheet = "Sheet1";
            var    data  = ReadFrom(path, sheet);

            var descriptions = data.Select(x => new
            {
                Id          = x["client id"].ToString(),
                stylenumber = x["style number"].ToString(),
                styledesc   = x["style description"].ToString(),
                clientdesc  = x["client description"].ToString()
            }).ToList();

            var gclient = InternalClientService.GetInternalClientByID(descriptions.First().Id);

            if (gclient != null)
            {
                foreach (var desc in descriptions)
                {
                    var gstyledesc = gclient.ClientStyles.FirstOrDefault(x => x.style_number == desc.stylenumber);
                    if (gstyledesc == null)
                    {
                        gstyledesc = new InternalClientStyle();
                        gclient.ClientStyles.Add(gstyledesc);
                    }
                    gstyledesc.etsy_style_descripion = desc.clientdesc;
                    gstyledesc.style_number          = desc.stylenumber;
                    gstyledesc.style_description     = desc.styledesc;

                    InternalClientService.UpdateInternalClient(gclient);
                }
            }
        }
コード例 #2
0
        public void AdminRefresh()
        {
            var clientID = cmbClients.SelectedValue.ToString();
            var client   = InternalClientService.GetInternalClientByID(clientID);

            txtClientID.Text   = client.clientID;
            txtClientName.Text = client.clientName;

            var styles = client.ClientStyles.Select(x => x.style_number).ToList();

            lbStyles.Items.Clear();
            lbStyles.Items.AddRange(styles.ToArray());

            var designs = client.ClientDesigns;

            if (designs != null)
            {
                lbDesigns.Items.Clear();
                lbDesigns.Items.AddRange(designs.Select(x => x.design_number).ToArray());
                lbDesigns.SelectedIndex = 0;

                lbDesignColors.Items.Clear();
                lbDesignColors.Items.AddRange(designs.FirstOrDefault().colors.ToArray());
            }
        }
コード例 #3
0
ファイル: DesignAdd.cs プロジェクト: villanus/EtsyAPIConsumer
        private void btnAddNewDesign_Click(object sender, EventArgs e)
        {
            var client = InternalClientService.GetInternalClientByID(clientID);

            if (!string.IsNullOrEmpty(txtDefaultColor.Text) && !string.IsNullOrEmpty(txtDesignNumber.Text))
            {
                var designs = client.ClientDesigns;
                if (designs == null)
                {
                    designs = new List <Models.InternalClientDesign>();
                    client.ClientDesigns = designs;
                }
                var design = designs.Where(x => x.design_number == txtDesignNumber.Text).FirstOrDefault();
                if (design == null)
                {
                    design = new Models.InternalClientDesign();
                    design.design_number = txtDesignNumber.Text;

                    design.colors = new List <string>();
                    design.colors.Add(txtDefaultColor.Text);

                    client.ClientDesigns.Add(design);
                }
                InternalClientService.UpdateInternalClient(client);
                userAdmin.Enabled = true;
                userAdmin.AdminRefresh();
                this.Close();
            }
        }
コード例 #4
0
        private void DownloadForm_Load(object sender, EventArgs e)
        {
            var clients = InternalClientService.GetAllInternalClients();

            cmbClients.DataSource    = clients;
            cmbClients.DisplayMember = "clientName";
            cmbClients.ValueMember   = "clientID";

            comboBox2.Visible = false;
            lblShop.Visible   = false;
        }
コード例 #5
0
        private void btnColorRemove_Click(object sender, EventArgs e)
        {
            string clientID = cmbClients.SelectedValue.ToString();

            if (lbDesignColors.SelectedItem != null && lbDesigns.SelectedItem != null)
            {
                var gclient = InternalClientService.GetInternalClientByID(clientID);
                var design  = gclient.ClientDesigns.Where(x => x.design_number == lbDesigns.SelectedItem.ToString()).FirstOrDefault();
                design.colors.Remove(lbDesignColors.SelectedItem.ToString());
                InternalClientService.UpdateInternalClient(gclient);
                AdminRefresh();
            }
        }
コード例 #6
0
        public UserAdmin(DownloadUploadForm DownloadUploadForm)
        {
            downloaduploadform = DownloadUploadForm;
            InitializeComponent();

            var clients = InternalClientService.GetAllInternalClients();

            cmbClients.DataSource    = clients;
            cmbClients.DisplayMember = "clientName";
            cmbClients.ValueMember   = "clientID";
            isClientsLoaded          = true;

            AdminRefresh();
        }
コード例 #7
0
 private void btnAddNewColor_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtColor.Text))
     {
         var gclient = InternalClientService.GetInternalClientByID(clientID);
         var design  = gclient.ClientDesigns.Where(x => x.design_number == designNumber).FirstOrDefault();
         if (design != null)
         {
             design.colors.Add(txtColor.Text);
         }
         InternalClientService.UpdateInternalClient(gclient);
         this.Close();
     }
 }
コード例 #8
0
        private void lbStyles_SelectedIndexChanged(object sender, EventArgs e)
        {
            string clientID = cmbClients.SelectedValue.ToString();
            var    client   = InternalClientService.GetInternalClientByID(clientID);

            ListBox lb          = (ListBox)sender;
            string  styleNumber = lb.SelectedItem.ToString();
            var     style       = client.ClientStyles.Where(x => x.style_number == styleNumber).FirstOrDefault();

            if (style != null)
            {
                txtEtsyDescription.Text  = style.etsy_style_descripion;
                txtStyleDescription.Text = style.style_description;
            }
        }
コード例 #9
0
        private void lbDesigns_SelectedIndexChanged(object sender, EventArgs e)
        {
            string clientID = cmbClients.SelectedValue.ToString();
            var    client   = InternalClientService.GetInternalClientByID(clientID);

            ListBox lb           = (ListBox)sender;
            string  designNumber = lb.SelectedItem.ToString();
            var     design       = client.ClientDesigns.Where(x => x.design_number == designNumber).FirstOrDefault();

            if (design != null)
            {
                lbDesignColors.Items.Clear();
                lbDesignColors.Items.AddRange(design.colors.ToArray());
            }
        }
コード例 #10
0
        private void btnOrderRefresh_Click(object sender, EventArgs e)
        {
            string clientID = cmbClients.SelectedValue.ToString();
            var    client   = InternalClientService.GetInternalClientByID(clientID);

            if (client.EtsyShopIDs.Count > 1)
            {
                comboBox2.Visible = true;
                lblShop.Visible   = true;
                //alert that a shop must be selected
            }

            var extractions = ExtractionService.CreateExtractionFromReceipt(client, chkGetAllOrders.Checked);

            dgvTransactions.DataSource = extractions;
        }
コード例 #11
0
        private void btnStyleRemove_Click(object sender, EventArgs e)
        {
            string clientID    = cmbClients.SelectedValue.ToString();
            var    stylenumber = lbStyles.SelectedItem.ToString();
            var    gclient     = InternalClientService.GetInternalClientByID(clientID);

            var style = gclient.ClientStyles.Where(x => x.style_number == stylenumber).FirstOrDefault();

            if (style != null)
            {
                gclient.ClientStyles.Remove(style);
                InternalClientService.UpdateInternalClient(gclient);
            }
            AdminRefresh();
            txtStyleDescription.Text = string.Empty;
            txtEtsyDescription.Text  = string.Empty;
        }
コード例 #12
0
        public static void ShippingSummaries()
        {
            string path  = @"C:\Internal\Shipping Summary.xls";
            string sheet = "Shipping Summary";
            var    data  = ReadFrom(path, sheet);

            var summaries = data.Select(x => new
            {
                CompanyID   = x["Company_ID"].ToString(),
                OrderNumber = x["Order_No"].ToString(),
                Tracking    = x["Tracking"].ToString()
            }).ToList();

            var gclient = InternalClientService.GetInternalClientByID(summaries.First().CompanyID);

            if (gclient != null)
            {
                var client = new RestClient();
                client.BaseUrl       = AppKeys.GetBaseUri();
                client.Authenticator = OAuth1Authenticator.ForProtectedResource(AppKeys.GetApiKey(), AppKeys.GetSharedSecretKey(), gclient.AccessToken, gclient.AccessSecretKey);

                ShopService    SS       = new ShopService();
                ReceiptService RS       = new ReceiptService();
                var            receipts = SS.GetShopReceipts(client, gclient.EtsyShopIDs.First());
                foreach (var summary in summaries)
                {
                    Console.WriteLine("Updating Receipt : {0}", summary.OrderNumber);
                    var receipt = receipts.FirstOrDefault(x => x.order_id == summary.OrderNumber);
                    if (receipt != null)
                    {
                        if (!bool.Parse(receipt.was_shipped))
                        {
                            Console.WriteLine("Receipt Status : {0}", RS.UpdateReceipt(client, receipt.receipt_id));
                            Thread.Sleep(1000);
                        }
                        //submit tracking
                        Console.WriteLine("Transcation Status : {0}", RS.SubmitTracking(client, receipt.receipt_id, gclient.EtsyShopIDs.FirstOrDefault(), summary.Tracking, "USPS"));
                        Thread.Sleep(1000);
                    }
                }
            }
        }
コード例 #13
0
        private void btnAddNewStyle_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtStyle.Text) &&
                !string.IsNullOrEmpty(txtDescription.Text) &&
                !string.IsNullOrEmpty(txtEtsyDescription.Text))
            {
                var gclient = InternalClientService.GetInternalClientByID(clientID);
                var style   = gclient.ClientStyles.Where(x => x.style_number == txtStyle.Text).FirstOrDefault();
                if (style == null)
                {
                    style = new Models.InternalClientStyle();
                    style.style_number          = txtStyle.Text;
                    style.style_description     = txtDescription.Text;
                    style.etsy_style_descripion = txtEtsyDescription.Text;

                    gclient.ClientStyles.Add(style);
                    InternalClientService.UpdateInternalClient(gclient);
                    userAdmin.Enabled = true;
                    userAdmin.AdminRefresh();
                    this.Close();
                }
            }
        }
コード例 #14
0
ファイル: Listing.cs プロジェクト: MatadorINC/EtsyAPIConsumer
        public static void CreateCustomListing(RestClient client, InternalClient Company)
        {
            ShopService    SS = new ShopService();
            ListingService LS = new ListingService();
            UserService    US = new UserService();

            //GETTING SHIPPING TEMPLATE
            string shiptempId = ShippingTemplateService.GetShippingTemplateId(client, "80374327");
            var    countries  = CountryService.GetCountryMapping(client);
            string status     = ShippingTemplateService.CreateShippingTemplate(client, "Test Shipping Template", countries.Where(x => x.Value == "United States").FirstOrDefault().Key.ToString(), "2.00", "1.00");


            // CREATING A DRAFT LISTING
            string  shippingTemplateId = ShippingTemplateService.GetShippingTemplateId(client, Company.EtsyID);
            Listing testListing        = new Listing
            {
                quantity             = "20",
                title                = "Better Living Through Despair Orange Font Hoodie",
                description          = "Designs are made to order with high quality cotton shirts.",
                price                = ".50",
                shipping_template_id = shippingTemplateId,
                state                = "draft",
                is_supply            = "false",
                who_made             = "i_did",
                when_made            = "made_to_order"
            };
            ListingService ls = new ListingService();

            ls.CreateListing(client, testListing);

            //CREATING A LISTING IMAGE

            var    listing  = ls.GetListing(client, "265534678");
            string filepath = @"C:\Internal\EtsyProductImages\bettr_despair_orange_white.png";

            ls.CreateListingItemImage(client, listing, "bettr_despair_orange_white.png", filepath);

            //IMPORTING STYLE DATA
            ImportHelpers.TempImportStyleDesc();

            var           gclient = InternalClientService.GetInternalClientByID("646");
            List <string> colors  = new List <string> {
                "Black", "White"
            };
            List <string> designs = new List <string> {
                "W81MA", "W81WA", "W81XA", "W81YA"
            };
            List <string> sizes = new List <string> {
                "S", "M", "L", "XL", "XXL"
            };



            List <ListingVariation> variations = new List <ListingVariation>();
            ListingVariation        variation;


            var listings = SS.GetShopListings(client, gclient.EtsyShopIDs.First());

            foreach (var style in gclient.ClientStyles.Where(x => x.style_number == "G2000"))
            {
                foreach (var size in sizes)
                {
                    variation             = new ListingVariation();
                    variation.property_id = "100";
                    //variation.is_available = "TRUE";
                    variation.value = string.Format("{0}-{1}", size, style.etsy_style_descripion);
                    variations.Add(variation);
                }
            }
            string output = JsonConvert.SerializeObject(variations.ToArray());

            //Console.Write(output);

            foreach (var l in listings)
            {
                LS.UpdateListingVariations(client, l, output);
                Thread.Sleep(1000);
            }
        }
コード例 #15
0
        public static void ExtractionExport(List <Receipt> Receipts, string filepath, Dictionary <int, string> Countries, bool run)
        {
            if (run)
            {
                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                List <ExtractionModel> extractions = new List <ExtractionModel>();

                var gclient = InternalClientService.GetInternalClientByEtsyID(Receipts.FirstOrDefault().seller_user_id);

                if (gclient != null)
                {
                    foreach (Receipt r in 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;

                            string[] color_design = t.variations.Where(x => x.formatted_name == "Color").FirstOrDefault().formatted_value.Split('-');
                            em.color              = color_design[0].Trim();
                            em.design_number      = FormattingHelpers.DesignNumberFormatCheck(color_design[1].Trim());
                            em.design_description = "TBD";
                            em.print_location     = "TBD";


                            string[] size_style = t.variations.Where(x => x.formatted_name == "Size").FirstOrDefault().formatted_value.Split('-');
                            string   etsystyle  = size_style[1].Trim();
                            em.size              = size_style[0].Trim();
                            em.style_number      = gclient.ClientStyles.Where(x => x.etsy_style_descripion == etsystyle).First().style_number;
                            em.style_description = gclient.ClientStyles.Where(x => x.etsy_style_descripion == etsystyle).First().style_description;

                            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);
                        }
                    }
                }

                List <string> properties = new ExtractionModel().GetType().GetProperties().Select(x => x.Name).ToList();

                StringBuilder sbHeader = new StringBuilder();
                foreach (var prop in properties)
                {
                    sbHeader.AppendFormat("{0}\t", prop);
                }

                using (StreamWriter writer = new StreamWriter(filepath.Replace(".txt", "_extractiondata" + DateTime.Now.ToString("yyMMdd") + ".txt")))
                {
                    writer.WriteLine(sbHeader.ToString());
                    foreach (var ext in extractions.OrderBy(x => x.Order_ID))
                    {
                        StringBuilder sbData = new StringBuilder();
                        foreach (var prop in properties)
                        {
                            var o = ext.GetType().GetProperty(prop).GetValue(ext, null);
                            if (o == null)
                            {
                                o = "";
                            }
                            sbData.AppendFormat("{0}\t", o.ToString());
                        }
                        writer.WriteLine(sbData.ToString());
                    }
                }
            }
        }
コード例 #16
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
        }