protected void gvAtasan_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Detail") { string URL = "~/newFormRequestDetailClaim.aspx?encrypt=" + Encrypto.Encrypt(e.CommandArgument.ToString()); URL = Page.ResolveClientUrl(URL); ScriptManager.RegisterStartupScript(this, GetType(), "openDetail", "openDetail('" + URL + "');", true); } if (e.CommandName == "Approve") { lblMessage.Text = claimApproval.ChangeStatus(e.CommandArgument.ToString(), e.CommandName, karyawan.nrp, "Atasan"); lblMessage.Visible = true; } if (e.CommandName == "Reject") { lblMessage.Text = claimApproval.ChangeStatus(e.CommandArgument.ToString(), e.CommandName, karyawan.nrp, "Atasan"); lblMessage.Visible = true; } if (e.CommandName != "Detail") { BindAtasan(); } }
protected void gvViewSPDTujuan_RowCommand(object sender, GridViewCommandEventArgs e) { lblMessageTujuan.Visible = false; switch (e.CommandName) { case "Detail": string URL = "~/newFormRequestDetail.aspx?encrypt=" + Encrypto.Encrypt(e.CommandArgument.ToString()); URL = Page.ResolveClientUrl(URL); ScriptManager.RegisterStartupScript(this, GetType(), "openDetail", "openDetail('" + URL + "');", true); break; case "Approve": lblMessageTujuan.Text = approvalSPDUrl.ChangeStatus(e.CommandArgument.ToString(), e.CommandName, karyawan.nrp, string.Empty); break; case "Reject": lblMessageTujuan.Text = approvalSPDUrl.ChangeStatus(e.CommandArgument.ToString(), e.CommandName, karyawan.nrp, string.Empty); break; default: break; } lblMessageTujuan.Visible = true; bindFindTujuan(); }
protected void btnDetail_Click(object sender, EventArgs e) { string URL = "~/newFormRequestDetail.aspx?encrypt=" + Encrypto.Encrypt(Session["noSPD"].ToString()); URL = Page.ResolveClientUrl(URL); ScriptManager.RegisterStartupScript(this, GetType(), "openDetail", "openDetail('" + URL + "');", true); }
protected void Page_Load(object sender, EventArgs e) { if (Session["IDLogin"] == null) { Response.Redirect("frmHome.aspx"); } string noSPD = Encrypto.Decrypt(Request.QueryString["encrypt"]); Id.Value = noSPD; strID = (string)Session["IDLogin"]; karyawan = oSPD.getKaryawan(strID); Session["nrpLogin"] = karyawan.nrp; if (string.IsNullOrEmpty(karyawan.nrp)) { Response.Redirect("frmHome.aspx"); } using (var ctx = new dsSPDDataContext()) { var spd = ctx.trSPDs.FirstOrDefault(o => o.noSPD == Id.Value); // jika sekertaris if ((spd.dibuatOleh == karyawan.nrp && spd.isSubmit != true) || (isSec(karyawan.nrp, spd.nrp) && spd.isSubmit != true)) { btnSubmit.Visible = true; } } }
public void ProcessRequest(HttpContext context) { string NoSPD = Encrypto.Decrypt(context.Request["sCrypt"]); string EmailAppproval = Encrypto.Decrypt(context.Request["eCrypt"]); string NrpApproval = Encrypto.Decrypt(context.Request["nCrypt"]); string Action = Encrypto.Decrypt(context.Request["Action"]); context.Response.ContentType = "text/plain"; context.Response.Write(ChangeStatus(NoSPD, Action, NrpApproval)); }
protected void gvViewSPDGA_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Detail") { string URL = "~/newFormRequestDetail.aspx?encrypt=" + Encrypto.Encrypt(e.CommandArgument.ToString()); URL = Page.ResolveClientUrl(URL); ScriptManager.RegisterStartupScript(this, GetType(), "openDetail", "openDetail('" + URL + "');", true); } if (e.CommandName == "Cancel") { lblMessageGA.Text = approvalSPDUrl.ChangeStatus(e.CommandArgument.ToString(), e.CommandName, karyawan.nrp, string.Empty); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["IDLogin"] == null) { Response.Redirect("frmHome.aspx"); } string noSPD = Encrypto.Decrypt(Request.QueryString["encrypt"]); Id.Value = noSPD; if (true) { } }
protected void gvViewSPD_RowCommand(object sender, GridViewCommandEventArgs e) { try { lblMessage.Visible = false; string[] command = e.CommandArgument.ToString().Split(';'); ViewState["NoSPD"] = command[0]; //split parameter nospd, nrpapproval, index switch (e.CommandName) { case "Detail": string URL = "~/newFormRequestDetail.aspx?encrypt=" + Encrypto.Encrypt(e.CommandArgument.ToString()); URL = Page.ResolveClientUrl(URL); ScriptManager.RegisterStartupScript(this, GetType(), "openDetail", "openDetail('" + URL + "');", true); break; case "Approve": lblMessage.Text = approvalSPDUrl.ChangeStatus(command[0], e.CommandName, command[1], command[2]); break; case "Reject": lblMessage.Text = approvalSPDUrl.ChangeStatus(command[0], e.CommandName, command[1], command[2]); break; default: break; } lblMessage.Visible = true; bindFind(); } catch (Exception ex) { LogError.Log_Error(ex, "copy file request", ViewState["NoSPD"].ToString()); } }
//==================== add agung ============================ public string GenerateText(string nospd, dsSPDDataContext dc) { try { var data = dc.trSPDs.FirstOrDefault(o => o.noSPD == nospd); string approvalDay = DateTime.Now.Day.ToString(); string approvalMonth = DateTime.Now.Month.ToString(); string approvalYear = DateTime.Now.Year.ToString(); string _NoSpd = data.noSPD; string _Status = "R"; string _approvaltgl = approvalDay + "." + approvalMonth + "." + approvalYear; string _NRP = data.nrp; string _NamaLengkap = data.namaLengkap; string _CostCenter = string.Empty; if (data.costCenter.Split('-').Count() > 0) { _CostCenter = data.costCenter.Split('-')[0]; } else { _CostCenter = data.costCenter; } string _UangMakan = "0"; string _UangSaku = "0"; string _Tiket = "0"; string _Hotel = "0"; string _Laundry = "0"; string _Komunikasi = "0"; string _AirPortTax = "0"; string _BBM = "0"; string _Tol = "0"; string _Taxi = "0"; string _Parkir = "0"; string _Biayalainlain = "0"; string _UangMuka = data.uangMuka.ToString(); string message = ""; message += _NoSpd.Trim() + "|"; message += _Status.Trim() + "|"; message += _approvaltgl.Trim() + "|"; message += _NRP.Trim() + "|"; message += _NamaLengkap.Trim() + "|"; message += _CostCenter.Trim() + "|"; message += _UangMakan.Trim() + "|"; message += _UangSaku.Trim() + "|"; message += _Tiket.Trim() + "|"; message += _Hotel.Trim() + "|"; message += _Laundry.Trim() + "|"; message += _Komunikasi.Trim() + "|"; message += _AirPortTax.Trim() + "|"; message += _BBM.Trim() + "|"; message += _Tol.Trim() + "|"; message += _Taxi.Trim() + "|"; message += _Parkir.Trim() + "|"; message += _Biayalainlain.Trim() + "|"; message += _UangMuka.Trim(); //message += data.tglBerangkat.Day + "." + data.tglBerangkat.Month + "." + data.tglBerangkat.Year + "|"; //message += data.tglKembali.Day + "." + data.tglKembali.Month + "." + data.tglKembali.Year; string day = DateTime.Now.Day.ToString(); string bulan = DateTime.Now.Month.ToString(); string tahun = DateTime.Now.Year.ToString(); string jam = DateTime.Now.Hour.ToString(); string menit = DateTime.Now.Minute.ToString(); string detik = DateTime.Now.Second.ToString(); string milSecond = DateTime.Now.Millisecond.ToString(); string tanggal = day + bulan + tahun + "-" + jam + menit + detik + "-" + milSecond; string fileName = "espd-request" + "_" + tanggal + ".txt"; string _User = Encrypto.Decrypt(ConfigurationManager.AppSettings["Username"]); string _Pass = Encrypto.Decrypt(ConfigurationManager.AppSettings["Password"]); string _Domain = Encrypto.Decrypt(ConfigurationManager.AppSettings["Domain"]); string _PathSource = ConfigurationManager.AppSettings["GenerateText"]; string _PathGenerateReq = ConfigurationManager.AppSettings["PathGenerateReq"]; string _BackupReq = ConfigurationManager.AppSettings["BackupReq"]; string filePath = string.Format("{0}\\{1}", _PathSource, fileName); using (StreamWriter writer = new StreamWriter(filePath, true)) { writer.WriteLine(message); writer.Close(); } string sourceFile = _PathSource + fileName; string backUpFile = _BackupReq + fileName; string destinationFile = _PathGenerateReq + fileName; bool ExistsFile = false; using (new Impersonator(_User, _Domain, _Pass)) { File.Copy(sourceFile, destinationFile); if (File.Exists(destinationFile)) { ExistsFile = true; } } if (ExistsFile == true) { File.Move(sourceFile, backUpFile); ExistsFile = false; } using (new Impersonator(_User, _Domain, _Pass)) { string _PathSapResp = ConfigurationManager.AppSettings["PathSapResp"]; string _PathArchiveSapResp = ConfigurationManager.AppSettings["PathArchiveSapResp"]; List <ListGenerateTextModel> textList = new List <ListGenerateTextModel>(); for (int i = 0; i <= 2; i++) { foreach (string file in Directory.EnumerateFiles(_PathSapResp, "*.txt")) { string contents = File.ReadAllText(file); List <string> cols = contents.Split(new char[] { '|' }).ToList(); List <string> fileNameList = file.Split(new char[] { '\\' }).ToList(); List <string> textName = fileNameList.LastOrDefault().Split(new char[] { '_' }).ToList(); string tgl = textName.LastOrDefault().Remove(textName.LastOrDefault().Length - 4, 4); var fileDate = DateTime.ParseExact(tgl, "yyyyMMdd-HHmmss-fff", CultureInfo.InvariantCulture); string noSPD = cols[0]; string type = cols[1]; string messageBPH = cols.LastOrDefault(); List <string> errorBPHUMs = messageBPH.Split(new char[] { ' ' }).ToList(); string bphNo = errorBPHUMs[4].ToString(); textList.Add(new ListGenerateTextModel() { NoSPD = noSPD, NamaFile = Path.GetFileName(file), Type = type, Tanggal = fileDate, Message = messageBPH, BPH = bphNo, FilePath = file }); #region command gak kepake //if (noSPD == data.noSPD && type == "R") //{ // string errorBPHUM = cols.LastOrDefault(); // string respMessage = string.Empty; // if (!errorBPHUM.ToLower().Contains("successfully")) // { // data.errorBPHUM = errorBPHUM; // respMessage = errorBPHUM; // } // else // { // data.status = "SPD Menunggu approval tujuan"; // List<string> errorBPHUMs = errorBPHUM.Split(new char[] { ' ' }).ToList(); // data.errorBPHUM = errorBPHUM; // data.BPHUM = errorBPHUMs[4].ToString(); // respMessage = "success"; // } // dc.SubmitChanges(); // fileName = Path.GetFileName(file); // string archiveSapRespFile = _PathArchiveSapResp + fileName; // File.Move(file, archiveSapRespFile); // return respMessage; //} #endregion } var dataListText = textList .Where(m => m.NoSPD.Contains(data.noSPD)) .Where(m => m.Type.Contains("R")) .OrderByDescending(m => m.Tanggal) .Select(m => new { m.NamaFile, m.FilePath, m.Message, m.BPH, m.Tanggal }).ToList(); if (dataListText.Count > 0) { string respMessage = string.Empty; if (!dataListText[0].Message.ToLower().Contains("successfully")) { data.errorBPHUM = dataListText[0].Message; respMessage = dataListText[0].Message; } else { data.status = "SPD Menunggu approval tujuan"; data.errorBPHUM = dataListText[0].Message; data.BPHUM = dataListText[0].BPH; respMessage = "success"; } dc.SubmitChanges(); foreach (var fileMove in dataListText) { string archiveSapRespFile = _PathArchiveSapResp + fileMove.NamaFile; File.Move(fileMove.FilePath, archiveSapRespFile); } return(respMessage); } Thread.Sleep(5000); } return("File SAP tidak ditemukan, silahkan mencoba kembali."); } } catch (Exception ex) { //EmailCore.InformasiGenerateUangMukaFailed(dataSpd.dibuatOleh, dataSpd.noSPD, dataSpd); return(ex.Message); } }
protected void btnTry_Click(object sender, EventArgs e) { lblHasil.Text = string.Empty; using (var ctx = new dsSPDDataContext()) { // ngga bis diembed ke template jadi manual var spd = (from p in ctx.trSPDs where (p.tglBerangkat.Date - DateTime.Now.Date).Days >= 0 && p.isSubmit == true && p.isCancel == null && p.isApproved == null select p).ToList(); var nospd = (from p in spd select p.noSPD).Distinct(); var approval = (from p in ctx.ApprovalStatus where nospd.Contains(p.NoSPD) && p.Status == null group p by p.NoSPD into groups select groups.OrderBy(p => p.IndexLevel).First()).ToList(); var nrpApproval = (from p in approval group p by p.NrpApproval into groups select groups.OrderBy(p => p.IndexLevel).First().NrpApproval).Distinct().ToList(); foreach (var item in nrpApproval) { var nama = approval.FirstOrDefault(o => o.NrpApproval == item).Nama; var datatoSend = (from p in approval join o in spd on p.NoSPD equals o.noSPD where p.NrpApproval == item select new Outstanding { NoSPD = o.noSPD, Nama = o.namaLengkap, TglBerangkat = o.tglBerangkat, Keperluan = o.msKeperluan.keperluan + " - " + o.ketKeperluan + " - " + o.keperluanLain }).ToList(); if (datatoSend.Count != 0 || datatoSend != null) { using (var smtpClient = new SmtpClient()) { string data = string.Empty; string trtd = string.Empty; foreach (var detail in datatoSend.OrderBy(o => o.TglBerangkat.Date)) { string urlExternal = "http://118.97.80.12/SPD/" + "newFormRequestDetail.aspx?encrypt=" + Encrypto.Encrypt(detail.NoSPD); string urlInternal = "http://trac39/SPD/" + "newFormRequestDetail.aspx?encrypt=" + Encrypto.Encrypt(detail.NoSPD); trtd += "<tr style='border:1px solid #eee;'>" + "<td style='border:1px solid #dedede;padding:5px;'>" + detail.NoSPD + "</td>" + "<td style='border:1px solid #dedede;padding:5px;'>" + detail.Nama + "</td>" + "<td style='border:1px solid #dedede;padding:5px;'>" + detail.Keperluan + "</td>" + "<td style='border:1px solid #dedede;padding:5px;'>" + detail.TglBerangkat.ToString("dd MMMM yyyy") + " <b>(H-" + (detail.TglBerangkat.Date - DateTime.Now.Date).Days.ToString() + ")</b></td>" + "<td style='border:1px solid #dedede;padding:5px;'><a href='" + urlInternal + "'>Internal</a> | <a href='" + urlExternal + "'>External</a></td>" + "</tr>"; } data += "<h4 style='color: #1b809e; border-bottom: 1px solid #eee;'>Kepada Yth " + nama + "</h4>" + "<br/>Berikut adalah data Approval yang masih outstanding per tanggal " + DateTime.Now.ToString("dd MMMM yyyy") + "<br/><br/>" + "<table style='border-color: #eee;border-collapse: collapse;border-width: 1px;color: #333333;'>" + "<tr style='border-width: 1px;padding: 8px;border-style: solid;border-color: #eee;background-color: #dedede;'>" + "<th style='border:1px solid #fff;padding:5px;'>No</th>" + "<th style='border:1px solid #fff;padding:5px;'>Nama</th>" + "<th style='border:1px solid #fff;padding:5px;'>Keperluan</th>" + "<th style='border:1px solid #fff;padding:5px;'>Tgl Berangkat</th>" + "<th style='border:1px solid #fff;padding:5px;'>#</th>" + "</tr>" + trtd + "</table><br/><br/><br/>" + "Terima kasih. <br/>" + "Catatan : Internal (jika berada dikantor) dan External (jika berada diluar kantor)<br/>" + "<span style='color: #FF0000'><b>E-mail ini dikirim otomatis oleh Sistem Pembuatan SPD.Tidak perlu membalas E-mail ini</b></span>"; SmtpSection section = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp"); MailMessage message = new MailMessage { Sender = new MailAddress(section.From), // on Behave of When From differs From = new MailAddress(section.From), Subject = "Outstanding Approval SPD " + DateTime.Now.Date.ToString("dd MMMM yyyy"), Body = data, IsBodyHtml = true, }; var getEmail = approval.FirstOrDefault(o => o.NrpApproval == item); string email = string.Empty; email = getEmail != null ? getEmail.Email : string.Empty; if (!string.IsNullOrEmpty(email)) { message.To.Add("*****@*****.**"); smtpClient.Send(message); } HasilEmail++; lblHasil.Text += HasilEmail.ToString() + " " + data + "<b/><hr/><br/>"; } } } } lblHasil.Text += "<br/>" + HasilEmail.ToString(); // }