private void comboBox_DMS_Projects_DropDown(object sender, EventArgs e) { RegSetting.DMS_Setting.UserID = textBox_DMS_UserID.Text; RegSetting.DMS_Setting.setPassword(textBox_DMS_Password.Text); if (textBox_DMS_UserID.Text.Length == 0 || textBox_DMS_Password.Text.Length == 0) { MessageBox.Show("Please provide UserID and Password first."); return; } if (!sw_DMSProjectRetrieved) { new FormWait(() => { try { var projects = Task.Run(() => { AutoDMS dms = new AutoDMS(RegSetting); if (!dms.loggedin) { MessageBox.Show("Login in Fail:\r\n" + string.Join("\r\n", dms.result)); return(null); } return(dms.getProjectList()); }).Result; if (projects == null) { MessageBox.Show("Retrieve projects from DMS server failed.\r\nCheck internet connection."); return; } Dictionary <string, string> ComboboxItem = new Dictionary <string, string>(); ComboboxItem.Add("auto", "Auto"); foreach (var p in projects) { ComboboxItem.Add(p["projectcode"] + p["fabid"] + p["workitemcode"], string.Format("{0} - {1} ({2})", p["projectname"], p["workitemname"], p["datestatus"])); } //跨執行續更新UI comboBox_DMS_Projects.InvokeIfRequired(() => { comboBox_DMS_Projects.DisplayMember = "Value"; comboBox_DMS_Projects.ValueMember = "Key"; comboBox_DMS_Projects.DataSource = new BindingSource(ComboboxItem, null); }); sw_DMSProjectRetrieved = true; } catch (Exception ex) { MessageBox.Show(string.Format("{0}\r\n{1}\r\n[comboBox_DMS_Projects_DropDown]", ex.Message, ex.InnerException.Message)); } }).SetMessage("Retrieving Projects from DMS ...").ShowDialog(); } }
private void updateDMS() { //避免重複執行 if (IconLock_DMS) { return; } IconLock_DMS = true; this.BeginInvoke(new MethodInvoker(delegate { pictureBox_DMS.Image = (Image)Resources.dms_running; toolTip.SetToolTip(pictureBox_DMS, "Auto DMS is running..."); })); AutoDMS dms = new AutoDMS(RegSetting); bool dmsok = dms.UpdateDailyReport(); foreach (string s in dms.result) { UpdateMSGtoUI(s); } if (dmsok) { UpdateMSGtoUI("DMS updated."); } else { UpdateMSGtoUI("DMS update failed."); } this.BeginInvoke(new MethodInvoker(delegate { pictureBox_DMS.Image = RegSetting.DMS_Enable ? (Image)Resources.dms_enable : (Image)Resources.dms_disable; toolTip.SetToolTip(pictureBox_DMS, RegSetting.DMS_Enable ? "Auto DMS is enable, Freya will fill out DMS daily for you." : "Auto DMS disabled."); })); IconLock_DMS = false; }
private void button_DMS_More_Click(object sender, EventArgs e) { string content = AutoDMS.getContent(Convert.ToInt32(numericUpDown_DMS_Items.Value), textBox_DMS_Target.Text, textBox_DMS_Action.Text, textBox_DMS_Event.Text); richTextBox_DMS_Example.Text = (content.Length > 0) ? content : "Can't generate content, please check Target/Action/Event fields."; }