Esempio n. 1
1
        public void AppendOneToFile()
        {
            engine = new FileHelperEngine(typeof (SampleType));

            SampleType[] res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1).Date;
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now.Date;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            engine.WriteFile(@"test.txt", res);

            SampleType record = new SampleType();

            record.Field1 = DateTime.Now.Date;
            record.Field2 = "h2";
            record.Field3 = 2;

            engine.AppendToFile(@"test.txt", record);

            SampleType[] res2 = (SampleType[]) engine.ReadFile(@"test.txt");

            Assert.AreEqual(3, res2.Length);
            Assert.AreEqual(res[0].Field1, res2[0].Field1);
            Assert.AreEqual(res[1].Field1, res2[1].Field1);
            Assert.AreEqual(DateTime.Now.Date, res2[2].Field1);
        }
Esempio n. 2
0
        public void AppendOneToFile()
        {
            var engine = new FileHelperEngine <SampleType>();

            var res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1).Date;
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now.Date;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            engine.WriteFile(@"test.txt", res);

            var record = new SampleType();

            record.Field1 = DateTime.Now.Date;
            record.Field2 = "h2";
            record.Field3 = 2;

            engine.AppendToFile(@"test.txt", record);

            var res2 = (SampleType[])engine.ReadFile(@"test.txt");

            Assert.AreEqual(3, res2.Length);
            Assert.AreEqual(res[0].Field1, res2[0].Field1);
            Assert.AreEqual(res[1].Field1, res2[1].Field1);
            Assert.AreEqual(DateTime.Now.Date, res2[2].Field1);
        }
Esempio n. 3
0
        public void AppendToFile()
        {
            var engine = new FileHelperEngine<SampleType>();

            var res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1).Date;
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now.Date;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            engine.WriteFile(@"test.txt", res);
            engine.AppendToFile(@"test.txt", res);

            var res2 = (SampleType[]) engine.ReadFile(@"test.txt");

            Assert.AreEqual(4, res2.Length);
            Assert.AreEqual(res[0].Field1, res2[0].Field1);
            Assert.AreEqual(res[1].Field1, res2[1].Field1);
            Assert.AreEqual(res[0].Field1, res2[2].Field1);
            Assert.AreEqual(res[1].Field1, res2[3].Field1);
        }
Esempio n. 4
0
        public void AppendToEmpty()
        {
            File.Copy(TestCommon.GetPath("Good", "TestEmpty.txt"), "tempEmpty.txt", true);

            var engine = new FileHelperEngine <SampleType>();

            var res = new SampleType[1];

            res[0] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1).Date;
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            engine.AppendToFile(@"tempEmpty.txt", res);

            var res2 = (SampleType[])engine.ReadFile(@"tempEmpty.txt");

            Assert.AreEqual(1, res2.Length);
            Assert.AreEqual(res[0].Field1, res2[0].Field1);

            if (File.Exists("tempEmpty.txt"))
            {
                File.Delete("tempEmpty.txt");
            }
        }
Esempio n. 5
0
 public void PredictionToFile(string webRootPath, string lotteryCode)
 {
     if (string.IsNullOrEmpty(lotteryCode))
     {
         lotteryCode = GetLotteryCode();
     }
     try
     {
         Dictionary <string, TrainingData> dicPredictionData = GetPredictionData(lotteryCode);
         _logger.LogInformation("Start Prediction :" + lotteryCode);
         int i = 0, j = 0;
         IList <LotteryPredictionResult> resultList = new List <LotteryPredictionResult>();
         for (i = 0; i < noSite.Count; i++)
         {
             for (j = 0; j < noType.Count; j++)
             {
                 resultList.Add(PredictionOneToFile(webRootPath, noSite[i], noType[j], dicPredictionData[noSite[i]], lotteryCode));
             }
         }
         var engine = new FileHelperEngine <LotteryPredictionResult>();
         engine.AppendToFile(webRootPath + "/PredictionResult/" + DateTime.Now.ToString("yyyyMMddHH") + ".Txt", resultList);
     }
     catch (Exception ex)
     {
         _logger.LogError("预测出错 :" + ex.ToString());
     }
 }
Esempio n. 6
0
        public void AppendToFile()
        {
            engine = new FileHelperEngine(typeof(SampleType));

            SampleType[] res = new SampleType[2];

            res[0] = new SampleType();
            res[1] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1).Date;
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            res[1].Field1 = DateTime.Now.Date;
            res[1].Field2 = "ho";
            res[1].Field3 = 2;

            engine.WriteFile(@"test.txt", res);
            engine.AppendToFile(@"test.txt", res);

            SampleType[] res2 = (SampleType[])engine.ReadFile(@"test.txt");

            Assert.AreEqual(4, res2.Length);
            Assert.AreEqual(res[0].Field1, res2[0].Field1);
            Assert.AreEqual(res[1].Field1, res2[1].Field1);
            Assert.AreEqual(res[0].Field1, res2[2].Field1);
            Assert.AreEqual(res[1].Field1, res2[3].Field1);
        }
        private static void AppendAllPaymentsDump(string path, List <FHB_Payment> rcds)
        {
            // Write emulated CPWFHBP1 database. Append records to History File
            string newXlsName2 = (Path.Combine(Path.GetDirectoryName(path), "Logs_n_Data", Path.GetFileName(path).Substring(0, 12) + "_All_Payment_History_tab.txt"));
            FileHelperEngine <FHB_Payment> engine = new FileHelperEngine <FHB_Payment>();

            engine.AppendToFile(newXlsName2, rcds);
        }
Esempio n. 8
0
        public static void AddMoreUsersToCsvFile(User user)
        {
            var filePath = AppDomain.CurrentDomain.BaseDirectory.Substring(0,
                                                                           AppDomain.CurrentDomain.BaseDirectory.Length - 9) + "/Assets/userData.csv";
            var engine = new FileHelperEngine <User>();

            engine.AppendToFile(filePath, user);
        }
        public override void AddEntry(string eventType)
        {
            var entry = new LogEntry(eventType);

            var filename    = string.Format("{0:MMddyyHH}.csv", DateTime.Now);
            var writeEngine = new FileHelperEngine <LogEntry> ();

            writeEngine.AppendToFile(Path.Combine(_currentFilePath, filename), entry);

            CallEventLogEntryAddedHandlers(entry);
        }
Esempio n. 10
0
        public static void Save(Idea idea)
        {
            var engine = new FileHelperEngine(typeof(Idea));

            try
            {
                idea.Id = Guid.NewGuid().ToString();
                engine.AppendToFile(HttpRuntime.AppDomainAppPath + "/app_data/ideas.csv", idea);
            }
            catch
            {
            }
        }
Esempio n. 11
0
        public static void Save(Vote vote)
        {
            var engine = new FileHelperEngine(typeof(Vote));

            try
            {
                vote.Id = Guid.NewGuid().ToString();
                engine.AppendToFile(HttpRuntime.AppDomainAppPath + "/app_data/votes.csv", vote);
            }
            catch
            {
            }
        }
Esempio n. 12
0
 public void SaveMagentoFile(string MagentoFilePath, string HeaderRow, List <iMagentoRecord> mList)
 {
     try
     {
         List <MagentoRecord>             newlist       = mList.Cast <MagentoRecord>().ToList();
         FileHelperEngine <MagentoRecord> magentoEngine = new FileHelperEngine <MagentoRecord>();
         File.WriteAllText(MagentoFilePath, HeaderRow);
         magentoEngine.AppendToFile(MagentoFilePath, newlist);
     }
     catch
     {
         List <MagentoRecordSB>             newlist       = mList.Cast <MagentoRecordSB>().ToList();
         FileHelperEngine <MagentoRecordSB> magentoEngine = new FileHelperEngine <MagentoRecordSB>();
         File.WriteAllText(MagentoFilePath, HeaderRow);
         magentoEngine.AppendToFile(MagentoFilePath, newlist);
     }
 }
Esempio n. 13
0
        public static void SampleToFile(string path, Triangle sample)
        {
            var engine = new FileHelperEngine(typeof(Triangle));

            if (File.Exists(path))
            {
                engine.AppendToFile(path, sample);
            }
            else
            {
                engine.HeaderText = engine.GetFileHeader();
                engine.WriteFile(path, new List <Triangle>()
                {
                    sample
                });
            }
        }
Esempio n. 14
0
        public void BadAppend2()
        {
            var engine = new FileHelperEngine <SampleType>();

            File.Copy(TestCommon.GetPath("Bad", "BadAdd2.txt"), "BadAddTemp2.txt", true);

            SampleType record = new SampleType();

            record.Field1 = DateTime.Now.Date;
            record.Field2 = "AS";
            record.Field3 = 66;

            engine.AppendToFile(@"BadAddTemp2.txt", record);

            SampleType[] res2 = (SampleType[])engine.ReadFile(@"BadAddTemp2.txt");
            Assert.AreEqual(4, res2.Length);
            Assert.AreEqual("AS", res2[3].Field2);
            Assert.AreEqual(66, res2[3].Field3);
        }
    static void Main(string[] args)
    {
        // dummy test data
        var originalAllPersonRecords = new Person[]
        {
            new Person {
                FirstName = "John", LastName = "Lee", Optional2 = "title"
            },
        };    //This will only get the FirstName,LastName,Optional2. No result for Optional1 and Optional3
        var allPersonRecords = from p in originalAllPersonRecords select new OutputPerson {
            FirstName = p.FirstName, LastName = p.LastName, Optional2 = p.Optional2
        };
        FileHelperEngine enginePerson = new FileHelperEngine(typeof(OutputPerson));
        string           fileName     = "Wherever you want the file to go";

        enginePerson.AppendToFile(fileName, allPersonRecords);     //Write the records to the file
        //Current Output looks like this:John      Lee            title
        //The output which I want is:John      Lee       title
    }
Esempio n. 16
0
        public void BadAppend2()
        {
            engine = new FileHelperEngine(typeof(SampleType));

            File.Copy(@"..\data\Bad\BadAdd2.txt", "BadAddTemp2.txt", true);

            SampleType record = new SampleType();

            record.Field1 = DateTime.Now.Date;
            record.Field2 = "AS";
            record.Field3 = 66;

            engine.AppendToFile(@"BadAddTemp2.txt", record);

            SampleType[] res2 = (SampleType[])engine.ReadFile(@"BadAddTemp2.txt");
            Assert.AreEqual(4, res2.Length);
            Assert.AreEqual("AS", res2[3].Field2);
            Assert.AreEqual(66, res2[3].Field3);
        }
Esempio n. 17
0
        private void writeLogEntry()
        {
            string logPath = Path.Combine(@"C:\Users\wwestlake\AppData\Roaming\LagDaemon\GameEngine\logs", "ServerLog.txt");

            var engine = new FileHelperEngine <ServerLogEntry>();

            var log = new List <ServerLogEntry>();

            log.Add(new ServerLogEntry()
            {
                Date          = DateTime.Now,
                PlayerID      = "LagDaemon",
                EntryType     = LogEntryType.Information,
                EntrySeverity = LogEntrySeverity.Low,
                Entry         = "This is a test log entry"
            });

            engine.AppendToFile(logPath, log);
        }
Esempio n. 18
0
        public static void SampleToFile(string path, ShearTriangle2D sample)
        {
            var engine  = new FileHelperEngine(typeof(ShearTriangle2D));
            var samples = new List <ShearTriangle2D>()
            {
                sample
            };

            if (File.Exists(path))
            {
                engine.AppendToFile(path, sample);
            }
            else
            {
                engine.HeaderText = engine.GetFileHeader();
                engine.WriteFile("C:\\Users\\bergerd\\simplices.csv", new List <ShearTriangle2D>()
                {
                    sample
                });
            }
        }
Esempio n. 19
0
        public static void SampleToFile(string path, Simplex3D sample)
        {
            var engine  = new FileHelperEngine(typeof(Simplex3D));
            var samples = new List <Simplex3D>()
            {
                sample
            };

            if (File.Exists(path))
            {
                engine.AppendToFile(path, sample);
            }
            else
            {
                engine.HeaderText = engine.GetFileHeader();
                engine.WriteFile(path, new List <Simplex3D>()
                {
                    sample
                });
            }
        }
Esempio n. 20
0
        public void AppendToEmpty()
        {
            File.Copy(TestCommon.GetPath("Good", "TestEmpty.txt"), "tempEmpty.txt", true);

            engine = new FileHelperEngine(typeof (SampleType));

            SampleType[] res = new SampleType[1];

            res[0] = new SampleType();

            res[0].Field1 = DateTime.Now.AddDays(1).Date;
            res[0].Field2 = "je";
            res[0].Field3 = 0;

            engine.AppendToFile(@"tempEmpty.txt", res);

            SampleType[] res2 = (SampleType[]) engine.ReadFile(@"tempEmpty.txt");

            Assert.AreEqual(1, res2.Length);
            Assert.AreEqual(res[0].Field1, res2[0].Field1);

            if (File.Exists("tempEmpty.txt")) File.Delete("tempEmpty.txt");
        }
Esempio n. 21
0
        //add and validates new products to the file.
        public void add_product(TextBox tb1, TextBox tb2, ComboBox cb)
        {
            //using FileHelpers package to read and write to file.
            var engine  = new FileHelperEngine <products>();
            var product = new List <products>();
            var x       = new products();

            if (x.validate_record(tb1, cb) == true)
            {
                MessageBox.Show("Product is already stocked.");
            }
            else
            {
                product.Add(new products()
                {
                    product_name  = tb1.Text.ToUpper(),
                    supplier_name = cb.Text.ToUpper(),
                    quantity      = tb2.Text.ToUpper(),
                }
                            );
                engine.AppendToFile(@"D:\RSMS\Files\Stock\Product_Details.txt", product);
                MessageBox.Show("Successfully Added");
            }
        }
Esempio n. 22
0
        static void combineCSV()
        {
            if (File.Exists(@"C:\Users\Jiahai\Documents\Visual Studio 2012\Projects\UpdateEarning2\UpdateEarning2\bin\Debug\Earingdate.n.csv"))
            {
                File.Delete(@"C:\Users\Jiahai\Documents\Visual Studio 2012\Projects\UpdateEarning2\UpdateEarning2\bin\Debug\Earingdate.n.csv");
            }
            string[] files = Directory.GetFiles(@"C:\Users\Jiahai\Documents\Visual Studio 2012\Projects\UpdateEarning2\UpdateEarning2\bin\Debug\symbol\");
            for (int i = 0; i < (int)files.Length; i++)
            {
                string str = files[i];
                FileHelperEngine fileHelperEngine = new FileHelperEngine(typeof(symbollistCombine));
                symbollistCombine[] symbollistCombineArray = (symbollistCombine[])fileHelperEngine.ReadFile(str);
                IEnumerable<symbollistCombine> symbollistCombines = ((IEnumerable<symbollistCombine>)symbollistCombineArray).Where<symbollistCombine>((symbollistCombine d) => d.Earingdate != DateTime.Parse("1999/01/01"));
                fileHelperEngine.AppendToFile(@"C:\Users\Jiahai\Documents\Visual Studio 2012\Projects\UpdateEarning2\UpdateEarning2\bin\Debug\Earingdate.n.csv", symbollistCombines);
            }
            if (File.Exists("C:\\Users\\Jiahai\\Documents\\Visual Studio 2012\\Projects\\earingdataProj\\earingdataProj\\bin\\Debug\\updateEarning.csv"))
            {
                File.Delete("C:\\Users\\Jiahai\\Documents\\Visual Studio 2012\\Projects\\earingdataProj\\earingdataProj\\bin\\Debug\\updateEarning.csv");
                File.Copy(@"C:\Users\Jiahai\Documents\Visual Studio 2012\Projects\UpdateEarning2\UpdateEarning2\bin\Debug\Earingdate.n.csv", "C:\\Users\\Jiahai\\Documents\\Visual Studio 2012\\Projects\\earingdataProj\\earingdataProj\\bin\\Debug\\updateEarning.csv");
            }
            else
            {
                File.Copy(@"C:\Users\Jiahai\Documents\Visual Studio 2012\Projects\UpdateEarning2\UpdateEarning2\bin\Debug\Earingdate.n.csv", "C:\\Users\\Jiahai\\Documents\\Visual Studio 2012\\Projects\\earingdataProj\\earingdataProj\\bin\\Debug\\updateEarning.csv");

            }
        }
Esempio n. 23
0
        private void move_Rectangle(object sender, MouseButtonEventArgs e)
        {
            int[,] pozice = new int[100, 2];

            /*while (true)
             * {*/
            if (_isRectDragInProg == false)
            {
                _isRectDragInProg = true;
                obj = sender as Rectangle;
                Panel.SetZIndex(obj, 100);

                //Console.WriteLine(obj.Name);

                obj.CaptureMouse();



                //Console.WriteLine(pocetradky);
                //Console.WriteLine(pocetsloupce);
            }
            else if (_isRectDragInProg == true)
            {
                List <Pozice> fill = new List <Pozice>();
                List <Pozice> akt  = new List <Pozice>();

                foreach (UIElement cell in grid.Children)
                {
                    int x  = Grid.GetColumn(cell);
                    int y  = Grid.GetRow(cell);
                    int xa = Grid.GetColumnSpan(cell);
                    int ya = Grid.GetRowSpan(cell);


                    if (cell.GetValue(NameProperty).ToString() == obj.Name)
                    {
                        Console.WriteLine(cell.GetValue(NameProperty));
                        Console.WriteLine(obj.Name);
                        if (xa == 0)
                        {
                            akt.Add(new Pozice(x + 1, y));
                            akt.Add(new Pozice(x, y));
                        }
                        else
                        {
                            akt.Add(new Pozice(x, y));
                        }

                        if (ya == 0)
                        {
                            akt.Add(new Pozice(x, y + 1));
                            akt.Add(new Pozice(x, y));
                        }
                        else
                        {
                            akt.Add(new Pozice(x, y));
                        }
                    }
                    else
                    {
                        Console.WriteLine(cell.GetValue(NameProperty));


                        if (xa == 0)
                        {
                            fill.Add(new Pozice(x + 1, y));
                            fill.Add(new Pozice(x, y));
                        }
                        else
                        {
                            fill.Add(new Pozice(x, y));
                        }

                        if (ya == 0)
                        {
                            fill.Add(new Pozice(x, y + 1));
                            fill.Add(new Pozice(x, y));
                        }
                        else
                        {
                            fill.Add(new Pozice(x, y));
                        }
                    }
                }
                foreach (var o in fill)
                {
                    Console.WriteLine(o.x + ", " + o.y);
                }
                foreach (var d in akt)
                {
                    Console.WriteLine(d.x + ", " + d.y);
                }

                foreach (var o in akt)
                {
                    foreach (var d in fill)
                    {
                        if (d.x == o.x && d.y == o.y)
                        {
                            isFilled = true;
                            Console.WriteLine(isFilled);
                        }
                    }
                }
                if (isFilled == true)
                {
                    _isRectDragInProg = true;
                }
                else
                {
                    obj.ReleaseMouseCapture();

                    Panel.SetZIndex(obj, 0);
                    _isRectDragInProg = false;
                    var engine = new FileHelperEngine <Position>();

                    var orders = new List <Position>();

                    orders.Add(new Position()
                    {
                        Name = obj.Name,
                        xpos = Grid.GetColumn(obj),
                        ypos = Grid.GetRow(obj)
                    });

                    engine.AppendToFile("position.txt", orders);
                }
                isFilled = false;

                /*{
                 *  //break;
                 * }
                 * else
                 * {
                 *  obj.ReleaseMouseCapture();
                 *  _isRectDragInProg = false;
                 *  _isRectDragInProg = true;
                 * }*/
            }
            //}
        }
Esempio n. 24
0
        public void BadAppend2()
        {
            engine = new FileHelperEngine(typeof (SampleType));

            File.Copy(TestCommon.GetPath("Bad", "BadAdd2.txt"), "BadAddTemp2.txt", true);

            SampleType record = new SampleType();

            record.Field1 = DateTime.Now.Date;
            record.Field2 = "AS";
            record.Field3 = 66;

            engine.AppendToFile(@"BadAddTemp2.txt", record);

            SampleType[] res2 = (SampleType[]) engine.ReadFile(@"BadAddTemp2.txt");
            Assert.AreEqual(4, res2.Length);
            Assert.AreEqual("AS", res2[3].Field2);
            Assert.AreEqual(66, res2[3].Field3);
        }
Esempio n. 25
0
        private static void backtest(int quarter,decimal threshold, int buyinpower)
        {
            TimeSpan st = DateTime.Now.TimeOfDay;
             #region hoilday dictionary
              bool flag3;
               Dictionary<string, DateTime> strs3 = new Dictionary<string, DateTime>();
            List<EarningData> earningDatas = new List<EarningData>();
            FileStream fileStream1 = new FileStream("holiday.txt", FileMode.Open);
            StreamReader streamReader1 = new StreamReader(fileStream1);
            do
            {
                string str1 = streamReader1.ReadLine();
                if (!(str1 == ""))
                {
                    strs3[str1] = DateTime.ParseExact(str1, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None);
                    flag3 = (str1 == null ? false : str1 != "");
                }
                else
                {
                    break;
                }
            } while (flag3);

            streamReader1.Close();
            streamReader1.Dispose();
            fileStream1.Close();
            fileStream1.Dispose();
               #endregion

            #region get the quarter

            int year = quarter / 10;
            string begindate = year.ToString();
            string enddate = year.ToString();
            if (quarter % 10 == 1)
            {
                begindate = string.Concat(begindate, "0101");
                enddate = string.Concat(enddate, "0315");
            }
            if (quarter % 10 == 2)
            {

                begindate = string.Concat(begindate, "0401");
                enddate = string.Concat(enddate, "0615");
            }
            if (quarter % 10 == 3)
            {

                begindate = string.Concat(begindate, "0701");
                enddate = string.Concat(enddate, "0915");
            }
            if (quarter % 10 == 4)
            {

                begindate = string.Concat(begindate, "1001");
                enddate = string.Concat(enddate, "1215");
            }

            #endregion

            #region create bio tech symbols Dic

            bool flag2;
            Dictionary<string, string> bioArry = new Dictionary<string, string>();
            FileStream fileStream = new FileStream("bio.csv", FileMode.Open);
            StreamReader streamReader = new StreamReader(fileStream);
            streamReader.BaseStream.Seek((long)0, SeekOrigin.Begin);
            string str2 = streamReader.ReadLine();
            while (true)
            {
                flag2 = (str2 == null ? false : str2 != "");
                if (!flag2)
                {
                    break;
                }
                bioArry[str2] = str2;
                str2 = streamReader.ReadLine();
            }
            streamReader.Close();
            streamReader.Dispose();
            fileStream.Close();
            fileStream.Dispose();

            #endregion

            #region get right the earingdata

            FileHelperEngine EngineDBq = new FileHelperEngine(typeof(DailyData1));
            DailyData1[] resDB = (DailyData1[])EngineDBq.ReadFile(string.Format("Daily\\DailyQua\\{0}.csv", quarter));
            FileHelperEngine EngineEarning = new FileHelperEngine(typeof(unionearingdate));
            unionearingdate[] unionearingdateArray = (unionearingdate[])EngineEarning.ReadFile("Daily\\final.csv");

            var selectEarningdata = unionearingdateArray.Where(d =>
                d.date >= DateTime.ParseExact(begindate, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None) &&
                d.date <= DateTime.ParseExact(enddate, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None)).
                Where(d => Math.Abs(d.threshold) >= threshold).
                Where(d => (d.high >= d.maxhigh && d.threshold > 0) || (d.low <= d.minlow && d.threshold < 0)).
                Where(d => {
                    bool symbolExit;
                    symbolExit = !bioArry.ContainsKey(d.symbol);
                    return symbolExit;
                }).
                Where(d=>d.high>=5)
                ;

            EngineEarning.WriteFile("Daily\\temp.csv", selectEarningdata);
            unionearingdate[] earningdata = (unionearingdate[])EngineEarning.ReadFile("Daily\\temp.csv");

            #endregion

            #region combin earning and spy in daily report

            #region select data from DB
            var spy=resDB.Where(d=>d.symbol=="SPY");

            var selectDB = from db in resDB
                           from e in earningdata
                           where (db.symbol == e.symbol) && (db.date >= e.date)
                           select new DailyDataout
                           {
                               symbol=db.symbol,
                               open=db.open,
                               high=db.high,
                               low=db.low,
                               close=db.close,
                               volume=db.volume,
                               adv=db.adv,
                               threshold=e.threshold,
                               date=db.date
                           };

            selectDB = selectDB.Where(dd => dd.date <= DateTime.ParseExact(enddate, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None));

            FileHelperEngine EngineOut = new FileHelperEngine(typeof(DailyDataout));
            EngineOut.HeaderText = "symbol,date,open,high,low,close,volume,Exist signal price,pricein,priceout,threshold,spy close,spy open,spy high, spy low,adv,win10,lose10,overnight pnl,day pnl,pnl,spy overnight pnl,spy day pnl, spy pnl,bp,beta";
            EngineOut.WriteFile("Daily\\temp.csv", selectDB);
            #endregion

            #region combine spy
            DailyDataout[] selectD = (DailyDataout[])EngineOut.ReadFile("Daily\\temp.csv");

            var combinspy = from db in selectD
                            join e in spy on db.date equals e.date
                            select new DailyDataout
                            {
                                symbol = db.symbol,
                                open = db.open,
                                high = db.high,
                                low = db.low,
                                close = db.close,
                                volume = db.volume,
                                adv = db.adv,
                                threshold = db.threshold,
                                date = db.date,
                                spyclose=e.close,
                                spyopen=e.open,
                                spylow=e.low,
                                spyhigh=e.high
                            };
            #endregion

            bool yc2tc = false;

            #region add beta
            if (yc2tc)
            {

                #region get beta close to close

                List<DailyDataout> newcombinspy = new List<DailyDataout>();
                string symbol = "";
                decimal beta = 0;
                decimal yesterdayClose = 0;
                decimal yesterdaySPYClose = 0;
                foreach (var data in combinspy)
                {
                    DailyDataout tempdailyout = new DailyDataout();
                    tempdailyout = data;

                    if (tempdailyout.symbol == symbol)
                    {
                        beta = ((tempdailyout.close / yesterdayClose) / (tempdailyout.spyclose / yesterdaySPYClose) - 1) * 100;
                        tempdailyout.beta = beta;
                        yesterdayClose = tempdailyout.close;
                        yesterdaySPYClose = tempdailyout.spyclose;
                    }
                    else
                    {
                        symbol = tempdailyout.symbol;
                        yesterdayClose = tempdailyout.close;
                        yesterdaySPYClose = tempdailyout.spyclose;
                    }
                    newcombinspy.Add(tempdailyout);
                }

            #endregion

                EngineOut.WriteFile("Daily\\temp.csv", newcombinspy);
            }
            else
            {

              #region get beta close to open

            List<DailyDataout> newcombinspy = new List<DailyDataout>();
            string symbol = "";
            decimal beta = 0;
            foreach (var data in combinspy)
            {
                DailyDataout tempdailyout = new DailyDataout();
                tempdailyout = data;

                if (tempdailyout.symbol == symbol)
                {
                    beta = ((tempdailyout.close / tempdailyout.open) / (tempdailyout.spyclose / tempdailyout.spyopen) - 1) * 100;
                    tempdailyout.beta = beta;
                }
                else
                {
                    symbol = tempdailyout.symbol;
                    beta = ((tempdailyout.close / tempdailyout.open) / (tempdailyout.spyclose / tempdailyout.spyopen) - 1) * 100;
                }
                newcombinspy.Add(tempdailyout);
            }

            #endregion

              EngineOut.WriteFile("Daily\\temp.csv", newcombinspy);
            }
            #endregion

            #endregion

            #region date thrshold

            DateTime lastDate = DateTime.ParseExact(enddate, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None);

            if (lastDate.DayOfWeek == DayOfWeek.Sunday)
            {
                if (strs3.ContainsKey(lastDate.AddDays(-2).ToString("yyyyMMdd")) || strs3.ContainsKey(lastDate.AddDays(-3).ToString("yyyyMMdd")))
                {
                    lastDate = lastDate.AddDays(-4);
                }
                else
                lastDate = lastDate.AddDays(-3);
            }
            else if (lastDate.DayOfWeek == DayOfWeek.Saturday)
            {
                if (strs3.ContainsKey(lastDate.AddDays(-1).ToString("yyyyMMdd")) || strs3.ContainsKey(lastDate.AddDays(-2).ToString("yyyyMMdd")))
                {
                    lastDate = lastDate.AddDays(-3);
                }
                else
                    lastDate = lastDate.AddDays(-2);
            }
            else if (lastDate.DayOfWeek == DayOfWeek.Monday)
            {
                if (strs3.ContainsKey(lastDate.ToString("yyyyMMdd")) || strs3.ContainsKey(lastDate.AddDays(-3).ToString("yyyyMMdd")))
                {
                    lastDate = lastDate.AddDays(-4);
                }
                    else
                lastDate = lastDate.AddDays(-3);
            }
            else if (lastDate.DayOfWeek == DayOfWeek.Tuesday)
            {
                if (strs3.ContainsKey(lastDate.ToString("yyyyMMdd")) || strs3.ContainsKey(lastDate.AddDays(-1).ToString("yyyyMMdd")))
                {
                    lastDate = lastDate.AddDays(-4);
                }
                else
                    lastDate = lastDate.AddDays(-1);

            }
            else
            {
                if (strs3.ContainsKey(lastDate.ToString("yyyyMMdd")) || strs3.ContainsKey(lastDate.AddDays(-1).ToString("yyyyMMdd")))
                {
                    lastDate = lastDate.AddDays(-2);
                }
                else
                    lastDate = lastDate.AddDays(-1);

            }

            #endregion

            strategy2ExitbySumBeta(quarter, threshold, buyinpower, (decimal)5, lastDate);

            DailyGroupbysymbol(quarter, threshold);

            #region create daily report

            //FileHelperEngine enginDR = new FileHelperEngine(typeof(DailyDataout));
            //enginDR.WriteFile(string.Format("DailyReport\\{0}.{1}.D.csv", quarter, Convert.ToInt32(threshold * new decimal(100))), ReportEaring);

            DailyDataout[] ReportEaring = (DailyDataout[])EngineOut.ReadFile(string.Format("DailyReport\\{0}.{1}.D.csv", quarter, Convert.ToInt32(threshold * new decimal(100))));

            var DailyReport = ReportEaring.GroupBy(d => d.date).Select(d => new DailyReport
            {
              date=d.Key,
              pnl=d.Sum(dd=>dd.pnl)+d.Sum(dd=>dd.spypnl),
              pnlovernight=d.Sum(dd=>dd.overnightpnl)+d.Sum(dd=>dd.overnightspypnl),
              pnlday=d.Sum(dd=>dd.daypnl)+d.Sum(dd=>dd.dayspypnl),
              longcount=d.Where(dd=>dd.threshold>0).Count(),
              shortcount=d.Where(dd=>dd.threshold<0).Count(),
              longpnl=d.Where(dd=>dd.threshold>0).Sum(dd=>dd.pnl),
              shortpnl = d.Where(dd => dd.threshold < 0).Sum(dd => dd.pnl),
              qua=quarter,
              lose10=d.Sum(dd=>dd.lose10),
              win10=d.Sum(dd=>dd.win10),
              hspypnl = d.Sum(dd => dd.spypnl),

            }).OrderBy(d=>d.date);
            #endregion

            #region get the bp and accpnl daily
            List<DailyReport> newDailyReport = new List<DailyReport>();
            decimal accPnl = 0;
            foreach(var date in DailyReport)
            {
                DailyReport tempdailyreport = new DailyReport();
                tempdailyreport = date;

                accPnl = accPnl + date.pnl;
                tempdailyreport.accPnl = accPnl;
                tempdailyreport.bp = Math.Max(date.longcount, date.shortcount) * 2 * buyinpower;
                newDailyReport.Add(tempdailyreport);
            }
            #endregion

            #region get the dollar sharpe
            decimal avgPnl = newDailyReport.Select(d => d.accPnl).Last() / newDailyReport.Where(d => d.pnl != 0).Count();

            List<DailyReport> finalDailyReport = new List<DailyReport>();
            decimal SD = 0;
            int count = 1;
            foreach(var date in newDailyReport)
            {
                DailyReport tempdailyreport = new DailyReport();
                tempdailyreport = date;

                SD = SD + (date.pnl - avgPnl) * (date.pnl - avgPnl);

                if (count != 1)
                    date.dollarSharp = avgPnl / (decimal)(Math.Sqrt(Convert.ToDouble(SD) / ((count - 1)*252)));
                finalDailyReport.Add(tempdailyreport);
                count++;
            }

            FileHelperEngine fileHelperEngine5 = new FileHelperEngine(typeof(DailyReport));
            fileHelperEngine5.HeaderText = "date,longpnl,shortpnl,longcount,shortcount,quarter,dollarsharp,bp,win10,lose10,spy hedge pnl,pnl overnight, pnl day,pnl,acc pnl";
            if (!File.Exists("DailyReport\\R.csv"))
            {
                fileHelperEngine5.WriteFile(string.Format("DailyReport\\R.csv", quarter, Convert.ToInt32(threshold * new decimal(100))), finalDailyReport);
            }
            else
            {
                fileHelperEngine5.AppendToFile(string.Format("DailyReport\\R.csv", quarter, Convert.ToInt32(threshold * new decimal(100))), finalDailyReport);
            }

            #endregion

            TimeSpan en = DateTime.Now.TimeOfDay;
            Console.WriteLine(en-st);
        }
Esempio n. 26
0
 private static void createQua()
 {
     IEnumerable<DailyData1> dailyData1s;
     int num = 2014;
     int num1 = 2014;
     string[] strArrays = new string[] { "0101", "0401", "0701", "1001" };
     string[] strArrays1 = strArrays;
     strArrays = new string[] { "0501", "0801", "1101", "0201" };
     string[] strArrays2 = strArrays;
     while (num <= num1)
     {
         for (int i = 0; i < 4; i++)
         {
             if (File.Exists((string.Format("Daily\\DailyQua\\{0}{1}.csv", num, i + 1))))
             {
                 File.Delete(string.Format("Daily\\DailyQua\\{0}{1}.csv", num, i + 1));
             }
             string[] files = Directory.GetFiles("Daily\\DBadv");
             for (int j = 0; j < (int)files.Length; j++)
             {
                 string str = files[j];
                 FileHelperEngine fileHelperEngine = new FileHelperEngine(typeof(DailyData1));
                 DailyData1[] dailyData1Array = (DailyData1[])fileHelperEngine.ReadFile(str);
                 if (i == 3)
                 {
                     DailyData1[] dailyData1Array1 = dailyData1Array;
                     IEnumerable<DailyData1> dailyData1s1 = ((IEnumerable<DailyData1>)dailyData1Array1).Where<DailyData1>((DailyData1 d) =>
                     {
                         bool flag = d.date >= DateTime.ParseExact(string.Format("{0}{1}", num, strArrays1[i]), "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None);
                         return flag;
                     });
                     dailyData1s = dailyData1s1.Where<DailyData1>((DailyData1 d) =>
                     {
                         bool flag = d.date < DateTime.ParseExact(string.Format("{0}{1}", num + 1, strArrays2[i]), "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None);
                         return flag;
                     });
                     fileHelperEngine.AppendToFile(string.Format("Daily\\DailyQua\\{0}{1}.csv", num, i + 1), dailyData1s);
                 }
                 else
                 {
                     DailyData1[] dailyData1Array2 = dailyData1Array;
                     IEnumerable<DailyData1> dailyData1s2 = ((IEnumerable<DailyData1>)dailyData1Array2).Where<DailyData1>((DailyData1 d) =>
                     {
                         bool flag = d.date >= DateTime.ParseExact(string.Format("{0}{1}", num, strArrays1[i]), "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None);
                         return flag;
                     });
                     dailyData1s = dailyData1s2.Where<DailyData1>((DailyData1 d) =>
                     {
                         bool flag = d.date < DateTime.ParseExact(string.Format("{0}{1}", num, strArrays2[i]), "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None);
                         return flag;
                     });
                     fileHelperEngine.AppendToFile(string.Format("Daily\\DailyQua\\{0}{1}.csv", num, i + 1), dailyData1s);
                 }
             }
         }
         num++;
     }
 }
Esempio n. 27
0
        /// <summary>
        /// Copies files from one directory to another recursively.
        /// An existing destination-file is replaced if the respective source file is newer and kept if it isn't.
        ///
        /// Additionally, a logfile is writen, containing the actions performed in the following format:
        ///    COPIED;C:\source\path\file.x;D:\destination\path\file.x
        ///    REPLACED;C:\source\path\file.x;D:\destination\path\file.x
        ///    NOT-REPLACED;C:\source\path\file.x;D:\destination\path\file.x
        ///    FAILED;C:\source\path\file.x;D:\destination\path\file.x
        ///
        /// Parameters:
        ///  -s  ... followed by space and the path of the source directory
        ///  -d  ... followed by space and the path of the destination directory
        ///  -l  ... followed by space and the name of the logfile
        ///  -nl ... create new logfile, i.e. delete the contents of an existing logfile
        ///  -al ... append to existing logfile, i.e. do not delete existing logfile contents
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            string sourceFolder      = null;
            string destinationFolder = null;
            string logfileName       = null;
            bool?  logfileCreateNew  = null;

            for (int i = 0; i < args.Length; ++i)
            {
                if (args[i] == "-s")
                {
                    if (i + 1 >= args.Length)
                    {
                        MessageBox.Show("Invalid parameters: No source folder specified after parameter -s");
                        Environment.Exit(-1);
                    }
                    sourceFolder = args[++i];
                }
                else if (args[i] == "-d")
                {
                    if (i + 1 >= args.Length)
                    {
                        MessageBox.Show("Invalid parameters: No destination folder specified after parameter -d");
                        Environment.Exit(-1);
                    }
                    destinationFolder = args[++i];
                }
                else if (args[i] == "-l")
                {
                    if (i + 1 >= args.Length)
                    {
                        MessageBox.Show("Invalid parameters: No logfile name specified after parameter -l");
                        Environment.Exit(-1);
                    }
                    logfileName = args[++i];
                }
                else if (args[i] == "-nl")
                {
                    logfileCreateNew = true;
                }
                else if (args[i] == "-al")
                {
                    logfileCreateNew = false;
                }
            }

            if (null == sourceFolder)
            {
                MessageBox.Show("Missing parameter: source folder");
                Environment.Exit(-1);
            }
            if (null == destinationFolder)
            {
                MessageBox.Show("Missing parameter: destination folder");
                Environment.Exit(-1);
            }
            if (null != logfileName && null == logfileCreateNew)
            {
                MessageBox.Show("Invalid configuration: If you specify log-file, please also state -nl or -al parameter");
                Environment.Exit(-1);
            }

            try
            {
                if (null == logfileName)
                {
                    CopyAllFilesFromSourceToDestination(sourceFolder, destinationFolder, new List <CopyFileLogEntry>());
                }
                else
                {
                    var engine      = new FileHelperEngine <CopyFileLogEntry>();
                    var logContents = new List <CopyFileLogEntry>();
                    CopyAllFilesFromSourceToDestination(sourceFolder, destinationFolder, logContents);

                    var destLogFileName = Path.Combine(destinationFolder, logfileName);
                    if (File.Exists(destLogFileName) && !logfileCreateNew.Value)
                    {
                        // exists and should append
                        engine.AppendToFile(destLogFileName, logContents);
                    }
                    else
                    {
                        // all other cases: doesn't exist or exists and should not append
                        engine.WriteFile(destLogFileName, logContents);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 28
0
 public static void append(String file, params Record[] records)
 {
     checkEngine();
     engine.AppendToFile(file, records);
 }
        /// <summary>
        /// Appends a search object to SearchData.txt file
        /// </summary>
        /// <param name="search"></param>
        private void AddSearch(Search search)
        {
            FileHelperEngine fileHelper = new FileHelperEngine(typeof(SearchData));
            SearchData[] result = new SearchData[1];

            result[0] = new SearchData();
            result[0].Term = search.Term;
            result[0].Type = search.Type;
            //result[0].Date = search.Date;
            
            // TODO: Fix permissions issue

            fileHelper.AppendToFile("SearchData.txt", result);
        }
Esempio n. 30
0
        public static void GuardarItfTXT(out string NombreProcesado, eFact_Entidades.Lote Lote, string PreFijo, string Ruta, bool IF)
        {
            //Deserializar ( pasar de XML a FeaEntidades.InterFacturas.lote_comprobantes )
            FeaEntidades.InterFacturas.lote_comprobantes Lc = new FeaEntidades.InterFacturas.lote_comprobantes();
            eFact_RN.Lote.DeserializarLc(out Lc, Lote, IF);

            //Evento de escritura de txt
            List<FeaEntidades.InterFacturas.cabecera_lote> clote = new List<FeaEntidades.InterFacturas.cabecera_lote>();
            clote.Add(Lc.cabecera_lote);
            FileHelperEngine e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.cabecera_lote));
            string nombreProcesado = "";
            GenerarNombreArch(out nombreProcesado, Ruta, PreFijo, Lote, "txt");
            NombreProcesado = nombreProcesado;
            e.WriteFile(NombreProcesado, clote);
            for (int i = 0; i < Lc.cabecera_lote.cantidad_reg; i++)
            {
                List<FeaEntidades.InterFacturas.informacion_comprador> icomprador = new List<FeaEntidades.InterFacturas.informacion_comprador>();
                icomprador.Add(Lc.comprobante[i].cabecera.informacion_comprador);
                e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.informacion_comprador));
                e.AppendToFile(NombreProcesado, icomprador);
                
                List<FeaEntidades.InterFacturas.informacion_comprobante> icomprobante = new List<FeaEntidades.InterFacturas.informacion_comprobante>();
                icomprobante.Add(Lc.comprobante[i].cabecera.informacion_comprobante);
                e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.informacion_comprobante));
                e.AppendToFile(NombreProcesado, icomprobante);

                List<FeaEntidades.InterFacturas.informacion_vendedor> ivendedor = new List<FeaEntidades.InterFacturas.informacion_vendedor>();
                ivendedor.Add(Lc.comprobante[i].cabecera.informacion_vendedor);
                e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.informacion_vendedor));
                e.AppendToFile(NombreProcesado, ivendedor);

                if (Lc.comprobante[i].cabecera.informacion_comprobante.referencias != null)
                {
                    e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.informacion_comprobanteReferencias));
                    e.AppendToFile(NombreProcesado, Lc.comprobante[i].cabecera.informacion_comprobante.referencias);
                }

                List<FeaEntidades.InterFacturas.detalle> idetalle = new List<FeaEntidades.InterFacturas.detalle>();
                idetalle.Add(Lc.comprobante[i].detalle);
                e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.detalle));
                e.AppendToFile(NombreProcesado, idetalle);

                foreach (FeaEntidades.InterFacturas.linea linea in Lc.comprobante[i].detalle.linea)
                {
                    e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.linea));
                    List<FeaEntidades.InterFacturas.linea> ilinea = new List<FeaEntidades.InterFacturas.linea>();
                    ilinea.Add(linea);
                    e.AppendToFile(NombreProcesado, ilinea);
                    if (linea.importes_moneda_origen != null)
                    {
                        List<FeaEntidades.InterFacturas.lineaImportes_moneda_origen> ilineaImportesMonedaOrigen = new List<FeaEntidades.InterFacturas.lineaImportes_moneda_origen>();
                        ilineaImportesMonedaOrigen.Add(linea.importes_moneda_origen);
                        e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.lineaImportes_moneda_origen));
                        e.AppendToFile(NombreProcesado, ilineaImportesMonedaOrigen);
                    }
                    if (linea.informacion_adicional != null)
                    {
                        e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.lineaInformacion_adicional));
                        e.AppendToFile(NombreProcesado, linea.informacion_adicional);
                    }
                }

                if (Lc.comprobante[i].cabecera.informacion_comprobante.informacion_exportacion != null)
                {
                    e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.informacion_exportacion));
                    e.AppendToFile(NombreProcesado, Lc.comprobante[i].cabecera.informacion_comprobante.informacion_exportacion);
                    if (Lc.comprobante[i].cabecera.informacion_comprobante.informacion_exportacion.permisos != null)
                    {
                        e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.permisos));
                        e.AppendToFile(NombreProcesado, Lc.comprobante[i].cabecera.informacion_comprobante.informacion_exportacion.permisos);
                    }
                }
                
                if (Lc.comprobante[i].extensiones != null)
                {
                    e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.extensiones));
                    e.AppendToFile(NombreProcesado, Lc.comprobante[i].extensiones);
                    if (Lc.comprobante[i].extensiones.extensiones_camara_facturas != null)
                    {
                        e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.extensionesExtensiones_camara_facturas));
                        e.AppendToFile(NombreProcesado, Lc.comprobante[i].extensiones.extensiones_camara_facturas);
                    }
                    if (Lc.comprobante[i].extensiones.extensiones_destinatarios != null)
                    {
                        e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.extensionesExtensiones_destinatarios));
                        e.AppendToFile(NombreProcesado, Lc.comprobante[i].extensiones.extensiones_destinatarios);
                    }
                }

                if (Lc.comprobante[i].resumen.descuentos != null)
                {
                    foreach (FeaEntidades.InterFacturas.resumenDescuentos descuento in Lc.comprobante[i].resumen.descuentos)
                    {
                        List<FeaEntidades.InterFacturas.resumenDescuentos> iresumenDescuentos = new List<FeaEntidades.InterFacturas.resumenDescuentos>();
                        iresumenDescuentos.Add(descuento);
                        e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.resumenDescuentos));
                        e.AppendToFile(NombreProcesado, iresumenDescuentos);
                    }
                }

                if (Lc.comprobante[i].resumen.impuestos != null)
                {
                    foreach (FeaEntidades.InterFacturas.resumenImpuestos impuesto in Lc.comprobante[i].resumen.impuestos)
                    {
                        List<FeaEntidades.InterFacturas.resumenImpuestos> iresumenImpuestos = new List<FeaEntidades.InterFacturas.resumenImpuestos>();
                        iresumenImpuestos.Add(impuesto);
                        e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.resumenImpuestos));
                        e.AppendToFile(NombreProcesado, iresumenImpuestos);
                    }
                }

                if (Lc.comprobante[i].resumen.importes_moneda_origen != null)
                {
                    List<FeaEntidades.InterFacturas.resumenImportes_moneda_origen> iresumenImportesMonedaOrigen = new List<FeaEntidades.InterFacturas.resumenImportes_moneda_origen>();
                    iresumenImportesMonedaOrigen.Add(Lc.comprobante[i].resumen.importes_moneda_origen);
                    e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.resumenImportes_moneda_origen));
                    e.AppendToFile(NombreProcesado, iresumenImportesMonedaOrigen);
                }

                List<FeaEntidades.InterFacturas.resumen> iresumen = new List<FeaEntidades.InterFacturas.resumen>();
                iresumen.Add(Lc.comprobante[i].resumen);
                e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.resumen));
                e.AppendToFile(NombreProcesado, iresumen);
            }
        }
Esempio n. 31
0
        public static void GuardarItfTXTlr(out string NombreProcesado, eFact_Entidades.Lote Lote, string PreFijo, string Ruta, bool IF)
        {
            //Deserializar ( pasar de XML a FeaEntidades.InterFacturas.lote_comprobantes )
            List<FeaEntidades.InterFacturas.lote_response> lLr = new List<FeaEntidades.InterFacturas.lote_response>();
            FeaEntidades.InterFacturas.lote_response Lr = new FeaEntidades.InterFacturas.lote_response();
            eFact_RN.Lote.DeserializarLr(out Lr, Lote.LoteXmlIF);
            lLr.Add(Lr);

            //Evento de escritura de txt
            FileHelperEngine e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.lote_response));
            string nombreProcesado = "";
            GenerarNombreArch(out nombreProcesado, Ruta, PreFijo, Lote, "txt");
            NombreProcesado = nombreProcesado;
            e.WriteFile(NombreProcesado, lLr);

            foreach (FeaEntidades.InterFacturas.error elote in Lr.errores_lote)
            {
                if (elote != null)
                {
                    List<FeaEntidades.InterFacturas.error> ierrores_lote = new List<FeaEntidades.InterFacturas.error>();
                    ierrores_lote.Add(elote);
                    e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.error));
                    e.AppendToFile(NombreProcesado, ierrores_lote);
                }
            }
            if (Lr.comprobante_response != null)
            {
                foreach (FeaEntidades.InterFacturas.comprobante_response comprobante in Lr.comprobante_response)
                {
                    List<FeaEntidades.InterFacturas.comprobante_response> icr = new List<FeaEntidades.InterFacturas.comprobante_response>();
                    icr.Add(comprobante);
                    e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.comprobante_response));
                    e.AppendToFile(NombreProcesado, icr);
                    if (comprobante.errores_comprobante != null)
                    {
                        foreach (FeaEntidades.InterFacturas.error ecomprobante in comprobante.errores_comprobante)
                        {
                            if (ecomprobante != null)
                            {
                                List<FeaEntidades.InterFacturas.error> ierrores_comprobante = new List<FeaEntidades.InterFacturas.error>();
                                ierrores_comprobante.Add(ecomprobante);
                                e = new FileHelperEngine(typeof(FeaEntidades.InterFacturas.error));
                                e.AppendToFile(NombreProcesado, ierrores_comprobante);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 32
0
 public void Append(Part part)
 {
     engine.AppendToFile(filePath, part);
 }