public void DeserializeProperties()
 {
     try
     {
         if (File.Exists(PropertyfileName) == false)
         {
             return;
         }
         else
         {
             using (Stream stream = File.Open(PropertyfileName, FileMode.Open))
             {
                 PropertyLog     log      = PropertyLog.Create;
                 BinaryFormatter bin      = new BinaryFormatter();
                 var             profiles = (Dictionary <string, Property>)bin.Deserialize(stream);
                 foreach (var x in profiles)
                 {
                     if (log.Contains(x.Key) == false)
                     {
                         log.Add(x.Value);
                     }
                 }
             }
         }
     }
     catch (IOException ex)
     {
         throw new Exception(ex.Message);
     }
 }
Esempio n. 2
0
        public string ReadPAFFileSingle(string fileName, string sheetName, PostalAdress poobj)
        {
            string ConsoleLog       = null;
            string ConnectionString = GetConnectionString(fileName);

            using (OleDbConnection conn = new OleDbConnection(ConnectionString))
            {
                conn.Open();
                cmd.Connection = conn;
                //+"."+ sheetName +
                string query = "SELECT * FROM [" + Path.GetFileName(fileName) + "] WHERE  = '" + poobj.PCD.ToUpper() + "'";
                cmd = new OleDbCommand(query, conn);

                //                cmd.Parameters.AddWithValue("@p1",Path.GetFileName(fileName));
                //              cmd.Parameters.AddWithValue("@p2", poobj.PCD.ToUpper());

                var x = cmd.ExecuteReader();
                while (x.Read())
                {
                    if (String.IsNullOrWhiteSpace(x[11].ToString()) == false)
                    {
                        Property p = new Property();
                        p.DateAdded = DateTime.Now;
                        try
                        {
                            p.ORD       = x[0].ToString();
                            ConsoleLog += "Added" + p.ORD + "\n";
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.ORC = x[1].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.SBN = x[2].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.BNA = x[3].ToString();
                            //      ConsoleLog += "Added" + p.BNA + "\n";
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.POB = x[4].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.NUM = x[5].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.DST = x[6].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }

                        try
                        {
                            p.STM = x[7].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.DDL = x[8].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.DLO = x[9].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.PTN = x[10].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.PCD = x[11].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }

                        try
                        {
                            p.CTA = x[12].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.CTP = x[13].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }

                        try
                        {
                            p.CTT = x[14].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }

                        try
                        {
                            p.SCD = x[15].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.CAT = x[16].ToString();
                            //             ConsoleLog += "Added" + p.CAT + "\n";
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }

                        try
                        {
                            p.NDP = x[17].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.DPX = x[18].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }

                        try
                        {
                            p.URN = x[19].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }


                        try
                        {
                            p.PID = poobj.PID;
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }



                        PropertiesObj.Add(p);
                        PostalAdressObj.Add(p);
                        //adressList.Add(p.PID, p);
                        PostalAdressObj.adressList[p.PID].AddPropertyKey(p.PID);
                    }
                }
                cmd = null;
                conn.Close();
            }
            return(ConsoleLog);
        }
Esempio n. 3
0
        public void ReadPAFFile(string FileName, PostalAdress poobj)
        {
            string ConsoleLog = null;
            CsvFileReader handler = new CsvFileReader(FileName);

            while (handler != null)
            {
                CsvRow row = new CsvRow();
                handler.ReadRow(row);
                if (row.Count == 0)
                {
                    break;
                }
                if (row[11].Equals(poobj.PCD.ToUpper()) == false)
                {
                    OnInformationDownload(new EventArguments() { Name = "Trace: ", Time = DateTime.Now, Details = "Searching " + poobj.PCD.ToUpper() + "==" + row[11].ToUpper() });
                    continue;
                }
                else
                {
                    OnInformationDownload(new EventArguments() { Name = "Trace: ", Time = DateTime.Now, Details = "Found Property " + poobj.PCD });

                    if (String.IsNullOrWhiteSpace(row[11].ToString()) == false)
                    {
                        Property p = new Property();
                        p.DateAdded = DateTime.Now;
                        try
                        {
                            p.ORD = row[0].ToString();
                            ConsoleLog += "Added" + p.ORD + "\n";
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }
                        try
                        {
                            p.ORC = row[1].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.SBN = row[2].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.BNA = row[3].ToString();
                            //      ConsoleLog += "Added" + p.BNA + "\n";
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.POB = row[4].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.NUM = row[5].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.DST = row[6].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }

                        try
                        {
                            p.STM = row[7].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.DDL = row[8].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.DLO = row[9].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.PTN = row[10].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.PCD = row[11].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }

                        try
                        {
                            p.CTA = row[12].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.CTP = row[13].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }

                        try
                        {
                            p.CTT = row[14].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }

                        try
                        {
                            p.SCD = row[15].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.CAT = row[16].ToString();
                            //             ConsoleLog += "Added" + p.CAT + "\n";

                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }

                        try
                        {
                            p.NDP = row[17].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        try
                        {
                            p.DPX = row[18].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }

                        try
                        {
                            p.URN = row[19].ToString();
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");
                        }


                        try
                        {
                            p.PID = poobj.PID;
                        }
                        catch (Exception)
                        {
                            throw new Exception("Can not Find");

                        }
                        p.SetAdressAutomatically();
                        log.Add(p);

                        POlog.Add(p);
                        //adressList.Add(p.PID, p);

                        POlog.adressList[p.PID].AddPropertyKey(p.PCD + p.URN);
                    }
                }
            }
        }