protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { String[] EditHotel = (string[])Session["Hotel_De"]; txtHotelName.Text = EditHotel[0]; txtAddress.Text = EditHotel[1]; txtLocation.Text = EditHotel[2]; txtDescription .Text = EditHotel [3]; String hName = EditHotel[0]; string qry1 = "select * from hotels where hotelname = '" + hName + "' "; DbConnect dc = new DbConnect(); DataTable dt = dc.select(qry1); if (dt == null ) { LblMsg.Text = "load error"; } else { txtHotelName.Text = dt.Rows[0][1].ToString(); txtAddress.Text = dt.Rows[0][2].ToString(); txtLocation.Text = dt.Rows[0][3].ToString(); txtDescription.Text = dt.Rows[0][4].ToString(); } } }
protected void Button7_Click(object sender, EventArgs e) { DbConnect dc = new DbConnect(); String getHID = "select hotelID from Hotels where hotelname = '"+txtHotelName .Text+"'"; DataTable hID = dc.select(getHID ); // get hotel id //txtLocation.Text = hID.Rows[0][0].ToString(); String hotelId = hID.Rows[0][0].ToString(); if (hotelId == null) { LblMsg.Text = "error id"; } else { String query = "update Hotels set hotelname = '" + txtHotelName.Text + "' , address = '" + txtAddress.Text + "' , location = '" + txtLocation.Text + "' , description = '" + txtDescription.Text + "' where hotelID ='"+hotelId+"' "; //String updateHotel = "update hotels set hotel_name = '" + txtHotelName.Text + "' , address = '" + txtAddress.Text + "' , location = '" + txtLocation.Text + "' , description = '" + txtDescription.Text + "' where hotelid = '" + hotelId + "' "; bool conf = dc.insert(query); if (conf == true) { LblMsg.Text = "Successful"; } else { LblMsg.Text = "error"; } //Response.Redirect(Request.RawUrl); } }
protected void save_main_pac_Click(object sender, EventArgs e) { DbConnect db = new DbConnect(); DataTable dt = db.select("Select max(package_id) from mainPackege"); string id = dt.Rows[0][0].ToString(); imageUpload1.SaveAs(Server.MapPath("tour_main/"+imageUpload1.PostedFile.FileName)); string url = "tour_main/" + imageUpload1.PostedFile.FileName; String sql1 = "insert into mainPackege(name,description,image_main) values('" + txtmainpac_name.Text + "','" + txtdescription_main.Text + "','" +url+ "')"; bool conf1 = db.insert(sql1); if (conf1 == true) { lblcon.Text = "Successfully added"; } else { lblcon.Text = "Cannot be added"; } // Response.Redirect("Confirmation.aspx"); }
public void fillgrid() { DbConnect db = new DbConnect(); String qry = "select name,description,image_main from mainPackege"; DataSet ds = db.getData(qry); gdvmain_pac.DataSource = ds.Tables["ss"]; gdvmain_pac.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { DbConnect dc = new DbConnect(); if (!IsPostBack) { fillGrid(); } }
public void fillgrid() { DbConnect db = new DbConnect(); string subPackage = Session["subname"].ToString(); string query = "select d.Day_no,d.accomodation,d.description,days_image from days_ d,subPackege s where s.subPacge_Name='"+subPackage+"' and d.subPcgId=s.subPack_ID "; DataSet ds = db.getData(query); gdvdays.DataSource = ds.Tables["ss"]; gdvdays.DataBind(); }
public void fillgrid() { DbConnect db = new DbConnect(); string mainPackage = Session["name"].ToString(); string query = " select s.subPacge_Name ,s.noofdays,s.price from subPackege s,mainPackege p where s.packge_ID=p.package_id and p.name='" + mainPackage + "' "; DataSet ds = db.getData(query); gdvsubpac.DataSource = ds.Tables["ss"]; gdvsubpac.DataBind(); }
public void FillGrid() { DbConnect db = new DbConnect(); string qry = "select CustomerID,fname,lname,email from Customer"; DataSet ds=db.getData(qry); GridEmail.DataSource = ds.Tables["ss"]; GridEmail.DataBind(); }
public void fillHotel() { DbConnect dc = new DbConnect(); String qry = "select hotelID,hotelname from Hotels"; DataTable dt = dc.select(qry); ddlHotel.DataValueField = "hotelID"; ddlHotel.DataTextField = "hotelname"; ddlHotel.DataSource = dt; ddlHotel.DataBind(); }
public void retriveImage() { DbConnect db = new DbConnect(); string qry = "select floor_image from floor1 where floornum='" + ddFloors.Text + "'"; DataTable dt = db.select(qry); string path = dt.Rows[0][0].ToString(); Floor_img.ImageUrl = path; }
public void fillCustomerID() { DbConnect db = new DbConnect(); string qry = "select CustomerID from Customer"; DataTable dt = db.select(qry); int count = dt.Rows.Count; for (int i = 0; i < count; i++) { ddCustomerID.Items.Add(dt.Rows[i][0].ToString()); } }
public void fillAgentID() { DbConnect db = new DbConnect(); string qry = "select AgentID from Agent"; DataTable dt = db.select(qry); int count = dt.Rows.Count; for (int i = 0; i < count; i++) { ddSearch.Items.Add(dt.Rows[i][0].ToString()); } }
public void fillFloors() { DbConnect dc = new DbConnect(); String q = "select floornum from floor1"; DataTable dt = dc.select(q); int c = dt.Rows.Count; for (int i = 0; i < c; i++) { floor_num.Items.Add(dt.Rows[i][0].ToString()); } }
public void fillGrid() { DbConnect dc = new DbConnect(); String MFillQuery = "select mr.rID,mr.date,mr.time, h.hall_Name,custID,hl.Hotelname,mp.price,mp.tableArrangement from MeetingReservation mr,Halls h,Hotels hl,Meeting mp where mr.hallID=h.HallID and h.hotelID=hl.hotelID and mp.hallID=h.HallID"; DataSet ds = dc.getData(MFillQuery); if (ds == null) { bool b = false; } gv_meetingList.DataSource = ds.Tables["ss"]; gv_meetingList.DataBind(); }
// fill the grid view public void fillGrid() { DbConnect dc = new DbConnect(); String qry = "select empid, fname , lname , address , email , Picture from employee"; DataSet ds = dc.getData(qry); if (ds == null) { bool b = false; } gvReceptionist.DataSource = ds.Tables["ss"].DefaultView; gvReceptionist.DataBind(); }
public void fillmainpac(DropDownList name) { //dbCOnnect db = new dbCOnnect(); DbConnect db = new DbConnect(); String qry = "select name ,package_id from mainpackege"; DataTable dt = db.selectIt(qry); int count = dt.Rows.Count; for (int i = 0; i < count; i++) { name.Items.Add(dt.Rows[i][0].ToString()); } }
public void fillGrid() { DbConnect dc = new DbConnect(); String wedFillQuery = "select wr.RID,wr.date,wr.time,wr.themeColor,h.hall_name,custID,hl.hotelname,wp.price,wp.Decoration from BanquetReservation wr,Halls h,Hotels hl,Banquet wp where wr.hallID=h.hallID and h.hotelID=hl.hotelID and wp.hallID=h.hallID"; DataSet ds = dc.getData(wedFillQuery); if (ds == null) { bool b = false; } gv_weddingList.DataSource = ds.Tables["ss"]; gv_weddingList.DataBind(); }
public void filldays() { //dbCOnnect db = new dbCOnnect(); DbConnect db = new DbConnect(); String qry=" select d.day_no from days_ d , subPackege s , mainPackege p where s.packge_ID=p.package_id and d.subPcgId=s.subPack_ID and s.subPacge_Name='"+ddsub_day.Text+"' and p.name='"+ddmain_day.Text+"' "; DataTable dt = db.selectIt(qry); int c = dt.Rows.Count; for (int i = 0; i < c; i++) { ddday_no.Items.Add(dt.Rows[i][0].ToString()); } }
public void fillGrid() { DbConnect dc = new DbConnect(); // String customerFillQuery = "select c.ID, c.salutation,c.fname,c.lname,c.address,c.nationality,c.country,c.phone,c.email,c.passportNum from Customer c,WeddingReservation wr e where c.ID=wr.custID and wr.custID in (select wr.custID from WeddingReservation wr)"; String customerFillQuery = "select c.CustomerID, c.salutation,c.fname,c.lname,c.state_address,c.city,c.postelCode,c.country,c.phone,c.email,c.passport_NIC from Customer c,BanquetReservation wr where c.CustomerID=wr.custID and wr.custID in (select wr.custID from BanquetReservation wr)"; DataSet ds = dc.getData(customerFillQuery); if (ds == null) { bool b = false; } gv_weddingCustomer.DataSource = ds.Tables["ss"]; gv_weddingCustomer.DataBind(); }
public void fillsubpack(DropDownList subname,DropDownList main) { //dbCOnnect db = new dbCOnnect(); DbConnect db = new DbConnect(); String qry = "select s.subPacge_name,subPack_ID from subPackege s , mainPackege p where s.packge_ID=p.package_id and p.name='"+main.Text+"'"; DataTable dt = db.selectIt(qry); subname.DataValueField = "subPack_ID"; int c = dt.Rows.Count; for (int i = 0; i < c; i++) { subname.Items.Add(dt.Rows[i][0].ToString()); } }
public void fillGrid() { DbConnect dc = new DbConnect(); String customerFillQuery = "select c.CustomerID, c.salutation,c.fname,c.lname,c.state_address,c.city,c.postelCode,c.country,c.phone,c.email,c.passport_NIC from Customer c,MeetingReservation mr where c.CustomerID=mr.custID and mr.custID in (select mr.custID from MeetingReservation mr)"; DataSet ds = dc.getData(customerFillQuery); //what is done by this if condition if (ds == null) { bool b = false; } gv_meetingCustomer.DataSource = ds.Tables["ss"]; gv_meetingCustomer.DataBind(); }
protected void btn_add_Click(object sender, EventArgs e) { DbConnect dc = new DbConnect(); string q2="insert into Login values('"+txt_email.Text+"','"+txt_pswd.Text+"','agent')"; String q = "insert into Agent(Firstname,Lastname,Address,Gender,Fax,TelNumber,Market,PassPortNumber,Country,Email) values('" + txt_name.Text.Trim() + "','" + txt_lastname.Text.Trim() + "','" + txt_add.Text + "','" + txt_gender.Text.Trim() + "','" + txt_fax.Text.Trim() + "','" + txt_telenum.Text.Trim() + "','" + ddl_marcket.Text.Trim() + "','" + txt_ppnum.Text.Trim() + "','" + txt_country.Text.Trim() + "','" + txt_email.Text.Trim() + "')"; bool conf1=dc.insert(q2); bool conf = dc.insert(q); if (conf1 == true && conf==true) { lblmsg.Text = "Successfully added"; } else { lblmsg.Text = "Operation is successfull"; } }
protected void btnAdd_Click(object sender, EventArgs e) { if (txtFName.Text == "" || txtLName.Text == "" || txtAddress.Text == "" || txtEMail.Text == "" || !fuEmp.HasFile) { lblError.Text = "Please enter all values"; lblError.Visible = true; } else if (txtAddress.Text != "" && txtEMail.Text != "" && txtFName.Text != "" && txtLName.Text != "" && fuEmp.HasFile) // validate controls { lblError.Visible = false;// initially no message DbConnect dc = new DbConnect(); try { if (fuEmp.PostedFile.ContentType.ToString() == "image/jpeg") // check the image format { fuEmp.SaveAs(Server.MapPath("EmpImage/" + fuEmp.PostedFile.FileName));// upload image to a folder String url = "EmpImage/" + fuEmp.PostedFile.FileName; String qry1 = "insert into login (username,password,status) values ('" + txtEMail.Text + "' , 'reseption' , 'reseption')"; String qry = "insert into Employee(fname,lname,address,email,Picture) values ('" + txtFName.Text + "' , '" + txtLName.Text + "' , '" + txtAddress.Text + "' , '" + txtEMail.Text + "' , '" + url + "');"; bool conf1 = dc.insertIt(qry1); bool conf = dc.insertIt(qry); if (conf == false || conf1 == false) lblError.Text = "Cannot be added"; else lblError.Text = "Successfully added"; fillGrid();//refresh the grid } else { lblError.Text = "Please insert JPG images only"; } } catch (Exception ex) { lblError.Text = ex.Message; } } lblError.Visible = true;//set visible the message }
protected void Button9_Click(object sender, EventArgs e) { DbConnect con = new DbConnect(); String qry = "insert into Hotels values ('" + txtHotelName.Text + "', '" + txtAddress.Text + "','" + txtLocation.Text + "','" + txtDescription.Text + "')"; bool confirm = con.insert(qry); if (confirm == true && txtHotelName.Text != null) { LblMsg.Text = "Successfully Added"; Session["hotel"] = txtHotelName.Text; //Response.Redirect("AddRoom.aspx"); } else { LblMsg.Text = "cannot be Added"; } }
protected void btnClear0_Click(object sender, EventArgs e) { DbConnect dc = new DbConnect(); String sql = "delete from employee where empid = '" + lblID.Text + "' "; bool conf = dc.insert(sql); fillGrid(); if (conf == true) { lblError.Text = "Successfully deleted"; } else { lblError.Text = "Error occured while deleting"; } lblError.Visible = true; }
protected void Button2_Click(object sender, EventArgs e) { DbConnect con = new DbConnect(); String qry1 = "select hotelid from hotels where hotelname = '" + Session["hotel"].ToString() + "'"; DataTable dt1 = con.select(qry1); String hotelId = dt1.Rows[0][0].ToString(); // lblMessage.Text = hotelId; String qry = "insert into Room(RoomNo, Roomtype , floor_num ,hotelID ) values ( '" + txtRoomNo.Text + "', '" + txtType.Text + "' , '" + txtfloorNo.Text + "' ,'" + hotelId + "' )"; bool confirm = con.insert(qry); if (confirm == true) { lblMessage.Text = "Successfully Added , Add more rooms"; } else { lblMessage.Text = "can not be Added"; } }
protected void Button1_Click(object sender, EventArgs e) { String qry = "select hotelID from hotels where hotelName = '" + Session["hotel"].ToString() + "' "; DbConnect con = new DbConnect(); DataTable dt = con.select(qry); String hotelId = dt.Rows [0][0].ToString (); String qry2 = "insert into halls values ('"+txtHallName.Text+"' , '"+txtHall_Type .Text+"' , '"+txtNoofSeat .Text+"' , '"+hotelId+"')"; bool confirm = con.insert(qry2); if (confirm == true) { lblMessage.Text = "Successfully Added"; } else { lblMessage.Text = "cannot be Added"; } }
public void fillroomdetails() { DbConnect dc = new DbConnect(); string hotel = ddlHotelName.Text; String qry = "select * from Hotels where hotelname = '" + ddlHotelName.Text + "' "; DataTable dt = dc.select(qry); // rooms if (dt != null && dt.Rows.Count != 0) //hotel details { txtAddress.Text = dt.Rows[0][2].ToString(); txtLocation.Text = dt.Rows[0][3].ToString(); txtDescription.Text = dt.Rows[0][4].ToString(); } else { txtDescription.Text = "error occured"; } String hotelId = dt.Rows[0][0].ToString(); String qry3 = "select RoomID,RoomNo,Roomtype,floor_num from room where hotelID = '" + hotelId + "' "; // room details DataSet ds = dc.getData(qry3); if (ds != null) { gvRoom.DataSource = ds.Tables["ss"]; gvRoom.DataBind(); } String qry4 = "select HallID,Hall_Name,Hall_Type,NoOfSeats from Halls where HotelID='" + hotelId + "'"; DataSet ds2 = dc.getData(qry4); // halls if (ds2 != null) { gvHalls.DataSource = ds2.Tables["ss"]; gvHalls.DataBind(); } else { txtAddress.Text = "error"; } }
protected void Button8_Click1(object sender, EventArgs e) { DbConnect da = new DbConnect(); fuFloorImage.SaveAs(Server.MapPath("room_img/" + fuFloorImage.PostedFile.FileName)); string url = "room_img/" + fuFloorImage.PostedFile.FileName; // get hotel id String qry = "select max(hotelID) from hotels"; DataTable dt = da.select(qry); String hotelID = dt.Rows[0][0].ToString(); String qry2 = "insert into floor1 (hotel_ID , floorNum, floor_Image) values('"+hotelID+"' , '"+ddlFloorNum.Text+"' , '"+url+"')"; bool conf = da.insert(qry2); if (conf == true) { lblMessage.Text = "successfully added"; } else { lblMessage.Text = "error occured"; } }
/* fill available venues */ public void fillVenue() { ddlVenue.Items.Clear(); DbConnect dc = new DbConnect(); //String qry = "select h.name from Hall h,Hotels hl,WeddingReservation wr where h.ID=wr.hallID and h.hotelID=hl.hotelID and hl.hotelID='"+ddlHotel.Text+"' and h.type='"+ddlLocation.Text+"' and h.ID in(select wr.hallID from WeddingReservation wr,Hall h where h.ID=wr.hallID and wr.Date='"+deDay.Date+"' and wr.Time != '"+ddlTime.Text+"' or wr.Date !='"+deDay.Date+"')"; String qry = "select h.hall_Name from Halls h,Hotels hl where h.HotelID=hl.hotelID and hl.hallID='" + ddlHotel.Text + "' and h.hall_type='" + ddlLocation.Text + "' and h.hallID in(select wr.hallID from BanquetReservation wr,Halls h where h.hallID=wr.hallID and wr.date='" + deDay.Date + "' and wr.time != '" + ddlTime.Text + "' or wr.date !='" + deDay.Date + "')"; DataTable dt = dc.select(qry); ddlVenue.DataValueField = "hall_name";//chk for error. int count = dt.Rows.Count; if (count != 0) { for (int i = 0; i < count; i++) { ddlVenue.Items.Add(dt.Rows[i][0].ToString()); } } else { lblAvailabilty.Visible = true; } }
/// <summary>连接 /// 连接 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { if (!CheckInput()) { return; } #if !DEBUG if (txtDB.Text.Trim() == string.Empty) { m_ServerDB = DataBaseManager.GetDataBase(dbType, BuildConn(this.dbType)); if (m_ServerDB.Rows.Count > 5) { dialog = MessageBox.Show(@"一共需要加载【" + m_ServerDB.Rows.Count + "】个数据库,需要时间较长,建议按需加载", "提示", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { btnSelectDB_Click(null, null); return; } } } #endif #if DEBUG LoadDatabase = new DataTable(); LoadDatabase.Columns.Add("name", typeof(string)); DataRow dr = LoadDatabase.NewRow(); dr["name"] = GlobalHelp.DefauleDatabase; LoadDatabase.Rows.Add(dr); #endif bool flag = TestConn(this.dbType); if (flag) { if (chkRem.Checked) { DataSet ds = m_dalConn.GetList("IP='" + cboServer.Text.Trim() + "'"); if (ds.Tables[0].Rows.Count > 0) { m_dalConn.DeleteByCond("IP='" + cboServer.Text.Trim() + "'"); } DbConnect model = new DbConnect { IP = cboServer.Text.Trim(), Pwd = DESEncryptHelper.Encrypt(txtPassword.Text.Trim(), "test332211"), User = cboUser.Text.Trim(), Remark = this.dbType.ToString(), CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; m_dalConn.Add(model); } DBConn = BuildConn(this.dbType); Server = cboServer.Text.Trim(); UID = cboUser.Text.Trim(); PWD = txtPassword.Text.Trim(); if (this.dbType == SqlType.MySql) { Port = cboLogin.Text.Trim(); } List <string> lstLoadType = new List <string>(); foreach (CCBoxItem item in chkAllowType.CheckedItems) { lstLoadType.Add(item.Name); } LoadType = lstLoadType; this.DialogResult = DialogResult.OK; } else { MessageBox.Show(@"连接失败"); } }
public MainForm() { InitializeComponent(); db = new DbConnect(); }
/// Checks if user with given password exists in the database /// <returns>True if user exist and password is correct</returns> public bool IsValid(string _username, string _password) { DbConnect dbc = new DbConnect(); return(dbc.LoginIsValid(_username, _password)); }
public ResponseAuth AuthenticateUserNamePasword(DbConnect con, int client_id, string username, string password) { ResponseAuth resp = new ResponseAuth(); string template = @" SELECT id, client_id, username, password, name_en, name_np,email, status FROM rbac_user u /**where**/ AND u.status=true AND u.is_deleted=false"; //creating command & preparing command string alias = DbServiceUtility.GetTableAliasForTable("u"); BangoCommand cmd = new BangoCommand(MyroCommandTypes.SqlBuilder); cmd.Template = cmd.SqlBuilder.AddTemplate(template); UserModel mdl = new UserModel(); DbServiceUtility.BindDeleteParameter(cmd, mdl, alias); DynamicDictionary data_param = new DynamicDictionary(); data_param.Add("client_id", client_id); data_param.Add("username", username); DbServiceUtility.BindParameters(cmd, mdl, data_param, alias, SearchTypes.Equal); //executing the command string finalSql = cmd.FinalSql; if (finalSql.Length > 0) { IEnumerable <SqlMapper.DapperRow> items = null; try { items = con.DB.Query <SqlMapper.DapperRow>(finalSql, cmd.FinalParameters, true); } catch (Npgsql.NpgsqlException ex) { LogTrace.WriteErrorLog(ex.ToString()); LogTrace.WriteDebugLog(string.Format("Select SQL which gave exception:\r{0}", ex.Routine)); } Errors = con.DB.GetErros(); if (items != null && items.Count() > 0) { DynamicDictionary data = Conversion.ToDynamicDictionary(items.FirstOrDefault()); if (data.GetValueAsString("password") == EncryptPassword(password)) { resp.success = true; resp.user_id = data.GetValueAsInt("id"); resp.email = data.GetValueAsString("email"); resp.message = "Login successfull"; } else { resp.message = "Username and/or Password is invalid."; } } else { if (Errors.Count > 0) { resp.message = "Technical Problem occurred."; } else { resp.message = "Please provide a valid Username."; } } } return(resp); }
//intialise public Login() { connection = new DbConnect(); }
public DbInterpreter(DbConnect dbConnect, QueryGenerator queryGenerator) { _dbConnect = dbConnect; _queryGenerator = queryGenerator; }
public M_VC_addBill(DataRow row, bool isEditable, M_V_history v1_history, string form) { InitializeComponent(); //common initializations this.Name = "Add Bill"; this.tablename = form; this.edit_form = true; this.v1_history = v1_history; this.c = new DbConnect(); this.do_no = new List <string>(); this.do_no.Add(""); //Create frop down type list List <string> dataSource = new List <string>(); dataSource.Add("---Select---"); dataSource.Add("0"); dataSource.Add("1"); this.typeCB.DataSource = dataSource; this.typeCB.DisplayMember = "Type"; this.typeCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.typeCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.typeCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down lists var dataSource1 = new List <string>(); DataTable d = c.getQC('f'); for (int i = 0; i < d.Rows.Count; i++) { dataSource1.Add(d.Rows[i][0].ToString()); } this.financialYearCB.DataSource = dataSource1; this.financialYearCB.DisplayMember = "Financial Year"; this.financialYearCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.financialYearCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.financialYearCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Quality lists DataTable d1 = c.getQC('q'); List <string> input_qualities = new List <string>(); input_qualities.Add("---Select---"); for (int i = 0; i < d1.Rows.Count; i++) { if (this.tablename == "Carton") { input_qualities.Add(d1.Rows[i]["Quality_Before_Twist"].ToString()); } else if (this.tablename == "Carton_Produced") { input_qualities.Add(d1.Rows[i]["Quality"].ToString()); } } List <string> norep_quality_list = input_qualities.Distinct().ToList(); this.qualityCB.DataSource = norep_quality_list; this.qualityCB.DisplayMember = "Quality"; this.qualityCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.qualityCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.qualityCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Customers list var dataSource4 = new List <string>(); DataTable d4 = c.getQC('C'); dataSource4.Add("---Select---"); for (int i = 0; i < d4.Rows.Count; i++) { dataSource4.Add(d4.Rows[i][0].ToString()); } this.billCustomerNameCB.DataSource = dataSource4; this.billCustomerNameCB.DisplayMember = "Customers"; this.billCustomerNameCB.DropDownStyle = ComboBoxStyle.DropDown;//Create a drop-down list this.billCustomerNameCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.billCustomerNameCB.AutoCompleteMode = AutoCompleteMode.Append; //DatagridView make dataGridView1.Columns.Add("Sl_No", "Sl_No"); dataGridView1.Columns[0].ReadOnly = true; DataGridViewComboBoxColumn dgvCmb = new DataGridViewComboBoxColumn(); //List<string> final_list = this.do_no.Distinct().ToList(); dgvCmb.HeaderText = "DO Number"; dataGridView1.Columns.Insert(1, dgvCmb); dataGridView1.Columns.Add("DO Weight", "DO Weight"); dataGridView1.Columns.Add("DO Amount", "DO Amount"); dataGridView1.Columns[2].ReadOnly = true; dataGridView1.Columns[3].ReadOnly = true; //if only in view mode if (isEditable == false) { this.Text += "(View Only)"; this.deleteButton.Visible = true; this.deleteButton.Enabled = true; this.disable_form_edit(); } else { this.Text += "(Edit)"; this.typeCB.Enabled = false; this.financialYearCB.Enabled = false; this.qualityCB.Enabled = false; this.loadDOButton.Enabled = false; this.saveButton.Enabled = true; } //Fill in required values this.inputDate.Value = Convert.ToDateTime(row["Date_Of_Input"].ToString()); this.billDateDTP.Value = Convert.ToDateTime(row["Sale_Bill_Date"].ToString()); this.qualityCB.SelectedIndex = this.qualityCB.FindStringExact(row["Quality"].ToString()); this.billNumberTextboxTB.Text = row["Sale_Bill_No"].ToString(); this.voucher_id = int.Parse(row["Voucher_ID"].ToString()); this.financialYearCB.SelectedIndex = this.financialYearCB.FindStringExact(row["DO_Fiscal_Year"].ToString()); this.typeCB.SelectedIndex = this.typeCB.FindStringExact(row["Type_Of_Sale"].ToString()); this.billWeightTB.Text = row["Sale_Bill_Weight"].ToString(); this.billAmountTB.Text = row["Sale_Bill_Amount"].ToString(); this.netDOWeightTB.Text = row["Sale_Bill_Weight_Calc"].ToString(); this.netDOAmountTB.Text = row["Sale_Bill_Amount_Calc"].ToString(); if (typeCB.Text == "0") { this.label13.Visible = true; this.billCustomerNameCB.Visible = true; this.billCustomerNameCB.TabIndex = 8; this.billCustomerNameCB.TabStop = true; this.billCustomerNameCB.SelectedIndex = this.billCustomerNameCB.FindStringExact(row["Bill_Customer"].ToString()); } //Load data in datagridview dropdown this.loadData(row["Quality"].ToString(), row["DO_Fiscal_Year"].ToString(), row["Type_Of_Sale"].ToString()); //Load previous data string[] do_nos = c.csvToArray(row["DO_No_Arr"].ToString()); for (int i = 0; i < do_nos.Length; i++) { this.do_no.Add(do_nos[i]); } dataGridView1.RowCount = do_nos.Length + 1; //Fill data in datagridview for (int i = 0; i < do_nos.Length; i++) { dataGridView1.Rows[i].Cells[1].Value = do_nos[i]; } dgvCmb.DataSource = this.do_no; //if (typeCB.Text == "1") //{ // this.billDateDTP.MinDate = this.inputDate.Value.Date.AddDays(-2); // this.billDateDTP.MaxDate = this.inputDate.Value.Date.AddDays(2); //} c.set_dgv_column_sort_state(this.dataGridView1, DataGridViewColumnSortMode.NotSortable); }
public M_V2_dyeingIssueForm() { InitializeComponent(); this.c = new DbConnect(); this.tray_no = new List <string>(); this.tray_no.Add(""); this.saveButton.Enabled = false; //Create drop-down Quality lists var dataSource1 = new List <string>(); DataTable d1 = c.getQC('q'); dataSource1.Add("---Select---"); for (int i = 0; i < d1.Rows.Count; i++) { dataSource1.Add(d1.Rows[i][0].ToString()); } this.comboBox1CB.DataSource = dataSource1; this.comboBox1CB.DisplayMember = "Quality"; this.comboBox1CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox1CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox1CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Company lists var dataSource2 = new List <string>(); DataTable d2 = c.getQC('c'); dataSource2.Add("---Select---"); for (int i = 0; i < d2.Rows.Count; i++) { dataSource2.Add(d2.Rows[i][0].ToString()); } this.comboBox2CB.DataSource = dataSource2; this.comboBox2CB.DisplayMember = "Company_Names"; this.comboBox2CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox2CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox2CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Dyeing Company lists var dataSource3 = new List <string>(); DataTable d3 = c.getQC('d'); dataSource3.Add("---Select---"); for (int i = 0; i < d3.Rows.Count; i++) { dataSource3.Add(d3.Rows[i][0].ToString()); } this.comboBox3CB.DataSource = dataSource3; this.comboBox3CB.DisplayMember = "Dyeing_Company_Names"; this.comboBox3CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox3CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox3CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Colour lists var dataSource4 = new List <string>(); DataTable d4 = c.getQC('l'); dataSource4.Add("---Select---"); for (int i = 0; i < d4.Rows.Count; i++) { dataSource4.Add(d4.Rows[i][0].ToString()); } List <string> final_list = dataSource4.Distinct().ToList(); this.comboBox4CB.DataSource = final_list; this.comboBox4CB.DisplayMember = "Colours"; this.comboBox4CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox4CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox4CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //DatagridView dataGridView1.Columns.Add("Sl_No", "Sl_No"); dataGridView1.Columns[0].ReadOnly = true; DataGridViewComboBoxColumn dgvCmb = new DataGridViewComboBoxColumn(); dgvCmb.DataSource = this.tray_no; dgvCmb.HeaderText = "Tray Number"; dataGridView1.Columns.Insert(1, dgvCmb); dataGridView1.Columns[1].Width = 250; dataGridView1.Columns.Add("Weight", "Weight"); dataGridView1.Columns[2].ReadOnly = true; dataGridView1.Columns.Add("Machine_Number", "Machine Number"); dataGridView1.Columns[3].ReadOnly = true; dataGridView1.Columns.Add("Grade", "Grade"); dataGridView1.Columns[4].ReadOnly = true; dataGridView1.RowCount = 10; c.set_dgv_column_sort_state(this.dataGridView1, DataGridViewColumnSortMode.NotSortable); }
/// <summary> /// Constructs the queue definitions based on user provided configuration. /// </summary> /// <param name="properties">The driver.</param> /// <param name="additionalDescription">The additional description.</param> /// <param name="ipStartValue">The start value of the last IP octet.</param> /// <param name="ipEndValue">The end value of the last IP octet.</param> /// <param name="hostName">The hostname.</param> /// <param name="numberOfQueues">The number of queues.</param> /// <param name="addressCode">The address code.</param> /// <param name="incrementIP">if set to <c>true</c> increment IP octet values.</param> /// <param name="enableSnmp">if set to <c>true</c> SNMP will be enable on the port.</param> /// <param name="renderOnClient">if set to <c>true</c> the render on client option will be set on the queue.</param> /// <param name="shareQueues">if set to <c>true</c> the queue will be shared.</param> /// <returns>Collection of QueueInstallationData</returns> public Collection <QueueInstallationData> Create ( PrintDeviceDriver properties, string additionalDescription, int ipStartValue, int ipEndValue, string hostName, int numberOfQueues, string addressCode, bool incrementIP, bool enableSnmp, bool renderOnClient, bool shareQueues ) { if (properties == null) { throw new ArgumentNullException("properties"); } if (numberOfQueues < 1) { throw new ArgumentException("numberOfQueues must be a positive, non-zero integer."); } if (ipStartValue < 1) { throw new ArgumentException("ipStartValue must be a positive, non-zero integer."); } Collection <QueueInstallationData> queueData = new Collection <QueueInstallationData>(); int currentIPNumber = ipStartValue; FrameworkServer vPrintServer = null; using (AssetInventoryContext context = DbConnect.AssetInventoryContext()) { vPrintServer = context.FrameworkServers.FirstOrDefault(n => n.HostName.StartsWith(hostName)); } AddressParser serverIP = ParseAddress(vPrintServer); StringBuilder queueName = new StringBuilder(); for (int i = 0; i < numberOfQueues; i++) { queueName.Clear(); QueueInstallationData data = new QueueInstallationData(); data.Driver = properties; data.QueueType = "VirtualPrinter"; data.AssetId = "{0}-{1:D5}".FormatWith(addressCode, currentIPNumber); data.Address = serverIP.Prefix + currentIPNumber.ToString(); data.SnmpEnabled = enableSnmp; data.ClientRender = renderOnClient; data.Shared = shareQueues; queueName.Append(addressCode); queueName.Append("-").Append(serverIP.GetOctet(2)); queueName.Append("-").Append(currentIPNumber.ToString("D3")); queueName.Append(" ").Append(properties.DriverType); queueName.Append(" ").Append(Regex.Replace(properties.VerifyPdl, @"\s+", " ")); if (!string.IsNullOrEmpty(properties.Release)) { queueName.Append(" ").Append(Regex.Replace(properties.Release, @"\s+", " ")); } // Append the additional description data if it exists if (!string.IsNullOrEmpty(additionalDescription)) { queueName.Append(" ").Append(Regex.Replace(additionalDescription, @"\s+", " ")); } // Append a queue index if we're reusing the Virtual Printer for multiple queues if (incrementIP == false || numberOfQueues > 255) { data.Key = queueName.ToString(); IncrementQueueIndex(data); queueName.Append(" ").Append(_queueIndex[data.Key].ToString("D3")); } data.QueueName = queueName.ToString(); queueData.Add(data); if (currentIPNumber == ipEndValue) { //Restart the IP number, don't increment currentIPNumber = ipStartValue; } else if (incrementIP) { currentIPNumber++; } } return(queueData); }
public async Task StartAsync(IDialogContext context) { Debug.WriteLine("luis_intent : " + luis_intent); Debug.WriteLine("entitiesStr : " + entitiesStr); // Db DbConnect db = new DbConnect(); Debug.WriteLine("activity : " + context.Activity.Conversation.Id); newUserID = context.Activity.Conversation.Id; if (beforeUserID != newUserID) { beforeUserID = newUserID; MessagesController.sorryMessageCnt = 0; } var message = MessagesController.queryStr; beforeMessgaeText = message.ToString(); if (message.ToString().Contains("코나") == true) { messgaeText = message.ToString(); if (messgaeText.Contains("현대자동차") != true || messgaeText.Contains("현대 자동차") != true) { messgaeText = "현대자동차 " + messgaeText; } } else { messgaeText = "코나 " + message.ToString(); if (messgaeText.Contains("현대자동차") != true || messgaeText.Contains("현대 자동차") != true) { messgaeText = "현대자동차 " + messgaeText; } } if (messgaeText.Contains("코나") == true && (messgaeText.Contains("현대자동차") == true || messgaeText.Contains("현대 자동차") == true)) { var reply = context.MakeMessage(); Debug.WriteLine("SERARCH MESSAGE : " + messgaeText); if ((messgaeText != null) && messgaeText.Trim().Length > 0) { //Naver Search API string url = "https://openapi.naver.com/v1/search/news.json?query=" + messgaeText + "&display=10&start=1&sort=sim"; //news JSON result //string blogUrl = "https://openapi.naver.com/v1/search/blog.json?query=" + messgaeText + "&display=10&start=1&sort=sim"; //search JSON result //string cafeUrl = "https://openapi.naver.com/v1/search/cafearticle.json?query=" + messgaeText + "&display=10&start=1&sort=sim"; //cafe JSON result //string url = "https://openapi.naver.com/v1/search/blog.xml?query=" + query; //blog XML result HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Headers.Add("X-Naver-Client-Id", "Y536Z1ZMNv93Oej6TrkF"); request.Headers.Add("X-Naver-Client-Secret", "cPHOFK6JYY"); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); string status = response.StatusCode.ToString(); if (status == "OK") { Stream stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream, Encoding.UTF8); string text = reader.ReadToEnd(); RootObject serarchList = JsonConvert.DeserializeObject <RootObject>(text); Debug.WriteLine("serarchList : " + serarchList); //description if (serarchList.display == 1) { Debug.WriteLine("SERARCH : " + Regex.Replace(serarchList.items[0].title, @"[^<:-:>-<b>-</b>]", "", RegexOptions.Singleline)); if (serarchList.items[0].title.Contains("코나")) { //Only One item List <CardImage> cardImages = new List <CardImage>(); CardImage img = new CardImage(); img.Url = ""; cardImages.Add(img); string searchTitle = ""; string searchText = ""; searchTitle = serarchList.items[0].title; searchText = serarchList.items[0].description; if (context.Activity.ChannelId == "facebook") { searchTitle = Regex.Replace(searchTitle, @"[<][a-z|A-Z|/](.|)*?[>]", "", RegexOptions.Singleline).Replace("\n", "").Replace("<:", "").Replace(":>", ""); searchText = Regex.Replace(searchText, @"[<][a-z|A-Z|/](.|)*?[>]", "", RegexOptions.Singleline).Replace("\n", "").Replace("<:", "").Replace(":>", ""); } LinkHeroCard card = new LinkHeroCard() { Title = searchTitle, Subtitle = null, Text = searchText, Images = cardImages, Buttons = null, Link = Regex.Replace(serarchList.items[0].link, "amp;", "") }; var attachment = card.ToAttachment(); reply.Attachments = new List <Attachment>(); reply.Attachments.Add(attachment); } } else { reply.AttachmentLayout = AttachmentLayoutTypes.Carousel; reply.Attachments = new List <Attachment>(); for (int i = 0; i < serarchList.display; i++) { string searchTitle = ""; string searchText = ""; searchTitle = serarchList.items[i].title; searchText = serarchList.items[i].description; if (context.Activity.ChannelId == "facebook") { searchTitle = Regex.Replace(searchTitle, @"[<][a-z|A-Z|/](.|)*?[>]", "", RegexOptions.Singleline).Replace("\n", "").Replace("<:", "").Replace(":>", ""); searchText = Regex.Replace(searchText, @"[<][a-z|A-Z|/](.|)*?[>]", "", RegexOptions.Singleline).Replace("\n", "").Replace("<:", "").Replace(":>", ""); } if (serarchList.items[i].title.Contains("코나")) { List <CardImage> cardImages = new List <CardImage>(); CardImage img = new CardImage(); img.Url = ""; cardImages.Add(img); List <CardAction> cardButtons = new List <CardAction>(); CardAction[] plButton = new CardAction[1]; plButton[0] = new CardAction() { Value = Regex.Replace(serarchList.items[i].link, "amp;", ""), Type = "openUrl", Title = "기사 바로가기" }; cardButtons = new List <CardAction>(plButton); if (context.Activity.ChannelId == "facebook") { LinkHeroCard card = new LinkHeroCard() { Title = searchTitle, Subtitle = null, Text = searchText, Images = cardImages, Buttons = cardButtons, Link = null }; var attachment = card.ToAttachment(); reply.Attachments.Add(attachment); } else { LinkHeroCard card = new LinkHeroCard() { Title = searchTitle, Subtitle = null, Text = searchText, Images = cardImages, Buttons = null, Link = Regex.Replace(serarchList.items[i].link, "amp;", "") }; var attachment = card.ToAttachment(); reply.Attachments.Add(attachment); } } } } await context.PostAsync(reply); if (reply.Attachments.Count == 0) { await this.SendSorryMessageAsync(context); } else { orgKRMent = Regex.Replace(message.ToString(), @"[^a-zA-Z0-9ㄱ-힣]", "", RegexOptions.Singleline); for (int n = 0; n < Regex.Split(message.ToString(), " ").Length; n++) { string chgMsg = db.SelectChgMsg(Regex.Split(message.ToString(), " ")[n]); if (!string.IsNullOrEmpty(chgMsg)) { message = message.ToString().Replace(Regex.Split(message.ToString(), " ")[n], chgMsg); } } Translator translateInfo = await getTranslate(message.ToString()); orgENGMent = Regex.Replace(translateInfo.data.translations[0].translatedText, @"[^a-zA-Z0-9ㄱ-힣-\s-']", "", RegexOptions.Singleline); orgENGMent = orgENGMent.Replace("'", "'"); //int dbResult = db.insertUserQuery(orgKRMent, orgENGMent, "", "", "", 1, 'S', "", "", "", "SEARCH", MessagesController.userData.GetProperty<int>("appID")); int dbResult = db.insertUserQuery(orgKRMent, "", "", "", "", 'S', MessagesController.chatBotID); Debug.WriteLine("INSERT QUERY RESULT : " + dbResult.ToString()); DateTime endTime = DateTime.Now; Debug.WriteLine("USER NUMBER : " + context.Activity.Conversation.Id); Debug.WriteLine("CUSTOMMER COMMENT KOREAN : " + messgaeText.Replace("코나 ", "")); Debug.WriteLine("CUSTOMMER COMMENT ENGLISH : " + translateInfo.data.translations[0].translatedText.Replace("'", "'")); Debug.WriteLine("CHANNEL_ID : " + context.Activity.ChannelId); Debug.WriteLine("프로그램 수행시간 : {0}/ms", ((endTime - startTime).Milliseconds)); //int inserResult = db.insertHistory(context.Activity.Conversation.Id, messgaeText.Replace("코나 ", ""), translateInfo.data.translations[0].translatedText.Replace("'", "'"), "SEARCH", context.Activity.ChannelId, ((endTime - startTime).Milliseconds), MessagesController.userData.GetProperty<int>("appID")); int inserResult = db.insertHistory(context.Activity.Conversation.Id, messgaeText, "SEARCH", context.Activity.ChannelId, ((endTime - startTime).Milliseconds), MessagesController.chatBotID); if (inserResult > 0) { Debug.WriteLine("HISTORY RESULT SUCCESS"); } else { Debug.WriteLine("HISTORY RESULT FAIL"); } HistoryLog("[ SEARCH ] ==>> userID :: [ " + context.Activity.Conversation.Id + " ] message :: [ " + messgaeText.Replace("코나 ", "") + " ] date :: [ " + DateTime.Now + " ]"); } } else { System.Diagnostics.Debug.WriteLine("Error 발생=" + status); await this.SendSorryMessageAsync(context); } context.Done(messgaeText); } } else { await this.SendSorryMessageAsync(context); } context.Done <IMessageActivity>(null); }
public M_V4_printDO() { InitializeComponent(); this.c = new DbConnect(); //Load Data //Create drop-down lists var dataSource = new List <string>(); var dataSource1 = new List <string>(); DataTable d = c.getQC('f'); for (int i = 0; i < d.Rows.Count; i++) { dataSource.Add(d.Rows[i][0].ToString()); dataSource1.Add(d.Rows[i][0].ToString()); } this.fiscalCB.DataSource = dataSource; this.fiscalCB.DisplayMember = "Financial Year"; this.fiscalCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.fiscalCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.fiscalCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; this.fiscalCB.SelectedIndex = this.fiscalCB.FindStringExact(c.getFinancialYear(DateTime.Now)); this.fiscal1CB.DataSource = dataSource1; this.fiscal1CB.DisplayMember = "Financial Year"; this.fiscal1CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.fiscal1CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.fiscal1CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; this.fiscal1CB.SelectedIndex = this.fiscal1CB.FindStringExact(c.getFinancialYear(DateTime.Now)); var dataSource2 = new List <string>(); dataSource2.Add("0"); dataSource2.Add("1"); this.type1CB.DataSource = dataSource2; this.type1CB.DisplayMember = "Type"; this.type1CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.type1CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.type1CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; this.type1CB.SelectedIndex = this.type1CB.FindStringExact("1"); //Datagridviews dataGridView1.DefaultCellStyle.SelectionBackColor = Color.White; dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Blue; dataGridView2.DefaultCellStyle.SelectionBackColor = Color.White; dataGridView2.DefaultCellStyle.SelectionForeColor = Color.Blue; DataTable DO_Nos = c.runQuery("SELECT * FROM Sales_Voucher WHERE Type_Of_Sale = 1 AND Fiscal_Year = '" + c.getFinancialYear(DateTime.Now) + "'"); dataGridView1.DataSource = DO_Nos; this.set_columns(dataGridView1); for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells["Printed"].Value.ToString() == "1") { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Global.printedColor; dataGridView1.Rows[i].DefaultCellStyle.SelectionBackColor = Global.printedColor; } else { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.White; dataGridView1.Rows[i].DefaultCellStyle.SelectionBackColor = Color.White; } } this.dataGridView1.Visible = false; this.dataGridView1.Visible = true; }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> /// //ThreadTest test = new ThreadTest(); //delegate void del_thread(string str); //public static void new_thread(string name) //{ // Thread cur_thread = Thread.CurrentThread; // Debug.WriteLine("Current {0} Thread = {1}", name, cur_thread.ManagedThreadId); //} public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { //Thread workerThread = Thread.CurrentThread; //Worker workerObject = new Worker(); //Thread workerThread = new Thread(workerObject.DoWork); // welcome message 출력 if (activity.Type == ActivityTypes.ConversationUpdate && activity.MembersAdded.Any(m => m.Id == activity.Recipient.Id)) { WeatherInfo weatherInfo = await GetWeatherInfo(); //weatherInfo.list[0].weather[0].description Debug.WriteLine("weatherInfo : " + weatherInfo.list[0].weather[0].description); Debug.WriteLine("weatherInfo : " + string.Format("{0}°С", Math.Round(weatherInfo.list[0].temp.min, 1))); Debug.WriteLine("weatherInfo : " + string.Format("{0}°С", Math.Round(weatherInfo.list[0].temp.max, 1))); DateTime startTime = DateTime.Now; //ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); //Activity reply = activity.CreateReply(""); //reply.Recipient = activity.From; //reply.Type = "message"; //reply.Attachments = new List<Attachment>(); //reply.AttachmentLayout = AttachmentLayoutTypes.Carousel; // Db DbConnect db = new DbConnect(); List <Dialog> dlg = db.SelectDialog(3); Debug.WriteLine("!!!!!!!!!!! : " + dlg[0].dlgId); ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); Activity reply2 = activity.CreateReply(); reply2.Recipient = activity.From; reply2.Type = "message"; reply2.Attachments = new List <Attachment>(); reply2.AttachmentLayout = AttachmentLayoutTypes.Carousel; //reply.Recipient = activity.From; //reply.Type = "message"; //reply.Attachments = new List<Attachment>(); //reply.AttachmentLayout = AttachmentLayoutTypes.Carousel; List <Card> card = db.SelectDialogCard(dlg[0].dlgId); VideoCard[] plVideoCard = new VideoCard[card.Count]; HeroCard[] plHeroCard = new HeroCard[card.Count]; ReceiptCard[] plReceiptCard = new ReceiptCard[card.Count]; Attachment[] plAttachment = new Attachment[card.Count]; for (int i = 0; i < card.Count; i++) { List <Button> btn = db.SelectBtn(card[i].dlgId, card[i].cardId); List <Image> img = db.SelectImage(card[i].dlgId, card[i].cardId); List <Media> media = db.SelectMedia(card[i].dlgId, card[i].cardId); List <CardAction> cardButtons = new List <CardAction>(); CardAction[] plButton = new CardAction[btn.Count]; ThumbnailUrl plThumnail = new ThumbnailUrl(); List <MediaUrl> mediaURL = new List <MediaUrl>(); MediaUrl[] plMediaUrl = new MediaUrl[media.Count]; for (int n = 0; n < img.Count; n++) { if (img[n].imgUrl != null) { plThumnail.Url = img[n].imgUrl; } } for (int l = 0; l < media.Count; l++) { if (media[l].mediaUrl != null) { plMediaUrl[l] = new MediaUrl() { Url = media[l].mediaUrl }; } } mediaURL = new List <MediaUrl>(plMediaUrl); for (int m = 0; m < btn.Count; m++) { if (btn[m].btnTitle != null) { plButton[m] = new CardAction() { Value = btn[m].btnContext, Type = btn[m].btnType, Title = btn[m].btnTitle }; } } cardButtons = new List <CardAction>(plButton); if (card[i].cardType == "videocard") { plVideoCard[i] = new VideoCard() { Title = "**" + card[i].cardTitle + "**", Text = card[i].cardText, Subtitle = card[i].cardSubTitle, Media = mediaURL, Image = plThumnail, Buttons = cardButtons, Autostart = true }; plAttachment[i] = plVideoCard[i].ToAttachment(); reply2.Attachments.Add(plAttachment[i]); } } var reply1 = await connector.Conversations.SendToConversationAsync(reply2); Debug.WriteLine("activity : " + activity.Id); Debug.WriteLine("activity : " + activity.ChannelId); Debug.WriteLine("activity : " + activity.Conversation.Id); Debug.WriteLine("activity : " + activity.Properties); Debug.WriteLine("activity : " + activity.Recipient); Debug.WriteLine("activity : " + activity.From.Id); Debug.WriteLine("activity : " + activity.Recipient.Id); Debug.WriteLine("end activity.Timestamp : " + activity.Timestamp); DateTime endTime = DateTime.Now; Debug.WriteLine("프로그램 수행시간 : {0}/ms", ((endTime - startTime).Milliseconds)); //GetWeatherInfo(); Activity reply = activity.CreateReply(); for (int n = 0; n < dlg[0].dlgMent.Split(new string[] { "@@" }, StringSplitOptions.None).Length; n++)//new string[] {"@@"},StringSplitOptions.None { reply = activity.CreateReply(dlg[0].dlgMent.Split(new string[] { "@@" }, StringSplitOptions.None)[n]); await connector.Conversations.SendToConversationAsync(reply); } Activity testReply = activity.CreateReply("**가나다라마바사** `jumped`"); await connector.Conversations.SendToConversationAsync(testReply); Activity replyToConversation = activity.CreateReply("Should go to conversation, in carousel format"); replyToConversation.AttachmentLayout = AttachmentLayoutTypes.Carousel; //replyToConversation.AttachmentLayout = "test"; replyToConversation.Attachments = new List <Attachment>(); Dictionary <string, string> cardContentList = new Dictionary <string, string>(); cardContentList.Add("PigLatin", "http://webbot02.azurewebsites.net/hyundai/images/price/Grandeur_24spec.PNG"); cardContentList.Add("Pork Shoulder", "http://webbot02.azurewebsites.net/hyundai/images/price/Grandeur_24spec.PNG"); cardContentList.Add("Bacon", "http://webbot02.azurewebsites.net/hyundai/images/price/Grandeur_24spec.PNG"); foreach (KeyValuePair <string, string> cardContent in cardContentList) { List <CardImage> cardImages = new List <CardImage>(); cardImages.Add(new CardImage(url: cardContent.Value)); List <CardAction> cardButtons = new List <CardAction>(); CardAction plButton = new CardAction() { Value = $"https://en.wikipedia.org/wiki/{cardContent.Key}", Type = "openUrl", Title = "WikiPedia Page" }; cardButtons.Add(plButton); NewHeroCard plCard = new NewHeroCard() { Title = $"I'm a hero card about {cardContent.Key}", Subtitle = $"{cardContent.Key} Wikipedia Page", Images = cardImages, Buttons = cardButtons, Kind = "test" }; Attachment attachment = plCard.ToAttachment(); replyToConversation.Attachments.Add(attachment); } await connector.Conversations.SendToConversationAsync(replyToConversation); } else if (activity.Type == ActivityTypes.Message) { //test.resume(); //Thread.Sleep(3000); //test.pause(); //Thread.Sleep(3000); //if (workerThread.IsAlive) //{ // workerObject.RequestStop(); // workerThread.Join(); // Debug.WriteLine("main thread: Worker thread has terminated."); //} DateTime startTime = DateTime.Now; long unixTime = ((DateTimeOffset)startTime).ToUnixTimeSeconds(); Debug.WriteLine("startTime : " + startTime); Debug.WriteLine("startTime Millisecond : " + unixTime); Debug.WriteLine("Debuging : " + activity.Text); LUIS Luis = await GetIntentFromLUIS(activity.Text); Debug.WriteLine("Debuging : " + Luis.intents[0].intent); Debug.WriteLine("Debuging : " + Luis.entities[0].entity); Debug.WriteLine("Debuging : " + Luis.entities[0].type); String entitiesStr = ""; for (int i = 0; i < Luis.entities.Count(); i++) { Debug.WriteLine("Split : " + Regex.Split(Luis.entities[i].type, "::")[1]); entitiesStr += Regex.Split(Luis.entities[i].type, "::")[1] + ","; } entitiesStr = entitiesStr.Substring(0, entitiesStr.Length - 1); Debug.WriteLine("entitiesStr : " + entitiesStr); ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); // Db DbConnect db = new DbConnect(); List <Luis> LuisDialogID = db.SelectLuis(Luis.intents[0].intent, entitiesStr); List <Dialog> dlg = db.SelectDialog(LuisDialogID[0].dlgId); if (dlg.Count > 0) { if (dlg[0].dlgMent != null) { // return our reply to the user Activity reply = activity.CreateReply(dlg[0].dlgMent); await connector.Conversations.ReplyToActivityAsync(reply); } } List <Card> card = db.SelectDialogCard(LuisDialogID[0].dlgId); if (card.Count > 0) { // HeroCard Activity replyToConversation = activity.CreateReply(""); Debug.WriteLine("activity : " + activity.Id); Debug.WriteLine("activity : " + activity.Properties); Debug.WriteLine("activity : " + activity.Recipient); Debug.WriteLine("activity : " + activity.Summary); Debug.WriteLine("activity : " + activity.ReplyToId); Debug.WriteLine("activity : " + activity.Recipient.Id); Debug.WriteLine("activity : " + activity.Conversation.Id); replyToConversation.Recipient = activity.From; replyToConversation.Type = "message"; replyToConversation.Attachments = new List <Attachment>(); replyToConversation.AttachmentLayout = AttachmentLayoutTypes.Carousel; for (int i = 0; i < card.Count; i++) { List <Button> btn = db.SelectBtn(card[i].dlgId, card[i].cardId); List <Image> img = db.SelectImage(card[i].dlgId, card[i].cardId); List <Media> media = db.SelectMedia(card[i].dlgId, card[i].cardId); List <CardImage> cardImages = new List <CardImage>(); CardImage[] plImage = new CardImage[img.Count]; ThumbnailUrl plThumnail = new ThumbnailUrl(); List <CardAction> cardButtons = new List <CardAction>(); CardAction[] plButton = new CardAction[btn.Count]; List <MediaUrl> mediaURL = new List <MediaUrl>(); MediaUrl[] plMediaUrl = new MediaUrl[media.Count]; ReceiptCard[] plReceiptCard = new ReceiptCard[card.Count]; HeroCard[] plHeroCard = new HeroCard[card.Count]; VideoCard[] plVideoCard = new VideoCard[card.Count]; Attachment[] plAttachment = new Attachment[card.Count]; for (int l = 0; l < img.Count; l++) { if (card[i].cardType == "herocard") { if (img[l].imgUrl != null) { plImage[l] = new CardImage() { Url = img[l].imgUrl }; } } else if (card[i].cardType == "videocard") { if (img[l].imgUrl != null) { plThumnail.Url = img[l].imgUrl; } } } cardImages = new List <CardImage>(plImage); for (int l = 0; l < media.Count; l++) { if (media[l].mediaUrl != null) { plMediaUrl[l] = new MediaUrl() { Url = media[l].mediaUrl }; } } mediaURL = new List <MediaUrl>(plMediaUrl); for (int m = 0; m < btn.Count; m++) { if (btn[m].btnTitle != null) { plButton[m] = new CardAction() { Value = btn[m].btnContext, Type = btn[m].btnType, Title = btn[m].btnTitle }; } } cardButtons = new List <CardAction>(plButton); if (card[i].cardType == "herocard") { plHeroCard[i] = new HeroCard() { Title = card[i].cardTitle, Text = card[i].cardText, Subtitle = card[i].cardSubTitle, Images = cardImages, Buttons = cardButtons }; plAttachment[i] = plHeroCard[i].ToAttachment(); replyToConversation.Attachments.Add(plAttachment[i]); } else if (card[i].cardType == "videocard") { plVideoCard[i] = new VideoCard() { Title = card[i].cardTitle, Text = card[i].cardText, Subtitle = card[i].cardSubTitle, Image = plThumnail, Media = mediaURL, Buttons = cardButtons, Autostart = true }; plAttachment[i] = plVideoCard[i].ToAttachment(); replyToConversation.Attachments.Add(plAttachment[i]); } } var reply1 = await connector.Conversations.SendToConversationAsync(replyToConversation); } DateTime endTime = DateTime.Now; Debug.WriteLine("프로그램 수행시간 : {0}/ms", ((endTime - startTime).Milliseconds)); //Debug.WriteLine("current main thread = {0}",workerThread.ManagedThreadId); //del_thread new_th = new del_thread(new_thread); //new_th.BeginInvoke("TEST", null, null); //Thread.Sleep(3000); //// Start the worker thread. //workerThread.Start(); //Debug.WriteLine("ID : "+ workerThread.ManagedThreadId); //Debug.WriteLine("main thread: Starting worker thread..."); //// Loop until worker thread activates. //while (!workerThread.IsAlive) ; //Thread.Sleep(5); //test.resume(); //Thread.Sleep(30000); } else { HandleSystemMessage(activity); } var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
public override BangoCommand BeforeBindingParameter(SearchScenario searchFor, DbConnect con, BangoCommand cmd, DynamicDictionary data_param, bool count = false, string tableAlias = null) { return(base.BeforeBindingParameter(searchFor, con, cmd, data_param, count, tableAlias)); }
/// <summary> /// Collects Dart Logs by calling the jta2 launcher and placing them in the location defined by the framework server setting. /// </summary> /// <remarks> Be sure that Java SDK, SNMPGet and JTA3 @ C:\JTA are located on the server.</remarks> /// <param name="assetID"></param> /// <param name="sessionID"></param> /// <param name="email"></param> public void CollectLog(string assetID, string sessionID, string email) { string printerIP = string.Empty; string dartIP = string.Empty; bool collectDart = false; string script = string.Empty; string modelName = string.Empty; try { using (AssetInventoryContext context = DbConnect.AssetInventoryContext()) { var temp = context.Assets.OfType <Printer>().FirstOrDefault(n => n.AssetId == assetID); printerIP = temp.Address1; modelName = temp.Product.Split(' ').First(); if (string.IsNullOrEmpty(printerIP)) { TraceFactory.Logger.Debug($@"Printer IP Not found for asset: {assetID}"); return; } var dartBoard = context.DartBoards.FirstOrDefault(n => n.PrinterId == assetID); if (dartBoard == null) { TraceFactory.Logger.Debug($@"No DartBoard found for: {assetID}"); collectDart = false; } else { dartIP = dartBoard.Address; collectDart = true; } string serverType = ServerType.Dart.ToString(); FrameworkServer server = context.FrameworkServers.FirstOrDefault(n => n.ServerTypes.Any(m => m.Name == serverType) && n.Active); string dartLocation = server.ServerSettings.First(n => n.Name == "DartServiceLocation").Value; string jtaLocation = GlobalSettings.Items["JTALogCollectorDirectory"]; string inAddition = $@"\{sessionID}"; DirectoryInfo di = Directory.CreateDirectory(dartLocation + inAddition); bool pingResult = false; using (var ping = new Ping()) { var response = ping.Send(printerIP, (int)TimeSpan.FromSeconds(15).TotalMilliseconds); //DV: sometimes the device, being lazy as it is, will be in sleep mode and doesn't respond to the ping command //so we poke it few more times so that it wakes up from its slumber and responds. int retries = 0; while (response.Status != IPStatus.Success && retries < 4) { System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1)); response = ping.Send(printerIP, (int)TimeSpan.FromSeconds(15).TotalMilliseconds); retries++; } if (response.Status != IPStatus.Success) { TraceFactory.Logger.Debug($"Ping Unsuccessful: {printerIP.ToString()}:{response.Status}"); pingResult = false; } else { pingResult = true; } } //Extra check that the device is in dev mode for JTA. if (pingResult) { pingResult = CheckProd(temp.Address1, temp.Password); } //If JTA checks are not a success, use dart.exe, else use JTA --Don't use JTA for dart logs. It may fail before dart collection if (pingResult) { if (collectDart) { bool result = false; Task.Factory.StartNew(() => { //Get DARTLOCATION FROM Global Settings string timestamp = string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}", DateTime.Now); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.CreateNoWindow = true; startInfo.UseShellExecute = true; startInfo.FileName = @"dart.exe"; startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.Arguments = $@"{dartIP} dl {dartLocation + inAddition}\{assetID}_{timestamp}.bin"; try { using (Process exeProcess = Process.Start(startInfo)) { exeProcess.WaitForExit(); } result = true; TraceFactory.Logger.Debug($@"Capture of {assetID} logs succeeded"); SendEmail(sessionID, assetID, result, email); } catch (Exception a) { TraceFactory.Logger.Error("Dart log collection failed."); TraceFactory.Logger.Error(a); } }); //TraceFactory.Logger.Info($@"Attempting to collect logs of {assetID} for Session ID: {sessionID}."); //script = $@"cd {jtaLocation} | java jta3.Launcher -p {modelName} -x {printerIP} -r {dartLocation + inAddition} -s false"; } TraceFactory.Logger.Info($@"Attempting to collect logs of {assetID} for Session ID: {sessionID}."); script = $@"cd {jtaLocation} | java jta3.Launcher -p {modelName} -x {printerIP} -r {dartLocation + inAddition} -s false"; Task.Factory.StartNew(() => { bool result = false; try { Runspace runspace = RunspaceFactory.CreateRunspace(); runspace.Open(); TraceFactory.Logger.Debug(Environment.CurrentDirectory); Pipeline pipeline = runspace.CreatePipeline(); pipeline.Commands.AddScript(string.Format("$user = \"{0}\"", "jawa")); pipeline.Commands.AddScript(script); Collection <PSObject> results = pipeline.Invoke(); bool hadErrors = pipeline.HadErrors; runspace.Close(); result = !hadErrors; TraceFactory.Logger.Debug($@"Capture of {assetID} logs succeeded, Error during collection? {hadErrors}"); if (hadErrors) { StringBuilder builder = new StringBuilder(); foreach (PSObject obj in results) { builder.AppendLine(obj.ToString()); } TraceFactory.Logger.Debug($@"{builder}"); } } catch (Exception a) { result = false; TraceFactory.Logger.Debug("JTA log collection failed."); TraceFactory.Logger.Debug(a); } SendEmail(sessionID, assetID, result, email); }); } else { if (collectDart) { bool result = false; Task.Factory.StartNew(() => { //Get DARTLOCATION FROM Global Settings string timestamp = string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}", DateTime.Now); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.CreateNoWindow = true; startInfo.UseShellExecute = true; startInfo.FileName = @"dart.exe"; startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.Arguments = $@"{dartIP} dl {dartLocation + inAddition}\{assetID}_{timestamp}.bin"; try { using (Process exeProcess = Process.Start(startInfo)) { exeProcess.WaitForExit(); } result = true; TraceFactory.Logger.Debug($@"Capture of {assetID} logs succeeded"); SendEmail(sessionID, assetID, result, email); } catch (Exception a) { TraceFactory.Logger.Error("Dart log collection failed."); TraceFactory.Logger.Error(a); } } ); } } } } catch (Exception e) { TraceFactory.Logger.Error(e); } }
public bool OpretNyBruger(string _username, string _password, string _rolle) { DbConnect dbc = new DbConnect(); return(dbc.OpretNyBruger(_username, _password, _rolle)); }
//public Task StartAsync(IDialogContext context) //{ // context.Wait(MessageReceivedAsync); // return Task.CompletedTask; //} public async Task StartAsync(IDialogContext context) { var activity = context.Activity; channel = activity.ChannelId; orgMent = MessagesController.queryStr; String beforeMent = ""; int facebookpagecount = 1; int fbLeftCardCnt = 0; if (context.ConversationData.TryGetValue("commonBeforeQustion", out beforeMent)) { if (beforeMent.Equals(orgMent) && channel.Equals("facebook")) { if (context.ConversationData.TryGetValue("facebookPageCount", out facebookpagecount)) { facebookpagecount++; } context.ConversationData.SetValue("facebookPageCount", facebookpagecount); fbLeftCardCnt++; } } var reply = context.MakeMessage(); reply.AttachmentLayout = AttachmentLayoutTypes.Carousel; DbConnect db = new DbConnect(); for (int m = 0; m < MessagesController.relationList.Count; m++) { DialogList dlg = db.SelectDialog(MessagesController.relationList[m].dlgId); Attachment tempAttachment = new Attachment(); if (dlg.dlgType.Equals(CARDDLG)) { foreach (CardList tempcard in dlg.dialogCard) { if (context.ConversationData.TryGetValue("facebookPageCount", out facebookpagecount)) { if (Int32.Parse(tempcard.card_order_no) > (MAXFACEBOOKCARDS * facebookpagecount) && Int32.Parse(tempcard.card_order_no) <= (MAXFACEBOOKCARDS * (facebookpagecount + 1))) { tempAttachment = getAttachmentFromDialog(tempcard); } else if (Int32.Parse(tempcard.card_order_no) > (MAXFACEBOOKCARDS * (facebookpagecount + 1))) { fbLeftCardCnt++; } } else if (channel.Equals("facebook")) { if (Int32.Parse(tempcard.card_order_no) <= MAXFACEBOOKCARDS) { tempAttachment = getAttachmentFromDialog(tempcard); } else { fbLeftCardCnt++; } } else { tempAttachment = getAttachmentFromDialog(tempcard); } reply.Attachments.Add(tempAttachment); } } else { tempAttachment = getAttachmentFromDialog(dlg); reply.Attachments.Add(tempAttachment); } await context.PostAsync(reply); reply.Attachments.Clear(); ////페이스북에서 남은 카드가 있는경우 //if (beforeMent.Equals(orgMent) && channel.Equals("facebook") && fbLeftCardCnt > 0) //{ // reply.Attachments.Add( // GetHeroCard( // "", "", // fbLeftCardCnt + "개의 컨테츠가 더 있습니다.", // //new CardAction(ActionTypes.ImBack, "더 보기", value: userData.GetProperty<string>("FB_BEFORE_MENT"))) // new CardAction(ActionTypes.ImBack, "더 보기", value: beforeMent)) // ); // await context.PostAsync(reply); // reply.Attachments.Clear(); //} } DateTime endTime = DateTime.Now; Debug.WriteLine("프로그램 수행시간 : {0}/ms", ((endTime - MessagesController.startTime).Milliseconds)); Debug.WriteLine("* activity.Type : " + activity.Type); Debug.WriteLine("* activity.Recipient.Id : " + activity.Recipient.Id); Debug.WriteLine("* activity.ServiceUrl : " + activity.ServiceUrl); int dbResult = db.insertUserQuery(Regex.Replace(MessagesController.queryStr, @"[^a-zA-Z0-9ㄱ-힣]", "", RegexOptions.Singleline), MessagesController.luisIntent, MessagesController.luisEntities, "0", MessagesController.luisId, 'H', 0); Debug.WriteLine("INSERT QUERY RESULT : " + dbResult.ToString()); if (db.insertHistory(activity.Conversation.Id, MessagesController.queryStr, MessagesController.relationList[0].dlgId.ToString(), activity.ChannelId, ((endTime - MessagesController.startTime).Milliseconds), 0) > 0) { Debug.WriteLine("HISTORY RESULT SUCCESS"); //HistoryLog("HISTORY RESULT SUCCESS"); } else { Debug.WriteLine("HISTORY RESULT SUCCESS"); //HistoryLog("HISTORY RESULT FAIL"); } context.ConversationData.SetValue("commonBeforeQustion", orgMent); context.Done <IMessageActivity>(null); }
public M_V2_dyeingIssueForm(DataRow row, bool isEditable, M_V_history v1_history) { InitializeComponent(); this.edit_form = true; this.v1_history = v1_history; this.c = new DbConnect(); this.tray_no = new List <string>(); this.tray_no.Add(""); this.saveButton.Enabled = false; //Create drop-down Quality lists var dataSource1 = new List <string>(); DataTable d1 = c.getQC('q'); dataSource1.Add("---Select---"); for (int i = 0; i < d1.Rows.Count; i++) { dataSource1.Add(d1.Rows[i][0].ToString()); } this.comboBox1CB.DataSource = dataSource1; this.comboBox1CB.DisplayMember = "Quality"; this.comboBox1CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox1CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox1CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Company lists var dataSource2 = new List <string>(); DataTable d2 = c.getQC('c'); dataSource2.Add("---Select---"); for (int i = 0; i < d2.Rows.Count; i++) { dataSource2.Add(d2.Rows[i][0].ToString()); } this.comboBox2CB.DataSource = dataSource2; this.comboBox2CB.DisplayMember = "Company_Names"; this.comboBox2CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox2CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox2CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Dyeing Company lists var dataSource3 = new List <string>(); DataTable d3 = c.getQC('d'); dataSource3.Add("---Select---"); for (int i = 0; i < d3.Rows.Count; i++) { dataSource3.Add(d3.Rows[i][0].ToString()); } this.comboBox3CB.DataSource = dataSource3; this.comboBox3CB.DisplayMember = "Dyeing_Company_Names"; this.comboBox3CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox3CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox3CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Colour lists var dataSource4 = new List <string>(); DataTable d4 = c.getQC('l'); dataSource4.Add("---Select---"); for (int i = 0; i < d4.Rows.Count; i++) { dataSource4.Add(d4.Rows[i][0].ToString()); } List <string> final_list = dataSource4.Distinct().ToList(); this.comboBox4CB.DataSource = final_list; this.comboBox4CB.DisplayMember = "Colours"; this.comboBox4CB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.comboBox4CB.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox4CB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //DatagridView dataGridView1.Columns.Add("Sl_No", "Sl_No"); dataGridView1.Columns[0].ReadOnly = true; DataGridViewComboBoxColumn dgvCmb = new DataGridViewComboBoxColumn(); dgvCmb.DataSource = this.tray_no; dgvCmb.HeaderText = "Tray Number"; dataGridView1.Columns.Insert(1, dgvCmb); dataGridView1.Columns[1].Width = 250; dataGridView1.Columns.Add("Weight", "Weight"); dataGridView1.Columns["Weight"].ReadOnly = true; dataGridView1.Columns.Add("Machine_Number", "Machine Number"); dataGridView1.Columns["Machine_Number"].ReadOnly = true; dataGridView1.Columns.Add("Grade", "Grade"); dataGridView1.Columns[4].ReadOnly = true; dataGridView1.RowCount = 10; bool invalid_edit = false; //make isEditable false if batch is in future states this.batch_state = c.getBatchState(int.Parse(row["Batch_No"].ToString()), row["Batch_Fiscal_Year"].ToString()); if (batch_state == 2) { dynamicEditableLabel.Text = "This voucher is not editable as the Batch has been recieved from dyeing"; invalid_edit = true; } else if (batch_state == 3) { dynamicEditableLabel.Text = "This voucher is not editable as the Batch has been packed"; invalid_edit = true; } else if (batch_state == 4) { dynamicEditableLabel.Text = "This voucher is not editable as the Batch has been split for redyeing"; invalid_edit = true; } if (isEditable == false) { if (invalid_edit == true) { this.deleteButton.Enabled = false; } else { this.deleteButton.Enabled = true; } this.deleteButton.Visible = true; } if (isEditable == false || invalid_edit == true) { this.Text += "(View Only)"; this.disable_form_edit(); } else { //no option to edit company name and quality this.Text += "(Edit)"; this.comboBox1CB.Enabled = false; this.comboBox2CB.Enabled = false; this.comboBox3CB.Enabled = true; this.comboBox4CB.Enabled = true; this.saveButton.Enabled = true; this.loadCartonButton.Enabled = false; this.dataGridView1.ReadOnly = false; } this.inputDateDTP.Value = Convert.ToDateTime(row["Date_Of_Input"].ToString()); this.issueDateDTP.Value = Convert.ToDateTime(row["Date_Of_Issue"].ToString()); this.comboBox1CB.SelectedIndex = this.comboBox1CB.FindStringExact(row["Quality"].ToString()); this.comboBox2CB.SelectedIndex = this.comboBox2CB.FindStringExact(row["Company_Name"].ToString()); this.comboBox3CB.SelectedIndex = this.comboBox3CB.FindStringExact(row["Dyeing_Company_Name"].ToString()); this.comboBox4CB.SelectedIndex = this.comboBox4CB.FindStringExact(row["Colour"].ToString()); this.rateTextBoxTB.Text = row["Dyeing_Rate"].ToString(); this.old_fiscal_year = row["Batch_Fiscal_Year"].ToString(); batchNumberTextboxTB.Text = row["Batch_No"].ToString(); this.voucherID = int.Parse(row["Voucher_ID"].ToString()); this.tray_no_this = c.csvToArray(row["Tray_No_Arr"].ToString()); this.tray_id_this = c.csvToArray(row["Tray_ID_Arr"].ToString()); for (int i = 0; i < tray_no_this.Length; i++) { this.tray_no.Add(tray_no_this[i]); } DataTable tray_data = c.getTrayDataBothTables("Tray_No, Net_Weight, Machine_No, Grade, Tray_ID", "Tray_ID IN (" + c.removecom(row["Tray_ID_Arr"].ToString()) + ")"); for (int i = 0; i < tray_data.Rows.Count; i++) { this.tray_fetch_data[tray_data.Rows[i]["Tray_No"].ToString()] = new fetch_data(float.Parse(tray_data.Rows[i]["Net_Weight"].ToString()), tray_data.Rows[i]["Machine_No"].ToString(), tray_data.Rows[i]["Grade"].ToString(), int.Parse(tray_data.Rows[i]["Tray_ID"].ToString())); } this.loadData(row["Quality"].ToString(), row["Company_Name"].ToString()); dataGridView1.RowCount = tray_no_this.Length + 1; for (int i = 0; i < tray_no_this.Length; i++) { dataGridView1.Rows[i].Cells[1].Value = tray_no_this[i]; } string voucher_fiscal_year = c.getFinancialYear(this.issueDateDTP.Value); string today_fiscal_year = c.getFinancialYear(DateTime.Now); List <int> years = c.getFinancialYearArr(voucher_fiscal_year); if (today_fiscal_year == voucher_fiscal_year) { this.issueDateDTP.MinDate = new DateTime(years[0], 04, 01); this.issueDateDTP.MaxDate = DateTime.Now; } else { this.issueDateDTP.MinDate = new DateTime(years[0], 04, 01); this.issueDateDTP.MaxDate = new DateTime(years[1], 03, 31); } c.set_dgv_column_sort_state(this.dataGridView1, DataGridViewColumnSortMode.NotSortable); }
/// <summary> /// Constructs the queue definitions based on the provided list of printer Ids. /// </summary> /// <param name="printerIds">The printer ids.</param> /// <param name="sourceDriver">The driver.</param> /// <param name="currentDriver">The driver.</param> /// <param name="description">The additional description.</param> /// <param name="queueCount">The queue count.</param> /// <returns></returns> public Collection <QueueInstallationData> Create ( Collection <string> printerIds, PrintDeviceDriver sourceDriver, PrintDeviceDriver currentDriver, string description, int queueCount = 1, bool fullName = true ) { Collection <QueueInstallationData> queueData = new Collection <QueueInstallationData>(); StringBuilder queueName = new StringBuilder(); if (printerIds.Count == 0) { return(queueData); } using (AssetInventoryContext context = DbConnect.AssetInventoryContext()) { foreach (Asset asset in context.Assets.Where(n => printerIds.Contains(n.AssetId))) { for (int i = 0; i < queueCount; i++) { QueueInstallationData data = new QueueInstallationData(); // Assign the driver install data from a collected list of loaded package data // based on the version. data.Driver = sourceDriver; data.AssetId = asset.AssetId; data.QueueType = asset.AssetType; data.Shared = true; queueName.Clear(); if (asset.AssetType == "Printer") { Printer printer = (Printer)asset; data.Port = printer.PortNumber; data.Address = printer.Address1; data.SnmpEnabled = true; data.ClientRender = false; data.Shared = true; data.Description = printer.Description; queueName.Append(printer.Product); queueName.Append(" ").Append(data.AssetId); if (fullName) { queueName.Append(" ").Append(currentDriver.DriverType); queueName.Append(" ").Append(Regex.Replace(currentDriver.VerifyPdl, @"\s+", " ")); } if (!string.IsNullOrEmpty(currentDriver.Release)) { queueName.Append(" ").Append(Regex.Replace(currentDriver.Release, @"\s+", " ")); } // Append the additional description data if it exists if (!string.IsNullOrEmpty(description)) { queueName.Append(" ").Append(Regex.Replace(description, @"\s+", " ")); } } else if (asset.AssetType == "VirtualPrinter") { VirtualPrinter virtualPrinter = (VirtualPrinter)asset; //Build a shortened version of the asset ID string addressCode = asset.AssetId.Split('-')[0]; AddressParser assetIP = new AddressParser(virtualPrinter.Address); data.Port = virtualPrinter.PortNumber; data.Address = virtualPrinter.Address; data.SnmpEnabled = virtualPrinter.SnmpEnabled; data.Description = "Virtual Printer"; data.ClientRender = false; data.Shared = true; queueName.Append(addressCode); queueName.Append("-").Append(assetIP.GetOctet(2)); queueName.Append("-").Append(assetIP.GetOctet(3)); queueName.Append(" ").Append(currentDriver.DriverType); queueName.Append(" ").Append(Regex.Replace(currentDriver.VerifyPdl, @"\s+", " ")); if (!string.IsNullOrEmpty(currentDriver.Release)) { queueName.Append(" ").Append(Regex.Replace(currentDriver.Release, @"\s+", " ")); } // Append the additional description data if it exists if (!string.IsNullOrEmpty(description)) { queueName.Append(" ").Append(Regex.Replace(description, @"\s+", " ")); } } data.Key = queueName.ToString(); IncrementQueueIndex(data); if (queueCount > 1) { queueName.Append(" ").Append(_queueIndex[data.Key].ToString("D3")); } data.QueueName = queueName.ToString(); queueData.Add(data); } } } return(queueData); }
private void CloseSessionHandler(string sessionId, ShutdownOptions options) { SetTraceSessionContext(sessionId); SessionProxyController controller = null; if (_proxyControllers.TryGetValue(sessionId, out controller)) //If a session exists, proceed with normal shutdown. Otherwise reset manually. { _proxyControllers.Remove(controller); TraceFactory.Logger.Debug("Found & removed controller: Count: {0} : {1}".FormatWith(_proxyControllers.Count, controller.Endpoint.AbsoluteUri)); if (!controller.SessionClosing) //Make sure the session isn't already closing { lock (controller) { controller.SessionClosing = true; try { ThreadPool.QueueUserWorkItem(t => ShutdownScenario(controller, sessionId, options)); } catch (Exception ex) { TraceFactory.Logger.Error(ex); } } } } else { TraceFactory.Logger.Debug(string.Format("Closing session {0}", sessionId)); // Manually reset DomainAccountReservation for all inactive SessionIds using (AssetInventoryContext context = DbConnect.AssetInventoryContext()) { List <string> activeSessionIds = context.FrameworkClients.Select(n => n.SessionId).Distinct().Where(n => n != null).ToList(); foreach (var reservation in context.DomainAccountReservations) { if (!activeSessionIds.Contains(reservation.SessionId)) { context.DomainAccountReservations.Remove(reservation); } } context.SaveChanges(); } try { // Parallel process the two actions required to clean up this session, first define // the collection of actions, then spawn them each off in the background and then // wait for them to return. var actions = new Collection <Action>() { () => CleanupAssetHosts(sessionId), () => CleanupResourceHosts(sessionId) }; Parallel.ForEach <Action>(actions, a => a()); using (DataLogContext context = DbConnect.DataLogContext()) { SessionSummary summary = context.DbSessions.First(n => n.SessionId == sessionId); summary.Status = SessionStatus.Aborted.ToString(); summary.EndDateTime = DateTime.UtcNow; context.SaveChanges(); } UpdateSessionShutdownState(MachineShutdownState.ManualReset, sessionId, ignoreMissing: true); TraceFactory.Logger.Info("Done closing {0}".FormatWith(sessionId)); } catch (Exception ex) { TraceFactory.Logger.Error(ex); } // Tell all clients to clean up any session info EventPublisher.ReleaseSession(sessionId); //Checks for any Virtual worker process which may have not been terminated correctly from the previous runs if (GlobalSettings.IsDistributedSystem == false) { using (DataLogContext context = DbConnect.DataLogContext()) { SessionSummary summary = context.DbSessions.First(n => n.SessionId == sessionId); if (summary.Dispatcher == Environment.MachineName) { KillOrphanedWorkerProcesses(sessionId); } } } } }
public editDyeingCompany() { InitializeComponent(); this.c = new DbConnect(); }
public override ResponseModel Insert(DbConnect con, DynamicDictionary item) { return(base.Insert(con, item)); }
public override ResponseModel Insert(DbConnect con, DynamicDictionary item) { item.Add("client_id", SessionData.client_id); return(base.Insert(con, item)); }
//Form functions public M_VC_addBill(string form) { InitializeComponent(); this.Name = "Add Bill"; this.tablename = form; this.c = new DbConnect(); this.do_no = new List <string>(); this.do_no.Add(""); //Create frop down type list List <string> dataSource = new List <string>(); dataSource.Add("---Select---"); dataSource.Add("0"); dataSource.Add("1"); this.typeCB.DataSource = dataSource; this.typeCB.DisplayMember = "Type"; this.typeCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.typeCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.typeCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down lists var dataSource1 = new List <string>(); DataTable d = c.getQC('f'); for (int i = 0; i < d.Rows.Count; i++) { dataSource1.Add(d.Rows[i][0].ToString()); } this.financialYearCB.DataSource = dataSource1; this.financialYearCB.DisplayMember = "Financial Year"; this.financialYearCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.financialYearCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.financialYearCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; this.financialYearCB.SelectedIndex = this.financialYearCB.FindStringExact(c.getFinancialYear(this.inputDate.Value)); //Create drop-down quality list DataTable d1 = c.getQC('q'); List <string> input_qualities = new List <string>(); input_qualities.Add("---Select---"); for (int i = 0; i < d1.Rows.Count; i++) { if (this.tablename == "Carton") { input_qualities.Add(d1.Rows[i]["Quality_Before_Twist"].ToString()); } else if (this.tablename == "Carton_Produced") { input_qualities.Add(d1.Rows[i]["Quality"].ToString()); } } List <string> norep_quality_list = input_qualities.Distinct().ToList(); this.qualityCB.DataSource = norep_quality_list; this.qualityCB.DisplayMember = "Quality"; this.qualityCB.DropDownStyle = ComboBoxStyle.DropDownList;//Create a drop-down list this.qualityCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.qualityCB.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //Create drop-down Customers list var dataSource4 = new List <string>(); DataTable d4 = c.getQC('C'); dataSource4.Add("---Select---"); for (int i = 0; i < d4.Rows.Count; i++) { dataSource4.Add(d4.Rows[i][0].ToString()); } this.billCustomerNameCB.DataSource = dataSource4; this.billCustomerNameCB.DisplayMember = "Customers"; this.billCustomerNameCB.DropDownStyle = ComboBoxStyle.DropDown;//Create a drop-down list this.billCustomerNameCB.AutoCompleteSource = AutoCompleteSource.ListItems; this.billCustomerNameCB.AutoCompleteMode = AutoCompleteMode.Append; //DatagridView dataGridView1.Columns.Add("Sl_No", "Sl_No"); dataGridView1.Columns[0].ReadOnly = true; DataGridViewComboBoxColumn dgvCmb = new DataGridViewComboBoxColumn(); dgvCmb.DataSource = this.do_no; dgvCmb.HeaderText = "DO Number"; dataGridView1.Columns.Insert(1, dgvCmb); dataGridView1.Columns.Add("DO Weight", "DO Weight"); dataGridView1.Columns.Add("DO Amount", "DO Amount"); dataGridView1.Columns[2].ReadOnly = true; dataGridView1.Columns[3].ReadOnly = true; dataGridView1.RowCount = 10; c.set_dgv_column_sort_state(this.dataGridView1, DataGridViewColumnSortMode.NotSortable); }
/// <summary> /// Sets up any child controls. /// </summary> /// <param name="officeWorker">The office worker.</param> protected override void SetupChildControls(OfficeWorker officeWorker) { if (officeWorker == null) { throw new ArgumentNullException("officeWorker"); } CitrixWorker worker = officeWorker as CitrixWorker; citrixServer_ComboBox.Visible = citrixServer_Label.Visible = true; appOptions_GroupBox.Visible = true; workersPerVM_Label.Visible = workersPerVM_UpDown.Visible = false; if (worker.RunMode != CitrixWorkerRunMode.None) { citrixWorker_CheckBox.Checked = true; pubApp_RadioButton.Checked = (worker.RunMode == CitrixWorkerRunMode.PublishedApp); desktop_RadioButton.Checked = (worker.RunMode == CitrixWorkerRunMode.Desktop); } else { pubApp_RadioButton.Checked = true; pubApp_RadioButton.Enabled = false; desktop_RadioButton.Enabled = false; } pubApp_CheckBox.Checked = !string.IsNullOrEmpty(worker.PublishedApp); citrixWorker_CheckBox.CheckedChanged += runWorkerOrApp_CheckedChanged; pubApp_CheckBox.CheckedChanged += runWorkerOrApp_CheckedChanged; desktop_RadioButton.CheckedChanged += desktop_RadioButton_CheckedChanged; pubApp_RadioButton.CheckedChanged += pubApp_RadioButton_CheckedChanged; pubApp_ComboBox.Text = worker.PublishedApp; using (AssetInventoryContext context = DbConnect.AssetInventoryContext()) { string serverType = ServerType.Citrix.ToString(); var servers = context.FrameworkServers.Where(n => n.ServerTypes.Any(m => m.Name == serverType) && n.Active).OrderBy(n => n.HostName); _citrixServers = new Collection <FrameworkServer>(servers.ToList()); if (_citrixServers.Any()) { citrixServer_ComboBox.AddServers(servers); var hostName = worker.ServerHostname; if (!_citrixServers.Any(x => x.HostName.Equals(hostName))) { hostName = _citrixServers.First().HostName; } citrixServer_ComboBox.SetSelectedServer(hostName); var appNames = SelectApplicationNames(context, hostName); pubApp_ComboBox.DataSource = appNames; if (appNames.Contains <string>(worker.PublishedApp)) { pubApp_ComboBox.SelectedItem = worker.PublishedApp; } } } UpdateControls(); citrixServer_ComboBox.SelectedIndexChanged += citrixServer_ComboBox_SelectedIndexChanged; }
private async Task SendSorryMessageAsync(IDialogContext context) { // Db DbConnect db = new DbConnect(); Debug.WriteLine("root before sorry count : " + MessagesController.sorryMessageCnt); HistoryLog("root before sorry count : " + MessagesController.sorryMessageCnt); //int sorryMessageCheck = db.SelectUserQueryErrorMessageCheck(context.Activity.Conversation.Id, MessagesController.userData.GetProperty<int>("appID")); int sorryMessageCheck = db.SelectUserQueryErrorMessageCheck(context.Activity.Conversation.Id, MessagesController.chatBotID); ++MessagesController.sorryMessageCnt; var reply_err = context.MakeMessage(); reply_err.Recipient = context.Activity.From; reply_err.Type = "message"; reply_err.Attachments = new List <Attachment>(); reply_err.AttachmentLayout = AttachmentLayoutTypes.Carousel; Debug.WriteLine("root after sorry count : " + MessagesController.sorryMessageCnt); HistoryLog("root after sorry count : " + MessagesController.sorryMessageCnt); List <TextList> text = new List <TextList>(); if (sorryMessageCheck == 0) { text = db.SelectSorryDialogText("5"); } else { text = db.SelectSorryDialogText("6"); } for (int i = 0; i < text.Count; i++) { HeroCard plCard = new HeroCard() { Title = text[i].cardTitle, Text = text[i].cardText }; Attachment plAttachment = plCard.ToAttachment(); reply_err.Attachments.Add(plAttachment); } //reply_err.Text = SorryMessageList.GetSorryMessage(sorryMessageCheck); await context.PostAsync(reply_err); orgKRMent = Regex.Replace(beforeMessgaeText, @"[^a-zA-Z0-9ㄱ-힣]", "", RegexOptions.Singleline); for (int n = 0; n < Regex.Split(beforeMessgaeText, " ").Length; n++) { string chgMsg = db.SelectChgMsg(Regex.Split(beforeMessgaeText, " ")[n]); if (!string.IsNullOrEmpty(chgMsg)) { beforeMessgaeText = beforeMessgaeText.Replace(Regex.Split(beforeMessgaeText, " ")[n], chgMsg); } } //Translator translateInfo = await getTranslate(beforeMessgaeText); //orgENGMent = Regex.Replace(translateInfo.data.translations[0].translatedText, @"[^a-zA-Z0-9ㄱ-힣-\s-']", "", RegexOptions.Singleline); //orgENGMent = orgENGMent.Replace("'", "'"); //int dbResult = db.insertUserQuery(orgKRMent, orgENGMent, "", "", "", 0, 'D', "", "", "", "SEARCH", MessagesController.userData.GetProperty<int>("appID")); int dbResult = db.insertUserQuery(orgKRMent, "", "", "", "", 'D', MessagesController.chatBotID); Debug.WriteLine("INSERT QUERY RESULT : " + dbResult.ToString()); DateTime endTime = DateTime.Now; Debug.WriteLine("USER NUMBER : " + context.Activity.Conversation.Id); Debug.WriteLine("CUSTOMMER COMMENT KOREAN : " + beforeMessgaeText); //Debug.WriteLine("CUSTOMMER COMMENT ENGLISH : " + translateInfo.data.translations[0].translatedText.Replace("'", "'")); Debug.WriteLine("CHANNEL_ID : " + context.Activity.ChannelId); Debug.WriteLine("프로그램 수행시간 : {0}/ms", ((endTime - startTime).Milliseconds)); //int inserResult = db.insertHistory(context.Activity.Conversation.Id, beforeMessgaeText, translateInfo.data.translations[0].translatedText.Replace("'", "'"), "SEARCH", context.Activity.ChannelId, ((endTime - startTime).Milliseconds), MessagesController.userData.GetProperty<int>("appID")); int inserResult = db.insertHistory(context.Activity.Conversation.Id, beforeMessgaeText, "ERROR", context.Activity.ChannelId, ((endTime - startTime).Milliseconds), MessagesController.chatBotID); if (inserResult > 0) { Debug.WriteLine("HISTORY RESULT SUCCESS"); } else { Debug.WriteLine("HISTORY RESULT FAIL"); } }