예제 #1
0
 private String GetFiledValue(String line, FiledHolder filedHolder, String name)
 {
     return(line.Substring(filedHolder.GetFiled(name).Pos, filedHolder.GetFiled(name).Length));
 }
예제 #2
0
        //private void MoveAttachment(String TransactionGUID, String Attachmnent)
        //{
        //    string ServerPath = Application.StartupPath + @"\TransientStorage";

        //    if (!Directory.Exists(ServerPath))
        //    {
        //        Directory.CreateDirectory(ServerPath);
        //    }

        //    if (Company_Info.CompanyCountryID != 0)
        //    {
        //        if (!Directory.Exists(ServerPath + "/" + Company_Info.CompanyCountryID))
        //        {
        //            Directory.CreateDirectory(ServerPath + "/" + Company_Info.CompanyCountryID);
        //        }
        //    }

        //    if (Company_Info.CompanyVAT != null)
        //    {
        //        if (!Directory.Exists(ServerPath + "/" + Company_Info.CompanyCountryID + "/" + Company_Info.CompanyVAT))
        //        {
        //            Directory.CreateDirectory(ServerPath + "/" + Company_Info.CompanyCountryID + "/" + Company_Info.CompanyVAT);
        //        }
        //    }

        //    String fileName = TransactionGUID + Path.GetExtension(Attachmnent);
        //    File.Move(Attachmnent, ServerPath + "/" + Company_Info.CompanyCountryID + "/" + Company_Info.CompanyVAT + "/" + fileName);
        //}

        public void ImportHakladaMokup(String filename, CompanyInfo _companyinfo, DBLayer _dblayer, char delimiter)
        {
            Company_Info = _companyinfo;
            dblayer      = _dblayer;
            FiledHolder filedHolder = new FiledHolder();

            filedHolder.InitINI();
            filedHolder.Company_Info = Company_Info;
            filedHolder.Add("CountryID");
            filedHolder.Add("CompanyVAT");
            filedHolder.Add("CompanyName");
            filedHolder.Add("ActionCode");
            filedHolder.Add("MisparMismach");
            filedHolder.Add("TarichMismach");
            filedHolder.Add("TarichAcher");
            filedHolder.Add("ActionDetails");
            filedHolder.Add("Maam");
            filedHolder.Add("SchumPaturMaam");
            filedHolder.Add("SchumMaam");
            filedHolder.Add("SchumKolelMaam");
            filedHolder.Add("Attachment");
            filedHolder.LoadData();

            StreamReader sr   = new StreamReader(filename, CheckEncoder()); //Encoding.GetEncoding("iso-8859-8") //Hebrew From Magic
            String       line = "";
            ArrayList    flds = filedHolder.GetFileds();

            //filedHolder.GetFiled("ActionCode")
            dblayer.Current_Company_Info = _companyinfo;

            //bool bSkipRow = false;

            while (!sr.EndOfStream)
            {
                line = sr.ReadLine();
                filedHolder.CurrentDataLine = line;

                ShuratHaklada shurat_haklada = new ShuratHaklada();

                String CompanyVAT  = filedHolder.GetFiledValue(filedHolder.GetFiledPosition("CompanyVAT"), delimiter);
                String CompanyName = filedHolder.GetFiledValue(filedHolder.GetFiledOrder("CompanyName"), delimiter);

                Company company = CompanyIdentification.Identify(dblayer, Company_Info, null, CompanyVAT, CompanyName, null);

                if (company != null)
                {
                    shurat_haklada.CompanyID = company.CompanyID;

                    shurat_haklada.ActionCode           = Convert.ToInt32(filedHolder.GetFiledValue("ActionCode"));
                    shurat_haklada.MisparMismach        = Convert.ToInt32(filedHolder.GetFiledValue("MisparMismach"));
                    shurat_haklada.TarichMismach        = Convert.ToDateTime(filedHolder.GetFiledValue("TarichMismach"));
                    shurat_haklada.TarichAcher          = Convert.ToDateTime(filedHolder.GetFiledValue("TarichAcher"));
                    shurat_haklada.ActionDetails        = filedHolder.GetFiledValue("ActionDetails");
                    shurat_haklada.AhuzHaMaam           = Convert.ToDouble(filedHolder.GetFiledValue("Maam"));
                    shurat_haklada.SchumPaturMaam       = Convert.ToDouble(filedHolder.GetFiledValue("SchumPaturMaam"));
                    shurat_haklada.SchumMaam            = Convert.ToDouble(filedHolder.GetFiledValue("SchumMaam"));
                    shurat_haklada.SchumKolelMaam       = Convert.ToDouble(filedHolder.GetFiledValue("SchumKolelMaam"));
                    shurat_haklada.Attachment           = filedHolder.GetFiledValue("Attachment");
                    shurat_haklada.CompamyInfoCountryID = Company_Info.CompanyCountryID;
                    shurat_haklada.CompamyInfoVAT       = Company_Info.CompanyVAT;
                    dblayer.AddHakladaRecord(shurat_haklada);
                }
            }

            sr.Close();
        }