public void Init() { customerGroupService = new CustomerGroupService(); customerGroupService.Credentials = new System.Net.NetworkCredential(WEBSERVICE_LOGIN, WEBSERVICE_PASSWORD); customerGroupService.PreAuthenticate = true; customerGroupService.Url = WEBSERVICE_URL; }
public void Init() { // try to get customer groups at first, because they are different since patch 7 string customerGroupsPath = "/Shops/DemoShop/Groups/"; string[] customerGroups = new string[]{ customerGroupsPath+"NewCustomer", customerGroupsPath+"RegularCustomer" }; WebServiceConfiguration WSConfig = new WebServiceConfiguration(); CustomerGroupService custService = new CustomerGroupService(); custService.Credentials = new System.Net.NetworkCredential(WSConfig.WEBSERVICE_LOGIN, WSConfig.WEBSERVICE_PASSWORD); custService.PreAuthenticate = true; custService.Url = WSConfig.WEBSERVICE_URL; TGetList_Return[] retGroups = custService.getList(); customerGroups[0] = customerGroupsPath + retGroups[0].Alias; customerGroups[1] = customerGroupsPath + retGroups[1].Alias; serviceClient = new PriceListServiceClient(); // create test PriceLists that can be used with the create and update methods PriceList_in.Alias = alias; PriceList_in.CurrencyID = "EUR"; PriceList_in.CustomerGroups = new string[] { customerGroups[0] }; PriceList_in.Customers = new string[]{"/Shops/DemoShop/Customers/1001"}; TLocalizedValue name_de = new TLocalizedValue(); name_de.LanguageCode = "de"; name_de.Value = "Meine Preisliste"; TLocalizedValue name_en = new TLocalizedValue(); name_en.LanguageCode = "en"; name_en.Value = "my price list"; PriceList_in.Name = new TLocalizedValue[]{name_de, name_en}; PriceList_in.TaxModel = "gross"; PriceList_in.ValidFrom = new DateTime(2005, 12, 1, 0, 0, 0, DateTimeKind.Local); PriceList_in.ValidTo = new DateTime(2005, 12, 31, 0, 0, 0, DateTimeKind.Local); TAttribute attr = new TAttribute(); attr.Name = "CreationDate"; attr.Type = "DateTime"; attr.Value = "2006-01-01T00:00:00"; PriceList_in.Attributes = new TAttribute[]{attr}; PriceList_update.Path = path + alias; TLocalizedValue name_de_update = new TLocalizedValue(); name_de_update.LanguageCode = "de"; name_de_update.Value = "Meine geänderte Preisliste"; TLocalizedValue name_en_update = new TLocalizedValue(); name_en_update.LanguageCode = "en"; name_en_update.Value = "my updated price list"; PriceList_update.Name = new TLocalizedValue[]{name_de_update, name_en_update}; // IMPORTANT!!! // .NET has the terrible behavior, to set all boolean and numeric value (incl. dates) that are not // defined to "false" resp. "0" // So if you update an object and do not set the "IsVisible" flag, it will set the object to // invisible!!! PriceList_update.ValidFrom = new DateTime(2005, 12, 1, 0, 0, 0, DateTimeKind.Local); PriceList_update.ValidTo = new DateTime(2005, 12, 31, 0, 0, 0, DateTimeKind.Local); TAttribute attr_update = new TAttribute(); attr_update.Name = "CreationDate"; attr_update.Type = "DateTime"; attr_update.Value = "2006-01-01T11:11:11"; PriceList_update.Attributes = new TAttribute[]{attr_update}; }