예제 #1
0
        private void GetListCount(ref PendingStatusCompareResult result)
        {
            try
            {
                var request = string.Format(SearchRequestListingCount, GetLoginText(_loginTrace), result.ModuleId,
                                            DateTime.Now.AddYears(-10).ToString("MM/dd/yyyyTHH:mm:ss") + "-" +
                                            DateTime.Now.ToString("MM/dd/yyyyTHH:mm:ss"));
                result.QaListingCount        = PsaHelper.GetListingCount(request, ConfigurationManager.AppSettings["TcsQaUrl"]);
                result.ProdutionListingCount = PsaHelper.GetListingCount(request, "");

                if (result.QaListingCount > 0 && result.ProdutionListingCount > 0)
                {
                    result.IncreaseInActiveCounts = ((int)(0.5f + 100f * (result.QaListingCount - result.ProdutionListingCount) / result.ProdutionListingCount)).ToString(CultureInfo.InvariantCulture) + "%";
                }
                if (!string.IsNullOrEmpty(result.CurrentRdcPendingStatus))
                {
                    result.RdcCurrentPendingListingCount = SearchByTmkCountRequest(result,
                                                                                   result.CurrentRdcPendingStatus,
                                                                                   _loginTrace);
                }
            }
            catch (Exception ex)
            {
                Log.Error(typeof(PsaManager), "Failed to get list count for Module ID: " + result.ModuleId + ex.Message + ex.StackTrace);
            }
        }
예제 #2
0
        private int SearchByTmkCountRequest(PendingStatusCompareResult compareResult, string status, LoginInfo loginInfo)
        {
            try
            {
                string statusName;
                string statusValue;
                string lastModidfyFieldName;
                string lastMoidfyFieldValue;
                var    helper = new PsaHelper();
                PsaHelper.GetStatusInfo(compareResult, status, out statusName, out statusValue, out lastModidfyFieldName,
                                        out lastMoidfyFieldValue);

                if (!string.IsNullOrEmpty(compareResult.CurrentRdcPendingStatus))
                {
                    var request = string.Format(SearchTMKCountRequest, GetLoginText(loginInfo),
                                                compareResult.BoardId.ToString(CultureInfo.InvariantCulture),
                                                PsaHelper.EncodeXml(compareResult.PropertyClass), statusName,
                                                statusValue, loginInfo.ByPassAuthentication);
                    return(PsaHelper.GetListingCount(request, ""));
                }
            }
            catch (Exception ex)
            {
                Log.Error(typeof(PsaManager), ex.Message);
            }

            return(0);
        }
예제 #3
0
        private string GetLoginText(LoginInfo loginInfo)
        {
            var result = string.Format(LoginNodeText, PsaHelper.EncodeXml(loginInfo.UserName),
                                       PsaHelper.EncodeXml(loginInfo.Password),
                                       loginInfo.UserAgent, PsaHelper.EncodeXml(loginInfo.UaPassword));

            return(result);
        }
예제 #4
0
        public void CompareTcsRdcActivePendingStatus(PendingStatusCompareResult compareResult, StreamWriter streamWriterReport)
        {
            try
            {
                var helper      = new PsaHelper();
                var connections = helper.GetDefConnections(compareResult.ModuleId);

                foreach (var connection in connections)
                {
                    _loginTrace = null;
                    if (connection.connection_name.EndsWith(".sql", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    if (!connection.connection_name.EndsWith("re.def", StringComparison.OrdinalIgnoreCase) &&
                        !connection.connection_name.EndsWith("al.def", StringComparison.OrdinalIgnoreCase) &&
                        !connection.connection_name.EndsWith("cp.def", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    var resultByPropertyClass = new PendingStatusCompareResult
                    {
                        ModuleId       = compareResult.ModuleId,
                        ModuleName     = compareResult.ModuleName,
                        PropertyClass  = connection.connection_type,
                        ConnectionName = connection.connection_name,
                        DefFilePath    = connection.definition_file,
                        RdcCode        = compareResult.RdcCode,
                        BoardId        = connection.board_id ?? 0
                    };
                    helper.AnalyzeDef(ref resultByPropertyClass);
                    if (resultByPropertyClass.IsNotAvailableForOrca || resultByPropertyClass.IsOpenHouseOnlyModule)
                    {
                        continue;
                    }
                    CheckRdcAccountAccess(ref resultByPropertyClass);
                    if (resultByPropertyClass.IsDataSourceRemoved)
                    {
                        continue;
                    }

                    if (_loginTrace != null)
                    {
                        GetListCount(ref resultByPropertyClass);
                    }
                    helper.WriteToReport(streamWriterReport, resultByPropertyClass);
                    break;
                }
            }
            catch (Exception ex)
            {
                Log.Error(typeof(PsaManager), "Module ID = " + compareResult.ModuleId + "\r\n" + ex.Message + ex.StackTrace);
            }
        }
예제 #5
0
        private Enums.CheckAccountReturnCode SearchByTmkRequest(PendingStatusCompareResult compareResult, string status, LoginInfo loginInfo)
        {
            string statusName;
            string statusValue;
            string lastModidfyFieldName;
            string lastMoidfyFieldValue;
            var    helper = new PsaHelper();

            PsaHelper.GetStatusInfo(compareResult, status, out statusName, out statusValue, out lastModidfyFieldName, out lastMoidfyFieldValue);

            if (!string.IsNullOrEmpty(statusValue))
            {
                var request = string.Format(SearchRequest, GetLoginText(loginInfo),
                                            compareResult.BoardId.ToString(CultureInfo.InvariantCulture),
                                            PsaHelper.EncodeXml(compareResult.PropertyClass), statusName, statusValue, loginInfo.ByPassAuthentication);
                //, lastModidfyFieldName, DateTime.Now.AddYears(-10).ToString("MM/dd/yyyyTHH/mm/ss") + "-" + DateTime.Now.ToString("MM/dd/yyyyTHH/mm/ss"));
                return(helper.CheckRdcAccount(request));
            }

            return(Enums.CheckAccountReturnCode.NoRecordFound);
        }
        public BoardCredentials getRDCOtherCredentials(BoardCredentials BoardCreds, StreamWriter streamWriterReport)
        {
            try
            {
                var    helper     = new PsaHelper();
                char[] delimiters = new char[] { ',' };
                string dsid       = BoardCreds.DatasourceId;
                BoardCreds.ModuleId = helper.GetOtherModuleId(dsid);

                string    retsLoginURL = "";
                LoginInfo loginInfo    = helper.GetDataAggTraceInfoExtra(BoardCreds.DatasourceId, BoardCreds.ModuleId, ref retsLoginURL, "TCS", "REALListing");

                string DefFilePath = "";
                string loginType   = "";

                var connections = helper.GetDefConnections(BoardCreds.ModuleId);
                if (connections != null)
                {
                    foreach (var connection in connections)
                    {
                        if (string.IsNullOrWhiteSpace(retsLoginURL) == false && string.IsNullOrWhiteSpace(loginType) == false)
                        {
                            break;
                        }
                        if (!connection.connection_name.EndsWith(".sql", StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }
                        DefFilePath = connection.definition_file;

                        var iniReader = new IniFile(connection.definition_file);
                        var tcpIp     = iniReader.Read("TcpIp", "Common");

                        if (tcpIp == "14")
                        {
                            //Check DEF
                            loginType         = "Master";
                            BoardCreds.isRets = true;
                        }
                        else if (tcpIp == "9" || tcpIp == "11" || tcpIp == "13")
                        {
                            loginType         = "AgentCredentials";
                            BoardCreds.isRets = true;
                        }
                        else
                        {
                            BoardCreds.isRets = false;
                        }
                        if (string.IsNullOrWhiteSpace(retsLoginURL) == true)
                        {
                            var mainscript = iniReader.GetSectionContent("MainScript");
                            retsLoginURL = getURL(mainscript);
                        }
                    }
                }

                BoardCreds.IsValidCredential = false;
                if (loginInfo != null)
                {
                    BoardCreds.IsValidCredential = true;
                    BoardCreds.RETSURL           = retsLoginURL;
                    BoardCreds.LoginType         = loginType;
                    BoardCreds.Username          = loginInfo.UserName;
                    BoardCreds.Password          = loginInfo.Password;
                    BoardCreds.UserAgent         = loginInfo.UserAgent;
                    BoardCreds.UserAgentPass     = loginInfo.UaPassword;

                    writetofile(BoardCreds, streamWriterReport);
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(BoardCreds);
        }
        public BoardCredentials getCredentials(BoardCredentials BoardCreds, StreamWriter streamWriterReport)
        {
            TCSEntities           tcsDb     = null;
            TCSEntitiesProduction tcsproddb = null;

            tcsDb     = new TCSEntities();
            tcsproddb = new TCSEntitiesProduction();
            try
            {
                var    helper      = new PsaHelper();
                var    connections = helper.GetDefConnections(BoardCreds.ModuleId);
                bool   credsfound  = false;
                char[] delimiters  = new char[] { ',' };

                string DefFilePath = "";

                string mid = Convert.ToString(BoardCreds.ModuleId);
                BoardCreds.DatasourceId = helper.GetDataSourceId(mid);

                foreach (var connection in connections)
                {
                    if (credsfound == true)
                    {
                        continue;
                    }
                    if (connection.connection_name.EndsWith(".sql", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    DefFilePath = connection.definition_file;
                    //BoardId = connection.board_id ?? 0;
                    var iniReader = new IniFile(connection.definition_file);
                    var tcpIp     = iniReader.Read("TcpIp", "Common");
                    //var HTTPUserAgent = iniReader.Read("SecList", "HttpUserAgent");
                    ////var RetsUAUserAgent = iniReader.Read("SecList", "RetsUAUserAgent");
                    ////var RetsUAPwd = iniReader.Read("SecList", "RetsUAPwd");
                    //var SecList = iniReader.GetSectionContent("SecList");
                    //var mainscript = iniReader.GetSectionContent("MainScript");

                    //string RetsUAUserAgent = ParseSecList(SecList,"RetsUAUserAgent");
                    //string RetsUAPwd = ParseSecList(SecList, "RetsUAPwd");

                    BoardCreds.UserAgent     = "";
                    BoardCreds.UserAgentPass = "";

                    if (tcpIp == "14")
                    {
                        //Check DEF
                        BoardCreds.LoginType         = "Master";
                        BoardCreds.Username          = "******";
                        BoardCreds.Password          = "******";
                        BoardCreds.IsValidCredential = true;
                        BoardCreds.isRets            = true;
                        return(BoardCreds);
                    }
                    else if (tcpIp == "9" || tcpIp == "11" || tcpIp == "13")
                    {
                        BoardCreds.LoginType = "AgentCredentials";
                        BoardCreds.isRets    = true;
                    }
                    else
                    {
                        BoardCreds.isRets            = false;
                        BoardCreds.IsValidCredential = false;
                        return(BoardCreds);
                    }
                    //Check DB
                    credsfound = true;
                    //BoardCreds.RETSURL = getURL(mainscript);

                    try
                    {
                        var AssociatedBoards = from boards in tcsproddb.cma_mls_boards
                                               where (boards.module_id == BoardCreds.ModuleId)
                                               select boards.board_id;



                        foreach (var Board in AssociatedBoards)
                        {
                            BoardCreds.BoardId = Board;
                            DateTime dt          = DateTime.Now.AddDays(-30);
                            var      UniqueUsers = from users in tcsproddb.tcs_request_log
                                                   join errors in tcsproddb.tcs_error_log on users.request_id equals errors.request_id into fg
                                                   from fgi in fg.DefaultIfEmpty()
                                                   where (users.client_name == "TMK" || users.client_name == "TPO" || users.client_name == "TMKListingAlert") &&
                                                   (users.board_id == Board) && (users.when_created > dt) && (fgi.error_code == null)
                                                   orderby users.when_created descending
                                                   group users by users.mls_user_name into uTable
                                                   select new { USER = uTable.Key, LOCATION = uTable.Max(x => x.location_path) };
                            int i = 0;
                            foreach (var user in UniqueUsers)
                            {
                                if ((user.USER != "") && (user.LOCATION != ""))
                                {
                                    if (BoardCreds.ModuleId == 2360)
                                    {
                                        if (user.USER.IndexOf("fl.") > -1)
                                        {
                                            continue;
                                        }
                                    }

                                    try
                                    {
                                        System.IO.StreamReader log;
                                        log = new System.IO.StreamReader(user.LOCATION);
                                        string copiedlog = log.ReadToEnd();
                                        log.Close();
                                        int startsub = copiedlog.IndexOf("<Login>") + 7;
                                        int endsub   = copiedlog.IndexOf("</Login>") - startsub;

                                        string logininfo = copiedlog.Substring(startsub, endsub);
                                        logininfo = logininfo.Replace("<password>", ",");
                                        logininfo = logininfo.Replace("</password>", ",");

                                        string[] creds = logininfo.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

                                        if (creds.Length > 0)
                                        {
                                            BoardCreds.Username = creds[0];
                                        }
                                        if (creds.Length > 1)
                                        {
                                            BoardCreds.Password = creds[1];
                                        }

                                        writetofile(BoardCreds, streamWriterReport);
                                        BoardCreds.IsValidCredential = true;
                                        i++;
                                        if (i > 0)
                                        {
                                            break;
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                        }

                        if (String.IsNullOrEmpty(BoardCreds.Username))
                        {
                            var query = (from users in tcsDb.CleanLogins1
                                         where (users.module_id.Equals(mid))
                                         select new { Username = users.user_name, Password = users.password });
                            var agentCredential = query.FirstOrDefault();
                            if (agentCredential == null)
                            {
                                query = (from users in tcsDb.tcs_clean_loggins
                                         where (users.module_id.Equals(BoardCreds.ModuleId))
                                         select new { Username = users.user_name, Password = users.password });
                                agentCredential = query.FirstOrDefault();
                            }

                            BoardCreds.Username          = agentCredential.Username;
                            BoardCreds.Password          = agentCredential.Password;
                            BoardCreds.IsValidCredential = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                tcsDb.Dispose();
                tcsproddb.Dispose();
            }
            return(BoardCreds);
        }
예제 #8
0
        private void CheckRdcAccountAccess(ref PendingStatusCompareResult compareResult)
        {
            try
            {
                GetTraceLogin(ref compareResult);
                if (compareResult.IsDataSourceRemoved)
                {
                    return;
                }

                if (string.IsNullOrEmpty(compareResult.PendingGap))
                {
                    compareResult.TestResult = PsaConstants.NoGapExisted;
                    return;
                }

                if (_loginTrace != null)
                {
                    var helper = new PsaHelper();
                    foreach (
                        var item in
                        (compareResult.TcsPending ?? "" + "," + compareResult.PendingGap + "," + compareResult.RdcPending).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Distinct())
                    {
                        var returnCode = SearchByTmkRequest(compareResult, item, _loginTrace);
                        if (returnCode == Enums.CheckAccountReturnCode.RequestFailed60310)
                        {
                            returnCode = SearchByTmkRequest(compareResult, item, _loginTrace);
                            if (returnCode == Enums.CheckAccountReturnCode.RequestFailed60310)
                            {
                                returnCode = SearchByTmkRequest(compareResult, item, _loginTrace);
                            }
                        }
                        ProcessSearchResult(returnCode, ref compareResult, item);
                    }
                    helper.AnlyzeAccountAccessResult(ref compareResult);
                    if (!string.IsNullOrEmpty(compareResult.StatusRdcAccountReturnNoRecord))
                    {
                        foreach (
                            var item in
                            (compareResult.StatusRdcAccountReturnNoRecord).Split(
                                new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Distinct())
                        {
                            CheckTpAccountAccess(ref compareResult, item);
                        }
                        compareResult.StatusHasNoListing = PsaHelper.FindGap(
                            compareResult.TpHasAccessStatusInRemainGap, compareResult.StatusRdcAccountReturnNoRecord);
                    }
                    else
                    {
                        compareResult.IsTpAccountLoginSuccess = true;
                    }
                }
                else
                {
                    compareResult.TestResult = PsaConstants.ResultError + " -- Cannot retrieve RDC credential";
                }
            }
            catch (Exception ex)
            {
                Log.Error(typeof(PsaManager), ex.Message + ex.StackTrace);
            }
        }