public JsonResult SetDMExcel(DMExcelModel DMexcel)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("SlNo", typeof(string));
            dt.Columns.Add("Turbine", typeof(string));
            dt.Columns.Add("DMTitle", typeof(string));
            dt.Columns.Add("Status", typeof(string));
            dt.Columns.Add("AnalyzingStatus", typeof(string));
            dt.Columns.Add("Description", typeof(string));
            DMexcel.Turbine = dt;
            DMSetExcelResult result = oMasterManager.SetDMStatusUploadExcel(DMexcel, CookieManager.GetCookie(CookieManager.CookieName).logindetail.EmpID);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult DMSaveExcel(string DSId, string Remarks)
        {
            OleDbConnection  con = new OleDbConnection();
            DMSetExcelResult result = new DMSetExcelResult();
            DMExcelModel     DMSetexcel = new DMExcelModel();
            OleDbCommand     cmd = new OleDbCommand();
            string           connectionstring = "", extension = "";

            try
            {
                string strTurbineDataEntryExcelUploadUrl = ConfigurationManager.AppSettings["TurbineFileUploadDataEntyUrl"].ToString();
                if (Session["UploadExcelUrl"] != null)
                {
                    HttpPostedFileBase UploadedEcelFile = Session["UploadExcelUrl"] as HttpPostedFileBase;
                    Session["UploadExcelUrl"] = null;
                    extension = UploadedEcelFile.FileName.Split('.')[UploadedEcelFile.FileName.Split('.').Length - 1];
                    string uploadurl = string.Format("{0}TurbineDataEntryTemplate/{1}", strTurbineDataEntryExcelUploadUrl, UploadedEcelFile.FileName);
                    if (extension == "xlsx" || extension == "xls")
                    {
                        if (extension == "xls")
                        {
                            connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + uploadurl + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
                        }
                        else if (extension == "xlsx")
                        {
                            connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + uploadurl + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
                        }

                        con.ConnectionString = connectionstring;
                        cmd.CommandType      = System.Data.CommandType.Text;
                        cmd.Connection       = con;
                        OleDbDataAdapter oledbDa = new OleDbDataAdapter(cmd);
                        con.Open();
                        DataTable dt = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                        string    getExcelSheetName = dt.Rows[0]["Table_Name"].ToString();
                        cmd.CommandText       = "SELECT * FROM [" + getExcelSheetName + "]";
                        oledbDa.SelectCommand = cmd;
                        dt = new DataTable();
                        oledbDa.Fill(dt);
                        if (dt.Rows.Count > 0)
                        {
                            DMSetexcel.Turbine  = dt;
                            DMSetexcel.FileName = UploadedEcelFile.FileName;
                            DMSetexcel.Remarks  = Remarks;
                            DMSetexcel.Submit   = "1";
                            DMSetexcel.DSId     = DSId;
                            DMSetexcel.RowId    = "0";
                            DMSetexcel.Delflag  = "0";

                            result = oMasterManager.SetDMStatusUploadExcel(DMSetexcel, CookieManager.GetCookie(CookieManager.CookieName).logindetail.EmpID);
                        }
                        else
                        {
                            result.message       = new Message();
                            result.message.Msg   = "Excel File Should not Empty!";
                            result.message.Clear = "False";
                        }
                        con.Close();
                    }
                    else
                    {
                        result.message       = new Message();
                        result.message.Msg   = "Upload .xlsx / .xls file only!";
                        result.message.Clear = "False";
                    }
                }
                else
                {
                    result.message       = new Message();
                    result.message.Msg   = "Upload Excel File!";
                    result.message.Clear = "False";
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetDMExcel(DMExcelModel DMexcel)
        {
            DMExcelGetResult result = oMasterManager.GetDMStatusUploadExcel(DMexcel, CookieManager.GetCookie(CookieManager.CookieName).logindetail.EmpID);

            return(Json(new { result }, JsonRequestBehavior.AllowGet));
        }