Пример #1
0
        public static void ProcessImages(string path)
        {
            string ErrorMessageUser = "";

            try
            {
                ErrorMessageUser = "******";
                WriteLog(ErrorMessageUser);
                Console.WriteLine(Environment.NewLine + ErrorMessageUser + Environment.NewLine + "Please wait....");

                //Note: e.g => 'http://169.45.133.92:8060/IDXResidential/Photo' + MLS + '-1.jpeg'
                List <string> FolderName = new List <string>();
                FolderName.Add("IDXResidential");
                FolderName.Add("IDXImagesCommercial");
                FolderName.Add("VoxCommercial");
                FolderName.Add("IDXImagesCondo");
                FolderName.Add("VoxCondo");
                FolderName.Add("VoxResidential");

                CommonClass           clsObj = new CommonClass();
                System.Data.DataTable dt     = new System.Data.DataTable();
                dt = clsObj.GetDataSet("SELECT MLSID FROM [ActiveMLSIDS]").Tables[0];
                foreach (var folder in FolderName)
                {
                    string NewPath = path + "\\" + folder;
                    if (Directory.Exists(NewPath))
                    {
                        string[] filePaths = Directory.GetFiles(NewPath, "*.jpeg", SearchOption.AllDirectories);
                        foreach (var file in filePaths)
                        {
                            try
                            {
                                string FileName          = Path.GetFileName(file);
                                string MLSId             = FileName.Replace("Photo", "").Split('-')[0].Trim();
                                System.Data.DataRow[] dr = dt.Select("MLSID='" + MLSId + "'");
                                if (dr.Length == 0) //MLSID Not Found in DB. So Delete its image from folder.
                                {
                                    if (File.Exists(file))
                                    {
                                        File.Delete(file);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                string ErrorMessage = ex.Message.ToString();
                                WriteLog("Error in Process Images file : " + file);
                                Console.WriteLine(Environment.NewLine + ErrorMessage);
                            }
                        }
                    }
                }

                ErrorMessageUser = "******";
                WriteLog(ErrorMessageUser);
                Console.WriteLine(ErrorMessageUser);
            }
            catch (Exception ex)
            {
                string ErrorMessage = ex.Message.ToString();
                WriteLog("Error in Process Images : " + ErrorMessage);
                Console.WriteLine(Environment.NewLine + ErrorMessage);
            }
        }
Пример #2
0
        public static void ProcessFiles(string path)
        {
            string ErrorMessageUser = "";

            try
            {
                //List<string> MLSActiveFileList = new List<string>();
                //MLSActiveFileList.Add("ActiveIdxCommercial.txt");
                //MLSActiveFileList.Add("ActiveIdxCondo.txt");
                //MLSActiveFileList.Add("ActiveIdxResidential.txt");
                //MLSActiveFileList.Add("ActiveVowCommercial.txt");
                //MLSActiveFileList.Add("ActiveVowCondo.txt");
                //MLSActiveFileList.Add("ActiveVowResidential.txt");

                //List<string> MlsAddedList = new List<string>();
                string QStr = "";

                ErrorMessageUser = "******";
                WriteLog(ErrorMessageUser);
                Console.WriteLine(Environment.NewLine + ErrorMessageUser + Environment.NewLine + "Please wait....");

                ////foreach (var MLSActiveFile in MLSActiveFileList)
                ////{
                ////    string NewPath = path + "/" + MLSActiveFile;
                ////    var webRequest = System.Net.WebRequest.Create(NewPath);

                ////    using (var response = webRequest.GetResponse())
                ////    using (var content = response.GetResponseStream())
                ////    using (var reader = new StreamReader(content))
                ////    {
                ////        var strContent = reader.ReadToEnd();
                ////        string[] Lines = strContent.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                ////        foreach (var line in Lines)
                ////        {
                ////            string[] MlsId = line.Split(' ');
                ////            if (MlsId.Length > 0)
                ////            {
                ////                string MlsIdMain = MlsId[0].Trim();
                ////                if (MlsIdMain != "")
                ////                {
                ////                    if (!MlsAddedList.Contains(MlsIdMain))
                ////                    {
                ////                        QStr += "INSERT INTO [ActiveMLSIDS]([MLSID])VALUES('" + MlsIdMain + "');";
                ////                        MlsAddedList.Add(MlsIdMain);
                ////                    }
                ////                }
                ////            }
                ////        }
                ////    }
                ////}

                //foreach (string file in Directory.EnumerateFiles(path, "*.txt"))
                //{
                //    string[] Lines = File.ReadAllLines(file);
                //    foreach (var line in Lines)
                //    {
                //        string[] MlsId = line.Split(' ');
                //        if (MlsId.Length > 0)
                //        {
                //            string MlsIdMain = MlsId[0].Trim();
                //            if (MlsIdMain != "")
                //            {
                //                if (!MlsAddedList.Contains(MlsIdMain))
                //                {
                //                    QStr += "INSERT INTO [ActiveMLSIDS]([MLSID])VALUES('" + MlsIdMain + "');";
                //                    MlsAddedList.Add(MlsIdMain);
                //                }
                //            }
                //        }
                //    }
                //}

                CommonClass clsObj = new CommonClass();
                clsObj.ExecuteNonQuery("UpdateActiveProperties");
                ////if (MlsAddedList.Count() > 0)
                ////{
                ////    clsObj.ExecuteNonQuery("TRUNCATE TABLE [ActiveMLSIDS]");

                //Remove left right space from mls columns.
                ////QStr += "UPDATE[ActiveMLSIDS] SET MLSID = SUBSTRING(mlsiD, 0, LEN(mlsiD))WHERE mlsiD LIKE '%A';";

                ////QStr += "update [ActiveMLSIDS] set MLSID=LTRIM(RTRIM(REPLACE(REPLACE(REPLACE(MLSID, CHAR(10), ''), CHAR(13), ''), CHAR(9), '')));";

                ////QStr += " UPDATE dbo.[ActiveMLSIDS] SET mlsid = REPLACE(mlsid, ',', ''); ";



                ////QStr += "update PropertyData set MLS = LTRIM(RTRIM(REPLACE(REPLACE(REPLACE(MLS, CHAR(10), ''), CHAR(13), ''), CHAR(9), '')));";
                ////QStr += "update PropertyData_Comm            set MLS = LTRIM(RTRIM(REPLACE(REPLACE(REPLACE(MLS, CHAR(10), ''), CHAR(13), ''), CHAR(9), '')));";
                ////QStr += "update PropertyData_Comm_VOX        set MLS = LTRIM(RTRIM(REPLACE(REPLACE(REPLACE(MLS, CHAR(10), ''), CHAR(13), ''), CHAR(9), '')));";
                ////QStr += "update PropertyData_Condo           set MLS = LTRIM(RTRIM(REPLACE(REPLACE(REPLACE(MLS, CHAR(10), ''), CHAR(13), ''), CHAR(9), '')));";
                ////QStr += "update PropertyData_Condo_Vox       set MLS = LTRIM(RTRIM(REPLACE(REPLACE(REPLACE(MLS, CHAR(10), ''), CHAR(13), ''), CHAR(9), '')));";
                ////QStr += "update PropertyData_Vox_Residential set MLS = LTRIM(RTRIM(REPLACE(REPLACE(REPLACE(MLS, CHAR(10), ''), CHAR(13), ''), CHAR(9), '')));";
                //end

                //Start Insert Procedure
                QStr += "DELETE FROM PropertyData where MLS NOT IN(SELECT MLSID FROM [ActiveMLSIDS]);";
                QStr += "DELETE FROM PropertyData where MLS NOT IN(SELECT MLSID FROM [ActiveMLSIDS]);";
                QStr += "DELETE FROM PropertyData where MLS NOT IN(SELECT MLSID FROM [ActiveMLSIDS]);";
                QStr += "DELETE FROM PropertyData_Comm where MLS NOT IN(SELECT MLSID FROM [ActiveMLSIDS]);";
                QStr += "DELETE FROM PropertyData_Comm_VOX where MLS NOT IN(SELECT MLSID FROM [ActiveMLSIDS]);";
                QStr += "DELETE FROM PropertyData_Condo where MLS NOT IN(SELECT MLSID FROM [ActiveMLSIDS]);";
                QStr += "DELETE FROM PropertyData_Condo_Vox where MLS NOT IN(SELECT MLSID FROM [ActiveMLSIDS]);";
                QStr += "DELETE FROM PropertyData_Vox_Residential where MLS NOT IN(SELECT MLSID FROM [ActiveMLSIDS]);";


                ////ErrorMessageUser = "******";
                ////WriteLog(ErrorMessageUser);
                ////Console.WriteLine(Environment.NewLine + ErrorMessageUser + Environment.NewLine + "Please wait....");

                ////clsObj.ExecuteNonQuery(QStr);

                ErrorMessageUser = "******";
                WriteLog(ErrorMessageUser);
                Console.WriteLine(ErrorMessageUser);
                //End : Start Insert Procedure
                //}
            }
            catch (Exception ex)
            {
                string ErrorMessage = ex.Message.ToString();
                WriteLog("Error in Insert ActiveMLSIDS : " + ErrorMessage);
                Console.WriteLine(Environment.NewLine + ErrorMessage);
            }
        }