Пример #1
0
        //timer eventhandler
        private void t_Tick(object sender, EventArgs e)
        {
            string log = "";
            int    jum = 0;

            //get current time
            int hh = DateTime.Now.Hour;
            int mm = DateTime.Now.Minute;
            int ss = DateTime.Now.Second;

            //time
            string time = jamText(hh.ToString() + ":" + mm.ToString() + ":" + ss.ToString());

            //update label
            txtJam.Text = time;

            if (next < DateTime.Now)
            {
                jum = fman.cekDir(inbox);
                log = "[" + DateTime.Now.ToString("HH:MM:ss") + "]  " + jum.ToString() + " files on Inbox";
                updateLog(log);

                if (jum > 0)
                {
                    //konversi
                    string[] files = fman.getFile(inbox);
                    if (files != null && files.Length > 0)
                    {
                        foreach (string i in files)
                        {
                            int conFile = fman.xlsToTxt(i, "xlsx");

                            if (conFile > 0)
                            {
                                fman.moveFile(i, error);
                                log = "[" + DateTime.Now.ToString("HH:MM:ss") + "]  " + conFile.ToString() + " new files Converted";
                                updateLog(log);
                            }
                            else
                            {
                                fman.moveFile(i, error);
                            }
                        }
                    }
                }

                int jumOut = fman.cekDir(outbox);
                log = "[" + DateTime.Now.ToString("HH:MM:ss") + "]  " + jumOut.ToString() + " files on Outbox";
                updateLog(log);

                if (jumOut > 0)
                {
                    string[] files = fman.getFile(outbox);
                    string   pes   = "";
                    string[] fName = null;
                    if (files != null && files.Length > 0)
                    {
                        foreach (string i in files)
                        {
                            pes = wsf.invokeProd("", "", i);
                            //pes = wsf.invokeProdUoi("", "", i);
                            string[] has = pes.Split('|');
                            fName = i.Split('\\');
                            string namaFile = fName[fName.Length - 1];
                            System.Console.WriteLine(namaFile + " " + pes);
                            log = "[" + DateTime.Now.ToString("HH:MM:ss") + "]  " + namaFile + " " + pes;
                            updateLog(log);

                            if (has[0] == "failed")
                            {
                                fman.moveFile(i, error);
                            }
                            else
                            {
                                fman.moveFile(i, succcess);
                            }
                            System.Threading.Thread.Sleep(1000);
                        }
                    }
                }

                next         = DateTime.Now.AddSeconds(schedInt);
                txtNext.Text = jamText(next.Hour.ToString() + ":" + next.Minute.ToString() + ":" + next.Second.ToString());
            }
        }
Пример #2
0
        private void button3_Click_1(object sender, EventArgs e)
        {
            var fm = new fileMan();

            fm.xlsToTxt("c:\\tes\\xls\\satu.xlsx", "xlsx");
        }