public ActionResult _PopulateTPFromFile(HttpPostedFileBase file, int IdTenagaAhliHeader) { bool bolImported = false; int intBarisMulaiData = 0; int intKolomMulaiData = 0; try { intBarisMulaiData = Convert.ToInt16(ConfigurationManager.AppSettings["BarisDataXLS_TP"]); } catch (Exception ex) { } try { intKolomMulaiData = Convert.ToInt16(ConfigurationManager.AppSettings["KolomDataXLS_TP"]); } catch (Exception ex) { } Guid gdPointer = Guid.NewGuid(); //tokenContainer.XLSPointer = gdPointer; if (Request.Files["file"].ContentLength > 0) { string fileExtension = System.IO.Path.GetExtension(Request.Files["file"].FileName); //string strFileName = Request.Files["file"].FileName; string strFileName = gdPointer.ToString() + fileExtension; string fileLocation = Server.MapPath("~/Content/FileUpload/") + strFileName; if (System.IO.File.Exists(fileLocation)) { System.IO.File.Delete(fileLocation); } Request.Files["file"].SaveAs(fileLocation); bolImported = ImportXLSHelper.ImportXLS(3, gdPointer, (Guid)tokenContainer.IdRekananContact, intBarisMulaiData, intKolomMulaiData, strFileName, fileExtension, fileLocation); ViewBag.Message = string.Format("Proses import {0}", "Berhasil"); //populate form header and gid from temp table trxTenagaAhliHeaderForm myDataForm = new trxTenagaAhliHeaderForm(); //populate grid data List <trxTenagaPendukung> myDataList = new List <trxTenagaPendukung>(); HttpResponseMessage responseMessage = client.GetAsync(urlTPTMP + "/GetByGuidHeader/" + gdPointer.ToString()).Result; if (responseMessage.IsSuccessStatusCode) { var responseData = responseMessage.Content.ReadAsStringAsync().Result; myDataList = JsonConvert.DeserializeObject <List <trxTenagaPendukung> >(responseData); } myDataForm.TenagaPendukungColls = myDataList; myDataForm.IdTenagaAhliHeader = IdTenagaAhliHeader; myDataForm.IdTipeTenaga = 3; myDataForm.GuidHeader = gdPointer; myDataForm.IdRekanan = (Guid)tokenContainer.IdRekananContact; ViewBag.GuidHeader = gdPointer; return(View("AddEditTPHeader", myDataForm)); } return(View("Error")); }
public async Task <ActionResult> AddEditTPHeader(trxTenagaAhliHeaderForm myDataForm) { string strXLSPointer = myDataForm.GuidHeader.ToString(); //if (tokenContainer.XLSPointer != null) //{ // strXLSPointer = tokenContainer.XLSPointer.ToString(); //} //pindahkan data temporary import XLS ke fix table berdasarkan XLS pointer guid //string strReqToExecTransData = string.Format("{0}/ExecTransDataTP/{1}/{2}/{3}" // , url, myData.IdTenagaAhliHeader.ToString(), tokenContainer.IdRekananContact.ToString(), strXLSPointer); trxTenagaAhliHeader myData = new trxTenagaAhliHeader(); myData.InjectFrom(myDataForm); string strReqToExecTransData = string.Format("{0}/ExecTransDataTP/{1}", url, strXLSPointer); if (strXLSPointer != string.Empty) { HttpResponseMessage responseMessageXLS = await client.GetAsync(strReqToExecTransData); if (!responseMessageXLS.IsSuccessStatusCode) { return(RedirectToAction("Error")); } } myData.JudulDokumen = string.Format("Diupload tanggal : {0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm")); if (myData.IdTenagaAhliHeader > 0) { HttpResponseMessage responseMessage = await client.PutAsJsonAsync(url + "/" + myData.IdTenagaAhliHeader, myData); if (responseMessage.IsSuccessStatusCode) { return(RedirectToAction("GetByRekanan", "TrxDataOrganisasi")); } return(RedirectToAction("Error")); } else { myData.IdRekanan = (Guid)tokenContainer.IdRekananContact; myData.CreatedDate = DateTime.Today; myData.CreatedUser = tokenContainer.UserId.ToString(); HttpResponseMessage responseMessage = await client.PostAsJsonAsync(url, myData); if (responseMessage.IsSuccessStatusCode) { return(RedirectToAction("GetByRekanan", "TrxDataOrganisasi")); } return(RedirectToAction("Error")); } }
public trxTenagaAhliHeaderForm GetByGuidHeader(Guid guidHeader) { trxTenagaAhliHeaderForm TAHeaderForm = new trxTenagaAhliHeaderForm(); //header //trxTenagaAhliHeader TAHeader = _repository.Get(guidHeader); trxTenagaAhliHeader TAHeader = _repTAhliHeader.GetByGuidHeader(guidHeader); TAHeaderForm.InjectFrom(TAHeader); //tenaga ahli collection TAHeaderForm.TenagaAhliColls = _repTAhli.GetByGuidHeader(guidHeader); //TAHeaderForm.TenagaAhliTTColls = _repTAhli.GetByGuidHeader(guidHeader,2); //tenaga pendukung collection TAHeaderForm.TenagaPendukungColls = _repTPendukung.GetByGuidHeader(guidHeader); return(TAHeaderForm); }
public async Task <ActionResult> AddEditTAHeader(int IdTenagaAhliHeader, Guid GuidHeader, int IdTenaga = -1) { trxTenagaAhliHeaderForm myDataForm = new trxTenagaAhliHeaderForm(); //if (GuidHeader != null && GuidHeader != Guid.Empty && IdTenagaAhliHeader > 0) if (IdTenagaAhliHeader > 0) { HttpResponseMessage responseMessage = await client.GetAsync(url + "/GetByGuidHeader/" + GuidHeader.ToString()); if (responseMessage.IsSuccessStatusCode) { var responseData = responseMessage.Content.ReadAsStringAsync().Result; myDataForm = JsonConvert.DeserializeObject <trxTenagaAhliHeaderForm>(responseData); ViewBag.GuidHeader = GuidHeader; ViewData["GuidHeader"] = GuidHeader; switch (myDataForm.IdTipeTenaga) { case 1: ViewBag.JudulDaftarTenaga = "Data Tenaga Ahli Tetap"; ViewBag.Tetap = true; return(View("AddEditTAHeader", myDataForm)); case 2: ViewBag.JudulDaftarTenaga = "Data Tenaga Ahli Tidak Tetap"; ViewBag.Tetap = false; return(View("AddEditTAHeader", myDataForm)); case 3: ViewBag.JudulDaftarTenaga = "Data Tenaga Pendukung"; return(View("AddEditTPHeader", myDataForm)); default: break; } } } else { myDataForm.IdTenagaAhliHeader = -1; ViewBag.GuidHeader = Guid.Empty; switch (IdTenaga) { case 1: myDataForm.IdTipeTenaga = 1; ViewBag.JudulDaftarTenaga = "Data Tenaga Ahli Tetap"; ViewBag.Tetap = true; return(View("AddEditTAHeader", myDataForm)); case 2: myDataForm.IdTipeTenaga = 2; ViewBag.JudulDaftarTenaga = "Data Tenaga Ahli Tidak Tetap"; ViewBag.Tetap = false; return(View("AddEditTAHeader", myDataForm)); case 3: myDataForm.IdTipeTenaga = 3; ViewBag.JudulDaftarTenaga = "Data Tenaga Pendukung"; return(View("AddEditTPHeader", myDataForm)); default: break; } } return(View("Error")); }