コード例 #1
0
ファイル: EmailCore.cs プロジェクト: azanM/ESPD
 public static void InformasiSPDExpired(string nrp, string nospd, trSPD dataSpd)
 {
     EmailCore.sendEmailNew(
         nrp,
         "Batas Claim " + nospd + " : " + (dataSpd.tglExpired.Value.AddDays(-1).ToString("dd MMMM yyyy")),
         "NotifExpired.txt",
         dataSpd,
         string.Empty,
         string.Empty,
         "ApprovalSPDUrl",
         string.Empty
         );
 }
コード例 #2
0
ファイル: EmailCore.cs プロジェクト: azanM/ESPD
 public static void InformasiClaim(string nrp, string nospd, trSPD dataSpd, string statusClaim)
 {
     EmailCore.sendEmailNew(
         nrp,
         "Informasi Claim " + nospd,
         "InformasiClaim.txt",
         dataSpd,
         string.Empty,
         statusClaim,
         "ClaimApprovalUrl",
         string.Empty
         );
 }
コード例 #3
0
ファイル: EmailCore.cs プロジェクト: azanM/ESPD
 public static void InformasiPencarianTiket(string nrp, string nospd, trSPD dataSpd)
 {
     EmailCore.sendEmailNew(
         nrp,
         "Informasi pencarian tiket " + nospd,
         "InformasiPencarianTiket.txt",
         dataSpd,
         string.Empty,
         string.Empty,
         "ApprovalSPDUrl",
         string.Empty
         );
 }
コード例 #4
0
ファイル: EmailCore.cs プロジェクト: azanM/ESPD
 public static void InformasiSPD(string nrp, string nospd, trSPD dataSpd)
 {
     EmailCore.sendEmailNew(
         nrp,
         "Informasi SPD " + nospd,
         "InformasiSPD.txt",
         dataSpd,
         string.Empty,
         string.Empty,
         "ApprovalSPDUrl",
         string.Empty
         );
 }
コード例 #5
0
ファイル: EmailCore.cs プロジェクト: azanM/ESPD
 public static void ApprovalClaim(string nrpApproval, string nospd, trSPD dataSpd, string AtasanGAFinance, string statusClaim)
 {
     EmailCore.sendEmailNew(
         nrpApproval,
         "Approval Claim " + nospd,
         "ApprovalClaim.txt",
         dataSpd,
         AtasanGAFinance,
         statusClaim,
         "ClaimApprovalUrl",
         string.Empty
         );
 }
コード例 #6
0
ファイル: EmailCore.cs プロジェクト: azanM/ESPD
        //spd

        public static void ApprovalSPD(string nrpApproval, string nospd, string index, trSPD dataSPD)
        {
            EmailCore.sendEmailNew(
                nrpApproval,
                "Approval " + nospd,
                "ApprovalSPD.txt",
                dataSPD,
                string.Empty,
                string.Empty,
                "ApprovalSPDUrl",
                index
                );
        }
コード例 #7
0
ファイル: EmailCore.cs プロジェクト: azanM/ESPD
        public static void sendEmailNew(
            string nrpApproval,
            string subject,
            string tamplate,
            trSPD spd,
            string claimApprove,
            string statusClaim,
            string urltarget,
            string indexLevel)
        {
            using (dsSPDDataContext ctx = new dsSPDDataContext())
            {
                //informasi approver
                var approval = ctx.msKaryawans.FirstOrDefault(o => o.nrp == nrpApproval);

                //informasi requestor
                var karyawan = ctx.msKaryawans.FirstOrDefault(o => o.nrp == spd.nrp);

                var informasiApproval = ctx.ApprovalStatus.Where(o => o.NoSPD == spd.noSPD);

                string trtd = string.Empty;

                foreach (var item in informasiApproval.OrderBy(o => o.IndexLevel))
                {
                    string statusApp = "Belum diapprove";

                    if (item.Status != null)
                    {
                        if (item.Status.Value == true)
                        {
                            statusApp = "Approved";
                        }
                        else
                        {
                            statusApp = "Rejected";
                        }
                    }
                    ;

                    var modifiedDate = item.ModifiedDate != null?item.ModifiedDate.Value.ToString("dd MMMM yyyy HH:mm") : "-";

                    trtd +=
                        "<tr>" +
                        "<td>" + item.IndexLevel.ToString() + "</td>" +
                        "<td>" + item.ApprovalRule.Deskripsi + "</td>" +
                        "<td>" + item.Nama + "</td>" +
                        "<td>" + modifiedDate + "</td>" +
                        "<td>" + statusApp + "</td>" +
                        "</tr>";
                }
                ;

                var tamplatesSPD = "<table><tr><th>No</th><th colspan='3' style='text-align:center;'>Detail Data</th><th>Status</th></tr>" + trtd + "</table>";

                EspdEmail espdEmail = new EspdEmail();

                //encrypt nrp
                espdEmail.nCrypt = Encrypto.Encrypt(nrpApproval);

                //encrypt email
                string toAddress = "";
                if (spd.nrp.Equals("99999999"))
                {
                    espdEmail.eCrypt = Encrypto.Encrypt(string.IsNullOrEmpty(spd.email) ? "" : spd.email);
                    if (tamplate.ToLower().Contains("informasi") || tamplate.ToLower().Contains("notifexpired"))
                    {
                        toAddress = string.IsNullOrEmpty(spd.email) ? "" : spd.email;
                    }
                    else
                    {
                        toAddress = approval.EMail;
                    }
                }

                //
                //
                else
                {
                    espdEmail.eCrypt = Encrypto.Encrypt(approval.EMail);
                    toAddress        = approval.EMail;
                }

                //encrypt nospd
                espdEmail.sCrypt = Encrypto.Encrypt(spd.noSPD);

                espdEmail.NoSPD        = spd.noSPD;
                espdEmail.approverName = approval.namaLengkap;

                espdEmail.spdRequester         = spd.namaLengkap;
                espdEmail.nrpRequester         = spd.nrp;
                espdEmail.statusName           = (string.IsNullOrEmpty(statusClaim) == true ? spd.status : statusClaim);
                espdEmail.noHp                 = spd.NoHP;
                espdEmail.golongan             = spd.idGolongan;
                espdEmail.jabatan              = spd.jabatan;
                espdEmail.organisasiUnit       = karyawan.organisasiUnit;
                espdEmail.companyCode          = karyawan.companyCode;
                espdEmail.personalArea         = karyawan.personelArea;
                espdEmail.personelSubArea      = karyawan.pSubArea;
                espdEmail.costCenterPembebanan = spd.costCenter;
                espdEmail.tempatTujuan         = !string.IsNullOrEmpty(spd.tempatTujuanLain) ? spd.Tujuan + " - " + spd.tempatTujuanLain : spd.Tujuan + " - " + spd.companyCodeTujuan + " - " + spd.personelAreaTujuan + " - " + spd.pSubAreaTujuan;
                espdEmail.keperluan            = spd.msKeperluan.keperluan + " - " + spd.ketKeperluan;
                espdEmail.tanggalBerangkat     = spd.tglBerangkat.ToString("dd MMMM yyyy");
                espdEmail.jamBerangkat         = spd.jamBerangkat;
                espdEmail.menitBerangkat       = spd.menitBerangkat;
                espdEmail.tanggalKembali       = spd.tglKembali.ToString("dd MMMM yyyy");
                espdEmail.jamKembali           = spd.jamKembali;
                espdEmail.menitKembali         = spd.menitKembali;
                espdEmail.angkutan             = spd.idAngkutan != null ? spd.msAngkutan.nama : spd.angkutanLain;
                espdEmail.hotel                = spd.penginapan;

                espdEmail.spdStatusList = tamplatesSPD;

                espdEmail.claimApprove = claimApprove;
                espdEmail.alasan       = spd.Alasan;
                string sqlFormattedDate = spd.tglExpired.HasValue
                ? spd.tglExpired.Value.ToString("dd MMMM yyyy")
                : "<not available>";

                espdEmail.tglExpired = sqlFormattedDate;
                espdEmail.uangMuka   = spd.uangMuka;
                espdEmail.BPHUM      = spd.BPHUM;
                try
                {
                    TimeSpan Jumlahhari = spd.tglKembali - spd.tglBerangkat;
                    TimeSpan tambahan   = TimeSpan.FromDays(1);
                    Jumlahhari         += tambahan;
                    espdEmail.totalDays = Jumlahhari.Days.ToString();
                }
                catch (Exception)
                {
                    espdEmail.totalDays = "Undetected";
                }


                if (urltarget.ToLower().Contains("claim"))
                {
                    var dc = ctx.trClaims.FirstOrDefault(o => o.noSPD == spd.noSPD);
                    #region claim
                    var uangmuka = (string.IsNullOrEmpty(spd.uangMuka) ? 0 : int.Parse(spd.uangMuka));
                    espdEmail.CbiayaMakan = dc.biayaMakan.ToString("#,###");
                    espdEmail.CuangSaku   = dc.uangSaku.ToString("#,###");
                    espdEmail.Ctiket      = dc.tiket.ToString("#,###");
                    espdEmail.Chotel      = dc.hotel.ToString("#,###");
                    espdEmail.CBBM        = dc.BBM.ToString("#,###");
                    espdEmail.Ctol        = dc.tol.ToString("#,###");
                    espdEmail.Ctaxi       = dc.taxi.ToString("#,###");
                    espdEmail.CairportTax = dc.airportTax.ToString("#,###");
                    espdEmail.Claundry    = dc.laundry.ToString("#,###");
                    espdEmail.Cparkir     = dc.parkir.ToString("#,###");
                    espdEmail.Ckomunikasi = dc.komunikasi != null?dc.komunikasi.Value.ToString("#,###") : "";

                    espdEmail.CbiayaLainLain = dc.biayaLainLain.ToString("#,###");
                    espdEmail.CtotalClaim    = dc.total.ToString("#,###");
                    espdEmail.CuangMuka      = uangmuka.ToString("#,###");
                    espdEmail.Cpenyelesaian  = (dc.total - uangmuka).ToString("#,###");
                    espdEmail.CtotalClaim    = dc.total.ToString("#,###");
                    espdEmail.CBPHClaim      = dc.BPHClaim;
                    #endregion
                }

                string urlSource =
                    "?nCrypt=" + espdEmail.nCrypt +
                    "&eCrypt=" + espdEmail.eCrypt +
                    "&sCrypt=" + espdEmail.sCrypt +
                    "&ClaimApprove=" + espdEmail.claimApprove +
                    "&index=" + indexLevel +
                    "&Action=";

                string urlAction         = "http://trac39/SPD/" + urltarget + ".ashx" + urlSource;
                string urlActionExternal = "http://118.97.80.12/SPD/" + urltarget + ".ashx" + urlSource;
                espdEmail.DetailURL      = "http://118.97.80.12/SPD/" + "newFormRequestDetail.aspx?encrypt=" + espdEmail.sCrypt;
                espdEmail.DetailClaimURL = "http://118.97.80.12/SPD/" + "newFormRequestDetailClaim.aspx?encrypt=" + espdEmail.sCrypt;

                espdEmail.ApproveUrl         = urlAction + Encrypto.Encrypt("approve");
                espdEmail.RejectUrl          = urlAction + Encrypto.Encrypt("reject");
                espdEmail.ApproveUrlExternal = urlActionExternal + Encrypto.Encrypt("approve");
                espdEmail.RejectUrlExternal  = urlActionExternal + Encrypto.Encrypt("reject");

                //send to requestor and approval
                string body = EmailCore.PrepareMailBodyWith(tamplate, espdEmail);

                //cc
                string ccAddress = "";
                if (toAddress.ToLower() == "*****@*****.**")
                {
                    ccAddress = "[email protected],[email protected],[email protected]";
                }

                if (toAddress.ToLower() == "*****@*****.**")
                {
                    ccAddress = "*****@*****.**";
                }

                if (toAddress.ToLower() == "*****@*****.**")
                {
                    ccAddress = "[email protected],[email protected]";
                }

                if (toAddress.ToLower() == "*****@*****.**")
                {
                    ccAddress = "*****@*****.**";
                }

                //for date 16-Maret-2015 till 20-Maret-2015
                //for date 20-April-2015 till 25-April-2015
                //for date 18-Mei-2015 till 22-Mei-2015
                //for date 19-September-2015 till the end
                // if (toAddress.ToLower() == "*****@*****.**")
                // {
                // //    //toAddress = "*****@*****.**";
                //     toAddress = "*****@*****.**";

                //}

                string bccAddress = "";

                Helper hp = new Helper();

                if (indexLevel.Contains("1"))
                {
                    bccAddress = "[email protected],";
                    DataSet dsCheckBcc = hp.wsEmail("spd");
                    if (dsCheckBcc.Tables[0].Rows.Count > 0)
                    {
                        DataRow  drCheckBcc = dsCheckBcc.Tables[0].Rows[0];
                        DataView dvCheckBcc = new DataView(dsCheckBcc.Tables[0]);
                        for (int i = 0; i < dvCheckBcc.Count; i++)
                        {
                            bccAddress += drCheckBcc.Table.Rows[i][0].ToString();
                            bccAddress += ",";
                        }
                        bccAddress = bccAddress.Remove(bccAddress.Length - 1);
                    }
                }
                else if (statusClaim.Contains("Menunggu approval atasan"))
                {
                    bccAddress = "[email protected],";
                    DataSet dsCheckBcc = hp.wsEmail("claim");
                    if (dsCheckBcc.Tables[0].Rows.Count > 0)
                    {
                        DataRow  drCheckBcc = dsCheckBcc.Tables[0].Rows[0];
                        DataView dvCheckBcc = new DataView(dsCheckBcc.Tables[0]);
                        for (int i = 0; i < dvCheckBcc.Count; i++)
                        {
                            bccAddress += drCheckBcc.Table.Rows[i][0].ToString();
                            bccAddress += ",";
                        }
                        bccAddress = bccAddress.Remove(bccAddress.Length - 1);
                    }
                }
                else
                {
                    bccAddress = "*****@*****.**";
                }
                //for production try TO DO
                //EmailCore.SendMail(toAddress, ccAddress, bccAddress, subject, body);
                //end for production
            }
        }