예제 #1
0
        private void OpenCreateForm(object sender, RibbonControlEventArgs e)
        {
            if (!ExeCheck())
            {
                return;
            }

            try
            {
                if (menuForm == null || menuForm.IsDisposed)
                {
                    Cursor preCursor = Cursor.Current;
                    Cursor.Current = Cursors.WaitCursor;
                    Reload();

                    Dictionary <object, object> titleDict = null;
                    if (selectedRange.ListObject == null)
                    {
                        titleDict = XlsOperation.GetTitleDict(activeSh);
                    }

                    UploadRequestParam paras = new UploadRequestParam
                    {
                        FileFullName = XlsOperation.MakeSelectedRangeTempFile(activePath, selectedRange, titleDict, activeSh),
                        Method       = "train"
                    };
                    InputFormData <UploadRequestParam> data = new InputFormData <UploadRequestParam>
                    {
                        SettingFile  = settingFile,
                        RequestParam = paras,
                        BookPath     = activePath,
                        ModelIdFile  = modelIdFile
                    };
                    var rsltData = UploadCommand.UploadCSV(data);
                    if (rsltData.MsgType == 0)
                    {
                        data.RequestParam.ModelID = rsltData.DsName;
                    }
                    else
                    {
                        return;
                    }

                    Cursor.Current = preCursor;
                    menuForm       = new ModelCreateEntranceForm(data);
                    menuForm.Show();
                }
            }
            catch (Exception ex)
            {
                MsgBox.MsgBoxShowErr(ex.Message);
            }
        }
예제 #2
0
        private void ModelApplied(object sender, EventArgs e)
        {
            btnExec.BackColor = Color.BurlyWood;
            Cursor preCursor = Cursor.Current;

            Cursor.Current = Cursors.WaitCursor;
            Library.AllCtrlSwInForm(this, false);
            IsDoing = true;

            try
            {
                ModelApplyRequestRaram reqParam = new ModelApplyRequestRaram();
                if (cbHowToModelID.SelectedIndex == 0)
                {
                    if (cbModelID.Items.Count >= 1)
                    {
                        reqParam.ModelID = cbModelID.SelectedItem.ToString();
                    }
                }
                else
                {
                    reqParam.ModelID = tbInputModelID.Text;
                }

                if (String.IsNullOrEmpty(reqParam.ModelID))
                {
                    throw new Exception("モデルIDを選択または入力して下さい。");
                }

                Dictionary <object, object> titleDict = null;
                var selectedRange = Globals.ThisAddIn.Application.Selection as Excel.Range;
                if (selectedRange.ListObject == null)
                {
                    titleDict = XlsOperation.GetTitleDict(ThisSh);
                }

                UploadRequestParam paras = new UploadRequestParam
                {
                    FileFullName = XlsOperation.MakeSelectedRangeTempFile(FilePath, selectedRange, titleDict, ThisSh),
                    Method       = "predict",
                    ModelID      = reqParam.ModelID
                };
                InputFormData <UploadRequestParam> data = new InputFormData <UploadRequestParam>
                {
                    SettingFile  = SettingFile,
                    RequestParam = paras
                };
                var rsltData = UploadCommand.UploadCSV(data);
                if (rsltData.MsgType != 0)
                {
                    return;
                }
                reqParam.DsName = rsltData.DsName;

                InputFormData <ModelApplyRequestRaram> iData = new InputFormData <ModelApplyRequestRaram>
                {
                    SettingFile  = SettingFile,
                    RequestParam = reqParam
                };
                ModelApplyResultData resData = ModelApplyCommand.ModelApplied(iData);
                if (resData.MsgType != 0)
                {
                    return;
                }

                MsgBox.MsgBoxShowInfo("モデル適用が完了しました。");
            }
            catch (Exception ex)
            {
                MsgBox.MsgBoxShowErr(ex.Message);
            }
            finally
            {
                Library.AllCtrlSwInForm(this, false);
                Cursor.Current    = preCursor;
                btnExec.BackColor = Color.Empty;
                IsDoing           = false;
                this.Close();
                this.Dispose();
            }
        }