コード例 #1
0
        public ActionResult DataConnection_Update([DataSourceRequest] DataSourceRequest request, ConnectorDTO _dtoConnector)
        {
            if (_dtoConnector != null && ModelState.IsValid)
            {
                _dtoConnector.SessionId = Session.SessionID;
                objConnectorRepository  = new ConnectorRepository(_dtoConnector);
                objConnectorRepository.SaveConnection();
            }

            return(Json(new[] { _dtoConnector }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult DataConnection_Insert([DataSourceRequest] DataSourceRequest request, ConnectorDTO _dtoConnector)
        {
            try
            {
                if (_dtoConnector != null && ModelState.IsValid)
                {
                    _dtoConnector.SessionId = Session.SessionID;
                    objConnectorRepository  = new ConnectorRepository(_dtoConnector);
                    objConnectorRepository.SaveConnection();
                }

                return(Json(new[] { _dtoConnector }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(Content(ex.Message + ex.InnerException.Message));
            }
        }
コード例 #3
0
        public ActionResult CreateDatabaseConnector(ConnectorsDTO objDCDTO)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    objDCDTO.SessionId     = Session.SessionID;
                    objConnectorRepository = new ConnectorRepository(objDCDTO);

                    if (Request.Form["btnTest"] != null)
                    {
                        objConnectorRepository.TestConnection();
                        return(Json(new { success = true, message = Resources.Resources.ConnectorTestMessage }));
                    }
                    else
                    {
                        objConnectorRepository.SaveConnection();
                        GetAllExistingConnections();
                        return(Json(new { success = true, message = Resources.Resources.ConnectorSaveMessage }));
                    }
                }
                catch (Exception ex)
                {
                    //ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                    //Response.StatusCode = 400;
                    //ModelState.AddModelError(string.Empty, ex.Message + ex.InnerException.Message);
                    //return Content(ex.Message + ex.InnerException.Message);

                    return(Json(new { success = false, message = ex.Message + ex.InnerException.Message }));
                }
            }
            else
            {
                return(Content(Resources.Resources.ConnectorValidationFailed));
            }
        }