public void addItemRecord() { NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; string itemName = this.ItemName; SearchStringField objItemName = new SearchStringField(); objItemName.searchValue = itemName; objItemName.@operator = SearchStringFieldOperator.@is; objItemName.operatorSpecified = true; ItemSearch objItemSearch = new ItemSearch(); objItemSearch.basic = new ItemSearchBasic(); objItemSearch.basic.itemId = objItemName; SearchPreferences searchPreferences = new SearchPreferences(); searchPreferences.bodyFieldsOnly = false; service.searchPreferences = searchPreferences; SearchResult objItemResult = service.search(objItemSearch); if (objItemResult.status.isSuccess != true) throw new Exception("Cannot find Item " + itemName + " " + objItemResult.status.statusDetail[0].message); if (objItemResult.recordList.Count() != 1) throw new Exception("More than one item found for item " + itemName); InventoryItem iRecord = new InventoryItem(); iRecord = ((InventoryItem)objItemResult.recordList[0]); this.itemRecord = new InventoryItem(); this.itemRecord=iRecord; }
/// <summary> /// logout /// </summary> /// <param name="netSuiteService">netsuite webservice instance</param> /// <param name="sessionResponse">session service response</param> public void logout(NetSuiteService netSuiteService, SessionResponse sessionResponse) { if (sessionResponse != null && sessionResponse.status.isSuccess) { netSuiteService.logout(); } }
public Location(string locationName) { NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; LocationSearch locSearch = new LocationSearch(); SearchStringField locName = new SearchStringField(); locName.@operator = SearchStringFieldOperator.@is; locName.operatorSpecified = true; locName.searchValue = locationName; LocationSearchBasic locSearchBasic = new LocationSearchBasic(); locSearchBasic.name = locName; locSearch.basic = locSearchBasic; SearchResult locationResult = service.search(locSearch); if (locationResult.status.isSuccess != true) throw new Exception("Cannot find Item " + locationName + " " + locationResult.status.statusDetail[0].message); if (locationResult.recordList.Count() != 1) throw new Exception("More than one item found for item " + locationName); this.locationRecord = new RecordRef(); this.locationRecord.type = RecordType.location; this.locationRecord.typeSpecified = true; this.locationRecord.internalId = ((com.netsuite.webservices.Location)locationResult.recordList[0]).internalId; }
public void savedSearch(NetSuiteService service, string searchID) { CustomRecordSearchAdvanced csa = new CustomRecordSearchAdvanced(); csa.savedSearchId = searchID; SearchResult SR = service.search(csa); if (SR.status.isSuccess) { SearchRow[] searchRows = SR.searchRowList; for (int i = 0; i < searchRows.Length; i++) { CustomRecordSearchRow crsr = (CustomRecordSearchRow)searchRows[i]; ArrayList customFieldList = new ArrayList(crsr.basic.customFieldList); String strRecNumberPrefix = "Record " + i.ToString() + ": "; for (int j = 0; j < customFieldList.Count; j++) { MessageBox.Show("Field Type for element " + j + ": " + customFieldList[j].GetType().Name); switch (customFieldList[j].GetType().Name) { case "SearchColumnSelectCustomField": SearchColumnSelectCustomField scselectcf = (SearchColumnSelectCustomField)customFieldList[j]; if (scselectcf.internalId == "custrecord_currency") { ListOrRecordRef lorrCurrency = (ListOrRecordRef)scselectcf.searchValue; RecordRef rrCurrency = new RecordRef(); rrCurrency.internalId = lorrCurrency.internalId; rrCurrency.type = RecordType.currency; txtSearchResults.Text = txtSearchResults.Text + strRecNumberPrefix + rrCurrency.name + Environment.NewLine; } else if (scselectcf.internalId == "custrecord_subsidiary") { ListOrRecordRef lorrSubsidiary = (ListOrRecordRef)scselectcf.searchValue; RecordRef rrSubsidiary = new RecordRef(); rrSubsidiary.internalId = lorrSubsidiary.internalId; rrSubsidiary.type = RecordType.subsidiary; txtSearchResults.Text = txtSearchResults.Text + strRecNumberPrefix + rrSubsidiary.name + Environment.NewLine; } break; case "SearchColumnStringCustomField": SearchColumnStringCustomField scstringcf = (SearchColumnStringCustomField)customFieldList[j]; if (scstringcf.internalId == "custrecord_jdecountry") { txtSearchResults.Text = txtSearchResults.Text + strRecNumberPrefix + scstringcf.searchValue + Environment.NewLine; } break; default: break; } } } } else { txtSearchResults.Text = "Failure"; } }
/// <summary> /// call the login service /// </summary> /// <param name="account">netsuite account</param> private void executeLogin(string account) { string _account = string.IsNullOrEmpty(account) ? ConfigurationManager.AppSettings["account"].Split(',')[0] : account; if (_account.Contains('|')) { _account = _account.Split('|')[0]; } Login login = new Login(_account); bool isSandbox = false; if (!string.IsNullOrEmpty(account)) { DialogResult dlrSandbox = MessageBox.Show("Connect to sandbox account?", "Question", MessageBoxButtons.YesNo); isSandbox = (dlrSandbox == DialogResult.Yes); } netSuiteService = new DataCenterAwareNetSuiteService(login.Account, isSandbox); ///password not mandatory in configuration if (string.IsNullOrEmpty(login.Password)) { FrmDialog passwordDialog = new FrmDialog(); passwordDialog.Text = login.Email; if (passwordDialog.ShowDialog(this) == DialogResult.OK) { login.Password = passwordDialog.txtPassword.Text; } else { login.Password = string.Empty; } passwordDialog.Dispose(); } sessionResponse = login.login(netSuiteService); if (sessionResponse != null && sessionResponse.status.isSuccess) { lblToolStripStatus.Text = ((isSandbox) ? "SANDBOX " : "") + "Account: " + login.Account + " - Email: " + login.Email; appendLog("Login done [" + lblToolStripStatus.Text + "]"); netSuiteService.addListCompleted += netSuiteService_addListCompleted; loadTasks(); } else { tmrTimeout.Stop(); lblToolStripStatus.Text = "Login failed!"; appendLog(lblToolStripStatus.Text, NOTIFICATION_ERROR); } }
protected NetSuiteService Service(bool requireLogin = false) { if (requireLogin || _Service == null) { bool UseTba = true; _Service = new DataCenterAwareNetSuiteService(ConfigurationManager.AppSettings["login.acct"], "true".Equals(ConfigurationManager.AppSettings["promptForLogin"]) && !UseTba); _Service.Timeout = 1000 * 60 * 60 * 2; //Enable cookie management Uri myUri = new Uri("https://webservices.netsuite.com"); _Service.CookieContainer = new CookieContainer(); _Service.tokenPassport = Token.ins.CreateTokenPassport(); } return(_Service); }
public ActionResult BeginCount(string confirm, WeekForCount week) { if (confirm.Equals("Begin Your New Count")) { NetSuiteService service = this.service; string email = this.email; string password = this.password; PopulateItemDB tableCreation = new PopulateItemDB(); tableCreation.GenerateDB(week.WeekNumber, email, password); } return(RedirectToAction("Index")); // Always return to index. }
/// <summary> /// exceute the upload of files set in the task /// </summary> /// <param name="netSuiteService">netsuite webservice instance</param> /// <param name="taskName">task executed</param> /// <returns>array of task files uploaded</returns> public static TaskFile[] UploadFiles(NetSuiteService netSuiteService, string taskName) { /* ///SINGLE FILE SAMPLE UPLOAD * RecordRef recRef = new RecordRef(); * recRef.internalId = "8700"; * file.folder = recRef; * * WriteResponse wr = netSuiteService.add(file); * lblNotification.Text = wr.status.isSuccess.ToString(); */ string filePath = ConfigurationManager.AppSettings["taskfolder"].ToString().TrimEnd('\\') + @"\" + taskName; string taskContent = System.IO.File.ReadAllText(filePath); List <TaskFile> taskFiles = JsonConvert.DeserializeObject <TaskFile[]>(taskContent).ToList(); List <TaskFile> taskFilesFolders = new List <TaskFile>(); List <Record> records = new List <Record>(taskFiles.Count); for (int i = 0; i < taskFiles.Count; i++) { if (System.IO.Directory.Exists(taskFiles[i].Path)) { ///loop for all files in folder string[] files = System.IO.Directory.GetFiles(taskFiles[i].Path); for (int k = 0; k < files.Length; k++) { TaskFile taskFile = new TaskFile() { Path = files[k], Folderid = taskFiles[i].Folderid }; taskFilesFolders.Add(taskFile); records.Add(createRecord(taskFile)); } } else { ///single file records.Add(createRecord(taskFiles[i])); } } netSuiteService.addListAsync(records.ToArray()); taskFiles.AddRange(taskFilesFolders); return(taskFiles.ToArray()); }
public void getCustomRecord(NetSuiteService service, string recordNo, string recordTypeNo) { CustomRecordRef recWebService = new CustomRecordRef(); recWebService.internalId = recordNo; recWebService.typeId = recordTypeNo; ReadResponse rr = service.get(recWebService); if (rr.status.isSuccess) { CustomRecord currExtension = (CustomRecord)rr.record; ArrayList currExtFieldList = new ArrayList(currExtension.customFieldList); for (int i = 0; i < currExtFieldList.Count; i++) { switch (currExtFieldList[i].GetType().Name) { case "StringCustomFieldRef": StringCustomFieldRef jdeCountry = (StringCustomFieldRef)currExtFieldList[i]; if (jdeCountry.internalId == "custrecord_jdecountry") { txtJDECountry.Text = jdeCountry.value; } break; case "SelectCustomFieldRef": SelectCustomFieldRef objSelect = (SelectCustomFieldRef)currExtFieldList[i]; if (objSelect.internalId == "custrecord_currency") { ListOrRecordRef currency = (ListOrRecordRef)objSelect.value; txtCurrency.Text = currency.name; } else if (objSelect.internalId == "custrecord_subsidiary") { ListOrRecordRef subsidiary = (ListOrRecordRef)objSelect.value; txtSubsidiary.Text = subsidiary.name; } break; } } } else { txtJDECountry.Text = "Failed at isSuccess"; } }
public string createNewBin(InventoryBin bin) { NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; LocationSearch locationSearch = new LocationSearch(); LocationSearchBasic locationSearchBasic = new LocationSearchBasic(); SearchStringField locationName = new SearchStringField(); locationName.searchValue = bin.LocationName; locationName.@operator = SearchStringFieldOperator.@is; locationName.operatorSpecified = true; locationSearchBasic.name = locationName; locationSearch.basic = locationSearchBasic; SearchResult sr = new SearchResult(); sr = service.search(locationSearch); if (sr.status.isSuccess != true) Console.WriteLine(sr.status.statusDetail[0].message); Bin newBin = new Bin(); RecordRef newLocation = new RecordRef(); newLocation.type = RecordType.location; newLocation.typeSpecified = true; newLocation.internalId = ((com.netsuite.webservices.Location)sr.recordList[0]).internalId; newBin.binNumber = bin.BinNumber; newBin.location = newLocation; WriteResponse writeResponse = service.add(newBin); if (writeResponse.status.isSuccess == true) { Console.WriteLine("Bin: "+ newBin.binNumber +" has been created."); return "Bin: " + newBin.binNumber + " has been created."; } if (writeResponse.status.isSuccess == false) { Console.WriteLine(writeResponse.status.statusDetail[0].message); return writeResponse.status.statusDetail[0].message; } return string.Empty; }
public SuiteTalkConnector() { /* * Sets the application to accept all certificates coming from a secure server. * NOTE: This line is only required if the network or application needs to communicate over HTTPS (SSL). */ ServicePointManager.ServerCertificateValidationCallback += delegate { return(true); }; ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; // All web service operations execute against the _service field _service = new NetSuiteService(); // Added to make sure the application works regardless of the data center setDataCenterUrl("ACCT105060"); //setPreferences(); // Set all preferences, search & regular setPassport(); // Set the Passport information for authentication //setTokenPassport(); // Comment out the setPassport() call and uncomment this to use tokens for logging in. }
/// <summary> /// exceute the upload of files set in the task /// </summary> /// <param name="netSuiteService">netsuite webservice instance</param> /// <param name="taskName">task executed</param> /// <returns>array of task files uploaded</returns> public static TaskFile[] UploadFiles(NetSuiteService netSuiteService, string taskName) { /* ///SINGLE FILE SAMPLE UPLOAD RecordRef recRef = new RecordRef(); recRef.internalId = "8700"; file.folder = recRef; WriteResponse wr = netSuiteService.add(file); lblNotification.Text = wr.status.isSuccess.ToString(); */ string filePath = ConfigurationManager.AppSettings["taskfolder"].ToString().TrimEnd('\\') + @"\" + taskName; string taskContent = System.IO.File.ReadAllText(filePath); List<TaskFile> taskFiles = JsonConvert.DeserializeObject<TaskFile[]>(taskContent).ToList(); List<TaskFile> taskFilesFolders = new List<TaskFile>(); List<Record> records = new List<Record>(taskFiles.Count); for (int i = 0; i < taskFiles.Count; i++) { if(System.IO.Directory.Exists(taskFiles[i].Path)) { ///loop for all files in folder string[] files = System.IO.Directory.GetFiles(taskFiles[i].Path); for (int k = 0; k < files.Length; k++) { TaskFile taskFile = new TaskFile() { Path = files[k], Folderid = taskFiles[i].Folderid }; taskFilesFolders.Add(taskFile); records.Add(createRecord(taskFile)); } } else { ///single file records.Add(createRecord(taskFiles[i])); } } netSuiteService.addListAsync(records.ToArray()); taskFiles.AddRange(taskFilesFolders); return taskFiles.ToArray(); }
public static NetSuiteService GetNetSuiteService() { if (passport == null) { passport = new TokenPassport(); passport.account = ConfigurationManager.AppSettings["AccountID"]; passport.consumerKey = ConfigurationManager.AppSettings["ConsumerKey"]; passport.token = ConfigurationManager.AppSettings["TokenId"]; passport.nonce = GenerateNonce(10); passport.timestamp = (Int64)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; passport.signature = GenerateSignature(passport.nonce, passport.timestamp); } if (service == null) { service = new NetSuiteService(); service.tokenPassport = passport; service.Url = ConfigurationManager.AppSettings["URL"]; } return(service); }
public void DeleteBin(InventoryBin bin) { NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; BinSearch binSearch = new BinSearch(); BinSearchBasic bSBasic = new BinSearchBasic(); SearchStringField binName = new SearchStringField(); binName.searchValue = bin.BinNumber; binName.@operator = SearchStringFieldOperator.@is; binName.operatorSpecified = true; bSBasic.binNumber = binName; binSearch.basic = bSBasic; SearchResult sr = new SearchResult(); sr = service.search(binSearch); if (sr.status.isSuccess != true) Console.WriteLine(sr.status.statusDetail[0].message); RecordRef binToDelete = new RecordRef(); binToDelete.type = RecordType.bin; binToDelete.typeSpecified = true; binToDelete.name = bin.BinNumber; binToDelete.internalId = ((Bin)sr.recordList[0]).internalId; WriteResponse writeResponse = service.delete(binToDelete); if (writeResponse.status.isSuccess == true) { Console.WriteLine("Bin: " + binToDelete.name + " has been deleted."); } if (writeResponse.status.isSuccess == false) { Console.WriteLine(writeResponse.status.statusDetail[0].message); } }
public void addBinRecord(string binNumber) { NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; SearchStringField objBinNumber = new SearchStringField(); objBinNumber.searchValue = binNumber; objBinNumber.@operator = SearchStringFieldOperator.@is; objBinNumber.operatorSpecified = true; BinSearch objBinSearch = new BinSearch(); objBinSearch.basic = new BinSearchBasic(); objBinSearch.basic.binNumber = objBinNumber; SearchResult objBinResult = service.search(objBinSearch); if (objBinResult.status.isSuccess == false) throw new Exception("Unable to find bin " + binNumber + " is NetSuite"); if (((Bin)objBinResult.recordList[0]).isInactive) throw new Exception("Bin Number " + binNumber + " is inactive in NetSuite"); this.binRecord = new Bin(); this.binRecord = (Bin)objBinResult.recordList[0]; }
/// <summary> /// /// </summary> /// <param name="netSuiteService">netsuite webservice instance</param> /// <param name="account">account</param> /// <returns>session service response</returns> public SessionResponse login(NetSuiteService netSuiteService) { try { Passport passport = new Passport(); passport.account = this.Account; passport.email = this.Email; passport.password = this.Password; //RecordRef role = new RecordRef(); //role.internalId = "3"; //passport.role = role; netSuiteService.CookieContainer = new CookieContainer(); //netSuiteService.Url = "https://webservices.na1.netsuite.com/services/NetSuitePort_2014_2"; SessionResponse sessionResponse = netSuiteService.login(passport); return sessionResponse; } catch (Exception ex) { ex.ToString(); return null; } }
public ActionResult LogIn(LogInModel model) { var email = model.Email + "@instrumart.com"; // Log-in through Netsuite: if (ModelState.IsValid) { NetSuiteService service = new NetSuiteService(); try { var login = service.xLogin(Int32.Parse(ConfigurationManager.AppSettings["NetSuiteAccountNumber"]), email, model.Password, Int32.Parse(ConfigurationManager.AppSettings["NetSuiteRoleNumber"])); Session["NetSuiteService"] = service; var counterID = login.userId.internalId; Employee employee = service.xGetRecord <Employee>(counterID as string); Session["CounterInitials"] = employee.initials as string; } catch (System.Web.Services.Protocols.SoapException) { ModelState.AddModelError("Email", "Invalid Email or Password. Try again."); } } if (ModelState.IsValid) { // Brings user to the page they wanted to go to FormsAuthentication.SetAuthCookie(model.Email, false); Session["Email"] = email; Session["Password"] = model.Password; return(RedirectToAction("Index", "Home")); } else { return(View(model)); } }
/// <summary> /// /// </summary> /// <param name="netSuiteService">netsuite webservice instance</param> /// <param name="account">account</param> /// <returns>session service response</returns> public SessionResponse login(NetSuiteService netSuiteService) { try { Passport passport = new Passport(); passport.account = this.Account; passport.email = this.Email; passport.password = this.Password; //RecordRef role = new RecordRef(); //role.internalId = "3"; //passport.role = role; netSuiteService.CookieContainer = new CookieContainer(); //netSuiteService.Url = "https://webservices.na1.netsuite.com/services/NetSuitePort_2014_2"; SessionResponse sessionResponse = netSuiteService.login(passport); return(sessionResponse); } catch (Exception ex) { ex.ToString(); return(null); } }
public New_Lead() { _isAuthenticated = false; _service = new NetSuiteService(); _service.Timeout = 1000*60*60*2; //Enable cookie management Uri myUri = new Uri("http://www.domain.com"); _service.CookieContainer = new CookieContainer(); }
public string markAsShipped() { ItemFulfillmentShipStatus shipped = ItemFulfillmentShipStatus._shipped; ItemFulfillment updatedOrder = new ItemFulfillment(); updatedOrder.itemFulfillment = new com.netsuite.webservices.ItemFulfillment(); updatedOrder.itemFulfillment.internalId = this.itemFulfillment.internalId; updatedOrder.itemFulfillment.shipStatus = shipped; updatedOrder.itemFulfillment.shipStatusSpecified = true; NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; WriteResponse writeResponse = service.update(updatedOrder.itemFulfillment); if (writeResponse.status.isSuccess == true) { Console.WriteLine("Item Fulfillment " + this.itemFulfillment.tranId + " marked as shipped."); } if (writeResponse.status.isSuccess == false) { Console.WriteLine(writeResponse.status.statusDetail[0].message); } return this.itemFulfillment.tranId; }
public string createItemFulfillment() { NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; WriteResponse writeResponse = service.add(this.itemFulfillment); if (writeResponse.status.isSuccess == true) { Console.WriteLine("Create Item Fulfillment success"); return "Create Item Fulfillment Success"; } if (writeResponse.status.isSuccess == false) { Console.WriteLine(writeResponse.status.statusDetail[0].message); return writeResponse.status.statusDetail[0].message; } return string.Empty; }
public string addBin(InventoryBin itemBin) { NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; SearchStringField objItemName = new SearchStringField(); objItemName.searchValue = itemBin.InventoryItem.ItemName; objItemName.@operator = SearchStringFieldOperator.@is; objItemName.operatorSpecified = true; ItemSearch objItemSearch = new ItemSearch(); objItemSearch.basic = new ItemSearchBasic(); objItemSearch.basic.itemId = objItemName; SearchResult objItemResult = service.search(objItemSearch); if (objItemResult.status.isSuccess != true) { Console.WriteLine("Cannot find Item " + itemBin.InventoryItem.ItemName + " " + objItemResult.status.statusDetail[0].message); return "Cannot find Item " + itemBin.InventoryItem.ItemName + " " + objItemResult.status.statusDetail[0].message; } if (objItemResult.recordList.Count() != 1) { Console.WriteLine("More than one item found for item " + itemBin.InventoryItem.ItemName); return "More than one item found for item " + itemBin.InventoryItem.ItemName; } SearchStringField objBinNumber = new SearchStringField(); objBinNumber.searchValue = itemBin.BinNumber; objBinNumber.@operator = SearchStringFieldOperator.@is; objBinNumber.operatorSpecified = true; BinSearch objBinSearch = new BinSearch(); objBinSearch.basic = new BinSearchBasic(); objBinSearch.basic.binNumber = objBinNumber; SearchResult objBinResult = service.search(objBinSearch); if (objBinResult.status.isSuccess == false) { Console.WriteLine("Unable to find bin " + itemBin.BinNumber + " in NetSuite"); return "Unable to find bin " + itemBin.BinNumber + " in NetSuite"; } if (objItemResult.recordList.Count() != 1) { Console.WriteLine("More than one bin found for " + itemBin.BinNumber); return "More than one bin found for " + itemBin.BinNumber; } if (((Bin)objBinResult.recordList[0]).isInactive) { Console.WriteLine("Bin Number " + itemBin.BinNumber + " is inactive in NetSuite"); return "Bin Number " + itemBin.BinNumber + " is inactive in NetSuite"; } RecordRef objAddBin = new RecordRef(); objAddBin.type = RecordType.bin; objAddBin.typeSpecified = true; objAddBin.internalId = ((Bin)objBinResult.recordList[0]).internalId; objAddBin.name = ((Bin)objBinResult.recordList[0]).binNumber; InventoryItemBinNumber objItemBinNumber = new InventoryItemBinNumber(); objItemBinNumber.location = ((Bin)objBinResult.recordList[0]).location.internalId; objItemBinNumber.binNumber = objAddBin; InventoryItemBinNumber[] objItemBinNumbers = new InventoryItemBinNumber[1]; objItemBinNumbers[0] = objItemBinNumber; if(((InventoryItem)objItemResult.recordList[0]).useBins==true) { //Initialize item to update InventoryItem objInventoryItem = new InventoryItem(); objInventoryItem.internalId = ((InventoryItem)objItemResult.recordList[0]).internalId; objInventoryItem.salesDescription = ((InventoryItem)objItemResult.recordList[0]).salesDescription; objInventoryItem.purchaseDescription = ((InventoryItem)objItemResult.recordList[0]).purchaseDescription; objInventoryItem.binNumberList = new InventoryItemBinNumberList(); objInventoryItem.binNumberList.binNumber = objItemBinNumbers; objInventoryItem.binNumberList.replaceAll = false; //Request to update item with bins WriteResponse objWriteResponse = service.update(objInventoryItem); if (objWriteResponse.status.isSuccess != true) { Console.WriteLine(objWriteResponse.status.statusDetail[0].message); return objWriteResponse.status.statusDetail[0].message; } Console.WriteLine("Bins successfully updated for: "+((InventoryItem)objItemResult.recordList[0]).itemId); return "Bins successfully updated for: " + ((InventoryItem)objItemResult.recordList[0]).itemId; } return string.Empty; }
public void uploadXMLMaxCredible(NetSuiteService service) { //Start processing for MaxCredible upload int currentMCRecord= 0; int currentMCChunk = 1; HTTP_POSTS theseHTTPSPOSTS = new HTTP_POSTS(); theseHTTPSPOSTS.NR_RECORDS = _SSRECORDS.Length.ToString(); int MCchunkSize = Convert.ToInt32(_MaxCredibleData.CHUNK_SIZE); int MCchunkQty = Convert.ToInt32(TxtChunkQty.Text); ProgressMCUpload.Maximum = _SSRECORDS.Length; string MCBatchName = Settings.Default.MC_XMLOutputPrefix + System.DateTime.Now.ToString("ddMMyyHHmmss"); for (int i = 0; i < _SSRECORDS.Length; i++) { TransactionSearchRow TSR = (TransactionSearchRow)_SSRECORDS[i]; theseHTTPSPOSTS.CHUNK_NR = currentMCChunk.ToString(); currentMCRecord = i + 1; HTTP_POST thisHTTPPOST = createHTTP_POST(TSR); thisHTTPPOST.RECORD_NR = currentMCRecord.ToString(); theseHTTPSPOSTS.HTTP_POST.Add(thisHTTPPOST); AppendTextBoxLine(TxtMaxCredibleUpload, " Invoice " + currentMCRecord.ToString("0000") + "\t" + thisHTTPPOST.FACTUURNUMMER, true); if ((currentMCRecord % MCchunkSize == 0 && i != 0) || currentMCRecord == _SSRECORDS.Length) { XmlSerializer XMLData = new XmlSerializer(theseHTTPSPOSTS.GetType()); if (System.IO.Directory.Exists(Settings.Default.MC_XMLOutputDir)) { StreamWriter XMLfile = new StreamWriter(Settings.Default.MC_XMLOutputDir + MCBatchName + currentMCChunk.ToString("0000") + ".xml", false); XMLData.Serialize(XMLfile, theseHTTPSPOSTS); XMLfile.Close(); AppendTextBoxLine(TxtMaxCredibleUpload, "Chunk " + currentMCChunk + " of " + MCchunkQty + " created", true); } if (!ChkFileXMLOnly.Checked)// Read back in and upload to MaxCredible { try { XmlNode MCResponseNode; XmlDocument MCRequestDoc = new XmlDocument(); XmlTextReader XMLTextReader = new XmlTextReader(Settings.Default.MC_XMLOutputDir + MCBatchName + currentMCChunk.ToString("0000") + ".xml"); MCRequestDoc.Load(XMLTextReader); string MCXML = MCRequestDoc.OuterXml.Replace("<HTTP_POST><HTTP_POST>", "<HTTP_POST>").Replace("</HTTP_POST></HTTP_POST>", "</HTTP_POST>"); //Remove outer list node as MaxCredible does not implement //This really needs more elegant XML node / attribute transform handling but just quick string replacements at the moment ... //Before - <HTTP_POSTS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> //After - <HTTP_POSTS xmlns="http://www.MaxCredible.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="Posten_Batch.xsd"> MCXML = MCXML.Replace("<HTTP_POSTS ", "<HTTP_POSTS xmlns=\"http://www.MaxCredible.com/\" xsi:schemaLocation=\"Posten_Batch.xsd\" "); MCXML = MCXML.Replace(" encoding=\"utf-8\"", ""); //Breaks if encoding present System.IO.File.WriteAllText(Settings.Default.MC_XMLOutputDir + "Request_" + currentMCChunk.ToString("0000") + ".xml", MCXML); MCResponseNode = _MaxCredibleService.XMLBatchReceive(Settings.Default.MC_UserName, Settings.Default.MC_Password, MCBatchName, MCXML); AppendTextBoxLine(TxtMaxCredibleUpload, "MC Response Chunk " + currentMCChunk.ToString("0000") + " : " + MCResponseNode.OuterXml, true); } catch (Exception ex) { MessageBox.Show("MaxCredible Web Services Error :\n" + ex.Message); } } currentMCChunk++; ProgressMCUpload.Value = currentMCRecord; theseHTTPSPOSTS.HTTP_POST.Clear(); //Ready for next chunk } } //Write textbox contents to log file - deprecated as now done as text box appended //if (Settings.Default.APP_LogFileName != "") //{ // System.IO.File.WriteAllText(Settings.Default.MC_XMLOutputDir + Settings.Default.APP_LogFileName, TxtMaxCredibleUpload.Text); // AppendTextBoxLine(TxtMaxCredibleUpload, "Log file created : " + Settings.Default.APP_LogFileName, false); //} }
public static string Login(string strUser, string strPassword, string strAccount, string strRole) { string strResult = null; try { Passport passport = new Passport(); RecordRef role = new RecordRef(); passport.email = strUser; passport.password = strPassword; role.internalId = strRole; passport.role = role; passport.account = strAccount; _service = new NetSuiteService(); _service.Timeout = 1000 * 60 * 60 * 2; _service.passport = passport; SessionResponse objResponse = _service.login(passport); if (!objResponse.status.isSuccess) { strResult = objResponse.status.statusDetail[0].message; } Console.WriteLine(_service.Url); } catch (Exception objExc) { strResult = objExc.Message; } return strResult; }
public bool placeSalesOrder() { bool success = false; NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; /* SelectCustomFieldRef tempCustFieldRef = new SelectCustomFieldRef(); tempCustFieldRef.internalId = "148"; tempCustFieldRef.scriptId = "custbodycustbodycust_fob"; tempCustFieldRef.value.internalId = "3"; this.salesOrder.customFieldList = new CustomFieldRef[4]; this.salesOrder.customFieldList[4] = new SelectCustomFieldRef(); this.salesOrder.customFieldList[4] = tempCustFieldRef; */ WriteResponse writeResponse = service.add(this.salesOrder); if (writeResponse.status.isSuccess == true) { success = true; Console.WriteLine("Sales Order success"); Console.WriteLine(((RecordRef)writeResponse.baseRef).internalId); return success; } else { success = false; Console.WriteLine(writeResponse.status.statusDetail[0].message); return success; } }
public void editFulfillment(List<ItemFulfillmentLine> fulfillmentLines) { ItemFulfillment updatedFulfillment = new ItemFulfillment(); updatedFulfillment.itemFulfillment = new com.netsuite.webservices.ItemFulfillment(); updatedFulfillment.itemFulfillment.internalId = this.itemFulfillment.internalId; updatedFulfillment.itemFulfillment.itemList = new ItemFulfillmentItemList(); // updatedFulfillment.itemFulfillment.itemList.item = new ItemFulfillmentItem[this.itemFulfillment.itemList.item.Length]; //bool flag = false; //bool contains = false; //bool contains1 = false; foreach (var line in fulfillmentLines) { foreach (var itemObject in this.itemFulfillment.itemList.item) { //if (itemObject.item.name.Contains(line.item.ItemName)) if (itemObject.item.name.Contains(line.item.ItemName) && (line.delete == true)) { this.itemFulfillment.itemList.item = this.itemFulfillment.itemList.item.Where(val => !val.item.name.Contains(line.item.ItemName)).ToArray(); //ItemFulfillmentItem ifi = new ItemFulfillmentItem(); //ifi.orderLine = itemObject.orderLine; } if (itemObject.item.name.Contains(line.item.ItemName) && (line.delete == false)) { itemObject.quantity = line.QuantityRequested; } if (!itemObject.item.name.Contains(line.item.ItemName) && (line.delete == false)) { } if (!itemObject.item.name.Contains(line.item.ItemName) && (line.delete == true)) { } } } updatedFulfillment.itemFulfillment.itemList = this.itemFulfillment.itemList; //updatedFulfillment.itemFulfillment.itemList.item = this.itemFulfillment.itemList.item; NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; WriteResponse writeResponse = service.update(updatedFulfillment.itemFulfillment); if (writeResponse.status.isSuccess == true) { Console.WriteLine("Update Item Fulfillment success"); } if (writeResponse.status.isSuccess == false) { Console.WriteLine(writeResponse.status.statusDetail[0].message); } }
public ActionResult InventoryAdjustment() { List <int> summmary = SummaryOfCurrentCount(); if (summmary[2] != 0 || !AdminEmails.Contains(this.email)) // If there are items left to count, return them to the home page { return(RedirectToAction("Index")); } NetSuiteService service = this.service; // Create the adjustment object InventoryAdjustment adjustment = new InventoryAdjustment(); adjustment.account = new RecordRef(RecordType.account, 147); // Set the adjustment account (147 is NetSuite ID) adjustment.adjLocation = new RecordRef(RecordType.location, 1); // Set adjustment location of South Burlington (1 is NetSuite ID) // All items var items = from m in db.Items select m; // Determine the Week for the count // Take the one code that is greater than 39 (Class C items) and determine the week by subtracting 39 from that code int[] CycleCodes = items.Select(x => x.CycleCountCode).Distinct().ToArray(); int week = 0; foreach (int cyclecode in CycleCodes) { if (cyclecode > 39) { week = cyclecode - 39; } } if (this.NonWeeklyCount != true) { adjustment.memo = "cycle count " + week.ToString() + "--" + DateTime.Now.Year; // Set the adjustment memo } else { adjustment.memo = "entire column count " + DateTime.Now.Year; } // List of items that have been changed var itemsChanged = items.ToList().Where(x => x.OnHand != x.NewOnHand); // We only care about items that have different qty for Adjustments // List of items with bin location changes var binLocationChanged = items.ToList().Where(x => x.NewBinLocation != x.BinLocation); // Create a List of InventoryAdjustmentInventory InventoryAdjustmentInventoryList inventoryList = new InventoryAdjustmentInventoryList(); // Required for Adjustment inventoryList.inventory = new InventoryAdjustmentInventory[itemsChanged.Count()]; // An array of items to be changed int currentIndex = 0; // Keep track of the index // Change the Bin Location for items that have different Bins foreach (var item in binLocationChanged) { var id = item.ID.ToString(); InventoryItem ii = new InventoryItem(); ii.internalId = id; ii.xSetCustomField("custitem_bin_location", item.NewBinLocation.ToString()); service.xUpdate(ii); } if (itemsChanged == null && binLocationChanged != null) { ViewBag.BinOnly = "You have only adjusted the Bin Location, no Inventory adjustment has been created."; } // Create Inventory adjustment for items that have different quantities if (itemsChanged.Count() != 0) { foreach (var item in itemsChanged) // Set the required fields for the Adjustment { InventoryAdjustmentInventory iai = new InventoryAdjustmentInventory(); iai.item = new RecordRef((item.ID).ToString()); iai.location = new RecordRef("1"); iai.xSetAdjustQtyBy(item.NewOnHand - item.OnHand); iai.memo = item.CounterInitials + ": " + item.Notes; inventoryList.inventory[currentIndex] = iai; // Add to array currentIndex++; // Update the Index } adjustment.inventoryList = inventoryList; // Required for adjustment var sumAdjusted = adjustment.inventoryList.inventory.Sum(x => x.adjustQtyBy); // Check to make sure that the local count and NetSuite count match WriteResponse adjustmentAdded = service.xAdd(adjustment); // Push to Netsuite if (adjustmentAdded.status.isSuccess) // Checks to make sure that the adjustment push was successfull { // Create a copy Adjustment to check against the local copy var id = adjustment.internalId; var CountItemsChanged = itemsChanged.Count(); InventoryAdjustment ia = service.xGetRecord <InventoryAdjustment>(id); var sumAdjustedCheck = ia.inventoryList.inventory.Sum(x => x.adjustQtyBy); if (sumAdjusted == sumAdjustedCheck) // Makes sure the quantity changes are the same { ViewBag.adjustmentID = id; return(View(adjustmentAdded)); // We are good to delete the count } else // The quantities are different { ViewBag.ErrorMessage("Something went wrong. Please check NetSuite and make sure everything is EXACTLY as you have entered in this software."); return(View(adjustmentAdded));// Need to check NetSuite, something went wrong } } else // The NetSuite push was not successfull { ViewBag.ErrorMessage = adjustmentAdded.status.statusDetail[0].message.ToString(); return(View(adjustmentAdded)); } } // The user only changed the notes ViewBag.NotesOnly = "You did not change the quantity or bin location of any item in the count. Nothing has changed in NetSuite."; return(View()); }
public void itemFulfillmentSearch(string orderNumber) { NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; TransactionSearchAdvanced tranSearchAdvanced = new TransactionSearchAdvanced(); TransactionSearch tranSearch = new TransactionSearch(); SearchStringField orderID = new SearchStringField(); orderID.@operator = SearchStringFieldOperator.@is; orderID.operatorSpecified = true; orderID.searchValue = orderNumber; TransactionSearchBasic tranSearchBasic = new TransactionSearchBasic(); tranSearchBasic.tranId = orderID; tranSearch.basic = tranSearchBasic; tranSearchAdvanced.criteria = tranSearch; SearchPreferences searchPreferences = new SearchPreferences(); searchPreferences.bodyFieldsOnly = false; service.searchPreferences = searchPreferences; SearchResult transactionResult = service.search(tranSearchAdvanced); if (transactionResult.status.isSuccess != true) throw new Exception("Cannot find Order " + orderNumber + " " + transactionResult.status.statusDetail[0].message); if (transactionResult.recordList.Count() != 1) throw new Exception("More than one order found for item " + orderNumber); this.itemFulfillment = new com.netsuite.webservices.ItemFulfillment(); this.itemFulfillment = ((com.netsuite.webservices.ItemFulfillment)transactionResult.recordList[0]); }
public void setupNetSuiteObjects(NetSuiteService service) { try //Using a session test - if it fails then login ... { GetServerTimeResult testResult = service.getServerTime(); } catch { AppendTextBoxLine(txtSearchResults, "Logging in ...", true); Passport passport = new Passport(); passport.account = Settings.Default.NS_AccountID; passport.email = Settings.Default.NS_UserEmail; RecordRef role = new RecordRef(); role.internalId = Settings.Default.NS_Role; passport.role = role; passport.password = Settings.Default.NS_Password; Status loginStatus = service.login(passport).status; if (loginStatus.isSuccess) { AppendTextBoxLine(txtSearchResults, "Logged in OK : " + passport.account + " : " + passport.email, true); } else { AppendTextBoxLine(txtSearchResults, "Login Error : " + loginStatus.statusDetail[0].message, true); } } }
public void savedSearchMaxCredible(NetSuiteService service) { TransactionSearchAdvanced TSA = new TransactionSearchAdvanced(); TSA.savedSearchScriptId = TxtSavedSearch1.Text; TransactionSearch TS = new TransactionSearch(); TransactionSearchBasic TSB = new TransactionSearchBasic(); if (Settings.Default.APP_DatesEnabled) { DateTime theSearchStartDate = DTPickerFrom.Value; DateTime theSearchFinishDate = DTPickerTo.Value; SearchDateField theDTSearch = new SearchDateField(); theDTSearch.operatorSpecified = true; theDTSearch.@operator = SearchDateFieldOperator.within; theDTSearch.searchValue2Specified = true; theDTSearch.searchValueSpecified = true; theDTSearch.searchValue = theSearchStartDate; theDTSearch.searchValue2 = theSearchFinishDate; TSB.tranDate = theDTSearch; } TS.basic = TSB; TSA.criteria = TS; AppendTextBoxLine(txtSearchResults, "Performing search ...", true); SearchResult SR = service.search(TSA); if (SR.totalRecords == 0) { AppendTextBoxLine(txtSearchResults, "No records / consignments were returned in the Saved Search : " + TxtSavedSearch1.Text, true); } else { AppendTextBoxLine(txtSearchResults, SR.totalRecords + " records / consignments were returned in the Saved Search : " + TxtSavedSearch1.Text, true); SearchRow[] SSR; SSR = SR.searchRowList; SearchRow[] SSRM; // Build Intermediate List to allow pagination System.Collections.ArrayList theInvoiceList = new System.Collections.ArrayList(); for (int ssr = 0; ssr < SSR.Length; ssr++) theInvoiceList.Add(SSR[ssr]); AppendTextBoxLine(txtSearchResults, "Records downloaded : " + theInvoiceList.Count + " of " + SR.totalRecords.ToString(), true); if (SR.totalRecords > SR.pageSize) { int batchNo = 2; // Keep getting pages until there are no more pages to get while (SR.totalRecords > ((batchNo - 1) * SR.pageSize)) { AppendTextBoxLine(txtSearchResults, "Fetching next batch no. " + batchNo, true); // Invoke searchMore() operation - ensure logged in ... setupNetSuiteObjects(service); // To ensure logged in before next batch SearchResult SRM = service.searchMore(batchNo); if (SRM != null) { // Process response if (SRM.status.isSuccess) { SSRM = SRM.searchRowList; for (int ssrm = 0; ssrm < SSRM.Length; ssrm++) theInvoiceList.Add(SSRM[ssrm]); AppendTextBoxLine(txtSearchResults, "Records downloaded : " + theInvoiceList.Count + " of " + SR.totalRecords.ToString(), true); batchNo++; } else { AppendTextBoxLine(txtSearchResults, getStatusDetails(SRM.status), true); } } } } _SSRECORDS = new SearchRow[theInvoiceList.Count]; IEnumerator iienum = theInvoiceList.GetEnumerator(); for (int iicr = 0; iienum.MoveNext(); iicr++) { _SSRECORDS[iicr] = (SearchRow)iienum.Current; } //Record list assembly complete - create list for MaxCredible upload ProgressNSSearch.Maximum = _SSRECORDS.Length; for (int i = 0; i < _SSRECORDS.Length; i++) { TransactionSearchRow TSR = (TransactionSearchRow)_SSRECORDS[i]; // Declare all the variables for use when writing the file... //DOCNUM string theInternalid = ""; if (TSR.basic.internalId != null) { theInternalid = TSR.basic.internalId[0].searchValue.internalId; } string sDocNum = ""; if (TSR.basic.tranId != null) { sDocNum = TSR.basic.tranId[0].searchValue.ToString(); } //DATE string sDate = ""; if (TSR.basic.tranDate != null) { sDate = TSR.basic.tranDate[0].searchValue.ToString("dd/MM/yyyy"); } AppendTextBoxLine(txtSearchResults, (i+1) + "\t" + theInternalid + "\t" + sDocNum + "\t" + sDate, false); ProgressNSSearch.Value++; } // Set up MaxCredible Data defaults based on records returned _MaxCredibleData.NR_RECORDS = _SSRECORDS.Length.ToString(); _MaxCredibleData.CHUNK_SIZE = TxtChunkSize.Text; GrpMaxCredible.Text = "Step 2 - Upload " + _MaxCredibleData.NR_RECORDS + " Records to MaxCredible"; updateChunkSizes(); } return; }
public void setupNetSuiteObjects(NetSuiteService service) { Passport passport = new Passport(); passport.account = "3524453"; passport.email = "*****@*****.**"; RecordRef role = new RecordRef(); role.internalId = "3"; passport.role = role; passport.password = "******"; //remember to replace Status loginStatus = service.login(passport).status; }
//TimeZoneInfo _logTimeZone = TimeZoneInfo.FindSystemTimeZoneById(Settings.Default.APP_LogTimeZoneCultureInfo); public MaxCredible_Export() { InitializeComponent(); TxtSavedSearch1.Text = Settings.Default.NS_MaxCredible_Savedsearch; DTPickerTo.Value = System.DateTime.Now.Date.AddDays(Settings.Default.APP_DefaultDateOffset); double delDayOffset = Settings.Default.APP_DefaultDateRange + Settings.Default.APP_DefaultDateOffset; DTPickerFrom.Value = System.DateTime.Now.Date.AddDays(delDayOffset); if (!Settings.Default.APP_DatesEnabled) { DTPickerFrom.Visible = false; lblDTFrom.Visible = false; DTPickerTo.Visible = false; lblDTTo.Visible = false; } _NSservice = new NetSuiteService(); _NSFileLog.deleteLog(); _MaxCredibleData = new HTTP_POSTS(); _MaxCredibleService = new Invoer_mc(); string environment = ""; #if useNSSandbox // override with live URLs if set in config file environment = "SANDBOX/STAGING"; if (Settings.Default.APP_UseLiveWebServices) { environment = "LIVE"; _NSservice.Url = Settings.Default.NS_com_netsuite_webservices_NetSuiteService; _MaxCredibleService.Url = Settings.Default.MaxCredibleExport_com_maxcredible_secure5_Invoer_mc; } #else // live build so invert the web services URLs logic environment = "LIVE"; if (!Settings.Default.APP_UseLiveWebServices) { environment = "SANDBOX/STAGING"; _NSservice.Url = Settings.Default.NS_com_netsuite_sandbox_webservices_NetSuiteService; _MaxCredibleService.Url = Settings.Default.MaxCredibleExport_com_maxcredible_secure6_Invoer_mc; } #endif GrpNSSearch.Text += " " + environment; GrpMaxCredible.Text += " " + environment; _NSservice.CookieContainer = new System.Net.CookieContainer(); setupNetSuiteObjects(_NSservice); //Set up defaults for processing flow if (Settings.Default.APP_XMLFileOnly) ChkFileXMLOnly.Checked = true; if (Settings.Default.APP_AutoFinish) ChkAutoFinish.Checked = true; if (Settings.Default.APP_AutoUpload) ChkAutoUpload.Checked = true; if (!ChkFileXMLOnly.Checked)// Read back in and upload to MaxCredible { try { System.Net.ServicePointManager.CertificatePolicy = new MaxCrediblePolicy(); X509Certificate Cert = X509Certificate.CreateFromCertFile(Settings.Default.MC_CertificateFile); //Defined in config file _MaxCredibleService.ClientCertificates.Add(Cert); } catch (Exception ex) { MessageBox.Show("MaxCredible Security / Certificate Error :\nCertificate File :" + Settings.Default.MC_CertificateFile + "\n" + ex.Message); ChkFileXMLOnly.Checked = true; ChkFileXMLOnly.Enabled = false; } } if (Settings.Default.APP_AutoSearch) btnGet_Click(null, EventArgs.Empty); }
private void btnGet_Click(object sender, EventArgs e) { NetSuiteService service = new NetSuiteService(); service.CookieContainer = new System.Net.CookieContainer(); setupNetSuiteObjects(service); getCustomRecord(service, "1", "13"); //this.Refresh(); //MessageBox.Show("hello world", "hello world"); //getCustomRecord(service, "2", "13"); savedSearch(service, "19"); Status logoutStatus = service.logout().status; if (logoutStatus.isSuccess) { lblFinished.Text = "Finished"; } }
/// <summary> /// call the login service /// </summary> /// <param name="account">netsuite account</param> private void executeLogin(string account) { string _account = string.IsNullOrEmpty(account) ? ConfigurationManager.AppSettings["account"].Split(',')[0] : account; if (_account.Contains('|')) _account = _account.Split('|')[0]; Login login = new Login(_account); bool isSandbox = false; if(!string.IsNullOrEmpty(account)) { DialogResult dlrSandbox = MessageBox.Show("Connect to sandbox account?", "Question", MessageBoxButtons.YesNo); isSandbox = (dlrSandbox == DialogResult.Yes); } netSuiteService = new DataCenterAwareNetSuiteService(login.Account, isSandbox); ///password not mandatory in configuration if (string.IsNullOrEmpty(login.Password)) { FrmDialog passwordDialog = new FrmDialog(); passwordDialog.Text = login.Email; if (passwordDialog.ShowDialog(this) == DialogResult.OK) { login.Password = passwordDialog.txtPassword.Text; } else { login.Password = string.Empty; } passwordDialog.Dispose(); } sessionResponse = login.login(netSuiteService); if (sessionResponse != null && sessionResponse.status.isSuccess) { lblToolStripStatus.Text = ((isSandbox) ? "SANDBOX " : "") + "Account: " + login.Account + " - Email: " + login.Email; appendLog("Login done [" + lblToolStripStatus.Text + "]"); netSuiteService.addListCompleted += netSuiteService_addListCompleted; loadTasks(); } else { tmrTimeout.Stop(); lblToolStripStatus.Text = "Login failed!"; appendLog(lblToolStripStatus.Text, NOTIFICATION_ERROR); } }
public string deleteFulfillment() { NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; RecordRef orderToBeDeleted = new RecordRef(); orderToBeDeleted.type = RecordType.itemFulfillment; orderToBeDeleted.typeSpecified = true; orderToBeDeleted.internalId = this.itemFulfillment.internalId; WriteResponse writeResponse = service.delete(orderToBeDeleted); if (writeResponse.status.isSuccess == true) { Console.WriteLine("Delete Item Fulfillment " + this.itemFulfillment.tranId + " success"); return "Delete Item Fulfillment " + this.itemFulfillment.tranId + " success"; } if (writeResponse.status.isSuccess == false) { Console.WriteLine(writeResponse.status.statusDetail[0].message); return writeResponse.status.statusDetail[0].message; } return string.Empty; }
public CustomerExample() { this.service = ConnectionManager.GetNetSuiteService(); }
/// <summary> /// logout /// </summary> /// <param name="netSuiteService">netsuite webservice instance</param> /// <param name="sessionResponse">session service response</param> public void logout(NetSuiteService netSuiteService, SessionResponse sessionResponse) { if (sessionResponse != null && sessionResponse.status.isSuccess) netSuiteService.logout(); }
public void setCustomer(string customerID) { NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; CustomerSearch customerSearch = new CustomerSearch(); customerSearch = CustomerNameSearch(customerID); SearchResult searchResult = service.search(customerSearch); if (searchResult.status.isSuccess) { if (searchResult.recordList != null && searchResult.recordList.Length == 1) { string entityID = ((Customer)searchResult.recordList[0]).entityId; Console.WriteLine(entityID); } } else { throw new Exception("Cannot find Customer " + customerID + " " + searchResult.status.statusDetail[0].message); } this.salesOrder.entity = createCustomer(searchResult); }
public void createInvoice() { NetSuiteService service = new NetSuiteService(); service.CookieContainer = new CookieContainer(); NetsuiteUser user = new NetsuiteUser("3451682", "*****@*****.**", "1026", "tridenT168"); Passport passport = user.prepare(user); Status status = service.login(passport).status; WriteResponse writeResponse = service.add(this.invoice); if (writeResponse.status.isSuccess == true) { Console.WriteLine("Create Invoice success"); } if (writeResponse.status.isSuccess == false) { Console.WriteLine(writeResponse.status.statusDetail[0].message); } }
private void btnConnect_Click(object sender, EventArgs e) { //Se non si è loggati si connette if (!logged) { if (cmbAccount.SelectedItem != null) { //Messaggio Connessione lblStatusConnection.Text = "Login in corso..."; //Istanza Servizio NetSuite service = new NetSuiteService(); //Lettura Credenziali string account = cmbAccount.SelectedItem.ToString(); string email = txtEmail.Text; string password = txtPassword.Text; MemoryExecutionContext ctx = new MemoryExecutionContext(logger); ctx.setSessionValue<NetSuiteService>("svcNS",service); //Ricerca Url WebService DataCenterAwareNetSuiteService DataCenter_Url = new DataCenterAwareNetSuiteService(account); service.Url = DataCenter_Url.Url; service.AllowAutoRedirect = true; service.CookieContainer = new System.Net.CookieContainer(); //Connessione Passport passport = new Passport(); passport.account = account; passport.email = email; passport.password = password; try { Status status = service.login(passport).status; //Connessione Riuscita Con Successo panelLogin.BackColor = Color.LightGreen; logged = true; lblStatusConnection.Text = "Connesso"; btnConnect.Text = "Disconnect"; //Abilito Comandi Programma EnableControls(this); btnStart.Enabled = false; } catch (SoapException ex) { panelLogin.BackColor = Color.Red; lblStatusConnection.Text = "Connessione non riuscita! " + ex.Message; } } else MessageBox.Show("Seleziona l'Account !"); } else { //Logout NetSuite service.logout(); //Disabilito comandi Programma se non Connesso DisableControls(this); logged = false; panelLogin.BackColor = Color.Transparent; btnConnect.Text = "Connect"; lblStatusConnection.Text = "Non Connesso"; txtEmail.Text = ""; txtPassword.Text = ""; cmbAccount.SelectedItem = null; listBoxCommands.Items.Clear(); rtbLogCommand.Clear(); } }
public Dictionary<string, double> getBins(string SKU) { NetSuiteService objService = new NetSuiteService(); objService.CookieContainer = new CookieContainer(); Passport passport = new Passport(); passport.account = "3451682"; passport.email = "*****@*****.**"; RecordRef role = new RecordRef(); role.internalId = "1026"; passport.role = role; passport.password = "******"; Passport objPassport = passport; Status objStatus = objService.login(objPassport).status; ItemSearchAdvanced isa = new ItemSearchAdvanced(); isa.savedSearchId = "141"; //substitute your own saved search internal ID ItemSearch iS = new ItemSearch(); ItemSearchBasic isb = new ItemSearchBasic(); SearchStringField itemSKU = new SearchStringField(); itemSKU.searchValue = SKU; itemSKU.@operator = SearchStringFieldOperator.contains; itemSKU.operatorSpecified = true; isb.itemId = itemSKU; iS.basic = isb; isa.criteria = iS; SearchResult sr = new SearchResult(); sr = objService.search(isa); if (sr.status.isSuccess != true) throw new Exception("Cannot find item."); Dictionary<string, double> binNumberList = new Dictionary<string, double>(); foreach (ItemSearchRow irow in sr.searchRowList) { if (irow.basic.itemId[0].searchValue == SKU) { binNumberList.Add(irow.basic.binNumber[0].searchValue, irow.basic.binOnHandAvail[0].searchValue); } } return binNumberList; }