public HttpResponseMessage GetAllowDomainByCompanyId(int id) { RedisKey cacheKey = "company_" + id + "_allowDomain"; string cacheValue = null; if (Global._enableRedisCache) { cacheValue = RedisCacheHelper.GetValueByKey(cacheKey); } if (cacheValue == null) { CompanyModel companyModel = new Models.CompanyModel(); try { CompanyModel.Format_Detail company = companyModel.GetById(id); //RedisCacheHelper.SetKeyValue(cacheKey, new JavaScriptSerializer().Serialize(company)); return(Request.CreateResponse(HttpStatusCode.OK, company.AllowDomain)); } catch (CDSException cdsEx) { return(Request.CreateResponse(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId))); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex)); } } else { return(Request.CreateResponse(HttpStatusCode.OK, JsonConvert.DeserializeObject <CompanyModel.Format_Detail>(cacheValue).AllowDomain)); } }
public IActionResult GetStamp() { try { string url = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).LocalPath) + @"\Assets\stamp.jpg"; Bitmap bm = new Bitmap(url); MemoryStream memoryStream = new MemoryStream(); bm.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] byteArray = memoryStream.GetBuffer(); Models.CompanyModel companyModel = new Models.CompanyModel() { Stamp = byteArray, StampBitmap = bm, CompanyName = "Tuloc technology", LocalURL = url }; return(Ok(companyModel)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public ActionResult Save(Models.CompanyModel data) { if (!ModelState.IsValid) { if (data.corp_id == 0) { _db = new QSoft_WUEntities(); DAL.Corp code = _db.Corp.Where(p => p.ccode == data.ccode).FirstOrDefault(); if (code != null) { return(Json(false, JsonRequestBehavior.AllowGet)); } else { System.Web.HttpContext.Current.Application.Lock(); _db = new QSoft_WUEntities(); _db.Corp.Add(new DAL.Corp { corp_id = data.corp_id, ccode = data.ccode, cname1 = data.cname1, cname11 = data.cname11, cname2 = data.cname2, cname21 = data.cname21, caddress1 = data.caddress1, caddress2 = data.caddress2, czip = data.czip, ctel = data.ctel, cfax = data.cfax, taxid = data.taxid, number1 = data.number1, number2 = data.number2, number3 = data.number3, number4 = data.number4, number5 = data.number5, number6 = data.number6, number7 = data.number7, number8 = data.number8, decimal1 = data.decimal1, decimal2 = data.decimal2, decimal3 = data.decimal3, decimal4 = data.decimal4, decimal5 = data.decimal5, decimal6 = data.decimal6, decimal7 = data.decimal7, decimal8 = data.decimal8, stockcount = data.stockcount }); _db.SaveChanges(); System.Web.HttpContext.Current.Application.UnLock(); return(Json(true, JsonRequestBehavior.AllowGet)); } } } if (data.corp_id != 0) { _db = new QSoft_WUEntities(); DAL.Corp code = _db.Corp.Where(p => p.ccode == data.ccode && p.corp_id != data.corp_id).FirstOrDefault(); if (code != null) { return(Json(false, JsonRequestBehavior.AllowGet)); } else { DAL.Corp edit = _db.Corp.Where(p => p.corp_id == data.corp_id).FirstOrDefault(); edit.corp_id = data.corp_id; edit.ccode = data.ccode; edit.cname1 = data.cname1; edit.cname11 = data.cname11; edit.cname2 = data.cname2; edit.cname21 = data.cname21; edit.caddress1 = data.caddress1; edit.caddress2 = data.caddress2; edit.czip = data.czip; edit.ctel = data.ctel; edit.cfax = data.cfax; edit.taxid = data.taxid; edit.number1 = data.number1; edit.number2 = data.number2; edit.number3 = data.number3; edit.number4 = data.number4; edit.number5 = data.number5; edit.number6 = data.number6; edit.number7 = data.number7; edit.number8 = data.number8; edit.decimal1 = data.decimal1; edit.decimal2 = data.decimal2; edit.decimal3 = data.decimal3; edit.decimal4 = data.decimal4; edit.decimal5 = data.decimal5; edit.decimal6 = data.decimal6; edit.decimal7 = data.decimal7; edit.decimal8 = data.decimal8; edit.stockcount = data.stockcount; _db.SaveChanges(); return(Json(true, JsonRequestBehavior.AllowGet)); } } return(View(data)); }
public void CompanyFileImport(HttpPostedFileBase companyExcelFile) { string ExcuteMsg = string.Empty; int NumberOfColume = 0; try { //HttpPostedFileBase file = Request.Files["ProductExcel"]; HttpPostedFileBase file = companyExcelFile; //Extaintion Check if (companyExcelFile.FileName.EndsWith("xls") || file.FileName.EndsWith("xlsx") || file.FileName.EndsWith("XLS") || file.FileName.EndsWith("XLSX")) { //Null Exp Check if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName)) { string fileName = file.FileName; string fileContentType = file.ContentType; byte[] fileBytes = new byte[file.ContentLength]; var data = file.InputStream.Read(fileBytes, 0, Convert.ToInt32(file.ContentLength)); List <CompanyImportModel> companyImportList = new List <CompanyImportModel>(); using (var package = new ExcelPackage(file.InputStream)) { var currentSheet = package.Workbook.Worksheets; var workSheet = currentSheet.First(); var noOfCol = workSheet.Dimension.End.Column; var noOfRow = workSheet.Dimension.End.Row; for (int rowIterator = 2; rowIterator <= noOfRow; rowIterator++) { if (workSheet.Cells[rowIterator, 2].Value != null && workSheet.Cells[rowIterator, 4].Value != null) { CompanyImportModel companyModel = new CompanyImportModel(); companyModel.Name = workSheet.Cells[rowIterator, 2].Value == null ? null : workSheet.Cells[rowIterator, 2].Value.ToString(); companyModel.MotherCompany = workSheet.Cells[rowIterator, 3].Value == null ? null : workSheet.Cells[rowIterator, 3].Value.ToString(); companyModel.Address = workSheet.Cells[rowIterator, 4].Value == null ? null : workSheet.Cells[rowIterator, 4].Value.ToString(); companyModel.Phone = workSheet.Cells[rowIterator, 5].Value == null ? null : workSheet.Cells[rowIterator, 5].Value.ToString(); companyModel.Fax = workSheet.Cells[rowIterator, 6].Value == null ? null : workSheet.Cells[rowIterator, 6].Value.ToString(); companyModel.Email = workSheet.Cells[rowIterator, 7].Value == null ? null : workSheet.Cells[rowIterator, 7].Value.ToString(); companyModel.ContactPerson = workSheet.Cells[rowIterator, 8].Value == null ? null : workSheet.Cells[rowIterator, 8].Value.ToString(); companyModel.ContactPersonEmail = workSheet.Cells[rowIterator, 9].Value == null ? null : workSheet.Cells[rowIterator, 9].Value.ToString(); companyModel.ContactPersonPhone = workSheet.Cells[rowIterator, 10].Value == null ? null : workSheet.Cells[rowIterator, 10].Value.ToString(); companyModel.FiscalYearStart = Convert.ToDateTime(workSheet.Cells[rowIterator, 11].Value); companyImportList.Add(companyModel); } } } //List data saving if (companyImportList.Count > 0) { foreach (var item in companyImportList) { //item.companyImportList(); if (!string.IsNullOrEmpty(item.MotherCompany)) { var company = new Models.CompanyModel().GetAllCompanies().SingleOrDefault(x => x.IsDelete == false && x.Name.ToLower() == item.MotherCompany.ToLower()); if (company != null) { item.MotherCompanyId = company.Id; } } _companyManagementService.AddCompany(item.Name, item.MotherCompanyId, item.Address, item.Phone, item.Fax, item.Email, item.ContactPerson, item.ContactPersonEmail, item.ContactPersonPhone, item.FiscalYearStart); } } } } } catch (Exception r) { ExcuteMsg = r.Message; } }
// GET: Admin/Company public ActionResult Index() { var companies = new Models.CompanyModel().GetAllCompanies().Where(x => x.IsDelete == false); return(View(companies)); }