public WorkerCrawlerHotProduct(Entities.Company company, Entities.Configuration configuration, Entities.CrawlerProduct.ConfigurationHotProduct configurationHotProduct) { // TODO: Complete member initialization this.configuration = configuration; this.configurationHotProduct = configurationHotProduct; this.company = company; }
private void InitSession() { _session = Guid.NewGuid().ToString(); if (!_productAdapter.AllowCrawlReload(this._companyId)) { return; } _config = new Configuration(_companyId, true); _company = new QT.Entities.Company(_companyId); _productAdapter.UpdateLastJobForDb(_company.ID); _productAdapter.UpdateLastReloadCrawler(_company.ID); _timeStart = DateTime.Now; _crawlerRegexs = _config.VisitUrlsRegex; _noCrawlerRegexs = _config.NoVisitUrlRegex; _countChange = 0; _countLink = 0; _countVisited = 0; _countProduct = 0; _totalProductBefore = _company.TotalProduct; _productWaitInsertGroup.Clear(); _productIdWaitChangeImage.Clear(); _linksQueue.Clear(); _crawlerRegexs.Clear(); _noCrawlerRegexs.Clear(); _dicCacheProduct.Clear(); _dicDuplicate.Clear(); _dicTrackDie = _cacheCheckDelete.GetDicTrackOfCompany(_companyId); lock (_productWaitUpdateGroup) { _productWaitUpdateGroup.Clear(); } LoadQueue(); }
private CompanyModel ToCompanyModel(Entities.Company company) { return(company != null ? new CompanyModel { Id = company.Id, Name = company.Name, CompanyOu = company.CompanyOu, ParentId = company.ParentId, Status = (CompanyStatus)company.Status, Type = (CompanyType)company.Type, UniqueIdentifier = company.UniqueIdentifier, StreetAddress = company.StreetAddress, BrandColorPrimary = company.BrandColorPrimary, Email = company.Email, City = company.City, Country = company.Country, State = company.State, ZipCode = company.ZipCode, PhoneNumber = company.PhoneNumber, LogoUrl = company.LogoUrl, BrandColorSecondary = company.BrandColorSecondary, BrandColorText = company.BrandColorText, Website = company.Website, SupportSiteUrl = company.SupportSiteUrl, ControlPanelSiteUrl = company.ControlPanelSiteUrl, CreateDate = company.CreateDate, Domains = company.Domains.Select(d => new DomainModel { Id = d.Id, Name = d.Name, IsPrimary = d.IsPrimary }) } : null); }
/// <summary> /// /// </summary> /// <param name="company"></param> /// <returns></returns> public bool DeleteCompany(Entities.Company company) { var isDeleted = false; try { using (DbCommand dbCommand = database.GetStoredProcCommand(DBStoredProcedure.DeleteCompany)) { database.AddInParameter(dbCommand, "@company_id", DbType.Int32, company.CompanyId); database.AddInParameter(dbCommand, "@deleted_by", DbType.Int32, company.DeletedBy); database.AddInParameter(dbCommand, "@deleted_by_ip", DbType.String, company.DeletedByIP); database.AddOutParameter(dbCommand, "@return_value", DbType.Int32, 0); var result = database.ExecuteNonQuery(dbCommand); if (database.GetParameterValue(dbCommand, "@return_value") != DBNull.Value) { isDeleted = Convert.ToBoolean(database.GetParameterValue(dbCommand, "@return_value")); } } } catch (Exception e) { throw e; } return(isDeleted); }
/// <summary> /// /// </summary> /// <returns></returns> public List <Entities.Company> SearchCompaniesByCompanyCodeOrName(string searchCriteria) { var companies = new List <Entities.Company>(); try { using (DbCommand dbCommand = database.GetStoredProcCommand(DBStoredProcedure.SearchCompaniesByCompanyCodeOrName)) { database.AddInParameter(dbCommand, "@search_company_name", DbType.String, searchCriteria); using (IDataReader reader = database.ExecuteReader(dbCommand)) { while (reader.Read()) { var company = new Entities.Company { CompanyId = DRE.GetNullableInt32(reader, "company_id", 0), CompanyName = DRE.GetNullableString(reader, "company_name", null) }; companies.Add(company); } } } } catch (Exception ex) { throw ex; } return(companies); }
public List <Entities.Company> GetCompanyIdAndCompanyName() { var companies = new List <Entities.Company>(); try { using (DbCommand dbCommand = database.GetStoredProcCommand(DBStoredProcedure.GetCompanyIdAndCompanyName)) { using (IDataReader reader = database.ExecuteReader(dbCommand)) { while (reader.Read()) { var company = new Entities.Company { CompanyId = DRE.GetNullableInt32(reader, "company_id", 0), CompanyName = DRE.GetNullableString(reader, "company_name", null) }; companies.Add(company); } } } } catch (Exception ex) { throw ex; } return(companies); }
public async Task <bool> Update(Entities.Company company) { var updated = await _context.Companies .ReplaceOneAsync(filter : item => item.Id == company.Id, replacement : company); return(updated.IsAcknowledged && updated.ModifiedCount > 0); }
// <returns></returns> public Int32 SaveCompany(Entities.Company company) { var companyId = 0; if (company.CompanyId == null || company.CompanyId == 0) { companyId = AddCompany(company); } else { if (company.IsDeleted == true) { var isDeleted = DeleteCompany(company); if (isDeleted == true) { companyId = (int)company.CompanyId; } } else { companyId = UpdateCompany(company); } } return(companyId); }
public async Task <IActionResult> Create(Entities.Company company) { _context.Companies.Add(company); await _context.SaveChanges(); return(Ok(company.Id)); }
private void InitSession() { _countVisited = 0; _totalProductBefore = 0; _countLink = 0; _countChange = 0; _session = Guid.NewGuid().ToString(); _tokenCrawler.ThrowIfCancellationRequested(); if (!_productAdapter.AllowCrawlFindNew(_companyId)) { return; } _company = new QT.Entities.Company(this._companyId); _config = new Configuration(_companyId, true); _visitRegexs = _config.VisitUrlsRegex; _detailLinkRegexs = _config.ProductUrlsRegex; _extraRegexNoVisitFn = _productAdapter.GetEtraRegexByTypeWeb(_companyId); _noCrawlerRegexs = _config.NoVisitUrlRegex; _noCrawlerRegexs.AddRange(Common.noCrawlerRegexDefault); _noCrawlerRegexs.AddRange(_extraRegexNoVisitFn); string rootUrl = _company.Website; _urlCurrent = ""; startCrawler = DateTime.Now; _linkQueue.Clear(); _visitedCrc.Clear(); _rootUri = Common.GetUriFromUrl(_company.Website); ClearOldCache(); _linkQueue.Enqueue(_company.Website); LoadOldData(); _totalProduct = _crcProductOldGroup.Count; }
private void btnCreateCom_Click(object sender, EventArgs e) { if (ValidateForm()) { var logCompany = new Logic.Company(); var entCompany = new Entities.Company(txtCuilCom.Text, txtNameCom.Text, txtAdressCom.Text); if (logCompany.ValidateCompany(entCompany)) { try { logCompany.CreateCompany(entCompany); } catch (Exception ex) { MessageBox.Show(ex.Message); } MessageBox.Show("EMPRESA CREADA CON EXITO."); frmRequester.CreateCompany(entCompany); this.Close(); } else { MessageBox.Show("LA EMPRESA YA A SIDO CREADA."); FocusAndClean(); } } }
public async Task CreateCompanyAsync(CompanyCreateRequest request) { Entities.Company company = CompanyFactory.CreateCompany(request); _companyRepository.Insert(company); await _unitOfWork.SaveAsync(); }
public CompanyDetailsPageModel(Entities.Company model) { Title = "Detalhes da Empresa"; Company = model; NotHasContacts = Company?.Contacts == null || !Company.Contacts.Any(); OpenMapCommand = new Command(ExecuteOpenMap); ShareCommand = new Command(async() => await ExecuteShare()); MakePhoneCallCommand = new Command(ExecuteMakePhoneCall); }
public Company(Entities.Company customer) : base(customer) { CompanyName = customer.CompanyName; TradeName = customer.TradeName; Cnpj = customer.Cnpj; Ie = customer.Ie; Im = customer.Im; }
public async void HandleValidSubmit() { foreach (var item in CheckBox) { CompanyDto company = (from c in companies where c.Name == item select c).FirstOrDefault(); Entities.Company companyToAdd = new Entities.Company { Name = company.Name, Email = company.Email, PhoneNumber = company.PhoneNumber, County = company.County, Invoiced = company.Invoiced, Accomplished = company.Accomplished, AvailableJobs = company.AvailableJobs, HitRate = company.HitRate, LatestLead = company.LatestLead, Leads = company.Leads, Left = company.Left, SalesTarget = company.SalesTarget }; companiesToAdd.Add(companyToAdd); } leadToSend.CompaniesSentTo = companiesToAdd; bool test; success = await Service.SendLead(leadToSend); //NOT IMPLEMENTED YET! //foreach(var company in leadToSend.CompaniesSentTo) //{ await ExecuteMail( "*****@*****.**", "Jesper", "Uppdrag från Trädgårdsproffsen", "Hejsan! \n " + "\n " + "Här kommer ett uppdrag från oss på Trädgårdsproffsen. Ring kunden så fort som möjligt, lycka till! \n" + $"{leadToSend.Name}\n" + $"{leadToSend.PhoneNumber}\n" + $"{leadToSend.Address + leadToSend.PostCode + leadToSend.District}\n" + $"{leadToSend.Info}\n" + $"{leadToSend.Description}" ); // } test = await validService.DeleteValidated(lead.Id); }
/// <summary> /// Valida que la empresa no se cree de nuevo. /// </summary> /// <param name="company">es la empresa que se queire validar.</param> /// <returns>Devuelve true si la empresa no se creo. Devulve false si la empresa ya existe.</returns> public bool ValidateCompany(Entities.Company company) { var companies = GetAllCompanies(); foreach (var c in companies) { if (c.CuilCom == company.CuilCom) { return(false); } } return(true); }
private void EndSession() { lock (_objLockEndSession) { if (_company != null) { LogData(string.Format("!------:{0} END RELOAD {1} {2} Vs:{3}", _indexThread, _company.ID, _company.Domain, _countVisited)); _productAdapter.UpdateEndCrawl(_company.ID, 1, _startCrawler, DateTime.Now, _countLink, _countVisited, _countProduct, _countChange, _session, _totalProductBefore, QT.Entities.Server.IPHost, _company.Domain); _redisWaitCrawler.SetNexReload(_companyId, _config.MinHourReload); _redisWaitCrawler.SetRemoveRunningCrawler(_companyId); _company = null; _companyId = 0; } } }
public List <Entities.Company> SearchCompanyByName(string companyName) { var companies = new List <Entities.Company>(); try { using (DbCommand dbCommand = database.GetStoredProcCommand(DBStoredProcedure.SearchCompany)) { database.AddInParameter(dbCommand, "@company_name", DbType.String, companyName); using (IDataReader reader = database.ExecuteReader(dbCommand)) { while (reader.Read()) { var company = new Entities.Company { CompanyId = DRE.GetNullableInt32(reader, "company_id", 0), CompanyCode = DRE.GetNullableString(reader, "company_code", null), CompanyName = DRE.GetNullableString(reader, "company_name", null), ShortName = DRE.GetNullableString(reader, "short_name", null), CompanyAddress = DRE.GetNullableString(reader, "company_address", null), CountryId = DRE.GetNullableInt32(reader, "country_id", null), CountryName = DRE.GetNullableString(reader, "country_name", null), StateId = DRE.GetNullableInt32(reader, "state_id", null), StateName = DRE.GetNullableString(reader, "state_name", null), CityId = DRE.GetNullableInt32(reader, "city_id", null), CityName = DRE.GetNullableString(reader, "city_name", null), PinCode = DRE.GetNullableString(reader, "pin_code", null), Locality = DRE.GetNullableString(reader, "locality", null), Website = DRE.GetNullableString(reader, "website", null), GSTINNo = DRE.GetNullableString(reader, "gstin_no", null), ContactPerson = DRE.GetNullableString(reader, "contact_person", null), ContactNo = DRE.GetNullableString(reader, "contact_no", null), EmailId = DRE.GetNullableString(reader, "email_id", null) }; companies.Add(company); } } } } catch (Exception ex) { throw ex; } return(companies); }
/// <summary> /// /// </summary> /// <param name="companyId"></param> /// <returns></returns> public Entities.Company GetCompanyDetailsById(Int32 companyId) { var companyDetails = new Entities.Company(); try { using (DbCommand dbCommand = database.GetStoredProcCommand(DBStoredProcedure.GetCompanyDetailsById)) { database.AddInParameter(dbCommand, "@company_id", DbType.Int32, companyId); using (IDataReader reader = database.ExecuteReader(dbCommand)) { while (reader.Read()) { var company = new Entities.Company { CompanyId = DRE.GetNullableInt32(reader, "company_id", 0), CompanyCode = DRE.GetNullableString(reader, "company_code", null), CompanyName = DRE.GetNullableString(reader, "company_name", null), ShortName = DRE.GetNullableString(reader, "short_name", null), CompanyAddress = DRE.GetNullableString(reader, "company_address", null), CountryId = DRE.GetNullableInt32(reader, "country_id", null), CountryName = DRE.GetNullableString(reader, "country_name", null), StateId = DRE.GetNullableInt32(reader, "state_id", null), StateName = DRE.GetNullableString(reader, "state_name", null), CityId = DRE.GetNullableInt32(reader, "city_id", null), CityName = DRE.GetNullableString(reader, "city_name", null), Locality = DRE.GetNullableString(reader, "locality", null), Website = DRE.GetNullableString(reader, "website", null), GSTINNo = DRE.GetNullableString(reader, "gstin_no", null), ContactPerson = DRE.GetNullableString(reader, "contact_person", null), ContactNo = DRE.GetNullableString(reader, "contact_no", null), EmailId = DRE.GetNullableString(reader, "email_id", null), guid = DRE.GetNullableGuid(reader, "row_guid", null) }; companyDetails = company; } } } } catch (Exception ex) { throw ex; } return(companyDetails); }
public static void ShowProduct(long CompanyId) { Entities.Company company = new Entities.Company(CompanyId); Configuration config = new Configuration(CompanyId); ProductParse pp = new ProductParse(); ProductEntity product = new ProductEntity(); string detailUrl = config.LinkTest; GABIZ.Base.HtmlAgilityPack.HtmlDocument document = new GABIZ.Base.HtmlAgilityPack.HtmlDocument(); pp.Analytics(product, document, config.LinkTest, config, config.Domain); string strDataShow = ""; strDataShow += string.Format("\r\n Name: {0}", product.Name); frmShow.Visible = true; frmShow.Show(); }
public async Task <IActionResult> Update(int id, Entities.Company companyData) { var company = _context.Companies.Where(a => a.Id == id).FirstOrDefault(); if (company == null) { return(NotFound()); } else { company.Name = companyData.Name; company.Contact = companyData.Contact; await _context.SaveChanges(); return(Ok(company.Id)); } }
public CompanyMarketOfferListViewModel(Entities.Company company, IQueryable <MarketOfferModel> marketOffers, PagingParam pagingParam, CompanyRights rights, IMarketService marketService) { Info = new CompanyInfoViewModel(company); CompanyRights = rights; PagingParam = pagingParam; if (marketOffers.Count() > 0) { var filteredOffers = marketOffers.OrderByDescending(mo => mo.OfferID).Apply(PagingParam).ToList(); foreach (var offer in filteredOffers) { Offers.Add(new MarketOfferViewModel(SessionHelper.CurrentEntity, offer, marketService, deleteable: true, showDetails: true)); } } }
private static IEnumerable <Entities.Company> GetAllCompanyDescendants(Entities.Company company) { var allDescendants = new List <Entities.Company>(); company.MyCompanies.ForEach(c => { allDescendants.Add(c); if (c.MyCompanies.Count <= 0) { return; } var descendants = GetAllCompanyDescendants(c); allDescendants.AddRange(descendants); }); return(allDescendants); }
private static IEnumerable <Entities.Company> GetAllCompanyDescendants(Entities.Company company) { var allDescendants = new List <Entities.Company>(); company.MyCompanies.Where(c => c.CompanyCatalogs.Any(cc => cc.CatalogType == CatalogType.Assigned)).ToList().ForEach(c => { allDescendants.Add(c); if (c.MyCompanies.Count <= 0) { return; } var descendants = GetAllCompanyDescendants(c); allDescendants.AddRange(descendants); }); return(allDescendants); }
private static List <Entities.Company> GetCompanyDescendantsAffectedByUpdate(Entities.Company company, int catalogId) { var descendantsAffectedByUpdate = new List <Entities.Company>(); var childrenWithAssignedCatalog = company.MyCompanies.Where(c => c.CompanyCatalogs.Any(cc => cc.CatalogType == CatalogType.Assigned && cc.CatalogId == catalogId)).ToList(); childrenWithAssignedCatalog.ForEach(c => { descendantsAffectedByUpdate.Add(c); if (c.MyCompanies.Count <= 0) { return; } var descendants = GetAllCompanyDescendants(c); descendantsAffectedByUpdate.AddRange(descendants); }); return(descendantsAffectedByUpdate); }
private Int32 AddCompany(Entities.Company company) { var companyId = 0; try { using (DbCommand dbCommand = database.GetStoredProcCommand(DBStoredProcedure.InsertCompany)) { database.AddInParameter(dbCommand, "@company_id", DbType.Int32, company.CompanyId); database.AddInParameter(dbCommand, "@company_code", DbType.String, company.CompanyCode); database.AddInParameter(dbCommand, "@company_name", DbType.String, company.CompanyName); database.AddInParameter(dbCommand, "@short_name", DbType.String, company.ShortName); database.AddInParameter(dbCommand, "@company_address", DbType.String, company.CompanyAddress); database.AddInParameter(dbCommand, "@country_id", DbType.Int32, company.CountryId); database.AddInParameter(dbCommand, "@state_id", DbType.Int32, company.StateId); database.AddInParameter(dbCommand, "@city_id", DbType.Int32, company.CityId); database.AddInParameter(dbCommand, "@locality", DbType.String, company.Locality); database.AddInParameter(dbCommand, "@pin_code", DbType.String, company.PinCode); database.AddInParameter(dbCommand, "@website", DbType.String, company.Website); database.AddInParameter(dbCommand, "@gstin_no", DbType.String, company.GSTINNo); database.AddInParameter(dbCommand, "@contact_person", DbType.String, company.ContactPerson); database.AddInParameter(dbCommand, "@contact_no", DbType.String, company.ContactNo); database.AddInParameter(dbCommand, "@email_id", DbType.String, company.EmailId); database.AddInParameter(dbCommand, "@created_by", DbType.Int32, company.CreatedBy); database.AddInParameter(dbCommand, "@created_by_ip", DbType.String, company.CreatedByIP); database.AddOutParameter(dbCommand, "@return_value", DbType.Int32, 0); companyId = database.ExecuteNonQuery(dbCommand); if (database.GetParameterValue(dbCommand, "@return_value") != DBNull.Value) { companyId = Convert.ToInt32(database.GetParameterValue(dbCommand, "@return_value")); } } } catch (Exception e) { throw e; } return(companyId); }
public void Setup() { var grandchildCompany = new Entities.Company { Id = 3, Name = "Grand Child Company", }; var childCompany = new Entities.Company { Id = 2, Name = "Child Company", MyCompanies = new List <Entities.Company> { grandchildCompany } }; var parentCompany = new Entities.Company { Id = 1, Name = "Parent Company", MyCompanies = new List <Entities.Company> { childCompany } }; var companies = new List <Entities.Company> { parentCompany, childCompany, grandchildCompany }; var companiesDbSet = MockSetGenerator.CreateMockSet(companies); var dbContextMock = new Mock <CldpDbContext>(); dbContextMock.Setup(c => c.Companies).Returns(companiesDbSet); var userServiceMock = new Mock <IUserService>(); _sut = new Database.Company.CompanyService(dbContextMock.Object, userServiceMock.Object); }
private bool CreateTransactional(Entities.Company company, Address address) { int companyId = Create(company); _addressService.Create( new Address( null, companyId, address.FullAddress, address.MarkerLat, address.MarkerLng, address.ManualMarkerLat, address.ManualMarkerLng, address.CreatedAt, address.CreatedBy ) ); return(true); }
private void ModelToEntity(CompanyModel model, Entities.Company company) { company.BrandColorPrimary = model.BrandColorPrimary; company.BrandColorSecondary = model.BrandColorSecondary; company.BrandColorText = model.BrandColorText; company.City = model.City; company.Country = model.Country; company.Email = model.Email; company.Name = model.Name; company.PhoneNumber = model.PhoneNumber; company.State = model.State; company.StreetAddress = model.StreetAddress; company.SupportSiteUrl = model.SupportSiteUrl; company.ControlPanelSiteUrl = model.ControlPanelSiteUrl; company.Website = model.Website; company.ZipCode = model.ZipCode; if (!string.IsNullOrWhiteSpace(model.LogoUrl)) { company.LogoUrl = model.LogoUrl; } }
private void EndSession() { if (this._linkQueue.Count == 0) { _redisCrcVisited.RemoveCrcVited(_companyId); } else { _redisCrcVisited.SetForCompany(_companyId, new List <long>(_visitedCrc.Keys)); _redisQueueFindNew.SaveQueue(_companyId, _linkQueue.ToArray()); } _redisWaitCrawler.SetRemoveRunningCrawler(_companyId); _redisWaitCrawler.SetNexFindNew(_companyId, _config.MinHourFindNew); _productAdapter.UpdateEndCrawl(_company.ID, 0, startCrawler, DateTime.Now, _countLink, _countVisited, _totalProductBefore, _countChange, _session, _totalProduct + _totalProductBefore, QT.Entities.Server.IPHost, _company.Domain); LogData(string.Format(" >>>>>>> END SESSION {0} - Vs:{1}", _company.Domain, _countVisited)); this._visitedCrc.Clear(); this._linkQueue.Clear(); this._companyId = 0; this._company = null; }