public ActionResult Assign(String mMapID)
        {
            if (Session["Login"] != null)
            {
                LoginSession loginsession = (LoginSession)Session["Login"];
                ViewBag.CompanyLogo = loginsession.CompanyLogo;
                ViewBag.Layout1 = BAL.Common.LayoutType(loginsession.UserType);
                String actionName = this.ControllerContext.RouteData.Values["action"].ToString();
                String controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ViewBag.Menu = BAL.Common.GetActiveMenu(controllerName, actionName, BAL.Common.LayoutType(loginsession.UserType));
                ViewBag.RoleName = loginsession.RoleName;
                if (mMapID != null)
                {

                    try
                    {
                        String DecMapID = BAL.Security.URLDecrypt(mMapID);
                        DAL.DataLoggerMapping logger = new DataLoggerMapping();
                        logger = DAL.DALDataLogger.ViewDataLoggerMappingRecord(DecMapID);
                        DataLoggerMapClass lg = new DataLoggerMapClass();
                        lg.Mapid = Convert.ToInt64(DecMapID);
                        lg.LoggerSerial = logger.LoggerSerial;
                        lg.ClientName = logger.Client;
                        lg.SiteName = logger.Site;
                        lg.CommunicationName = logger.Communication;
                        lg.StartDate = logger.StartDate;
                        ViewBag.MapID = DecMapID;
                        return View(lg);
                    }
                    catch (Exception ex)
                    { Console.Write(ex.Message); }

                }

                return View();

            }
            else
            { return RedirectToAction("Index", "Home"); }
        }
        public static DataLoggerMapping ViewDataLoggerMappingRecord(String MapID)
        {
            DataLoggerMapping logger = new DataLoggerMapping();
            try
            {
                using (var context = new SycousCon())
                {
                    var parMapID = new SqlParameter
                    {
                        ParameterName = "MapID",
                        Value = MapID,
                        Direction = ParameterDirection.Input
                    };
                    logger = context.ExecuteStoreQuery<DataLoggerMapping>("exec SYCOUS.GetAssignDataLogger @MapID", parMapID).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return logger;
        }
        public ActionResult UpdateLoggerMapping(List<DataLoggerInPropertyMaster> Logger)
        {
            if (Session["Login"] != null)
            {
                LoginSession loginsession = (LoginSession)Session["Login"];
                try
                {
                   List<DataLoggerInPropertyMaster> LoggerList = new List<DataLoggerInPropertyMaster>();
                    LoggerList = Logger;
                    var MappingID = LoggerList.Select(a => a.SiteMapID).FirstOrDefault();
                    DAL.DataLoggerMapping _logger = new DataLoggerMapping();
                    _logger = DAL.DALDataLogger.ViewDataLoggerMappingRecord(MappingID);
                    LoggerList.ToList().ForEach(u =>
                    {
                        u.CreateBy = Convert.ToInt64(loginsession.UserID);
                        u.LoggerID = _logger.DataloggerID;
                        u.ClientID = _logger.ClientID;
                        u.SiteID = _logger.SiteID;
                        u.CommonicationID = _logger.CommunicationID;
                        u.StartDate = _logger.StartDate;

                    });

                    if (BAL.DataLoggerModel.SaveMappingLoggerInProperty(LoggerList.Cast<Object>().ToList()))
                    {

                        return Json(new { Result = "true" }, JsonRequestBehavior.AllowGet);
                    }
                    else
                    {
                        return Json(new { Result = "false" }, JsonRequestBehavior.AllowGet);
                    }

                }
                catch (Exception ex)
                {
                    return Content("Error:" + ex.StackTrace.ToString());
                }

            }

            return View();
        }
        public ActionResult PropertyMap()
        {
            if (Session["Login"] != null)
            {
                LoginSession loginsession = (LoginSession)Session["Login"];
                ViewBag.CompanyLogo = loginsession.CompanyLogo;
                ViewBag.Layout1 = BAL.Common.LayoutType(loginsession.UserType);
                String actionName = this.ControllerContext.RouteData.Values["action"].ToString();
                String controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ViewBag.Menu = BAL.Common.GetActiveMenu(controllerName, actionName, BAL.Common.LayoutType(loginsession.UserType));
                ViewBag.RoleName = loginsession.RoleName;
                IEnumerable<DAL.MeterDetails> MeterList = null;
                try
                {

                    String LoggerID = Request.Form["hdLoggerID"];
                    String Client = Request.Form["Client"];
                    String Site = Request.Form["Site"];
                    String Type = Request.Form["hdType"];
                    String MapID = Request.Form["hdMapID"];

                    if ((loginsession.ClientID != null)&&(Client !=null))
                    {
                        ViewBag.ClientList = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text", Client);

                        ViewBag.SiteList = new SelectList(BAL.SiteModel.SiteDropDownList(loginsession.UserID.ToString(), Convert.ToInt64(Client), loginsession.UserType.ToString(), loginsession.RoleName), "Value", "Text", Site);
                    }
                    else
                    { ViewBag.ClientList = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text"); }
                    ViewBag.Communication = new SelectList(BAL.CommunicationModel.CommunicationDropDownList(), "Value", "Text");

                    if (LoggerID != null)
                    {
                        ViewBag.LoggerID = LoggerID;
                        DAL.DataLoggerlist Logger = new DataLoggerlist();
                        Logger = BAL.DataLoggerModel.ViewDataLogger(LoggerID);
                        ViewBag.LoggerID = Logger.ID;
                        ViewBag.LoogerSerial = Logger.SerialNumber;
                    }

                    ViewBag.TYPE = Type;
                    ViewBag.MapID = MapID;
                    DAL.DataLoggerMapping logger = new DataLoggerMapping();
                    if (Type == "Assign")
                    {

                        logger = DAL.DALDataLogger.ViewDataLoggerMappingRecord(MapID);
                        MeterList = BAL.DataLoggerModel.GetMeterDeatailsRecordList(logger.DataloggerID, logger.ClientID, logger.SiteID);
                    }
                    else
                    {
                        if ((LoggerID != null) && (Client != null) && (Site != null))
                        {
                            MeterList = BAL.DataLoggerModel.GetMeterDeatailsRecordList(LoggerID, Client, Site);
                        }
                    }
                    return View(MeterList);
                }
                catch (Exception ex)
                {
                    return Content("ErrorMessage" + ":" + ex.StackTrace.ToString());
                }

            }
            else
            { return RedirectToAction("Index", "Home"); }
        }
        public ActionResult PropertyMap(String mloggerID, String Type, String MapID)
        {
            if (Session["Login"] != null)
            {
                LoginSession loginsession = (LoginSession)Session["Login"];
                ViewBag.CompanyLogo = loginsession.CompanyLogo;
                ViewBag.Layout1 = BAL.Common.LayoutType(loginsession.UserType);
                String actionName = this.ControllerContext.RouteData.Values["action"].ToString();
                String controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ViewBag.Menu = BAL.Common.GetActiveMenu(controllerName, actionName, BAL.Common.LayoutType(loginsession.UserType));
                ViewBag.RoleName = loginsession.RoleName;
                IEnumerable<DAL.MeterDetails> MeterList = null;
                try
                {

                    if (loginsession.ClientID != null)
                    {
                        ViewBag.ClientList = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text");
                    }
                    else
                    { ViewBag.ClientList = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text"); }

                    if( (mloggerID != null)&&(Type != null))
                    {
                        String _LoggerID = BAL.Security.URLDecrypt(mloggerID);
                        String _Type = BAL.Security.URLDecrypt(Type);
                        String _MapID = BAL.Security.URLDecrypt(MapID);
                        ViewBag.LoggerID = _LoggerID;

                        DAL.DataLoggerlist Logger = new DataLoggerlist();
                        Logger = BAL.DataLoggerModel.ViewDataLogger(_LoggerID);
                        ViewBag.LoggerID = Logger.ID;
                        ViewBag.LoogerSerial = Logger.SerialNumber;
                        ViewBag.TYPE = _Type;
                        ViewBag.MapID = _MapID;
                        DAL.DataLoggerMapping logger = new DataLoggerMapping();
                        if (_Type == "Assign")
                        {

                            logger = DAL.DALDataLogger.ViewDataLoggerMappingRecord(_MapID);

                        }

                        if (_Type == "Assign")
                        {
                            ViewBag.ClientList = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text", logger.ClientID);
                            ViewBag.ClientName = logger.Client;
                            ViewBag.SiteList = new SelectList(BAL.SiteModel.SiteDropDownList(loginsession.UserID.ToString(), Convert.ToInt64(logger.ClientID), loginsession.UserType.ToString(), loginsession.RoleName), "Value", "Text", logger.SiteID);
                            ViewBag.siteName = logger.Site;

                            ViewBag.Communication = new SelectList(BAL.CommunicationModel.CommunicationDropDownList(), "Value", "Text", logger.CommunicationID);
                            ViewBag.CommunicationName = logger.Communication;
                            ViewBag.StartDatevalue = logger.StartDate;

                            MeterList = BAL.DataLoggerModel.GetMeterDeatailsRecordList(logger.DataloggerID, logger.ClientID, logger.SiteID);

                            return View(MeterList);
                        }
                        else
                        {
                            ViewBag.ClientName = "";
                            ViewBag.siteName = "";
                            ViewBag.CommunicationName = "";
                            ViewBag.StartDatevalue = "";
                            ViewBag.SiteList = new SelectList(BAL.Common.Default_DDR(), "Value", "Text");
                            ViewBag.Communication = new SelectList(BAL.CommunicationModel.CommunicationDropDownList(), "Value", "Text");

                            if (loginsession.ClientID != null)
                            {
                                ViewBag.ClientList = new SelectList(BAL.ClientModel.ClientDropDownList(loginsession.ClientID), "Value", "Text");
                            }
                            else
                            { ViewBag.ClientList = new SelectList(BAL.ClientModel.ClientDropDownList(), "Value", "Text"); }
                            return View();
                        }

                        //DataLoggerMapClass logger = new DataLoggerMapClass();
                        //DataLoggerMaster loggermaster = new DataLoggerMaster();
                        //loggermaster = BAL.DataLoggerModel.EditDataLogger(Dec_LoggerID);
                        //logger.LoggerId = Convert.ToInt32(Dec_LoggerID);
                        //logger.LoggerSerial = loggermaster.SerialNumber;

                    }
                    else
                    {
                        return View();
                    }

                }
                catch (Exception ex)
                {
                    return Content("ErrorMessage" + ":" + ex.StackTrace.ToString());
                }

            }
            else
            { return RedirectToAction("Index", "Home"); }
        }