static void Main(string[] args) { Navision_CustomerListService.CustomerList nv_Customer = new Navision_CustomerListService.CustomerList(); Navision_CustomerListService.CustomerList_PortClient client = new Navision_CustomerListService.CustomerList_PortClient(); Navision_CustomerListService.CustomerList[] nv_CustomerLists; client.ClientCredentials.UserName.UserName = "******"; client.ClientCredentials.UserName.Password = "******"; //client.ClientCredentials.Windows.ClientCredential.UserName = "******"; //client.ClientCredentials.Windows.ClientCredential.Password = "******"; //client.ClientCredentials.Windows.ClientCredential.Domain = "122.166.222.116"; nv_CustomerLists = client.ReadMultiple(null, null, 10000); MagentoConnectService.PortTypeClient mage_client = new MagentoConnectService.PortTypeClient(); DBConnect db = new DBConnect(); int newCustomerCreateID = 0; int createAddressID = 0; string token_id = ""; filters myfilter = new filters(); token_id = mage_client.login("webserviceuser", "apikey"); Hashtable hsc = db.fetch_CustomerMapping(); for (int i = 0; i < nv_CustomerLists.Length; i++) { // Create Customer customerCustomerEntityToCreate customerCreate = new customerCustomerEntityToCreate(); try { customerCreate.firstname = nv_CustomerLists[i].Name; customerCreate.lastname = "."; customerCreate.middlename = ""; customerCreate.password = "******"; customerCreate.store_id = 1; customerCreate.store_idSpecified = true; customerCreate.website_id = 1; customerCreate.website_idSpecified = true; customerCreate.group_id = 1; customerCreate.group_idSpecified = true; customerCreate.suffix = "P"; customerCreate.email = nv_CustomerLists[i].E_Mail; customerCreate.gender = 1; //1-Male;2-Female customerCreate.genderSpecified = true; //customer address customerAddressEntityCreate customerAddress = new customerAddressEntityCreate(); if (nv_CustomerLists[i].Location_Code == null) { customerAddress.city = "NA"; } else { customerAddress.city = nv_CustomerLists[i].Location_Code; } customerAddress.region_id = 2; //CountryID customerAddress.region_idSpecified = true; if (nv_CustomerLists[i].Country_Region_Code == null) { customerAddress.country_id = "NA"; } else { customerAddress.country_id = nv_CustomerLists[i].Country_Region_Code; } customerAddress.fax = nv_CustomerLists[i].Fax_No; customerAddress.firstname = nv_CustomerLists[i].Name; customerAddress.lastname = "."; customerAddress.middlename = ""; string[] streettxt = { nv_CustomerLists[i].Address }; customerAddress.street = streettxt; customerAddress.postcode = nv_CustomerLists[i].Post_Code; customerAddress.prefix = "M"; customerAddress.suffix = "P"; // customerAddress.street = nv_CustomerLists[i].Address.ToString(); if (nv_CustomerLists[i].Phone_No == null) { customerAddress.telephone = "NA"; } else { customerAddress.telephone = nv_CustomerLists[i].Phone_No; } //If you specify 'true' for is_default_billing and is_default_shipping. Then this address will be your default shipping and billing. Otherwise none. customerAddress.is_default_billing = true; customerAddress.is_default_shipping = true; if (db.fetch_Customer(nv_CustomerLists[i].No.ToString())) { mage_client.customerCustomerUpdate(token_id, Convert.ToInt16(hsc[nv_CustomerLists[i].No]), customerCreate); } else { newCustomerCreateID = mage_client.customerCustomerCreate(token_id, customerCreate); createAddressID = mage_client.customerAddressCreate(token_id, newCustomerCreateID, customerAddress); db.InsertCustomerMapping(nv_CustomerLists[i].No, newCustomerCreateID.ToString(), nv_CustomerLists[i].E_Mail); db.InsertLog("Customer", nv_CustomerLists[i].No, "Navision Customer Code", "SUCCESS"); } } catch (Exception ex) { MNC_Product_Sync.ErrorLog errLog = new MNC_Product_Sync.ErrorLog(); errLog.LogError("C:\\MNC_Logs", "Customer :" + ex.Message); db.InsertLog("Customer", nv_CustomerLists[i].No, ex.Message, "FAILED"); } finally { //mage_client.endSession(token_id); } } mage_client.endSession(token_id); }
static void MainPr(string[] args) { try { Navision_ItemCategory_Service.ItemCategories nv_Item_Cat = new Navision_ItemCategory_Service.ItemCategories(); Navision_ItemList_Service.ItemList_PortClient client = new Navision_ItemList_Service.ItemList_PortClient(); Navision_ItemList_Service.ItemList nv_ItemList = new Navision_ItemList_Service.ItemList(); Navision_ItemList_Service.ItemList[] nv_ItemLists; client.ClientCredentials.Windows.ClientCredential.UserName = "******"; client.ClientCredentials.Windows.ClientCredential.Password = "******"; client.ClientCredentials.Windows.ClientCredential.Domain = "122.166.222.116"; Navision_ItemList_Service.ItemList_Filter f = new Navision_ItemList_Service.ItemList_Filter(); nv_ItemLists = client.ReadMultiple(new Navision_ItemList_Service.ItemList_Filter[] { f }, null, 10000); MagentoConnectService.PortTypeClient mage_client = new MagentoConnectService.PortTypeClient(); string token_id = mage_client.login("webserviceuser", "apikey"); DBConnect db = new DBConnect(); Hashtable hs = db.fetch_CategoryMapping(); Hashtable hsp = db.fetch_ProductMapping(); for (int i = 0; i < nv_ItemLists.Length; i++) { MagentoConnectService.catalogProductCreateEntity mage_Product = new MagentoConnectService.catalogProductCreateEntity(); try { mage_Product.description = nv_ItemLists[i].Description; mage_Product.name = nv_ItemLists[i].Description; mage_Product.weight = "1"; mage_Product.price = nv_ItemLists[i].Last_Direct_Cost.ToString(); mage_Product.short_description = nv_ItemLists[i].Search_Description; string mage_cat_id = null; if (nv_ItemLists[i].Item_Category_Code != null) { mage_cat_id = (string)hs[nv_ItemLists[i].Item_Category_Code]; } string[] array = { mage_cat_id }; mage_Product.category_ids = array; mage_Product.status = "1"; mage_Product.visibility = "4"; String productType = "simple"; var stock = new catalogInventoryStockItemUpdateEntity { is_in_stockSpecified = true, is_in_stock = 1, qty = nv_ItemLists[i].Inventory.ToString() }; mage_Product.stock_data = stock; int productid = 0; try { if (db.fetch_Product(nv_ItemLists[i].No)) { mage_client.catalogProductUpdate(token_id, (string)hsp[nv_ItemLists[i].No], mage_Product, "default", productType); } else { productid = mage_client.catalogProductCreate(token_id, productType, "4", nv_ItemLists[i].No, mage_Product, "default"); db.InsertProductMapping(nv_ItemLists[i].No, productid.ToString(), nv_ItemLists[i].No); db.InsertLog("Product", nv_ItemLists[i].No, "Navision Product Code", "SUCCESS"); } } catch (Exception ex) { db.InsertLog("Product", nv_ItemLists[i].No, ex.ToString(), "FAILED"); } } catch (Exception ex) { db.InsertLog("Product", nv_ItemLists[i].No, ex.ToString(), "FAILED"); } } } catch (Exception ex) { MNC_Product_Sync.ErrorLog errLog = new MNC_Product_Sync.ErrorLog(); errLog.LogError("C:\\MNC_Logs", "Product " + ex.Message); } }
static void MainCat(string[] args) { //AppConfigFileSettings.UpdateAppSettings("address", "http://103.238.216.254:7047/DynamicsNAV71/WS/CRONUS%20India%20Ltd/Page/ItemCategory"); Navision_ItemCategory_Service.ItemCategories nv_Item_Cat = new Navision_ItemCategory_Service.ItemCategories(); Navision_ItemCategory_Service.ItemCategories_PortClient client = new Navision_ItemCategory_Service.ItemCategories_PortClient(); Navision_ItemCategory_Service.ItemCategories[] nv_ItemCats = null; client.ClientCredentials.Windows.ClientCredential.UserName = "******"; client.ClientCredentials.Windows.ClientCredential.Password = "******"; client.ClientCredentials.Windows.ClientCredential.Domain = "122.166.222.116"; string token_id = null; DBConnect db = null; db = new DBConnect(); Hashtable hscat = db.fetch_CategoryMapping(); MagentoConnectService.PortTypeClient mage_client = null; try { nv_ItemCats = client.ReadMultiple(null, null, 5000); mage_client = new MagentoConnectService.PortTypeClient(); token_id = mage_client.login("webserviceuser", "apikey"); } catch (Exception ex) { MNC_Product_Sync.ErrorLog errLog = new MNC_Product_Sync.ErrorLog(); errLog.LogError("C:\\MNC_Logs", "ProductCategory : " + ex.Message); } finally { // mage_client.endSession(token_id); } try { for (int i = 0; i < nv_ItemCats.Length; i++) { if (!db.fetch_ProductCat(nv_ItemCats[i].Code)) { string[] sortby_values; string sortbyval = "name"; sortby_values = sortbyval.ToString().Split(','); catalogCategoryEntityCreate cat = new catalogCategoryEntityCreate(); cat.description = nv_ItemCats[i].Description; cat.name = nv_ItemCats[i].Code; cat.available_sort_by = sortby_values; cat.include_in_menu = 1; cat.default_sort_by = "name"; cat.is_active = 1; cat.include_in_menuSpecified = true; cat.include_in_menu = 1; cat.is_activeSpecified = true; cat.is_active = 1; int id = mage_client.catalogCategoryCreate(token_id, 1, cat, null); db.InsertProductCatMapping(nv_ItemCats[i].Code, id.ToString(), cat.name); db.InsertLog("Category", nv_ItemCats[i].Code, "Navision Category Code", "SUCCESS"); } } } catch (Exception ex) { MNC_Product_Sync.ErrorLog errLog = new MNC_Product_Sync.ErrorLog(); errLog.LogError("C:\\MNC_Logs", "ProductCategory : " + ex.Message); } finally { mage_client.endSession(token_id); } //mage_client.catalogProductCreate(token_id, }