Example #1
0
        /// <summary>
        /// 保存连接信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult SaveConnectionConfig(SAPConnectionConfigViewModel model)
        {
            return(ExecuteFunctionRun(() =>
            {
                ActionResult result = new ActionResult(true, "");
                if (model.MaxPoolSize == 0)
                {
                    result.Message = "SAPConnectionConfig.Msg0"; result.Success = false; return Json(result);
                }                                                                                                                        //TODO 信息提示
                // 更新到服务器
                try
                {
                    OThinker.H3.BizBus.SAPConnector.SAPConnectionConfig config = SAPClient.Connector.GetConfig(model.Name);//.GetDefaultConfig();
                    if (config == null)
                    {
                        config = new OThinker.H3.BizBus.SAPConnector.SAPConnectionConfig();
                    }
                    else if (string.IsNullOrWhiteSpace(model.ObjectID))//如果是新增,提示已经存在
                    {
                        //this.ShowWarningMessage(this.PortalResource.GetString("EditSAPConnectionConfig_NameExist"));
                        result.Success = false;
                        result.Message = "SAPConnectionConfig.NameExist";//TODO
                        return Json(result, JsonRequestBehavior.AllowGet);
                    }
                    config.AppServerHost = model.AppserverHost;
                    config.Client = model.Client;
                    config.ConnectionName = model.Name;
                    config.Language = model.Language;
                    config.LoginPassword = model.LoginPassword;
                    config.LoginUser = model.LoginUser;
                    config.MaxPoolSize = model.MaxPoolSize;
                    config.SystemNumber = model.SystemNumber;

                    if (SAPClient.Connector.SaveConfig(config))
                    {
                        // ShowSuccessMessage(this.PortalResource.GetString("Msg_UpdateSuccess"));
                        result.Message = "SAPConnectionConfig.SaveSuccess";
                        //this.CloseCurrentDialog();
                    }
                    else
                    {
                        result.Success = false;
                        result.Message = "SAPConnectionConfig.SaveSuccess";
                        //ShowWarningMessage(this.PortalResource.GetString("EditSAPConnectionConfig_Msg1"));
                    }
                }
                catch (Exception ex)
                {
                    result.Success = false;
                    result.Message = "SAPConnectionConfig.SaveFailed";
                    result.Extend = ex.Message;
                    //this.ShowWarningMessage(this.PortalResource.GetString("EditSAPConnectionConfig_Msg2"));
                    //return;
                }

                return Json(result, JsonRequestBehavior.AllowGet);
            }));
        }
Example #2
0
        /// <summary>
        /// 获取连接信息
        /// </summary>
        /// <param name="connectionName"></param>
        /// <returns></returns>
        public JsonResult GetConnectionConfig(string connectionName)
        {
            return(ExecuteFunctionRun(() =>
            {
                SAPConnectionConfigViewModel model = new SAPConnectionConfigViewModel();
                OThinker.H3.BizBus.SAPConnector.SAPConnectionConfig config = SAPClient.Connector.GetConfig(connectionName);
                if (config != null)
                {
                    model.Name = config.ConnectionName;
                    model.AppserverHost = config.AppServerHost;
                    model.Client = config.Client;
                    model.Language = config.Language;
                    model.LoginUser = config.LoginUser;
                    model.LoginPassword = config.LoginPassword;
                    model.MaxPoolSize = config.MaxPoolSize;
                    model.SystemNumber = config.SystemNumber;
                    model.ObjectID = config.ObjectID;//区分更新和新增
                }

                return Json(model, JsonRequestBehavior.AllowGet);
            }));
        }