private void UpdateData(CompanyProfile companyProfile) { using (SqlConnection connection = new SqlConnection(this._connString)) { string updateSql = @"UPDATE dbo.posTbCompanyProfile SET Name = @CPFName, Owner = @CPFOwner, LogoPath = @CPFLogoPath, Phone1 = @CPFPhone1, Phone2 = @CPFPhone2, Fax = @CPFFax, Email = @CPFEmail, Website = @CPFWebsite, Address1 = @CPFAddress1, Address2 = @CPFAddress2, City = @CPFCity, Zip = @CPFZip;"; SqlCommand command = new SqlCommand(updateSql, connection); command.Parameters.Add("@CPFName", SqlDbType.VarChar).Value = companyProfile.Name; command.Parameters.Add("@CPFOwner", SqlDbType.VarChar).Value = companyProfile.Owner; command.Parameters.Add("@CPFLogoPath", SqlDbType.VarChar).Value = companyProfile.LogoPath; command.Parameters.Add("@CPFPhone1", SqlDbType.VarChar).Value = companyProfile.Phone1; command.Parameters.Add("@CPFPhone2", SqlDbType.VarChar).Value = companyProfile.Phone2; command.Parameters.Add("@CPFFax", SqlDbType.VarChar).Value = companyProfile.Fax; command.Parameters.Add("@CPFEmail", SqlDbType.VarChar).Value = companyProfile.Email; command.Parameters.Add("@CPFWebsite", SqlDbType.VarChar).Value = companyProfile.Website; command.Parameters.Add("@CPFAddress1", SqlDbType.VarChar).Value = companyProfile.Address1; command.Parameters.Add("@CPFAddress2", SqlDbType.VarChar).Value = companyProfile.Address2; command.Parameters.Add("@CPFCity", SqlDbType.VarChar).Value = companyProfile.City; command.Parameters.Add("@CPFZip", SqlDbType.VarChar).Value = companyProfile.Zip; connection.Open(); command.ExecuteNonQuery(); } }
public async Task <IActionResult> PutCompanyProfile([FromRoute] int id, [FromBody] CompanyProfile companyProfile) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != companyProfile.Id) { return(BadRequest()); } _context.Entry(companyProfile).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompanyProfileExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public CompanyProfileRepository() { this._connString = SqlHelper.GetConnectionString(); this._cpfStore = new CompanyProfile(); this.PopulateData(); }
private void PopulateData() { using (SqlConnection connection = new SqlConnection(this._connString)) { SqlDataReader dataReader = null; string selectSql = @"SELECT * FROM dbo.posVwCompanyProfile;"; SqlCommand command = new SqlCommand(selectSql, connection); connection.Open(); dataReader = command.ExecuteReader(); while (dataReader.Read()) { this._cpfStore = new CompanyProfile() { Name = (string)dataReader["Name"], Owner = (string)dataReader["Owner"], LogoPath = (string)dataReader["LogoPath"], Phone1 = (string)dataReader["Phone1"], Phone2 = (string)dataReader["Phone2"], Fax = (string)dataReader["Fax"], Email = (string)dataReader["Email"], Website = (string)dataReader["Website"], Address1 = (string)dataReader["Address1"], Address2 = (string)dataReader["Address2"], City = (string)dataReader["City"], Zip = (string)dataReader["Zip"] }; } } }
public CompanyProfile GetUserInfo(string connectionString, string StoreProcedureName, string UserId, string Password) { CompanyProfile _userInfo = new CompanyProfile(); _userInfo = exSp.GetCompanyData(connectionString, StoreProcedureName, UserId, Password); return(_userInfo); }
public bool Save(CompanyProfile companyProfile) { bool isSaved = false; int retry = 0; while ((!isSaved) && (retry < 3)) { try { this.UpdateData(companyProfile); isSaved = true; } catch (SqlException) { retry++; } } if (!isSaved) { MessageBox.Show("Terjadi kesalahan program. Silahkan coba beberapa saat lagi.", "Proses Gagal", MessageBoxButton.OK); } this.PopulateData(); return(isSaved); }
public IActionResult GetCompanyProfile() { try { var companyProfile = _companyProfileRepository.Get(User.FindFirst(JwtRegisteredClaimNames.Sid).Value); if (companyProfile == null) { companyProfile = new CompanyProfile() { Name = "", Description = "", Adress = "", Website = "" }; } var companyProfileDto = Mapper.Map <CompanyProfileViewDto>(companyProfile); return(Ok(companyProfileDto)); } catch (Exception ex) { _logger.LogCritical($"An exception was thrown: ", ex); return(StatusCode(500, "A problem happend while handeling your request.")); } }
private void ClientOnCompProfCompletedEx(object sender, GetCompProfileCompletedEventArgs e) { string msg = null; bool success = true; if (e.Error != null) { msg = e.Error.Message; success = false; } else if (e.Cancelled) { msg = CallingActivity.Resources.GetString(Resource.String.msg_reqcancel); success = false; } else { CompanyProfile pro = (CompanyProfile)e.Result; RunOnUiThread(() => InsertCompProfIntoDbEx(pro)); } if (!success) { RunOnUiThread(() => Downloadhandle.Invoke(CallingActivity, 0, msg)); } }
public async Task CreateCompany(string email, string username, string name, string description, string password, IEnumerable <Category> categories) { var rating = new Rating(); var companyProfile = new CompanyProfile { Name = name, Description = description, Categories = categories, Rating = rating }; var user = new Project.Models.Account { Email = email, UserName = username, CompanyProfile = companyProfile, CompanyProfileId = companyProfile.Id, }; var result = await userManager.CreateAsync(user, password); if (result.Succeeded) { await CreateRole(Constants.companyRoleName, user); companyProfile.AccountId = user.Id; companyProfile.Account = user; context.SaveChanges(); } }
public void GetCompanyJobsTest() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "Get_Company_Jobs") .Options; int result; var companyProfile = new CompanyProfile { Account = new Account { UserName = "******" } }; var job = new Job { Company = companyProfile, Status = JobStatus.WaitingForCompany }; using (var context = new ApplicationDbContext(options)) { IJobService service = new JobService(context); context.CompaniesProfiles.Add(companyProfile); context.Jobs.Add(job); context.SaveChanges(); var jobs = service.GetCompanyJobs("username", JobStatus.WaitingForCompany); result = jobs.Count(); } Assert.Equal(1, result); }
public static CompanyProfile GetCompanyPageData(oAuthLinkedIn _oauth, string ProfileId) { CompanyProfile objCompanyProfile = new CompanyProfile(); objCompanyProfile = GetCompanyPageProfile(_oauth, ProfileId); return(objCompanyProfile); }
[HttpGet("{companyId}", Name = nameof(GetCompany))] //api/Companies/companyId //[Route("/{companyId}")] public async Task <IActionResult> GetCompany(Guid companyId, string fields, [FromHeader(Name = "Accept")] string mediaType) { if (!MediaTypeHeaderValue.TryParse(mediaType, out MediaTypeHeaderValue mediaTypeValue)) { return(BadRequest()); } if (!_propertyCheckServices.HasProperty <CompanyDto>(fields)) { return(BadRequest()); } var company = await _service.GetCompanyAsync(companyId); if (company == null) { return(NotFound()); } if (mediaTypeValue.MediaType == "application/vnd.company.hateoas.json") { var links = CreateLinksForCompany(companyId, fields); var resDic = CompanyProfile.InitializeAutoMapper().Map <CompanyDto>(company).ShapeData(fields) as IDictionary <string, object>; resDic.Add("Links", links); return(Ok(resDic)); } return(Ok(CompanyProfile.InitializeAutoMapper().Map <CompanyDto>(company).ShapeData(fields))); }
public ActionResult Index(HttpPostedFileWrapper file, string content) { string imgname = Guid.NewGuid().ToString() + ".jpg"; string imgpath = Server.MapPath("~/upload/image/" + imgname); file.SaveAs(imgpath); CompanyProfile pro = client.FindOne <CompanyProfile>(new { Language = Language }); if (pro == null) { pro = new CompanyProfile(); pro.ImaPath = "/upload/image/" + imgname; pro.Content = content; pro.Language = Language; pro.Type = ContentTypeEnum.公司简介; client.InsertOne(pro); } else { pro.ImaPath = "/upload/image/" + imgname; pro.Content = content; pro.Language = Language; pro.Type = ContentTypeEnum.公司简介; client.UpdateOneById(pro); } return(RedirectToAction("Index")); }
protected override int GetId(BaseModel dat) { CompanyProfile m = (CompanyProfile)dat; int id = (int)m.CompanyProfileId; return(id); }
public CompanyProfile GetCompanyProfile(string url, string apiKey, string ticker) { var companyProfile = new CompanyProfile(); var completeUrl = $"{url}&symbol={ticker}&apikey={apiKey}"; var client = new System.Net.WebClient(); var alphaVantageModel = JsonSerializer.Deserialize <AlphaVantageCompanyProfile>(client.DownloadString(completeUrl)); MapAlphaVantageModelToCompanyProfile(alphaVantageModel, companyProfile); /* * if (json_data != null) * { * var tasks = new List<Task>(); * foreach (var property in json_data) * { * tasks.Add(Task.Run(() => * { * MapProperties(property, companyProfile); * })); * } * Task.WaitAll(tasks.ToArray()); * } */ return(companyProfile); }
protected override int GetId(BaseModel dat) { CompanyProfile m = (CompanyProfile)dat; int id = ConvertUtils.NullableToInt(m.CompanyProfileId, 0); return(id); }
protected override BaseModel Execute(BaseModel dat) { OnixErpDbContext ctx = (OnixErpDbContext)context; CompanyProfile m = (CompanyProfile)dat; if ((m.CompanyPrefix != null) && (m.CompanyPrefix.MasterId != null)) { int?id = m.CompanyPrefix.MasterId; var o = ctx.Masters .Where(s => s.MasterId == id) .FirstOrDefault(); m.CompanyPrefix = o; } if (ConvertUtils.NullableToInt(m.CompanyProfileId, 0) <= 0) { m.CompanyProfileId = null; ctx.CompanyProfiles.Add(m); } else { ctx.CompanyProfiles.Update(m); } ctx.SaveChanges(); return(m); }
public ActionResult getBranch(string id) { CompanyProfile cp = new CompanyProfile(); List <CompanyProfile> branchList = cp.GetCompanyProfiles(id); return(Json(branchList, JsonRequestBehavior.AllowGet)); }
public static void BindShop(ComboBox cboCompanyName, bool includeALL = false) { if (includeALL) { MBMSEntities entity = new MBMSEntities(); List <CompanyProfile> companyProfileList = new List <CompanyProfile>(); CompanyProfile companyProfile = new CompanyProfile(); companyProfile.CompanyName = "ALL"; companyProfile.CompanyProfileID = null; var companys = entity.CompanyProfiles.ToList(); companyProfileList.Add(companyProfile); companyProfileList.AddRange(companys); cboCompanyName.DataSource = companyProfileList; cboCompanyName.DisplayMember = "CompanyName"; cboCompanyName.ValueMember = "CompanyProfileID"; cboCompanyName.AutoCompleteMode = AutoCompleteMode.SuggestAppend; cboCompanyName.AutoCompleteSource = AutoCompleteSource.ListItems; } else { MBMSEntities entity = new MBMSEntities(); List <CompanyProfile> companyProfileList = new List <CompanyProfile>(); cboCompanyName.DataSource = companyProfileList; cboCompanyName.DisplayMember = "CompanyName"; cboCompanyName.ValueMember = "CompanyProfileID"; cboCompanyName.AutoCompleteMode = AutoCompleteMode.SuggestAppend; cboCompanyName.AutoCompleteSource = AutoCompleteSource.ListItems; } }
public async Task <CompanyRaiting> GetCompanyRaitingAsync(CompanyProfile company) { CompanyRaitingFinMod raitingFinMod = await _financialModelingPrepService.GetCompanyRaitingAsync(company.Symbol); CompanyRaiting companyRaiting = new CompanyRaiting { Date = raitingFinMod.Date, Symbol = raitingFinMod.Symbol, Rating = _unitOfWork.Repository <Rating>().Find(rating => rating.Name == raitingFinMod.Rating).SingleOrDefault() ?? new Rating { Name = raitingFinMod.Rating }, RatingRecommendation = GetRatingRecommendation(raitingFinMod.RatingRecommendation), RatingScore = raitingFinMod.RatingScore, RatingDetailsDCFRecommendation = GetRatingRecommendation(raitingFinMod.RatingDetailsDCFRecommendation), RatingDetailsDCFScore = raitingFinMod.RatingDetailsDCFScore, RatingDetailsDERecommendation = GetRatingRecommendation(raitingFinMod.RatingDetailsDERecommendation), RatingDetailsDEScore = raitingFinMod.RatingDetailsDEScore, RatingDetailsPBRecommendation = GetRatingRecommendation(raitingFinMod.RatingDetailsPBRecommendation), RatingDetailsPBScore = raitingFinMod.RatingDetailsPBScore, RatingDetailsPERecommendation = GetRatingRecommendation(raitingFinMod.RatingDetailsPERecommendation), RatingDetailsPEScore = raitingFinMod.RatingDetailsPEScore, RatingDetailsROARecommendation = GetRatingRecommendation(raitingFinMod.RatingDetailsROARecommendation), RatingDetailsROAScore = raitingFinMod.RatingDetailsROAScore, RatingDetailsROERecommendation = GetRatingRecommendation(raitingFinMod.RatingDetailsROERecommendation), RatingDetailsROEScore = raitingFinMod.RatingDetailsROEScore }; return(companyRaiting); }
public void GetCompanyProfileWithUsernameTest() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "Get_CompanyProfile") .Options; var profile = new CompanyProfile { Account = new Account { UserName = "******" } }; CompanyProfile companyProfile; using (var context = new ApplicationDbContext(options)) { context.CompaniesProfiles.Add(profile); context.SaveChanges(); IProfileService service = new ProfileService(context); companyProfile = service.GetCompanyProfileWithUsername("username"); } Assert.Equal(profile.Account.UserName, companyProfile.Account.UserName); }
public async Task <int> DeleteCompanyProfileAsync(CompanyProfile model) { if (model.CompanyId > 0) { _context.CompanyProfile.Remove(model); } return(await _context.SaveChangesAsync()); }
public async Task <CompanyProfile> GetComponyData(string connection, string spName, string UserId, string Password) { string response = await httpClient.GetStringAsync("api/Values/GetUserInfo/" + connection + "," + spName + "," + UserId + "," + Password); CompanyProfile _userInfo = JsonConvert.DeserializeObject <CompanyProfile>(response); return(_userInfo); }
public ActionResult DeleteConfirmed(int id) { CompanyProfile companyProfile = db.CompanyProfiles.Find(id); db.CompanyProfiles.Remove(companyProfile); db.SaveChanges(); return(RedirectToAction("Index")); }
private void LoadCompanies(AssignLoanInfoViewModel assignLoanInfoViewModel) { if (assignLoanInfoViewModel.Companies != null) { assignLoanInfoViewModel.Companies.Clear(); } else { assignLoanInfoViewModel.Companies = new List <DropDownItem>(); } if (!assignLoanInfoViewModel.Companies.Any(c => c.Text.Equals(ViewAllItem.Text))) { assignLoanInfoViewModel.Companies.Add(ViewAllItem); } if (!assignLoanInfoViewModel.Channels.Any(ch => ch.Text.Equals(ViewAllItem.Text))) { assignLoanInfoViewModel.Channels.Add(ViewAllItem); } if (!assignLoanInfoViewModel.Divisions.Any(d => d.Text.Equals(ViewAllItem.Text))) { assignLoanInfoViewModel.Divisions.Add(ViewAllItem); } if (!assignLoanInfoViewModel.Branches.Any(b => b.Text.Equals(ViewAllItem.Text))) { assignLoanInfoViewModel.Branches.Add(ViewAllItem); } // for administrator role, we need to fetch all companies from the system var companies = MML.Web.Facade.UserAccountServiceFacade.GetAllCompanies(); if (companies == null) { return; } DropDownItem item = null; foreach (Company c in companies.OrderBy(c => c.Name)) { item = new DropDownItem(); item.Value = c.CompanyId.ToString(); item.Text = c.Name; assignLoanInfoViewModel.Companies.Add(item); } if (assignLoanInfoViewModel.CompanyId == null || assignLoanInfoViewModel.CompanyId == "-1" || assignLoanInfoViewModel.CompanyId == "0" || assignLoanInfoViewModel.CompanyId == Guid.Empty.ToString()) { CompanyProfile companyProfile = CompanyProfileServiceFacade.RetrieveCompanyProfile(); if (companyProfile != null) { assignLoanInfoViewModel.CompanyId = companyProfile.CompanyProfileId.ToString(); } } }
public CreateAcademyTrustViewModel(CompanyProfile companyProfile) { Name = companyProfile.Name; OpenDate = companyProfile.IncorporationDate; CompaniesHouseNumber = companyProfile.Number; Address = companyProfile.Address.ToString().Clean(); CompaniesHouseAddressToken = UriHelper.SerializeToUrlToken(companyProfile.Address); TrustExists = false; }
//[Authorize(Roles = "Admin,Client")] public ActionResult CompanyProfile(CompanyProfile CompanyProfile, string CompanyName, string CompanyType, string CompanySize, string Website , string PANCardNo, string TaxDeductionAccNo, string GSTTax, string ProvidentFund = "0", string EmployeeStateInsurance = "0") { string CorporateId = User.Identity.GetUserId(); bool result = cms.AddCompanyProfile(CorporateId, CompanyName, CompanyType, CompanySize, Website, DateTime.UtcNow, CorporateId, ProvidentFund, PANCardNo, TaxDeductionAccNo, EmployeeStateInsurance, GSTTax); return(RedirectToAction("CompanyProfile", "Dashboard", new { area = "CMS", status = result })); }
public void DeleteCompanyProfile(CompanyProfile cp) { CompanyProfile companyProfile = mBMSEntities.CompanyProfiles.Where(x => x.CompanyProfileID == cp.CompanyProfileID).SingleOrDefault(); companyProfile.Active = cp.Active; companyProfile.DeletedDate = DateTime.Now; companyProfile.DeletedUserID = cp.DeletedUserID; mBMSEntities.SaveChanges(); }
private void MapAlphaVantageModelToCompanyProfile(AlphaVantageCompanyProfile alphaVantageModel, CompanyProfile companyProfile) { companyProfile.Symbol = alphaVantageModel.Symbol; companyProfile.Profile.CompanyName = alphaVantageModel.Name; companyProfile.Profile.Country = alphaVantageModel.Country; companyProfile.Profile.Industry = alphaVantageModel.Industry; companyProfile.Profile.Sector = alphaVantageModel.Sector; }
public void UpdateCompanyProfile(CompanyProfile companyProfile) { if (companyProfile == null) { throw new ArgumentNullException(nameof(companyProfile)); } _companyProfileRepository.Update(companyProfile); }
private void InsertCompProfIntoDbEx(CompanyProfile pro) { string pathToDatabase = ((GlobalvarsApp)CallingActivity.Application).DATABASE_PATH; string compcode = ((GlobalvarsApp)CallingActivity.Application).COMPANY_CODE; string brncode = ((GlobalvarsApp)CallingActivity.Application).BRANCH_CODE; DataHelper.InsertCompProfIntoDb (pro, pathToDatabase,compcode,brncode); //FireEvent (EventID.LOGIN_DOWNCOMPRO); if (_downloadAll) { DownloadAllhandle.Invoke(CallingActivity,0,"Successfully Download Company Profile."); FireEvent (EventID.DOWNLOADED_PROFILE); } else Downloadhandle.Invoke(CallingActivity,0,"Successfully Download Company Profile."); }
/// <summary> /// Get The Linkedin Company Page Profile by Id /// </summary> /// <param name="OAuth"></param> /// <returns></returns> /// //id,name,email-domains,description,founded-year,end-year,locations,Specialties,website-url,status,employee-count-range,industries,company-type,logo-url,square-logo-url,blog-rss-url,num-followers,universal-name public CompanyProfile GetCompanyPageProfile(oAuthLinkedIn oAuth, string CompanyPageId) { CompanyProfile CompanyProfile = new CompanyProfile(); Company companyConnection = new Company(); xmlResult = companyConnection.Get_CompanyProfileById(oAuth, CompanyPageId); XmlElement root = xmlResult.DocumentElement; try { CompanyProfile.Pageid = xmlResult.GetElementsByTagName("id")[0].InnerText; } catch { } try { CompanyProfile.name = xmlResult.GetElementsByTagName("name")[0].InnerText; } catch { } try { CompanyProfile.EmailDomains = xmlResult.GetElementsByTagName("email-domains")[0].InnerText; } catch { } try { CompanyProfile.description = xmlResult.GetElementsByTagName("description")[0].InnerText; } catch { } try { CompanyProfile.founded_year = xmlResult.GetElementsByTagName("founded-year")[0].InnerText; } catch { } try { CompanyProfile.end_year = xmlResult.GetElementsByTagName("end-year")[0].InnerText; } catch { } try { string location = string.Empty; string street1 = xmlResult.GetElementsByTagName("street1")[0].InnerText; string city = xmlResult.GetElementsByTagName("city")[0].InnerText; string postalcode = xmlResult.GetElementsByTagName("postal-code")[0].InnerText; string phone1 = xmlResult.GetElementsByTagName("phone1")[0].InnerText; string fax = xmlResult.GetElementsByTagName("fax")[0].InnerText; location += street1 + " " + city + " postal Code: " + postalcode + " Phone: " + phone1 + " Fax: " + fax; CompanyProfile.locations = location; } catch { } try { string Speciality = string.Empty; XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("specialties"); foreach (XmlNode xn in xmlNodeList) { try { XmlElement Element = (XmlElement)xn; Speciality = Element.GetElementsByTagName("specialty")[0].InnerText; Speciality += ","; } catch { } } Speciality = Speciality.Substring(0, Speciality.Length - 1); CompanyProfile.Specialties = Speciality; } catch { } try { CompanyProfile.website_url = xmlResult.GetElementsByTagName("website-url")[0].InnerText; } catch { } try { XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("status"); foreach (XmlNode xn in xmlNodeList) { try { XmlElement Element = (XmlElement)xn; CompanyProfile.status = Element.GetElementsByTagName("name")[0].InnerText; } catch { } } } catch { } try { XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("employee-count-range"); foreach (XmlNode xn in xmlNodeList) { try { XmlElement Element = (XmlElement)xn; CompanyProfile.employee_count_range = Element.GetElementsByTagName("name")[0].InnerText; } catch { } } } catch { } try { XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("industry"); foreach (XmlNode xn in xmlNodeList) { try { XmlElement Element = (XmlElement)xn; CompanyProfile.industries = Element.GetElementsByTagName("name")[0].InnerText; } catch { } } } catch { } try { XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("company-type"); foreach (XmlNode xn in xmlNodeList) { try { XmlElement Element = (XmlElement)xn; CompanyProfile.company_type = Element.GetElementsByTagName("name")[0].InnerText; } catch { } } } catch { } try { CompanyProfile.logo_url = xmlResult.GetElementsByTagName("logo-url")[0].InnerText; } catch { } try { CompanyProfile.square_logo_url = xmlResult.GetElementsByTagName("square-logo-url")[0].InnerText; } catch { } try { CompanyProfile.blog_rss_url = xmlResult.GetElementsByTagName("blog-rss-url")[0].InnerText; } catch { } try { CompanyProfile.num_followers = Convert.ToInt16(xmlResult.GetElementsByTagName("num-followers")[0].InnerText); } catch { } try { CompanyProfile.universal_name = xmlResult.GetElementsByTagName("universal-name")[0].InnerText; } catch { } return CompanyProfile; }
/// <summary> /// Get The Linkedin Company Page Profile by Id /// </summary> /// <param name="OAuth"></param> /// <returns></returns> /// //id,name,email-domains,description,founded-year,end-year,locations,Specialties,website-url,status,employee-count-range,industries,company-type,logo-url,square-logo-url,blog-rss-url,num-followers,universal-name public CompanyProfile GetCompanyPageProfile(oAuthLinkedIn oAuth, string CompanyPageId) { CompanyProfile CompanyProfile = new CompanyProfile(); Company companyConnection = new Company(); //xmlResult = companyConnection.Get_CompanyProfileById(oAuth, CompanyPageId); //XmlElement root = xmlResult.DocumentElement; string linkedincmpydata = companyConnection.GetLinkedIN_CompanyProfileById(oAuth,CompanyPageId); var company_data = JObject.Parse(linkedincmpydata); try { //CompanyProfile.Pageid = xmlResult.GetElementsByTagName("id")[0].InnerText; CompanyProfile.Pageid = company_data["id"].ToString(); } catch { } try { //CompanyProfile.name = xmlResult.GetElementsByTagName("name")[0].InnerText; CompanyProfile.name = company_data["name"].ToString(); } catch { } try { // CompanyProfile.EmailDomains = xmlResult.GetElementsByTagName("email-domains")[0].InnerText; CompanyProfile.EmailDomains = company_data["emailDomains"]["values"][0].ToString(); } catch { } try { //CompanyProfile.description = xmlResult.GetElementsByTagName("description")[0].InnerText; CompanyProfile.description = company_data["description"].ToString(); } catch { } try { //CompanyProfile.founded_year = xmlResult.GetElementsByTagName("founded-year")[0].InnerText; CompanyProfile.founded_year = company_data["foundedYear"].ToString(); } catch { } try { //CompanyProfile.end_year = xmlResult.GetElementsByTagName("end-year")[0].InnerText; } catch { } try { string location = string.Empty; //string street1 = xmlResult.GetElementsByTagName("street1")[0].InnerText; //string city = xmlResult.GetElementsByTagName("city")[0].InnerText; //string postalcode = xmlResult.GetElementsByTagName("postal-code")[0].InnerText; //string phone1 = xmlResult.GetElementsByTagName("phone1")[0].InnerText; //string fax = xmlResult.GetElementsByTagName("fax")[0].InnerText; string street1 = company_data["locations"]["values"][0]["address"]["street1"].ToString(); string city = company_data["locations"]["values"][0]["address"]["city"].ToString(); string postalCode = company_data["locations"]["values"][0]["address"]["postalCode"].ToString(); string phone1 = company_data["locations"]["values"][0]["contactInfo"]["phone1"].ToString(); string fax = company_data["locations"]["values"][0]["contactInfo"]["fax"].ToString(); location += street1 + " " + city + " postal Code: " + postalCode + " Phone: " + phone1 + " Fax: " + fax; CompanyProfile.locations = location; } catch { } try { string Speciality = string.Empty; //XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("specialties"); //foreach (XmlNode xn in xmlNodeList) //{ // try // { // XmlElement Element = (XmlElement)xn; // Speciality = Element.GetElementsByTagName("specialty")[0].InnerText; // Speciality += ","; // } // catch { } //} foreach (var item in company_data["specialties"]["values"]) { try { Speciality = item.ToString(); Speciality += ","; } catch { } } Speciality = Speciality.Substring(0, Speciality.Length - 1); CompanyProfile.Specialties = Speciality; } catch { } try { //CompanyProfile.website_url = xmlResult.GetElementsByTagName("website-url")[0].InnerText; CompanyProfile.website_url = company_data["websiteUrl"].ToString(); } catch { } try { CompanyProfile.status = company_data["status"]["name"].ToString(); //XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("status"); //foreach (XmlNode xn in xmlNodeList) //{ // try // { // XmlElement Element = (XmlElement)xn; // CompanyProfile.status = Element.GetElementsByTagName("name")[0].InnerText; // } // catch { } //} } catch { } try { CompanyProfile.employee_count_range = company_data["employeeCountRange"]["name"].ToString(); //XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("employee-count-range"); //foreach (XmlNode xn in xmlNodeList) //{ // try // { // XmlElement Element = (XmlElement)xn; // CompanyProfile.employee_count_range = Element.GetElementsByTagName("name")[0].InnerText; // } // catch { } //} } catch { } try { foreach (var item in company_data["industries"]["values"]) { CompanyProfile.industries = item["name"].ToString(); } //XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("industry"); //foreach (XmlNode xn in xmlNodeList) //{ // try // { // XmlElement Element = (XmlElement)xn; // CompanyProfile.industries = Element.GetElementsByTagName("name")[0].InnerText; // } // catch { } //} } catch { } try { CompanyProfile.company_type = company_data["companyType"]["name"].ToString(); //XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("company-type"); //foreach (XmlNode xn in xmlNodeList) //{ // try // { // XmlElement Element = (XmlElement)xn; // CompanyProfile.company_type = Element.GetElementsByTagName("name")[0].InnerText; // } // catch { } //} } catch { } try { // CompanyProfile.logo_url = xmlResult.GetElementsByTagName("logo-url")[0].InnerText; CompanyProfile.logo_url = company_data["logoUrl"]. ToString(); } catch { } try { // CompanyProfile.square_logo_url = xmlResult.GetElementsByTagName("square-logo-url")[0].InnerText; CompanyProfile.square_logo_url = company_data["square-logo-url"].ToString(); } catch { } try { //CompanyProfile.blog_rss_url = xmlResult.GetElementsByTagName("blog-rss-url")[0].InnerText; CompanyProfile.blog_rss_url = company_data["blog-rss-url"].ToString(); } catch { } try { //CompanyProfile.num_followers = Convert.ToInt16(xmlResult.GetElementsByTagName("num-followers")[0].InnerText); CompanyProfile.num_followers = Convert.ToInt16(company_data["numFollowers"].ToString()); } catch { } try { // CompanyProfile.universal_name = xmlResult.GetElementsByTagName("universal-name")[0].InnerText; CompanyProfile.universal_name = company_data["universalName"].ToString(); } catch { } return CompanyProfile; }
public static void InsertCompProfIntoDb(CompanyProfile pro,string pathToDatabase) { using (var db = new SQLite.SQLiteConnection(pathToDatabase)) { var list2 = db.Table<CompanyInfo>().ToList<CompanyInfo>(); var list3 = db.Table<AdPara>().ToList<AdPara>(); var list4 = db.Table<AdNumDate> ().Where (x => x.Year == DateTime.Now.Year && x.Month == DateTime.Now.Month).ToList<AdNumDate> (); CompanyInfo cprof = null; if (list2.Count > 0) { cprof = list2 [0]; } else { cprof = new CompanyInfo (); } cprof.Addr1 = pro.Addr1; cprof.Addr2= pro.Addr2; cprof.Addr3 = pro.Addr3; cprof.Addr4 = pro.Addr4; cprof.CompanyName = pro.CompanyName; cprof.Fax = pro.Fax; cprof.GSTNo = pro.GSTNo; cprof.HomeCurr = pro.HomeCurr; cprof.IsInclusive = pro.IsInclusive; cprof.RegNo = pro.RegNo; cprof.SalesTaxDec = pro.SalesTaxDec; cprof.AllowDelete = pro.AllowDelete; cprof.AllowEdit = pro.AllowEdit; cprof.WCFUrl = pro.WCFUrl; cprof.SupportContat = pro.SupportContat; cprof.ShowTime = pro.ShowPrintTime; cprof.AllowClrTrxHis = pro.AllowClrTrxHis; cprof.NotEditAfterPrint = pro.NoEditAfterPrint; cprof.Tel = pro.Tel; if (list2.Count==0) db.Insert (cprof); else db.Update (cprof); AdPara apara=null; if (list3.Count == 0) { apara= new AdPara (); } else { apara = list3 [0]; } apara.Prefix = pro.Prefix; apara.RunNo = pro.RunNo; apara.Warehouse = pro.WareHouse; //new added V2 apara.CNPrefix = pro.CNPrefix; apara.CNRunNo = pro.CNRunNo; apara.DOPrefix = pro.DOPrefix; apara.DORunNo = pro.DORunNo; apara.SOPrefix = pro.SOPrefix; apara.SORunNo = pro.SORunNo; if (list3.Count == 0) { apara.ReceiptTitle = "TAX INVOICE"; db.Insert (apara); } else { db.Update (apara); } AdNumDate info = null; if (list4.Count == 0) { info = new AdNumDate (); info.Year = DateTime.Now.Year; info.Month = DateTime.Now.Month; info.RunNo = pro.RunNo; info.TrxType = "INV"; db.Insert (info); } } }
private void InsertCompProfIntoDb(CompanyProfile pro) { string pathToDatabase = ((GlobalvarsApp)CallingActivity.Application).DATABASE_PATH; string comp =((GlobalvarsApp)CallingActivity.Application).COMPANY_CODE; string brn =((GlobalvarsApp)CallingActivity.Application).BRANCH_CODE; try { DataHelper.InsertCompProfIntoDb (pro, pathToDatabase,comp,brn); } catch(Exception ex) { AlertShow (ex.Message + ex.StackTrace); } //DownloadAllhandle.Invoke(CallingActivity,0,"Successfully downloaded Profile."); startDownloadRunNoInfo (); // if (_downloadAll) { // DownloadAllhandle.Invoke(CallingActivity,0,"Successfully downloaded Profile."); // FireEvent (EventID.DOWNLOADED_PROFILE); // // }else Downloadhandle.Invoke(CallingActivity,0,"Successfully downloaded Profile."); }
private void InsertCompProfIntoDbEx(CompanyProfile pro) { string pathToDatabase = ((GlobalvarsApp)CallingActivity.Application).DATABASE_PATH; DataHelper.InsertCompProfIntoDb (pro, pathToDatabase); string dmsg = CallingActivity.Resources.GetString (Resource.String.msg_successdownprofile); //FireEvent (EventID.LOGIN_DOWNCOMPRO); if (_downloadAll) { DownloadAllhandle.Invoke(CallingActivity,0, dmsg); FireEvent (EventID.DOWNLOADED_PROFILE); } else Downloadhandle.Invoke(CallingActivity,0,dmsg); }
static void calculatePenaltyForEachLoan(FinanceManagerDataContext dataContext, CompanyProfile cProfile) { //set grace period to zero if null if (cProfile.GracePeriodDays == null) cProfile.GracePeriodDays = 0; //select loans that have not been paid up and thier expected repayment dates are due. Given a grace period DateTime TodayPlusGracePeriod = DateTime.Today.Date.AddDays(cProfile.GracePeriodDays.Value); foreach (Loan Loanitem in dataContext.Loans.Where(l => l.IsPaidup.Value == false && TodayPlusGracePeriod >= l.ExpectedRepaymentEndDate.Value.Date)) //iterate through unpaid loans { LoanPenalty _loanPenalty = null; //get most recent penalty for current loan (Last penalty calculates) try { _loanPenalty = dataContext.LoanPenalties.Where<LoanPenalty>(l => l.LoanID == Loanitem.LoanID).OrderBy(lp => lp.CreatedDate).LastOrDefault(); } catch (Exception) { } //get the frequency of calculation of penalty eg. every 30days int? _PenaltyCalculationFrequencyDays = cProfile.PenaltyCalculationFrequencyDays.Value; if (_PenaltyCalculationFrequencyDays == null) _PenaltyCalculationFrequencyDays = 0; if (_loanPenalty != null) { int numberOfTimesToRunPenalty = (DateTime.Today.Date - _loanPenalty.CreatedDate.Value.Date).Days / _PenaltyCalculationFrequencyDays.Value; if (numberOfTimesToRunPenalty > 0) for (int i = 0; i < numberOfTimesToRunPenalty; i++) { decimal totalPenalty2; try { totalPenalty2 = Loanitem.LoanPenalties.Sum(p => p.PenaltyAmount).Value; } catch (Exception) { totalPenalty2 = 0; } decimal balance2 = Loanitem.Amount.Value + totalPenalty2 - Loanitem.Repayments.Sum(r => r.RepaymentAmount).Value; decimal penaltyInsterst2 = (cProfile.DefaultersInteresty.Value / 100) * balance2; LoanPenalty _newLoanPenalty = new LoanPenalty(); _newLoanPenalty.CreatedDate = DateTime.Now; _newLoanPenalty.LoanID = Loanitem.LoanID; _newLoanPenalty.PenaltyAmount = penaltyInsterst2; _newLoanPenalty.IsReleived = false; _newLoanPenalty.PenaltyRate = cProfile.DefaultersInteresty.Value; dataContext.LoanPenalties.InsertOnSubmit(_newLoanPenalty); //audit Utils.logAction("Insert", _newLoanPenalty); } } else { //get the number of days between the lastRundate and today. int numberOfTimesToRunPenalty = (DateTime.Today.Date - cProfile.EndOfDayLastRunDate.Value).Days / _PenaltyCalculationFrequencyDays.Value; if (numberOfTimesToRunPenalty > 0) for (int i = 0; i < numberOfTimesToRunPenalty; i++) { decimal totalPenalty2 = 0; decimal balance2 = Loanitem.Amount.Value + totalPenalty2 - Loanitem.Repayments.Sum(r => r.RepaymentAmount).Value; decimal penaltyInsterst2 = (cProfile.DefaultersInteresty.Value / 100) * balance2; LoanPenalty _newLoanPenalty = new LoanPenalty(); _newLoanPenalty.CreatedDate = DateTime.Now; _newLoanPenalty.LoanID = Loanitem.LoanID; _newLoanPenalty.PenaltyAmount = penaltyInsterst2; _newLoanPenalty.IsReleived = false; _newLoanPenalty.PenaltyRate = cProfile.DefaultersInteresty.Value; dataContext.LoanPenalties.InsertOnSubmit(_newLoanPenalty); try { //test if this bit of the code works totalPenalty2 = Loanitem.LoanPenalties.Sum(p => p.PenaltyAmount).Value; } catch (Exception) { totalPenalty2 = 0; } //audit Utils.logAction("Insert", _newLoanPenalty); } } } }
private void InsertCompProfIntoDb(CompanyProfile pro) { string pathToDatabase = ((GlobalvarsApp)CallingActivity.Application).DATABASE_PATH; if (pro.CompanyName == "SUSPENDED") return; try{ AccessRights rights= DataHelper.InsertCompProfIntoDb (pro, pathToDatabase); ((GlobalvarsApp)CallingActivity.Application).EnableGPSTracking(rights); } catch(Exception ex) { AlertShow (ex.Message + ex.StackTrace); } //DownloadAllhandle.Invoke(CallingActivity,0,"Successfully downloaded Profile."); startDownloadRunNoInfo (); }