public JToken GetListSuiteRegistration(string auctionCalenderId, string clientId, string logId) { var suiteWrapper = new SuiteWrapper(); suitesessionId = suiteWrapper.Login().GetAwaiter().GetResult(); var request = new SuiteReadEntryListRequest(); request.SessionId = suitesessionId; request.ModuleName = "reg_Registration"; request.Query = "reg_Registration_cstm.ac1_auction_calendar_id_c='" + auctionCalenderId + "'"; //request.Query = $"reg_Registration_cstm.ac1_auction_calendar_id_c='{auctionCalenderId}' and id in ( SELECT contacts_reg_registration_1reg_registration_idb FROM contacts_reg_registration_1_c where contacts_reg_registration_1contacts_ida = '{clientId}') "; request.SelectFields = new List <string> { "id", }; var registration_list = suiteWrapper.GetList(request).GetAwaiter().GetResult(); foreach (var registratonRecord in registration_list.EntityList) { if (CheckForRegistrationAvailalibilityForContact(registratonRecord.SelectToken("id").ToString(), clientId, logId) > 0) { return(registratonRecord); } } return(null); }
public List <EntryListArray> GetSuiteContactIDByEmail(string email, string logId) { var wrapper = new SuiteWrapper(); suitesessionId = wrapper.Login().GetAwaiter().GetResult(); var request = new SuiteReadEntryListRequest(); request.SessionId = suitesessionId; request.ModuleName = "Contacts"; request.Query = " contacts" + ".id in (SELECT eabr.bean_id FROM email_addr_bean_rel eabr JOIN email_addresses ea ON " + "(ea.id = eabr.email_address_id) WHERE eabr.deleted=0 AND ea.email_address = '" + email + "')"; request.SelectFields = new List <string> { "Am_customer_id", "email" }; try { var suiteConstactList = wrapper.GetList(request).GetAwaiter().GetResult(); return(suiteConstactList.EntryList); } catch (Exception ex) { SuiteWrapper.WriteTraceLog("GetRegistration", "Error : " + ex.Message); InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "Error : " + ex.Message, Name = "GetSuiteConstactIDByEmail", Entity_c = "Customer" }, logId); } return(null); }
//Path: /api/Contact/PullContacts public HttpResponseMessage PullContacts() { // Trace Log File.AppendAllText(SuiteWrapper.traceLogPath, Environment.NewLine + Environment.NewLine); SuiteWrapper.WriteTraceLog("Called PullClientData"); var sessionId = "0"; try { sessionId = SuiteWrapper.Login().GetAwaiter().GetResult(); } catch (Exception ex) { SuiteWrapper.WriteTraceLog("Exception while generating session id is " + ex.ToString()); return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, ex.Message.ToString())); } try { List <string> vs = new List <string>(); vs.Add("id"); var req = new SuiteAPI.ReadEntryListRequest(); req.SessionId = sessionId; req.MethodName = "get_entry_list"; req.ModuleName = "Contacts"; req.LinkNameToFieldsArray = new Dictionary <string, object>() { { "name", "contacts_add1_addresses_1" }, { "value", vs } }; PropertyInfo[] props = typeof(PullContact).GetProperties(); req.SelectFields = SuiteAPI.SuiteWrapper.GetFieldList(props); var list = SuiteWrapper.GetList <PullContact>(req).GetAwaiter().GetResult(); var pullResponse = PullResponseWithoutPagination <PullContact> .pullResponse(list); SuiteWrapper.WriteTraceLog("Successfully called with response:" + JsonConvert.SerializeObject(pullResponse)); return(Request.CreateResponse(HttpStatusCode.OK, pullResponse)); } catch (Exception ex) { SuiteWrapper.WriteTraceLog("Exception while pulling data is : " + ex.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message.ToString())); } }
public GetListofSuiteContactResponse GetListSuiteContact(GetListofSuiteContactRequest GetSuiteContactRequest) { var suiteWrapper = new SuiteWrapper(); suitesessionId = suiteWrapper.Login().GetAwaiter().GetResult(); var request = new SuiteReadEntryListRequest(); request.SessionId = suitesessionId; request.ModuleName = "Contacts"; request.SelectFields = new List <string> { "first_name", "last_name", "phone_work", "title", "phone_fax", "description", }; var contacts_List = suiteWrapper.GetList(request).GetAwaiter().GetResult(); for (var i = 0; i <= contacts_List.EntityList.Count(); i++) { var values = new Dictionary <string, string> { { "method", "POST" }, { "input_type", "JSON" }, { "response_type", "JSON" }, { "email_address", "*****@*****.**" }, { "given_name", "ABC" }, { "family_name", "Xyz" }, { "password", "1234567890" }, { "first_name", contacts_List.EntryList[i].Entity.SelectToken("first_name").ToString() }, { "last_name", contacts_List.EntryList[i].Entity.SelectToken("last_name").ToString() }, { "phone_work", contacts_List.EntryList[i].Entity.SelectToken("phone_work").ToString() }, { "title", contacts_List.EntryList[i].Entity.SelectToken("title").ToString() }, { "phone_fax", contacts_List.EntryList[i].Entity.SelectToken("phone_fax").ToString() }, { "description", contacts_List.EntryList[i].Entity.SelectToken("description").ToString() } }; } return(null); }
// Get NetSuite Customer internalID public SuiteContact GetSuiteConstactID(string auctionCustmoerID, string logId) { var suiteContact = new SuiteContact(); var amwrapper = new AMWrapper(); var suiteWrapper = new SuiteWrapper(); var contactrequest = new CreateContactRequest(); suitesessionId = suiteWrapper.Login().GetAwaiter().GetResult(); var request = new SuiteReadEntryListRequest(); request.SessionId = suitesessionId; request.ModuleName = "Contacts"; request.Query = " am_customer_id_c = '" + auctionCustmoerID + "'"; request.SelectFields = new List <string> { "id", "am_customer_id_c", "name", "client_number_c" }; try { var suiteConstactlist = suiteWrapper.GetList(request).GetAwaiter().GetResult(); foreach (var record in suiteConstactlist.EntryList) { suiteContact.Id = record.Entity.SelectToken("id").ToString(); suiteContact.Name = record.Entity.SelectToken("name").ToString(); suiteContact.Client_number_c = record.Entity.SelectToken("client_number_c").ToString(); return(suiteContact); } } catch (Exception ex) { InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "Error : " + ex.Message, Name = "CheckForRegistration", Entity_c = "Customer" }, logId); SuiteWrapper.WriteTraceLog("CheckForRegistration", "Error Message : " + ex.Message); } return(null); }
public EntryListArray GetListSuiteAuctionCalender(string id, string logId) { var amWrapper = new AMWrapper(); var suiteWrapper = new SuiteWrapper(); var contactrequest = new CreateContactRequest(); suitesessionId = suiteWrapper.Login().GetAwaiter().GetResult(); var request = new SuiteReadEntryListRequest(); request.SessionId = suitesessionId; request.ModuleName = "AC1_Auction_Calendar"; request.Query = "AC1_Auction_Calendar.id='" + id + "'"; request.SelectFields = new List <string> { "name", }; var auction_List = suiteWrapper.GetList(request).GetAwaiter().GetResult(); if (auction_List.EntityList == null) { return(null); } var auction_List_Cnt = auction_List.EntityList.Count(); common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "Total Auction Calender in Suite: " + auction_List_Cnt, Name = "GetListSuiteAuctionCalender", Entity_c = "Registration" }, logId); if (auction_List.EntityList.Count() == 0) { return(null); } for (var i = 0; i <= auction_List_Cnt; i++) { return(auction_List.EntryList[i]); } return(null); }
public HttpResponseMessage PullMasterData(string methodName, string lastSyncDate = null, int?nextOffSet = null, bool deleted = false) { // Trace Log File.AppendAllText(SuiteWrapper.traceLogPath, Environment.NewLine + Environment.NewLine); SuiteWrapper.WriteTraceLog("Called 'PullMasterData' with request : MethodName-" + methodName + " and nextOffSet=" + nextOffSet); var sessionId = "0"; try { sessionId = SuiteWrapper.Login().GetAwaiter().GetResult(); } catch (Exception ex) { SuiteWrapper.WriteTraceLog("Exception while generating session id is " + ex.ToString()); return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, ex.Message.ToString())); } var query = string.Empty; var req = new SuiteAPI.ReadEntryListRequest(); req.SessionId = sessionId; req.MethodName = "get_entry_list"; req.MaxResults = SuiteWrapper.maxPullResults; req.Deleted = deleted; if (nextOffSet != null && nextOffSet > 0) { req.Offset = nextOffSet; } int v = (req.Deleted) ? 1 : 0; try { if (methodName == "Artists") { req.ModuleName = "A1_Artists"; PropertyInfo[] props = typeof(PullArtist).GetProperties(); req.SelectFields = SuiteAPI.SuiteWrapper.GetFieldList(props); query = "A1_Artists.deleted=" + Convert.ToInt32((req.Deleted) ? 1 : 0) + " "; if (!string.IsNullOrEmpty(lastSyncDate)) { req.Query = query + "and A1_Artists.date_modified >='" + lastSyncDate + "'"; } else { req.Query = query; } var list = SuiteWrapper.GetList <PullArtist>(req).GetAwaiter().GetResult(); var pullResponse = PullResponse <PullArtist> .pullResponse(list, methodName, deleted, lastSyncDate); SuiteWrapper.WriteTraceLog("Successfully called with response:" + JsonConvert.SerializeObject(pullResponse)); return(Request.CreateResponse(HttpStatusCode.OK, pullResponse)); } else if (methodName == "Auctions") { req.ModuleName = "AC1_Auction_Calendar"; PropertyInfo[] props = typeof(PullAuctionCalendar).GetProperties(); query = "AC1_Auction_Calendar.deleted=" + Convert.ToInt32((req.Deleted) ? 1 : 0) + " "; if (!string.IsNullOrEmpty(lastSyncDate)) { req.Query = query + "and AC1_Auction_Calendar.date_modified >='" + lastSyncDate + "'"; } else { req.Query = query; } var list = SuiteWrapper.GetList <PullAuctionCalendar>(req).GetAwaiter().GetResult(); var pullResponse = PullResponse <PullAuctionCalendar> .pullResponse(list, methodName, deleted, lastSyncDate); SuiteWrapper.WriteTraceLog("Successfully called with response:" + JsonConvert.SerializeObject(pullResponse)); return(Request.CreateResponse(HttpStatusCode.OK, pullResponse)); } else if (methodName == "Symbols") { req.ModuleName = "Sym1_Symbols"; PropertyInfo[] props = typeof(PullSymbols).GetProperties(); req.SelectFields = SuiteAPI.SuiteWrapper.GetFieldList(props); query = "Sym1_Symbols.deleted=" + Convert.ToInt32((req.Deleted) ? 1 : 0) + " "; if (!string.IsNullOrEmpty(lastSyncDate)) { req.Query = query + "and Sym1_Symbols.date_modified >='" + lastSyncDate + "'"; } else { req.Query = query; } var list = SuiteWrapper.GetList <PullSymbols>(req).GetAwaiter().GetResult(); var pullResponse = PullResponse <PullSymbols> .pullResponse(list, methodName, deleted, lastSyncDate); SuiteWrapper.WriteTraceLog("Successfully called with response:" + JsonConvert.SerializeObject(pullResponse)); return(Request.CreateResponse(HttpStatusCode.OK, pullResponse)); } else if (methodName == "Locations") { req.ModuleName = "loc_Location"; PropertyInfo[] props = typeof(PullLocation).GetProperties(); req.SelectFields = SuiteAPI.SuiteWrapper.GetFieldList(props); query = "loc_Location.deleted=" + Convert.ToInt32((req.Deleted) ? 1 : 0) + " "; if (!string.IsNullOrEmpty(lastSyncDate)) { req.Query = query + "and loc_Location.date_modified >='" + lastSyncDate + "'"; } else { req.Query = query; } var list = SuiteWrapper.GetList <PullLocation>(req).GetAwaiter().GetResult(); var pullResponse = PullResponse <PullLocation> .pullResponse(list, methodName, deleted, lastSyncDate); SuiteWrapper.WriteTraceLog("Successfully called with response:" + JsonConvert.SerializeObject(pullResponse)); return(Request.CreateResponse(HttpStatusCode.OK, pullResponse)); } else if (methodName == "Categories") { req.ModuleName = "Cat1_Categories"; PropertyInfo[] props = typeof(PullCategories).GetProperties(); req.SelectFields = SuiteAPI.SuiteWrapper.GetFieldList(props); query = "Cat1_Categories.deleted=" + Convert.ToInt32((req.Deleted) ? 1 : 0) + " "; if (!string.IsNullOrEmpty(lastSyncDate)) { req.Query = query + "and Cat1_Categories.date_modified >='" + lastSyncDate + "'"; } else { req.Query = query; } var list = SuiteWrapper.GetList <PullCategories>(req).GetAwaiter().GetResult(); var pullResponse = PullResponse <PullCategories> .pullResponse(list, methodName, deleted, lastSyncDate); SuiteWrapper.WriteTraceLog("Successfully called with response:" + JsonConvert.SerializeObject(pullResponse)); return(Request.CreateResponse(HttpStatusCode.OK, pullResponse)); } else { SuiteWrapper.WriteTraceLog("Invalid Pull request method name : " + methodName); return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Method name '" + methodName + "' not found.")); } } catch (Exception ex) { SuiteWrapper.WriteTraceLog("Exception while pulling the data is " + ex.ToString()); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message.ToString())); } }
public PushListofSuiteAuctionResponse PushListofAMAuction(string auctionId, string logId) { SuiteWrapper.WriteTraceLog("PushAMAuction", "---------------- AUCTION SYNC START ------------------------- "); common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "Push Auction to AM sync started", Name = "PushAuction", Entity_c = "Auction" }, logId); var amWrapper = new AMWrapper(); var suiteWrapper = new SuiteWrapper(); var ret = new PushListofSuiteAuctionResponse(); ret.List = new List <AMCustomer.AMAuction>(); try { suitesessionId = suiteWrapper.Login().GetAwaiter().GetResult(); var requestAuction = new SuiteReadEntryListRequest(); requestAuction.SessionId = suitesessionId; requestAuction.ModuleName = "AC1_Auction_Calendar"; requestAuction.Query = $"ac1_auction_calendar_cstm.auction_number_c in ('{string.Join("','", auctionId.Split(','))}')"; requestAuction.SelectFields = new List <string> { "id", "name", "auction_number_c", "auction_type_c", "currency_type_c", "start_date_c", "invoice_description_c", "viewing_c", "city_description_c", "city_c", }; var auction_List = suiteWrapper.GetList(requestAuction).GetAwaiter().GetResult(); if (auction_List.Count > 0) { foreach (var item in auction_List.EntityList.Children()) { var itemProperties = item.Children <JProperty>(); var values = new Dictionary <string, string> { { "method", "POST" }, { "input_type", "JSON" }, { "response_type", "JSON" }, { "integration_id", itemProperties.FirstOrDefault(xx => xx.Name == "id").Value.ToString() }, }; if (!string.IsNullOrEmpty(itemProperties.FirstOrDefault(xx => xx.Name == "name").Value.ToString())) { values.Add("title", itemProperties.FirstOrDefault(xx => xx.Name == "name").Value.ToString()); } values.Add("auction_code", itemProperties.FirstOrDefault(xx => xx.Name == "auction_number_c").Value.ToString()); var auction_type_c = GetAuctionType(itemProperties.FirstOrDefault(xx => xx.Name == "auction_type_c").Value.ToString()); values.Add("auction_type", auction_type_c); var currency_type_c = GetCurrencyCode(itemProperties.FirstOrDefault(xx => xx.Name == "currency_type_c").Value.ToString()); values.Add("currency_code", currency_type_c); values.Add("location_name", itemProperties.FirstOrDefault(xx => xx.Name == "city_c").Value.ToString()); string start_date_c = Convert.ToDateTime(itemProperties.FirstOrDefault(xx => xx.Name == "start_date_c").Value.ToString()).ToString("yyyy-MM-dd'T'HH:mm'Z'"); values.Add("time_start", start_date_c); values.Add("description", itemProperties.FirstOrDefault(xx => xx.Name == "invoice_description_c").Value.ToString()); values.Add("viewing_information", itemProperties.FirstOrDefault(xx => xx.Name == "viewing_c").Value.ToString()); values.Add("location_description", itemProperties.FirstOrDefault(xx => xx.Name == "city_description_c").Value.ToString()); var result_Auction = amWrapper.PostDataToAM(values, $"{amWrapper.apiUrl}/v1/auction/").GetAwaiter().GetResult(); var responseData = JObject.Parse(result_Auction).SelectToken("response"); string AMId; if (responseData != null) { AMId = responseData.SelectToken("row_id").ToString(); SuiteWrapper.WriteTraceLog("PushAMAuction", "Auction Inserted to AM successfully for Id :" + AMId); common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "Auction Inserted to AM successfully for Id :" + itemProperties.FirstOrDefault(xx => xx.Name == "id").Value.ToString(), Name = "PushAMAuction", Entity_c = "Auction" }, logId); ret.StatusCode = ClsConstant.SuccessCode; ret.Message = ClsConstant.SuccessMessage; } else { var message = JObject.Parse(result_Auction).SelectToken("error"); AMId = ""; SuiteWrapper.WriteTraceLog("PushAMAuction", "Error Message : " + message); common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "Error Message : " + message, Name = "PushAMAuction", Entity_c = "Auction" }, logId); ret.StatusCode = ClsConstant.ServerErrorCode; ret.Message = ClsConstant.ServerErrorMsg; } AMCustomer.AMAuction result = new AMCustomer.AMAuction(); result.SuiteId = itemProperties.FirstOrDefault(xx => xx.Name == "id").Value.ToString(); result.Row_id = AMId; ret.List.Add(result); } } else { common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "No any Auction exist for period", Name = "PushAMAuction", Entity_c = "Auction" }, logId); SuiteWrapper.WriteTraceLog("PushAMAuction", "No any Auction exist for period"); } } catch (Exception ex) { common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "Error Message : " + ex.Message, Name = "PushAMAuction", Entity_c = "Auction" }, logId); ret.StatusCode = ClsConstant.ServerErrorCode; ret.Message = ClsConstant.ServerErrorMsg; return(ret); } SuiteWrapper.WriteTraceLog("PushAMAuction", "---------------- AUCTION SYNC END ------------------------- "); common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "Push Auction to AM sync ended", Name = "PushAMAuction", Entity_c = "Auction" }, logId); return(ret); }