Exemple #1
0
        /// <summary>
        /// プロジェクトのJsonStringを取得する
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string GetProjectJsonString(string projectId, ExecDataType type)
        {
            try
            {
                string name = "";
                switch (type)
                {
                case ExecDataType.PROJECT:
                    name = "PROJECT";
                    break;

                case ExecDataType.MACRO:
                    name = "MACRO";
                    break;
                }
                string result = "";
                result = DbUtil.GetInstance().Get_Project_Macro_Value(name, projectId);

                return(result);
            }
            catch (Exception ex)
            {
                throw Program.ThrowException(ex);
            }
        }
Exemple #2
0
 /// <summary>
 /// プロジェクトを削除する
 /// </summary>
 /// <param name="projectId"></param>
 /// <param name="type"></param>
 private void DeleteProject(string projectId, ExecDataType type)
 {
     try
     {
         DbUtil.GetInstance().Delete_Project_Macro_Info(type, projectId);
     }
     catch (Exception ex)
     {
         throw Program.ThrowException(ex);
     }
 }
Exemple #3
0
 /// <summary>
 /// プロジェクトを取得する
 /// </summary>
 /// <param name="projectId"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static ProjectModel GetProject(string projectId, ExecDataType type)
 {
     try
     {
         return(GetProjectFromJsonString(GetProjectJsonString(projectId, type)));
     }
     catch (Exception ex)
     {
         throw Program.ThrowException(ex);
     }
 }
Exemple #4
0
 /// <summary>
 /// プロジェクトを実行する
 /// </summary>
 /// <param name="projId"></param>
 internal void StartProject(string projId, ExecDataType type, MacroStartType startType)
 {
     try
     {
         _autoMode = true;
         ProjectModel model = LoadProjectForm.GetProject(projId, type);
         StartProject(model, startType);
     }
     catch (Exception ex)
     {
         throw Program.ThrowException(ex);
     }
 }
Exemple #5
0
        internal List <string[]> Get_Project_Macro_InfoAll(ExecDataType execDataType)
        {
            try
            {
                List <string[]> resultList = new List <string[]>();
                OnExecute = (SQLiteConnection con, SQLiteTransaction tran) => {
                    StringBuilder sql  = new StringBuilder();
                    string        name = "";
                    switch (execDataType)
                    {
                    case ExecDataType.PROJECT:
                        name = "PROJECT";
                        break;

                    case ExecDataType.MACRO:
                        name = "MACRO";
                        break;
                    }
                    sql.Append("SELECT ID, " + name + "NAME, CDATE FROM " + name + "_INFO ORDER BY " + ((name != "PROJECT") ? name + "NAME" : "CDATE DESC"));
                    using (SQLiteCommand command = new SQLiteCommand(sql.ToString(), con))
                    {
                        using (SQLiteDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                string id    = "" + reader.GetValue(0);
                                string pName = "" + reader.GetValue(1);
                                string cdate = "" + reader.GetValue(2);
                                resultList.Add(new string[] { id, pName, cdate });
                            }
                        }
                    }
                };
                Execute(false);
                return(resultList);
            }
            catch (Exception ex)
            {
                throw Program.ThrowException(ex);
            }
        }
Exemple #6
0
        /// <summary>
        /// プロジェクト又はマクロを削除する
        /// </summary>
        /// <param name="type"></param>
        /// <param name="projectId"></param>
        internal void Delete_Project_Macro_Info(ExecDataType type, string projectId)
        {
            try
            {
                OnExecute = (SQLiteConnection con, SQLiteTransaction tran) => {
                    try
                    {
                        StringBuilder sql  = new StringBuilder();
                        string        name = "";
                        switch (type)
                        {
                        case ExecDataType.PROJECT:
                            name = "PROJECT";
                            break;

                        case ExecDataType.MACRO:
                            name = "MACRO";
                            break;
                        }
                        sql.Append("DELETE FROM " + name + "_INFO WHERE ID = @ID");
                        using (SQLiteCommand command = new SQLiteCommand(sql.ToString(), con))
                        {
                            command.Parameters.Add(new SQLiteParameter("@ID", projectId));
                            command.ExecuteNonQuery();
                            tran.Commit();
                        }
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        throw Program.ThrowException(ex);
                    }
                };
                Execute(true);
            }
            catch (Exception ex)
            {
                throw Program.ThrowException(ex);
            }
        }
Exemple #7
0
        /// <summary>
        /// プログラムを開始する
        /// </summary>
        private void Start(string[] args)
        {
            ClearTmpFolder();
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            string       projId = "";
            ExecDataType type   = ExecDataType.PROJECT;

            if (args != null)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    if (args[i].ToUpper() == "-P" || args[i].ToUpper() == "-M")
                    {
                        if (args[i].ToUpper() == "-P")
                        {
                            type = ExecDataType.PROJECT;
                        }
                        if (args[i].ToUpper() == "-M")
                        {
                            type = ExecDataType.MACRO;
                        }
                        projId = args[i + 1];
                        i++;
                    }
                }
            }
            if (string.IsNullOrEmpty(projId))
            {
                Application.Run(new MainMenu());
            }
            else
            {
                using (MainMenu form = new MainMenu())
                {
                    form.StartProject(projId, type, MacroStartType.SHORTCUTSTART);
                }
            }
        }
Exemple #8
0
 /// <summary>
 /// プロジェクトモードを設定する
 /// </summary>
 /// <param name="projModel"></param>
 internal void SetProjectMode(ProjectModel projModel, ExecDataType execMode)
 {
     try
     {
         CurrentProjectModel     = projModel;
         NodeType                = NodeType.Root;
         ProjTextBox.Text        = projModel.Name;
         ProjTextBox.Tag         = projModel.Name;
         DescriptionTextBox.Text = projModel.Description;
         //プロジェクトControlをセットする
         ProjectControl ctrl = new ProjectControl();
         ctrl.Init(CurrentProjectModel);
         ctrl.Anchor   = (((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
         ctrl.Width    = ContainerPanel.Width;
         ctrl.Height   = ContainerPanel.Height;
         ctrl.Location = new Point(0, 0);
         ContainerPanel.Controls.Add(ctrl);
     }
     catch (Exception ex)
     {
         throw Program.ThrowException(ex);
     }
 }
Exemple #9
0
        /// <summary>
        /// 初期化処理
        /// </summary>
        /// <param name="mode"></param>
        public void Init(LoadProjectMode mode)
        {
            try
            {
                LoadMode = mode;
                switch (LoadMode)
                {
                case LoadProjectMode.プロジェクト読込_削除:     //0
                    this.Text = "Macrobo - プロジェクト読込・削除";
                    ProjectGrid.Columns[COL_読込.Index].Visible    = true;
                    ProjectGrid.Columns[COL_削除.Index].Visible    = true;
                    ProjectGrid.Columns[COL_CDATE.Index].Visible = true;
                    break;

                case LoadProjectMode.プロジェクト実行:     //1
                    this.Text = "Macrobo - プロジェクト実行";
                    ProjectGrid.Columns[COL_実行.Index].Visible      = true;
                    ProjectGrid.Columns[COL_ショートカット.Index].Visible = true;
                    break;

                case LoadProjectMode.プロジェクトエクスポート:     //2
                    this.Text = "Macrobo - プロジェクトエクスポート";
                    ProjectGrid.Columns[COL_出力.Index].Visible = true;
                    break;

                case LoadProjectMode.モジュール読込_削除:     //3
                    this.Text = "Macrobo - モジュール読込・削除";
                    ProjectGrid.Columns[COL_読込.Index].Visible    = true;
                    ProjectGrid.Columns[COL_削除.Index].Visible    = true;
                    ProjectGrid.Columns[COL_CDATE.Index].Visible = true;
                    ExecDataType = ExecDataType.MACRO;
                    break;

                case LoadProjectMode.モジュール実行:      //4
                    this.Text = "Macrobo - モジュール実行";
                    ProjectGrid.Columns[COL_実行.Index].Visible      = true;
                    ProjectGrid.Columns[COL_ショートカット.Index].Visible = true;
                    ExecDataType = ExecDataType.MACRO;
                    break;

                case LoadProjectMode.モジュールエクスポート:      //5
                    this.Text = "Macrobo - モジュールエクスポート";
                    ProjectGrid.Columns[COL_出力.Index].Visible = true;
                    ExecDataType = ExecDataType.MACRO;
                    break;

                case LoadProjectMode.モジュール読込:      //6
                    this.Text = "Macrobo - モジュール読込";
                    ProjectGrid.Columns[COL_読込.Index].Visible = true;
                    ExecDataType = ExecDataType.MACRO;
                    break;
                }
                switch (ExecDataType)
                {
                case ExecDataType.MACRO:
                    ProjectGrid.Columns[COL_プロジェクト名.Index].HeaderText = "モジュール名";
                    break;
                }
                LoadProjects();
            }
            catch (Exception ex)
            {
                throw Program.ThrowException(ex);
            }
        }
Exemple #10
0
        /// <summary>
        /// ファイルからプロジェクト、又はモジュールをインポートします。
        /// </summary>
        /// <param name="type"></param>
        private void ImportFromFile(ExecDataType type)
        {
            try
            {
                string kana  = "プロジェクト";
                string file1 = "mcrp";
                string file2 = "MCRP";
                switch (type)
                {
                case ExecDataType.MACRO:
                    kana  = "モジュール";
                    file1 = "mcrm";
                    file2 = "MCRM";
                    break;
                }
                var dialog = new CommonOpenFileDialog(kana + "ファイルの選択");
                // ファイル選択モード
                dialog.IsFolderPicker = false;
                dialog.Multiselect    = false;
                dialog.Filters.Add(new CommonFileDialogFilter(file2 + "ファイル(*." + file1 + ")", "*." + file1));
                if (dialog.ShowDialog(this.Handle) == CommonFileDialogResult.Ok)
                {
                    ProjectModel model = null;

                    //平文フォーマット
                    using (StreamReader sr = new StreamReader(dialog.FileName, Encoding.Default))
                    {
                        try
                        {
                            string jsonString = sr.ReadToEnd();
                            model = JsonConvert.DeserializeObject <ProjectModel>(jsonString);
                            model = LoadProjectForm.RebuildProject(model);
                        }
                        catch (Exception) { }
                    }

                    //新フォーマット
                    if (model == null)
                    {
                        using (FileStream fs = new FileStream(dialog.FileName, FileMode.Open, FileAccess.Read))
                        {
                            try
                            {
                                BinaryFormatter f = new BinaryFormatter();
                                model = (ProjectModel)f.Deserialize(fs);
                                model = LoadProjectForm.RebuildProject(model);
                            }
                            catch (Exception) { }
                        }
                    }

                    //旧フォーマット
                    if (model == null)
                    {
                        using (FileStream fs = new FileStream(dialog.FileName, FileMode.Open, FileAccess.Read))
                        {
                            BinaryFormatter f          = new BinaryFormatter();
                            string          jsonString = (string)f.Deserialize(fs);
                            jsonString = CryptUtil.DecryptString(jsonString, StringValue.CRYPT_PASSWORD);
                            model      = LoadProjectForm.GetProjectFromJsonString(jsonString);
                        }
                    }

                    switch (type)
                    {
                    case ExecDataType.PROJECT:
                        if (model.ExecDataType != ExecDataType.PROJECT)
                        {
                            throw new Exception(kana + "ファイルではありません。");
                        }
                        break;

                    case ExecDataType.MACRO:
                        if (model.ExecDataType != ExecDataType.MACRO)
                        {
                            throw new Exception(kana + "ファイルではありません。");
                        }
                        break;
                    }
                    model.Name = DateTime.Now.ToString("yyyyMMddHHmmss_") + model.Name;
                    //IDを更新する
                    model.RenewId();

                    DialogResult result = this.ShowInfoDialog("保存確認", kana + "をインポートしますか?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);
                    if (result == DialogResult.No)
                    {
                        return;
                    }
                    ProcessEditForm.SaveProject(model);
                    this.ShowDialog("保存成功", kana + "を保存しました。");
                    switch (type)
                    {
                    case ExecDataType.PROJECT:
                        ShowEditProject(this, 0, MacroStartType.EDITORSTART);
                        break;

                    case ExecDataType.MACRO:
                        ShowEditProject(this, 1, MacroStartType.EDITORSTART);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                throw Program.ThrowException(ex);
            }
        }