public string ExtractRARFile(string filePath, string UserID, int Fileid)
 {
     try
     {
         string[]   FileDetail = filePath.ToString().Split(new string[] { "\\", ".rar" }, StringSplitOptions.RemoveEmptyEntries);
         string     fileName   = FileDetail[FileDetail.Length - 1];
         string     newPath    = null;
         RarArchive file       = RarArchive.Open(filePath);
         newPath = Path.Combine(Server.MapPath("~/Files"), fileName);
         using (DBClass context = new DBClass())
         {
             context.AddParameter("@FileID", Fileid);
             context.AddParameter("@UserID", UserID);
             context.AddParameter("@FileName", fileName);
             context.AddParameter("@NewPath", newPath);
             context.ExecuteNonQuery("UpdateFileData", CommandType.StoredProcedure);
         }
         foreach (RarArchiveEntry rarFile in file.Entries)
         {
             rarFile.WriteToDirectory(newPath, ExtractOptions.ExtractFullPath);
         }
         //if(System.IO.File.Exists(filePath))
         //{
         //    System.IO.File.Delete(filePath);
         //}
         return(newPath);
     }
     catch (Exception e) { throw e; }
 }
        public ActionResult ChangeProfileImage()
        {
            HttpFileCollectionBase files = Request.Files;
            HttpPostedFileBase     file  = files[0];
            string FileName  = Session["UserName"].ToString() + "@" + file.FileName;
            string extension = file.FileName.Substring(file.FileName.LastIndexOf('.'));

            if (file.FileName != null || file.FileName != "")
            {
                string fname    = Path.Combine(Server.MapPath("../Content/User Image/"), FileName);
                string filepath = "../Content/User Image/" + FileName;
                using (DBClass context = new DBClass())
                {
                    context.AddParameter("@UserName", Session["UserName"]);
                    context.AddParameter("@UserRole", Session["UserRole"]);
                    context.AddParameter("@Filepath", filepath);
                    int i = context.ExecuteNonQuery("updateUserImage", CommandType.StoredProcedure);
                    if (i > 0)
                    {
                        file.SaveAs(fname);
                    }
                    Session["ImagePath"] = filepath;
                    //string imgpath = "../Content/User Image/" + FileName;
                    //ViewData["ImagePath"] = imgpath;
                    return(Json(new { status = "Success", path = filepath }));
                }
            }
            else
            {
                return(Json(new { status = "Failed", Message = "You have not selected any image !" }));
            }
        }
        public ActionResult GetMachineData1(int fileID, UploadFile upl)
        {
            List <UploadFile> MachineData = new List <UploadFile>();

            try
            {
                using (DBClass context = new DBClass())
                {
                    context.AddParameter("@FileID", fileID);
                    context.AddParameter("@UserName", Session["UserName"].ToString());
                    DataTable dt = context.getData("getDriveUnit", CommandType.StoredProcedure);
                    foreach (DataRow dr in dt.Rows)
                    {
                        string MacID      = Convert.ToString(dr["ID"]);
                        string Train      = Convert.ToString(dr["MachineName"]);
                        string DEUnit     = Convert.ToString(dr["DUName"]);
                        int    PointCount = Convert.ToInt32(dr["Point_Count"]);
                        MachineData.Add(new UploadFile
                        {
                            MachineID  = Convert.ToInt32(MacID),
                            TrainName  = Convert.ToString(Train),
                            DEUnitType = Convert.ToString(DEUnit),
                            //NDEUnit1 = Convert.ToString(NDE1),
                            //NDEUnit2 = Convert.ToString(NDE2),
                            //NDEUnit3 = Convert.ToString(NDE3),
                            TotalPoint = Convert.ToInt32(PointCount)
                        });
                    }
                }
            }
            catch { }
            var machinedata = Json(MachineData, JsonRequestBehavior.AllowGet);

            return(machinedata);
        }
        public JsonResult getDrivenUnit(string id)
        {
            //Preparing anonymous variable with json data
            List <UploadFile> MachineData = new List <UploadFile>();

            try
            {
                using (DBClass context = new DBClass())
                {
                    context.AddParameter("@MachineID", id);
                    context.AddParameter("@UserName", Session["UserName"].ToString());
                    DataTable dt = context.getData("getDrivenUnit", CommandType.StoredProcedure);
                    foreach (DataRow dr in dt.Rows)
                    {
                        string MacID      = Convert.ToString(dr["ID"]);
                        string NDEName    = Convert.ToString(dr["Machine_Name"]);
                        int    PointCount = Convert.ToInt32(dr["Point_Count"]);
                        MachineData.Add(new UploadFile
                        {
                            MachineID       = Convert.ToInt32(MacID),
                            NDEUnit1        = Convert.ToString(NDEName),
                            Point_Count_NDE = Convert.ToInt32(PointCount)
                        });
                    }
                }
            }
            catch { }

            //Returning json data
            return(Json(MachineData, JsonRequestBehavior.AllowGet));
        }
        public ActionResult BoughtEnquiry(string Id)
        {
            using (DBClass context = new DBClass())
            {
                var uname = Session["UserName"].ToString();
                SessionClass.Username = uname;
                context.AddParameter("@Username", Session["UserName"].ToString());
                DataSet ds = context.ExecuteDataSet("getUserRole", CommandType.StoredProcedure);
                if (Convert.ToString(ds.Tables[0].Rows[0]["UserRole"]) != "Client")
                {
                    DataTable dt = new DataTable();
                    context.AddParameter("@UserName", Session["UserName"].ToString());
                    context.AddParameter("@EnquiryID", Convert.ToInt32(Id));
                    dt = context.getData("getExpertBalance", CommandType.StoredProcedure);
                    //int CurrentBalance = Convert.ToInt32(dt.Rows[0]["Current_PointBalance"]);
                    int enquiryCost = Convert.ToInt32(dt.Rows[0]["Enquiry_Cost"]);


                    return(Json(new { status = "Success", message = "hello !" }));
                }
                else
                {
                    //return View();
                    return(Json(new { status = "Client", message = "You are not autherized to buy an enquiry !" }));
                }
            }
        }
        private string FillTrainDetail(string trainName, int fileID, string AID, int NoofMachine)
        {
            string NewTrainID = null;
            int    t;

            try
            {
                using (DBClass context = new DBClass())
                {
                    context.AddParameter("@FileID", fileID);
                    context.AddParameter("@AID", AID);
                    context.AddParameter("@TrainName", trainName);
                    context.AddParameter("@NoofMachine", NoofMachine);
                    t = context.ExecuteNonQuery("AddTrainInRoute", CommandType.StoredProcedure);
                }
                if (t > 0)
                {
                    using (DBClass context = new DBClass())
                    {
                        context.AddParameter("@FileID", fileID);
                        DataTable dtTrain = context.getData("GetTrainIDForCurrentRoute", CommandType.StoredProcedure);
                        if (dtTrain.Rows.Count > 0)
                        {
                            NewTrainID = Convert.ToString(dtTrain.Rows[0]["NodeID"]);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new NotImplementedException();
            }
            return(NewTrainID);
        }
        private string FillMachineDetail(string machineName, int fileID, string TID)
        {
            string NewMachineID = null;
            int    m;

            try
            {
                using (DBClass context = new DBClass())
                {
                    context.AddParameter("@FileID", fileID);
                    context.AddParameter("@TID", TID);
                    context.AddParameter("@MachineName", machineName);
                    m = context.ExecuteNonQuery("AddMachineInRoute", CommandType.StoredProcedure);
                }
                if (m > 0)
                {
                    using (DBClass context = new DBClass())
                    {
                        context.AddParameter("@FileID", fileID);
                        DataTable dtMachine = context.getData("GetMachineIDForCurrentRoute", CommandType.StoredProcedure);
                        if (dtMachine.Rows.Count > 0)
                        {
                            NewMachineID = Convert.ToString(dtMachine.Rows[0]["NodeID"]);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(NewMachineID);
        }
        private string FillAreaDetail(string areaName, int fileID, string PID)
        {
            string NewAreaID = null;
            int    a;

            try
            {
                using (DBClass context = new DBClass())
                {
                    context.AddParameter("@FileID", fileID);
                    context.AddParameter("@PID", PID);
                    context.AddParameter("@AreaName", areaName);
                    a = context.ExecuteNonQuery("AddAreaInRoute", CommandType.StoredProcedure);
                }
                if (a > 0)
                {
                    using (DBClass context = new DBClass())
                    {
                        context.AddParameter("@FileID", fileID);
                        DataTable dtArea = context.getData("GetAreaIDForCurrentRoute", CommandType.StoredProcedure);
                        if (dtArea.Rows.Count > 0)
                        {
                            NewAreaID = Convert.ToString(dtArea.Rows[0]["NodeID"]);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new NotImplementedException();
            }
            return(NewAreaID);
        }
        private string FillPlantDetail(string plantName, int fileID)
        {
            string NewPlantID = null;
            int    i;

            try
            {
                using (DBClass context = new DBClass())
                {
                    context.AddParameter("@FileID", fileID);
                    context.AddParameter("@PlantName", plantName);
                    i = context.ExecuteNonQuery("AddPlantInRoute", CommandType.StoredProcedure);
                }
                if (i > 0)
                {
                    using (DBClass context = new DBClass())
                    {
                        context.AddParameter("@FileID", fileID);
                        DataTable dtPlant = context.getData("GetPlantIDForCurrentRoute", CommandType.StoredProcedure);
                        if (dtPlant.Rows.Count > 0)
                        {
                            NewPlantID = Convert.ToString(dtPlant.Rows[0]["NodeID"]);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(NewPlantID);
        }
 public static double[] getFaultFrequencyData(string Pointid, string Userid)
 {
     double[] lstFF = new double[1];
     try
     {
         using (DBClass context = new DBClass())
         {
             context.AddParameter("@PointID", Pointid);
             context.AddParameter("@UserName", Userid);
             DataTable dtFF = context.getData("getFalutFrequencyListbyPointID", CommandType.StoredProcedure);
             Array.Resize(ref lstFF, dtFF.Rows.Count);
             if (dtFF.Rows.Count > 0)
             {
                 int i = 0;
                 foreach (DataRow dr in dtFF.Rows)
                 {
                     lstFF[i] = Convert.ToDouble(dr["FrequencyValue"]);
                     i++;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(lstFF);
 }
        public List <ReturnData> GetFileToRead(int FileID, string Userid)
        {
            bool status = false;
            RemoteAnalysisKohtect _kohtect = new RemoteAnalysisKohtect();
            List <ReturnData>     rList    = new List <ReturnData>();
            string filePath = null;
            string newpath  = null;
            string filetype = null;

            try
            {
                if (Userid != null)
                {
                    using (DBClass _dbConnection = new DBClass())
                    {
                        _dbConnection.AddParameter("@FileID", FileID);
                        _dbConnection.AddParameter("UserID", Userid);
                        DataTable dtPath = _dbConnection.getData("GetFilePathbyFileID", CommandType.StoredProcedure);
                        filePath = Convert.ToString(dtPath.Rows[0]["FilePath"]);
                        filetype = Convert.ToString(dtPath.Rows[0]["FileType"]);
                        if (filetype != "File")
                        {
                            newpath = ExtractRARFile(filePath, Userid, FileID);
                            status  = _kohtect.FileDataSave(FileID, Userid, newpath, filetype);
                        }
                        else
                        {
                        }
                        {
                            status = _kohtect.FileDataSave(FileID, Userid, filePath, filetype);
                        }
                        rList.Add(new ReturnData
                        {
                            Status          = status,
                            FileID          = FileID,
                            UserID          = Userid,
                            MeasurementTime = _kohtect.MeasureTime,
                            UploadTime      = DateTime.Now
                        });
                    }
                }
                else
                {
                    status = false;
                    ModelState.AddModelError("UserIDNotFound", "Please Logout and Login again to complete your process !");
                }
            }
            catch
            {
            }

            return(rList);
        }
 public ActionResult updateLikes(string blogID)
 {
     using (DBClass context = new DBClass())
     {
         DataTable dt    = context.getData("Select * from BlogsData where id='" + blogID + "'", CommandType.Text);
         int       likes = Convert.ToInt32(dt.Rows[0]["Likes"]) + 1;
         context.AddParameter("@Likes", likes);
         context.AddParameter("@blogID", blogID);
         context.ExecuteNonQuery("updateBlog", CommandType.StoredProcedure);
     }
     return(RedirectToAction("ShowBlogs"));
 }
 public ActionResult Login(LoginViewModel model, string ReturnUrl)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (DBClass context = new DBClass())
             {
                 context.AddParameter("@Username", model.UserName);
                 context.AddParameter("@Password", model.Password);
                 DataTable dtLogin = context.getData("CheckUser", CommandType.StoredProcedure);
                 if (dtLogin.Rows.Count > 0)
                 {
                     WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe);
                     Session["UserRole"] = Convert.ToString(dtLogin.Rows[0]["UserRole"]);
                     Session["UserName"] = Convert.ToString(dtLogin.Rows[0]["LoginId"]);
                     if (Convert.ToString(dtLogin.Rows[0]["UserRole"]) == "Employee")
                     {
                         Session["Department"] = Convert.ToString(dtLogin.Rows[0]["Department"]);
                     }
                     else
                     {
                         Session["Department"] = null;
                     }
                     Session["ConsultantEmailID"] = Convert.ToString(dtLogin.Rows[0]["EmailId"]);
                     Session["IsActiveSession"]   = true;
                     Session["ImagePath"]         = dtLogin.Rows[0]["Image"].ToString();
                     Session["FullName"]          = Convert.ToString(dtLogin.Rows[0]["Emp_Name"]);
                     Session["UserEmailID"]       = Convert.ToString(dtLogin.Rows[0]["EmailId"]);
                     return(RedirectToLocal(ReturnUrl));
                     //return RedirectToLocal(ViewData["baseUrl"].ToString());
                 }
                 else
                 {
                     ModelState.AddModelError("", "The user name or password provided is incorrect.");
                 }
             }
         }
         else
         {
             ModelState.AddModelError("", "The user name or password provided is incorrect.");
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(View(model));
 }
        public JsonResult CreateHierarchy()
        {
            List <TreeViewModel> TreeList = new List <TreeViewModel>();

            try
            {
                using (DBClass context = new DBClass())
                {
                    context.AddParameter("@FileID", Convert.ToInt32(Session["FileID"]));
                    DataTable dtHierarchy = context.getData("GetHierarchyData", CommandType.StoredProcedure);
                    ViewBag.FirstNodeID = Convert.ToString(dtHierarchy.Rows[0]["NodeID"]);
                    if (dtHierarchy.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dtHierarchy.Rows)
                        {
                            TreeList.Add(new TreeViewModel
                            {
                                id     = Convert.ToString(dr["NodeID"]),
                                text   = Convert.ToString(dr["NodeText"]),
                                parent = Convert.ToString(dr["ParentID"])
                            });
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(Json(TreeList, "True", JsonRequestBehavior.AllowGet));
        }
        public ActionResult showEnquiryDetail(string EnquiryID)
        {
            Enquiry enquiry = new Enquiry();

            using (DBClass context = new DBClass())
            {
                context.AddParameter("@EnquiryID", EnquiryID);
                DataTable dt = context.getData("getEnquiryDetailByID", CommandType.StoredProcedure);
                if (dt.Rows.Count > 0)
                {
                    enquiry.UserName       = Convert.ToString(dt.Rows[0]["uName"]);
                    enquiry.company        = Convert.ToString(dt.Rows[0]["uCompanyName"]);
                    enquiry.phone          = Convert.ToString(dt.Rows[0]["uMobile_No"]);
                    enquiry.emailid        = Convert.ToString(dt.Rows[0]["Email_ID"]);
                    enquiry.EnquiryID      = Convert.ToString(dt.Rows[0]["ID"]);
                    enquiry.Country        = Convert.ToString(dt.Rows[0]["Country"]);
                    enquiry.City           = Convert.ToString(dt.Rows[0]["City"]);
                    enquiry.State          = Convert.ToString(dt.Rows[0]["State"]);
                    enquiry.Enq_Category   = Convert.ToString(dt.Rows[0]["EnquiryCategory"]);
                    enquiry.Enq_Subject    = Convert.ToString(dt.Rows[0]["EnquirySubject"]);
                    enquiry.EnquiryDetail1 = Convert.ToString(dt.Rows[0]["EnquiryDetail"]);
                }
                else
                {
                    ModelState.AddModelError("", "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.");
                }
            }
            return(PartialView("_showEnquiryDetail", enquiry));
        }
Beispiel #16
0
        public static List <FileDetail> getPreviousFileData(string UserRole)
        {
            List <FileDetail> fileList = new List <FileDetail>();  // creating list of model.
            string            username = HttpContext.Current.Session["UserName"].ToString();

            using (DBClass context = new DBClass())
            {
                context.AddParameter("@UserID", username);
                DataTable dt = context.getData("getPreviousDataByUserID", CommandType.StoredProcedure);
                foreach (DataRow dr in dt.Rows)
                {
                    string[] fName = Convert.ToString(dr["FileName"]).Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries);
                    fileList.Add(new FileDetail
                    {
                        FileID         = Convert.ToInt16(dr["FileID"]),
                        UserName       = Convert.ToString(dr["UserID"]),
                        UploadDate     = Convert.ToString(dr["DateOfUpload"]),
                        FileType       = Convert.ToString(dr["FileType"]),
                        FileName       = Convert.ToString(fName[1]),
                        InstrumentUsed = Convert.ToString(dr["InstrumentUsed"])
                    });
                }
                return(fileList);
            }
        }
Beispiel #17
0
        public ActionResult ShowDriveUnit(string MachineID)
        {
            UploadFile upload = new UploadFile();

            upload.DrivenUnitID   = Convert.ToInt32(MachineID);
            TempData["MachineID"] = MachineID.ToString();
            ViewBag.DriveID       = Convert.ToInt32(MachineID);

            using (DBClass context = new DBClass())
            {
                DataTable dt = new DataTable();
                context.AddParameter("@MachineID", MachineID);
                dt = context.getData("getDriveUnitByID", CommandType.StoredProcedure);
                upload.TrainName          = Convert.ToString(dt.Rows[0]["MachineName"]);
                upload.MachineOrientaion  = Convert.ToString(dt.Rows[0]["MachineOrientation"]);
                upload.MountingType       = Convert.ToString(dt.Rows[0]["MountingType"]);
                upload.DEUnitType         = Convert.ToString(dt.Rows[0]["DUName"]);
                upload.DURPM              = Convert.ToString(dt.Rows[0]["RPM"]);
                upload.BearingLubrication = Convert.ToString(dt.Rows[0]["Ber_Lubrication"]);
                upload.bearingMake        = Convert.ToString(dt.Rows[0]["Ber_Manufacture"]);
                upload.bearingNoDE        = Convert.ToString(dt.Rows[0]["Ber_NumberDE"]);
                upload.bearingNoNDE       = Convert.ToString(dt.Rows[0]["Ber_NumberNDE"]);
                upload.NoOfPoles          = Convert.ToInt32(dt.Rows[0]["PolesCount"]);
                upload.Point_Count_DE     = Convert.ToInt32(dt.Rows[0]["Point_Count"]);
            }
            return(View("_DriveDetail", upload));
        }
Beispiel #18
0
        public static double[] GetRPMValues(string Pointid, string Userid)
        {
            double[] lstFF  = new double[1];
            double[] lstFF1 = new double[1];
            try
            {
                using (DBClass context = new DBClass())
                {
                    context.AddParameter("@PointID", Pointid);
                    //context.AddParameter("@UserName", Userid);
                    DataTable dtFF = context.getData("getMachineRPMByPointID", CommandType.StoredProcedure);
                    Array.Resize(ref lstFF, dtFF.Rows.Count);
                    if (dtFF.Rows.Count > 0)
                    {
                        int i = 0;
                        foreach (DataRow dr in dtFF.Rows)
                        {
                            lstFF[i] = (Convert.ToDouble(dr["rpmdriven"]) / 60);

                            i++;
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(lstFF);
        }
 public ActionResult getEnquiryStatus(string Id)
 {
     using (DBClass context = new DBClass())
     {
         context.AddParameter("@EnquiryID", Id);
         context.AddParameter("@UserName", Session["UserName"].ToString());
         DataTable dt = context.getData("getEnquiryStatus", CommandType.StoredProcedure);
         if (dt.Rows.Count > 0)
         {
             return(Json(new { sts = "True", message = "True" }));
         }
         else
         {
             return(Json(new { sts = "False", message = "False" }));
         }
     }
 }
        public static ArrayList GetData(string nodeid, string userid, ArrayList BearingFrequency)
        {
            ArrayList xyData = new ArrayList();

            try
            {
                double[] Xdoubles = new double[1];
                double[] Ydoubles = new double[1];
                //string[] ffData = getFaultFrequencyData(nodeid, userid);//used for frequency name with value..

                //////////////  Chages for bearing fault frequency /////////////////////

                double[] bearingFrequency = new double[BearingFrequency.Count];
                for (int i = 0; i < BearingFrequency.Count; i++)
                {
                    string[] bff = (Convert.ToString(BearingFrequency[i])).Split(new char[] { '=' });
                    bearingFrequency[i] = Convert.ToDouble(bff[1]);
                }
                double[] faultFrequency = getFaultFrequencyData(nodeid, userid);
                using (DBClass context = new DBClass())
                {
                    context.AddParameter("@Nodeid", nodeid);
                    DataTable dtData = context.getData("GetRecordedDataByPointID", CommandType.StoredProcedure);
                    foreach (DataRow dr in dtData.Rows)
                    {
                        string[] xData = Convert.ToString(dr["Chnl1FFT_X"]).Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                        string[] yData = Convert.ToString(dr["Chnl1FFT_Y"]).Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                        Array.Resize(ref Xdoubles, xData.Length);
                        Array.Resize(ref Ydoubles, xData.Length);
                        Xdoubles            = Array.ConvertAll(xData, new Converter <string, double>(Double.Parse));
                        Ydoubles            = Array.ConvertAll(yData, new Converter <string, double>(Double.Parse));
                        ChartData.xAxisUnit = "Frequency-Hz";
                        ChartData.yAxisUnit = Convert.ToString(dr["OverallUnitChnlA"]);
                        if (ChartData.yAxisUnit == "mm/sec" || ChartData.yAxisUnit == "inch/sec")
                        {
                            ChartData.amplitudeUnit = "Velocity ( " + ChartData.yAxisUnit + " )";
                        }
                        if (ChartData.yAxisUnit == "G" || ChartData.yAxisUnit == "m/s2")
                        {
                            ChartData.amplitudeUnit = "Acceleration ( " + ChartData.yAxisUnit + " )";
                        }
                        if (ChartData.yAxisUnit == "um" || ChartData.yAxisUnit == "mil")
                        {
                            ChartData.amplitudeUnit = "Displacement ( " + ChartData.yAxisUnit + " )";
                        }

                        ChartData.overallValue = Convert.ToDouble(dr["OverallValueChnlA"]);
                    }
                }
                xyData.Add(Xdoubles);
                xyData.Add(Ydoubles);
                xyData.Add(FindNearestPointIndex(faultFrequency, Xdoubles));
                xyData.Add(FindNearestPointIndex(bearingFrequency, Xdoubles));
            }
            catch (Exception ex) { throw ex; }
            return(xyData);
        }
        //[InitializeSimpleMembership]

        public ActionResult buyEnquiry(string Id)
        {
            try
            {
                using (DBClass context = new DBClass())
                {
                    var uname = Session["UserName"].ToString();
                    SessionClass.Username = uname;
                    context.AddParameter("@Username", Session["UserName"].ToString());
                    DataSet ds = context.ExecuteDataSet("getUserRole", CommandType.StoredProcedure);
                    if (Convert.ToString(ds.Tables[0].Rows[0]["UserRole"]) != "Client")
                    {
                        DataTable dt = new DataTable();
                        context.AddParameter("@UserName", Session["UserName"].ToString());
                        context.AddParameter("@EnquiryID", Convert.ToInt32(Id));
                        dt = context.getData("getExpertBalance", CommandType.StoredProcedure);
                        //int CurrentBalance = Convert.ToInt32(dt.Rows[0]["Current_PointBalance"]);
                        int enquiryCost = Convert.ToInt32(dt.Rows[0]["Enquiry_Cost"]);

                        DataSet dsEmp  = context.ExecuteDataSet("Select * from [Emp_Detail] where [LoginID]='" + uname + "'", CommandType.Text);
                        int     UserID = (int)dsEmp.Tables[0].Rows[0]["AutoId"];
                        context.ExecuteNonQuery("INSERT INTO [dbo].[Enquiry_Buyer] ([EnquiryID] ,[BuyerID] ,[Buyer_Name] ,[Enquiry_Cost] ,[DateofBuying]) VALUES(" +
                                                Convert.ToInt32(Id) + ",'" + UserID + "','" + uname + "'," + enquiryCost + ",'" + DateTime.Now.ToLocalTime().ToString() + "')", CommandType.Text);

                        SendPurchaseMail(uname, Convert.ToInt32(Id), Convert.ToInt32(UserID), enquiryCost);
                        //Payment(enquiryCost.ToString());
                        //return Json(new { status = "Success", message = "hello !" });



                        return(RedirectToAction("Payment", new { Amount = enquiryCost, EnquiryId = Id.ToString() }));
                    }
                    else
                    {
                        //return View();
                        return(Json(new { status = "Client", message = "You are not autherized to buy an enquiry !" }));
                    }
                }
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Errormessage"));
            }
        }
Beispiel #22
0
        public ActionResult MachineDetail(FormCollection form, UploadFile up)
        {
            int id = Convert.ToInt32(up.FileID);

            using (DBClass context = new DBClass())
            {
                int totalPoint = 0;
                context.AddParameter("@FileID", id);
                DataTable DEPoint = context.getData("getDEPointCountbyFileID", CommandType.StoredProcedure);
                foreach (DataRow dr in DEPoint.Rows)
                {
                    totalPoint += Convert.ToInt32(dr["Point_Count"]);
                }
                context.AddParameter("@FileID", id);
                DataTable NDEPoint = context.getData("getNDEPointCountbyFileID", CommandType.StoredProcedure);
                foreach (DataRow dr in NDEPoint.Rows)
                {
                    totalPoint += Convert.ToInt32(dr["Point_Count"]);
                }

                if (context.ExecuteNonQuery("Update UploadData set PointCount = '" + totalPoint + "' where ID = '" + id + "' ", CommandType.Text) > 0)
                {
                    DataTable dt1  = context.getData("Select AnalysisType from UploadData where ID = '" + id + "'", CommandType.Text);
                    double    cost = 0;
                    if (Convert.ToString(dt1.Rows[0]["AnalysisType"]) == "Indicative Analysis")
                    {
                        cost = 140 * totalPoint;
                    }
                    else
                    {
                        cost = 680 * totalPoint;
                    }
                    context.ExecuteNonQuery("Update PaymentDetail set Amount = '" + cost + "' where FileID = '" + id + "' ", CommandType.Text);
                    ModelState.Clear();
                    return(RedirectToAction("ClientList", "Clients"));
                }
            }
            return(View());
        }
        public List <ReturnData> GetFileToAnalyse(int FileID, string Userid)
        {
            bool status = false;
            RemoteAnalysisKohtect _kohtect = new RemoteAnalysisKohtect();
            List <ReturnData>     rList    = new List <ReturnData>();

            try
            {
                if (Userid != null)
                {
                    using (DBClass _dbConnection = new DBClass())
                    {
                        _dbConnection.AddParameter("@FileID", FileID);
                        _dbConnection.AddParameter("UserID", Userid);
                        DataTable dtPath = _dbConnection.getData("GetFileData", CommandType.StoredProcedure);
                        rList.Add(new ReturnData
                        {
                            Status          = true,
                            FileID          = FileID,
                            UserID          = Userid,
                            MeasurementTime = Convert.ToDateTime(dtPath.Rows[0]["MeasureTime"]),
                            UploadTime      = Convert.ToDateTime(dtPath.Rows[0]["DateOfUpload"]),
                        });
                    }
                }
                else
                {
                    status = false;
                    ModelState.AddModelError("UserIDNotFound", "Please Logout and Login again to complete your process !");
                }
            }
            catch
            {
            }

            return(rList);
        }
        /// <summary>
        /// To fill all the data for hierarchy in the database on the basis of uploaded file.
        /// It uses stored procedure AddPlant,AddArea,AddTrain,AddMachine and AddPoint respectivly with all required parameters.
        /// </summary>
        public string FillRouteDetail(string filename)
        {
            string PID = null;

            try
            {
                string[] fname = filename.Split(new string[] { "@" }, StringSplitOptions.RemoveEmptyEntries);
                using (DBClass _dbConnection = new DBClass())
                {
                    _dbConnection.AddParameter("@FileID", FileID);
                    _dbConnection.AddParameter("@NoofMachine", 1);
                    _dbConnection.AddParameter("@FileName", fname[fname.Length - 1]);
                    _dbConnection.ExecuteNonQuery("AddRouteData", CommandType.StoredProcedure);
                }
                using (DBClass context = new DBClass())
                {
                    context.AddParameter("@FileID", FileID);
                    DataTable dt = context.getData("GetPointIDForCurrentRoute", CommandType.StoredProcedure);
                    PID = Convert.ToString(dt.Rows[0]["NodeID"]);
                }
            }
            catch { }
            return(PID);
        }
Beispiel #25
0
        public static ArrayList GetUnitXY(string nodeid, string userid, ArrayList XYUnit)
        {
            ArrayList XYdata = new ArrayList();

            try
            {
                double[] Xdoubles = new double[1];
                double[] Ydoubles = new double[1];

                using (DBClass context = new DBClass())
                {
                    context.AddParameter("@NodeId", nodeid);
                    DataTable dtData = context.getData("GetRecordDataByPointID", CommandType.StoredProcedure);
                    foreach (DataRow dr in dtData.Rows)
                    {
                        string[] xData = Convert.ToString(dr["Chnl1FFT_X"]).Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                        string[] yData = Convert.ToString(dr["Chnl1FFT_Y"]).Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);

                        Array.Resize(ref Xdoubles, xData.Length);
                        Array.Resize(ref Ydoubles, yData.Length);

                        Xdoubles            = Array.ConvertAll(xData, new Converter <string, double>(double.Parse));
                        Ydoubles            = Array.ConvertAll(yData, new Converter <string, double>(double.Parse));
                        ChartData.xAxisUnit = "Ferquecy-HZ";
                        ChartData.yAxisUnit = Convert.ToString(dr["OverallChnlA"]);
                        if (ChartData.yAxisUnit == "mm/sec" || ChartData.yAxisUnit == "inch/sec")
                        {
                            ChartData.amplitudeUnit = "Velocity ( " + ChartData.xAxisUnit + " )";
                        }

                        ChartData.overallValue = Convert.ToDouble(dr["OverallValueChnlA"]);
                    }
                }
                XYdata.Add(Xdoubles);
                XYdata.Add(Ydoubles);

                // XYdata.Add(FindNearestPointIndex1(RPM, Xdoubles));
            }
            catch (Exception)
            {
                throw;
            }
            return(XYdata);
        }
        private bool CheckDuplicateFileRecord(int fileid, string userid)
        {
            bool sts = false;

            try
            {
                using (DBClass context = new DBClass())
                {
                    context.AddParameter("@Fileid", fileid);
                    DataTable dt = context.getData("GetRecordedDataByFileID", CommandType.StoredProcedure);
                    if (dt.Rows.Count > 0)
                    {
                        sts = true;
                    }
                }
            }
            catch (Exception ex)
            { throw ex; }
            return(sts);
        }
 public ActionResult EditDriveUnit(UploadFile edit, string MachineID)
 {
     using (DBClass context = new DBClass())
     {
         context.AddParameter("@MachineID", MachineID);
         DataTable dt = context.getData("Select * from MachineInfo mi inner join DriveMachineDetail de on mi.ID= de.MachineID where mi.ID='" + MachineID + "'", CommandType.Text);
         edit.TrainName          = Convert.ToString(dt.Rows[0]["MachineName"]);
         edit.MachineOrientaion  = Convert.ToString(dt.Rows[0]["MachineOrientation"]);
         edit.MountingType       = Convert.ToString(dt.Rows[0]["MountingType"]);
         edit.DEUnitType         = Convert.ToString(dt.Rows[0]["DUName"]);
         edit.DURPM              = Convert.ToString(dt.Rows[0]["RPM"]);
         edit.BearingLubrication = Convert.ToString(dt.Rows[0]["Ber_Lubrication"]);
         edit.bearingMake        = Convert.ToString(dt.Rows[0]["Ber_Manufacture"]);
         edit.bearingNoDE        = Convert.ToString(dt.Rows[0]["Ber_NumberDE"]);
         edit.bearingNoNDE       = Convert.ToString(dt.Rows[0]["Ber_NumberNDE"]);
         edit.NoOfPoles          = Convert.ToInt32(dt.Rows[0]["PolesCount"]);
         edit.Point_Count_DE     = Convert.ToInt32(dt.Rows[0]["Point_Count"]);
         return(View("_EditDriveUnit", edit));
     }
 }
 public JsonResult getCity(int stateid)
 {
     try
     {
         using (DBClass context = new DBClass())
         {
             dtList.Clear();
             context.AddParameter("@StateID", stateid);
             dtList = context.getData("getCityByState", CommandType.Text);
             for (int i = 0; i < dtList.Rows.Count; i++)
             {
                 City.Add(new SelectListItem {
                     Text = Convert.ToString(dtList.Rows[i]["CityName"]), Value = Convert.ToString(dtList.Rows[i]["CityID"])
                 });
             }
         }
     }
     catch { }
     return(Json(City, JsonRequestBehavior.AllowGet));
 }
        public ActionResult MachineDetail(UploadFile uploadMachine)
        {
            //bool filetype = false;
            using (DBClass context = new DBClass())
            {
                context.AddParameter("@UserName", Session["UserName"].ToString());
                DataTable dt = context.getData("getCurrentFileDetail", CommandType.StoredProcedure);

                //if (Convert.ToString(dt.Rows[0]["FileType"]) == "Data")
                //{
                //    filetype = true;
                //}
                uploadMachine.FileID       = Convert.ToInt32(dt.Rows[0]["ID"]);
                uploadMachine.fileName1    = Convert.ToString(dt.Rows[0]["FileName"]);
                uploadMachine.Instrument   = Convert.ToString(dt.Rows[0]["InstrumentUsed"]);
                uploadMachine.AnalysisType = Convert.ToString(dt.Rows[0]["AnalysisType"]);
                uploadMachine.Description  = Convert.ToString(dt.Rows[0]["Description"]);
            }
            ViewBag.FileID = uploadMachine.FileID;
            return(View(uploadMachine));
        }
Beispiel #30
0
        public ActionResult ShowDrivenUnit(string MachineID)
        {
            UploadFile upload = new UploadFile();

            using (DBClass context = new DBClass())
            {
                DataTable dt = new DataTable();
                context.AddParameter("@MachineID", MachineID);
                dt = context.getData("getDrivenUnitByID", CommandType.StoredProcedure);

                upload.NDEUnit1           = Convert.ToString(dt.Rows[0]["Machine_Name"]);
                upload.NDEType            = Convert.ToString(dt.Rows[0]["Machine_Type"]);
                upload.TransmissionType   = Convert.ToString(dt.Rows[0]["Transmission_Type"]);
                upload.BearingLubrication = Convert.ToString(dt.Rows[0]["Ber_Lubrication"]);
                upload.bearingMake        = Convert.ToString(dt.Rows[0]["Ber_Manufacture"]);
                upload.bearingNoDE        = Convert.ToString(dt.Rows[0]["Ber_DE"]);
                upload.bearingNoNDE       = Convert.ToString(dt.Rows[0]["Ber_NDE"]);
                upload.bearingDEIn        = Convert.ToString(dt.Rows[0]["Ber_DE_IN"]);
                upload.bearingDEOut       = Convert.ToString(dt.Rows[0]["Ber_DE_OUT"]);
                upload.bearingNDEIn       = Convert.ToString(dt.Rows[0]["Ber_NDE_IN"]);
                upload.bearingNDEOut      = Convert.ToString(dt.Rows[0]["Ber_NDE_OUT"]);
                upload.bearingDEIdler     = Convert.ToString(dt.Rows[0]["Ber_DE_Idle"]);
                upload.bearingNDEIdler    = Convert.ToString(dt.Rows[0]["Ber_NDE_Idle"]);
                upload.InputRPM           = Convert.ToDouble(dt.Rows[0]["Input_RPM"]);
                upload.OutputRPM          = Convert.ToDouble(dt.Rows[0]["Output_RPM"]);
                upload.GearRatio          = Convert.ToString(dt.Rows[0]["Gear_Ratio"]);
                upload.TeethCountInput    = Convert.ToInt32(dt.Rows[0]["Teeth_Input_Count"]);
                upload.TeethCountOutput   = Convert.ToInt32(dt.Rows[0]["Teeth_Output_Count"]);
                upload.TeethCountIdle     = Convert.ToInt32(dt.Rows[0]["Teeth_Idler_Count"]);
                upload.NDERPM             = Convert.ToDouble(dt.Rows[0]["RPM"]);
                upload.BladesorFins       = Convert.ToInt32(dt.Rows[0]["BladesORFins"]);
                upload.BeltType           = Convert.ToString(dt.Rows[0]["Belt_Type"]);
                upload.BeltCount          = Convert.ToInt32(dt.Rows[0]["Belt_Count"]);
                upload.BeltLength         = Convert.ToDouble(dt.Rows[0]["Belt_Length"]);
                upload.PitchDia           = Convert.ToDouble(dt.Rows[0]["Pitch_Dia"]);
                upload.TeethCount         = Convert.ToInt32(dt.Rows[0]["Teeth_Count"]);
                upload.Point_Count_NDE    = Convert.ToInt32(dt.Rows[0]["Point_Count"]);
            }
            return(View("_DrivenDetail", upload));
        }