public void runService(string wsdlKey, Dictionary <String, String> args) { switch (wsdlKey) { case "ChannelAdvisor.Admin": //AdminService admin = new AdminService ("ac93793a-4b71-44d4-ad4d-d302c39c238c","Domo123!"); APICredentials creds = new APICredentials() { DeveloperKey = "ac93793a-4b71-44d4-ad4d-d302c39c238c", Password = "******" }; //AdminService admin = AdminService.getInstance ("ac93793a-4b71-44d4-ad4d-d302c39c238c", "Domo123!"); AdminService admin = AdminService.getInstance(args.get("developerKey"), args.get("developerPassword")); admin.APICredentialsValue = creds; var result = admin.GetAuthorizationList(args.get("localId")).ResultData; foreach (AuthorizationResponse resp in result) { Console.WriteLine(resp.AccountID + ":" + resp.LocalID); } break; case "CelsiusToFarenheit": TempConvert converter = new TempConvert(); Console.WriteLine(converter.CelsiusToFahrenheit(args.get("temperature"))); break; case "FarenheitToCelsius": TempConvert converter2 = new TempConvert(); Console.WriteLine(converter2.FahrenheitToCelsius(args.get("temperature"))); break; default: throw new Exception("MagicException:Domo encountered error running service:Unable to map SOAP wsdl"); } }
/// <summary> /// Initializes a new instance of the <see cref="ListingService"/> class. /// </summary> /// <param name="credentials">The credentials.</param> /// <param name="name">The account user-friendly name.</param> /// <param name="accountId">The account id.</param> public ListingService(APICredentials credentials, string name, string accountId) { this.Name = name; this.AccountId = accountId; this._credentials = credentials; this._client = new ListingServiceSoapClient(); }
/// <summary> /// Initializes a new instance of the <see cref="ListingService"/> class. /// </summary> /// <param name="credentials">The credentials.</param> /// <param name="name">The account user-friendly name.</param> /// <param name="accountId">The account id.</param> public ListingService( APICredentials credentials, string name, string accountId ) { this.Name = name; this.AccountId = accountId; this._credentials = credentials; this._client = new ListingServiceSoapClient(); }
public IOrdersService CreateOrdersService(string accountName, string accountId) { SetSecurityProtocol(); var ordersCredentials = new APICredentials { DeveloperKey = this._developerKey, Password = this._developerPassword }; return(new OrdersService(ordersCredentials, accountName, accountId, _cache)); }
public OrdersService(APICredentials credentials, string accountId, ObjectCache cache = null) { this._credentials = credentials; this.AccountId = accountId; this._client = new OrderServiceSoapClient(); this._fulfillmentServiceCredentials = new FulfillmentService.APICredentials { DeveloperKey = this._credentials.DeveloperKey, Password = this._credentials.Password }; this._fulfillmentServiceClient = new FulfillmentService.FulfillmentServiceSoapClient(); }
/// <summary> /// Initializes a new instance of the <see cref="ItemsService"/> class. /// </summary> /// <param name="credentials">The credentials.</param> /// <param name="name">The account user-friendly name.</param> /// <param name="accountId">The account id.</param> /// <param name="cache">The cache.</param> /// <remarks>If <paramref name="cache"/> is <c>null</c> no caching takes place.</remarks> public ItemsService(APICredentials credentials, string name, string accountId, ObjectCache cache = null, LogDetailsEnum logDetailsEnum = LogDetailsEnum.Undefined) { this._credentials = credentials; this.AccountId = accountId; this.LogDetailsEnum = logDetailsEnum; this._client = new InventoryServiceSoapClient(); this.Name = name; this._cache = cache; this.SlidingCacheExpiration = ObjectCache.NoSlidingExpiration; this._allItemsCacheKey = string.Format("caAllItems_ID_{0}", this.AccountId); }
private LoginRequestDTO setlogin(string username, string password) { LoginRequestDTO login = new LoginRequestDTO(); login.UserName = username; login.Password = password; APICredentials api = new APICredentials() { APIPassword = ConfigurationManager.AppSettings["ApiPass"], APIUserName = ConfigurationManager.AppSettings["ApiUserName"] }; login.APICredentials = api; return(login); }
public ResponseDTO LoadActivityTypes(APICredentials request) { ResponseDTO resp = new ResponseDTO(); using (ProjectManagementBLL objProjectManagementBLL = new ProjectManagementBLL()) { try { APICredentialsBLL credentialsBLL = new APICredentialsBLL(); credentialsBLL.UserName = request.APIUserName; credentialsBLL.Password = request.APIPassword; if (!new CommonMethods().ValidateRequest(credentialsBLL)) { resp.ResponseCode = ResponseCodes.Failed; resp.ResponseMessage = ResponseMessages.InvalidCredentials; } else { DataTable dtRecord = new ActivityBLL().GetAllActivityTypes(objProjectManagementBLL); List <ActivityTypes> acttypes = new List <ActivityTypes>(); if (dtRecord.Rows.Count > 0) { foreach (DataRow row in dtRecord.Rows) { ActivityTypes acttyp = new ActivityTypes(); acttyp.ActTypeID = int.Parse(row["ActTypeID"].ToString()); acttyp.ActivityType = row["ActivityType"].ToString(); acttypes.Add(acttyp); } } resp.ResponseCode = ResponseCodes.Success; resp.ResponseMessage = ResponseMessages.Success; resp.ResponseData = new ResponseData(); resp.ResponseData.activitytypes = acttypes; } } catch (Exception ex) { resp.ResponseCode = ResponseCodes.Failed; resp.ResponseMessage = ex.Message; } } return(resp); }
public async Task Run() { var apiCredentials = new APICredentials( "ID", "SECRET" ); // var loginCredentials = new LoginCredentials( // "USERNAME", // "PASSWORD" // ); var config = new WHMCSConfig("https://www.domain.com/panel/includes/api.php", apiCredentials); var client = new WHMCSClient(config); var response = await client.GetModule <ClientModule>().Browse(); Console.WriteLine(JsonConvert.SerializeObject(response)); }
public ResponseDTO LoadProjects(APICredentials request) { ResponseDTO resp = new ResponseDTO(); using (ProjectManagementBLL objProjectManagementBLL = new ProjectManagementBLL()) { try { APICredentialsBLL credentialsBLL = new APICredentialsBLL(); credentialsBLL.UserName = request.APIUserName; credentialsBLL.Password = request.APIPassword; if (!new CommonMethods().ValidateRequest(credentialsBLL)) { resp.ResponseCode = ResponseCodes.Failed; resp.ResponseMessage = ResponseMessages.InvalidCredentials; } else { DataTable dtRecord = new ProjectsBLL().GetAllProjects(objProjectManagementBLL); List <Projects> projects = new List <Projects>(); if (dtRecord.Rows.Count > 0) { foreach (DataRow row in dtRecord.Rows) { Projects proj = new Projects(); proj.ProjectID = int.Parse(row["ProjectID"].ToString()); proj.ProjectName = row["ProjectName"].ToString(); projects.Add(proj); } } resp.ResponseCode = ResponseCodes.Success; resp.ResponseMessage = ResponseMessages.Success; resp.ResponseData = new ResponseData(); resp.ResponseData.projects = projects; } } catch (Exception ex) { resp.ResponseCode = ResponseCodes.Failed; resp.ResponseMessage = ex.Message; } } return(resp); }
public IOrdersService CreateOrdersService( string accountName, string accountId ) { var ordersCredentials = new APICredentials { DeveloperKey = this._developerKey, Password = this._developerPassword }; return new OrdersService( ordersCredentials, accountName, accountId, _cache ); }
private void DownloadInventoryData() { try { this.StatusDescription = string.Format("Creating ChannelAdvisor Client"); //Create OrderService client and ready it for request string devKey = System.Configuration.ConfigurationManager.AppSettings["CaDevK"]; string devPW = System.Configuration.ConfigurationManager.AppSettings["CaDevPw"]; //int profileID = 32001327; string accountID = System.Configuration.ConfigurationManager.AppSettings["CaAcct"]; ; APICredentials cred = new APICredentials(); cred.DeveloperKey = devKey; cred.Password = devPW; InventoryServiceSoapClient invClient = new InventoryServiceSoapClient(); this.StatusDescription = string.Format("Downloading Inventory Item List"); int invItemDownloadedCount = 0; List<InventoryItem> inventory = new List<InventoryItem>(); InventoryItemCriteria itemCriteria = new InventoryItemCriteria(); itemCriteria.PageNumber = 1; itemCriteria.PageSize = 100; InventoryItemDetailLevel detailLevel = new InventoryItemDetailLevel(); detailLevel.IncludePriceInfo = true; detailLevel.IncludeQuantityInfo = true; detailLevel.IncludeClassificationInfo = false; APIResultOfArrayOfInventoryItemResponse response; do { //invItemDownloadedCount += response.ResultData.Length; //this.StatusDescription = string.Format("Downloading Inventory Item List ({0} completed)", invItemDownloadedCount); response = invClient.GetFilteredInventoryItemList(cred, accountID, itemCriteria, detailLevel, "", ""); if (response.ResultData == null) break; foreach (var responseItem in response.ResultData) { invItemDownloadedCount++; this.StatusDescription = string.Format("Downloading Inventory Item List ({0} completed)", invItemDownloadedCount); InventoryItem item = new InventoryItem(); item.Asin = responseItem.ASIN; item.Brand = responseItem.Brand; item.Description = responseItem.Description; item.Ean = responseItem.EAN; item.HarmonizedCode = responseItem.HarmonizedCode; item.Height = (decimal)responseItem.Height; item.Isbn = responseItem.ISBN; item.Length = (decimal)responseItem.Length; item.Manufacturer = responseItem.Manufacturer; item.Mpn = responseItem.MPN; item.Quantity = responseItem.Quantity.Total; item.Sku = responseItem.Sku; item.SupplierCode = responseItem.SupplierCode; item.Title = responseItem.Title; item.Upc = responseItem.UPC; item.WarehouseLocation = responseItem.WarehouseLocation; item.Weight = (decimal)responseItem.Weight; item.Width = (decimal)responseItem.Width; bool getAttributes = true; if (getAttributes) { var attrResponse = invClient.GetInventoryItemAttributeList(cred, accountID, item.Sku); foreach (var attrPair in attrResponse.ResultData) { item.AttributeList.Add(attrPair.Name, attrPair.Value); if (attrPair.Name.Equals("Amazon Category")) { item.AmazonCategory = attrPair.Value; } else if (attrPair.Name.Equals("FBA Notes")) { item.FbaNotes = attrPair.Value; } else if (attrPair.Name.Equals("Is Chocolate")) { item.IsMeltable = attrPair.Value; } else if (attrPair.Name.Equals("Foreign Market Restriction")) { item.ForeignMarketRestrictions = attrPair.Value; } else if (attrPair.Name.Equals("Marketplace Restrictions")) { item.MarketplaceRestrictions = attrPair.Value; } else if (attrPair.Name.Equals("Pricing: Seller Cost Formula")) { item.MultiPackQuantity = attrPair.Value; } else if (attrPair.Name.Equals("Perishable?")) { item.Perishable = attrPair.Value; } } } inventory.Add(item); } itemCriteria.PageNumber += 1; } while (response.ResultData != null && response.ResultData.Length != 0); CommitToDatabase(inventory); } catch (Exception e) { throw new Exception(string.Format("ChannelAdvisorInventoryService - {0}", e.Message)); } }
public ShippingService( APICredentials credentials, string name, string id ): this( credentials, id ) { this.Name = name; }
public AdminService(APICredentials credentials) { this._credentials = credentials; this._client = new AdminServiceSoapClient(); }
public async Task <ImportReport> PerformImport(ExportType exportType, bool fetchLiveData, APICredentials credentials, CoreReferenceData coreRefData, string outputPath, IImportProvider provider) { var p = ((BaseImportProvider)provider); p.ExportType = exportType; ImportReport resultReport = new ImportReport(); resultReport.ProviderDetails = p; try { bool loadOK = false; if (fetchLiveData && p.IsAutoRefreshed && !String.IsNullOrEmpty(p.AutoRefreshURL)) { p.Log("Loading input data from URL.."); loadOK = p.LoadInputFromURL(p.AutoRefreshURL); } else { if (p.IsStringData) { p.Log("Loading input data from file.."); loadOK = p.LoadInputFromFile(p.InputPath); } else { //binary streams pass as OK by default loadOK = true; } } if (!loadOK) { //failed to load p.Log("Failed to load input data."); throw new Exception("Failed to fetch input data"); } List <ChargePoint> duplicatesList = new List <ChargePoint>(); p.Log("Processing input.."); var list = provider.Process(coreRefData); int numAdded = 0; int numUpdated = 0; if (list.Count > 0) { p.Log("De-Deuplicating list (" + p.ProviderName + ":: " + list.Count + " Items).."); //de-duplicate and clean list based on existing data //TODO: take original and replace in final update list, setting relevant updated properties (merge) and status var finalList = await DeDuplicateList(list, true, coreRefData, resultReport); //var finalList = list; if (ImportUpdatesOnly) { finalList = finalList.Where(l => l.ID > 0).ToList(); } //finalList = client.GetLocations(new SearchFilters { MaxResults = 10000 }); //export/apply updates if (p.ExportType == ExportType.XML) { p.Log("Exporting XML.."); //output xml p.ExportXMLFile(finalList, outputPath + p.OutputNamePrefix + ".xml"); } if (p.ExportType == ExportType.CSV) { p.Log("Exporting CSV.."); //output csv p.ExportCSVFile(finalList, outputPath + p.OutputNamePrefix + ".csv"); } if (p.ExportType == ExportType.JSON) { p.Log("Exporting JSON.."); //output json p.ExportJSONFile(finalList, outputPath + p.OutputNamePrefix + ".json"); } if (p.ExportType == ExportType.API && p.IsProductionReady) { //publish list of locations to OCM via API OCMClient ocmClient = new OCMClient(IsSandboxedAPIMode); p.Log("Publishing via API.."); foreach (ChargePoint cp in finalList.Where(l => l.AddressInfo.Country != null)) { ocmClient.UpdateItem(cp, credentials); if (cp.ID == 0) { numAdded++; } else { numUpdated++; } } } if (p.ExportType == ExportType.POIModelList) { resultReport.Added = finalList.Where(cp => cp.ID == 0).ToList(); resultReport.Updated = finalList.Where(cp => cp.ID > 0).ToList(); } } p.Log("Import Processed:" + provider.GetProviderName() + " Added:" + numAdded + " Updated:" + numUpdated); } catch (Exception exp) { p.Log("Import Failed:" + provider.GetProviderName() + " ::" + exp.ToString()); } return(resultReport); }
public ShippingService( APICredentials credentials, string accountId ) { this._credentials = credentials; this.AccountId = accountId; this._client = new ShippingServiceSoapClient(); }
public ShippingService(APICredentials credentials, string accountId) { this._credentials = credentials; this.AccountId = accountId; this._client = new ShippingServiceSoapClient(); }
public AdminService( APICredentials credentials ) { this._credentials = credentials; this._client = new AdminServiceSoapClient(); }
public ShippingService(APICredentials credentials, string name, string id) : this(credentials, id) { this.Name = name; }
private void DownloadInventoryData() { try { this.StatusDescription = string.Format("Creating ChannelAdvisor Client"); //Create OrderService client and ready it for request string devKey = System.Configuration.ConfigurationManager.AppSettings["CaDevK"]; string devPW = System.Configuration.ConfigurationManager.AppSettings["CaDevPw"]; //int profileID = 32001327; string accountID = System.Configuration.ConfigurationManager.AppSettings["CaAcct"];; APICredentials cred = new APICredentials(); cred.DeveloperKey = devKey; cred.Password = devPW; InventoryServiceSoapClient invClient = new InventoryServiceSoapClient(); this.StatusDescription = string.Format("Downloading Inventory Item List"); int invItemDownloadedCount = 0; List <InventoryItem> inventory = new List <InventoryItem>(); InventoryItemCriteria itemCriteria = new InventoryItemCriteria(); itemCriteria.PageNumber = 1; itemCriteria.PageSize = 100; InventoryItemDetailLevel detailLevel = new InventoryItemDetailLevel(); detailLevel.IncludePriceInfo = true; detailLevel.IncludeQuantityInfo = true; detailLevel.IncludeClassificationInfo = false; APIResultOfArrayOfInventoryItemResponse response; do { //invItemDownloadedCount += response.ResultData.Length; //this.StatusDescription = string.Format("Downloading Inventory Item List ({0} completed)", invItemDownloadedCount); response = invClient.GetFilteredInventoryItemList(cred, accountID, itemCriteria, detailLevel, "", ""); if (response.ResultData == null) { break; } foreach (var responseItem in response.ResultData) { invItemDownloadedCount++; this.StatusDescription = string.Format("Downloading Inventory Item List ({0} completed)", invItemDownloadedCount); InventoryItem item = new InventoryItem(); item.Asin = responseItem.ASIN; item.Brand = responseItem.Brand; item.Description = responseItem.Description; item.Ean = responseItem.EAN; item.HarmonizedCode = responseItem.HarmonizedCode; item.Height = (decimal)responseItem.Height; item.Isbn = responseItem.ISBN; item.Length = (decimal)responseItem.Length; item.Manufacturer = responseItem.Manufacturer; item.Mpn = responseItem.MPN; item.Quantity = responseItem.Quantity.Total; item.Sku = responseItem.Sku; item.SupplierCode = responseItem.SupplierCode; item.Title = responseItem.Title; item.Upc = responseItem.UPC; item.WarehouseLocation = responseItem.WarehouseLocation; item.Weight = (decimal)responseItem.Weight; item.Width = (decimal)responseItem.Width; bool getAttributes = true; if (getAttributes) { var attrResponse = invClient.GetInventoryItemAttributeList(cred, accountID, item.Sku); foreach (var attrPair in attrResponse.ResultData) { item.AttributeList.Add(attrPair.Name, attrPair.Value); if (attrPair.Name.Equals("Amazon Category")) { item.AmazonCategory = attrPair.Value; } else if (attrPair.Name.Equals("FBA Notes")) { item.FbaNotes = attrPair.Value; } else if (attrPair.Name.Equals("Is Chocolate")) { item.IsMeltable = attrPair.Value; } else if (attrPair.Name.Equals("Foreign Market Restriction")) { item.ForeignMarketRestrictions = attrPair.Value; } else if (attrPair.Name.Equals("Marketplace Restrictions")) { item.MarketplaceRestrictions = attrPair.Value; } else if (attrPair.Name.Equals("Pricing: Seller Cost Formula")) { item.MultiPackQuantity = attrPair.Value; } else if (attrPair.Name.Equals("Perishable?")) { item.Perishable = attrPair.Value; } } } inventory.Add(item); } itemCriteria.PageNumber += 1; } while (response.ResultData != null && response.ResultData.Length != 0); CommitToDatabase(inventory); } catch (Exception e) { throw new Exception(string.Format("ChannelAdvisorInventoryService - {0}", e.Message)); } }
public OrdersService(APICredentials credentials, string accountName, string accountId, ObjectCache cache = null) : this(credentials, accountId, cache) { this.Name = accountName; }
public WHMCSConfig(string url, APICredentials apiCredentials, bool throwErrors = false) : this(url, throwErrors) { AuthType = AuthTypes.API; ApiCredentials = apiCredentials; }
private void DownloadSalesData() { try { this.StatusDescription = string.Format("Creating ChannelAdvisor Client"); //Create OrderService client and ready it for request string devKey = System.Configuration.ConfigurationManager.AppSettings["CaDevK"]; string devPW = System.Configuration.ConfigurationManager.AppSettings["CaDevPw"]; //int profileID = 32001327; string accountID = System.Configuration.ConfigurationManager.AppSettings["CaAcct"]; ; APICredentials cred = new APICredentials(); cred.DeveloperKey = devKey; cred.Password = devPW; OrderServiceSoapClient ordClient = new OrderServiceSoapClient(); //Get latest order date in DB, and pull all orders since then DateTime beginTime; using (var db = new CheapeesEntities()) { beginTime = (DateTime)db.MerchantFulfilledSales.OrderByDescending(o => o.OrderTime).FirstOrDefault().OrderTime; } OrderCriteria criteria = new OrderCriteria(); criteria.OrderCreationFilterBeginTimeGMT = beginTime; criteria.OrderCreationFilterEndTimeGMT = DateTime.Now; criteria.DetailLevel = "High"; List<ChannelAdvisorSale> listOfSales = new List<ChannelAdvisorSale>(); int page = 1; criteria.PageNumberFilter = page; //Issue requests this.StatusDescription = string.Format("Requesting sales data since latest sale ({0})", beginTime); APIResultOfArrayOfOrderResponseItem response = ordClient.GetOrderList(cred, accountID, criteria); int numberOfOrders = 0; //When everything has been retrieved, pages will be returned empty and should exit loop while (response.ResultData.Length != 0) { numberOfOrders += response.ResultData.Length; this.StatusDescription = string.Format("Downloading sales data: {0} orders retrieved", numberOfOrders); foreach (OrderResponseDetailHigh order in response.ResultData) { foreach (OrderLineItemItem item in order.ShoppingCart.LineItemSKUList) { ChannelAdvisorSale sale = new ChannelAdvisorSale(); sale.SKU = item.SKU; sale.Quantity = item.Quantity; sale.Marketplace = item.ItemSaleSource; sale.UnitPrice = item.UnitPrice; sale.OrderTime = ((DateTime)order.OrderTimeGMT).ToLocalTime(); sale.Invoice = order.OrderID.ToString(); listOfSales.Add(sale); } } //Get next page of results page++; criteria.PageNumberFilter = page; response = ordClient.GetOrderList(cred, accountID, criteria); } CommitToDatabase(listOfSales); } catch (Exception e) { throw new Exception(string.Format("ChannelAdvisorOrderService - {0}", e.Message)); } }
public async Task <ImportReport> PerformImport(ExportType exportType, bool fetchLiveData, APICredentials credentials, CoreReferenceData coreRefData, string outputPath, IImportProvider provider, bool cacheInputData, bool fetchExistingFromAPI = false) { var p = ((BaseImportProvider)provider); p.ExportType = exportType; ImportReport resultReport = new ImportReport(); resultReport.ProviderDetails = p; try { bool loadOK = false; if (p.ImportInitialisationRequired && p is IImportProviderWithInit) { ((IImportProviderWithInit)provider).InitImportProvider(); } if (fetchLiveData && p.IsAutoRefreshed && !String.IsNullOrEmpty(p.AutoRefreshURL)) { Log("Loading input data from URL.."); loadOK = p.LoadInputFromURL(p.AutoRefreshURL); } else { if (p.IsStringData && !p.UseCustomReader) { Log("Loading input data from file.."); loadOK = p.LoadInputFromFile(p.InputPath); } else { //binary streams pass as OK by default loadOK = true; } } if (!loadOK) { //failed to load Log("Failed to load input data."); throw new Exception("Failed to fetch input data"); } else { if (fetchLiveData && cacheInputData) { //save input data p.SaveInputFile(p.InputPath); } } List <ChargePoint> duplicatesList = new List <ChargePoint>(); Log("Processing input.."); var list = provider.Process(coreRefData); int numAdded = 0; int numUpdated = 0; if (list.Count > 0) { if (p.MergeDuplicatePOIEquipment) { Log("Merging Equipment from Duplicate POIs"); list = MergeDuplicatePOIEquipment(list); } if (!p.IncludeInvalidPOIs) { Log("Cleaning invalid POIs"); var invalidPOIs = new List <ChargePoint>(); foreach (var poi in list) { if (!BaseImportProvider.IsPOIValidForImport(poi)) { invalidPOIs.Add(poi); } } foreach (var poi in invalidPOIs) { list.Remove(poi); } } GC.Collect(); List <ChargePoint> finalList = new List <ChargePoint>(); if (!p.SkipDeduplication) { Log("De-Deuplicating list (" + p.ProviderName + ":: " + list.Count + " Items).."); //de-duplicate and clean list based on existing data //TODO: take original and replace in final update list, setting relevant updated properties (merge) and status finalList = await DeDuplicateList(list.ToList(), true, coreRefData, resultReport, p.AllowDuplicatePOIWithDifferentOperator, fetchExistingFromAPI); //var finalList = list; } else { //skip deduplication finalList = list.ToList(); } if (ImportUpdatesOnly) { finalList = finalList.Where(l => l.ID > 0).ToList(); } //finalList = client.GetLocations(new SearchFilters { MaxResults = 10000 }); GC.Collect(); //export/apply updates if (p.ExportType == ExportType.XML) { Log("Exporting XML.."); //output xml p.ExportXMLFile(finalList, outputPath + p.OutputNamePrefix + ".xml"); } if (p.ExportType == ExportType.CSV) { Log("Exporting CSV.."); //output csv p.ExportCSVFile(finalList, outputPath + p.OutputNamePrefix + ".csv"); } if (p.ExportType == ExportType.JSON) { Log("Exporting JSON.."); //output json p.ExportJSONFile(finalList, outputPath + p.OutputNamePrefix + ".json"); } if (p.ExportType == ExportType.API && p.IsProductionReady) { //publish list of locations to OCM via API OCMClient ocmClient = new OCMClient(IsSandboxedAPIMode); Log("Publishing via API.."); foreach (ChargePoint cp in finalList.Where(l => l.AddressInfo.Country != null)) { ocmClient.UpdateItem(cp, credentials); if (cp.ID == 0) { numAdded++; } else { numUpdated++; } } } if (p.ExportType == ExportType.POIModelList) { //result report contains POI lists } } Log("Import Processed:" + provider.GetProviderName() + " Added:" + numAdded + " Updated:" + numUpdated); } catch (Exception exp) { Log("Import Failed:" + provider.GetProviderName() + " ::" + exp.ToString()); } resultReport.Log = ""; resultReport.Log += p.ProcessingLog; resultReport.Log += ImportLog; return(resultReport); }
private void DownloadSalesData() { try { this.StatusDescription = string.Format("Creating ChannelAdvisor Client"); //Create OrderService client and ready it for request string devKey = System.Configuration.ConfigurationManager.AppSettings["CaDevK"]; string devPW = System.Configuration.ConfigurationManager.AppSettings["CaDevPw"]; //int profileID = 32001327; string accountID = System.Configuration.ConfigurationManager.AppSettings["CaAcct"];; APICredentials cred = new APICredentials(); cred.DeveloperKey = devKey; cred.Password = devPW; OrderServiceSoapClient ordClient = new OrderServiceSoapClient(); //Get latest order date in DB, and pull all orders since then DateTime beginTime; using (var db = new CheapeesEntities()) { beginTime = (DateTime)db.MerchantFulfilledSales.OrderByDescending(o => o.OrderTime).FirstOrDefault().OrderTime; } OrderCriteria criteria = new OrderCriteria(); criteria.OrderCreationFilterBeginTimeGMT = beginTime; criteria.OrderCreationFilterEndTimeGMT = DateTime.Now; criteria.DetailLevel = "High"; List <ChannelAdvisorSale> listOfSales = new List <ChannelAdvisorSale>(); int page = 1; criteria.PageNumberFilter = page; //Issue requests this.StatusDescription = string.Format("Requesting sales data since latest sale ({0})", beginTime); APIResultOfArrayOfOrderResponseItem response = ordClient.GetOrderList(cred, accountID, criteria); int numberOfOrders = 0; //When everything has been retrieved, pages will be returned empty and should exit loop while (response.ResultData.Length != 0) { numberOfOrders += response.ResultData.Length; this.StatusDescription = string.Format("Downloading sales data: {0} orders retrieved", numberOfOrders); foreach (OrderResponseDetailHigh order in response.ResultData) { foreach (OrderLineItemItem item in order.ShoppingCart.LineItemSKUList) { ChannelAdvisorSale sale = new ChannelAdvisorSale(); sale.SKU = item.SKU; sale.Quantity = item.Quantity; sale.Marketplace = item.ItemSaleSource; sale.UnitPrice = item.UnitPrice; sale.OrderTime = ((DateTime)order.OrderTimeGMT).ToLocalTime(); sale.Invoice = order.OrderID.ToString(); listOfSales.Add(sale); } } //Get next page of results page++; criteria.PageNumberFilter = page; response = ordClient.GetOrderList(cred, accountID, criteria); } CommitToDatabase(listOfSales); } catch (Exception e) { throw new Exception(string.Format("ChannelAdvisorOrderService - {0}", e.Message)); } }