Exemplo n.º 1
0
        //public List<ServerEntity> GetServerInfoByGuid(string[] GuidList, bool isWithPassword=false, bool bNeedSSO=false)
        //{
        //    m_Logger.DebugFormat("__{0}__: {1}: Enter Function", this.GetType().Name, MethodInfo.GetCurrentMethod().Name);
        //    DataTable dtResult = new DataTable();
        //    List<ServerEntity> ServerInfos = new List<ServerEntity>();
        //    string strGuidList = String.Join(",", GuidList);
        //    m_Logger.DebugFormat("__{0}__: {1}: strGuidList={2}, isWithPassword={3}", this.GetType().Name, MethodInfo.GetCurrentMethod().Name, strGuidList, isWithPassword.ToString());
        //    dtResult = ServerList.GetServer(m_DbConnectionString, strGuidList, isWithPassword);

        //    if (dtResult.Rows.Count > 0)
        //    {
        //        foreach (DataRow dr in dtResult.Rows)
        //        {
        //            ServerEntity se = new ServerEntity();

        //            se.ServerID = (dr["ServerID"] == null) ? null : dr["ServerID"].ToString();
        //            se.ServerName = (dr["ServerName"] == null) ? null : dr["ServerName"].ToString();
        //            se.DisplayName = (dr["DisplayName"] == null) ? null : dr["DisplayName"].ToString();
        //            se.ProductID = (dr["ProductID"] == null) ? null : dr["ProductID"].ToString();
        //            se.ProductVersion = (dr["ProductVersion"] == null) ? null : dr["ProductVersion"].ToString();
        //            se.ServerType = (dr["ServerType"] == null) ? -1 : Convert.ToInt32(dr["ServerType"].ToString());
        //            se.Protocol = (dr["Protocol"] == null) ? null : dr["Protocol"].ToString();
        //            se.Host = (dr["Host"] == null) ? null : dr["Host"].ToString();
        //            se.Port = (dr["Port"] == null) ? null : dr["Port"].ToString();
        //            se.UserID = (dr["UserID"] == null) ? null : dr["UserID"].ToString();
        //            se.Password = (dr["Password"] == null) ? null : dr["Password"].ToString();
        //            se.ProxyEnable = (dr["ProxyEnable"] == null) ? 0 : Convert.ToInt32(dr["ProxyEnable"].ToString());
        //            se.CreatedUserID = (dr["CreatedUserID"] == null) ? null : dr["CreatedUserID"].ToString();
        //            se.Others = (dr["Others"] == null) ? null : dr["Others"].ToString();
        //            se.ProxyID = (dr["ProxyID"] == null) ? null : dr["ProxyID"].ToString();
        //            se.ProxyDisplayName = (dr["ProxyDisplayName"] == null) ? null : dr["ProxyDisplayName"].ToString();
        //            se.ProxyProtocol = (dr["ProxyProtocol"] == null) ? null : dr["ProxyProtocol"].ToString();
        //            se.ProxyServerName = (dr["ProxyServerName"] == null) ? null : dr["ProxyServerName"].ToString();
        //            se.ProxyPort = (dr["ProxyPort"] == null) ? null : dr["ProxyPort"].ToString();
        //            se.ProxyUserID = (dr["ProxyUserID"] == null) ? null : dr["ProxyUserID"].ToString();
        //            se.ProxyPassword = (dr["ProxyPassword"] == null) ? null : dr["ProxyPassword"].ToString();

        //            SingleSignOnInfo ssoInfo = new SingleSignOnInfo();
        //            if (string.IsNullOrEmpty(dr["UserID"].ToString()) && bNeedSSO)
        //            {
        //                ssoInfo.SSOInfo = 1;
        //                string installPath = string.Empty;
        //                SystemConfigurationXmlWrapper sysCfg = new SystemConfigurationXmlWrapper(true);
        //                installPath = sysCfg.GetValueByParameterName("m_strTMS_InstallPath");
        //                Dictionary<string, string> dictSSOParameters = ServerList.GetSSOParameters(m_DbConnectionString, se.ServerID, installPath);
        //                // remove the SSO parameter used by policy deployment
        //                string host = string.Empty;
        //                if (dictSSOParameters.ContainsKey("TargetServerIP"))
        //                {
        //                    host = dictSSOParameters["TargetServerIP"]; // got from Uri.Host which is the hostname without port number
        //                    dictSSOParameters.Remove("TargetServerIP");
        //                }
        //                if (host != string.Empty)
        //                    se.Host = host;
        //                ssoInfo.SSOCookie = dictSSOParameters;
        //            }
        //            else
        //            {
        //                ssoInfo.SSOInfo = 0;
        //                ssoInfo.SSOCookie = null;
        //            }
        //            se.SSO = ssoInfo;

        //            ServerInfos.Add(se);
        //        }
        //    }
        //    m_Logger.DebugFormat("__{0}__: {1}: Leave Function", this.GetType().Name, MethodInfo.GetCurrentMethod().Name);
        //    return ServerInfos;
        //}

        public string[] GetServerGuidListByProductType(string strLogonUserGuid, string strProductID, string strPluginID)
        {
            m_Logger.DebugFormat("__{0}__: {1}: Enter Function", this.GetType().Name, MethodInfo.GetCurrentMethod().Name);
            m_Logger.DebugFormat("__{0}__: {1}: strLogonUserGuid={2}, strProductID={3}, strPluginID={4}", this.GetType().Name, MethodInfo.GetCurrentMethod().Name, strLogonUserGuid, strProductID, strPluginID);
            string[] ServerGuidList = { };
            try
            {
                using (ServerDatabaseUtility serverDB = new ServerDatabaseUtility(m_DbConnectionString))
                {
                    ServerGuidList = serverDB.QueryServerGuidListByProductType(strLogonUserGuid, strProductID, strPluginID);
                }
            }
            catch (SqlException ex)
            {
                m_Logger.ErrorFormat("__{0}__: {1}: SQL Exception={2}", this.GetType().Name, MethodInfo.GetCurrentMethod().Name, ex.ToString());
                throw;
            }
            catch (Exception ex)
            {
                m_Logger.ErrorFormat("__{0}__: {1}: Exception={2}", this.GetType().Name, MethodInfo.GetCurrentMethod().Name, ex.ToString());
                throw;
            }

            m_Logger.DebugFormat("__{0}__: {1}: Leave Function", this.GetType().Name, MethodInfo.GetCurrentMethod().Name);
            return(ServerGuidList);
        }
Exemplo n.º 2
0
        // parameters:
        //      cfg_dom 装入了 library.xml 的 XmlDocument 对象
        //      strDbName   被删除的数据库名
        // return:
        //      -1  验证过程出现错误(也就是说验证过程没有来的及完成)
        //      0   验证发现不正确
        //      1   验证发现正确
        public int VerifyDatabaseDelete(
            RmsChannel channel,
            string strDbType,
            string strDbName,
            out string strError)
        {
            int nRet = ServerDatabaseUtility.VerifyDatabaseDelete(this.LibraryCfgDom,
                                                                  strDbType,
                                                                  strDbName,
                                                                  out strError);

            if (nRet == -1)
            {
                return(-1);
            }

            if (string.IsNullOrEmpty(strDbType) == true)
            {
                strError = "strDbType 参数值不应为空";
                return(-1);
            }
            if (string.IsNullOrEmpty(strDbName) == true)
            {
                strError = "strDbName 参数值不应为空";
                return(-1);
            }

            // 实用库
            // 不用再验证。因为数据库名信息都在 LibraryCfgDom 里面了,上面已经验证过了

            string strDbTypeCaption = ServerDatabaseUtility.GetTypeCaption(strDbType);

            // 单个数据库
            if (ServerDatabaseUtility.IsSingleDbType(strDbType))
            {
                string dbname = GetSingleDbName(strDbType);
                if (string.IsNullOrEmpty(dbname) == false)
                {
                    strError = "删除完成后," + strDbTypeCaption + "库名 '" + strDbName + "' 在 LibraryApplication 的 相应成员(.???DbName)内没有清理干净";
                    return(0);
                }
            }

            // 书目库
            if (strDbType == "biblio")
            {
                // TODO: 在内存结构里面验证
            }

            // 单个书目库下属库
            if (ServerDatabaseUtility.IsBiblioSubType(strDbType) == true)
            {
                // TODO: 在内存结构里面验证
            }

            if (strDbType == "reader")
            {
                // TODO: 在内存结构里面验证
            }

            // 验证 dp2kernel 一端数据库是否被删除
            if (channel != null)
            {
                // 数据库是否已经存在?
                // return:
                //      -1  error
                //      0   not exist
                //      1   exist
                //      2   其他类型的同名对象已经存在
                nRet = DatabaseUtility.IsDatabaseExist(
                    channel,
                    strDbName,
                    out strError);
                if (nRet == -1)
                {
                    strError = "验证物理数据库 '" + strDbName + "' 在 dp2kernel 一端是否成功删除时发生错误: " + strError;
                    return(-1);
                }
                if (nRet >= 1)
                {
                    strError = "物理数据库 '" + strDbName + "' 在 dp2kernel 一端未被删除: " + strError;
                    return(-1);
                }
            }

            return(1);
        }