private void btnAC_Click(object sender, EventArgs e) { string Mid = menuID; String IdName = String.Empty; string Uid = String.Empty; language = CliUtils.fClientLang; if (lstSelected.SelectedItem != null) IdName = lstSelected.SelectedItem.ToString(); else if (lstLibrary.SelectedItem != null) IdName = lstLibrary.SelectedItem.ToString(); if (IdName == String.Empty) { language = CliUtils.fClientLang; string message = SysMsg.GetSystemMessage(language, "Srvtools", "InfoSecurity", "IsChooseUser"); MessageBox.Show(message); } else { String[] str = IdName.Split(new char[] { '(', ')' }); Uid = str[1]; if (Mid == "" || Mid == null) { language = CliUtils.fClientLang; string message = SysMsg.GetSystemMessage(language, "Srvtools", "InfoSecurity", "IsChooseMenu"); MessageBox.Show(message); } else { frmAccessControlForUser fac = new frmAccessControlForUser(Mid, menuName, Uid, IdName); fac.ShowDialog(); } } }
public frmNavQuery(QueryFieldCollection queryfields, InfoBindingSource bs, InfoNavigator nav) { //language = CliSysMegLag.GetClientLanguage(); language = CliUtils.fClientLang; queryFields = queryfields; if (queryfields == null || queryfields.Count == 0) { DataColumnCollection dcc = ((InfoDataSet)bs.GetDataSource()).RealDataSet.Tables[bs.DataMember].Columns; colNum = dcc.Count; colName = new string[colNum]; for (int j = 0; j < colNum; j++) { colName[j] = dcc[j].ColumnName; } } else { colNum = queryfields.Count; colName = new string[colNum]; for (int j = 0; j < colNum; j++) { colName[j] = queryfields[j].FieldName; } } bSource = bs; infoNavigator = nav; InitializeComponent(); InitializeQueryConditionItem(); }
public WebClientMove() { //language = CliSysMegLag.GetClientLanguage(); language = CliUtils.fClientLang; _KeyMatchColumns = new WebKeyMatchColumns(this, typeof(WebKeyMatchColumn)); _MatchColumns = new WebMatchColumns(this, typeof(WebMatchColumn)); }
public AutoTest() { //language = CliSysMegLag.GetClientLanguage(); language = CliUtils.fClientLang; _Columns = new infoColumns(this, typeof(infoColumn)); InitializeComponent(); }
public UPWDControl(IContainer container) { container.Add(this); //language = CliSysMegLag.GetClientLanguage(); language = CliUtils.fClientLang; InitializeComponent(); }
public void OnExport() { if (ws.DBAlias == null || ws.DBAlias == "" || ws.DBAlias == "(none)") { //language = CliSysMegLag.GetClientLanguage(); language = CliUtils.fClientLang; string message = SysMsg.GetSystemMessage(language, "Srvtools", "InfoSecurity", "IsDBAlias", true); MessageBox.Show(message); } else if (Export == null) { Export = new frmWebSecurity(ws, this.GetService(typeof(IDesignerHost)) as IDesignerHost); Export.ShowDialog(); } Export = null; }
public override void DoDefaultAction() { InfoSecurity ifs = (InfoSecurity)this.Component; if (ifs.DBAlias == null || ifs.DBAlias == "" || ifs.DBAlias == "(none)") { //language = CliSysMegLag.GetClientLanguage(); language = CliUtils.fClientLang; string message = SysMsg.GetSystemMessage(language, "Srvtools", "InfoSecurity", "IsDBAlias"); MessageBox.Show(message); } else if (editor == null) { editor = new frmInfoSecurityEdit(this.Component as InfoSecurity, this.GetService(typeof(IDesignerHost)) as IDesignerHost); editor.ShowDialog(); } //editor.Dispose(); editor = null; }
public InfoDMDesigner() { // Get language type language = GetClientLanguage(); // Add By Chenjian 2005-12-26 // For Save/Load Component Location // Save Component Location EventHandler saveComponentLocationEventHandler = new EventHandler( delegate(object sender, EventArgs e) { SaveComponentLocation(); } ); DesignerVerb saveComponentLocation = new DesignerVerb("Save Location", saveComponentLocationEventHandler); this.Verbs.Insert(0, saveComponentLocation); // Load Component Location EventHandler loadComponentLocationEventHandler = new EventHandler( delegate(object sender, EventArgs e) { LoadComponentLocation(); } ); DesignerVerb loadComponentLocation = new DesignerVerb("Load Location", loadComponentLocationEventHandler); this.Verbs.Insert(0, loadComponentLocation); // End Add 2005-12-26 // Use a thread to load the design time view and apply Service-Event // because that can not be done in constructor // Thread t = new Thread(new ThreadStart(ViewOperation)); t.Priority = ThreadPriority.Highest; t.Start(); }
private string SetEmptyData(WebDropDownList ddl) { string ret = ""; if (ddl.AutoInsertEmptyData) { language = CliUtils.fClientLang; String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDropDownList", "EmptyData", true); ret = "filterSelect.options.add(new Option('" + message + "',''));"; } return ret; }
private void button1_Click(object sender, EventArgs e) { String Mid = menuID; String IdName = String.Empty; String Gid = String.Empty; //language = CliSysMegLag.GetClientLanguage(); language = CliUtils.fClientLang; if (lstSelected.SelectedItem != null) IdName = lstSelected.SelectedItem.ToString(); else if (lstLibrary.SelectedItem != null) IdName = lstLibrary.SelectedItem.ToString(); if (String.IsNullOrEmpty(IdName)) { language = CliUtils.fClientLang; string message = SysMsg.GetSystemMessage(language, "Srvtools", "InfoSecurity", "IsChooseGroup"); MessageBox.Show(message); } else { String[] str = IdName.Split(new char[] { '(', ')' }); Gid = str[1]; if (Mid == "" || Mid == null) { language = CliUtils.fClientLang; string message = SysMsg.GetSystemMessage(language, "Srvtools", "InfoSecurity", "IsChooseMenu"); MessageBox.Show(message); } else { frmAccessControlForGroup fac = new frmAccessControlForGroup(Mid, menuName, Gid, IdName); fac.ShowDialog(); } } }
private void SetLanguage(SYS_LANGUAGE language) { string[] UITexts = SysMsg.GetSystemMessage(CliUtils.fClientLang, "FLClientControls", "SubmitConfirm", "UIText").Split(','); if (UITexts.Length >= 12) { this.gbContainer.Text = UITexts[0]; this.chkImportant.Text = UITexts[1]; this.chkUrgent.Text = UITexts[2]; this.tabSuggest.Text = UITexts[3]; this.tabHis.Text = UITexts[4]; this.lblRole.Text = UITexts[5]; this.btnOK.Text = UITexts[6]; this.btnCancel.Text = UITexts[7]; this.lblOrg.Text = UITexts[9]; this.lblReturnStep.Text = UITexts[10]; this.btnUploadFiles.Text = UITexts[12]; this.btnClose.Text = UITexts[13]; this.buttonPreview.Text = UITexts[14]; } string[] UIHisTexts = SysMsg.GetSystemMessage(CliUtils.fClientLang, "FLClientControls", "SubmitConfirm", "HisUIText").Split(','); if (UIHisTexts.Length >= 5) { this.columnUserId.HeaderText = UIHisTexts[0]; this.columnUserName.HeaderText = UIHisTexts[1]; this.columnUpdateDate.HeaderText = UIHisTexts[2]; this.columnUpdateTime.HeaderText = UIHisTexts[3]; this.columnStepId.HeaderText = UIHisTexts[5]; this.label1.Text = UIHisTexts[4]; this.columnStatus.HeaderText = UIHisTexts[6]; } }
protected override void Render(HtmlTextWriter writer) { if (!this.Display) writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none"); if (this.CheckDate) { string blurScript = "if(!checkdate(" + this.UniqueID + ".value)) {" + this.ClientID + ".focus();" + this.ClientID + ".value='';}"; writer.AddAttribute("onblur", blurScript); } //this.RenderBeginTag(writer); //base.RenderContents(writer); //this.RenderEndTag(writer); base.Render(writer); if (!this.DesignMode) { _calendarExtender.OnClientDateSelectionChanged = this.ClientID + "SelDate"; _calendarExtender.RenderControl(writer); } ClientScriptManager csm = Page.ClientScript; if (!csm.IsClientScriptBlockRegistered("clientScript")) { //language = CliSysMegLag.GetClientLanguage(); language = CliUtils.fClientLang; string message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDateTimePicker", "DateTimeValidate", true); writer.WriteLine("<script language=\"JavaScript\">"); writer.WriteLine("function checkdate(inpar)"); writer.WriteLine("{"); //writer.WriteLine("var flag=true;"); writer.WriteLine("var flagM = false;"); writer.WriteLine("var flagY = false;"); writer.WriteLine("var flagD = false;"); writer.WriteLine("var getdate = inpar;"); writer.WriteLine("if(getdate != \"\")"); writer.WriteLine("{"); writer.WriteLine("var datepart = getdate.split('');"); writer.WriteLine("var syear='', smonth='', sday='';"); writer.WriteLine("var f = 0;"); writer.WriteLine("for(var i = 0; i < datepart.length; i++)"); writer.WriteLine("{"); writer.WriteLine("var j = datepart[i];"); writer.WriteLine("if(parseInt(j) <= 9 && parseInt(j) >= 0)"); writer.WriteLine("{"); writer.WriteLine("if(f == 0)"); writer.WriteLine("{"); switch (this.Format) { case "d": case "MM/dd/yyyy": case "MM-dd-yyyy": writer.WriteLine("smonth += j;"); break; case "yyyy/MM/dd": case "yyyy-MM-dd": writer.WriteLine("syear += j;"); break; } writer.WriteLine("}"); writer.WriteLine("else if(f == 1)"); writer.WriteLine("{"); switch (this.Format) { case "d": case "MM/dd/yyyy": case "MM-dd-yyyy": writer.WriteLine("sday += j;"); break; case "yyyy/MM/dd": case "yyyy-MM-dd": writer.WriteLine("smonth += j;"); break; } writer.WriteLine("}"); writer.WriteLine("else if(f == 2)"); writer.WriteLine("{"); switch (this.Format) { case "d": case "MM/dd/yyyy": case "MM-dd-yyyy": writer.WriteLine("syear += j;"); break; case "yyyy/MM/dd": case "yyyy-MM-dd": writer.WriteLine("sday += j;"); break; } writer.WriteLine("}"); writer.WriteLine("}"); writer.WriteLine("else"); writer.WriteLine("{"); writer.WriteLine("f++;"); writer.WriteLine("}"); writer.WriteLine("}"); writer.WriteLine("var year = parseInt(syear);"); //if (TraDate) //{ // writer.WriteLine("year = year + 1911;"); //} writer.WriteLine("if (smonth.indexOf('0') == 0)"); writer.WriteLine("{"); writer.WriteLine("smonth = smonth.substring(1);"); writer.WriteLine("}"); writer.WriteLine("if (sday.indexOf('0') == 0)"); writer.WriteLine("{"); writer.WriteLine("sday = sday.substring(1);"); writer.WriteLine("}"); writer.WriteLine("var month = parseInt(smonth);"); writer.WriteLine("var day = parseInt(sday);"); //判断年份是否格式正确 writer.WriteLine("if(year <= 9999 && year >= 1) { flagY=true; }"); // 判断月份是否格式正确 writer.WriteLine("if(month <= 12 && month >= 1) { flagM=true; }"); // 判断4,6,9,11月份 writer.WriteLine("if (month==4 || month==6 || month==9 || month==11)"); writer.WriteLine("{"); writer.WriteLine("if(day<=30 && day>=1)"); writer.WriteLine("{"); writer.WriteLine("flagD=true;"); writer.WriteLine("}"); writer.WriteLine("}"); // 判断2月份 writer.WriteLine("else if (month==2)"); writer.WriteLine("{"); writer.WriteLine("if (LeapYear(year))"); writer.WriteLine("{"); writer.WriteLine("if (day<=29 && day>=1){ flagD=true; }"); writer.WriteLine("}"); writer.WriteLine("else"); writer.WriteLine("{"); writer.WriteLine("if (day<=28 && day>=1){flagD=true; } "); writer.WriteLine("}"); writer.WriteLine("}"); // 判断1,3,5,7,8,10,12月份 writer.WriteLine("else"); writer.WriteLine("{"); writer.WriteLine("if(day<=31 && day >= 1)"); writer.WriteLine("{"); writer.WriteLine("flagD=true;"); writer.WriteLine("}"); writer.WriteLine("}"); writer.WriteLine("if (flagY==false || flagM==false || flagD==false)"); writer.WriteLine("{"); writer.WriteLine("alert('" + message + "');"); writer.WriteLine("}"); writer.WriteLine("return (flagY && flagM && flagD);"); writer.WriteLine("}"); writer.WriteLine("else {return true;}"); writer.WriteLine("}"); // 判断当前年是否为闰年 writer.WriteLine("function LeapYear(intYear)"); writer.WriteLine("{"); writer.WriteLine("if (intYear % 100 == 0)"); writer.WriteLine("{"); writer.WriteLine("if (intYear % 400 == 0) { return true; }"); writer.WriteLine("}"); writer.WriteLine("else"); writer.WriteLine("{"); writer.WriteLine("if ((intYear % 4) == 0) { return true; }"); writer.WriteLine("}"); writer.WriteLine("return false;"); writer.WriteLine("}"); writer.WriteLine("function " + this.OnClientDateSelectionChanged + "()"); writer.WriteLine("{"); writer.WriteLine("$find('" + _calendarExtender.BehaviorID + "').hide();"); writer.WriteLine("}"); writer.WriteLine("</script>"); csm.RegisterClientScriptBlock(this.GetType(), "clientScript", ""); } }
private void WriteLog() { if (this.Log != null && this.Log != "") { string s = null; if (Log.Length > 4) { for (int h = 0; h < 4; h++) s = s + this.Log[Log.Length - 4 + h]; if (string.Compare(s, ".txt", true) != 0)//IgnoreCase this.Log = this.Log + ".txt"; } else this.Log = this.Log + ".txt"; try { if (File.Exists(this.Log)) { FileStream fs = File.Open(this.Log, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); StreamReader sreader = new StreamReader(fs); alLog.Add(sreader.ReadToEnd()); sreader.Close(); fs = File.Open(this.Log, FileMode.Open, FileAccess.Write, FileShare.ReadWrite); StreamWriter swriter = new StreamWriter(fs); for (int i = 0; i < alLog.Count; i++) { swriter.WriteLine(alLog[i]); } swriter.Close(); fs.Close(); } else { language = CliUtils.fClientLang; string message = SysMsg.GetSystemMessage(language, "Srvtools", "AutoTest", "LogError"); MessageBox.Show(message); } } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show(ex.GetType().ToString()); } } }
private void SetLanguage(SYS_LANGUAGE language) { string[] UITexts = SysMsg.GetSystemMessage(CliUtils.fClientLang, "FLClientControls", "NotifyForm", "UIText").Split(','); if (UITexts.Length >= 7) { this.gbRoles.Text = UITexts[1]; this.gbNotify.Text = UITexts[2]; this.label1.Text = UITexts[3]; this.label2.Text = UITexts[4]; this.btnOK.Text = UITexts[5]; this.btnCancel.Text = UITexts[6]; this.label4.Text = UITexts[8]; this.label5.Text = UITexts[9]; this.btnSearch.Text = UITexts[10]; } }
public frmDGVGridRefVal() { InitializeComponent(); language = CliUtils.fClientLang; }
public void Execute(string user) { if (this.ParentAutoTest != null && (this.KeyField == "" || this.KeyField == null)) { language = CliUtils.fClientLang; string message = SysMsg.GetSystemMessage(language, "Srvtools", "AutoTest", "KeyFieldNull"); MessageBox.Show(message); return; } if (this.infoBindingSource != null) { if (ids == null) { ids = (InfoDataSet)this.infoBindingSource.GetDataSource(); } if (this.ParentAutoTest != null || this.infoBindingSource.DataSource == ids) { for (int times = 0; times < this.Rows; times++) { List<String> listKey = new List<String>(); DataRow dr = ids.RealDataSet.Tables[deep].NewRow(); foreach (infoColumn ColumnsItem in Columns) { for (int i = 0; i < ids.RealDataSet.Tables[deep].Columns.Count; i++) { if (ids.RealDataSet.Tables[deep].Columns[i].Caption == ColumnsItem.ColumnName) { if (deep > 0 && ids.RealDataSet.Tables[0].Rows.Count > 0) { DataRow dr_temp = ids.RealDataSet.Tables[0].Rows[ids.RealDataSet.Tables[0].Rows.Count - 1]; if (ColumnsItem.ColumnName == ids.RealDataSet.Tables[0].PrimaryKey.GetValue(0).ToString()) { dr[ids.RealDataSet.Tables[deep].Columns[i].Caption] = dr_temp[ids.RealDataSet.Tables[0].Columns[i].Caption]; break; } } if (ColumnsItem.valueMode == ValueMode.Fixed) { dr[ids.RealDataSet.Tables[deep].Columns[i].Caption] = GetDefaultValue(ColumnsItem); break; } else if (ColumnsItem.valueMode == ValueMode.Random) { bool flag = true; for (int j = 0; j < ColumnsItem.Value.Length; j++) if (ColumnsItem.Value[j] < 48 || ColumnsItem.Value[j] > 57) flag = false; for (int j = 0; j < ColumnsItem.RandomTo.Length; j++) if (ColumnsItem.RandomTo[j] < 48 || ColumnsItem.RandomTo[j] > 57) flag = false; if (flag == false) { int length; String value = null; if (ColumnsItem.Value.Length < ColumnsItem.RandomTo.Length) length = ColumnsItem.Value.Length; else length = ColumnsItem.RandomTo.Length; Label1: StringBuilder sb = new StringBuilder(length); for (int x = 0; x < length; x++) { sb.Append(getRandomChar(ColumnsItem.Value[x], ColumnsItem.RandomTo[x])); } for (int x = 0; x < ColumnsItem.RandomTo.Length - ColumnsItem.Value.Length; x++) { sb.Append(getRandomChar(ColumnsItem.RandomTo[x])); } if (ColumnsItem.ColumnName == this.KeyField && listKey.Contains(sb.ToString())) { goto Label1; } value = sb.ToString(); dr[ids.RealDataSet.Tables[deep].Columns[i].Caption] = value; listKey.Add(value); } else { int begin, end; Random m_rnd = new Random(); int value; begin = this.getRandomInt(ColumnsItem.Value); end = this.getRandomInt(ColumnsItem.RandomTo); Label2: value = this.m_rnd.Next(begin, end); if (ColumnsItem.ColumnName == this.KeyField && listKey.Contains(value.ToString())) { goto Label2; } dr[ids.RealDataSet.Tables[deep].Columns[i].Caption] = value; listKey.Add(value.ToString()); } break; } else if (ColumnsItem.valueMode == ValueMode.RefRandom) { if (ColumnsItem.RefVal != null) { InfoDataSet r_ds = (InfoDataSet)ColumnsItem.RefVal.GetDataSource(); Random rnd = new Random(); Label3: int x = rnd.Next(r_ds.RealDataSet.Tables[0].Rows.Count); DataRow r_dr = r_ds.RealDataSet.Tables[0].Rows[x]; if (ColumnsItem.ColumnName == this.KeyField && listKey.Contains(r_dr[ColumnsItem.RefVal.ValueMember].ToString())) { goto Label3; } dr[ColumnsItem.ColumnName] = r_dr[ColumnsItem.RefVal.ValueMember]; listKey.Add(r_dr[ColumnsItem.RefVal.ValueMember].ToString()); } break; } else { dr[ColumnsItem.ColumnName] = user + sequence++; break; } } } } try { ids.RealDataSet.Tables[deep].Rows.Add(dr); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } if (this.ChildAutoTest.Count > 0) { int xcount = 0; for (; xcount < this.ChildAutoTest.Count; xcount++) { deep++; deep = deep + xcount; AutoTest test = (AutoTest)this.ChildAutoTest[xcount]; //DateTime StartTime = DateTime.Now; //int start = (StartTime.Hour * 60 * 60 + StartTime.Minute * 60 + StartTime.Second) * 1000 + StartTime.Millisecond; //alLog.Add("UserID: " + user + " PackageName: " + package + " Satuts: DetailStart"); test.Execute(user); //DateTime CompleteTime = DateTime.Now; //int complete = (CompleteTime.Hour * 60 * 60 + CompleteTime.Minute * 60 + CompleteTime.Second) * 1000 + CompleteTime.Millisecond; //int between = complete - start; //alLog.Add("UserID: " + user + " PackageName: " + package + " Satuts: DetailComplete DateTime: " + between.ToString()); //MaxRespendTime = Max(StartTime, CompleteTime, MaxRespendTime); //MinRespendTime = Min(StartTime, CompleteTime, MinRespendTime); } if (xcount > 0) deep -= xcount; else deep++; } //if(deep > 0) //{ // DateTime CompleteTime = DateTime.Now; // int complete = (CompleteTime.Hour * 60 * 60 + CompleteTime.Minute * 60 + CompleteTime.Second) * 1000 + CompleteTime.Millisecond; // int between = complete - start; // alLog.Add("UserID: " + user + " PackageName: " + package + " Satuts: MasterComplete DateTime: " + between.ToString()); //} } } deep = 0; //if (this.Log != null && this.Log != "") //{ // complete = DateTime.Now; //MaxRespendTime = Max(start, complete, MaxRespendTime); //MinRespendTime = Min(start, complete, MinRespendTime); // alLog.Add("UserID: " + user + " PackageName: " + package); // int time = (complete.Hour * 60 * 60 + complete.Minute * 60 + complete.Second) * 1000 + complete.Millisecond; // alLog.Add(" Status: COMPLETE TEST DateTime: " + time.ToString()); // //alLog.Add(" Status: COMPLETE TEST DateTime: " + complete.ToString()); //} } }
/*public void designerHost_LoadComplete(object sender, EventArgs e) { LoadComponentLocation(); }*/ private void ViewOperation() { try { // designerHost // designerHost = this.GetService(typeof(IDesignerHost)) as IDesignerHost; while (designerHost == null) { Thread.Sleep(100); designerHost = this.GetService(typeof(IDesignerHost)) as IDesignerHost; } // Wait for loading document // //designerHost.LoadComplete += new EventHandler(designerHost_LoadComplete); while (designerHost.Loading) { Thread.Sleep(100); } // view // view = this.Control; while (view == null) { Thread.Sleep(100); view = this.Control; } view.Paint += new PaintEventHandler(view_Paint); view.Click += new EventHandler(view_Click); this.TrayAutoArrange = false; // Add a Rectangle border to every control in design view // foreach (Control ctrl in view.Controls) { ctrl.Paint += new PaintEventHandler(ctrl_Paint); } // componnetChangeService // componentChangeService = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService; while (componentChangeService == null) { Thread.Sleep(100); componentChangeService = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService; } componentChangeService.ComponentAdded += new ComponentEventHandler(componentChangeService_ComponentAdded); componentChangeService.ComponentChanged += new ComponentChangedEventHandler(componentChangeService_ComponentChanged); componentChangeService.ComponentRemoved += new ComponentEventHandler(componentChangeService_ComponentRemoved); componentChangeService.ComponentRename += new ComponentRenameEventHandler(componentChangeService_ComponentRename); // Load Relations // relations = new ArrayList(); Type componentType = typeof(System.ComponentModel.Component); // Reload relations if loading fails StartLoadRelation: try { foreach (IComponent comp in designerHost.Container.Components) { string src = comp.ToString(); if (src.IndexOf(' ') != -1) { src = src.Substring(0, src.IndexOf(' ')); } Control source = GetViewedControl(src); if (source == null) { continue; } Type t = comp.GetType(); PropertyInfo[] properties = t.GetProperties(); foreach (PropertyInfo property in properties) { // A property can be System.Object-Type that have relation with other component // Such as ComboBox.DataSource // //if (property.PropertyType.GetInterface("System.ComponentModel.IComponent") == null) //{ // continue; //} // To filter properties such as TextBox.Text if (property.PropertyType.FullName == "System.String") { continue; } // To filter collections properties if (property.PropertyType.GetInterface("System.Collections.ICollection") != null) { continue; } if (!property.CanWrite) { continue; } MethodInfo mi = property.GetGetMethod(); //// To filter write-only properties //if (mi == null) //{ // continue; //} // To filter indexer perperties if (mi.GetParameters().GetLength(0) != 0) { continue; } // To filter properties with no value if (property.GetValue(comp, null) == null) { continue; } // To filter Connection Properties if (property.GetValue(comp, null) is System.Data.IDbConnection) { continue; } string dst = property.GetValue(comp, null).ToString(); if (dst.IndexOf(' ') != -1) { dst = dst.Substring(0, dst.IndexOf(' ')); } if (src == dst) { continue; } Control destination = GetViewedControl(dst); if (source != null && destination != null) { relations.Add(new Relation(this, src, dst)); } } // A special case for InfoTransaction //if (comp is InfoTransaction) //{ // InfoTransaction infoTrans = comp as InfoTransaction; // foreach (Transaction trans in infoTrans.Transactions) // { // if (trans.AutoNumber != null && trans.AutoNumber.Site != null) // { // string dst = trans.AutoNumber.Site.Name; // if (dst.IndexOf(' ') != -1) // { // dst = dst.Substring(0, dst.IndexOf(' ')); // } // Control destination = GetViewedControl(dst); // if (destination != null) // { // relations.Add(new Relation(this, src, dst)); // } // } // } //} } } catch { relations.Clear(); goto StartLoadRelation; } view.Refresh(); } catch (Exception err) { language = CliUtils.fClientLang; string sMess = SysMsg.GetSystemMessage(language, ThisModuleName, ThisComponentName, "msg_Exception"); MessageBox.Show(string.Format(sMess, ThisComponentName, "ViewOperation", err.Message)); } }
// Occurs when a component is renamed // void componentChangeService_ComponentRename(object sender, ComponentRenameEventArgs e) { try { // search and change the modified name in relations // for (int i = relations.Count - 1; i >= 0; --i) { Relation relation = relations[i] as Relation; if (relation.Source == e.OldName) { relation.Source = e.NewName; } if (relation.Destination == e.OldName) { relation.Destination = e.NewName; } } } catch (Exception err) { language = CliUtils.fClientLang; string sMess = SysMsg.GetSystemMessage(language, ThisModuleName, ThisComponentName, "msg_Exception"); MessageBox.Show(string.Format(sMess, ThisComponentName, "componentChangeService_ComponentRename", err.Message)); } }
void ctrl_Paint(object sender, PaintEventArgs e) { try { // Draw a rectangle border on the Control // Control ctrl = sender as Control; Pen pen = new Pen(Brushes.DarkGray, 1.0f); e.Graphics.DrawRectangle(pen, 0, 0, ctrl.Width - 1, ctrl.Height - 1); } catch (Exception err) { language = CliUtils.fClientLang; string sMess = SysMsg.GetSystemMessage(language, ThisModuleName, ThisComponentName, "msg_Exception"); MessageBox.Show(string.Format(sMess, ThisComponentName, "ctrl_Paint", err.Message)); } }
// Occurs when a component is removed // void componentChangeService_ComponentRemoved(object sender, ComponentEventArgs e) { try { // remove the removed component from relations // if (e.Component.Site == null) { return; } string obj = e.Component.Site.Name; if (obj.IndexOf(' ') != -1) { obj = obj.Substring(0, obj.IndexOf(' ')); } for (int i = relations.Count - 1; i >= 0; --i) { Relation relation = relations[i] as Relation; if (relation.Source == obj || relation.Destination == obj) { relations.RemoveAt(i); } } view.Refresh(); } catch (Exception err) { language = CliUtils.fClientLang; string sMess = SysMsg.GetSystemMessage(language, ThisModuleName, ThisComponentName, "msg_Exception"); MessageBox.Show(string.Format(sMess, ThisComponentName, "componentChangeService_ComponentRemoved", err.Message)); } }
// Occurs when change happens the a componnet // void componentChangeService_ComponentChanged(object sender, ComponentChangedEventArgs e) { try { string src = e.Component.ToString(); if (src.IndexOf(' ') != -1) { src = src.Substring(0, src.IndexOf(' ')); } if (GetViewedControl(src) == null) { return; } if (e.OldValue != null) { string dst = e.OldValue.ToString(); if (dst.IndexOf(' ') != -1) { dst = dst.Substring(0, dst.IndexOf(' ')); } for (int i = relations.Count - 1; i >= 0; --i) { Relation relation = relations[i] as Relation; if (relation.Source == src && relation.Destination == dst) { relations.RemoveAt(i); } } } if (e.NewValue != null) { // To filter Connection Properties if (e.NewValue is System.Data.Common.DbConnection) { return; } string dst = e.NewValue.ToString(); if (dst.IndexOf(' ') != -1) { dst = dst.Substring(0, dst.IndexOf(' ')); } if (src == dst) { return; } Control source = GetViewedControl(src); Control destination = GetViewedControl(dst); if (source != null && destination != null) { relations.Add(new Relation(this, src, dst)); } } // A special case for InfoTransaction //if (e.Component is InfoTransaction && e.Member != null && e.Member.Name == "Transactions") //{ // InfoTransaction infoTrans = e.Component as InfoTransaction; // // Clear the old AutoNumber - InfoTransaction Relations // List<Transaction> oldTransactions = e.OldValue as List<Transaction>; // if (infoTrans != null && oldTransactions != null) // { // foreach (Transaction trans in oldTransactions) // { // if (trans.AutoNumber != null && trans.AutoNumber.Site != null) // { // string dst = trans.AutoNumber.Site.Name; // if (dst.IndexOf(' ') != -1) // { // dst = dst.Substring(0, dst.IndexOf(' ')); // } // for (int i = relations.Count - 1; i >= 0; --i) // { // Relation relation = relations[i] as Relation; // if (relation.Source == infoTrans.Name || relation.Destination == dst) // { // relations.RemoveAt(i); // } // } // } // } // // Add the new AutoNumber - InfoTransactions Relations // foreach (Transaction trans in infoTrans.Transactions) // { // if (trans.AutoNumber != null // && trans.AutoNumber.Site != null) // { // string dst = trans.AutoNumber.Site.Name; // if (dst.IndexOf(' ') != -1) // { // dst = dst.Substring(0, dst.IndexOf(' ')); // } // Control destination = GetViewedControl(dst); // if (destination != null) // { // relations.Add(new Relation(this, src, dst)); // } // } // } // } //} view.Refresh(); } catch (Exception err) { language = CliUtils.fClientLang; string sMess = SysMsg.GetSystemMessage(language, ThisModuleName, ThisComponentName, "msg_Exception"); MessageBox.Show(string.Format(sMess, ThisComponentName, "componentChangeService_ComponentChanged", err.Message)); } }
// Occurs when a component is added // void componentChangeService_ComponentAdded(object sender, ComponentEventArgs e) { try { if (e.Component.Site != null) { Control ctrl = this.GetViewedControl(e.Component.Site.Name); if (ctrl != null) { ctrl.Paint += new PaintEventHandler(ctrl_Paint); } if (e.Component is InfoCommand) { foreach (Component comp in designerHost.Container.Components) { if (comp is InfoConnection) { ((InfoCommand)(e.Component)).InfoConnection = (InfoConnection)comp; break; } } } // Add By Chenjian 2006-01-11 //string src = e.Component.ToString(); //if (src.IndexOf(' ') != -1) //{ // src = src.Substring(0, src.IndexOf(' ')); //} //Control source = GetViewedControl(src); //if (source != null) //{ // Type t = e.Component.GetType(); // PropertyInfo[] properties = t.GetProperties(); // foreach (PropertyInfo property in properties) // { // // A property can be System.Object-Type that have relation with other component // // Such as ComboBox.DataSource // // // //if (property.PropertyType.GetInterface("System.ComponentModel.IComponent") == null) // //{ // // continue; // //} // // To filter properties such as TextBox.Text // if (property.PropertyType.FullName == "System.String") // { // continue; // } // // To filter collections properties // if (property.PropertyType.GetInterface("System.Collections.ICollection") != null) // { // continue; // } // MethodInfo mi = property.GetGetMethod(); // // To filter write-only properties // if (mi == null) // { // continue; // } // // To filter indexer perperties // if (mi.GetParameters().GetLength(0) != 0) // { // continue; // } // // To filter properties with no value // if (property.GetValue(e.Component, null) == null) // { // continue; // } // // To filter Connection Properties // if (property.GetValue(e.Component, null) is System.Data.Common.DbConnection) // { // continue; // } // string dst = property.GetValue(e.Component, null).ToString(); // if (dst.IndexOf(' ') != -1) // { // dst = dst.Substring(0, dst.IndexOf(' ')); // } // if (src == dst) // { // continue; // } // Control destination = GetViewedControl(dst); // if (source != null && destination != null) // { // relations.Add(new Relation(this, src, dst)); // } // } //} // End Add } } catch (Exception err) { language = CliUtils.fClientLang; string sMess = SysMsg.GetSystemMessage(language, ThisModuleName, ThisComponentName, "msg_Exception"); MessageBox.Show(string.Format(sMess, ThisComponentName, "componentChangeService_ComponentAdded", err.Message)); } }
protected override void OnDataBinding(EventArgs e) { this.SetFilter(); if (this.AutoInsertEmptyData) { language = CliUtils.fClientLang; String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDropDownList", "EmptyData", true); ListItem item = new ListItem(message, ""); if (!this.Items.Contains(item)) this.Items.Insert(0, item); } try { base.OnDataBinding(e); } catch (Exception ex) { if (!(ex is InvalidOperationException)) this.SelectedIndex = 0; } }
// Paint the line between components void view_Paint(object sender, PaintEventArgs e) { try { Pen pen = new Pen(Brushes.Chocolate, 1.0f); // Draw lines between related components // foreach (Relation relation in relations) { Point srcPoint, destPoint; GetCrossPoint(relation.SourceControl, relation.DestinationControl, out srcPoint, out destPoint); pen.Brush = Brushes.Chocolate; if (designerHost.Container.Components[relation.destination] is System.Data.DataSet || designerHost.Container.Components[relation.destination] is InfoDataSet) { pen.Brush = Brushes.Blue; } e.Graphics.DrawLine(pen, srcPoint, destPoint); float x = destPoint.X - srcPoint.X; float y = destPoint.Y - srcPoint.Y; float angle = 0; if (x == 0 && y == 0) { continue; } else if (x > 0 && y == 0) { angle = 180; } else if (x > 0 && y > 0) { angle = (float)(180 + Math.Atan(y / x) / Math.PI * 180); } else if (x == 0 && y > 0) { angle = 270; } else if (x < 0 && y > 0) { angle = (float)(360 - Math.Atan(y / Math.Abs(x)) / Math.PI * 180); } else if (x < 0 && y == 0) { angle = 360; } else if (x < 0 && y < 0) { angle = (float)(Math.Atan(Math.Abs(y) / Math.Abs(x)) / Math.PI * 180); } else if (x == 0 && y < 0) { angle = 90; } else if (x > 0 && y < 0) { angle = (float)(180 - Math.Atan(Math.Abs(y) / x) / Math.PI * 180); } e.Graphics.FillPie(pen.Brush, destPoint.X - 13, destPoint.Y - 13, 26, 26, angle - 20, 40); } } catch (Exception err) { language = CliUtils.fClientLang; string sMess = SysMsg.GetSystemMessage(language, ThisModuleName, ThisComponentName, "msg_Exception"); MessageBox.Show(string.Format(sMess, ThisComponentName, "view_Paint", err.Message)); } }
//建立基本資訊 private object[] CreateClientInfo(string user, string password, string loginDB, string projectName, SYS_LANGUAGE language) { return new object[] { language, user, loginDB , "", "", "" , projectName, "", "" , "", "", "" , "", "", "", "0", password }; }
private void btnUpdate_Click(object sender, EventArgs e) { object[] param = new object[1]; param[0] = groupID + ";" + menuID; DataSet ds = new DataSet(); object[] myRet = CliUtils.CallMethod("GLModule", "GetGroup", param); //language = CliSysMegLag.GetClientLanguage(); language = CliUtils.fClientLang; if ((myRet != null) && (0 == (int)myRet[0])) { ds = (DataSet)myRet[1]; } for(int i = 0; i < infoDataGridView1.Rows.Count;i++) { bool flag = false; for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { if (infoDataGridView1.Rows[i].Cells["Group_ID"].Value == null || (ds.Tables[0].Rows[j]["GroupID"].ToString() == infoDataGridView1.Rows[i].Cells["Group_ID"].Value.ToString() && ds.Tables[0].Rows[j]["MenuID"].ToString() == infoDataGridView1.Rows[i].Cells["Menu_ID"].Value.ToString() && ds.Tables[0].Rows[j]["ControlName"].ToString() == infoDataGridView1.Rows[i].Cells["ControlName"].Value.ToString())) { flag = true; object[] UpdateGroup = new object[1]; if (infoDataGridView1.Rows[i].Cells["Group_ID"].Value != null && (infoDataGridView1.Rows[i].Cells["Type"].Value.ToString() == "InfoBindingSource" || infoDataGridView1.Rows[i].Cells["Type"].Value.ToString() == "WebDataSource" || infoDataGridView1.Rows[i].Cells["Type"].Value.ToString() == "JQDataGrid")) { if (infoDataGridView1.Rows[i].Cells["Group_ID"].Value != null && (infoDataGridView1.Rows[i].Cells["AllowAdd"].Value == null || infoDataGridView1.Rows[i].Cells["AllowUpdate"].Value == null || infoDataGridView1.Rows[i].Cells["AllowDelete"].Value == null || infoDataGridView1.Rows[i].Cells["AllowPrint"].Value == null)) { language = CliUtils.fClientLang; string message = SysMsg.GetSystemMessage(language, "Srvtools", "InfoSecurity", "IsNull"); MessageBox.Show(string.Format(message, infoDataGridView1.Rows[i].Cells["ControlName"].Value)); } else { if (infoDataGridView1.Rows[i].Cells["Group_ID"].Value != null && (string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "infobindingsource", true) == 0//IgnoreCase || string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "webdatasource", true) == 0 || string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "servicedatasource", true) == 0 || string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "jqdatagrid", true) == 0))//IgnoreCase { UpdateGroup[0] = infoDataGridView1.Rows[i].Cells["Group_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["Menu_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["ControlName"].Value + ";" + infoDataGridView1.Rows[i].Cells["Type"].Value + ";" + " ; ;" + infoDataGridView1.Rows[i].Cells["AllowAdd"].Value + ";" + infoDataGridView1.Rows[i].Cells["AllowUpdate"].Value + ";" + infoDataGridView1.Rows[i].Cells["AllowDelete"].Value + ";" + infoDataGridView1.Rows[i].Cells["AllowPrint"].Value; } else { UpdateGroup[0] = infoDataGridView1.Rows[i].Cells["Group_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["Menu_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["ControlName"].Value + ";" + infoDataGridView1.Rows[i].Cells["Type"].Value + ";" + infoDataGridView1.Rows[i].Cells["gridEnabled"].Value + ";" + infoDataGridView1.Rows[i].Cells["gridVisible"].Value + "; ; ; ; "; } myRet = CliUtils.CallMethod("GLModule", "UpdateGroup", UpdateGroup); } } else { if (infoDataGridView1.Rows[i].Cells["Group_ID"].Value != null && (infoDataGridView1.Rows[i].Cells["gridEnabled"].Value == null || infoDataGridView1.Rows[i].Cells["gridVisible"].Value == null)) { language = CliUtils.fClientLang; string message = SysMsg.GetSystemMessage(language, "Srvtools", "InfoSecurity", "IsNull"); MessageBox.Show(string.Format(message, infoDataGridView1.Rows[i].Cells["ControlName"].Value)); } else { if (infoDataGridView1.Rows[i].Cells["Group_ID"].Value != null && (string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "infobindingsource", true) == 0//IgnoreCase || string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "webdatasource", true) == 0 || string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "servicedatasource", true) == 0 || string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "jqdatagrid", true) == 0))//IgnoreCase { UpdateGroup[0] = infoDataGridView1.Rows[i].Cells["Group_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["Menu_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["ControlName"].Value + ";" + infoDataGridView1.Rows[i].Cells["Type"].Value + ";" + " ; ;" + infoDataGridView1.Rows[i].Cells["AllowAdd"].Value + ";" + infoDataGridView1.Rows[i].Cells["AllowUpdate"].Value + ";" + infoDataGridView1.Rows[i].Cells["AllowDelete"].Value + ";" + infoDataGridView1.Rows[i].Cells["AllowPrint"].Value; } else { UpdateGroup[0] = infoDataGridView1.Rows[i].Cells["Group_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["Menu_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["ControlName"].Value + ";" + infoDataGridView1.Rows[i].Cells["Type"].Value + ";" + infoDataGridView1.Rows[i].Cells["gridEnabled"].Value + ";" + infoDataGridView1.Rows[i].Cells["gridVisible"].Value + "; ; ; ; "; } myRet = CliUtils.CallMethod("GLModule", "UpdateGroup", UpdateGroup); } } } } if (flag == false) { object[] NewGroup = new object[1]; if (infoDataGridView1.Rows[i].Cells["Group_ID"].Value != null && (infoDataGridView1.Rows[i].Cells["Type"].Value.ToString() == "InfoBindingSource" || infoDataGridView1.Rows[i].Cells["Type"].Value.ToString() == "WebDataSource" || infoDataGridView1.Rows[i].Cells["Type"].Value.ToString() == "JQDataGrid")) { if (infoDataGridView1.Rows[i].Cells["Group_ID"].Value != null && (infoDataGridView1.Rows[i].Cells["AllowAdd"].Value == null || infoDataGridView1.Rows[i].Cells["AllowUpdate"].Value == null || infoDataGridView1.Rows[i].Cells["AllowDelete"].Value == null || infoDataGridView1.Rows[i].Cells["AllowPrint"].Value == null)) { language = CliUtils.fClientLang; string message = SysMsg.GetSystemMessage(language, "Srvtools", "InfoSecurity", "IsNull"); MessageBox.Show(string.Format(message, infoDataGridView1.Rows[i].Cells["ControlName"].Value)); } else { if (infoDataGridView1.Rows[i].Cells["Group_ID"].Value != null && (string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "infobindingsource", true) == 0//IgnoreCase || string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "webdatasource", true) == 0 || string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "servicedatasource", true) == 0 || string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "jqdatagrid", true) == 0))//IgnoreCase { NewGroup[0] = infoDataGridView1.Rows[i].Cells["Group_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["Menu_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["ControlName"].Value + ";" + infoDataGridView1.Rows[i].Cells["Type"].Value + ";" + " ; ;" + infoDataGridView1.Rows[i].Cells["AllowAdd"].Value + ";" + infoDataGridView1.Rows[i].Cells["AllowUpdate"].Value + ";" + infoDataGridView1.Rows[i].Cells["AllowDelete"].Value + ";" + infoDataGridView1.Rows[i].Cells["AllowPrint"].Value; } else { NewGroup[0] = infoDataGridView1.Rows[i].Cells["Group_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["Menu_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["ControlName"].Value + ";" + infoDataGridView1.Rows[i].Cells["Type"].Value + ";" + " ; ;" + infoDataGridView1.Rows[i].Cells["gridEnabled"].Value + ";" + infoDataGridView1.Rows[i].Cells["gridVisible"].Value + "; ; ; ; "; } myRet = CliUtils.CallMethod("GLModule", "InsertToGroup", NewGroup); } } else { if (infoDataGridView1.Rows[i].Cells["Group_ID"].Value != null && (infoDataGridView1.Rows[i].Cells["gridEnabled"].Value == null || infoDataGridView1.Rows[i].Cells["gridVisible"].Value == null)) { language = CliUtils.fClientLang; string message = SysMsg.GetSystemMessage(language, "Srvtools", "InfoSecurity", "IsNull"); MessageBox.Show(string.Format(message, infoDataGridView1.Rows[i].Cells["ControlName"].Value)); } else { if (infoDataGridView1.Rows[i].Cells["Group_ID"].Value != null && (string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "infobindingsource", true) == 0//IgnoreCase || string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "webdatasource", true) == 0 || string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "servicedatasource", true) == 0 || string.Compare(infoDataGridView1.Rows[i].Cells["Type"].Value.ToString(), "jqdatagrid", true) == 0))//IgnoreCase { NewGroup[0] = infoDataGridView1.Rows[i].Cells["Group_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["Menu_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["ControlName"].Value + ";" + infoDataGridView1.Rows[i].Cells["Type"].Value + ";" + " ; ;" + infoDataGridView1.Rows[i].Cells["AllowAdd"].Value + ";" + infoDataGridView1.Rows[i].Cells["AllowUpdate"].Value + ";" + infoDataGridView1.Rows[i].Cells["AllowDelete"].Value + ";" + infoDataGridView1.Rows[i].Cells["AllowPrint"].Value; } else { NewGroup[0] = infoDataGridView1.Rows[i].Cells["Group_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["Menu_ID"].Value + ";" + infoDataGridView1.Rows[i].Cells["ControlName"].Value + ";" + infoDataGridView1.Rows[i].Cells["Type"].Value + ";" + infoDataGridView1.Rows[i].Cells["gridEnabled"].Value + ";" + infoDataGridView1.Rows[i].Cells["gridVisible"].Value + "; ; ; ; "; } myRet = CliUtils.CallMethod("GLModule", "InsertToGroup", NewGroup); } } } } language = CliUtils.fClientLang; string message1 = SysMsg.GetSystemMessage(language, "Srvtools", "InfoSecurity", "IsUpdate"); MessageBox.Show(message1); }
private object[] CreateClientInfo(string user, string password, string database, string solution, SYS_LANGUAGE language) { return new object[] { language, user, database , "", "", "" , solution, "", "" , "", "", "" , "", "", "", "0", password }; }
protected void Page_Load(object sender, EventArgs e) { language = Srvtools.CliSysMegLag.GetClientLanguage(); string message = SysMsg.GetSystemMessage(language, "Srvtools", "EEPNetAutoRun", "LabelName", true); string[] user = message.Split(';'); this.lblUsers.Text = user[0]; this.labelChooseXML.Text = user[4]; string strPath = Request.Path; strPath = Request.MapPath(strPath); strPath = strPath.Substring(0, strPath.LastIndexOf('\\') + 1); if (System.Runtime.Remoting.Channels.ChannelServices.RegisteredChannels.Length == 0) RemotingConfiguration.Configure(strPath + "WebAutoLogin.exe.config", true); }
private void frmDGVGridRefVal_Load(object sender, EventArgs e) { language = CliUtils.fClientLang; String message = SysMsg.GetSystemMessage(language, "Srvtools", "InfoRefVal", "ButtonName"); string[] buttons = message.Split(';'); this.btnOK.Text = buttons[0]; this.btnCancel.Text = buttons[1]; this.btnRefresh.Text = buttons[2]; this.btnQuery.Text = buttons[3]; this.btnAdd.Text = buttons[4]; this.btnApply.Text = buttons[5]; this.btnOK.Text += "(&O)"; this.btnCancel.Text += "(&C)"; this.btnRefresh.Text += "(&U)"; this.btnQuery.Text += "(&Q)"; this.btnAdd.Text += "(&A)"; this.Font = this.RefVal.Font; this.Text = this.RefVal.Caption; this.dgView.DataSource = this.DataSource; if (this.DataSource.DataSource is InfoDataSet) { (this.DataSource.DataSource as InfoDataSet).NextPacket += new InfoDataSet.PacketEventHandler(DataSource_NextPacket); } if (this.RefVal.Columns.Count == 0) { DataSet ds = new DataSet(); if (this.RefVal.DataSource != null && this.RefVal.DataSource is InfoBindingSource) { ds = DBUtils.GetDataDictionary(this.RefVal.DataSource as InfoBindingSource, false); } if (ds != null && ds.Tables.Count > 0) { int x = ds.Tables[0].Rows.Count; for (int y = 0; y < x; y++) { int m = this.dgView.Columns.Count; for (int n = 0; n < m; n++) { if (string.Compare(ds.Tables[0].Rows[y]["FIELD_NAME"].ToString(), this.dgView.Columns[n].DataPropertyName, true) == 0//IgnoreCase && ds.Tables[0].Rows[y]["CAPTION"].ToString() != "") { this.dgView.Columns[n].HeaderText = ds.Tables[0].Rows[y]["CAPTION"].ToString(); } } } } } SetColumnStyles(); AutoGridSize(); if (this.AllowAddData) { this.dgView.AllowUserToAddRows = true; this.dgView.ReadOnly = false; this.btnAdd.Visible = true; this.btnApply.Visible = true; } // locate data int txtLenth = this.InitValue.Length; int rows = this.AllowAddData ? this.dgView.Rows.Count - 1 : this.dgView.Rows.Count; bool HasLocated = false; int ix = 0; while (!this.dgView.Columns[ix].Visible) { ix++; } for (int row = 0; row < rows; row++) { if (string.Compare(this.dgView[RefVal.ValueMember, row].Value.ToString(), this.InitValue, true) == 0)//IgnoreCase { HasLocated = true; //this.dgView[RefVal.ValueMember, row].Selected = true; this.dgView[ix, row].Selected = true; break; } } if (!HasLocated) { //merge a new datarow object[] obj = this.RefVal.CheckValid_And_ReturnDisplayValue(this.InitValue, false, false); if (obj.Length == 3 && obj[2] != null) { DataTable table = (this.RefVal.GetDataSource() as InfoDataSet).RealDataSet.Tables[0]; DataRow dr = table.NewRow(); DataRow drsource = (DataRow)obj[2]; foreach (DataColumn column in table.Columns) { dr[column] = drsource[column.ColumnName]; } if (table.PrimaryKey.Length == 0) { try { table.PrimaryKey = new DataColumn[] { table.Columns[this.RefVal.ValueMember] }; } catch { } } table.Rows.Add(dr); closepacketrecord = true; this.dgView[ix, rows].Selected = true; closepacketrecord = false; } } if (!HasLocated) { for (int row = 0; row < rows; row++) { if (dgView[RefVal.ValueMember, row].Value.ToString().Length >= txtLenth) { if (string.Compare(dgView[RefVal.ValueMember, row].Value.ToString().Substring(0, txtLenth), this.InitValue, true) == 0)//IgnoreCase { //dgView[RefVal.ValueMember, row].Selected = true; this.dgView[ix, row].Selected = true; break; } } } } this.dgView.Select(); }
public void ExecuteTest(int Times, int Interval, string user, string package, string Fixed) { MaxRespendTime = 0; MinRespendTime = 0; AverageRespendTime = 0; //if (this.ClickControl == null || this.ClickControl.ToString() == "(none)" || this.ClickControl.ToString() == "") //{ DateTime start = DateTime.Now; alLog.Add("AutoTest log file."); alLog.Add("UserID: " + user + " PackageName: " + package + " Start Time: " + start + " " + start.Millisecond); int temp = 0; if (user[user.Length - 1] > 47 && user[user.Length - 1] < 58) { switch (user[user.Length - 1]) { case '0': temp = 0; break; case '1': temp = 1; break; case '2': temp = 2; break; case '3': temp = 3; break; case '4': temp = 4; break; case '5': temp = 5; break; case '6': temp = 6; break; case '7': temp = 7; break; case '8': temp = 8; break; case '9': temp = 9; break; } } else temp = m_rnd.Next(0, 9); for (int i = 0; i < Times; i++) { int number = i + 1; if (number % (temp + 1) == 0 || i == temp || number == Times) { try { string strPath = Application.StartupPath + "\\"; XmlDocument DBXML = new XmlDocument(); FileStream aFileStream; if (!File.Exists(strPath + Fixed + "AutoRunMessage.xml")) { try { aFileStream = new FileStream(strPath + Fixed + "AutoRunMessage.xml", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); try { XmlTextWriter w = new XmlTextWriter(aFileStream, new System.Text.ASCIIEncoding()); w.Formatting = Formatting.Indented; w.WriteStartElement("InfolightAutoRunMessage"); w.WriteEndElement(); w.Close(); } finally { aFileStream.Close(); } } catch (Exception e) { string str = e.Message; } } try { aFileStream = new FileStream(strPath + Fixed + "AutoRunMessage.xml", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); try { DBXML.Load(aFileStream); XmlNode aNode = null; for (int j = DBXML.DocumentElement.ChildNodes.Count - 1; j >= 0; j--) { if (string.Compare(DBXML.DocumentElement.ChildNodes[j].Attributes["UserId"].InnerText.Trim(), user, true) == 0//IgnoreCase && string.Compare(DBXML.DocumentElement.ChildNodes[j].Attributes["Module"].InnerText.Trim(), package, true) == 0)//IgnoreCase { aNode = DBXML.DocumentElement.ChildNodes[j]; break; } } if (aNode == null) { XmlElement elem = DBXML.CreateElement("String"); XmlAttribute attr = DBXML.CreateAttribute("UserId"); attr.Value = user; elem.Attributes.Append(attr); attr = DBXML.CreateAttribute("Module"); attr.Value = package; elem.Attributes.Append(attr); attr = DBXML.CreateAttribute("StartTime"); attr.Value = start.ToString(); elem.Attributes.Append(attr); attr = DBXML.CreateAttribute("Number"); attr.Value = number.ToString(); elem.Attributes.Append(attr); attr = DBXML.CreateAttribute("Times"); attr.Value = Times.ToString(); elem.Attributes.Append(attr); attr = DBXML.CreateAttribute("Status"); attr.Value = ((float)(number) / (float)(Times)) * 100 + "%"; elem.Attributes.Append(attr); attr = DBXML.CreateAttribute("CompleteTime"); if (number == Times) attr.Value = DateTime.Now.ToString(); else attr.Value = ""; elem.Attributes.Append(attr); attr = DBXML.CreateAttribute("Flag"); if (number == Times) attr.Value = "1"; else attr.Value = ""; elem.Attributes.Append(attr); DBXML.DocumentElement.AppendChild(elem); } else { aNode.Attributes["Number"].InnerText = number.ToString(); aNode.Attributes["Status"].InnerText = ((float)(number) / (float)(Times)) * 100 + "%"; if (number == Times) { aNode.Attributes["CompleteTime"].InnerText = DateTime.Now.ToString(); aNode.Attributes["Flag"].InnerText = "1"; } } } finally { aFileStream.Close(); } DBXML.Save(strPath + Fixed + "AutoRunMessage.xml"); } catch (Exception e) { string str = e.Message; } } finally { } } DateTime BeforeExecute = DateTime.Now; Execute(user); DateTime AfterExecute = DateTime.Now; TimeSpan betweenExecute = AfterExecute - BeforeExecute; if (betweenExecute.TotalMilliseconds > RecordTime) { alLog.Add("Times: " + (i + 1) + " BetweenExecute: " + betweenExecute.TotalMilliseconds); } DateTime BeforeApply = DateTime.Now; DataTable t = ids.RealDataSet.Tables[0].GetChanges(DataRowState.Added); DataTable cloneTable = null; if (t != null) cloneTable = t.Copy(); try { ids.ApplyUpdates(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } if (cloneTable != null) { foreach (DataRow row in cloneTable.Rows) this.SubmitFlow(row); } DateTime AfterApply = DateTime.Now; TimeSpan betweenApply = AfterApply - BeforeApply; if (betweenApply.TotalMilliseconds > RecordTime) { alLog.Add("Times: " + (i + 1) + " BetweenApply: " + betweenApply.TotalMilliseconds); } MaxRespendTime = Max(BeforeApply, AfterApply, MaxRespendTime); MinRespendTime = Min(BeforeApply, AfterApply, MinRespendTime); System.Threading.Thread.Sleep(Interval); } if (this.Log != null && this.Log != "") { string s = null; if (Log.Length > 4) { for (int h = 0; h < 4; h++) s = s + this.Log[Log.Length - 4 + h]; if (string.Compare(s, ".txt", true) != 0)//IgnoreCase this.Log = this.Log + ".txt"; } else this.Log = this.Log + ".txt"; AverageRespendTime /= Times; DateTime complete = DateTime.Now; alLog.Add("UserID: " + user + " PackageName: " + package + " Complete Time: " + complete + " " + DateTime.Now.Millisecond); alLog.Add("Total " + (Times + 1) + " Records, Use" + (complete - start) + " Seconds."); alLog.Add("MaxRespendTime: " + MaxRespendTime + " MilliSeconds "); alLog.Add("MinRespendTime: " + MinRespendTime + " MilliSeconds "); alLog.Add("AverageRespendTime: " + AverageRespendTime + "MilliSeconds"); alLog.Add(""); try { if (File.Exists(this.Log)) { FileStream fs = File.Open(this.Log, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); StreamReader sreader = new StreamReader(fs); alLog.Add(sreader.ReadToEnd()); sreader.Close(); fs = File.Open(this.Log, FileMode.Open, FileAccess.Write, FileShare.ReadWrite); StreamWriter swriter = new StreamWriter(fs); for (int i = 0; i < alLog.Count; i++) { swriter.WriteLine(alLog[i]); } swriter.Close(); fs.Close(); } else { language = CliUtils.fClientLang; string message = SysMsg.GetSystemMessage(language, "Srvtools", "AutoTest", "LogError"); MessageBox.Show(message); } } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show(ex.GetType().ToString()); } } }