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