예제 #1
0
파일: Form1.cs 프로젝트: bryful/CGIDotNET
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int si = listBox1.SelectedIndex;

            if (si < 0)
            {
                return;
            }
            string c = tbCaption.Text.Trim();
            string s = tbSrc.Text.Trim();
            string d = tbDst.Text.Trim();
            string o = tbOpt.Text.Trim();

            if ((c == "") || (s == "") || (d == ""))
            {
                return;
            }

            FastCopyOpt fc = new FastCopyOpt();

            fc.caption = c;
            fc.src     = s;
            fc.dst     = d;
            fc.args    = o;

            m_FCOL.Items[si]   = fc;
            listBox1.Items[si] = fc.caption;
        }
예제 #2
0
파일: Form1.cs 프로젝트: bryful/CGIDotNET
        private FastCopyOpt ToOpt(string s)
        {
            FastCopyOpt fco = new FastCopyOpt();

            fco.FromJson(s);
            return(fco);
        }
예제 #3
0
파일: Form1.cs 프로젝트: bryful/CGIDotNET
        private void button6_Click(object sender, EventArgs e)
        {
            FastCopyOpt fc = new FastCopyOpt();

            fc.src     = tbSrc.Text;
            fc.dst     = tbDst.Text;
            fc.args    = tbOpt.Text;
            fc.caption = "001";

            tbArg.Text  = fc.ToJsonD();
            tbArgD.Text = FastCopyOpt.DDecode(tbArg.Text);
        }
예제 #4
0
파일: Form1.cs 프로젝트: bryful/CGIDotNET
        private void Form1_Load(object sender, EventArgs e)
        {
            string ExeName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "FastCopy.exe");

            string[] cmds = System.Environment.GetCommandLineArgs();
            //%1%Qsrc%Q%C%QE%C%Y%Ypool2%Y%Y%Q%K%Qdst%Q%C%Q%Y%Y%Y%Y192.168.10.88%Y%Ysv04%Y%Y%Q%K%Qargs%Q%C%Q%S%Y%Lcmd=sync%S%Y%Lforce_close%S%Y%Lno_confirm_del%S%Y%Lopen_window%Q%K%Qcaption%Q%C%Q001%Q%2
            FastCopyOpt fco = new FastCopyOpt();

            if (cmds.Length > 1)
            {
                fco.FromJsonD(cmds[1]);
            }
            else
            {
                string ds = "%1%Qsrc%Q%C%QE%C%Y%Ypool2%Y%Y%Q%K%Qdst%Q%C%Q%Y%Y%Y%Y192.168.10.88%Y%Ysv04%Y%Y%Q%K%Qargs%Q%C%Q%S%Y%Lcmd=sync%S%Y%Lforce_close%S%Y%Lno_confirm_del%S%Y%Lopen_window%Q%K%Qcaption%Q%C%Q001%Q%2";
                fco.FromJsonD(ds);
            }

            this.Text     = fco.ToJson();
            textBox1.Text = fco.ToJson();

            Process p = new Process();

            p.StartInfo.FileName  = ExeName;
            p.StartInfo.Arguments = fco.Options();
            p.SynchronizingObject = this;
            p.Exited += new EventHandler(p_Exited);
            p.EnableRaisingEvents = true;

            if (p.Start() == true)
            {
                textBox1.Text += "\r\n実行中\r\n";
            }
            else
            {
                textBox1.Text += "\r\n実行失敗\r\n" + ExeName;
#if DEBUG
#else
                Application.Exit();
#endif
            }
            //FastCopy.Exec
        }
예제 #5
0
파일: Form1.cs 프로젝트: bryful/CGIDotNET
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string c = tbCaption.Text.Trim();
            string s = tbSrc.Text.Trim();
            string d = tbDst.Text.Trim();
            string o = tbOpt.Text.Trim();

            if ((c == "") || (s == "") || (d == ""))
            {
                return;
            }

            FastCopyOpt fc = new FastCopyOpt();

            fc.caption = c;
            fc.src     = s;
            fc.dst     = d;
            fc.args    = o;

            m_FCOL.Items.Add(fc);
            listBox1.Items.Add(c);
        }
예제 #6
0
파일: Form1.cs 프로젝트: bryful/CGIDotNET
        private void button4_Click(object sender, EventArgs e)
        {
            FastCopyOptList fcl = new FastCopyOptList();

            FastCopyOpt fc = new FastCopyOpt();

            fc.src     = tbSrc.Text;
            fc.dst     = tbDst.Text;
            fc.args    = tbOpt.Text;
            fc.caption = "001";
            fcl.Items.Add(fc);
            FastCopyOpt fc2 = new FastCopyOpt();

            fc2.src     = tbSrc.Text;
            fc2.dst     = tbDst.Text;
            fc2.args    = tbOpt.Text;
            fc2.caption = "002";
            fcl.Items.Add(fc2);

            fcl.Save("Test.json");
            tbSrc.Text = "";
            tbDst.Text = "";
            tbOpt.Text = "";
        }
예제 #7
0
파일: Program.cs 프로젝트: bryful/CGIDotNET
        static void Main(string[] args)
        {
            // NFsCgiでpost/getの処理を行う
            NFsCgi cgi = new NFsCgi(args);

            /// lock処理
            if (cgi.CheckLockFile("fastcopy") == false)
            {
                cgi.WriteErr("<b>lock err<b>");
                return;
            }
            string pramD = LoadPref(".pref");

            if ((pramD == "") || (pramD == "dir exists"))
            {
                cgi.WriteErr("<b>pref err<b>");
                cgi.CloseLockFile();
                return;
            }



            // CGIパラメータを獲得
            // 動作モード find listup etc
            string Mode = "";

            cgi.Data.FindValueFromTag("Mode", out Mode);
            // 対象ディレクトリのインデックス文字列
            string TargetIndexStr = "";

            cgi.Data.FindValueFromTag("TargetIndex", out TargetIndexStr);
            // 対象ディレクトリのインデックス
            int TargetIndexValue = 0;

            if (int.TryParse(TargetIndexStr, out TargetIndexValue) == false)
            {
                TargetIndexValue = 0;
            }
            // FormのSelect 項目
            string SelectItemStr = "";

            // 対象ディレクトリの知ると
            string[] TargetDirs = new string[0];

            //prefファイルを読み込む
            //prefファイルにはターゲットリストがあるフォルダパスが入っている
            FastCopyOptList optlist = LoadFastCopy(Path.Combine(pramD, "fastcopy.json"));

            if (optlist.Items.Count <= 0)
            {
                cgi.WriteErr("<b>fastcopy.json err<b>");
                cgi.CloseLockFile();
                return;
            }
            else
            {
                // ターゲットリストからSelect項目のhtmlを作成。
                for (int i = 0; i < optlist.Items.Count; i++)
                {
                    string b  = "<option {0} value=\"{1}\">{2}</option>\r\n";
                    string ss = "";
                    if (TargetIndexValue == i)
                    {
                        ss = "selected";
                    }
                    SelectItemStr += String.Format(b, ss, i, optlist.Items[i].caption);
                }
            }
            if (TargetIndexValue < 0)
            {
                TargetIndexValue = 0;
            }
            else if (TargetIndexValue > optlist.Items.Count - 1)
            {
                TargetIndexValue = optlist.Items.Count - 1;
            }


            // htmlの処理
            string  htmlPath = Path.Combine(pramD, "base.html");
            NFsHtml html     = new NFsHtml(htmlPath);

            //基本htmlがなかったら作成
            if (html.Html == "")
            {
                html.Html = Properties.Resources.baseHtml;
                html.Save(htmlPath);
            }
            // htmlの形成
            html.ReplaceTag("$PATH_INFO", cgi.PATH_INFO);
            html.ReplaceTag("$QUERY_STRING", cgi.QUERY_STRING);
#if DEBUG
            html.ReplaceTag("$Data", cgi.Data.ToJson());
#endif
            html.ReplaceTag("$SelectItems", SelectItemStr);



            if (Mode == "exec")
            {
            }


            Process[] fxs         = FastCopy.ListupFastCopy();
            string    FastCopyNow = "";
            if (fxs.Length > 0)
            {
                for (int i = 0; i < fxs.Length; i++)
                {
                    string      t   = fxs[i].MainWindowTitle;
                    FastCopyOpt fco = new FastCopyOpt();
                    fco.FromJson(t);
                    string ss = "<li>FastCopy src:[{0}] dst:[{1}] start:{2}</li>\r\n";
                    FastCopyNow += String.Format(ss, fco.src, fco.dst, fxs[i].StartTime.ToString());
                }
                FastCopyNow = "<ul>\r\n" + FastCopyNow + "</ul>\r\n";
            }
            else
            {
                FastCopyNow = "起動なし";
            }
            html.ReplaceTag("$FastCopyNow", FastCopyNow);
            //出力
            html.output();

            // lock解除
            cgi.CloseLockFile();
        }