Пример #1
0
            public void Import(IObjectSpace os, String acc_sys_code, String file_name)
            {
                DelimitedFileEngine engine = new DelimitedFileEngine(typeof(FAAccountImport));

                FAAccountImport[]  records = (FAAccountImport[])engine.ReadFile(file_name);
                fmCFAAccountSystem acc_sys = os.GetObjects <fmCFAAccountSystem>(new BinaryOperator("Code", acc_sys_code), true).FirstOrDefault();

                if (acc_sys == null)
                {
                    acc_sys      = os.CreateObject <fmCFAAccountSystem>();
                    acc_sys.Code = "1000";
                    acc_sys.Name = "Áóõãàëòåðèÿ";
                }
                foreach (FAAccountImport rec in records)
                {
                    fmCFAAccount bs_acc = acc_sys.Accounts.Where(x => x.Code == rec.BsCode).FirstOrDefault();
                    if (bs_acc == null)
                    {
                        bs_acc      = os.CreateObject <fmCFAAccount>();
                        bs_acc.Code = rec.BsCode;
                        acc_sys.Accounts.Add(bs_acc);
                    }
                    if (rec.SsCode == "0000")
                    {
                        bs_acc.Name     = rec.NameShort;
                        bs_acc.NameFull = rec.NameFull;
                    }
                    else
                    {
                        fmCFAAccount ss_acc = acc_sys.Accounts.Where(x => x.Code == rec.SsCode).FirstOrDefault();
                        if (ss_acc == null)
                        {
                            ss_acc      = os.CreateObject <fmCFAAccount>();
                            ss_acc.Code = rec.SsCode;
                            bs_acc.SubAccounts.Add(ss_acc);
                        }
                        ss_acc.BuhCode = rec.BuhCode;
                        if (rec.NameShort.Length > 60)
                        {
                            ss_acc.Name = rec.NameShort.Substring(0, 60);
                        }
                        else
                        {
                            ss_acc.Name = rec.NameShort;
                        }
                        ss_acc.NameFull      = rec.NameFull;
                        ss_acc.IsSelectabled = true;
                    }
                }
            }
Пример #2
0
        public static void ImportInData(FmDocsFmInData doc, IObjectSpace os, TextReader reader)
        {
            DelimitedFileEngine engine = new DelimitedFileEngine(typeof(InDataImport));

            engine.Options.IgnoreFirstLines = 1;
            InDataImport[] records = (InDataImport[])engine.ReadStream(reader);
            os.Delete(doc.Lines);
            fmCFAAccountSystem fact_system = os.FindObject <fmCFAAccountSystem>(new BinaryOperator("Code", "1000"));
            IList <fmCostItem> cost_items  = os.GetObjects <fmCostItem>();

            foreach (InDataImport rec in records)
            {
                FmDocsFmInData.Line line = doc.LinesCreate();
                line.FactAccount = fact_system.Accounts.FirstOrDefault(x => x.Code == rec.AccountCode);
                line.FmOrder     = os.FindObject <fmCOrder>(new BinaryOperator("Code", rec.OrderCode));
                line.FmCostItem  = cost_items.FirstOrDefault(x => x.Code == rec.CostItemCode);
                line.Summ        = rec.Summ;
            }
        }
Пример #3
0
            public void Import(IObjectSpace os, String file_name)
            {
                DelimitedFileEngine engine = new DelimitedFileEngine(typeof(fmOrderImport));

                fmOrderImport[]     records = (fmOrderImport[])engine.ReadFile(file_name);
                IList <fmCOrderExt> orders  = os.GetObjects <fmCOrderExt>(null, true);
                fmCFAAccountSystem  acc_sys = os.GetObjects <fmCFAAccountSystem>(new BinaryOperator("Code", "1000"), true).FirstOrDefault();
                IList <fmÑOrderAnalitycAccouterType> acc_types = os.GetObjects <fmÑOrderAnalitycAccouterType>();

                foreach (fmOrderImport rec in records)
                {
                    fmCOrderExt order = orders.FirstOrDefault(item => item.Code == rec.Code);
                    if (order == null)
                    {
                        Trace.TraceWarning("Updater_1.1.1.220_OrderImport: Order >" + rec.Code + "< not found");
                        order      = os.CreateObject <fmCOrderExt>();
                        order.Code = rec.Code;
                        if (rec.IsClosed != "X")
                        {
                            order.Status = fmIOrderStatus.Loaded;
                        }
                        else
                        {
                            order.Status = fmIOrderStatus.FinClosed;
                        }
                        orders.Add(order);
                    }
                    order.BuhIntNum = rec.Oid;
                    if (rec.IsClosed != "X")
                    {
                        if (order.Status == fmIOrderStatus.Project || order.Status == fmIOrderStatus.FinOpened)
                        {
                            order.Status   = fmIOrderStatus.Opened;
                            order.IsClosed = false;
                        }
                    }
                    else
                    {
                        if (order.Status == fmIOrderStatus.Project || order.Status == fmIOrderStatus.FinClosed)
                        {
                            order.Status   = fmIOrderStatus.Closed;
                            order.IsClosed = true;
                        }
                    }
                    if (!String.IsNullOrEmpty(rec.AccType) && rec.AccType != "0")
                    {
                        order.AnalitycAccouterType = acc_types.FirstOrDefault(x => x.Code == rec.AccType);
                    }
                    if (!String.IsNullOrEmpty(rec.AccBuhCode) && rec.AccBuhCode != "0")
                    {
                        order.BuhAccount = acc_sys.Accounts.FirstOrDefault(x => x.BuhCode == rec.AccBuhCode);
                        if (order.BuhAccount == null)
                        {
                            Trace.TraceWarning("Updater_1.1.1.220_OrderImport: Order >" + rec.Code + "< Account: >" + rec.AccBuhCode + "< not found");
                        }
                    }
                }
                foreach (fmCOrderExt order in orders)
                {
                    fmOrderImport order_record = records.FirstOrDefault(x => x.Code == order.Code);
                    if (order.Status != fmIOrderStatus.Project &&
                        order.Status != fmIOrderStatus.FinOpened && order_record == null)
                    {
                        order.Status = fmIOrderStatus.Deleting;
                        Trace.TraceWarning("Updater_1.1.1.220_OrderImport: Delete order >" + order.Code + "< Status: " + order.Status.ToString());
                    }
                    if (order.Status != fmIOrderStatus.Deleting && order.Status != fmIOrderStatus.Project &&
                        order.Status != fmIOrderStatus.FinOpened && order.Status != fmIOrderStatus.FinClosed &&
                        order.Status != fmIOrderStatus.Opened && order.Status != fmIOrderStatus.Closed)
                    {
                        order.Status = fmIOrderStatus.Loaded;
                    }
                }
            }