private DocumentReceiveLog ParseFileForRedmine(string filename, bool createIssue = true,
                                                       bool changeValues = true, DocType documentType = DocType.Waybill, bool deleteCreatedDirectory = true,
                                                       bool priority     = false, bool priorityFull   = true, bool exceptionAdd = false)
        {
            var addressRed =
                session.Query <Address>()
                .FirstOrDefault(
                    s => (changeValues && s.Id != testAddress.Id) || (!changeValues && s.Id == testAddress.Id));
            var supplierRed =
                session.Query <Supplier>()
                .FirstOrDefault(s => (changeValues && s.Id != supplier.Id) || (!changeValues && s.Id == supplier.Id));

            supplierRed.RegionMask = addressRed.Client.MaskRegion;
            session.Save(supplierRed);

            if (exceptionAdd)
            {
                if (!session.Transaction.IsActive)
                {
                    session.BeginTransaction();
                }
                session.Transaction.Commit();
                session.BeginTransaction();
                session.Connection.Query(
                    $"INSERT INTO usersettings.WaybillExcludeFile (Supplier,Mask)  Values({supplierRed.Id} , '{"*.dbf"}')")
                .FirstOrDefault();

                session.Transaction.Commit();
                session.BeginTransaction();
                supplierRed =
                    session.Query <Supplier>()
                    .FirstOrDefault(s => (changeValues && s.Id != supplier.Id) || (!changeValues && s.Id == supplier.Id));
                session.Refresh(supplierRed);
            }

            var curretnClient = addressRed.Client;

            curretnClient.RedmineNotificationForUnresolved = true;
            session.Save(curretnClient);

            if (addressRed.Id != 0)
            {
                testAddress = new TestAddress {
                    Id = addressRed.Id
                };
            }
            if (supplier.Id != 0)
            {
                supplier = new TestSupplier {
                    Id = supplierRed.Id
                };
            }

            if (createIssue)
            {
                addressRed.Client.RedmineNotificationForUnresolved = true;
                session.Save(addressRed.Client);
            }
            else
            {
                addressRed.Client.RedmineNotificationForUnresolved = false;
                session.Save(addressRed.Client);
            }

            var log = new DocumentReceiveLog(supplierRed, addressRed)
            {
                FileName     = filename,
                DocumentType = documentType
            };

            session.Save(log);

            if (priority)
            {
                session.CreateSQLQuery($"INSERT INTO customers.Associations (Name) values('TestUser')")
                .ExecuteUpdate();
                var newAssociationId = session.CreateSQLQuery($"SELECT Id FROM customers.Associations WHERE Name = 'TestUser' LIMIT 1")
                                       .UniqueResult <uint>();
                session.CreateSQLQuery(
                    $"INSERT INTO customers.PromotionMembers (AssociationId,ClientId) values({newAssociationId},'{curretnClient.Id}')")
                .ExecuteUpdate();
                session.CreateSQLQuery(
                    $"Update usersettings.RetClientsSet SET IsStockEnabled = {(priorityFull ? "1" : "0")} , InvisibleOnFirm = 1 WHERE ClientCode = {curretnClient.Id} ")
                .ExecuteUpdate();
            }

            session.Flush();


            var fi  = new FileInfo(log.GetFileName());
            var str = fi.DirectoryName;

            if (!Directory.Exists(str))
            {
                Directory.CreateDirectory(str);
            }
            File.Delete(fi.FullName);
            File.Copy(@"..\..\Data\Waybills\" + log.FileName, fi.FullName);

            var w       = new WaybillService();
            var waybill = DocumentReceiveLog.Find(log.Id);

            w.Process(new EditableList <DocumentReceiveLog> {
                waybill
            });
            session.Flush();

            if (deleteCreatedDirectory && Directory.GetParent(str).Exists)
            {
                Directory.GetParent(str).Delete(true);
            }

            if (priority)
            {
                session.CreateSQLQuery($"DELETE FROM customers.Promoters WHERE Login = '******'").ExecuteUpdate();
            }

            return(log);
        }