示例#1
0
        public int InsertFilereading(EMFilereading objfilereading)
        {
            Hashtable htparams = new Hashtable {
                { "@FileId", objfilereading.FileId },
                { "@FileName", objfilereading.FileName },
                { "@FileContent", objfilereading.FileContent },

                { "@CreatedBy", objfilereading.CreatedBy },
            };

            return(ExecuteNonQuery("FileReading_Insert", htparams));
        }
示例#2
0
 public int InsertFilereading(EMFilereading objEMFlereading)
 {
     return(objDAFilereading.InsertFilereading(objEMFlereading));
 }
示例#3
0
    protected void button1_Click(object sender, EventArgs e)
    {
        EMFilereading objEMFilereading = new EMFilereading();

        try
        {
            int filecount       = 0;
            int fileuploadcount = 0;

            //First Create the instance of Stopwatch Class
            Stopwatch sw = new Stopwatch();

            // Start The StopWatch ...From 000
            sw.Start();

            // List<string> Name = new List<string>();

            //// string Name = "";
            // string Type = "getContent";

            //       DataSet ds=objBALFilereading.GetFilesContent(Type);
            //       if (ds.Tables[0].Rows.Count > 0)
            //       {
            //           foreach (DataRow dtlRow in ds.Tables[0].Rows)
            //           {
            //               string name=dtlRow["FileName"].ToString();

            //               Name.Add(name);

            //           }
            //       }
            //       else
            //       {
            //           Name.Add("FileName Not Match");
            //       }

            for (int i = 0; i < Request.Files.Count; i++)
            {
                filecount = fileuplaod1.PostedFiles.Count();

                HttpPostedFile postedFile = Request.Files[i];
                if (postedFile.ContentLength > 0)
                {
                    string filename = Path.GetFileName(postedFile.FileName);

                    //if (Name[i].ToString() != filename)
                    //{

                    //   string contentType = postedFile.ContentType;
                    using (Stream fs = postedFile.InputStream)
                    {
                        string filetype = Path.GetExtension(postedFile.FileName);
                        if (filetype == ".MIR")
                        {
                            System.IO.Stream content = new System.IO.MemoryStream();

                            fs.CopyTo(content);

                            byte[] bytes = new byte[content.Length];
                            content.Position = 0;
                            content.Read(bytes, 0, (int)content.Length);
                            string data = Encoding.ASCII.GetString(bytes);

                            using (BinaryReader br = new BinaryReader(fs))
                            {
                                //Get The File Extension


                                objEMFilereading.FileName    = postedFile.FileName;
                                objEMFilereading.FileContent = data;
                                objEMFilereading.CreatedBy   = 0;

                                int result = objBALFilereading.InsertFilereading(objEMFilereading);

                                if (result != 0)
                                {
                                    fileuploadcount++;
                                    double filesize = postedFile.ContentLength;
                                    if (filesize < (1048576))
                                    {
                                        string getFileName = Path.GetFileName(postedFile.FileName);
                                        postedFile.SaveAs(Server.MapPath(@"uplaodfiles\pdf\" + getFileName));
                                        //  label1.Text += "[" + postedFile.FileName + "]- pdf file uploaded  successfully<br/>";
                                    }

                                    else
                                    {
                                        label1.Text   += "[" + postedFile.FileName + "]- files not uploded size is greater then(1)MB.<br/>Your File Size is(" + (filesize / (1024 * 1034)) + ") MB </br>";
                                        label1.Visible = true;
                                    }



                                    label3.Visible = true;
                                    label3.Text    = "ToTal File =(" + filecount + ")<br/> Uploded file =(" + fileuploadcount + ")<br/> Not Uploaded=(" + (filecount - fileuploadcount) + ")";
                                }
                            }
                        }
                        else
                        {
                            label1.Text   += "[" + postedFile.FileName + "]-file not uploaded <br/>";
                            label1.Visible = true;
                        }
                    }
                }
            }

            //Stop the Timer
            sw.Stop();


            //Writing Execution Time in label
            string ExecutionTimeTaken = string.Format("Minutes :{0}\nSeconds :{1}\n<br/> Mili seconds :{2}", sw.Elapsed.Minutes, sw.Elapsed.Seconds, sw.Elapsed.TotalMilliseconds);

            label1.Text = ExecutionTimeTaken;
        }

        catch (Exception ex)
        {
            ExceptionLogging.SendExcepToDB(ex);
            label1.Text = "Some Technical Error occurred,Please visit after some time";
        }
    }