Example #1
0
        public static void UploadProcess(string path, string xmlName, string spName, string NewFileName)
        {
            string ErrorMessageUser = "";

            try
            {
                string fullFilePath = path + "//" + xmlName;

                RefineXmlFile(path, xmlName);
                CreateCopyOfFile(path, NewFileName, xmlName);

                //Refine File
                if (File.ReadLines(fullFilePath).Any(line => line.Contains("REProperties")))
                {
                    WriteLog(fullFilePath);
                    XDocument XMLDoc  = XDocument.Load(fullFilePath);
                    XElement  element = (from xml1 in XMLDoc.Descendants("REProperties")
                                         select xml1).FirstOrDefault();
                    ErrorMessageUser = xmlName + " started.";
                    WriteLog(ErrorMessageUser);
                    Console.WriteLine(Environment.NewLine + ErrorMessageUser + Environment.NewLine + "Please wait....");

                    System.IO.File.WriteAllText(fullFilePath, element.ToString()
                                                .Replace("<REProperties>", "")
                                                .Replace("</REProperties>", ""));

                    ErrorMessageUser = xmlName + " done.";
                    WriteLog(ErrorMessageUser);
                    Console.WriteLine(ErrorMessageUser);
                }
                //End : Refine File



                //Start Store Procedure
                CommonClass clsObj = new CommonClass();
                ErrorMessageUser = spName + " started.";
                WriteLog(ErrorMessageUser);
                Console.WriteLine(Environment.NewLine + ErrorMessageUser + Environment.NewLine + "Please wait....");

                clsObj.ExecuteNonQuery(spName + " '" + fullFilePath + "'");

                ErrorMessageUser = spName + " done.";
                WriteLog(ErrorMessageUser);
                Console.WriteLine(ErrorMessageUser);
                //End : Start Store Procedure
            }
            catch (Exception ex)
            {
                string ErrorMessage = ex.Message.ToString();
                WriteLog("Error in " + xmlName + " : " + ErrorMessage);
                Console.WriteLine(Environment.NewLine + ErrorMessage);
            }
        }
Example #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);
            }
        }