Esempio n. 1
0
        public string GetDataSourceId(string moduleId)
        {
            string      dataSourceId = string.Empty;
            TCSEntities tcsDb        = null;

            tcsDb = new TCSEntities();

            try
            {
                var datasource = from di in tcsDb.mls_vendor
                                 where (di.moduleid == moduleId)
                                 select di.mlsid;


                dataSourceId = datasource.First();
            }
            catch (Exception ex1)
            {
                dataSourceId = string.Empty;
                Console.WriteLine(ex1.Message + " Failed to get datasource id for " + moduleId);
            }
            finally
            {
                tcsDb.Dispose();
            }

            return(dataSourceId);
        }
Esempio n. 2
0
        public short GetModuleId(string dataSourceId)
        {
            short       moduleId = 0;
            TCSEntities tcsDb    = null;

            tcsDb = new TCSEntities();

            try
            {
                var module = from di in tcsDb.mls_vendor
                             where (di.mlsid == dataSourceId)
                             select di.moduleid;


                moduleId = Int16.Parse(module.First());
            }
            catch (Exception ex1)
            {
                moduleId = 0;
                Console.WriteLine(ex1.Message + " Failed to get module id for " + dataSourceId);
            }
            finally
            {
                tcsDb.Dispose();
            }
            return(moduleId);
        }
Esempio n. 3
0
        public void GetLoginfromDB(ModuleLoginContainer compareResult, StreamWriter streamWriterReport)
        {
            var LoginInfo = new ModuleLoginContainer();

            try
            {
                bool loginInfoExistsInTCS = false;
                using (var tcsDb = new TCSEntities())
                {
                    short moduleId = Convert.ToInt16(compareResult.ModuleId);
                    if (tcsDb.tcs_rets_connection_info.Any(x => x.module_id == moduleId))
                    {
                        loginInfoExistsInTCS = true;
                        var qe = tcsDb.tcs_rets_connection_info.Where(x => x.module_id == moduleId).FirstOrDefault();
                        compareResult.LoginURL      = qe.login_url;
                        compareResult.LoginUserName = qe.user_name;
                        compareResult.LoginPassword = qe.password;
                        compareResult.UserAgent     = qe.user_agent;
                        compareResult.UserAgentPW   = qe.ua_password;
                    }
                }
                if (!loginInfoExistsInTCS)
                {
                    using (SystemEntities se = new SystemEntities())
                    {
                        se.Connection.Open();
                        ObjectResult <spDA_RETSConnectionInfo_sel_Result> loginTrace =
                            se.spDA_RETSConnectionInfo_sel(compareResult.RdcCode, false);
                        foreach (var connInfo in loginTrace)
                        {
                            compareResult.LoginURL      = connInfo.RETSLoginURL;
                            compareResult.LoginUserName = connInfo.RETSUserName;
                            compareResult.LoginPassword = connInfo.RETSPassword;
                            compareResult.UserAgent     = connInfo.RETSUserAgent;
                            compareResult.UserAgentPW   = connInfo.RETSUserAgentPassword;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to access DataAgg db\r\n" + ex.Message + ex.Source + ex.StackTrace);
            }
        }
        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);
        }
Esempio n. 5
0
        private static void StartOpenHouseReport(ref List <string> filePaths, ref StringBuilder sbDeletedDataSources)
        {
            string lastdatasourceid          = "";
            string lastdatasourceiddeleted   = "";
            bool   previousIsValidCredential = false;

            TCSEntities tcsDb = null;

            try
            {
                tcsDb = new TCSEntities();

                var moduleList = tcsDb.ExecuteStoreQuery <ModuleEntity>(string.Format(Query, "pm.DSID", "tcs.dbo.rdc_modules"), null);

                using (var sw = new StreamWriter(string.Format(@"{0}\speedup\CredentialReportOpenHouse" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv", ConfigurationManager.AppSettings["Drive"]), false))
                {
                    sw.WriteLine(ReportHeader);
                    ListhubSearch ls = new ListhubSearch("module_id,mls_name,data_source_id,resource_type,resource,class,search_limit,search_format,count_records,key_field,dqml_query,start_datetime_field_name,start_datetime_field_format_low,start_datetime_field_format_delimiter,start_datetime_field_format_high,end_datetime_field_name,end_datetime_field_format_low,end_datetime_field_format_delimiter,end_datetime_field_format_high,datetime_field_operation,raw_dmql_query\r\n");
                    ls.DmqlFilePath  = string.Format(@"{0}\listhub\DMQLOpenHouse-", ConfigurationManager.AppSettings["Drive"]);
                    ls.LoginFilePath = string.Format(@"{0}\listhub\CleanLoginsOpenHouse-", ConfigurationManager.AppSettings["Drive"]);
                    int           i                 = 0;
                    var           helper            = new PsaHelper();
                    List <string> validModuleIDList = helper.GetValidModuleIDs();
                    foreach (var module in moduleList)
                    {
                        if (!validModuleIDList.Contains(module.ModuleId.ToString()))
                        {
                            continue;
                        }
                        if (!helper.ExistDataSource(module.DatasourceId))
                        {
                            string datasourceidtodelete = helper.GetExactDataSourceId(module.ModuleId.ToString(), module.DatasourceId);
                            //notify by email
                            if (!string.IsNullOrWhiteSpace(datasourceidtodelete) && !datasourceidtodelete.Equals(lastdatasourceiddeleted))
                            {
                                lastdatasourceiddeleted = datasourceidtodelete;
                                sbDeletedDataSources.AppendFormat(TABLELINE, module.DatasourceId, module.ModuleId, module.ModuleName);
                                sbDeletedDataSources.AppendLine();
                            }
                            continue;
                        }
                        var manager = new CredentialGatheringManager();
                        BoardCredentials BoardInfo = new BoardCredentials();
                        if (module.DatasourceId.Equals(lastdatasourceid) && previousIsValidCredential)
                        {
                            continue;
                        }
                        if (string.IsNullOrWhiteSpace(module.DatasourceId))
                        {
                            continue;
                        }
                        lastdatasourceid       = module.DatasourceId;
                        BoardInfo.DatasourceId = module.DatasourceId;
                        BoardInfo.ModuleName   = module.ModuleName.Replace(",", "-");
                        BoardInfo = manager.getOpenHouseCredentials(BoardInfo, sw);
                        //if (!BoardInfo.IsValidCredential) BoardInfo = manager.getRDCOtherCredentials(BoardInfo, sw);
                        previousIsValidCredential = BoardInfo.IsValidCredential;
                        if (true)// (BoardInfo.IsValidCredential)
                        {
                            ls.openhouseSearch(Convert.ToString(BoardInfo.BoardId), Convert.ToString(BoardInfo.ModuleId), Convert.ToString(BoardInfo.DatasourceId), BoardInfo);
                            i++;
                            //if (i > 80)
                            //    break;
                        }
                    }
                    ls.WriteToFile();
                    filePaths.Add(ls.LoginFilePath);
                    filePaths.Add(ls.DmqlFilePath);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error message:{0}", ex.Message);
                if (tcsDb != null)
                {
                    tcsDb.Dispose();
                }
            }
        }
Esempio n. 6
0
        private static void StartRDCRosterReport(ref List <string> filePaths, ref StringBuilder sbDeletedDataSources)
        {
            string lastdatasourceid          = "";
            string lastdatasourceiddeleted   = "";
            bool   previousIsValidCredential = false;

            TCSEntities tcsDb = null;

            try
            {
                //                string query = @"SELECT distinct cmm.module_id as ModuleId, module_name as ModuleName,cmb.board_id as BoardId FROM [TCS].[dbo].[cma_mls_modules] cmm, tcs.dbo.cma_mls_boards cmb, tcs.dbo.prosoft_modules pm
                //    where cmm.module_id=cmb.module_id and cmm.module_id = pm.ShippingID order by ModuleId";// and pm.ShippingID=1796
                //                string query = @"SELECT distinct cmb.module_id as ModuleId, module_name as ModuleName,cmb.board_id as BoardId FROM [TCS].[dbo].[tcs_request_log] trl, tcs.dbo.cma_mls_boards cmb, tcs.dbo.cma_mls_modules cmm
                //  where trl.board_id = cmb.board_id and cmm.module_id=cmb.module_id and (client_name = 'tpo' or client_name = 'tmk' or client_name= 'ORCA')";
                //                string query = @"SELECT distinct cmb.module_id as ModuleId, module_name as ModuleName, cmb.board_id as BoardId
                //  FROM tcs.dbo.tcs_request_log trl inner join tcs.dbo.cma_mls_boards cmb on trl.board_id=cmb.board_id inner join tcs.dbo.cma_mls_modules cmm on cmm.module_id = cmb.module_id
                //  left join tcs.dbo.tcs_error_log tel on trl.request_id=tel.request_id
                //  where (client_name = 'tpo' or client_name = 'tmk') and tel.error_code is null and module_name not like '%Orca%Only%' and cmb.module_id not in (1686, 2333, 1101) and cmb.module_id in (1015,1115)
                //  order by ModuleId";// and cmm.module_id=1015";
                tcsDb = new TCSEntities();

                //var args = new DbParameter[] { new SqlParameter { } };
                var moduleList = tcsDb.ExecuteStoreQuery <ModuleEntity>(string.Format(Query, "pm.DSID", "tcs.dbo.rdc_modules"), null);
                //var UniqueUsers = from trl in tcsproddb.tcs_request_log
                //                  join cmb in tcsproddb.cma_mls_boards on trl.board_id equals cmb.board_id
                //                  join cmm in tcsproddb.cma_mls_modules on cmb.module_id equals cmm.module_id
                //                  where (users.client_name == "TMK" || users.client_name == "TPO")
                //                      && (users.board_id == Board) && tel.error_code != 60310
                //                  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) };
                //var moduleList = from boards in tcsDb.cma_mls_boards
                //                 join modules in tcsDb.cma_mls_modules on boards.module_id equals modules.module_id
                //                 where (boards.board_status_id == 1)
                //                 && (boards.type == "Internet")
                //                 select new { boards.board_id, boards.module_id, modules.module_name };
                //tcsDb.Dispose();

                using (var sw = new StreamWriter(string.Format(@"{0}\speedup\CredentialReportRDCRoster" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv", ConfigurationManager.AppSettings["Drive"]), false))
                {
                    sw.WriteLine(ReportHeader);
                    ListhubSearch ls = new ListhubSearch("module_id,mls_name,data_source_id,resource_type,resource,class,search_limit,search_format,count_records_active,count_records_sold,count_records_offmarket,last_modified_date_field,sold_date_field,key_field,status_active_dqml_query,status_sold_dqml_query,status_offmarket_dqml_query\r\n");
                    ls.DmqlFilePath  = string.Format(@"{0}\listhub\DMQLRDCRoster-", ConfigurationManager.AppSettings["Drive"]);
                    ls.LoginFilePath = string.Format(@"{0}\listhub\CleanLoginsRDCRoster-", ConfigurationManager.AppSettings["Drive"]);
                    int           i                 = 0;
                    var           helper            = new PsaHelper();
                    List <string> validModuleIDList = helper.GetValidModuleIDs();
                    foreach (var module in moduleList)
                    {
                        if (!validModuleIDList.Contains(module.ModuleId.ToString()))
                        {
                            continue;
                        }
                        if (!helper.ExistDataSource(module.DatasourceId))
                        {
                            string datasourceidtodelete = helper.GetExactDataSourceId(module.ModuleId.ToString(), module.DatasourceId);
                            //notify by email
                            if (!string.IsNullOrWhiteSpace(datasourceidtodelete) && !datasourceidtodelete.Equals(lastdatasourceiddeleted))
                            {
                                lastdatasourceiddeleted = datasourceidtodelete;
                                sbDeletedDataSources.AppendFormat(TABLELINE, module.DatasourceId, module.ModuleId, module.ModuleName);
                                sbDeletedDataSources.AppendLine();
                            }
                            continue;
                        }
                        var manager = new CredentialGatheringManager();
                        BoardCredentials BoardInfo = new BoardCredentials();
                        if (module.DatasourceId.Equals(lastdatasourceid) && previousIsValidCredential)
                        {
                            continue;
                        }
                        if (string.IsNullOrWhiteSpace(module.DatasourceId))
                        {
                            continue;
                        }
                        lastdatasourceid       = module.DatasourceId;
                        BoardInfo.DatasourceId = module.DatasourceId;
                        BoardInfo.ModuleName   = module.ModuleName.Replace(",", "-");
                        BoardInfo = manager.getRDCRosterCredentials(BoardInfo, sw);
                        previousIsValidCredential = BoardInfo.IsValidCredential;
                        if (true)// (BoardInfo.IsValidCredential)
                        {
                            ls.rosterRDCSearch(Convert.ToString(BoardInfo.BoardId), Convert.ToString(BoardInfo.ModuleId), Convert.ToString(BoardInfo.DatasourceId), BoardInfo);
                            i++;
                            //if (i > 80)
                            //    break;
                        }
                    }
                    ls.WriteToFile();
                    filePaths.Add(ls.LoginFilePath);
                    filePaths.Add(ls.DmqlFilePath);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error message:{0}", ex.Message);
                if (tcsDb != null)
                {
                    tcsDb.Dispose();
                }
            }
        }
Esempio n. 7
0
        private static void StartRosterReport(ref List <string> filePaths)
        {
            short       lastmodule = 0;
            TCSEntities tcsDb      = null;

            try
            {
                //                string query = @"SELECT distinct cmm.module_id as ModuleId, module_name as ModuleName,cmb.board_id as BoardId FROM [TCS].[dbo].[cma_mls_modules] cmm, tcs.dbo.cma_mls_boards cmb, tcs.dbo.prosoft_modules pm
                //    where cmm.module_id=cmb.module_id and cmm.module_id = pm.ShippingID order by ModuleId";// and pm.ShippingID=1796
                //                string query = @"SELECT distinct cmb.module_id as ModuleId, module_name as ModuleName,cmb.board_id as BoardId FROM [TCS].[dbo].[tcs_request_log] trl, tcs.dbo.cma_mls_boards cmb, tcs.dbo.cma_mls_modules cmm
                //  where trl.board_id = cmb.board_id and cmm.module_id=cmb.module_id and (client_name = 'tpo' or client_name = 'tmk' or client_name= 'ORCA')";
                //                string query = @"SELECT distinct cmb.module_id as ModuleId, module_name as ModuleName, cmb.board_id as BoardId
                //  FROM tcs.dbo.tcs_request_log trl inner join tcs.dbo.cma_mls_boards cmb on trl.board_id=cmb.board_id inner join tcs.dbo.cma_mls_modules cmm on cmm.module_id = cmb.module_id
                //  left join tcs.dbo.tcs_error_log tel on trl.request_id=tel.request_id
                //  where (client_name = 'tpo' or client_name = 'tmk') and tel.error_code is null and module_name not like '%Orca%Only%' and cmb.module_id not in (1686, 2333, 1101) and cmb.module_id in (1015,1115)
                //  order by ModuleId";// and cmm.module_id=1015";
                tcsDb = new TCSEntities();

                //var args = new DbParameter[] { new SqlParameter { } };
                var moduleList = tcsDb.ExecuteStoreQuery <ModuleEntity>(string.Format(Query, "''", "tcs.dbo.prosoft_modules"), null);
                //var UniqueUsers = from trl in tcsproddb.tcs_request_log
                //                  join cmb in tcsproddb.cma_mls_boards on trl.board_id equals cmb.board_id
                //                  join cmm in tcsproddb.cma_mls_modules on cmb.module_id equals cmm.module_id
                //                  where (users.client_name == "TMK" || users.client_name == "TPO")
                //                      && (users.board_id == Board) && tel.error_code != 60310
                //                  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) };
                //var moduleList = from boards in tcsDb.cma_mls_boards
                //                 join modules in tcsDb.cma_mls_modules on boards.module_id equals modules.module_id
                //                 where (boards.board_status_id == 1)
                //                 && (boards.type == "Internet")
                //                 select new { boards.board_id, boards.module_id, modules.module_name };
                //tcsDb.Dispose();

                using (var sw = new StreamWriter(string.Format(@"{0}\speedup\CredentialReportRoster" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv", ConfigurationManager.AppSettings["Drive"]), false))
                {
                    sw.WriteLine(ReportHeader);
                    //ListhubSearch ls = new ListhubSearch("module_id,mls_name,data_source_id,resource_type,resource,class,search_limit,search_format,count_records,dqml_query\r\n");
                    ListhubSearch ls = new ListhubSearch();
                    ls.DmqlFilePath  = string.Format(@"{0}\listhub\DMQLRoster-", ConfigurationManager.AppSettings["Drive"]);
                    ls.LoginFilePath = string.Format(@"{0}\listhub\CleanLoginsRoster-", ConfigurationManager.AppSettings["Drive"]);
                    int           i                 = 0;
                    var           helper            = new PsaHelper();
                    List <string> validModuleIDList = helper.GetValidModuleIDs();
                    foreach (var module in moduleList)
                    {
                        if (!validModuleIDList.Contains(module.ModuleId.ToString()))
                        {
                            continue;
                        }
                        var manager = new CredentialGatheringManager();
                        BoardCredentials BoardInfo = new BoardCredentials();
                        if (module.ModuleId != 1676 &&
                            module.ModuleId != 1972 &&
                            module.ModuleId != 1774 &&
                            module.ModuleId != 1751 &&
                            module.ModuleId != 1461 &&
                            module.ModuleId != 2842 &&
                            module.ModuleId != 2631 &&
                            module.ModuleId != 2357 &&
                            module.ModuleId != 2034 &&
                            module.ModuleId != 2038 &&
                            module.ModuleId != 2407 &&
                            module.ModuleId != 2022 &&
                            module.ModuleId != 2076 &&
                            module.ModuleId != 1966 &&
                            module.ModuleId != 2504 &&
                            module.ModuleId != 2656 &&
                            module.ModuleId != 2620 &&
                            module.ModuleId != 2485 &&
                            module.ModuleId != 1910 &&
                            module.ModuleId != 1765 &&
                            module.ModuleId != 1832 &&
                            module.ModuleId != 1335)
                        {
                            continue;
                        }
                        if (module.ModuleId == lastmodule)
                        {
                            continue;
                        }
                        if (module.ModuleId == 0)
                        {
                            continue;
                        }
                        lastmodule           = module.ModuleId;
                        BoardInfo.ModuleId   = module.ModuleId;
                        BoardInfo.ModuleName = module.ModuleName.Replace(",", "-");
                        //BoardInfo = manager.getRosterCredentials(BoardInfo, sw);
                        //if (!BoardInfo.IsValidCredential) BoardInfo = manager.getCredentials(BoardInfo, sw);
                        BoardInfo = manager.getCredentials(BoardInfo, sw);
                        if (true)// (BoardInfo.IsValidCredential)
                        {
                            ls.rosterSearch(Convert.ToString(BoardInfo.BoardId), Convert.ToString(BoardInfo.ModuleId), BoardInfo);
                            i++;
                            //if (i > 80)
                            //    break;
                        }
                    }
                    ls.WriteToFile();
                    filePaths.Add(ls.LoginFilePath);
                    filePaths.Add(ls.DmqlFilePath);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error message:{0}", ex.Message);
                if (tcsDb != null)
                {
                    tcsDb.Dispose();
                }
            }
        }
Esempio n. 8
0
        private void StartReportListings_Click(object sender, RoutedEventArgs e)
        {
            short       lastmodule = 0;
            TCSEntities tcsDb      = null;

            try
            {
//                string query = @"SELECT distinct cmm.module_id as ModuleId, module_name as ModuleName,cmb.board_id as BoardId FROM [TCS].[dbo].[cma_mls_modules] cmm, tcs.dbo.cma_mls_boards cmb, tcs.dbo.prosoft_modules pm
//    where cmm.module_id=cmb.module_id and cmm.module_id = pm.ShippingID order by ModuleId";// and pm.ShippingID=1796
                //                string query = @"SELECT distinct cmb.module_id as ModuleId, module_name as ModuleName,cmb.board_id as BoardId FROM [TCS].[dbo].[tcs_request_log] trl, tcs.dbo.cma_mls_boards cmb, tcs.dbo.cma_mls_modules cmm
                //  where trl.board_id = cmb.board_id and cmm.module_id=cmb.module_id and (client_name = 'tpo' or client_name = 'tmk' or client_name= 'ORCA')";
                //                string query = @"SELECT distinct cmb.module_id as ModuleId, module_name as ModuleName, cmb.board_id as BoardId
                //  FROM tcs.dbo.tcs_request_log trl inner join tcs.dbo.cma_mls_boards cmb on trl.board_id=cmb.board_id inner join tcs.dbo.cma_mls_modules cmm on cmm.module_id = cmb.module_id
                //  left join tcs.dbo.tcs_error_log tel on trl.request_id=tel.request_id
                //  where (client_name = 'tpo' or client_name = 'tmk') and tel.error_code is null and module_name not like '%Orca%Only%' and cmb.module_id not in (1686, 2333, 1101) and cmb.module_id in (1015,1115)
                //  order by ModuleId";// and cmm.module_id=1015";
                tcsDb = new TCSEntities();

                //var args = new DbParameter[] { new SqlParameter { } };
                var moduleList = tcsDb.ExecuteStoreQuery <ModuleEntity>(Query, null);
                //var UniqueUsers = from trl in tcsproddb.tcs_request_log
                //                  join cmb in tcsproddb.cma_mls_boards on trl.board_id equals cmb.board_id
                //                  join cmm in tcsproddb.cma_mls_modules on cmb.module_id equals cmm.module_id
                //                  where (users.client_name == "TMK" || users.client_name == "TPO")
                //                      && (users.board_id == Board) && tel.error_code != 60310
                //                  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) };
                //var moduleList = from boards in tcsDb.cma_mls_boards
                //                 join modules in tcsDb.cma_mls_modules on boards.module_id equals modules.module_id
                //                 where (boards.board_status_id == 1)
                //                 && (boards.type == "Internet")
                //                 select new { boards.board_id, boards.module_id, modules.module_name };
                //tcsDb.Dispose();

                using (var sw = new StreamWriter(string.Format(@"{0}\speedup\CredentialReport" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv", ConfigurationManager.AppSettings["Drive"]), false))
                {
                    sw.WriteLine(ReportHeader);
                    ListhubSearch ls = new ListhubSearch();
                    int           i  = 0;
                    foreach (var module in moduleList)
                    {
                        //if (module.module_id > 1100) break;
                        var manager = new CredentialGatheringManager();
                        BoardCredentials BoardInfo = new BoardCredentials();
                        if (module.ModuleId == lastmodule)
                        {
                            continue;
                        }
                        if (module.ModuleId == 0)
                        {
                            continue;
                        }
                        lastmodule           = module.ModuleId;
                        BoardInfo.ModuleId   = module.ModuleId;
                        BoardInfo.ModuleName = module.ModuleName.Replace(",", "-");
                        BoardInfo            = manager.getCredentials(BoardInfo, sw);
                        if (true)// (BoardInfo.IsValidCredential)
                        {
                            ls.search(Convert.ToString(BoardInfo.BoardId), Convert.ToString(BoardInfo.ModuleId), BoardInfo);
                            i++;
                            //if (i > 80)
                            //    break;
                        }
                    }
                    ls.WriteToFile();
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 9
0
        private void GenerateDefFilesButton_Click(object sender, RoutedEventArgs e)
        {
            if (!IsValidInputFields())
            {
                return;
            }
            _stopProgressDialog = false;
            ModuleId            = ModuleIDTextBox.Text;
            try
            {
                ProgressDialogResult result = ProgressDialog.Execute(this, "Loading data", (bw, we) =>
                {
                    //1.Creating Def files from template def files
                    if (ProgressDialog.ReportWithCancellationCheck(bw, we, 10,
                                                                   "Creating Def files from template def files...",
                                                                   1))
                    {
                        return;
                    }
                    Thread.Sleep(1000);
                    this.Dispatcher.Invoke((Action)(CreateNewDefFiles));
                    if (_stopProgressDialog)
                    {
                        ProgressDialog.CloseProgressDialog(bw, we);
                        return;
                    }
                    //2.Download Metadata
                    if (ProgressDialog.ReportWithCancellationCheck(bw, we, 20, "Downloading Metadata...", 2))
                    {
                        return;
                    }
                    Thread.Sleep(1000);

                    this.Dispatcher.Invoke((Action)(DownloadMlsMetadata));
                    if (_stopProgressDialog)
                    {
                        ProgressDialog.CloseProgressDialog(bw, we);
                        return;
                    }

                    //6.Generate search field
                    if (ProgressDialog.ReportWithCancellationCheck(bw, we, 60, "Generating Def Files...", 9))
                    {
                        return;
                    }
                    Thread.Sleep(1000);
                    this.Dispatcher.Invoke((Action)(GenerateSearchFields));
                    if (_stopProgressDialog)
                    {
                        ProgressDialog.CloseProgressDialog(bw, we);
                        return;
                    }
                    if (ProgressDialog.ReportWithCancellationCheck(bw, we, 100, "Done", 10))
                    {
                        return;
                    }
                    Thread.Sleep(1000);


                    //7.Status
                    //8.Property type

                    // So this check in order to avoid default processing after the Cancel button has been pressed.
                    // This call will set the Cancelled flag on the result structure.
                    ProgressDialog.CheckForPendingCancellation(bw, we);
                }, new ProgressDialogSettings(true, true, false));

                if (result.Cancelled)
                {
                    MessageBox.Show("Failed to generate Def files.");
                }
                else if (result.OperationFailed)
                {
                    MessageBox.Show("ProgressDialog failed.");
                }
                else
                {
                    MessageBox.Show("Def files have been successfully generated.");
                }
                if (!_stopProgressDialog)
                {
                    //Add Rets account info to db

                    using (TCSEntities tcsDb = new TCSEntities())
                    {
                        short moduleId = Convert.ToInt16(ModuleIDTextBox.Text);
                        if (!tcsDb.tcs_rets_connection_info.Any(x => x.module_id == moduleId))
                        {
                            tcs_rets_connection_info retsInfo = new tcs_rets_connection_info();
                            retsInfo.module_id    = moduleId;
                            retsInfo.account_type = 1;
                            retsInfo.rdc_code     = "N/A";
                            retsInfo.user_name    = LoginNameTextBox.Text;
                            retsInfo.password     = PasswordTextBox.Text;
                            retsInfo.user_agent   = UserAgentTextBox.Text;
                            retsInfo.ua_password  = UAPasswordTextBox.Text;
                            retsInfo.login_url    = LoginURLTextBox.Text;

                            tcsDb.AddTotcs_rets_connection_info(retsInfo);
                            tcsDb.SaveChanges();
                        }
                    }

                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to generate Def files. \r\n" + ex.Message);
            }
        }