private string GetAuctionIntegrationId(string aucId)
        {
            var amWrapper             = new AMWrapper();
            var ret                   = new GetListofAMAuctionResponse();
            var getListofAMAuctionReq = new GetListofAMAuctionRequest();

            ret.ReferenceID = getListofAMAuctionReq.ReferenceID;
            var aucIntId = string.Empty;

            try
            {
                var req = new ReadEntryListRequest();
                req.AccessToken = req.AccessToken;
                req.ModuleName  = "auction";
                var auction_Details = amWrapper.GetAMList <AMCustomer.AMAuction>(req, $"{amWrapper.apiUrl}/v1/auction/" + aucId + "/").GetAwaiter().GetResult();
                var result_page     = JObject.Parse(auction_Details).SelectToken("response");

                foreach (var result in result_page.SelectTokens("integration_id"))
                {
                    aucIntId = result.ToString();
                }
            }
            catch (Exception ex)
            {
                SuiteWrapper.WriteTraceLog("GetAuctionIntegrationId", "Error Message : " + ex.Message);
            }
            return(aucIntId);
        }
        public GetListofAMRegistrationResponse GetListofAMRegistration(string logId)
        {
            SuiteWrapper.WriteTraceLog("GetRegistration", "---------------- REGISTRATION SYNC START ------------------------- ");
            common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest()
            {
                Description = "Registration sync started", Name = "GetRegistration", Entity_c = "Registration"
            }, logId);

            var amWrapper = new AMWrapper();
            var ret       = new GetListofAMRegistrationResponse();

            try
            {
                var req = new ReadEntryListRequest();
                req.AccessToken = amWrapper.apiAccessToken;
                req.ModuleName  = "auction";
                var AMRegistration_List = amWrapper.GetAMList <AMCustomer.AMAuction>(req, $"{amWrapper.apiUrl}/v1/auction/upcoming").GetAwaiter().GetResult();

                var result_page = JObject.Parse(AMRegistration_List).SelectToken("result_page");

                var listOfUpcomingAuction = ReadAllAMAuctionUpcoming(result_page);

                ProcessSuiteRegistration(listOfUpcomingAuction, logId);

                var query_info    = JObject.Parse(AMRegistration_List).SelectToken("query_info");
                var next_page_url = string.Empty;

                foreach (var next_page in query_info.SelectTokens("next_page"))
                {
                    next_page_url = next_page.ToString();
                    while (!string.IsNullOrEmpty(next_page_url))
                    {
                        var jstr_Next        = amWrapper.GetAMList <AMCustomer.AMAuction>(req, next_page_url).GetAwaiter().GetResult();
                        var result_page_Next = JObject.Parse(jstr_Next).SelectToken("result_page");
                        listOfUpcomingAuction = ReadAllAMAuctionUpcoming(result_page_Next);
                        ProcessSuiteRegistration(listOfUpcomingAuction, logId);

                        var query_info_Next = JObject.Parse(jstr_Next).SelectToken("query_info");
                        foreach (var next_page1 in query_info_Next.SelectTokens("next_page"))
                        {
                            next_page_url = string.Empty;
                            next_page_url = next_page1.ToString();
                        }
                    }
                }

                ret.StatusCode = AMAPI.ClsConstant.SuccessCode;
                ret.Message    = AMAPI.ClsConstant.SuccessMessage;

                return(ret);
            }
            catch (Exception ex)
            {
                SuiteWrapper.WriteTraceLog("GetListofAMRegistration", "Error Message : " + ex.Message);
                ret.StatusCode = AMAPI.ClsConstant.ServerErrorCode;
                ret.Message    = AMAPI.ClsConstant.ServerErrorMsg;

                return(ret);
            }
        }
        // Get Auction registrations customer ID
        private List <AMCustomer.AMRegistration> GetAuctionRegistrationArray(string AuctionID, string LogId)
        {
            var amAuctionSummary = new List <AMCustomer.AMRegistration>();

            var amWrapper             = new AMWrapper();
            var ret                   = new GetListofAMAuctionResponse();
            var GetListofAMAuctionReq = new GetListofAMAuctionRequest();

            ret.ReferenceID = GetListofAMAuctionReq.ReferenceID;

            try
            {
                var req = new ReadEntryListRequest();
                req.AccessToken = req.AccessToken;
                req.ModuleName  = "auction";
                var list        = amWrapper.GetAMList <AMCustomer.AMRegistration>(req, $"{amWrapper.apiUrl}/v2/admin/auction/" + AuctionID + "/registrations?fieldset=customer-addresses").GetAwaiter().GetResult();
                var result_page = JObject.Parse(list).SelectToken("result_page");

                foreach (var result in result_page)
                {
                    amAuctionSummary.Add(GetAuctionSummary(result));
                }

                var query_info    = JObject.Parse(list).SelectToken("query_info");
                var next_page_url = string.Empty;

                foreach (var next_page in query_info.SelectTokens("next_page"))
                {
                    next_page_url = next_page.ToString();
                    while (!string.IsNullOrEmpty(next_page_url))
                    {
                        var jstr_Next        = amWrapper.GetAMList <AMCustomer.AMAuction>(req, next_page_url).GetAwaiter().GetResult();
                        var result_page_Next = JObject.Parse(jstr_Next).SelectToken("result_page");

                        foreach (var result in result_page)
                        {
                            amAuctionSummary.Add(GetAuctionSummary(result));
                        }

                        var query_info_Next = JObject.Parse(jstr_Next).SelectToken("query_info");
                        foreach (var next_page1 in query_info_Next.SelectTokens("next_page"))
                        {
                            next_page_url = string.Empty;
                            next_page_url = next_page1.ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SuiteWrapper.WriteTraceLog("GetSuiteAddress", "Error : " + ex.Message);
                common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest()
                {
                    Description = "Error Message : " + ex.Message, Name = "GetSuiteAddress", Entity_c = "Registration"
                }, LogId);
            }

            return(amAuctionSummary);
        }
Example #4
0
        // 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);
        }
        // Get Auction Summary
        private AMCustomer.AMAuctionSummary GetAuctionSummary(string auctionID, string logId)
        {
            var amWrapper             = new AMWrapper();
            var ret                   = new GetListofAMAuctionResponse();
            var getListofAMAuctionReq = new GetListofAMAuctionRequest();

            ret.ReferenceID = getListofAMAuctionReq.ReferenceID;

            try
            {
                var req = new ReadEntryListRequest();
                req.AccessToken = req.AccessToken;
                req.ModuleName  = "auction";
                var auctionDetails         = amWrapper.GetAMList <AMCustomer.AMAuction>(req, $"{amWrapper.apiUrl}/v1/auction/" + auctionID + "/summary").GetAwaiter().GetResult();
                var result_page            = JObject.Parse(auctionDetails).SelectToken("response");
                var amAuctionSummaryRecord = new AMCustomer.AMAuctionSummary();

                amAuctionSummaryRecord.Row_id                = result_page.Value <string>("row_id");
                amAuctionSummaryRecord.Auction_type          = result_page.Value <string>("auction_type");
                amAuctionSummaryRecord.Time_start            = result_page.Value <string>("time_start");
                amAuctionSummaryRecord.Timezone              = result_page.Value <string>("timezone");
                amAuctionSummaryRecord.Auction_code          = result_page.Value <string>("auction_code");
                amAuctionSummaryRecord.Title                 = result_page.Value <string>("title");
                amAuctionSummaryRecord.Truncated_description = result_page.Value <string>("truncated_description");
                amAuctionSummaryRecord.Viewing_information   = result_page.Value <string>("viewing_information");
                amAuctionSummaryRecord.Currency_code         = result_page.Value <string>("currency_code");
                amAuctionSummaryRecord.Location_name         = result_page.Value <string>("location_name");

                return(amAuctionSummaryRecord);
            }
            catch (Exception ex)
            {
                SuiteWrapper.WriteTraceLog("GetAuctionSummary", "Error : " + ex.Message);
                common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest()
                {
                    Description = "Error : " + ex.Message, Name = "GetAuctionSummary", Entity_c = "Registration"
                }, logId);
            }
            return(null);
        }
        public GetListofAMCustomerResponse GetListofAMCustomer(DateTime startDate, DateTime endDate, string logId)
        {
            SuiteWrapper.WriteTraceLog("GetCustomer", "---------------- CUSTOMER SYNC START ------------------------- ");
            common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest()
            {
                Description = "Customer sync started", Name = "GetCustomer", Entity_c = "Customer"
            }, logId);

            var amWrapper = new AMWrapper();
            var ret       = new GetListofAMCustomerResponse();


            try
            {
                var request = new ReadEntryListRequest
                {
                    AccessToken = amWrapper.apiAccessToken,
                    ModuleName  = "customer"
                };

                var result_AMCustomers = amWrapper.GetAMList <AMCustomer.AMCustomer>(request, $"{amWrapper.apiUrl}/v2/admin/customer").GetAwaiter().GetResult();
                var result_page        = JObject.Parse(result_AMCustomers).SelectToken("result_page");

                ReadAMContact(result_page, startDate, endDate, logId);

                var query_info    = JObject.Parse(result_AMCustomers).SelectToken("query_info");
                var next_page_url = string.Empty;

                foreach (var next_page in query_info.SelectTokens("next_page"))
                {
                    next_page_url = next_page.ToString();
                    while (!string.IsNullOrEmpty(next_page_url))
                    {
                        var jstr_Next        = amWrapper.GetAMList <AMCustomer.AMCustomer>(request, next_page_url).GetAwaiter().GetResult();
                        var result_page_Next = JObject.Parse(jstr_Next).SelectToken("result_page");

                        ReadAMContact(result_page_Next, startDate, endDate, logId);

                        var query_info_Next = JObject.Parse(jstr_Next).SelectToken("query_info");
                        foreach (var next_page1 in query_info_Next.SelectTokens("next_page"))
                        {
                            next_page_url = string.Empty;
                            next_page_url = next_page1.ToString();
                        }
                    }
                }

                ret.StatusCode = AMAPI.ClsConstant.SuccessCode;
                ret.Message    = AMAPI.ClsConstant.SuccessMessage;

                return(ret);
            }
            catch (Exception ex)
            {
                SuiteWrapper.WriteTraceLog("GetListofAMCustomer", "Error Message : " + ex.Message);
                ret.StatusCode = AMAPI.ClsConstant.ServerErrorCode;
                ret.Message    = AMAPI.ClsConstant.ServerErrorMsg;

                return(ret);
            }
        }
        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);
        }