public ActionResult <ConfigurationViewModel> Get(string id) { ConfigurationViewModel result = null; try { if (string.IsNullOrEmpty(id)) { return(BadRequest("bad request..")); } var config = new ConfigurationViewModelParam() { ConfigGUID = id }; result = _businessAccess.GetConfiguration(config); if (string.IsNullOrEmpty(result.SiteConfiguration.WebsiteConfigurationName)) { return(NotFound(id)); } } catch (Exception ex) { _log.Write("Exception in ConfigurationController; Message: " + ex.Message); } finally { } return(Ok(result)); }
public IDbResponse DeleteConfiguration(ConfigurationViewModelParam param) { IDbResponse result = new DbResponse(); try { result = _dataAccess.DeleteConfiguration(param); } catch (Exception ex) { _log.Write("Exception in BusinessAccess; Message: " + ex.Message); } finally { } return(result); }
public ConfigurationViewModel GetConfiguration(ConfigurationViewModelParam param) { var result = new ConfigurationViewModel(); try { result = _dataAccess.GetConfiguration(param); } catch (Exception ex) { _log.Write("Exception in BusinessAccess; Message: " + ex.Message); } finally { } return(result); }
public ActionResult <IDbResponse> Delete(string id) { IDbResponse result = null; try { var user = new ConfigurationViewModelParam() { ConfigGUID = id }; result = _businessAccess.DeleteConfiguration(user); } catch (Exception ex) { _log.Write("Exception in ConfigurationController; Message: " + ex.Message); } finally { } return(Ok(result)); }
public ActionResult <IDbResponse> Post([FromBody] ConfigurationViewModelParam config) { IDbResponse result = null; try { if (config == null || string.IsNullOrEmpty(config.SiteConfiguration.WebsiteConfigurationName)) { return(BadRequest("bad request..")); } result = _businessAccess.AddConfiguration(config); } catch (Exception ex) { _log.Write("Exception in ConfigurationController; Message: " + ex.Message); } finally { } return(Ok(result)); }
public IDbResponse DeleteConfiguration(ConfigurationViewModelParam param) { IDbResponse result = new DbResponse(); try { using (SqlConnection conn = _connectionHelper.DefaultConnectionDB()) { using (SqlCommand cmd = new SqlCommand(SpHelper.DeleteConfiguration, conn)) { conn.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LoginUser", param.LoginUser); cmd.Parameters.AddWithValue("@ConfigGUID", param.ConfigGUID); using (SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { // get details from reader if (rdr.HasRows) { while (rdr.Read()) { result.IsSuccess = rdr.CustomGetValue <bool>("IsSuccess"); result.Message = rdr.CustomGetValue <string>("Message"); } } } } } } catch (Exception ex) { _log.Write("Exception in DataAccess; Message: " + ex.Message); } finally { } return(result); }
public IDbResponse UpdateConfiguration(ConfigurationViewModelParam param) { IDbResponse result = new DbResponse(); try { using (SqlConnection conn = _connectionHelper.DefaultConnectionDB()) { using (SqlCommand cmd = new SqlCommand(SpHelper.UpdateConfiguration, conn)) { conn.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@LoginUser", param.LoginUser); cmd.Parameters.AddWithValue("@ConfigGUID", param.ConfigGUID); cmd.Parameters.AddWithValue("@WebsiteConfigurationName", param.SiteConfiguration.WebsiteConfigurationName); cmd.Parameters.AddWithValue("@ScrapingMechanism", param.SiteConfiguration.ScrapingMechanism); cmd.Parameters.AddWithValue("@ShouldRotateProxy", param.SiteConfiguration.ShouldRotateProxy); cmd.Parameters.AddWithValue("@RequireInputValues", param.SiteConfiguration.RequireInputValues); cmd.Parameters.AddWithValue("@ShouldDisableJavaScript", param.SiteConfiguration.ShouldDisableJavaScript); cmd.Parameters.AddWithValue("@WaitingTimeAfterPageLoad", param.SiteConfiguration.WaitingTimeAfterPageLoad); cmd.Parameters.AddWithValue("@WebsiteNamePrefix", param.WebsiteDetail.WebsiteNamePrefix); cmd.Parameters.AddWithValue("@WebscrapeType", param.WebsiteDetail.WebscrapeType); cmd.Parameters.AddWithValue("@WebsiteURL", param.WebsiteDetail.WebsiteURL); cmd.Parameters.AddWithValue("@WebsiteURLs", param.WebsiteDetail.DbWebsiteURLs); cmd.Parameters.AddWithValue("@DoesHaveSearchButton", param.WebsiteDetail.DoesHaveSearchButton); cmd.Parameters.AddWithValue("@SearchButtonPathType", param.WebsiteDetail.SearchButtonPathType); cmd.Parameters.AddWithValue("@SearchButton", param.WebsiteDetail.SearchButton); cmd.Parameters.AddWithValue("@DoesHaveResetButton", param.WebsiteDetail.DoesHaveResetButton); cmd.Parameters.AddWithValue("@ResetButtonPathType", param.WebsiteDetail.ResetButtonPathType); cmd.Parameters.AddWithValue("@ResetButton", param.WebsiteDetail.ResetButton); cmd.Parameters.AddWithValue("@OverallContainerPathType", param.ProductDetail.OverallContainerPathType); cmd.Parameters.AddWithValue("@OverallContainer", param.ProductDetail.OverallContainer); cmd.Parameters.AddWithValue("@ProductContainerPathType", param.ProductDetail.ProductContainerPathType); cmd.Parameters.AddWithValue("@ProductContainer", param.ProductDetail.ProductContainer); cmd.Parameters.AddWithValue("@PagingType", param.PaginationDetail.PagingType); cmd.Parameters.AddWithValue("@PaginationContainerPathType", param.PaginationDetail.PaginationContainerPathType); cmd.Parameters.AddWithValue("@PaginationContainer", param.PaginationDetail.PaginationContainer); cmd.Parameters.AddWithValue("@DoesHaveNextButton", param.PaginationDetail.DoesHaveNextButton); cmd.Parameters.AddWithValue("@NextButtonPathType", param.PaginationDetail.NextButtonPathType); cmd.Parameters.AddWithValue("@NextButton", param.PaginationDetail.NextButton); cmd.Parameters.AddWithValue("@ActiveClassForCurrentPage", param.PaginationDetail.ActiveClassForCurrentPage); cmd.Parameters.AddWithValue("@DisabledClassForLastPage", param.PaginationDetail.DisabledClassForLastPage); cmd.Parameters.AddWithValue("@ShouldLimitPaging", param.PaginationDetail.ShouldLimitPaging); cmd.Parameters.AddWithValue("@PagingLimit", param.PaginationDetail.PagingLimit); cmd.Parameters.AddWithValue("@ShouldSendMail", param.MailingInformation.ShouldSendMail); cmd.Parameters.AddWithValue("@MailToAddress", param.MailingInformation.MailToAddress); cmd.Parameters.AddWithValue("@MailCCAddress", param.MailingInformation.MailCCAddress); cmd.Parameters.AddWithValue("@MailBCCAddress", param.MailingInformation.MailBCCAddress); cmd.Parameters.AddWithValue("@DbInputFieldDetail", param.WebsiteDetail.DbInputFields); cmd.Parameters.AddWithValue("@DbOutputFieldDetail", param.ProductDetail.DbFields); using (SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { // get details from reader if (rdr.HasRows) { while (rdr.Read()) { result.IsSuccess = rdr.CustomGetValue <bool>("IsSuccess"); result.Message = rdr.CustomGetValue <string>("Message"); } } } } } } catch (Exception ex) { _log.Write("Exception in DataAccess; Message: " + ex.Message); } finally { } return(result); }
public ConfigurationViewModel GetConfiguration(ConfigurationViewModelParam param) { var result = new ConfigurationViewModel(); try { using (SqlConnection conn = _connectionHelper.DefaultConnectionDB()) { using (SqlCommand cmd = new SqlCommand(SpHelper.GetConfiguration, conn)) { conn.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ConfigGUID", param.ConfigGUID); using (SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { // get details from reader if (rdr.HasRows) { while (rdr.Read()) { result.IsSuccess = rdr.CustomGetValue <bool>("IsSuccess"); result.Message = rdr.CustomGetValue <string>("Message"); } } if (rdr.NextResult()) { while (rdr.Read()) { result.ConfigID = rdr.CustomGetValue <string>("ConfigID"); result.ConfigGUID = rdr.CustomGetValue <string>("ConfigGUID"); result.CreatedOn = rdr.CustomGetValue <string>("CreatedOn"); result.CreatedBy = rdr.CustomGetValue <string>("CreatedBy"); result.UpdatedOn = rdr.CustomGetValue <string>("UpdatedOn"); result.UpdatedBy = rdr.CustomGetValue <string>("UpdatedBy"); result.SiteConfiguration = new SiteConfiguration() { WebsiteConfigurationName = rdr.CustomGetValue <string>("Configuration_WebsiteConfigurationName"), ScrapingMechanism = rdr.CustomGetValue <string>("Configuration_ScrapingMechanism"), ShouldRotateProxy = rdr.CustomGetValue <bool>("Configuration_ShouldRotateProxy"), RequireInputValues = rdr.CustomGetValue <bool>("Configuration_RequireInputValues"), ShouldDisableJavaScript = rdr.CustomGetValue <bool>("Configuration_ShouldDisableJavaScript"), WaitingTimeAfterPageLoad = rdr.CustomGetValue <string>("Configuration_WaitingTimeAfterPageLoad") }; result.WebsiteDetail = new WebsiteDetail() { WebsiteNamePrefix = rdr.CustomGetValue <string>("WebsiteDetail_WebsiteNamePrefix"), WebscrapeType = rdr.CustomGetValue <string>("WebsiteDetail_WebscrapeType"), WebsiteURL = rdr.CustomGetValue <string>("WebsiteDetail_WebsiteURL"), DoesHaveSearchButton = rdr.CustomGetValue <bool>("WebsiteDetail_DoesHaveSearchButton"), SearchButtonPathType = rdr.CustomGetValue <string>("WebsiteDetail_SearchButtonPathType"), SearchButton = rdr.CustomGetValue <string>("WebsiteDetail_SearchButton"), DoesHaveResetButton = rdr.CustomGetValue <bool>("WebsiteDetail_DoesHaveResetButton"), ResetButtonPathType = rdr.CustomGetValue <string>("WebsiteDetail_ResetButtonPathType"), ResetButton = rdr.CustomGetValue <string>("WebsiteDetail_ResetButton") }; result.ProductDetail = new ProductDetail() { OverallContainerPathType = rdr.CustomGetValue <string>("ProductDetail_OverallContainerPathType"), OverallContainer = rdr.CustomGetValue <string>("ProductDetail_OverallContainer"), ProductContainerPathType = rdr.CustomGetValue <string>("ProductDetail_ProductContainerPathType"), ProductContainer = rdr.CustomGetValue <string>("ProductDetail_ProductContainer") }; result.PaginationDetail = new PaginationDetail() { PagingType = rdr.CustomGetValue <string>("PaginationDetail_PagingType"), PaginationContainerPathType = rdr.CustomGetValue <string>("PaginationDetail_PaginationContainerPathType"), PaginationContainer = rdr.CustomGetValue <string>("PaginationDetail_PaginationContainer"), DoesHaveNextButton = rdr.CustomGetValue <bool>("PaginationDetail_DoesHaveNextButton"), NextButtonPathType = rdr.CustomGetValue <string>("PaginationDetail_NextButtonPathType"), NextButton = rdr.CustomGetValue <string>("PaginationDetail_NextButton"), ActiveClassForCurrentPage = rdr.CustomGetValue <string>("PaginationDetail_ActiveClassForCurrentPage"), DisabledClassForLastPage = rdr.CustomGetValue <string>("PaginationDetail_DisabledClassForLastPage"), ShouldLimitPaging = rdr.CustomGetValue <bool>("PaginationDetail_ShouldLimitPaging"), PagingLimit = rdr.CustomGetValue <string>("PaginationDetail_PagingLimit") }; result.MailingInformation = new MailingInformation() { ShouldSendMail = rdr.CustomGetValue <bool>("MailingInformation_ShouldSendMail"), MailToAddress = rdr.CustomGetValue <string>("MailingInformation_MailToAddress"), MailCCAddress = rdr.CustomGetValue <string>("MailingInformation_MailCCAddress"), MailBCCAddress = rdr.CustomGetValue <string>("MailingInformation_MailBCCAddress") }; } } if (rdr.NextResult()) { while (rdr.Read()) { string url = rdr.CustomGetValue <string>("WebsiteURL"); result.WebsiteDetail.WebsiteURLs.Add(url); } } if (rdr.NextResult()) { while (rdr.Read()) { var inputField = new InputField() { FieldName = rdr.CustomGetValue <string>("FieldName"), FieldPathType = rdr.CustomGetValue <string>("FieldPathType"), FieldPath = rdr.CustomGetValue <string>("FieldPath"), HasPartnerElement = rdr.CustomGetValue <bool>("HasPartnerElement"), TargetType = rdr.CustomGetValue <string>("TargetType"), WaitingTimeAfterElementChange = rdr.CustomGetValue <string>("WaitingTimeAfterElementChange") }; result.WebsiteDetail.InputFields.Add(inputField); } } if (rdr.NextResult()) { while (rdr.Read()) { var field = new Field() { FieldName = rdr.CustomGetValue <string>("FieldName"), FieldPathType = rdr.CustomGetValue <string>("FieldPathType"), FieldPath = rdr.CustomGetValue <string>("FieldPath"), ShouldCheckElementInBody = rdr.CustomGetValue <bool>("ShouldCheckElementInBody"), RemoveText = rdr.CustomGetValue <string>("RemoveText"), AttributeName = rdr.CustomGetValue <string>("AttributeName") }; result.ProductDetail.Fields.Add(field); } } } } } } catch (Exception ex) { _log.Write("Exception in DataAccess; Message: " + ex.Message); } finally { } return(result); }
public ConfigurationViewModel(ConfigurationViewModelParam param) : this() { LoginUser = param.LoginUser; }