public void Created_Audit_Fields_Should_be_Set_After_Save_With_Children()
        {
            CompanyIdentification companyIdentification1 =
                new CompanyIdentification
                {
                    Identification = "1"
                };
            CompanyIdentification companyIdentification2 =
                new CompanyIdentification
                {
                    Identification = "2"
                };
            Company company =
                new Company
                {
                    Name = "Peopleware NV",
                    Identifications = new[] { companyIdentification1, companyIdentification2 }
                };

            Company savedCompany = Repository.Save(company);

            Assert.AreSame(company, savedCompany);
            Assert.AreEqual(UserName, company.CreatedBy);
            Assert.AreEqual(m_Now, company.CreatedAt);

            Assert.AreEqual(2, company.Identifications.Count);
            foreach (CompanyIdentification companyIdentification in company.Identifications)
            {
                Assert.AreEqual(UserName, companyIdentification.CreatedBy);
                Assert.AreEqual(m_Now, companyIdentification.CreatedAt);
            }
        }
        public void Check_BiDirectionality_Add_Childs_To_Parent()
        {
            Company company = CreateCompany(CompanyCreationType.NO_CHILDREN);

            // Add child
            CompanyIdentification companyIdentification =
                new CompanyIdentification
            {
                Identification = "1"
            };

            company.AddIdentification(companyIdentification);
            CompanyIdentification companyIdentification2 =
                new CompanyIdentification
            {
                Identification = "1"
            };

            company.AddIdentification(companyIdentification2);
            Assert.AreEqual(2, company.Identifications.Count);
            foreach (CompanyIdentification identification in company.Identifications)
            {
                Assert.IsTrue(identification.IsTransient);
            }

            Company savedCompany = Repository.Merge(company);

            Assert.AreEqual(2, savedCompany.PersistenceVersion);
            Assert.AreEqual(2, savedCompany.Identifications.Count);
            foreach (CompanyIdentification identification in savedCompany.Identifications)
            {
                Assert.IsFalse(identification.IsTransient);
            }
        }
        public void DirtyCheckingTest()
        {
            CompanyIdentification companyIdentification1 =
                new CompanyIdentification
                {
                    Identification = "1"
                };
            CompanyIdentification companyIdentification2 =
                new CompanyIdentification
                {
                    Identification = "2"
                };
            Company company =
                new Company
                {
                    Name = "Peopleware NV",
                    Identifications = new[] { companyIdentification1, companyIdentification2 }
                };
            Repository.Save(company);
            Session.Evict(company);

            /* Set Number to null (but Number is defined as int) */
            /*
            using (ISession session = NhConfigurator.SessionFactory.OpenSession())
            {
                using (ITransaction trans = session.BeginTransaction())
                {
                    session.CreateQuery(@"update CompanyIdentification set Number = null").ExecuteUpdate();
                    trans.Commit();
                }
            }
            */
            new DirtyChecking(NhConfigurator.Configuration, NhConfigurator.SessionFactory, Assert.Fail, Assert.Inconclusive).Test();
        }
示例#4
0
        public void Check_BiDirectionality_Add_Child_To_Parent()
        {
            Company company = CreateCompany(CompanyCreationType.NO_CHILDREN);

            // Add child
            CompanyIdentification companyIdentification =
                new CompanyIdentification
                {
                    Identification = "1"
                };
            company.AddIdentification(companyIdentification);
            Assert.AreEqual(1, company.Identifications.Count);
            foreach (CompanyIdentification identification in company.Identifications)
            {
                Assert.IsTrue(identification.IsTransient);
            }

            Company savedCompany = Repository.Merge(company);
            Assert.AreEqual(2, savedCompany.PersistenceVersion);
            Assert.AreEqual(1, savedCompany.Identifications.Count);
            foreach (CompanyIdentification identification in savedCompany.Identifications)
            {
                Assert.IsFalse(identification.IsTransient);
            }
        }
        public void Check_BiDirectionality_Remove_Child_From_Parent()
        {
            Company company = CreateCompany(CompanyCreationType.WITH_2_CHILDREN);

            Company mergedCompany;

            using (ITransaction trans = Session.BeginTransaction(IsolationLevel.ReadCommitted))
            {
                // 1. Attach company to session
                mergedCompany = Repository.Merge(company);

                // 2. Remove companyIdentification 1
                CompanyIdentification companyIdentification =
                    mergedCompany
                    .Identifications
                    .SingleOrDefault(i => i.Identification == "1");
                Assert.IsNotNull(companyIdentification);
                mergedCompany.RemoveIdentification(companyIdentification);

                trans.Commit();
            }

            // 4. Clear session
            Session.Clear();

            // 5. Check Db status
            Company selectedCompany = Repository.GetById(mergedCompany.Id);

            Assert.AreEqual(1, selectedCompany.Identifications.Count);
        }
        public void Can_Get_Company_with_Identification_1_with_explicit_join()
        {
            CompanyIdentification ci = null;
            Company company          = Repository.Get(
                qry => qry.Inner.JoinAlias(c => c.Identifications, () => ci)
                .Where(() => ci.Identification == "1"));

            Assert.IsNotNull(company);
            Assert.IsFalse(NHibernateUtil.IsInitialized(company.Identifications));
        }
示例#7
0
        private ShuratHaklada CreateShuratHakladaHavshavshevet(string line)
        {
            ShuratHaklada shurat_haklada = new ShuratHaklada();
            int           pos            = 0;
            String        CountryID      = Convert.ToInt32(line.Substring(pos, 4)).ToString();

            pos += 4;
            String CompanyVAT = line.Substring(pos, 9);

            pos += 9;
            String CompanyName = line.Substring(pos, 30);

            pos += 30;

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

            if (company != null)
            {
                shurat_haklada.CompanyID = dblayer.GetCompany(CountryID, CompanyVAT).CompanyID;

                shurat_haklada.ActionCode = Convert.ToInt32(line.Substring(pos, 2));
                pos += 2;
                shurat_haklada.MisparMismach = Convert.ToInt32(line.Substring(pos, 9));
                pos += 9;
                shurat_haklada.TarichMismach = Convert.ToDateTime(line.Substring(pos, 10));
                pos += 10;
                shurat_haklada.TarichAcher = Convert.ToDateTime(line.Substring(pos, 10));
                pos += 10;
                shurat_haklada.ActionDetails = line.Substring(pos, 70);
                pos += 70;
                shurat_haklada.AhuzHaMaam = Convert.ToDouble(line.Substring(pos, 5));
                pos += 5;
                shurat_haklada.SchumPaturMaam = Convert.ToDouble(line.Substring(pos, 12));
                pos += 12;
                shurat_haklada.SchumMaam = Convert.ToDouble(line.Substring(pos, 12));
                pos += 12;
                shurat_haklada.SchumKolelMaam = Convert.ToDouble(line.Substring(pos, 12));
                pos += 12;
                shurat_haklada.Attachment = line.Substring(pos, line.Length - pos);

                shurat_haklada.CompamyInfoCountryID = Company_Info.CompanyCountryID;
                shurat_haklada.CompamyInfoVAT       = Company_Info.CompanyVAT;
            }

            return(shurat_haklada);
        }
示例#8
0
        ////////////////////////////////////////////////////////////////////////////////////////////

        private ShuratHaklada CreateShuratHakladaMokupINI(string line, string delimiter)
        {
            PrepareIniFileName();

            ShuratHaklada shurat_haklada = new ShuratHaklada();

            string[] parts = line.Split(new string[] { delimiter }, StringSplitOptions.None);

            String CompanyVAT  = GetOutboxImportStringValue("VAT", parts).ToString();
            String CompanyName = GetOutboxImportStringValue("CompanyName", parts);

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

            if (company != null)
            {
                CompanyVAT  = company.CompanyVAT;
                CompanyName = company.CompanyName;

                shurat_haklada.CompanyID      = company.CompanyID;
                shurat_haklada.CountryID      = GetOutboxImportIntValue("CountryID", parts);
                shurat_haklada.CompanyVAT     = CompanyVAT;  // iniFile.IniReadValue(companyinfo.CompanySerialNumber + " Import Outbox Structure", "VAT");
                shurat_haklada.CompanyName    = CompanyName; // iniFile.IniReadValue(companyinfo.CompanySerialNumber + " Import Outbox Structure", "CountryName");
                shurat_haklada.ActionCode     = GetOutboxImportIntValue("ActionCode", parts);
                shurat_haklada.MisparMismach  = GetOutboxImportIntValue("MisparMismach", parts);
                shurat_haklada.TarichMismach  = GetOutboxImportDateTimeValue("TarichMismach", parts);
                shurat_haklada.TarichAcher    = GetOutboxImportDateTimeValue("TarichAcher", parts);
                shurat_haklada.ActionDetails  = GetOutboxImportStringValue("ActionDetails", parts);
                shurat_haklada.AhuzHaMaam     = GetOutboxImportDoubleValue("Maam", parts);
                shurat_haklada.SchumPaturMaam = GetOutboxImportIntValue("SchumPaturMaam", parts);
                shurat_haklada.SchumMaam      = GetOutboxImportIntValue("SchumMaam", parts);
                shurat_haklada.SchumKolelMaam = GetOutboxImportIntValue("SchumKolelMaam", parts);
                shurat_haklada.Attachment     = GetOutboxImportStringValue("Attachment", parts);

                shurat_haklada.CompamyInfoCountryID = Company_Info.CompanyCountryID;
                shurat_haklada.CompamyInfoVAT       = Company_Info.CompanyVAT;
            }

            return(shurat_haklada);
        }
示例#9
0
        private ShuratHaklada CreateShuratHakladaDelimter(string line, string delimiter)
        {
            ShuratHaklada shurat_haklada = null;

            string[] parts = line.Split(new string[] { delimiter }, StringSplitOptions.None);


            String CountryID   = parts[0];
            String CompanyVAT  = parts[1];
            String CompanyName = parts[2].Replace("'", "''");

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

            if (company != null)
            {
                shurat_haklada               = new ShuratHaklada();
                shurat_haklada.CompanyID     = company.CompanyID;// dblayer.GetCompany(CountryID, CompanyVAT).CompanyID;
                shurat_haklada.ActionCode    = Convert.ToInt32(parts[3]);
                shurat_haklada.MisparMismach = Convert.ToInt32(parts[4]);

                shurat_haklada.TarichMismach = DateTime.Parse(parts[5], new System.Globalization.CultureInfo("en-AU", false)); //Convert.ToDateTime(parts[5]);
                shurat_haklada.TarichAcher   = DateTime.Parse(parts[6], new System.Globalization.CultureInfo("en-AU", false)); //Convert.ToDateTime(parts[6]);

                shurat_haklada.ActionDetails = parts[7].Replace("'", "''");;

                if (parts[8] != "")
                {
                    shurat_haklada.AhuzHaMaam = Convert.ToDouble(parts[8]);
                }
                if (parts[9] != "")
                {
                    shurat_haklada.SchumPaturMaam = Convert.ToDouble(parts[9]);
                }
                if (parts[10] != "")
                {
                    shurat_haklada.SchumMaam = Convert.ToDouble(parts[10]);
                }
                if (parts[11] != "")
                {
                    shurat_haklada.SchumKolelMaam = Convert.ToDouble(parts[11]);
                }

                shurat_haklada.Attachment = parts[12];

                if ((parts[13] != "") && (parts[13] != "0"))
                {
                    shurat_haklada.LeTkufaMe = DateTime.Parse(parts[13], new System.Globalization.CultureInfo("en-AU", false));
                }
                else
                {
                    shurat_haklada.LeTkufaMe = shurat_haklada.TarichAcher;
                }
                //shurat_haklada.LeTkufaMe = new DateTime(shurat_haklada.LeTkufaMe.Year, shurat_haklada.LeTkufaMe.Month, 1);

                if ((parts[14] != "") && (parts[14] != "0"))
                {
                    shurat_haklada.LeTkufaUd = DateTime.Parse(parts[14], new System.Globalization.CultureInfo("en-AU", false));
                }
                else
                {
                    shurat_haklada.LeTkufaUd = shurat_haklada.TarichAcher;
                }
                //shurat_haklada.LeTkufaUd = new DateTime(shurat_haklada.LeTkufaUd.Year, shurat_haklada.LeTkufaUd.Month, 1);

                shurat_haklada.MisparProyect = parts[15];

                shurat_haklada.CompamyInfoCountryID = Company_Info.CompanyCountryID;
                shurat_haklada.CompamyInfoVAT       = Company_Info.CompanyVAT;
            }

            return(shurat_haklada);
        }
示例#10
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();
        }