示例#1
0
    protected void btnExport_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            DataTable dt = BLL_LMS_Training.GET_VESSEL_VIDEOS(null);
            dt.DefaultView.RowFilter = "FileName IS NOT NULL";
            DataView dv = dt.DefaultView;

            List <String> lFileList = new List <string>();

            foreach (DataRow item in dv.ToTable().Rows)
            {
                lFileList.Add(item["FileName"].ToString());
            }

            if (lFileList.Count > 0)
            {
                string lDownlodFileName = BLL_LMS_Training.RAR(Server.MapPath("~/Uploads/VesselVideos"), lFileList);
                ResponseHelper.Redirect("~/Uploads/VesselVideos/" + lDownlodFileName, "blank", "");
            }
        }
        catch (Exception)
        {
            string js1 = "alert('Videos Not Found.');";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "showModalJS", js1, true);
            return;
        }

        //string[] HeaderCaptions = { "Module Name", "Original File Name", "New File Name" };
        //string[] DataColumnsName = { "text", "OriginalFileName", "FileName", };

        //GridViewExportUtil.ShowExcel(dv.ToTable(), HeaderCaptions, DataColumnsName, "Vessel_Videos_File_List", "Rename your local files with file names as given below", "");
    }
示例#2
0
    protected void DownloadFiles(object sender, EventArgs e)
    {
        try
        {
            System.IO.StreamWriter excelDoc;
            string hdnRank = hdnCrewRank.Value.ToString();
            hdnRank  = hdnRank.Replace("/", "_");
            hdnRank  = hdnRank.Replace(" ", "_");
            excelDoc = new System.IO.StreamWriter(System.IO.Path.Combine(Server.MapPath("~") + @"\" + "Uploads/Temp/", "CrewDetails_" + hdnRank + "_" + hdnFirstName.Value.ToString().Replace(" ", "_") + "_" + hdnStaffCode.Value.ToString() + ".xls"));

            string data = hdnCrewDetails.Value.ToString();
            data = data.Replace("\"", "'");
            excelDoc.Write(data);
            excelDoc.Close();
            excelDoc.Dispose();

            string        zipFile = "";
            List <string> zips    = new List <string>();
            zips.Add("CrewDetails_" + hdnRank + "_" + hdnFirstName.Value.ToString().Replace(" ", "_") + "_" + hdnStaffCode.Value.ToString() + ".xls");
            foreach (GridViewRow row in grdCrewDoc.Rows)
            {
                if ((row.FindControl("chkSelect") as CheckBox).Checked)
                {
                    string[] args     = ((row.FindControl("lblFilePath") as Label).Text).Split(';');
                    string   filePath = args[0];
                    string   DestPath = Server.MapPath("~") + "\\Uploads\\Temp\\" + UDFLib.ReplaceSpecialCharacter(args[1]) + args[2];
                    File.Copy(filePath, DestPath, true);
                    zips.Add(UDFLib.ReplaceSpecialCharacter(args[1]) + args[2]);
                }
            }

            if (zips.Count > 0)
            {
                zipFile = BLL_LMS_Training.RAR((Server.MapPath("~") + @"\" + "Uploads\\Temp\\"), zips);

                string DownloadFileName = hdnStaffCode.Value.ToString() + "_" + hdnFirstName.Value.ToString().Replace(" ", "_") + "_" + hdnRank + "_" + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + "_" + DateTime.Now.Hour + "h" + DateTime.Now.Minute + "m" + DateTime.Now.Second + "s" + ".rar";
                if (File.Exists(Server.MapPath("~") + @"\" + "Uploads\\Temp\\" + zipFile))
                {
                    File.Move((Server.MapPath("~") + @"\" + "Uploads\\Temp\\" + zipFile), Server.MapPath("~") + @"\" + "Uploads\\Temp\\" + DownloadFileName);

                    ResponseHelper.Redirect("~/Uploads/Temp/" + DownloadFileName, "blank", "");
                }
            }
        }
        catch
        { }
    }
示例#3
0
    protected void btnDownloadSelected_Click(object sender, EventArgs e)
    {
        string msgmodal = "";

        try
        {
            DataTable tablePIDS = new DataTable();
            tablePIDS.Columns.Add("ID", typeof(int));
            DataTable table = new DataTable();
            table.Columns.Add("ID", typeof(string));
            table.Columns.Add("VALUE", typeof(string));
            foreach (GridViewRow row in gvProgram_ListDetails.Rows)
            {
                if (row.RowType != DataControlRowType.Header)
                {
                    CheckBox checkRow      = row.FindControl("checkRow") as CheckBox;
                    TextBox  txtProgramIDS = row.FindControl("txtProgramIDS") as TextBox;


                    if (checkRow.Checked)
                    {
                        List <string> PIDS      = new List <string>();
                        List <string> lPrograms = txtProgramIDS.Text.Split(',').ToList <string>();

                        foreach (string lProgram in lPrograms)
                        {
                            if (!PIDS.Contains(lProgram.Trim()))
                            {
                                if (UDFLib.ConvertIntegerToNull(lProgram.Trim()) != null)
                                {
                                    tablePIDS.Rows.Add(Convert.ToInt32(lProgram.Trim()));
                                    table.Rows.Add(gvProgram_ListDetails.DataKeys[row.RowIndex].Values[0].ToString(), lProgram.Trim());
                                    PIDS.Add(lProgram.Trim());
                                }
                            }
                        }
                    }
                }
            }

            if (tablePIDS.Rows.Count <= 0)
            {
                msgmodal = String.Format("alert('Vessel(s) not selected for downloading training items!.')");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", msgmodal, true);

                return;
            }



            DataSet ds_ProgramList_Scheduled = BLL_LMS_Training.GET_FileList_To_Sync(tablePIDS);

            int           rowindex = 0;
            string        zipFile  = "";
            List <string> zips     = new List <string>();
            foreach (DataRow row in ds_ProgramList_Scheduled.Tables[0].Rows)
            {
                zips.Add(row["ITEM_PATH"].ToString());
                rowindex++;
            }

            if (zips.Count > 0)
            {
                var ac = Server.MapPath("~/Uploads/TrainingItems/");

                zipFile = BLL_LMS_Training.RAR(Server.MapPath("~/Uploads/TrainingItems/"), zips);



                int lLastValue = BLL_LMS_Training.Ins_Program_Sync(table, Convert.ToInt32(Session["USERID"]));

                string DownloadFileName = "AttachedProgramDocuments" + "_" + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + "_" + DateTime.Now.Hour + "h" + DateTime.Now.Minute + "m" + DateTime.Now.Second + "s" + ".rar";
                if (File.Exists(Server.MapPath("~/Uploads/TrainingItems/" + zipFile)))
                {
                    File.Move(Server.MapPath("~/Uploads/TrainingItems/" + zipFile), Server.MapPath("~/Uploads/Temp/" + DownloadFileName));

                    ResponseHelper.Redirect("~/Uploads/Temp/" + DownloadFileName, "blank", "");
                }
                else
                {
                    msgmodal = String.Format("alert('Files not present on the Server.')");
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", msgmodal, true);
                }


                BindPrograms();
                BindHistorySelection();
                ddlSyncDate.SelectedIndex = -1;
            }
        }
        catch (Exception ex)
        {
            msgmodal = String.Format("Error :\n " + ex.ToString());
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", msgmodal, true);
        }
    }