Exemple #1
0
        static void Main(string[] args)
        {
            //string pathToSCV = @"D:\WORK\Education\4_course\1_semestr\IntTech\GSTU.IntTech.Lab1\Lab_1\Lab_1\bin\Debug\netcoreapp2.1\csv\data.csv";
            //string pathToOutFile = @"D:\WORK\Education\4_course\1_semestr\IntTech\GSTU.IntTech.Lab1\Lab_1\Lab_1\bin\Debug\netcoreapp2.1\excel\data.xlsx";
            //string format = "xlsx";
            if (args.Length == 3)
            {
                string pathToSCV     = args[0];
                string pathToOutFile = args[1];
                string format        = args[2].ToUpper();
                Group  group         = new Group(CSVUtils.GetStudents(pathToSCV));
                switch (format.ToUpper())
                {
                case "JSON":
                    JsonWriter.SaveGroup(group, pathToOutFile);
                    break;

                case "XLSX":
                    ExcelWriter.SaveGroup(group, pathToOutFile);
                    break;

                default:
                    Console.WriteLine("Неверный формат файла");
                    break;
                }
            }
            else
            {
                Console.WriteLine("Неправильное количество аргументов");
            }
        }
    private static Asteroid ParseAsteroid(string line)
    {
        Asteroid asteroid = new Asteroid();
        int      i        = 0;

        asteroid.SpkID              = CSVUtils.ParseInt(line, ref i);
        asteroid.FullName           = CSVUtils.ParseString(line, ref i);
        asteroid.SemiMajorAxis      = CSVUtils.ParseFloat(line, ref i);
        asteroid.Eccentricity       = CSVUtils.ParseFloat(line, ref i);
        asteroid.Inclination        = CSVUtils.ParseFloat(line, ref i);
        asteroid.AscNodeLongitude   = CSVUtils.ParseFloat(line, ref i);
        asteroid.ArgOfPerihelion    = CSVUtils.ParseFloat(line, ref i);
        asteroid.PerihelionDistance = CSVUtils.ParseFloat(line, ref i);
        asteroid.AphelionDistance   = CSVUtils.ParseFloat(line, ref i);
        asteroid.PeriodYears        = CSVUtils.ParseFloat(line, ref i);
        asteroid.Magnitude          = CSVUtils.ParseFloat(line, ref i);
        asteroid.RotationalPeriod   = CSVUtils.ParseFloat(line, ref i);
        asteroid.SpecTypeSMASSII    = CSVUtils.ParseString(line, ref i);
        asteroid.SpecTypeTholen     = CSVUtils.ParseString(line, ref i);
        asteroid.MeanMotion         = CSVUtils.ParseFloat(line, ref i);
        asteroid.PeriodDays         = CSVUtils.ParseFloat(line, ref i);
        asteroid.OrbitClass         = CSVUtils.ParseString(line, ref i);
        asteroid.Producer           = CSVUtils.ParseString(line, ref i);
        asteroid.DateOfFirstObs     = CSVUtils.ParseString(line, ref i);
        asteroid.Diameter           = CSVUtils.ParseFloat(line, ref i);
        return(asteroid);
    }
Exemple #3
0
    private static Star ParseStar(string data)
    {
        int  i    = 0;
        Star star = new Star();

        star.StarID         = CSVUtils.ParseInt(data, ref i);
        star.HIP            = CSVUtils.ParseInt(data, ref i);
        star.HD             = CSVUtils.ParseInt(data, ref i);
        star.HR             = CSVUtils.ParseInt(data, ref i);
        star.Gliese         = CSVUtils.ParseString(data, ref i);
        star.BayerFlamsteed = CSVUtils.ParseString(data, ref i);
        star.ProperName     = CSVUtils.ParseString(data, ref i);
        star.RA             = CSVUtils.ParseFloat(data, ref i);
        star.Dec            = CSVUtils.ParseFloat(data, ref i);
        star.Distance       = CSVUtils.ParseFloat(data, ref i);
        star.PMRA           = CSVUtils.ParseFloat(data, ref i);
        star.PMDec          = CSVUtils.ParseFloat(data, ref i);
        star.RV             = CSVUtils.ParseFloat(data, ref i);
        star.Mag            = CSVUtils.ParseFloat(data, ref i);
        star.AbsMag         = CSVUtils.ParseFloat(data, ref i);
        star.Spectrum       = CSVUtils.ParseString(data, ref i);
        star.ColorIndex     = CSVUtils.ParseFloat(data, ref i);
        star.X  = CSVUtils.ParseFloat(data, ref i);
        star.Y  = CSVUtils.ParseFloat(data, ref i);
        star.Z  = CSVUtils.ParseFloat(data, ref i);
        star.VX = CSVUtils.ParseFloat(data, ref i);
        star.VY = CSVUtils.ParseFloat(data, ref i);
        star.VZ = CSVUtils.ParseFloat(data, ref i);

        return(star);
    }
Exemple #4
0
        private async void B_Customers_Click(object sender, RoutedEventArgs e)
        {
            // Getting CrudAPI
            var crudAPI = UnicontaAPIManager.GetCrudAPI();

            crudAPI.RunInTransaction = false;

            // Parsing CSV
            var customers = CSVUtils.ParseCustomers(@"C:\src\Uniconta\Technical-Training-Cases-master\TrainingData\CompanyData\Finace-Customers.csv");

            // Creating Insert List
            var newDebtorClients = new List <DebtorClient>();

            foreach (var customer in customers)
            {
                // Parsing Account Number
                var accountNumber = (int.Parse(customer.AccountNumber) + 20000).ToString();

                // TODO: Add the customer to the newDebtorClients List
            }
            ;

            // Calling insert API
            // TODO: Call the insert API to insert newDebtorClients
        }
Exemple #5
0
        private static void TestCsvParsing()
        {
            string path = @"D:\Downloads\1253a5fc75280025995fa7f3cb61000e-6b4989b6cf20ddc619c28a2e51eb9e27eb185709\fuel.csv";

            //string path = @"D:\Downloads\582e9c044eee5882d54a6e5997c0be52-1c6cd2fe0bda9c63178fda1f313370479ff0bc8a\manufacturers.csv";

            ConsoleUtils.WriteTableFromCSV(path);


            var dt = CSVUtils.ParseCSVToDataTable(path);

            ConsoleUtils.WriteDataTable(dt);

            if (!path.EndsWith("fuel.csv"))
            {
                return;
            }

            var customers = CSVUtils.ParseCSV <Customer, CustomerMap>(path);

            ConsoleUtils.WriteLine(customers.Last().Name);


            var customers2 = CSVUtils.ParseCSV <Customer>(path);

            ConsoleUtils.WriteLine(customers2.First().Name);
        }
Exemple #6
0
        private static void TestStopWatchTime()
        {
            string filePath = @"D:\Users\User\OneDrive\Magisterka\Semestr 1\Python\Notebooki\Dane\orders\orders.csv";

            Stopwatch stopwatch = new Stopwatch();

            long time = stopwatch.TimeMillis(() =>
            {
                CSVUtils.ParseCSVLines(filePath, delimiter: "\t").ToList();
                CSVUtils.ParseCSVLines(filePath, delimiter: "\t").ToList();
                CSVUtils.ParseCSVLines(filePath, delimiter: "\t").ToList();
            });

            Console.WriteLine(time);


            time = ObjectUtils.Time(() => CSVUtils.ParseCSVLines(filePath, delimiter: "\t").ToList());

            Console.WriteLine(time);


            time = ObjectUtils.Time(() => CSVUtils.ParseCSVLines2(filePath, delimiter: "\t").ToList());

            Console.WriteLine(time);
        }
Exemple #7
0
 public void ProceedData()
 {
     if (!string.IsNullOrWhiteSpace(this.FilePath))
     {
         var data = CSVUtils.ReadCSVFile(this.FilePath);
         DataColumns = data[0];
         DataRows    = data.GetRange(1, data.Count - 2);
     }
 }
Exemple #8
0
        public void ExportLotteryCSV(string filePath, List <LotteryWinnerInfo> winnerInfoList)
        {
            var head = new List <string>();

            head.Add("序号");
            head.Add("奖项");
            head.Add("姓名");
            head.Add("手机");
            head.Add("邮箱");
            head.Add("地址");
            head.Add("状态");
            head.Add("中奖时间");
            head.Add("兑奖码");
            head.Add("兑奖时间");

            var rows = new List <List <string> >();

            var index = 1;

            foreach (var winnerInfo in winnerInfoList)
            {
                LotteryAwardInfo awardInfo = null;
                if (awardInfoMap.ContainsKey(winnerInfo.AwardID))
                {
                    awardInfo = awardInfoMap[winnerInfo.AwardID];
                }
                else
                {
                    awardInfo = DataProviderWX.LotteryAwardDAO.GetAwardInfo(winnerInfo.AwardID);
                    awardInfoMap.Add(winnerInfo.AwardID, awardInfo);
                }

                var award = string.Empty;
                if (awardInfo != null)
                {
                    award = awardInfo.AwardName + ":" + awardInfo.Title;
                }

                var row = new List <string>();

                row.Add((index++).ToString());
                row.Add(award);
                row.Add(winnerInfo.RealName);
                row.Add(winnerInfo.Mobile);
                row.Add(winnerInfo.Email);
                row.Add(winnerInfo.Address);
                row.Add(EWinStatusUtils.GetText(EWinStatusUtils.GetEnumType(winnerInfo.Status)));
                row.Add(DateUtils.GetDateAndTimeString(winnerInfo.AddDate));
                row.Add(winnerInfo.CashSN);
                row.Add(DateUtils.GetDateAndTimeString(winnerInfo.CashDate));

                rows.Add(row);
            }

            CSVUtils.Export(filePath, head, rows);
        }
        /// <summary>
        /// Generates the dictionary of entities found.
        /// </summary>
        /// <param name="options">Options.</param>
        public override void Run()
        {
            if (options.Verbose)
            {
                Console.Error.WriteLine("Dictionary generation command");
            }

            string xml = NER.GenerateEntitiesToString(options.InputFile, options.Language);
            string csv = CSVUtils.RemoveDuplicates(CSVUtils.EntitiesToCsv(xml, options.Separator));

            WriteResult(csv);
        }
Exemple #10
0
        private static void TestDisposableStopwatch()
        {
            string filePath = @"D:\Users\User\OneDrive\Magisterka\Semestr 1\Python\Notebooki\Dane\orders\orders.csv";

            using (new DisposableStopwatch(t => Console.WriteLine("{0} elapsed", t)))
            {
                // do stuff that I want to measure
                CSVUtils.ParseCSVLines(filePath, delimiter: "\t").ToList();
            }

            using (new DisposableStopwatch())
            {
                CSVUtils.ParseCSVLines(filePath, delimiter: "\t").ToList();
            }
        }
Exemple #11
0
        /// <summary>
        /// Writes to the output stream a csv with the match results against the dictionary
        /// </summary>
        /// <param name="inputPath">Files path.</param>
        /// <param name="dicPath">Dictionary path.</param>
        /// <param name="output">Output stream.</param>
        public static void MatchEntitiesInFiles(string inputPath, string dicPath, TextWriter output, char sep, string language)
        {
            string[] files = FilesUtils.GetFiles(inputPath);
            foreach (string file in files)
            {
                string xml = NER.GenerateEntitiesToString(file, language);
                string csv = CSVUtils.RemoveDuplicates(CSVUtils.EntitiesToCsv(xml, sep));

                List <string[]> dicTable      = CSVUtils.TabulateCSV(new StreamReader(dicPath), sep);
                List <string[]> fileTable     = CSVUtils.TabulateCSV(new StringReader(csv), sep);
                List <string>   entitiesTable = GetEntitiesFromDic(dicTable);

                var matchs = MatchEntities(fileTable, entitiesTable);

                GenerateMatchedEntriesCSV(file, dicPath, matchs, output, sep);
            }
        }
Exemple #12
0
        private static void TestParseCSVToObjectAndDisplayObject()
        {
            const string filePathFormat = @"D:\Users\User\OneDrive\Magisterka\Semestr 2\Business Intelligence w przedsięborstwie\Laboratoria\Zadanie 3\Zadanie\Dane\{0}_DATA_TABLE.csv";

            string tableName = "klient";

            string filePath = string.Format(filePathFormat, tableName.ToUpper());


            var customers = CSVUtils.ParseCSV <Customer>(filePath);

            var customersFromMap = CSVUtils.ParseCSV <Customer, CustomerMap>(filePath, false);


            ConsoleUtils.WriteTableFromObjects(customers, false);

            ConsoleUtils.WriteTableFromObjects(customersFromMap, false);
        }
Exemple #13
0
        public void Test_CSV_ReadFile()
        {
            var csvFilePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\Wave000.csv");

            var result = CSVUtils.ReadCSVFile <CSVWaveRecord>(csvFilePath);

            Assert.AreEqual(5747, result.Count());

            var first = result.First();

            Assert.AreEqual(0m, first.Seconds);
            Assert.AreEqual(0m, first.Volts);

            var second = result.Skip(1).First();

            Assert.AreEqual(6.009475E-08m, second.Seconds);
            Assert.AreEqual(0.01737575m, second.Volts);
        }
        /// <summary>
        /// 取得单表数据(压缩)
        /// </summary>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public byte[] GetDataByCsvStream(string tableName, LogedInUser CurrentUser)
        {
            //DateTime dt = DateTime.Now;

            IDataReader   dataReader;
            StringBuilder csvStr = new StringBuilder();

            byte[] data;
            try
            {
                dataReader = GetSyncTableReader(tableName, CurrentUser);
                data       = (byte[])CompressUtil.CompressData(CSVUtils.ToCSV(dataReader, true));
            }
            catch (Exception e)
            {
                throw e;
            }
            return(data);
        }
Exemple #15
0
        public MainWindow()
        {
            InitializeComponent();



            AppDomain currentDomain = default(AppDomain);

            currentDomain = AppDomain.CurrentDomain;
            // Handler for unhandled exceptions.
            currentDomain.UnhandledException += GlobalUnhandledExceptionHandler;
            // Handler for exceptions in threads behind forms.
            System.Windows.Forms.Application.ThreadException += GlobalThreadExceptionHandler;



            CsvUtils = new CSVUtils(this);



            //ConsoleManager initialize
            ConsoleManager.Toggle();
            Console.WriteLine("\"(HTTP)指令\"和\"永恒之蓝\"需关闭其他指令窗口(如CMD,VNC..).");



            TB_IP_FILE.Text = fileutils.path + @"\IP.csv";
            if (File.Exists(TB_IP_FILE.Text))
            {
                CSV = CsvUtils.Read(TB_IP_FILE.Text);
                LV_IP.ItemsSource = CSV;
                CsvUtils.Refresh(CSV);
            }



            Style itemContainerStyle = new Style(typeof(System.Windows.Controls.ListViewItem));

            itemContainerStyle.Setters.Add(new Setter(System.Windows.Controls.ListViewItem.AllowDropProperty, true));
            itemContainerStyle.Setters.Add(new EventSetter(System.Windows.Controls.ListViewItem.DropEvent, new System.Windows.DragEventHandler(Window_DragDrop)));
            LV_ZkplayPlayList.ItemContainerStyle = itemContainerStyle;
        }
Exemple #16
0
        private async void B_Customers_Click(object sender, RoutedEventArgs e)
        {
            // Getting CrudAPI
            var crudAPI = UnicontaAPIManager.GetCrudAPI();

            crudAPI.RunInTransaction = false;

            // Parsing CSV
            var customers = CSVUtils.ParseCustomers(@"C:\src\Uniconta\Technical-Training-Cases-master\TrainingData\CompanyData\Finace-Customers.csv");

            // Creating Insert List
            var newDebtorClients = new List <DebtorClient>();

            foreach (var customer in customers)
            {
                // Parsing Account Number
                var accountNumber = (int.Parse(customer.AccountNumber) + 20000).ToString();

                newDebtorClients.Add(new DebtorClient
                {
                    _Account  = accountNumber.ToString(),
                    _Name     = customer.AccountName,
                    _Address1 = customer.Address1,
                    _Address2 = customer.Address2,
                    _ZipCode  = customer.ZIP,
                    _Phone    = customer.Telephone
                });
            }
            ;

            // Calling insert API
            var errorCode = await crudAPI.Insert(newDebtorClients);

            if (errorCode != ErrorCodes.Succes)
            {
                MessageBox.Show($"ERROR: Failed to import customers {errorCode.ToString()}");
            }
            else
            {
                MessageBox.Show("Import Completed");
            }
        }
        /// <summary>
        /// 取得单表数据,生产csv文件
        /// </summary>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public byte[] DataToFile(string tableName, LogedInUser CurrentUser)
        {
            //DateTime dt = DateTime.Now;

            IDataReader   dataReader;
            StringBuilder csvStr = new StringBuilder();

            byte[] data;
            try
            {
                dataReader = GetSyncTableReader(tableName, CurrentUser);
                string file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, tableName + CurrentUser.UserOrg.Reg_org_id + ".csv");

                ////写表头
                //File.WriteAllText(file, CSVUtils.CreateCSVHeader(dataReader, csvStr), Encoding.GetEncoding(936));
                ////写数据
                //while (dataReader.Read())
                //{
                //    //using (StreamWriter sw = File.AppendText(file))
                //    //{
                //    //    sw.Write(CSVUtils.CreateCSVContextLine(dataReader, csvStr));
                //    //}
                //    File.AppendAllText(file, CSVUtils.CreateCSVContextLine(dataReader, csvStr), Encoding.GetEncoding(936));
                //}

                File.WriteAllText(file, CSVUtils.ToCSV(dataReader, true), Encoding.GetEncoding(936));

                //TimeSpan t = DateTime.Now.Subtract(dt);
                //MessageBox.Show(t.TotalSeconds.ToString(), "", MessageBoxButtons.OK, MessageBoxIcon.Information);

                CompressUtil.CompressFile(file);
                data = File.ReadAllBytes(file + ".cps");
                File.Delete(file);
                File.Delete(file + ".cps");
            }
            catch (Exception e)
            {
                throw e;
            }
            return(data);
        }
Exemple #18
0
        public ArrayList GetCardEntitySNInfoArrayList(string filePath)
        {
            var index = 0;
            var cardEntitySNInfoArrayList = new ArrayList();

            var cardEntitySNInfoList = CSVUtils.Import(filePath);

            if (cardEntitySNInfoList.Count > 0)
            {
                foreach (var info in cardEntitySNInfoList)
                {
                    index++;
                    if (index == 1)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(info))
                    {
                        continue;
                    }
                    var value = info.Split(',');

                    var cardEntitySNInfo = new CardEntitySNInfo();

                    cardEntitySNInfo.PublishmentSystemID = PublishmentSystemID;
                    cardEntitySNInfo.CardID    = cardID;
                    cardEntitySNInfo.SN        = value[0];
                    cardEntitySNInfo.UserName  = value[1];
                    cardEntitySNInfo.Mobile    = value[2];
                    cardEntitySNInfo.Email     = value[3];
                    cardEntitySNInfo.Address   = value[4];
                    cardEntitySNInfo.Amount    = TranslateUtils.ToDecimal(value[5]);
                    cardEntitySNInfo.Credits   = TranslateUtils.ToInt(value[6]);
                    cardEntitySNInfo.IsBinding = false;
                    cardEntitySNInfo.AddDate   = DateTime.Now;
                    cardEntitySNInfoArrayList.Add(cardEntitySNInfo);
                }
            }
            return(cardEntitySNInfoArrayList);
        }
Exemple #19
0
        /// <summary>
        /// Run the specified options.
        /// Run all the logic of the command.
        /// </summary>
        /// <param name="options">Options.</param>
        public override void Run()
        {
            if (options.Verbose)
            {
                Console.Error.WriteLine("Parse text command");
            }

            if (options.InputFile == null)
            {
                Console.Error.WriteLine("Input file/directory required. Exiting...");
                return;
            }

            List <string[]> matchs = Parser.GetMatching(options.InputFile, options.Separator);

            IMatchIterator iter = new MatchIterator(matchs);

            var csvEntries = new List <string[]>();

            while (iter.HasNext())
            {
                Match match = iter.GetNext();
                foreach (string[] item in match.Items)
                {
                    csvEntries.AddRange(Parser.Parse(match.Text, item[1], match.FilePath, options.Language));
                }
            }

            var CSV_FMT = "{0}{4}{1}{4}{2}{4}{3}";

            WriteResult(CSVUtils.RemoveDuplicates(CSVUtils.BuildCSV(csvEntries,
                                                                    (builder, e) => builder.AppendFormat(
                                                                        CSV_FMT,
                                                                        e[0],
                                                                        e[1],
                                                                        e[2],
                                                                        e[3],
                                                                        options.Separator))));
        }
Exemple #20
0
        private async void B_Items_Click(object sender, RoutedEventArgs e)
        {
            // Getting CrudAPI
            var crudAPI = UnicontaAPIManager.GetCrudAPI();

            crudAPI.RunInTransaction = false;

            // Parsing CSV
            var items = CSVUtils.ParseItems(@"C:\src\Uniconta\Technical-Training-Cases-master\TrainingData\CompanyData\Finace-Items.csv");

            // Creating Insert List
            var newInvItemClients = new List <InvItemClient>();

            foreach (var item in items)
            {
                // TODO: Add the item to the newInvItemClients List
            }
            ;

            // Calling insert API
            // TODO: Call the insert API to insert newInvItemClients
        }
Exemple #21
0
        public void ExportCardSNCSV(string filePath, List <CardSNInfo> cardSNInfoList)
        {
            var head = new List <string>();

            head.Add("序号");
            head.Add("卡号");
            head.Add("姓名");
            head.Add("手机");
            head.Add("邮箱");
            head.Add("地址");
            head.Add("金额");
            head.Add("积分");
            head.Add("领卡时间");

            var rows = new List <List <string> >();

            var index = 1;

            foreach (var cardSNInfo in cardSNInfoList)
            {
                var userInfo        = BaiRongDataProvider.UserDao.GetUserInfoByUserName(cardSNInfo.UserName);
                var userContactInfo = BaiRongDataProvider.UserContactDao.GetContactInfo(cardSNInfo.UserName);

                var row = new List <string>();

                row.Add((index++).ToString());
                row.Add(cardSNInfo.SN);
                row.Add(userInfo != null ? userInfo.DisplayName : string.Empty);
                row.Add(userInfo != null ? userInfo.Mobile : string.Empty);
                row.Add(userInfo != null ? userInfo.Email : string.Empty);
                row.Add(userContactInfo != null ? userContactInfo.Address : string.Empty);
                row.Add(cardSNInfo.Amount.ToString());
                row.Add(userInfo != null ? userInfo.Credits.ToString() : "0");
                row.Add(DateUtils.GetDateAndTimeString(cardSNInfo.AddDate));
                rows.Add(row);
            }

            CSVUtils.Export(filePath, head, rows);
        }
Exemple #22
0
        private static void TestConvertCSVToDataTableAndWriteDataTable()
        {
            string filePath = @"D:\Users\User\OneDrive\Magisterka\Semestr 2\Big Data\Laboratoria\Koronawirus - Zadanie\CSVs\Podzielone pliki\20.csv";

            string filePath2 = @"D:\Users\User\OneDrive\Magisterka\Semestr 1\Python\Notebooki\Dane\orders\orders.csv";

            string filePath3 = @"D:\Users\User\OneDrive\Magisterka\Semestr 2\Data Mining\Ćwiczenia\Dane\datasets_12603_17232_Life Expectancy Data.csv";


            DataTable dataTable = CSVUtils.ParseCSVToDataTable(filePath);

            ConsoleUtils.WriteDataTable(dataTable);


            dataTable = CSVUtils.ParseCSVToDataTable(filePath2, delimiter: "\t");

            ConsoleUtils.WriteDataTable(dataTable);


            dataTable = CSVUtils.ParseCSVToDataTable(filePath3);

            ConsoleUtils.WriteDataTable(dataTable);
        }
Exemple #23
0
        private async void B_Items_Click(object sender, RoutedEventArgs e)
        {
            // Getting CrudAPI
            var crudAPI = UnicontaAPIManager.GetCrudAPI();

            crudAPI.RunInTransaction = false;

            // Parsing CSV
            var items = CSVUtils.ParseItems(@"C:\src\Uniconta\Technical-Training-Cases-master\TrainingData\CompanyData\Finace-Items.csv");

            // Creating Insert List
            var newInvItemClients = new List <InvItemClient>();

            foreach (var item in items)
            {
                newInvItemClients.Add(new InvItemClient
                {
                    _Item        = item.Item,
                    _Name        = item.ItemName,
                    _SalesPrice1 = item.SalesPrice,
                    _Group       = "Grp1"
                });
            }
            ;

            // Calling insert API
            var errorCode = await crudAPI.Insert(newInvItemClients);

            if (errorCode != ErrorCodes.Succes)
            {
                MessageBox.Show($"ERROR: Failed to import items {errorCode.ToString()}");
            }
            else
            {
                MessageBox.Show("Import Completed");
            }
        }
Exemple #24
0
 /// <summary>
 /// Gets the matchs of the matchingFile.
 /// </summary>
 /// <returns>The matching.</returns>
 /// <param name="matchingFilePath">Matching file path.</param>
 public static List <String[]> GetMatching(string matchingFilePath, char sep)
 {
     return(CSVUtils.TabulateCSV(new StreamReader(matchingFilePath), sep));
 }
        public void ExportAppointmentContentCSV(string filePath, List <AppointmentContentInfo> appointmentContentInfolList, string appointmentTitle, int appointmentID)
        {
            var appointmentInfo = DataProviderWX.AppointmentDAO.GetAppointmentInfo(appointmentID);

            var head = new List <string>();

            head.Add("序号");
            head.Add("预约名称");
            if (appointmentInfo.IsFormRealName == "True")
            {
                head.Add(appointmentInfo.FormRealNameTitle);
            }
            if (appointmentInfo.IsFormMobile == "True")
            {
                head.Add(appointmentInfo.FormMobileTitle);
            }
            if (appointmentInfo.IsFormEmail == "True")
            {
                head.Add(appointmentInfo.FormEmailTitle);
            }
            head.Add("预约时间");
            head.Add("预约状态");
            head.Add("留言");
            var configExtendInfoList = DataProviderWX.ConfigExtendDAO.GetConfigExtendInfoList(PublishmentSystemId, appointmentID, EKeywordTypeUtils.GetValue(EKeywordType.Appointment));

            foreach (var cList in configExtendInfoList)
            {
                head.Add(cList.AttributeName);
            }

            var rows = new List <List <string> >();

            var index = 1;

            foreach (var applist in appointmentContentInfolList)
            {
                var row = new List <string>();

                row.Add((index++).ToString());
                row.Add(appointmentTitle);
                if (appointmentInfo.IsFormRealName == "True")
                {
                    row.Add(applist.RealName);
                }
                if (appointmentInfo.IsFormMobile == "True")
                {
                    row.Add(applist.Mobile);
                }
                if (appointmentInfo.IsFormEmail == "True")
                {
                    row.Add(applist.Email);
                }
                row.Add(DateUtils.GetDateAndTimeString(applist.AddDate));
                row.Add(EAppointmentStatusUtils.GetText(EAppointmentStatusUtils.GetEnumType(applist.Status)));
                row.Add(applist.Message);

                var SettingsXML = applist.SettingsXML.Replace("{", "").Replace("}", "");
                var arr         = SettingsXML.Split(',');
                if (arr[0] != "")
                {
                    for (var i = 0; i < arr.Length; i++)
                    {
                        var arr1 = arr[i].Replace("\"", "").Split(':');
                        row.Add(arr1[1]);
                    }
                }
                rows.Add(row);
            }

            CSVUtils.Export(filePath, head, rows);
        }
Exemple #26
0
    public static List <List <string> > SplitCellsAndLines(string source, string newLineSequence, char deliminator, char encapsulate, char escape)
    {
        bool flag  = false;
        bool flag2 = false;
        List <List <string> > result        = new List <List <string> >();
        List <string>         list          = new List <string>();
        StringBuilder         stringBuilder = new StringBuilder();

        if (source.Length > 0)
        {
            list = new List <string>();
        }
        int num = 0;

        foreach (char c in source)
        {
            bool flag3 = c == encapsulate;
            if (flag && escape == encapsulate && !flag3)
            {
                flag  = false;
                flag2 = false;
            }
            if (c == newLineSequence[num] && !flag2)
            {
                if (num++ >= newLineSequence.Length - 1)
                {
                    num = 0;
                    CSVUtils.FinalizeCurrentCell(ref list, ref stringBuilder);
                    CSVUtils.FinalizeCurrentLine(ref result, ref list);
                }
            }
            else
            {
                if (num > 0)
                {
                    stringBuilder.Append(newLineSequence.Substring(0, num));
                    num = 0;
                }
                bool flag4 = c == escape;
                if (flag2 && flag4 && !flag)
                {
                    flag = true;
                }
                else if (flag3 && !flag)
                {
                    flag2 = !flag2;
                }
                else
                {
                    bool flag5 = c == deliminator;
                    if (flag5 && !flag2)
                    {
                        CSVUtils.FinalizeCurrentCell(ref list, ref stringBuilder);
                    }
                    else
                    {
                        flag = false;
                        stringBuilder.Append(c);
                    }
                }
            }
        }
        CSVUtils.FinalizeCurrentCell(ref list, ref stringBuilder);
        CSVUtils.FinalizeCurrentLine(ref result, ref list);
        return(result);
    }
Exemple #27
0
        private async void B_Orders_Click(object sender, RoutedEventArgs e)
        {
            // Getting CrudAPI
            var crudAPI = UnicontaAPIManager.GetCrudAPI();

            crudAPI.RunInTransaction = false;

            // Parsing CSV
            var orders = CSVUtils.ParseOrders(@"C:\src\Uniconta\Technical-Training-Cases-master\TrainingData\CompanyData\Finace-Orders.csv");

            // Creating SQLCache's
            // TODO: Create a customer (DebtorClient) SQLCache

            // TODO: Create a inventory (InvItemClient) SQLCache

            // Creating Insert List
            var newDebtorOrderClients = new List <DebtorOrderClient>();

            foreach (var order in orders)
            {
                // Parsing Account Number
                var accountNumber = (int.Parse(order.AccountNumber) + 20000).ToString();

                // Finding customer in cache
                // TODO: Use the customerCache to get the customer by accountNumber

                // TODO: Add the order to the newDebtorOrderClients List + SetMaster
            }
            ;

            // Calling insert API
            var errorCode = await crudAPI.Insert(newDebtorOrderClients);

            if (errorCode != ErrorCodes.Succes)
            {
                MessageBox.Show($"ERROR: Failed to import orders {errorCode.ToString()}");
            }

            // Creating order lines
            var newDebtorOrderLineClients = new List <DebtorOrderLineClient>();
            var inventoryList             = inventoryCache.GetRecords as InvItemClient[];

            var index = 0;

            foreach (var debtorOrder in newDebtorOrderClients)
            {
                var orderItems = orders[index].Items;
                foreach (var item in orderItems)
                {
                    var inventoryItem = inventoryList.FirstOrDefault(i => i.Name == item.ItemName);

                    // TODO: Add the item to the newDebtorOrderLineClients List + SetMaster
                }
                ;

                index++;
            }
            ;

            // Calling insert API
            // TODO: Call the insert API to insert newDebtorOrderLineClients
        }
Exemple #28
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            try
            {
                if (flg == 0)
                {
                    var totalNum = TranslateUtils.ToInt(tbTotalNum.Text);
                    if (totalNum > 1000)
                    {
                        FailMessage("新增失败,一次最多只能新增1000张优惠劵");
                    }
                    else
                    {
                        DataProviderWX.CouponSNDAO.Insert(PublishmentSystemID, couponID, totalNum);

                        StringUtility.AddLog(PublishmentSystemID, "新增优惠劵数量", $"数量:{totalNum}");
                        isChanged = true;
                    }
                }
                if (flg == 1)
                {
                    //string filehou = this.hifUpload.PostedFile.FileName.Split('.')[1].ToString();

                    //if (filehou != "xls" || filehou != "xlsx")
                    //{
                    //    base.FailMessage("请检查上传文件的类型.必须为EXCEL文件.");
                    //}

                    var filePath = PathUtils.GetTemporaryFilesPath("coupon_sn_upload.csv");
                    FileUtils.DeleteFileIfExists(filePath);

                    hifUpload.PostedFile.SaveAs(filePath);

                    try
                    {
                        var snList = CSVUtils.Import(filePath);

                        if (snList.Count > 0)
                        {
                            DataProviderWX.CouponSNDAO.Insert(PublishmentSystemID, couponID, snList);
                            StringUtility.AddLog(PublishmentSystemID, "新增优惠劵数量", $"数量:{snList.Count}");
                            isChanged = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "失败:" + ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                FailMessage(ex, "失败:" + ex.Message);
            }

            if (isChanged)
            {
                JsUtils.OpenWindow.CloseModalPage(Page);
            }
        }
Exemple #29
0
        private async void B_Orders_Click(object sender, RoutedEventArgs e)
        {
            // Getting CrudAPI
            var crudAPI = UnicontaAPIManager.GetCrudAPI();

            crudAPI.RunInTransaction = false;

            // Parsing CSV
            var orders = CSVUtils.ParseOrders(@"C:\src\Uniconta\Technical-Training-Cases-master\TrainingData\CompanyData\Finace-Orders.csv");

            // Creating SQLCache's
            SQLCache customerCache = crudAPI.CompanyEntity.GetCache(typeof(DebtorClient));

            if (customerCache == null)
            {
                customerCache = await crudAPI.CompanyEntity.LoadCache(typeof(DebtorClient), crudAPI);
            }

            SQLCache inventoryCache = crudAPI.CompanyEntity.GetCache(typeof(InvItemClient));

            if (inventoryCache == null)
            {
                inventoryCache = await crudAPI.CompanyEntity.LoadCache(typeof(InvItemClient), crudAPI);
            }

            // Creating Insert List
            var newDebtorOrderClients = new List <DebtorOrderClient>();

            foreach (var order in orders)
            {
                // Parsing Account Number
                var accountNumber = (int.Parse(order.AccountNumber) + 20000).ToString();

                // Finding customer in cache
                var customer = customerCache.Get(accountNumber) as DebtorClient;

                var newDebtorOrderClient = new DebtorOrderClient
                {
                    _Created = order.CreatedDate
                };
                newDebtorOrderClient.SetMaster(customer);
                newDebtorOrderClients.Add(newDebtorOrderClient);
            }
            ;

            // Calling insert API
            var errorCode = await crudAPI.Insert(newDebtorOrderClients);

            if (errorCode != ErrorCodes.Succes)
            {
                MessageBox.Show($"ERROR: Failed to import orders {errorCode.ToString()}");
            }

            // Creating order lines
            var newDebtorOrderLineClients = new List <DebtorOrderLineClient>();
            var inventoryList             = inventoryCache.GetRecords as InvItemClient[];

            var index = 0;

            foreach (var debtorOrder in newDebtorOrderClients)
            {
                var orderItems = orders[index].Items;
                foreach (var item in orderItems)
                {
                    var inventoryItem = inventoryList.FirstOrDefault(i => i.Name == item.ItemName);

                    var orderLine = new DebtorOrderLineClient
                    {
                        _Item  = inventoryItem.Item,
                        _Qty   = 1,
                        _Price = inventoryItem.SalesPrice1
                    };
                    orderLine.SetMaster(debtorOrder);
                    newDebtorOrderLineClients.Add(orderLine);
                }
                ;

                index++;
            }
            ;

            // Calling insert API
            var errorCode2 = await crudAPI.Insert(newDebtorOrderLineClients);

            if (errorCode2 != ErrorCodes.Succes)
            {
                MessageBox.Show($"ERROR: Failed to import order lines {errorCode2.ToString()}");
            }
            else
            {
                MessageBox.Show("Import Completed");
            }
        }