// Submit Button adds a new guestbook entry to the database, // clears the form and displays the updated list of guestbook entries protected void submitButton_Click( object sender, EventArgs e ) { // create dictionary of parameters for inserting ListDictionary insertParameters = new ListDictionary(); // add current date and the user's name, e-mail address // and message to dictionary of insert parameters insertParameters.Add( "Date", DateTime.Now.ToShortDateString() ); insertParameters.Add( "Name", nameTextBox.Text ); insertParameters.Add( "Email", emailTextBox.Text ); insertParameters.Add( "Message1", messageTextBox.Text ); // execute an INSERT LINQ statement to add a new entry to the // Messages table in the Guestbook data context that contains the // current date and the user's name, e-mail address and message messagesLinqDataSource.Insert( insertParameters ); // clear the TextBoxes nameTextBox.Text = String.Empty; emailTextBox.Text = String.Empty; messageTextBox.Text = String.Empty; // update the GridView with the new database table contents messagesGridView.DataBind(); }
protected void gridHistoricData_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Insert") { string[] fields = { "Date", "CASH", "COMM", "GLEQ", "HEDG", "LOSH", "PREQ" }; ListDictionary listDictionary = new ListDictionary(); foreach (var f in fields) { string boxName = "text" + f + "Add"; TextBox textBox = (TextBox)gridHistoricData.FooterRow.FindControl(boxName); if (f == "Date") { DateTime dt = DateTime.Parse(textBox.Text); listDictionary.Add(f, dt); } else { double db = Double.Parse(textBox.Text); listDictionary.Add(f, db); } textBox.Text = String.Empty; } sourceHistoricData.Insert(listDictionary); gridHistoricData.DataBind(); } } catch (Exception ex) { showException(ex, labelException, "adding the asset class prices"); } }
public DataTable getNguoiDung(clsNguoiDung_DTO nguoidungDTO) { ListDictionary _list = new ListDictionary(); _list.Add("TenDangNhap", nguoidungDTO.TenDangNhap); _list.Add("MaDiemThi", nguoidungDTO.MaDiemThi); _list.Add("MatKhau", nguoidungDTO.MatKhau); _list.Add("Ho", nguoidungDTO.Ho); _list.Add("Ten", nguoidungDTO.Ten); _list.Add("CMND", nguoidungDTO.CMND); _list.Add("NgaySinh", nguoidungDTO.NgaySinh); _list.Add("DiaChi", nguoidungDTO.DiaChi); _list.Add("DienThoai", nguoidungDTO.DienThoai); _list.Add("Email", nguoidungDTO.Email); _list.Add("NgayDK", nguoidungDTO.NgayDK); _list.Add("TrangThai", nguoidungDTO.TrangThai); _list.Add("MaNhom", nguoidungDTO.MaNhom); DataTable dt = new DataTable(); try { dt = obj.GetDataTable("Select_Nguoi_Dung",_list, CommandType.StoredProcedure); } catch { dt = null; } return dt; }
public CustomerAccountService() { customerAccounts = new ListDictionary<int, CustomerAccount>(); customerAccounts.Add(1, new CustomerAccount(123456781, "Checking", 1842.75M)); customerAccounts.Add(1, new CustomerAccount(123456782, "Savings", 9367.92M)); customerAccounts.Add(2, new CustomerAccount(987654321, "Interest Checking", 2496.44M)); customerAccounts.Add(2, new CustomerAccount(987654322, "Money Market", 21959.38M)); customerAccounts.Add(2, new CustomerAccount(987654323, "Car Loan", -19483.95M)); }
public int Check_Login(string strTenDangNhap, string strKhauKhau) { try { ListDictionary _list = new ListDictionary(); _list.Add("TenDangNhap", strTenDangNhap); _list.Add("MatKhau", strKhauKhau); int iReturn = obj.ExcSql("[Check_Login]", _list, CommandType.StoredProcedure); return iReturn; } catch (Exception) { return -1111; } }
public static void FindSpriteNamesInAllScene() { ListDictionary<string, string> spriteNames = new ListDictionary<string, string>(); string[] scenes = (from scene in EditorBuildSettings.scenes where scene.enabled select scene.path).ToArray(); foreach (string scene in scenes) { EditorApplication.OpenScene(scene); Transform[] allTrnasforms = GameObject.FindObjectsOfType<Transform>(); foreach (Transform transform in allTrnasforms) { UISprite sprite = transform.GetComponent<UISprite>(); if (sprite != null && !spriteNames.ContainsValue(scene, sprite.spriteName)) spriteNames.Add(scene, sprite.spriteName); } } string log = string.Empty; foreach (string scene in scenes) { if (!spriteNames.ContainsKey(scene)) continue; log += string.Format("Scene : {0}\n", scene); string spriteNameInScene = string.Empty; foreach (string spriteName in spriteNames[scene]) spriteNameInScene += string.Format("{0}\n", spriteName); log += string.Format("{0}\n\n", spriteNameInScene); } Debug.LogWarning(log); }
//lay cau lua chon theo cau hoi public DataTable getcauluachon_cauhoi(string MaCauHoi) { //DataTable dt_dethi1 = new DataTable(); DataTable dt_cauhoi_cauluachon = new DataTable(); try { // dt_dethi1 = obj.GetDataTable("select top 0 * from View_cauhoi_cauluachon", CommandType.Text); // dt_cauhoi_cauluachon = obj.GetDataTable("Select_cauluachontheocauhoi", //getcauluachon_cauhoi(MaCauHoi); //foreach (DataRow dr in dt_cauhoi_cauluachon.Rows) //{ ListDictionary _list = new ListDictionary(); _list.Add("MaCauHoi", MaCauHoi); // _list.Add("NoiDung", dr["NoiDung"].ToString()); // _list.Add("HinhAnh", dr["HinhAnh"].ToString()); // _list.Add("NoiDungCLC", dr["NoiDungCLC"].ToString()); // //_list.Add("NoiDung", dr["NoiDung"].ToString()); dt_cauhoi_cauluachon = obj.GetDataTable("Select_cauluachontheocauhoi", _list, CommandType.StoredProcedure); //for (int i = 0; i < dt_cauhoi_cauluachon.Rows.Count; i++) // { // DataRow drDeThi = dt_dethi1.NewRow(); // drDeThi["MaCauHoi"] = dt_cauhoi_cauluachon.Rows[i]["MaCauHoi"]; // drDeThi["NoiDung"] = dt_cauhoi_cauluachon.Rows[i]["NoiDung"]; // drDeThi["HinhAnh"] = dt_cauhoi_cauluachon.Rows[i]["HinhAnh"]; // drDeThi["NoiDungCLC"] = dt_cauhoi_cauluachon.Rows[i]["NoiDungCLC"]; // dt_dethi1.Rows.Add(drDeThi); // } } //} catch { dt_cauhoi_cauluachon = null; } return dt_cauhoi_cauluachon; }
public int Delete(clsCTQuyen_DTO ctqDTO) { try { ListDictionary _list = new ListDictionary(); _list.Add("MaQuyen", ctqDTO.MaQuyen); _list.Add("MaNhom", ctqDTO.MaQuyen); int iReturn = obj.ExcSql("Delete_CT_Quyen", _list, CommandType.StoredProcedure); return iReturn; } catch (Exception) { //return ex.Message; return -1111; } }
public DataTable getQuyen(clsQuyen_DTO qDTO) { ListDictionary _list = new ListDictionary(); _list.Add("MaQuyen", qDTO.MaQuyen); _list.Add("MoTa", qDTO.MoTa); DataTable dt = new DataTable(); try { dt = obj.GetDataTable("Select_Quyen", CommandType.StoredProcedure); } catch { dt = null; } return dt; }
public DataTable getLoaiCauHoi(clsLoaiCauHoi_DTO loaiCHDTO) { ListDictionary _list = new ListDictionary(); _list.Add("MaloaiCauHoi", loaiCHDTO.MaloaiCauHoi); _list.Add("TenLoaiCH", loaiCHDTO.TenLoaiCH); DataTable dt = new DataTable(); try { dt = obj.GetDataTable("Select_Loai_Cau_Hoi", _list, CommandType.StoredProcedure); } catch { dt = null; } return dt; }
protected override ICollection NonGenericICollectionFactory(int count) { ListDictionary list = new ListDictionary(); int seed = 13453; for (int i = 0; i < count; i++) list.Add(CreateT(seed++), CreateT(seed++)); return list.Keys; }
private static ListDictionary Fill(ListDictionary ld, KeyValuePair<string, string>[] data) { foreach (KeyValuePair<string, string> d in data) { ld.Add(d.Key, d.Value); } return ld; }
public DataTable getCauLuaChon(clsCauLuaChon_DTO clcDTO) { ListDictionary _list = new ListDictionary(); _list.Add("MaCauLuaChon", clcDTO.MaCauLuaChon); _list.Add("NoiDungCLC", clcDTO.NoiDungCLC); DataTable dt = new DataTable(); try { dt = obj.GetDataTable("Select_Cau_Lua_Chon", CommandType.StoredProcedure); } catch { dt = null; } return dt; }
public DataTable getCTQuyen(clsCTQuyen_DTO ctqDTO) { ListDictionary _list = new ListDictionary(); _list.Add("MaQuyen", ctqDTO.MaQuyen); _list.Add("MaNhom", ctqDTO.MaNhom); DataTable dt = new DataTable(); try { dt = obj.GetDataTable("Select_CT_Quyen", CommandType.StoredProcedure); } catch { dt = null; } return dt; }
public DataTable getNhomNguoiDung(clsNhomNguoiDung_DTO nhomndDTO) { ListDictionary _list = new ListDictionary(); _list.Add("MaNhom", nhomndDTO.MaNhom); _list.Add("TenNhom", nhomndDTO.TenNhom); DataTable dt = new DataTable(); try { dt = obj.GetDataTable("Select_Nhom_Nguoi_Dung", CommandType.StoredProcedure); } catch { dt = null; } return dt; }
internal void Update() { var rResult = new ListDictionary<FleetLoSFormulaInfo, double>(); foreach (var rCalculation in FleetLoSFormulaInfo.Formulas.Select(r => new { Formula = r, LoS = r.Calculate(r_Fleet) })) rResult.Add(rCalculation.Formula, rCalculation.LoS); Formulas = rResult; OnPropertyChanged(nameof(Formulas)); }
public DataTable getCaThi(clsCaThi_DTO cathiDTO) { ListDictionary _list = new ListDictionary(); _list.Add("MaCaThi", cathiDTO.MaCaThi); _list.Add("MoTa", cathiDTO.MoTa); _list.Add("GioBatDau", cathiDTO.GioBatDau); _list.Add("MaDotThi", cathiDTO.MaDotThi); DataTable dt = new DataTable(); try { dt = obj.GetDataTable("Select_Ca_Thi", _list, CommandType.StoredProcedure); } catch { dt = null; } return dt; }
public DataTable getDotThi(clsDotThi_DTO dotthiDTO) { ListDictionary _list = new ListDictionary(); _list.Add("MaDotThi", dotthiDTO.MaDotThi); _list.Add("MaLoaiBang", dotthiDTO.MaLoaiBang); _list.Add("NgayTao", dotthiDTO.NgayTao); _list.Add("MoTa", dotthiDTO.MoTa); DataTable dt = new DataTable(); try { dt = obj.GetDataTable("Select_Dot_Thi", _list, CommandType.StoredProcedure); } catch { dt = null; } return dt; }
public int InsertUpdate(clsLoaiCauHoi_DTO loaiCHDTO) { try { ListDictionary _list = new ListDictionary(); _list.Add("old_id", loaiCHDTO.OldID); _list.Add("MaloaiCauHoi", loaiCHDTO.MaloaiCauHoi); _list.Add("TenLoaiCH", loaiCHDTO.TenLoaiCH); int iReturn = obj.ExcSql("Insert_Update_Loai_Cau_Hoi", _list, CommandType.StoredProcedure); return iReturn; } catch (Exception) { //return ex.Message; return -1111; // Đặt số này làm ngoại lệ ko lường trước được. ở StoredProcedure không được return có số này tránh trường hợp trùng } }
public DataTable getPCCT(clsPhanCongCoiThi_DTO pcctDTO) { ListDictionary _list = new ListDictionary(); _list.Add("STT", pcctDTO.STT); _list.Add("TenDangNhap", pcctDTO.TenDangNhap); _list.Add("MaCaThi", pcctDTO.MaCaThi); _list.Add("MaPhong", pcctDTO.MaPhong); DataTable dt = new DataTable(); try { dt = obj.GetDataTable("Select_Phan_Cong_Coi_Thi", _list, CommandType.StoredProcedure); } catch { dt = null; } return dt; }
public int InsertUpdate(clsNhomNguoiDung_DTO nhomndDTO) { try { ListDictionary _list = new ListDictionary(); _list.Add("old_id", nhomndDTO.OldID); _list.Add("MaNhom", nhomndDTO.MaNhom); _list.Add("TenNhom", nhomndDTO.TenNhom); int iReturn = obj.ExcSql("Insert_Update_Nhom_Nguoi_Dung", _list, CommandType.StoredProcedure); return iReturn; } catch (Exception) { //return ex.Message; return -1111; // Đặt số này làm ngoại lệ ko lường trước được. ở StoredProcedure không được return có số này tránh trường hợp trùng } }
public DataTable getCauHoi_LoaiBang(clsCauHoi_LoaiBang_DTO ch_lbDTO) { ListDictionary _list = new ListDictionary(); _list.Add("STT", ch_lbDTO.STT); _list.Add("MaLoaiBang", ch_lbDTO.MaLoaiBang); _list.Add("MaCauHoi", ch_lbDTO.MaCauHoi); DataTable dt = new DataTable(); try { dt = obj.GetDataTable("Select_CauHoi_LoaiBang", CommandType.StoredProcedure); } catch { dt = null; } return dt; }
public DataTable getKetQuaThi(clsKetQuaThi_DTO kqtDTO) { ListDictionary _list = new ListDictionary(); _list.Add("SoDeThi", kqtDTO.SoDeThi); _list.Add("MaTS", kqtDTO.MaTS); _list.Add("DiemDanh", kqtDTO.DiemDanh); _list.Add("KetQuaThi", kqtDTO.KetQuaThi); DataTable dt = new DataTable(); try { dt = obj.GetDataTable("Select_Ket_Qua_Thi", _list, CommandType.StoredProcedure); } catch { dt = null; } return dt; }
public FriendDictionary(IEnumerable<TwitterUser> users) { FriendsByCount = new ListDictionary<int, TwitterUser>(); foreach (TwitterUser user in users) { friendsByName.Add(user.Name, user); FriendsByCount.Add(user.FriendCount, user); } }
public int InsertUpdate(clsQuyen_DTO qDTO) { try { ListDictionary _list = new ListDictionary(); _list.Add("old_id", qDTO.OldID); _list.Add("MaQuyen", qDTO.MaQuyen); _list.Add("MoTa", qDTO.MoTa); int iReturn = obj.ExcSql("Insert_Update_Quyen", _list, CommandType.StoredProcedure); return iReturn; } catch (Exception) { //return ex.Message; return -1111; // Đặt số này làm ngoại lệ ko lường trước được. ở StoredProcedure không được return có số này tránh trường hợp trùng } }
public DataTable getDiaDiemThi(clsDiaDiemThi_DTO diemthiDTO) { ListDictionary _list = new ListDictionary(); _list.Add("MaDiemThi", diemthiDTO.MaDiemThi); _list.Add("DiaChi", diemthiDTO.DiaChi); _list.Add("SoDienThoai", diemthiDTO.SoDienThoai); _list.Add("NgayThanhLap", diemthiDTO.NgayThanhLap); DataTable dt = new DataTable(); try { dt = obj.GetDataTable("Select_Dia_Diem_Thi", _list, CommandType.StoredProcedure); } catch { dt = null; } return dt; }
public DataTable getCauTrucDeThi(clsCauTrucDeThi_DTO ctdtDTO) { ListDictionary _list = new ListDictionary(); _list.Add("STT", ctdtDTO.STT); _list.Add("MaLoaiBang", ctdtDTO.MaLoaiBang); _list.Add("MaloaiCauHoi", ctdtDTO.MaloaiCauHoi); _list.Add("SoCau", ctdtDTO.SoCau); DataTable dt = new DataTable(); try { dt = obj.GetDataTable("Select_Cau_Truc_De_Thi", CommandType.StoredProcedure); } catch { dt = null; } return dt; }
protected void GetStatus() { ISession session = (ISession)Context.Items[Constant.NHibernateSessionSign]; int userId = (int)Session[Constant.NormalUserSessionSign]; IDbCommand cmdGetStatus = session.Connection.CreateCommand(); cmdGetStatus.CommandText = "select chat_status.message, chat_status.status from chat_status where user_id = @userid"; IDbDataParameter paramUserId = cmdGetStatus.CreateParameter(); paramUserId.DbType = DbType.Int32; paramUserId.ParameterName = "@userid"; paramUserId.Value = userId; cmdGetStatus.Parameters.Add(paramUserId); session.Transaction.Enlist(cmdGetStatus); IDataReader readerGetStatus = cmdGetStatus.ExecuteReader(CommandBehavior.SingleRow); ListDictionary chat = new ListDictionary(); if (readerGetStatus.Read()) { chat.Add("message", readerGetStatus["message"]); chat.Add("status", readerGetStatus["status"]); } else { chat.Add("message", string.Empty); chat.Add("status", string.Empty); } readerGetStatus.Close(); if (chat["status"] == string.Empty) chat["status"] = "available"; else if (chat["status"] == "offline") ((ListDictionary)Session["chat_sessionvars"])["buddylist"] = 0; if (chat["message"]==string.Empty) chat["message"] = "I'm " + TextUtility.UppercaseFirst(chat["status"].ToString()); ListDictionary status = new ListDictionary(); status["message"] = chat["message"]; status["status"] = chat["status"]; response["userstatus"] = status; }
public int InsertUpdate(clsCauLuaChon_DTO clcDTO) { try { ListDictionary _list = new ListDictionary(); _list.Add("old_id", clcDTO.OldID); _list.Add("MaCauLuaChon", clcDTO.MaCauLuaChon); _list.Add("NoiDungCLC", clcDTO.NoiDungCLC); int iReturn = obj.ExcSql("Insert_Update_Cau_Lua_Chon", _list, CommandType.StoredProcedure); return iReturn; } catch (Exception) { //return ex.Message; return -1111; // Đặt số này làm ngoại lệ ko lường trước được. ở StoredProcedure không được return có số này tránh trường hợp trùng } }
public int InsertUpdate(clsPhanCongCoiThi_DTO pcctDTO) { try { ListDictionary _list = new ListDictionary(); _list.Add("old_id", pcctDTO.OldID); _list.Add("STT", pcctDTO.STT); _list.Add("TenDangNhap", pcctDTO.TenDangNhap); _list.Add("MaCaThi", pcctDTO.MaCaThi); _list.Add("MaPhong", pcctDTO.MaPhong); int iReturn = obj.ExcSql("Insert_Update_Phan_Cong_Coi_Thi", _list, CommandType.StoredProcedure); return iReturn; } catch (Exception) { //return ex.Message; return -1111; // Đặt số này làm ngoại lệ ko lường trước được. ở StoredProcedure không được return có số này tránh trường hợp trùng } }
/// <summary> /// Register Perf Counter implemented by user. Custom Perf Counter. /// Use GetPerfCounter(name) for getting this counter for processing /// User should himself take care of calcualting this counter /// </summary> /// <param name="counter"></param> public void AddUserCustomPerfCounter(IPerformanceCounter counter) { countersList.Add(counter.Name, counter); countersListGeneric.Add(counter); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="data"></param> internal void InsertGRData(int id, GRData data) { string s = " INSERT INTO tblGRData(DT, GT1, BT1, GT2, BT2, OT, GTBase2, GP1, BP1, WL, GP2, BP2, I1, I2, IR, S1, S2, SR, OD, PA2, IH1, SH1, CM1, CM2, CM3, RM1, RM2, DeviceID)" + " VALUES(@dt, @gt1, @BT1, @GT2, @BT2, @OT, @GTBase2, @GP1, @BP1, @WL, @GP2, @BP2, @I1, @I2, @IR, @S1, @S2, @SR, @OD, @PA2, @IH1, @SH1, @CM1, @CM2, @CM3, @RM1, @RM2, @DeviceID)"; ListDictionary listDict = new ListDictionary(); listDict.Add("DT", data.DT); listDict.Add("GT1", data.GT1); listDict.Add("BT1", data.BT1); listDict.Add("GT2", data.GT2); listDict.Add("BT2", data.BT2); listDict.Add("OT", data.OT); listDict.Add("GTBase2", data.GTBase2); listDict.Add("GP1", data.GP1); listDict.Add("BP1", data.BP1); listDict.Add("WL", data.WL); listDict.Add("GP2", data.GP2); listDict.Add("BP2", data.BP2); listDict.Add("I1", data.I1); listDict.Add("I2", data.I2); listDict.Add("IR", data.IR); listDict.Add("S1", data.S1); listDict.Add("S2", data.S2); listDict.Add("SR", data.SR); listDict.Add("OD", data.OD); listDict.Add("PA2", data.PA2); listDict.Add("IH1", data.IH1); listDict.Add("SH1", data.SH1); listDict.Add("CM1", data.CM1.PumpStatusEnum); listDict.Add("CM2", data.CM2.PumpStatusEnum); listDict.Add("CM3", data.CM3.PumpStatusEnum); listDict.Add("RM1", data.RM1.PumpStatusEnum); listDict.Add("RM2", data.RM2.PumpStatusEnum); listDict.Add("DeviceID", id); ExecuteScalar(s, listDict); InsertGRAlarmData(id, data.DT, data.Warn.WarnList); }
/// <summary> /// Create email body and send the same to mentioned email id /// </summary> MailMessage CreateMessage(string emailid, string status) { MailDefinition md = new MailDefinition(); if (paymentType.Equals(CSAAWeb.Constants.PC_Payment_CC)) { if (status.Equals(CSAAWeb.Constants.PC_SUCESS)) { md.BodyFileName = CSAAWeb.Constants.PC_UNENROLL_HTML; md.From = Config.Setting("FromAddress"); md.Subject = CSAAWeb.Constants.PC_UNENROLL_SUCCESS; md.Priority = MailPriority.Normal; md.IsBodyHtml = true; EmbeddedMailObject logo = new EmbeddedMailObject(); logo.Path = Server.MapPath(CSAAWeb.Constants.PC_LOGO_PATH); logo.Name = "logo"; md.EmbeddedObjects.Add(logo); EmbeddedMailObject pass = new EmbeddedMailObject(); pass.Path = Server.MapPath(CSAAWeb.Constants.PC_CORRECT_ICON_PATH); pass.Name = CSAAWeb.Constants.PASS_MAIL; md.EmbeddedObjects.Add(pass); EmbeddedMailObject thanks = new EmbeddedMailObject(); thanks.Path = Server.MapPath("/PaymentToolimages/thank-email.jpg"); thanks.Name = "thanks"; md.EmbeddedObjects.Add(thanks); } else { md.BodyFileName = "/PaymentToolimages/CCFailed.html"; md.From = Config.Setting("FromAddress"); md.Subject = "Enrollment Failed"; md.Priority = MailPriority.Normal; md.IsBodyHtml = true; EmbeddedMailObject logo = new EmbeddedMailObject(); logo.Path = Server.MapPath(CSAAWeb.Constants.PC_LOGO_PATH); logo.Name = "logo"; md.EmbeddedObjects.Add(logo); EmbeddedMailObject fail = new EmbeddedMailObject(); fail.Path = Server.MapPath("/PaymentToolimages/cancel-icon.png"); fail.Name = "fail"; md.EmbeddedObjects.Add(fail); } ListDictionary replacements = new ListDictionary(); replacements.Add("<%NAME%>", CCCustomerName.ToString()); replacements.Add("<%DATE%>", DateTime.Now.ToString(CSAAWeb.Constants.FULL_DATE_TIME_FORMAT)); replacements.Add("<%RECEIPT%>", confirmationNumber.ToString()); replacements.Add("<%CARDNO%>", CCNumber.ToString()); replacements.Add("<%POLICY%>", policyNumber.ToString().ToUpper()); //Clearing context Context.Items.Clear(); System.Net.Mail.MailMessage fileMsg; fileMsg = md.CreateMailMessage(emailid, replacements, this); return(fileMsg); } else { if (status.Equals("Success")) { md.BodyFileName = "/PaymentToolimages/email-success-ECheckunenroll.html"; md.From = Config.Setting("FromAddress"); md.Subject = CSAAWeb.Constants.PC_UNENROLL_SUCCESS; md.Priority = MailPriority.Normal; md.IsBodyHtml = true; EmbeddedMailObject logo = new EmbeddedMailObject(); logo.Path = Server.MapPath(CSAAWeb.Constants.PC_LOGO_PATH); logo.Name = "logo"; md.EmbeddedObjects.Add(logo); EmbeddedMailObject pass = new EmbeddedMailObject(); pass.Path = Server.MapPath(CSAAWeb.Constants.PC_CORRECT_ICON_PATH); pass.Name = CSAAWeb.Constants.PASS_MAIL; md.EmbeddedObjects.Add(pass); EmbeddedMailObject thanks = new EmbeddedMailObject(); thanks.Path = Server.MapPath("/PaymentToolimages/thank-email.jpg"); thanks.Name = "thanks"; md.EmbeddedObjects.Add(thanks); } else { md.BodyFileName = "/PaymentToolimages/ECFailed.html"; md.From = Config.Setting("FromAddress"); md.Subject = "Enrollment Failed"; md.Priority = MailPriority.Normal; md.IsBodyHtml = true; EmbeddedMailObject logo = new EmbeddedMailObject(); logo.Path = Server.MapPath(CSAAWeb.Constants.PC_LOGO_PATH); logo.Name = "logo"; md.EmbeddedObjects.Add(logo); EmbeddedMailObject fail = new EmbeddedMailObject(); fail.Path = Server.MapPath("/PaymentToolimages/cancel-icon.png"); fail.Name = "fail"; md.EmbeddedObjects.Add(fail); } string[] EC = ECAccNumber.Split(new char[] { '(', ')' }); ListDictionary replacements = new ListDictionary(); replacements.Add("<%ACCOUNTHOLDNAME%>", ECCustomerName.ToString()); replacements.Add("<%DATE%>", DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt")); replacements.Add("<%RECEIPT%>", confirmationNumber.ToString()); replacements.Add("<%ACCOUNTTYPE%>", EC[1].ToString()); replacements.Add("<%BANKNAME%>", ECBankName.ToString()); replacements.Add("<%ACCOUNTNUMBER%>", EC[0]); replacements.Add("<%POLICYNO%>", policyNumber.ToString().ToUpper()); System.Net.Mail.MailMessage fileMsg; fileMsg = md.CreateMailMessage(emailid, replacements, this); return(fileMsg); } }
static void Main(string[] args) { Car car1 = new Car(); car1.Make = "Oldsmobile"; car1.Model = "Cutlas Supreme"; Car car2 = new Car(); car2.Make = "Geo"; car2.Model = "Prism"; Book book1 = new Book(); book1.Author = "Mark Twain"; book1.Title = "Huckleberry Finn"; book1.ISBN = "0-000-00000-0"; /* OLD COLLECTIONS FRAMEWORKS, SANS COLLECTIONS */ // ArrayList properties (compared to Java) // not synced (same) // dynamically grows in size (same), // but can be explicitly curtailed via Capacity property (has Capacity variable) // maintains insertion order (same) // can access items by index (same) ArrayList bcList = new ArrayList(); bcList.Add(car1); bcList.Add(car2); bcList.Add(book1); // They store everything as an object, however (unless parameterized) foreach (object obj in bcList) { if (obj is Car) { Console.WriteLine(((Car)obj).Make); } else { Console.WriteLine(((Book)obj).Title); } } // ListDictionary: appears to be HashMap-like, taking // key-value pairs and storing things as objects ListDictionary bcListD = new ListDictionary(); bcListD.Add(car1.Make, car1); bcListD.Add(car2.Make, car2); bcListD.Add(book1.Author, book1); // can access objeccts by key Console.WriteLine(((Car)bcListD["Geo"]).Model); // but sine it doesn't use generics os strong typing, we can easily // break it by casting the objects as something else. For instance, // the line below throws an InvalidCastException // Console.WriteLine(((Car)bcListD["Mark Twain"]).Model); /* NEW COLLECTIONS, WITH SUPPORT FOR GENERICS */ // Found in System.Colelctions.Generic, automagically added to "using" // portion above // List is akin to ArrayList List <Car> genCars = new List <Car>(); genCars.Add(car1); genCars.Add(car2); // this throws an error // genCars.Add(book1); // no casting is required foreach (Car car in genCars) { Console.WriteLine(car.Make); } // Dictionary is akin to HashMap Dictionary <String, Car> carDict = new Dictionary <string, Car>(); carDict.Add(car1.Make, car1); carDict.Add(car2.Make, car2); // no casting needed Console.WriteLine(carDict["Geo"].Model); // initializing an array can be done as follows: int[] arrint = { 1, 2, 3, 4 }; // this is known as an object initializer. Thinking of objects as merely // a collection of key-value pairs of properties and their corresponding // values, we can use the same syntax with objects, i.e. Car car3 = new Car() { Make = "Toyota", Model = "Camry" }; Car car4 = new Car() { Make = "Nissan", Model = "Altima" }; Car car5 = new Car() { Make = "Nissan", Model = "Sentra" }; // Collection initializers are the equivalent code for collections. List <Car> carList = new List <Car>() { new Car() { Make = "BMW", Model = "745-i" }, // notice the commas at the end new Car() { Make = "Honda", Model = "Accord" }, new Car() { Make = "Audi", Model = "A1" } // except for the last entry }; // check if the dictionary allows duplicate keys with different values. // Both car4 and car5 are Nissans. carDict.Add(car4.Make, car4); // carDict.Add(car5.Make, car5); // Nope. ArgumentException thrown, since item with same key is already present // To iterate through a Dictionary, use the KeyValuePair object; // alternatively, use var, if you hate programmers foreach (KeyValuePair <string, Car> item in carDict) { Console.WriteLine(item); } // check if lists allow duplicate entries. carList.Add(new Car() { Make = "Honda", Model = "Accord" }); foreach (Car car in carList) { Console.WriteLine(car); } Console.ReadLine(); }
public static void Add_NullKeyTest(ListDictionary ld, KeyValuePair <string, string>[] data) { Assert.Throws <ArgumentNullException>("key", () => ld.Add(null, "value")); Assert.Throws <ArgumentNullException>("key", () => ld[null] = "value"); }
public void InsertCallRecords(Obj.CallRecords obj) { try { parameters.Add(new SqlParameter("@CallDateTime", SqlDbType.DateTime), obj.CallDateTime); parameters.Add(new SqlParameter("@ContactID", SqlDbType.Int), obj.ContactID); parameters.Add(new SqlParameter("@CallingPerson", SqlDbType.VarChar, 50), obj.CallingPerson); parameters.Add(new SqlParameter("@CompanyName", SqlDbType.VarChar, 50), obj.CompanyName); parameters.Add(new SqlParameter("@CallingNo", SqlDbType.VarChar, 20), obj.CallingNo); parameters.Add(new SqlParameter("@CategoryID", SqlDbType.TinyInt), obj.CategoryID); parameters.Add(new SqlParameter("@CallDetail", SqlDbType.VarChar, 200), obj.CallDetail); parameters.Add(new SqlParameter("@IsOutgoing", SqlDbType.Bit), obj.IsOutgoing); if (obj.City == "") { parameters.Add(new SqlParameter("@City", SqlDbType.VarChar, 50), null); } else { parameters.Add(new SqlParameter("@City", SqlDbType.VarChar, 50), obj.City); } parameters.Add(new SqlParameter("@CallStatus", SqlDbType.VarChar, 20), obj.CallStaus); new Database().ExecuteNonQueryOnly("Sp_Insert_CallRecords", parameters); } catch (Exception ex) { throw ex; } }
private static void StartHelper(NetworkAddressChangedEventHandler caller, bool captureContext, StartIPOptions startIPOptions) { lock (globalLock) { // setup changedEvent and native overlapped struct. if (s_ipv4Socket == null) { Socket.InitializeSockets(); int blocking; if (Socket.OSSupportsIPv4) { blocking = -1; s_ipv4Socket = SafeCloseSocketAndEvent.CreateWSASocketWithEvent(AddressFamily.InterNetwork, SocketType.Dgram, (ProtocolType)0, true, false); UnsafeNclNativeMethods.OSSOCK.ioctlsocket(s_ipv4Socket, IoctlSocketConstants.FIONBIO, ref blocking); s_ipv4WaitHandle = s_ipv4Socket.GetEventHandle(); } if (Socket.OSSupportsIPv6) { blocking = -1; s_ipv6Socket = SafeCloseSocketAndEvent.CreateWSASocketWithEvent(AddressFamily.InterNetworkV6, SocketType.Dgram, (ProtocolType)0, true, false); UnsafeNclNativeMethods.OSSOCK.ioctlsocket(s_ipv6Socket, IoctlSocketConstants.FIONBIO, ref blocking); s_ipv6WaitHandle = s_ipv6Socket.GetEventHandle(); } } if ((caller != null) && (!s_callerArray.Contains(caller))) { s_callerArray.Add(caller, captureContext ? ExecutionContext.Capture() : null); } //if s_listener is not null, it means we are already actively listening if (s_isListening || s_callerArray.Count == 0) { return; } if (!s_isPending) { int length; SocketError errorCode; if (Socket.OSSupportsIPv4 && (startIPOptions & StartIPOptions.StartIPv4) != 0) { s_registeredWait = ThreadPool.UnsafeRegisterWaitForSingleObject( s_ipv4WaitHandle, new WaitOrTimerCallback(AddressChangedCallback), StartIPOptions.StartIPv4, -1, true); errorCode = (SocketError)UnsafeNclNativeMethods.OSSOCK.WSAIoctl_Blocking( s_ipv4Socket.DangerousGetHandle(), (int)IOControlCode.AddressListChange, null, 0, null, 0, out length, SafeNativeOverlapped.Zero, IntPtr.Zero); if (errorCode != SocketError.Success) { NetworkInformationException exception = new NetworkInformationException(); if (exception.ErrorCode != (uint)SocketError.WouldBlock) { throw exception; } } errorCode = (SocketError)UnsafeNclNativeMethods.OSSOCK.WSAEventSelect(s_ipv4Socket, s_ipv4Socket.GetEventHandle().SafeWaitHandle, AsyncEventBits.FdAddressListChange); if (errorCode != SocketError.Success) { throw new NetworkInformationException(); } } if (Socket.OSSupportsIPv6 && (startIPOptions & StartIPOptions.StartIPv6) != 0) { s_registeredWait = ThreadPool.UnsafeRegisterWaitForSingleObject( s_ipv6WaitHandle, new WaitOrTimerCallback(AddressChangedCallback), StartIPOptions.StartIPv6, -1, true); errorCode = (SocketError)UnsafeNclNativeMethods.OSSOCK.WSAIoctl_Blocking( s_ipv6Socket.DangerousGetHandle(), (int)IOControlCode.AddressListChange, null, 0, null, 0, out length, SafeNativeOverlapped.Zero, IntPtr.Zero); if (errorCode != SocketError.Success) { NetworkInformationException exception = new NetworkInformationException(); if (exception.ErrorCode != (uint)SocketError.WouldBlock) { throw exception; } } errorCode = (SocketError)UnsafeNclNativeMethods.OSSOCK.WSAEventSelect(s_ipv6Socket, s_ipv6Socket.GetEventHandle().SafeWaitHandle, AsyncEventBits.FdAddressListChange); if (errorCode != SocketError.Success) { throw new NetworkInformationException(); } } } s_isListening = true; s_isPending = true; } }
/** * CLIENT - SEND INVOICE SUCCESSFUL * Send email to client on payment success */ public string SendMailClientInvoice(int jobId, string renterMail, string mailType, string renterName, string site) { try { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("mail.realwheelsdavao.com"); //smtp server MailDefinition md = new MailDefinition(); md.From = "*****@*****.**"; //sender mail md.IsBodyHtml = true; //set true to enable use of html tags md.Subject = "RealWheels Reservation"; //mail title ListDictionary replacements = new ListDictionary(); replacements.Add("{name}", "Martin"); replacements.Add("{unit}", "Honda City"); replacements.Add("{tour}", "City Tour"); replacements.Add("{type}", "w/ Driver"); replacements.Add("{days}", "2"); replacements.Add("{total}", "5500"); string body, message; string siteName = site; //get job details //send email in /joborder JobMain job = db.JobMains.Find(jobId); //mail title md.Subject = "Realwheels Payment"; //mail content for client inquiries string jobDesc = System.Web.HttpUtility.UrlPathEncode(job.Description); message = "Good day, please follow the link for the invoice and payment of your reservation. <a href='" + siteName + "" + jobId + "/" + job.JobDate.Month + "/" + job.JobDate.Day + "/" + job.JobDate.Year + "/" + jobDesc + "/' " + "> View Invoice </a> "; //" style='display:block;background-color:dodgerblue;margin:20px;padding:20px;text-decoration:none;font-weight:bolder;font-size:300;color:white;border-radius:3px;min-width:100px;'> View Invoice </a> "; body = "" + // " <p>Hello {name}, You have booked a {tour} and {unit} {type} for {days} day(s). The total cost of the package is {total}. </p>" + " <div style='background-color:#f4f4f4;padding:20px' align='center'>" + " <div style='background-color:white;min-width:200px;margin:20px;padding:30px;text-align:center;color:#555555;font:normal 300 16px/21px 'Helvetica Neue',Arial'> <h1> Reservation Invoice </h1>" + message + " <p> This is an auto-generated email. DO NOT REPLY TO THIS MESSAGE </p> " + " <p> For further inquiries kindly email us through [email protected] or dial(+63) 82 297 1831. </p> " + " </div></div>" + ""; MailMessage msg = md.CreateMailMessage(renterMail, replacements, body, new System.Web.UI.Control()); SmtpServer.Port = 587; //default smtp port SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Real123!"); SmtpServer.EnableSsl = false; //enable for gmail smtp server System.Net.ServicePointManager.Expect100Continue = false; SmtpServer.Send(msg); //send message return("success"); } catch (Exception ex) { return("error: " + ex); } }
static Hour() { values = new ListDictionary(); values.Add(Zero.Code, Zero); values.Add(One.Code, One); values.Add(Two.Code, Two); values.Add(Three.Code, Three); values.Add(Four.Code, Four); values.Add(Five.Code, Five); values.Add(Six.Code, Six); values.Add(Seven.Code, Seven); values.Add(Eight.Code, Eight); values.Add(Nine.Code, Nine); values.Add(Ten.Code, Ten); values.Add(Eleven.Code, Eleven); values.Add(Twelve.Code, Twelve); values.Add(Thirteen.Code, Thirteen); values.Add(Fourteen.Code, Fourteen); values.Add(Fifteen.Code, Fifteen); values.Add(Sixteen.Code, Sixteen); values.Add(Seventeen.Code, Seventeen); values.Add(Eighteen.Code, Eighteen); values.Add(Nineteen.Code, Nineteen); values.Add(Twenty.Code, Twenty); values.Add(TwentyOne.Code, TwentyOne); values.Add(TwentyTwo.Code, TwentyTwo); values.Add(TwentyThree.Code, TwentyThree); }
public string SendMail(int jobId, string renterMail, string mailType, string renterName, string site) { try { // configure mail server MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("mail.realwheelsdavao.com"); //smtp server //create email MailDefinition md = new MailDefinition(); // md.From = "*****@*****.**"; //sender mail md.From = "*****@*****.**"; //sender mail md.IsBodyHtml = true; //set true to enable use of html tags md.Subject = "RealWheels Reservation"; //mail title ListDictionary replacements = new ListDictionary(); replacements.Add("{name}", "Reservation"); string body, message; string siteName = site; //get job details JobMain job = db.JobMains.Find(jobId); //encode white space string jobDesc = System.Web.HttpUtility.UrlPathEncode(job.Description); md.Subject = renterName + ": NEW RealWheels Reservation"; //mail title switch (mailType) { case "ADMIN": //mail title md.Subject = renterName + ": Reservation "; //find reservation CarReservation reserve = db.CarReservations.Find(jobId); //email content message = "A NEW Reservation Inquiry has been made. Please follow the link for the reservation details. <a href='" + siteName + "" + jobId + "/" + reserve.DtTrx.Month + "/" + reserve.DtTrx.Day + "/" + reserve.DtTrx.Year + "/" + reserve.RenterName + "/' " + "> View Reservation Details </a> "; break; case "PAYMENT-SUCCESS": //mail content for successful payment //mail title md.Subject = renterName + ": Reservation "; //find reservation reserve = db.CarReservations.Find(jobId); //email content message = "Paypal Payment is successful. Please follow the link for the invoice details. <a href='" + siteName + "" + jobId + "/" + reserve.DtTrx.Month + "/" + reserve.DtTrx.Day + "/" + reserve.DtTrx.Year + "/" + reserve.RenterName + "/' " + "> View Invoice Details </a> "; break; case "PAYMENT-DENIED": //mail content for denied payment //mail title md.Subject = renterName + ": Reservation "; //find reservation reserve = db.CarReservations.Find(jobId); //email content message = "Paypal Payment have been DENIED. Please follow the link for the invoice details. <a href='" + siteName + "" + jobId + "/" + reserve.DtTrx.Month + "/" + reserve.DtTrx.Day + "/" + reserve.DtTrx.Year + "/" + reserve.RenterName + "/' " + "> View Invoice Details </a> "; break; case "PAYMENT-PENDING": //mail content for pending payment //mail title md.Subject = renterName + ": Reservation "; //find reservation reserve = db.CarReservations.Find(jobId); //email content message = "Paypal Payment has been sent. Please follow the link for the invoice details. <a href='" + siteName + "" + jobId + "/" + reserve.DtTrx.Month + "/" + reserve.DtTrx.Day + "/" + reserve.DtTrx.Year + "/" + reserve.RenterName + "/' " + "> View Invoice </a> "; break; case "CLIENT-PENDING": //mail title md.Subject = "Realwheels Reservation"; reserve = db.CarReservations.Find(jobId); //mail content for pending payment message = "We are happy to recieved your inquiry. We will contact you after we have processed your reservation. Please click the link below for your reservation details, Thank you. <a href='" + siteName + "" + jobId + "/" + reserve.DtTrx.Month + "/" + reserve.DtTrx.Day + "/" + reserve.DtTrx.Year + "/" + reserve.RenterName + "/' " + "> View Booking Details </a> "; break; case "CLIENT-INQUIRY": //Client Inquiry //mail title md.Subject = "Realwheels Reservation"; //find reservation reserve = db.CarReservations.Find(jobId); //mail content for pending payment message = "We are happy to recieved your inquiry. We will contact you after we have" + " processed your reservation. Please click the link below for your reservation details," + " Thank you.<br> <a href='" + siteName + "" + jobId + "/" + reserve.DtTrx.Month + "/" + reserve.DtTrx.Day + "/" + reserve.DtTrx.Year + "/" + reserve.RenterName + "/' " + "> View Booking Details </a> "; break; case "CLIENT-INVOICE-SEND": //mail title md.Subject = "Realwheels Invoice"; //find reservation reserve = db.CarReservations.Find(jobId); //mail content for pending payment message = "Good day, please follow the link for the invoice and payment of your reservation." + "<br> <a href='" + siteName + "" + jobId + "/" + job.JobDate.Month + "/" + job.JobDate.Day + "/" + job.JobDate.Year + "/" + jobDesc + "/' " + "> View Invoice </a> "; break; case "CLIENT-PAYMENT-SUCCESS": //mail title md.Subject = "Realwheels Payment"; //find reservation reserve = db.CarReservations.Find(jobId); //mail content for pending payment message = "Thank you for your payment. Please follow the link for the invoice and payment." + "<br> <a href='" + siteName + "" + jobId + "/" + job.JobDate.Month + "/" + job.JobDate.Day + "/" + job.JobDate.Year + "/" + jobDesc + "/' " + "> View Invoice </a> "; break; case "ADMIN-INVOICE-SENT": //mail title md.Subject = job.Description + " Invoice Sent"; //mail content for client inquiries message = " An invoice link has been sent to " + job.Description + ". Please follow the link" + " for the invoice and payment.<br> <a href='" + siteName + "" + jobId + "/" + job.JobDate.Month + "/" + job.JobDate.Day + "/" + job.JobDate.Year + "/" + jobDesc + "/' " + "> View Invoice </a> "; break; case "ADMIN-PAYMENT-SUCCESS": //mail title md.Subject = job.Description + " Payment Success"; //mail content for client inquiries message = "A New Payment has been made. Please follow the link for the invoice and payment.<br>" + " <a href='" + siteName + "" + jobId + "/" + job.JobDate.Month + "/" + job.JobDate.Day + "/" + job.JobDate.Year + "/" + jobDesc + "/' " + "> View Invoice </a> "; break; default: //new reservation //send email in /joborder md.Subject = "Realwheels Reservation"; //mail content for client inquiries message = " Your inquiry have been processed to confirm your reservation, please follow the link" + "for the invoice and payment. <a href='" + siteName + "" + jobId + "/" + job.JobDate.Month + "/" + job.JobDate.Day + "/" + job.JobDate.Year + "/" + jobDesc + "/' " + "> View Booking Details </a> "; //" style='display:block;background-color:dodgerblue;margin:20px;padding:20px;text-decoration:none;font-weight:bolder;font-size:300;color:white;border-radius:3px;min-width:100px;'> View Booking Details </a> "; break; } body = "" + " <div style='background-color:#f4f4f4;padding:20px' align='center'>" + " <div style='background-color:white;min-width:200px;margin:30px;padding:30px;text-align:center;color:#555555;font:normal 300 16px/21px 'Helvetica Neue',Arial'> <h1> RealWheels Car Reservation </h1>" + message + " <p> This is an auto-generated email. DO NOT REPLY TO THIS MESSAGE </p> " + " <p> For further inquiries kindly email us through [email protected] or dial(+63) 82 297 1831. </p> " + " </div></div>" + ""; MailMessage msg = md.CreateMailMessage(renterMail, replacements, body, new System.Web.UI.Control()); SmtpServer.Port = 587; //default smtp port SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Real123!"); SmtpServer.EnableSsl = false; //enable for gmail smtp server System.Net.ServicePointManager.Expect100Continue = false; SmtpServer.Send(msg); //send message return("success"); } catch (Exception ex) { return("error: " + ex); } }
public static bool SendEmailChangeStatus(Statement statement) { if (statement == null) { return(false); } var status = statement.StatementStatuses.LastOrDefault(); if (status == null) { return(false); } User AssignedToUser = new User(); if (status.StatusID != 1) { AssignedToUser = ReferencesProvider.GetUser(status.AssignedToUserID.Value); } List <SelectListItem> coordinators = ReferencesProvider.GetCoordinators(); List <ReferenceItem> listStatus = ReferencesProvider.GetReferenceItems(Constants.RefStatus); MailDefinition md = new MailDefinition(); md.From = "*****@*****.**"; md.IsBodyHtml = true; md.Subject = "Портал регистрации обращений"; ListDictionary replacements = new ListDictionary(); replacements.Add("{fio}", AssignedToUser?.Fullname); replacements.Add("{StatementID}", statement.Id.ToString()); replacements.Add("{status}", listStatus.Where(a => a.Id == status.StatusID).Select(b => b.Name).FirstOrDefault().ToString()); replacements.Add("{ExecuteToDate}", status.ExecuteToDate == null ? string.Empty : status.ExecuteToDate.Value.ToShortDateString()); replacements.Add("{CreateDate}", statement.CreateDate.ToShortDateString()); replacements.Add("{fioClient}", statement.Lastname + " " + statement.Firstname + " " + statement.Secondname); string body = string.Empty; body = body + "<div>Уважаемый сотрудник, {fio}.</div>" + Environment.NewLine; body = body + "<div> </div>" + Environment.NewLine; body = body + "<div>В системе регистрации обращений клиентов на Вас назначена заявка <a href=\" dev_complaint.uralsibins.ru/Home/Statement?id={StatementID}\">№{StatementID}</a></div>" + Environment.NewLine; body = body + "<div>Установлен новый статус: [{status}]</div>" + Environment.NewLine; body = body + "<div><b>Необходимо рассмотреть до {ExecuteToDate}</b></div>" + Environment.NewLine; body = body + "<div>Дата создания заявки {CreateDate}</div>" + Environment.NewLine; body = body + "<div>Клиент: {fioClient}</div>" + Environment.NewLine; body = body + "<div> </div>" + Environment.NewLine; body = body + "<div>С уважением,</div>" + Environment.NewLine; body = body + "<div>Система регистрации заявок.</div>" + Environment.NewLine; //smtp.uralsibins.ru - можно отправлять без авторизации SmtpClient Smtp = new SmtpClient("smtp.uralsibins.ru", 25); if (!string.IsNullOrEmpty(AssignedToUser.Email)) { MailMessage msg = md.CreateMailMessage(AssignedToUser.Email.Trim(' ', ','), replacements, body, new System.Web.UI.Control()); Smtp.Send(msg); } if (status.StatusID == 1) { foreach (var item in coordinators) { if (!string.IsNullOrEmpty(item.Value)) { MailMessage msgs = md.CreateMailMessage(item.Value.Trim(' ', ','), replacements, body, new System.Web.UI.Control()); Smtp.Send(msgs); } } } return(true); }
public void AddThrowsIfKeyNull() { var ex = Assert.Throws <ArgumentNullException>(() => { list.Add(null, new object()); }); }
public IActionResult SendMail(MailData em) { // Mail send section string to = em.To; string subject = em.Subject; MailMessage mm = new MailMessage(); StringBuilder mailBody = new StringBuilder(); ListDictionary replacements = new ListDictionary(); replacements.Add("{hashlink}", GetHashString(to)); string encryptedstring = SimplerAES.Encrypt(to); string appUrl = $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}"; string verifyUrl = appUrl + "/Login/UserVerification?GetCrypto=" + encryptedstring + "&M=" + to; string body = "<div style='font-family:Arial,sans-serif;height:100%;margin:0;padding:0;min-width:100%;width:100%!important;word-break:break-word;background-color:#ffffff'>" + "<center style='font-family:Arial,sans-serif'>" + "<img src='./Fwd_ Welcome to STC Digital Securities Transfer Platform - [email protected] - Gmail_files/bhEjQ3CuIzwtd2NcRgHo6egDVx84yjhji4_XmrJd_4UKMeRSYSlUXEpxRA8IOzSNaL6s7CrVEJQQ1ztfFGsVG4KYqQE4aw=s0-d-e1-ft' alt='STC Digital Securities' style='font-family:Arial,sans-serif;border:0;border-radius:0.2em;width:10%;min-width:40px;max-width:80px class='CToWUd'>" + "<table style='font-family:Arial,sans-serif;width:98%;background-color:#ffffff;border:0.05em #dce1e6 solid;border-bottom:0;border-radius:0.2em;border-spacing:0;margin:1%;padding:2%;max-width:800px;min-width:320px'>" + "<tbody>" + "<tr style='padding:0'>" + "<td align='center' style = 'font-family:Arial,sans-serif;padding:1.3em .65em'>" + "<table cellpadding='0' cellspacing='0' border='0' style='font-family:Arial,sans-serif;width:100%'>" + "<tbody>" + "<tr style='padding:0'>" + "<td align='center' style='font-family:Arial,sans-serif;padding:1.3em .65em'>" + "<h1 style='font-family:Arial,sans-serif;font-size:2em;font-weight:normal;color:#021d49'>Verify your email address</h1>" + "<h1 style='font-family:Arial,sans-serif;font-size:2em;font-weight:normal;color:#021d49'>Dear {email}</h1>" + "<hr style='font-family:Arial,sans-serif;border:0.03em #b8c2cc solid;max-width:50%'>" + "</td></tr></tbody></table>" + "<p style='font-family:Arial,sans-serif;font-size:1em;font-weight:normal;line-height:2em;color:#021d49'>" + "In order to get started, you need to verify your email address.<br>" + "Please click the button below to activate your account." + "</p><table cellpadding='0' cellspacing='0' border='0' style='font-family:Arial,sans-serif;width:100%'>" + "<tbody><tr style='padding:0'>" + "<td align='center' style='font-family:Arial,sans-serif;padding:1.3em .65em'>" + "<a href='" + verifyUrl + "' style='font-family:Arial,sans-serif;padding:0.8em;border:0;border-radius:0.15em;color:#dde5ed;font-size:1.2em;font-weight:bold;display:inline-block;text-decoration:none;background-color:#753bbd' target='_blank' data-saferedirecturl='https://www.google.com/url?q=https://u6499205.ct.sendgrid.net/ls/click?upn%3DVUi6vtiYq6Dke21-2BFPsFP-2F0H1DarKXFNoBO3yxpk-2FutF-2FA0aFvaXu2VN8DX-2FfiEyrxjCHmfo9qPNVstwcb84hgsjdVvV2cYFTqhmh8k2uCzGiA2j7T3yv0fClUoTU4-2FKHWVY-2F1R-2BmMPK6TeLu2bLxw-3D-3Dc2Y3_p3SVlCDbKSLRLli1GKmEeVVMyM0p8JQlVUwTygYVI-2Fi29ZjgcvOzCoDXzTKic-2F92zaNoixbOAYj9pkKW8piaz8nU3fVvPwxsGyBRsRIm4uwBIzZjKicUYgKN0vFSqBnssNebBc3Cksd5YVE-2B-2BkqH2m6F7ZrX4As-2B-2BYB-2BSeq38jJ08clcMSvF4akmCHjz5Ci866MJCw2AKMDgHORAEilcFkIgo7M-2BiPQU7N0-2B63M-2Bp8c-3D&source=gmail&ust=1594995475240000&usg=AFQjCNFuHxCWBKEGDICZZyCROI6SFxkf3w'>Verify my email address</a>" + "</td></tr></tbody></table>" + "<hr style='font-family:Arial,sans-serif;border:0.03em #b8c2cc solid;max-width:50%'>" + "<br><strong style='font-family:Arial,sans-serif;font-size:1em;font-weight:bold;color:#021d49'>Your verification key is</strong>" + "<table width='100%' cellpadding='0' cellspacing='0'style='font-family:Arial,sans-serif;width:100%;background-color:#dce1e6'><tbody><tr style='padding:0'>" + "<td align='center' style='font-family:Arial,sans-serif;padding:0'>" + "<p style='font-family:Arial,sans-serif;background-color:#dce1e6'></p>" + "<p style='font-family:Arial,sans-serif'>{hashlink}</p>" + "</td></tr></tbody></table>" + "<table cellpadding='0' cellspacing='0' border='0' style='font-family:Arial,sans-serif;width:100%'><tbody><tr style='padding:0'>" + "<td align='center' style='font-family:Arial,sans-serif;padding:1.3em .65em'>" + "<p style='font-family:Arial,sans-serif'><em style='font-family:Arial,sans-serif;font-size:0.8em;font-weight:normal;line-height:1.6em;color:#697080;font-style:normal'>If you did not sign up for this account<br>you can ignore this email and the account will be deleted.</em></p>" + "</td></tr></tbody></table>" + "<table cellpadding='0' cellspacing='0' bordVerier='0' style='font-family:Arial,sans-serif;width:100%'><tbody><tr style='padding:0'>" + "<td align='center' style='font-family:Arial,sans-serif;padding:1.3em .65em'>" + "<em style='font-family:Arial,sans-serif;font-size:0.8em;font-weight:normal;line-height:1.6em;color:#697080;font-style:normal'><a href='https://mail.google.com/mail/u/0/#m_3102665213440501867_m_-2437924468448491603_' style='font-family:Arial,sans-serif;font-size:1em;color:#753bbd;text-decoration:none'>STC Digital Securities</a><br>2901 N Dallas Parkway Suite 380<br>Plano, Texas 75093</em>" + "</td></tr></tbody></table>" + "<table cellpadding='0' cellspacing='0' border='0' style='font-family:Arial,sans-serif;width:100%'><tbody><tr style='padding:0'><td align='center' style='font-family:Arial,sans-serif;padding:1.3em .65em'>" + "<span style='font-family:Arial,sans-serif;color:#28334a;font-size:1.3em'>ℹ</span><em style='font-family:Arial,sans-serif;font-size:0.8em;font-weight:normal;line-height:1.6em;color:#697080;font-style:normal'> This email and any files and info transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. Please notify the sender immediately if you have received this e-mail by mistake, then delete it.</em>" + "</td></tr></tbody></table></td></tr>" + "</tbody>" + "</table>" + "</center>" + "<img src='./Fwd_ Welcome to STC Digital Securities Transfer Platform - [email protected] - Gmail_files/unnamed.gif' alt='' width='1' height='1' border='0' style='height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important' class='CToWUd'></div><div class='yj6qo'></div><div class='adL'>" + "</div>"; // string body = "<div><a href=''https://*****:*****@gmail.com"); mm.IsBodyHtml = true; mm.Subject = "Creosafe Mail Aktivasyonu"; SmtpClient smtp = new SmtpClient("smtp.gmail.com"); smtp.Port = 587; smtp.UseDefaultCredentials = true; smtp.EnableSsl = true; smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "19982929291903"); smtp.Send(mm); ViewBag.message = "Bu maili " + em.To + "gönderdi "; //hash1 = GetHashString(to); //mail1 = to; return(View()); }
public void LoadData() { // var cls = new clsDM_LoaiCV(); var dt = new DataTable(); cls.ID_DonVi = int.Parse(cmbDonVi.EditValue.ToString()); dt = cls.SelectAll_TheoDonVi(); // fg.BeginUpdate(); fg.Cols["ID_LoaiCV_Cha"].DataMap = null; fg.ClearRows(); foreach (DataRow dr in dt.Rows) { var fgRow = fg.Rows.Add(); fgRow["ID_LoaiCV"] = dr["ID_LoaiCV"]; fgRow["Ten_LoaiCV"] = dr["Ten_LoaiCV"]; fgRow["ID_LoaiCV_Cha"] = dr["ID_LoaiCV_Cha"]; fgRow["TonTai"] = dr["TonTai"]; fgRow["SuDung"] = dr["SuDung"]; fgRow["ID_DonVi"] = dr["ID_DonVi"]; fgRow["STT_LoaiCV"] = dr["STT_LoaiCV"]; } //add combobox column //Add Node 0 công việc con for (var r = fg.Rows.Fixed; r < fg.Rows.Count; ++r) { fg.Rows[r].Visible = false; fg.Rows.InsertNode(r + 1, 0); GetDataTwoRow(r + 1, r); ++r; } for (var r = fg.Rows.Fixed; r < fg.Rows.Count; r++) { if (!fg.Rows[r].Visible) { fg.Rows.Remove(r); r = r - 1; } } // for (var r = fg.Rows.Fixed; r < fg.Rows.Count; ++r) { if (fg.Rows[r].Node.Level == 0 && fg.Rows[r].Visible && IsNode0(r)) { r = TimCongViecGoc(r, 1); } } var level = 1; while (TonTaiCongViecGoc(level)) { for (var r1 = fg.Rows.Fixed; r1 < fg.Rows.Count; ++r1) { if (fg.Rows[r1].Node.Level == level && fg.Rows[r1].Visible) { r1 = TimCongViecGoc(r1, level + 1); } } ++level; } fg.Tree.Column = 1; //////// for (var r = fg.Rows.Fixed; r < fg.Rows.Count; ++r) { if (!fg.Rows[r].Visible) { fg.Rows.Remove(r); --r; } } SetSTT(); fg.Tree.Show(0); var clsCha = new clsDM_LoaiCV(); dt = clsCha.SelectAll(); dt.DefaultView.RowFilter = "TonTai = 1"; dt = dt.DefaultView.ToTable(); var drow = dt.NewRow(); drow["ID_LoaiCV"] = 0; drow["Ten_LoaiCV"] = ""; dt.Rows.Add(drow); dt.DefaultView.Sort = "Ten_LoaiCV ASC"; //add datamap var datamap = new ListDictionary(); for (var i = 0; i <= dt.DefaultView.ToTable().Rows.Count - 1; i++) { datamap.Add(dt.DefaultView.ToTable().Rows[i][0], dt.DefaultView.ToTable().Rows[i][1]); } fg.Cols["ID_LoaiCV_Cha"].DataMap = datamap; fg.EndUpdate(); }
public TypeSelectionForm() { // // Required for Windows Form Designer support // InitializeComponent(); radioButtonToQuestionType.Add(radioMixed, QuestionType.CreateMixed()); radioButtonToQuestionType.Add(radioQauantitative, new QuestionType(QuestionType.Type.Quantitative)); radioButtonToQuestionType.Add(radioVerbal, new QuestionType(QuestionType.Type.Verbal)); radioButtonToQuestionType.Add(radioAlgebra, new QuestionType(BuisinessObjects.Subtype.Algebra)); radioButtonToQuestionType.Add(radioArithmetic, new QuestionType(BuisinessObjects.Subtype.Arithmetic)); radioButtonToQuestionType.Add(radioCombinations, new QuestionType(BuisinessObjects.Subtype.Combinations)); radioButtonToQuestionType.Add(radioCriticalReasoning, new QuestionType(BuisinessObjects.Subtype.CriticalReasoning)); radioButtonToQuestionType.Add(radioGeometry, new QuestionType(BuisinessObjects.Subtype.Geometry)); radioButtonToQuestionType.Add(radioProbability, new QuestionType(BuisinessObjects.Subtype.Probability)); radioButtonToQuestionType.Add(radioSentenceCorrection, new QuestionType(BuisinessObjects.Subtype.SentenceCorrection)); radioButtonToQuestionType.Add(radioStatistics, new QuestionType(BuisinessObjects.Subtype.Statistics)); radioButtonToQuestionType.Add(radioWordProblems, new QuestionType(BuisinessObjects.Subtype.WordProblems)); radioButtonToQuestionType.Add(radioReadingComprehension, new QuestionType(BuisinessObjects.Subtype.ReadingComprehensionQuestionToPassage)); //radioButtonToQuestionType.Add(radioCriticalReasoning, // new QuestionType(BuisinessObjects.Subtype.CriticalReasoning)); //radioButtonToQuestionType.Add(radioSentenceCorrection, // new QuestionType(BuisinessObjects.Subtype.SentenceCorrection)); foreach (DictionaryEntry e in radioButtonToQuestionType) { questionTypeToRadioButton.Add(e.Value, e.Key); } BaseQuestionType = QuestionType.CreateMixed(); QuestionType = QuestionType.CreateMixed(); }
// This stores the map options in a configuration internal void WriteConfiguration(string settingsfile) { Configuration wadcfg; // Write resources to config resources.WriteToConfig(mapconfig, "resources"); //mxd. Save selection groups General.Map.Map.WriteSelectionGroups(mapconfig); //mxd. Save Tag Labels if (tagLabels.Count > 0) { ListDictionary tagLabelsData = new ListDictionary(); int counter = 1; foreach (KeyValuePair <int, string> group in tagLabels) { ListDictionary data = new ListDictionary(); data.Add("tag", group.Key); data.Add("label", group.Value); tagLabelsData.Add("taglabel" + counter, data); counter++; } mapconfig.WriteSetting("taglabels", tagLabelsData); } //mxd. Write Sector drawing options mapconfig.WriteSetting("defaultfloortexture", defaultfloortexture); mapconfig.WriteSetting("defaultceiltexture", defaultceiltexture); mapconfig.WriteSetting("defaulttoptexture", defaulttoptexture); mapconfig.WriteSetting("defaultwalltexture", defaultwalltexture); mapconfig.WriteSetting("defaultbottomtexture", defaultbottomtexture); mapconfig.WriteSetting("custombrightness", custombrightness); mapconfig.WriteSetting("customfloorheight", customfloorheight); mapconfig.WriteSetting("customceilheight", customceilheight); //mxd. Write Sector drawing overrides mapconfig.WriteSetting("overridefloortexture", overridefloortexture); mapconfig.WriteSetting("overrideceiltexture", overrideceiltexture); mapconfig.WriteSetting("overridetoptexture", overridetoptexture); mapconfig.WriteSetting("overridemiddletexture", overridemiddletexture); mapconfig.WriteSetting("overridebottomtexture", overridebottomtexture); mapconfig.WriteSetting("overridefloorheight", overridefloorheight); mapconfig.WriteSetting("overrideceilheight", overrideceilheight); mapconfig.WriteSetting("overridebrightness", overridebrightness); //mxd mapconfig.WriteSetting("uselongtexturenames", uselongtexturenames); //mxd. Position and scale mapconfig.WriteSetting("viewpositionx", General.Map.Renderer2D.OffsetX); mapconfig.WriteSetting("viewpositiony", General.Map.Renderer2D.OffsetY); mapconfig.WriteSetting("viewscale", General.Map.Renderer2D.Scale); //mxd. Write script compiler if (!string.IsNullOrEmpty(scriptcompiler)) { mapconfig.WriteSetting("scriptcompiler", scriptcompiler); } // Write grid settings General.Map.Grid.WriteToConfig(mapconfig, "grid"); //mxd. Write script files settings to config mapconfig.DeleteSetting("scriptfiles"); foreach (ScriptDocumentSettings settings in scriptfilesettings.Values) { WriteScriptDocumentSettings(mapconfig, "scriptfiles.file", settings); } //mxd. Write script lumps settings to config mapconfig.DeleteSetting("scriptlumps"); foreach (ScriptDocumentSettings settings in scriptlumpsettings.Values) { WriteScriptDocumentSettings(mapconfig, "scriptlumps.lump", settings); } // Load the file or make a new file if (File.Exists(settingsfile)) { wadcfg = new Configuration(settingsfile, true); } else { wadcfg = new Configuration(true); } // Write configuration type information wadcfg.WriteSetting("type", "Doom Builder Map Settings Configuration"); wadcfg.WriteSetting("gameconfig", configfile); wadcfg.WriteSetting("strictpatches", General.Bool2Int(strictpatches)); // Update the settings file with this map configuration wadcfg.WriteSetting("maps." + currentname, mapconfig.Root); // Save file wadcfg.SaveConfiguration(settingsfile); }
private void SendPDFEmail(DataTable dt) { using (StringWriter sw = new StringWriter()) { using (HtmlTextWriter hw = new HtmlTextWriter(sw)) { string companyName = "Online Book Shop"; int orderNo = 1111; string email = "Email"; string desc = "Description"; string name = "Book Name"; StringBuilder sb = new StringBuilder(); sb.Append("<br /><br />"); sb.Append("<table width='100%' cellspacing='0' cellpadding='2'>"); sb.Append("<tr><td align='center' style='background-color: #18B5F0' colspan = '2'><b>Donation Sleep</b></td></tr>"); sb.Append("<tr><td colspan = '2'></td></tr>"); sb.Append("<tr><td><b>Order No:</b>"); sb.Append(orderNo); sb.Append("</td><td><b>Date: </b>"); sb.Append(DateTime.Now); sb.Append(" </td></tr>"); sb.Append("<tr><td colspan = '2'><b>Company Name :</b> "); sb.Append(companyName); sb.Append("</td></tr>"); sb.Append("</table>"); sb.Append("<br />"); sb.Append("<table border = '1'>"); sb.Append("<tr>"); //foreach (DataColumn column in dt.Columns) //{ sb.Append("<td style = 'background-color: #D20B0C;color:black'>"); sb.Append(email); sb.Append("</td>"); sb.Append("<td style = 'background-color: #D20B0C;color:black'>"); sb.Append(name); sb.Append("</td>"); sb.Append("<td style = 'background-color: #D20B0C;color:black'>"); sb.Append(desc); sb.Append("</td>"); //} sb.Append("</tr>"); foreach (DataRow row in dt.Rows) { sb.Append("<tr>"); foreach (DataColumn column in dt.Columns) { sb.Append("<td>"); sb.Append(row[column]); sb.Append("</td>"); } sb.Append("</tr>"); } sb.Append("</table>"); sb.Append("<br/><br/>"); sb.Append("<b> Thank You For Your Valuable Donation"); StringReader sr = new StringReader(sb.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); using (MemoryStream memoryStream = new MemoryStream()) { PdfWriter writer = PdfWriter.GetInstance(pdfDoc, memoryStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); byte[] bytes = memoryStream.ToArray(); memoryStream.Close(); MailDefinition md = new MailDefinition(); md.From = "*****@*****.**"; md.IsBodyHtml = true; //md.Subject = "Test of MailDefinition"; ListDictionary replacements = new ListDictionary(); replacements.Add("{name}", TextBox_emailID.Text); replacements.Add("{book}", TextBox_Bookname.Text); //replacements.Add("{url}", "/ICON.jpg"); //string body = "<div style='color:red;background:yellow'>Hello {name}<br><br><br> You're from {country}.</div><br><br> <div style='color:red;background:red'>Nice To Meet You.</div>"; string body = "<style type='text/css'>td {padding: 15px;}.auto-style1 {color: #00E600;}</style><div style='width:80%;height:80%;margin:auto;padding:20px;color:#00cc00;border:10px solid #00cc00;'><img src=\"cid:filename\"><div style='margin:50px;background-color:#f7ffe6;padding:30px'><center><h2>Thank you for the donation!</h2></center><table><tr><td>Donor Name:</td><td>{name}</td></tr><tr><td>Donation ID:</td><td>4355</td></tr><tr><td>Book Donated:</td><td>{book}</td></tr></table></div><b style='float:right;'>©Copyright BooksForTechs</b></div>"; MailMessage mm = md.CreateMailMessage(TextBox_emailID.Text, replacements, body, new System.Web.UI.Control()); //MailMessage mm = new MailMessage("*****@*****.**", "*****@*****.**"); mm.Subject = "Donation Sleep"; mm.Attachments.Add(new Attachment(new MemoryStream(bytes), "donationPDF.pdf")); mm.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential(); NetworkCred.UserName = "******"; NetworkCred.Password = "******"; smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(mm); /*MailMessage mm = new MailMessage(); * mm.From=new MailAddress("*****@*****.**"); * mm.To.Add(new MailAddress(TextBox_emailID.Text)); * mm.Subject = "Donation Reciept"; * mm.Body = "Thank you for donating book...we appriciate your work.....please find an attachment which contains donation sleep"; * mm.Attachments.Add(new Attachment(new MemoryStream(bytes), "donationPDF.pdf")); * mm.IsBodyHtml = true; * SmtpClient smtp = new SmtpClient(); * smtp.Host = "smtp.gmail.com"; * smtp.EnableSsl = true; * NetworkCredential NetworkCred = new NetworkCredential(); * NetworkCred.UserName = "******"; * NetworkCred.Password = "******"; * smtp.UseDefaultCredentials = true; * smtp.Credentials = NetworkCred; * smtp.Port = 587; * smtp.Send(mm);*/ } } } }
public void Test01() { IntlStrings intl; ListDictionary ld; // simple string values string[] values = { "", " ", "a", "aA", "text", " SPaces", "1", "$%^#", "2222222222222222222222222", System.DateTime.Today.ToString(), Int32.MaxValue.ToString() }; // keys for simple string values string[] keys = { "zero", "oNe", " ", "", "aa", "1", System.DateTime.Today.ToString(), "$%^#", Int32.MaxValue.ToString(), " spaces", "2222222222222222222222222" }; // string [] destination; Array destination; int cnt = 0; // Count // initialize IntStrings intl = new IntlStrings(); // [] ListDictionary is constructed as expected //----------------------------------------------------------------- ld = new ListDictionary(); // [] CopyTo empty dictionary into empty array // destination = new Object[0]; Assert.Throws <ArgumentOutOfRangeException>(() => { ld.CopyTo(destination, -1); }); ld.CopyTo(destination, 0); // exception even when copying empty dictionary Assert.Throws <ArgumentException>(() => { ld.CopyTo(destination, 1); }); // [] CopyTo empty dictionary into filled array // destination = new Object[values.Length]; for (int i = 0; i < values.Length; i++) { destination.SetValue(values[i], i); } ld.CopyTo(destination, 0); if (destination.Length != values.Length) { Assert.False(true, string.Format("Error, altered array after copying empty dictionary")); } if (destination.Length == values.Length) { for (int i = 0; i < values.Length; i++) { if (String.Compare(destination.GetValue(i).ToString(), values[i]) != 0) { Assert.False(true, string.Format("Error, altered item {0} after copying empty dictionary", i)); } } } // // [] CopyTo(Array, 0) for dictionary filled with simple strings cnt = ld.Count; int len = values.Length; for (int i = 0; i < len; i++) { ld.Add(keys[i], values[i]); } if (ld.Count != len) { Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, values.Length)); } destination = new Object[len]; ld.CopyTo(destination, 0); // // for (int i = 0; i < len; i++) { // verify that dictionary is copied correctly // if (String.Compare(ld[keys[i]].ToString(), ((DictionaryEntry)destination.GetValue(i)).Value.ToString()) != 0) { Assert.False(true, string.Format("Error, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Value.ToString(), ld[keys[i]])); } if (String.Compare(keys[i], ((DictionaryEntry)destination.GetValue(i)).Key.ToString()) != 0) { Assert.False(true, string.Format("Error, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Key.ToString(), keys[i])); } } // // [] CopyTo(Array, middle_index) for dictionary filled with simple strings // ld.Clear(); for (int i = 0; i < len; i++) { ld.Add(keys[i], values[i]); } if (ld.Count != len) { Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, values.Length)); } destination = new Object[len * 2]; ld.CopyTo(destination, len); // // for (int i = 0; i < len; i++) { // verify that dictionary is copied correctly // if (String.Compare(ld[keys[i]].ToString(), ((DictionaryEntry)destination.GetValue(i + len)).Value.ToString()) != 0) { Assert.False(true, string.Format("Error, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i + len)).Value, ld[keys[i]])); } // verify keys if (String.Compare(keys[i], ((DictionaryEntry)destination.GetValue(i + len)).Key.ToString()) != 0) { Assert.False(true, string.Format("Error, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i + len)).Key, keys[i])); } } // // Intl strings // // [] CopyTo(Array, 0) for dictionary filled with Intl strings // string[] intlValues = new string[len * 2]; // fill array with unique strings // for (int i = 0; i < len * 2; i++) { string val = intl.GetRandomString(MAX_LEN); while (Array.IndexOf(intlValues, val) != -1) { val = intl.GetRandomString(MAX_LEN); } intlValues[i] = val; } Boolean caseInsensitive = false; for (int i = 0; i < len * 2; i++) { if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper()) { caseInsensitive = true; } } ld.Clear(); for (int i = 0; i < len; i++) { ld.Add(intlValues[i + len], intlValues[i]); } if (ld.Count != (len)) { Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, len)); } destination = new Object[len]; ld.CopyTo(destination, 0); // // for (int i = 0; i < len; i++) { // verify that dictionary is copied correctly // if (String.Compare(ld[intlValues[i + len]].ToString(), ((DictionaryEntry)destination.GetValue(i)).Value.ToString()) != 0) { Assert.False(true, string.Format("Error, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Value, ld[intlValues[i + len]])); } // verify keys if (String.Compare(intlValues[i + len], ((DictionaryEntry)destination.GetValue(i)).Key.ToString()) != 0) { Assert.False(true, string.Format("Error, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Key, intlValues[i + len])); } } // // Intl strings // // [] CopyTo(Array, middle_index) for dictionary filled with Intl strings // destination = new Object[len * 2]; ld.CopyTo(destination, len); // // order of items is the same as they were in dictionary // for (int i = 0; i < len; i++) { // verify that dictionary is copied correctly // if (String.Compare(ld[intlValues[i + len]].ToString(), ((DictionaryEntry)destination.GetValue(i + len)).Value.ToString()) != 0) { Assert.False(true, string.Format("Error, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i + len)).Value, ld[intlValues[i + len]])); } // verify keys if (String.Compare(intlValues[i + len], ((DictionaryEntry)destination.GetValue(i + len)).Key.ToString()) != 0) { Assert.False(true, string.Format("Error, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i + len)).Key, intlValues[i + len])); } } // // [] Case sensitivity // string[] intlValuesLower = new string[len * 2]; // fill array with unique strings // for (int i = 0; i < len * 2; i++) { intlValues[i] = intlValues[i].ToUpper(); } for (int i = 0; i < len * 2; i++) { intlValuesLower[i] = intlValues[i].ToLower(); } ld.Clear(); // // will use first half of array as values and second half as keys // for (int i = 0; i < len; i++) { ld.Add(intlValues[i + len], intlValues[i]); // adding uppercase strings } destination = new Object[len]; ld.CopyTo(destination, 0); // // for (int i = 0; i < len; i++) { // verify that dictionary is copied correctly // if (String.Compare(ld[intlValues[i + len]].ToString(), ((DictionaryEntry)destination.GetValue(i)).Value.ToString()) != 0) { Assert.False(true, string.Format("Error, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Value, ld[intlValues[i + len]])); } if (!caseInsensitive && Array.IndexOf(intlValuesLower, ((DictionaryEntry)destination.GetValue(i)).Value.ToString()) > -1) { Assert.False(true, string.Format("Error, copied lowercase string")); } // verify keys if (String.Compare(intlValues[i + len], ((DictionaryEntry)destination.GetValue(i)).Key.ToString()) != 0) { Assert.False(true, string.Format("Error, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Key, intlValues[i + len])); } if (!caseInsensitive && Array.IndexOf(intlValuesLower, ((DictionaryEntry)destination.GetValue(i)).Key.ToString()) > -1) { Assert.False(true, string.Format("Error, copied lowercase key")); } } // // [] CopyTo(null, int) // destination = null; Assert.Throws <ArgumentNullException>(() => { ld.CopyTo(destination, 0); }); // // [] CopyTo(Array, -1) // cnt = ld.Count; destination = new Object[2]; Assert.Throws <ArgumentOutOfRangeException>(() => { ld.CopyTo(destination, -1); }); // // [] CopyTo(Array, upperBound+1) // if (ld.Count < 1) { ld.Clear(); for (int i = 0; i < len; i++) { ld.Add(keys[i], values[i]); } } destination = new Object[len]; Assert.Throws <ArgumentException>(() => { ld.CopyTo(destination, len); }); // // [] CopyTo(Array, upperBound+2) // Assert.Throws <ArgumentException>(() => { ld.CopyTo(destination, len + 1); }); // // [] CopyTo(Array, not_enough_space) // Assert.Throws <ArgumentException>(() => { ld.CopyTo(destination, len / 2); }); // // [] CopyTo(multidim_Array, 0) // Array dest = new string[len, len]; Assert.Throws <ArgumentException>(() => { ld.CopyTo(dest, 0); }); // // [] CopyTo(wrong_type, 0) // dest = new ArrayList[len]; Assert.Throws <InvalidCastException>(() => { ld.CopyTo(dest, 0); }); // // [] CopyTo(Array, upperBound+1) - copy empty dictionary - no exception // ld.Clear(); destination = new Object[len]; ld.CopyTo(destination, len); }
/// <summary> /// Checks output state and flushes pending attributes and namespaces /// when it's appropriate. /// </summary> private void CheckState() { if (_state == WriteState.Element) { //Emit pending attributes _nsManager.PushScope(); foreach (string prefix in _currentNamespaceDecls.Keys) { string uri = _currentNamespaceDecls [prefix] as string; if (_nsManager.LookupNamespace(prefix, false) == uri) { continue; } newNamespaces.Add(prefix); _nsManager.AddNamespace(prefix, uri); } for (int i = 0; i < pendingAttributesPos; i++) { Attribute attr = pendingAttributes [i]; string prefix = attr.Prefix; if (prefix == XmlNamespaceManager.PrefixXml && attr.Namespace != XmlNamespaceManager.XmlnsXml) { // don't allow mapping from "xml" to other namespaces. prefix = String.Empty; } string existing = _nsManager.LookupPrefix(attr.Namespace, false); if (prefix.Length == 0 && attr.Namespace.Length > 0) { prefix = existing; } if (attr.Namespace.Length > 0) { if (prefix == null || prefix == String.Empty) { // ADD // empty prefix is not allowed // for non-local attributes. prefix = "xp_" + _xpCount++; //if (existing != prefix) { while (_nsManager.LookupNamespace(prefix) != null) { prefix = "xp_" + _xpCount++; } newNamespaces.Add(prefix); _currentNamespaceDecls.Add(prefix, attr.Namespace); _nsManager.AddNamespace(prefix, attr.Namespace); //} } // ADD } Emitter.WriteAttributeString(prefix, attr.LocalName, attr.Namespace, attr.Value); } for (int i = 0; i < newNamespaces.Count; i++) { string prefix = (string)newNamespaces [i]; string uri = _currentNamespaceDecls [prefix] as string; if (prefix != String.Empty) { Emitter.WriteAttributeString("xmlns", prefix, XmlNamespaceManager.XmlnsXmlns, uri); } else { Emitter.WriteAttributeString(String.Empty, "xmlns", XmlNamespaceManager.XmlnsXmlns, uri); } } _currentNamespaceDecls.Clear(); //Attributes flushed, state is Content now _state = WriteState.Content; newNamespaces.Clear(); } _canProcessAttributes = false; }
public void ShouldThrowIfAttemptingToAddNullKey() { ListDictionary <string, int> dict = new ListDictionary <string, int>(); dict.Add(null); }
/// <summary> /// This method parses a connection string and returns a new NpgsqlConnectionString object. /// </summary> public static NpgsqlConnectionString ParseConnectionString(String CS) { ListDictionary new_values = new ListDictionary(CaseInsensitiveComparer.Default); String[] pairs; String[] keyvalue; if (CS == null) { CS = String.Empty; } // Get the key-value pairs delimited by ; pairs = CS.Split(';'); // Now, for each pair, get its key=value. foreach (String sraw in pairs) { String s = sraw.Trim(); String Key = "", Value = ""; // Just ignore these. if (s == "") { continue; } // Split this chunk on the first CONN_ASSIGN only. keyvalue = s.Split(new Char[] { '=' }, 2); // Keys always get trimmed and uppercased. Key = keyvalue[0].Trim().ToUpper(); // Make sure the key is even there... if (Key.Length == 0) { throw new ArgumentException(resman.GetString("Exception_WrongKeyVal"), "<BLANK>"); } // We don't expect keys this long, and it might be about to be put // in an error message, so makes sure it is a sane length. if (Key.Length > 20) { Key = Key.Substring(0, 20); } // Check if there is a key-value pair. if (keyvalue.Length != 2) { throw new ArgumentException(resman.GetString("Exception_WrongKeyVal"), Key); } // Values always get trimmed. Value = keyvalue[1].Trim(); // Substitute the real key name if this is an alias key (ODBC stuff for example)... String AliasKey = (string)ConnectionStringKeys.Aliases[Key]; if (AliasKey != null) { Key = AliasKey; } // Add the pair to the dictionary.. new_values.Add(Key, Value); } return(new NpgsqlConnectionString(new_values)); }
static void Main() { ListDictionary myDict = new ListDictionary(); myDict.Add(1, "This"); myDict.Add(2, "is"); myDict.Add(3, "List"); myDict.Add(4, "Dictionary"); myDict.Add(5, "Demo"); Console.WriteLine("Elements in List Dictionary :"); foreach (DictionaryEntry de in myDict) { Console.WriteLine(de.Key + " " + de.Value); } Console.WriteLine("-----------------"); Console.WriteLine("Total key value in myDict are : " + myDict.Count); Console.WriteLine("-----------------"); Console.WriteLine("Keys in List Dictionary :"); ICollection ic = myDict.Keys; foreach (var v in ic) { Console.WriteLine(v); } Console.WriteLine("----------------"); Console.WriteLine("Values in List Dictionary :"); ICollection value = myDict.Values; foreach (var v in value) { Console.WriteLine(v); } Console.WriteLine("-----------------"); Console.WriteLine("Output for Contains"); Console.WriteLine(myDict.Contains(4)); Console.WriteLine("-------------"); Console.WriteLine("After Removing a particular key :"); myDict.Remove(1); foreach (DictionaryEntry de in myDict) { Console.WriteLine(de.Key + " " + de.Value); } Console.WriteLine("-------------"); myDict.Clear(); Console.WriteLine("Total key value pairs in myDict are : " + myDict.Count); }
public virtual bool runTest() { Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer); int iCountErrors = 0; int iCountTestcases = 0; String strLoc = "Loc_000oo"; ListDictionary ld; int cnt; string [] values = { "", " ", "a", "aA", "text", " SPaces", "1", "$%^#", "2222222222222222222222222", System.DateTime.Today.ToString(), Int32.MaxValue.ToString() }; string [] keys = { "zero", "oNe", " ", "", "aa", "1", System.DateTime.Today.ToString(), "$%^#", Int32.MaxValue.ToString(), " spaces", "2222222222222222222222222" }; try { Console.WriteLine("--- create dictionary ---"); strLoc = "Loc_001oo"; iCountTestcases++; ld = new ListDictionary(); Console.WriteLine("1. IsSynchronized on empty dictionary"); iCountTestcases++; if (ld.IsSynchronized) { iCountErrors++; Console.WriteLine("Err_0001, returned true for empty dictionary"); } Console.WriteLine("2. IsSynchronized for filled dictionary"); strLoc = "Loc_002oo"; iCountTestcases++; ld.Clear(); cnt = values.Length; for (int i = 0; i < cnt; i++) { ld.Add(keys[i], values[i]); } if (ld.Count != cnt) { iCountErrors++; Console.WriteLine("Err_0002a, count is {0} instead of {1}", ld.Count, cnt); } iCountTestcases++; if (ld.IsSynchronized) { iCountErrors++; Console.WriteLine("Err_0002b, returned true for filled dictionary"); } } catch (Exception exc_general) { ++iCountErrors; Console.WriteLine(s_strTFAbbrev + " : Error Err_general! strLoc==" + strLoc + ", exc_general==\n" + exc_general.ToString()); } if (iCountErrors == 0) { Console.WriteLine("Pass. " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases); return(true); } else { Console.WriteLine("Fail! " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums); return(false); } }
public virtual bool runTest() { Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer); int iCountErrors = 0; int iCountTestcases = 0; IntlStrings intl; String strLoc = "Loc_000oo"; ListDictionary ld; string [] values = { "", " ", "a", "aA", "text", " SPaces", "1", "$%^#", "2222222222222222222222222", System.DateTime.Today.ToString(), Int32.MaxValue.ToString() }; string [] keys = { "zero", "oNe", " ", "", "aa", "1", System.DateTime.Today.ToString(), "$%^#", Int32.MaxValue.ToString(), " spaces", "2222222222222222222222222" }; int cnt = 0; try { intl = new IntlStrings(); Console.WriteLine("--- create dictionary ---"); strLoc = "Loc_001oo"; iCountTestcases++; ld = new ListDictionary(); Console.WriteLine("1. Remove() on empty dictionary"); iCountTestcases++; cnt = ld.Count; Console.WriteLine(" - Remove(null)"); try { ld.Remove(null); iCountErrors++; Console.WriteLine("Err_0001a, no exception"); } catch (ArgumentNullException ex) { Console.WriteLine(" Expected exception: {0}", ex.Message); } catch (Exception e) { iCountErrors++; Console.WriteLine("Err_0001b, unexpected exception: {0}", e.ToString()); } iCountTestcases++; cnt = ld.Count; Console.WriteLine(" - Remove(some_string)"); ld.Remove("some_string"); if (ld.Count != cnt) { iCountErrors++; Console.WriteLine("Err_0001c, changed dictionary after Remove(some_string)"); } Console.WriteLine("2. add simple strings, Remove(Object)"); strLoc = "Loc_002oo"; iCountTestcases++; cnt = ld.Count; int len = values.Length; for (int i = 0; i < len; i++) { ld.Add(keys[i], values[i]); } if (ld.Count != len) { iCountErrors++; Console.WriteLine("Err_0002a, count is {0} instead of {1}", ld.Count, values.Length); } for (int i = 0; i < len; i++) { cnt = ld.Count; iCountTestcases++; ld.Remove(keys[i]); if (ld.Count != cnt - 1) { iCountErrors++; Console.WriteLine("Err_0002_{0}b, returned: failed to remove item", i); } iCountTestcases++; if (ld.Contains(keys[i])) { iCountErrors++; Console.WriteLine("Err_0002_{0}c, removed wrong item", i); } } Console.WriteLine("3. add intl strings and Remove()"); strLoc = "Loc_003oo"; iCountTestcases++; string [] intlValues = new string [len * 2]; for (int i = 0; i < len * 2; i++) { string val = intl.GetString(MAX_LEN, true, true, true); while (Array.IndexOf(intlValues, val) != -1) { val = intl.GetString(MAX_LEN, true, true, true); } intlValues[i] = val; } Boolean caseInsensitive = false; for (int i = 0; i < len * 2; i++) { if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper()) { caseInsensitive = true; } } iCountTestcases++; cnt = ld.Count; for (int i = 0; i < len; i++) { ld.Add(intlValues[i + len], intlValues[i]); } if (ld.Count != (cnt + len)) { iCountErrors++; Console.WriteLine("Err_0003a, count is {0} instead of {1}", ld.Count, cnt + len); } for (int i = 0; i < len; i++) { cnt = ld.Count; iCountTestcases++; ld.Remove(intlValues[i + len]); if (ld.Count != cnt - 1) { iCountErrors++; Console.WriteLine("Err_0003_{0}b, returned: failed to remove item", i); } iCountTestcases++; if (ld.Contains(intlValues[i + len])) { iCountErrors++; Console.WriteLine("Err_0003_{0}c, removed wrong item", i); } } Console.WriteLine("4. case sensitivity"); strLoc = "Loc_004oo"; string [] intlValuesLower = new string [len * 2]; for (int i = 0; i < len * 2; i++) { intlValues[i] = intlValues[i].ToUpper(); } for (int i = 0; i < len * 2; i++) { intlValuesLower[i] = intlValues[i].ToLower(); } ld.Clear(); Console.WriteLine(" - add uppercase and remove uppercase"); for (int i = 0; i < len; i++) { ld.Add(intlValues[i + len], intlValues[i]); } for (int i = 0; i < len; i++) { cnt = ld.Count; iCountTestcases++; ld.Remove(intlValues[i + len]); if (ld.Count != cnt - 1) { iCountErrors++; Console.WriteLine("Err_0004_{0}b, returned: failed to remove item", i); } iCountTestcases++; if (ld.Contains(intlValues[i + len])) { iCountErrors++; Console.WriteLine("Err_0004_{0}c, removed wrong item", i); } } ld.Clear(); Console.WriteLine(" - add uppercase but remove lowercase"); for (int i = 0; i < len; i++) { ld.Add(intlValues[i + len], intlValues[i]); } for (int i = 0; i < len; i++) { cnt = ld.Count; iCountTestcases++; ld.Remove(intlValuesLower[i + len]); if (!caseInsensitive && ld.Count != cnt) { iCountErrors++; Console.WriteLine("Err_0004_{0}d, failed: removed item using lowercase key", i); } } Console.WriteLine("5. Remove() on LD with insensitive comparer"); ld = new ListDictionary(new Co8689_InsensitiveComparer()); strLoc = "Loc_005oo"; iCountTestcases++; len = values.Length; ld.Clear(); string kk = "key"; for (int i = 0; i < len; i++) { ld.Add(kk + i, values[i]); } if (ld.Count != len) { iCountErrors++; Console.WriteLine("Err_0005a, count is {0} instead of {1}", ld.Count, len); } for (int i = 0; i < len; i++) { iCountTestcases++; cnt = ld.Count; ld.Remove(kk.ToUpper() + i); if (ld.Count != cnt - 1) { iCountErrors++; Console.WriteLine("Err_0005b_{0}, failed to remove item", i); } iCountTestcases++; if (ld.Contains(kk + i)) { iCountErrors++; Console.WriteLine("Err_0005_c_{0}, removed wrong item", i); } } Console.WriteLine("6. Remove(null) for filled LD"); ld = new ListDictionary(); strLoc = "Loc_006oo"; iCountTestcases++; cnt = ld.Count; if (ld.Count < len) { ld.Clear(); for (int i = 0; i < len; i++) { ld.Add(keys[i], values[i]); } } iCountTestcases++; try { ld.Remove(null); iCountErrors++; Console.WriteLine("Err_0006a, no exception"); } catch (ArgumentNullException ex) { Console.WriteLine(" Expected exception: {0}", ex.Message); } catch (Exception e) { iCountErrors++; Console.WriteLine("Err_0006b, unexpected exception: {0}", e.ToString()); } } catch (Exception exc_general) { ++iCountErrors; Console.WriteLine(s_strTFAbbrev + " : Error Err_general! strLoc==" + strLoc + ", exc_general==\n" + exc_general.ToString()); } if (iCountErrors == 0) { Console.WriteLine("Pass. " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases); return(true); } else { Console.WriteLine("Fail! " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums); return(false); } }
public void UpdateList() { //Remember selection and scroll position EndEdit(); int nTopItemIndex = -1; if (this.TopItem != null && this.TopItem.Index >= 0) { nTopItemIndex = this.TopItem.Index; } int nSelectedIndex = -1; if (this.SelectedIndices.Count > 0) { nSelectedIndex = this.SelectedIndices[0]; } Items.Clear(); HybridDictionary mapTypesPos = new HybridDictionary(); ListDictionary mapAttributes = new ListDictionary(); mapTypesPos.Clear(); mapTypesPos.Add("", AddDelimer("")); // Custom attributes var nCount = 0; m_pMFProps.PropsGetCount("", out nCount); for (int i = 0; i < nCount; i++) { string strName, strValue; int isNode; m_pMFProps.PropsGetByIndex("", i, out strName, out strValue, out isNode); if (!mapAttributes.Contains(strName) && !forbiddenAttributes.Contains(strName)) { mapAttributes.Add(strName, null); } } // Insert names and attributes into list foreach (DictionaryEntry entry in mapAttributes) { string strFullName = (string)entry.Key; string strName = strFullName; string strPrefix = GetPrefix(ref strName); if (!mapTypesPos.Contains(strPrefix)) { mapTypesPos.Add(strPrefix, AddDelimer(strPrefix)); } int nPos = Items.IndexOf((ListViewItem)mapTypesPos[strPrefix]); string strValue; m_pMFProps.PropsGet(strFullName, out strValue); string strHelp; m_pMFProps.PropsInfoGet(strName, eMInfoType.eMIT_Help, out strHelp); string strType; m_pMFProps.PropsInfoGet(strName, eMInfoType.eMIT_Type, out strType); string strDefault; m_pMFProps.PropsInfoGet(strName, eMInfoType.eMIT_Default, out strDefault); string strValues; m_pMFProps.PropsInfoGet(strName, eMInfoType.eMIT_Values, out strValues); if (string.IsNullOrEmpty(strValue)) { strValue = strDefault; } string strHelpString; m_pMFProps.PropsInfoGet(strName, eMInfoType.eMIT_Help, out strHelpString); ListViewItem lvItem = nPos >= 0 ? Items.Insert(nPos, strName) : Items.Add(strName); if (strHelpString != string.Empty && strHelpString != "null") { lvItem.ToolTipText = strHelpString; } ListViewItem.ListViewSubItem lvSubItem = lvItem.SubItems.Add(strValue); if ((strType == "option" || strType == "option_fixed") && !string.IsNullOrEmpty(strValues)) { strValues = strValues.TrimEnd('|'); // The option values may be divided by commas or by '|' if values contain commas string[] arrValues = strValues.Contains("|") ? strValues.Split('|') : strValues.Split(','); if (arrValues.Length > 1) { ComboBox pCombo = SubItem_SetCombo(lvSubItem, null, strType == "option_fixed" ? ComboBoxStyle.DropDownList : ComboBoxStyle.DropDown); for (int k = 0; k < arrValues.Length; k++) { pCombo.Items.Add(arrValues[k].Trim()); } } } else if (strType == "bool") { ComboBox pCombo = SubItem_SetCombo(lvSubItem, null, ComboBoxStyle.DropDownList); pCombo.Items.Add("true"); pCombo.Items.Add("false"); } else if (strType == "path") { SaveFileDialog pDialog = new SaveFileDialog { Title = strHelp }; TextBox textWithDialog = new TextBox { Tag = pDialog }; SubItem_SetControl(lvSubItem, textWithDialog); } else if (strType == "path_open") { OpenFileDialog pDialog = new OpenFileDialog { Title = strHelp }; TextBox textWithDialog = new TextBox { Tag = pDialog }; SubItem_SetControl(lvSubItem, textWithDialog); } if (strPrefix != "") { strPrefix += "::"; } lvItem.Tag = strPrefix; lvItem.UseItemStyleForSubItems = false; lvItem.BackColor = Color.White; if (strValue != strDefault) { // User modified values select by black lvSubItem.ForeColor = Color.Black; } else { lvSubItem.ForeColor = Color.Gray; } } Columns[0].Width = -2; //Columns[1].Width = -2; //Restore selection and scroll if (nSelectedIndex > 0 && this.Items.Count - 1 >= nSelectedIndex) { this.Items[nSelectedIndex].Selected = true; } if (nTopItemIndex > 0 && this.Items.Count - 1 >= nTopItemIndex) { this.TopItem = this.Items[nTopItemIndex]; } }
public override void Execute(GameLiving living) { if (CheckPreconditions(living, DEAD | SITTING | MEZZED | STUNNED)) { return; } GamePlayer player = living as GamePlayer; if (player == null) { return; } GamePlayer targetPlayer = null; bool isGoodTarget = true; if (player.TargetObject == null) { isGoodTarget = false; } else { targetPlayer = player.TargetObject as GamePlayer; if (targetPlayer == null || targetPlayer.IsAlive || GameServer.ServerRules.IsSameRealm(living, player.TargetObject as GameLiving, true) == false) { isGoodTarget = false; } } if (isGoodTarget == false) { player.Out.SendMessage("You have to target a dead member of your realm!", eChatType.CT_SpellResisted, eChatLoc.CL_SystemWindow); return; } if (ServerProperties.Properties.USE_NEW_ACTIVES_RAS_SCALING) { switch (Level) { case 1: m_resurrectValue = 10; break; case 2: m_resurrectValue = 25; break; case 3: m_resurrectValue = 50; break; case 4: m_resurrectValue = 75; break; case 5: m_resurrectValue = 100; break; } } else { switch (Level) { case 2: m_resurrectValue = 50; break; case 3: m_resurrectValue = 100; break; } } GameLiving resurrectionCaster = targetPlayer.TempProperties.getProperty <object>(RESURRECT_CASTER_PROPERTY, null) as GameLiving; if (resurrectionCaster != null) { player.Out.SendMessage("Your target is already considering a resurrection!", eChatType.CT_SpellResisted, eChatLoc.CL_SystemWindow); return; } if (!player.IsWithinRadius(targetPlayer, (int)(1500 * player.GetModified(eProperty.SpellRange) * 0.01))) { player.Out.SendMessage("You are too far away from your target to use this ability!", eChatType.CT_SpellResisted, eChatLoc.CL_SystemWindow); return; } if (targetPlayer != null) { SendCasterSpellEffectAndCastMessage(living, 7019, true); DisableSkill(living); //Lifeflight: //don't rez just yet //ResurrectLiving(targetPlayer, player); //we need to add a dialogue response to the rez, copying from the rez spellhandler targetPlayer.TempProperties.setProperty(RESURRECT_CASTER_PROPERTY, living); RegionTimer resurrectExpiredTimer = new RegionTimer(targetPlayer); resurrectExpiredTimer.Callback = new RegionTimerCallback(ResurrectExpiredCallback); resurrectExpiredTimer.Properties.setProperty("targetPlayer", targetPlayer); resurrectExpiredTimer.Start(15000); lock (m_resTimersByLiving.SyncRoot) { m_resTimersByLiving.Add(player.TargetObject, resurrectExpiredTimer); } //send resurrect dialog targetPlayer.Out.SendCustomDialog("Do you allow " + living.GetName(0, true) + " to resurrect you\nwith " + m_resurrectValue + " percent hits?", new CustomDialogResponse(ResurrectResponceHandler)); } }
internal object InternalGetSchemaObject(SchemaObjectType schemaObjectType, string uniqueName, bool retryUniqueName) { DataRow dataRow; if (SchemaObjectType.ObjectTypeMember == schemaObjectType) { ListDictionary listDictionary = new ListDictionary(); listDictionary.Add(CubeCollectionInternal.cubeNameRest, this.Name); AdomdUtils.AddCubeSourceRestrictionIfApplicable(this.Connection, listDictionary); string requestType = "MDSCHEMA_MEMBERS"; string key = "MEMBER_UNIQUE_NAME"; listDictionary.Add(key, uniqueName); AdomdUtils.AddMemberBinaryRestrictionIfApplicable(this.Connection, listDictionary); DataRowCollection rows = AdomdUtils.GetRows(this.Connection, requestType, listDictionary); if (rows.Count != 1) { throw new ArgumentException(SR.Indexer_ObjectNotFound(uniqueName), "uniqueName"); } dataRow = rows[0]; } else { dataRow = this.metadataCache.FindObjectByUniqueName(schemaObjectType, uniqueName); if (dataRow == null && retryUniqueName) { ListDictionary listDictionary2 = new ListDictionary(); listDictionary2.Add(CubeCollectionInternal.cubeNameRest, this.Name); AdomdUtils.AddCubeSourceRestrictionIfApplicable(this.Connection, listDictionary2); string schemaName; string text; switch (schemaObjectType) { case SchemaObjectType.ObjectTypeDimension: schemaName = DimensionCollectionInternal.schemaName; text = DimensionCollectionInternal.dimUNameRest; goto IL_16D; case SchemaObjectType.ObjectTypeHierarchy: schemaName = HierarchyCollectionInternal.schemaName; text = HierarchyCollectionInternal.hierUNameRest; goto IL_16D; case SchemaObjectType.ObjectTypeLevel: schemaName = LevelCollectionInternal.schemaName; text = LevelCollectionInternal.levelUNameRest; goto IL_16D; case SchemaObjectType.ObjectTypeMember: case (SchemaObjectType)5: break; case SchemaObjectType.ObjectTypeMeasure: schemaName = MeasureCollectionInternal.schemaName; text = Measure.uniqueNameColumn; goto IL_16D; case SchemaObjectType.ObjectTypeKpi: schemaName = KpiCollectionInternal.schemaName; text = Kpi.kpiNameColumn; goto IL_16D; default: if (schemaObjectType == SchemaObjectType.ObjectTypeNamedSet) { schemaName = NamedSetCollectionInternal.schemaName; text = "SET_NAME"; goto IL_16D; } break; } throw new ArgumentOutOfRangeException("schemaObjectType"); IL_16D: listDictionary2.Add(text, uniqueName); AdomdUtils.AddObjectVisibilityRestrictionIfApplicable(this.Connection, schemaName, listDictionary2); DataRowCollection rows2 = AdomdUtils.GetRows(this.Connection, schemaName, listDictionary2); if (rows2.Count > 0) { uniqueName = (rows2[0][text] as string); if (uniqueName != null) { dataRow = this.metadataCache.FindObjectByUniqueName(schemaObjectType, uniqueName); } } } } if (dataRow == null) { throw new ArgumentException(SR.Indexer_ObjectNotFound(uniqueName), "uniqueName"); } switch (schemaObjectType) { case SchemaObjectType.ObjectTypeDimension: { object result = DimensionCollectionInternal.GetDimensionByRow(this.Connection, dataRow, this, this.baseData.Catalog, this.baseData.SessionID); return(result); } case SchemaObjectType.ObjectTypeHierarchy: { Dimension parentDimension = (Dimension)this.InternalGetSchemaObject(SchemaObjectType.ObjectTypeDimension, dataRow[Dimension.uniqueNameColumn].ToString()); object result = HierarchyCollectionInternal.GetHiearchyByRow(this.Connection, dataRow, parentDimension, this.baseData.Catalog, this.baseData.SessionID); return(result); } case SchemaObjectType.ObjectTypeLevel: { string uniqueName2 = dataRow[Hierarchy.uniqueNameColumn].ToString(); Hierarchy parentHierarchy = (Hierarchy)this.InternalGetSchemaObject(SchemaObjectType.ObjectTypeHierarchy, uniqueName2); object result = LevelCollectionInternal.GetLevelByRow(this.Connection, dataRow, parentHierarchy, this.baseData.Catalog, this.baseData.SessionID); return(result); } case SchemaObjectType.ObjectTypeMember: { object result = new Member(this.Connection, dataRow, null, null, MemberOrigin.Metadata, this.Name, null, -1, this.baseData.Catalog, this.baseData.SessionID); return(result); } case (SchemaObjectType)5: break; case SchemaObjectType.ObjectTypeMeasure: { object result = MeasureCollectionInternal.GetMeasureByRow(this.Connection, dataRow, this, this.baseData.Catalog, this.baseData.SessionID); return(result); } case SchemaObjectType.ObjectTypeKpi: { object result = KpiCollectionInternal.GetKpiByRow(this.Connection, dataRow, this, this.baseData.Catalog, this.baseData.SessionID); return(result); } default: if (schemaObjectType == SchemaObjectType.ObjectTypeNamedSet) { object result = NamedSetCollectionInternal.GetNamedSetByRow(this.Connection, dataRow, this, this.baseData.Catalog, this.baseData.SessionID); return(result); } break; } throw new ArgumentOutOfRangeException("schemaObjectType"); }
/// <summary> /// Compiles the sourcecode of the <c>PlotItem</c>. /// </summary> /// <param name="load">Specifies if the code should also be loaded, or if only to check the /// items source for compilation errors.</param> public virtual void Compile(bool load) { DeleteDLLs(); ListDictionary opts; if (model != null) { opts = model.CompilerOptions; } else { opts = new ListDictionary(); opts.Add("target", "library"); opts.Add("o", true); } CompilerError[] err = Compiler.Compile(new string[1] { GetSource() }, new string[1] { "Source" }, DLLName(), GetImports(), opts); compiled = true; if (err.Length > 0) { errors = new string[err.Length]; for (int i = 0; i < err.Length; i++) { compiled = compiled && (err[i].ErrorLevel != ErrorLevel.Error) && (err[i].ErrorLevel != ErrorLevel.FatalError); if (err[i].ErrorLevel == ErrorLevel.Warning) { errors[i] = "warning at line "; } else { errors[i] = "line "; } errors[i] += err[i].SourceLine + ": " + err[i].ErrorMessage; } } else { errors = new string[1] { "No errors found." }; } if (compiled && load) { Assembly a = Assembly.LoadFrom(DLLName()); Type t = a.GetType("FPlotLibrary.Code.Item" + dllIndex.ToString(), true, false); object o = t.GetConstructor(Type.EmptyTypes).Invoke(null); dllIndex++; code = (PlotItem)o; modified = recalc = true; } else if (load) { modified = recalc = true; code = this; } }
public void AddThrowsIfKeyNull() { list.Add(null, new object()); }
MailMessage CreateMessage(string emailid) { MailDefinition md = new MailDefinition(); string PaymentType = Context.Items[CSAAWeb.Constants.PC_PAYMT_TYPE].ToString(); string PaymentUpdated = Context.Items[CSAAWeb.Constants.PC_IS_ENROLLED].ToString(); if (PaymentType == CSAAWeb.Constants.PC_CC) { if (PaymentUpdated == CSAAWeb.Constants.PC_POL_NOTENROLL_STATUS) { md.BodyFileName = CSAAWeb.Constants.PC_SUCCESS_HTML; md.From = Config.Setting("FromAddress"); md.Subject = CSAAWeb.Constants.ENROLL_SUCCESS_MAIL; md.Priority = MailPriority.Normal; md.IsBodyHtml = true; EmbeddedMailObject logo = new EmbeddedMailObject(); logo.Path = Server.MapPath(CSAAWeb.Constants.PC_LOGO_PATH); logo.Name = "logo"; md.EmbeddedObjects.Add(logo); EmbeddedMailObject pass = new EmbeddedMailObject(); pass.Path = Server.MapPath(CSAAWeb.Constants.PC_CORRECT_ICON_PATH); pass.Name = CSAAWeb.Constants.PASS_MAIL; md.EmbeddedObjects.Add(pass); EmbeddedMailObject thanks = new EmbeddedMailObject(); thanks.Path = Server.MapPath("/PaymentToolimages/thank-email.jpg"); thanks.Name = "thanks"; md.EmbeddedObjects.Add(thanks); } else if (PaymentUpdated == CSAAWeb.Constants.PC_POL_ENROLL_STATUS) { md.BodyFileName = CSAAWeb.Constants.PC_SUCCESS_HTML; md.From = Config.Setting("FromAddress"); md.Subject = CSAAWeb.Constants.MODIFY_SUCCESS_MAIL; md.Priority = MailPriority.Normal; md.IsBodyHtml = true; EmbeddedMailObject logo = new EmbeddedMailObject(); logo.Path = Server.MapPath(CSAAWeb.Constants.PC_LOGO_PATH); logo.Name = "logo"; md.EmbeddedObjects.Add(logo); EmbeddedMailObject pass = new EmbeddedMailObject(); pass.Path = Server.MapPath(CSAAWeb.Constants.PC_CORRECT_ICON_PATH); pass.Name = CSAAWeb.Constants.PASS_MAIL; md.EmbeddedObjects.Add(pass); EmbeddedMailObject thanks = new EmbeddedMailObject(); thanks.Path = Server.MapPath("/PaymentToolimages/thank-email.jpg"); thanks.Name = "thanks"; md.EmbeddedObjects.Add(thanks); } else { md.BodyFileName = "/PaymentToolimages/CCFailed.html"; md.From = Config.Setting("FromAddress"); md.Subject = "Enrollment Failed"; md.Priority = MailPriority.Normal; md.IsBodyHtml = true; EmbeddedMailObject logo = new EmbeddedMailObject(); logo.Path = Server.MapPath(CSAAWeb.Constants.PC_LOGO_PATH); logo.Name = "logo"; md.EmbeddedObjects.Add(logo); EmbeddedMailObject fail = new EmbeddedMailObject(); fail.Path = Server.MapPath("/PaymentToolimages/cancel-icon.png"); fail.Name = "fail"; md.EmbeddedObjects.Add(fail); } ListDictionary replacements = new ListDictionary(); replacements.Add("<%NAME%>", Context.Items[CSAAWeb.Constants.PC_CUST_NAME].ToString()); replacements.Add("<%DATE%>", DateTime.Now.ToString(CSAAWeb.Constants.FULL_DATE_TIME_FORMAT)); replacements.Add("<%CARDNO%>", Context.Items[CSAAWeb.Constants.PC_CCNumber].ToString()); replacements.Add("<%POLICY%>", PolicyNumber.ToString().ToUpper()); //CHG0072116 - PC Edit Card Details CH3:START - changed the content and subject for email WRT edit/Enrollment details. if (PaymentUpdated == CSAAWeb.Constants.PC_POL_ENROLL_STATUS) { replacements.Add("<%RESPONSE%>", CSAAWeb.Constants.PC_EDIT_RESPONSE); } else { replacements.Add("<%RESPONSE%>", Context.Items["Response"].ToString()); } //CHG0072116 - PC Edit Card Details CH3:END - changed the content and subject for email WRT edit/Enrollment details. //Clearing context Context.Items.Clear(); System.Net.Mail.MailMessage fileMsg; fileMsg = md.CreateMailMessage(emailid, replacements, this); return(fileMsg); } else { if (PaymentUpdated == CSAAWeb.Constants.PC_POL_NOTENROLL_STATUS) { md.BodyFileName = "/PaymentToolimages/ECheckSuccess.html"; md.From = Config.Setting("FromAddress"); md.Subject = CSAAWeb.Constants.ENROLL_SUCCESS_MAIL; md.Priority = MailPriority.Normal; md.IsBodyHtml = true; EmbeddedMailObject logo = new EmbeddedMailObject(); logo.Path = Server.MapPath(CSAAWeb.Constants.PC_LOGO_PATH); logo.Name = "logo"; md.EmbeddedObjects.Add(logo); EmbeddedMailObject pass = new EmbeddedMailObject(); pass.Path = Server.MapPath(CSAAWeb.Constants.PC_CORRECT_ICON_PATH); pass.Name = CSAAWeb.Constants.PASS_MAIL; md.EmbeddedObjects.Add(pass); EmbeddedMailObject thanks = new EmbeddedMailObject(); thanks.Path = Server.MapPath("/PaymentToolimages/thank-email.jpg"); thanks.Name = "thanks"; md.EmbeddedObjects.Add(thanks); } else if (PaymentUpdated == CSAAWeb.Constants.PC_POL_ENROLL_STATUS) { md.BodyFileName = "/PaymentToolimages/ECheckSuccess.html"; md.From = Config.Setting("FromAddress"); md.Subject = CSAAWeb.Constants.MODIFY_SUCCESS_MAIL; md.Priority = MailPriority.Normal; md.IsBodyHtml = true; EmbeddedMailObject logo = new EmbeddedMailObject(); logo.Path = Server.MapPath(CSAAWeb.Constants.PC_LOGO_PATH); logo.Name = "logo"; md.EmbeddedObjects.Add(logo); EmbeddedMailObject pass = new EmbeddedMailObject(); pass.Path = Server.MapPath(CSAAWeb.Constants.PC_CORRECT_ICON_PATH); pass.Name = CSAAWeb.Constants.PASS_MAIL; md.EmbeddedObjects.Add(pass); EmbeddedMailObject thanks = new EmbeddedMailObject(); thanks.Path = Server.MapPath("/PaymentToolimages/thank-email.jpg"); thanks.Name = "thanks"; md.EmbeddedObjects.Add(thanks); } else { md.BodyFileName = "/PaymentToolimages/ECFailed.html"; md.From = Config.Setting("FromAddress"); md.Subject = "Enrollment Failed"; md.Priority = MailPriority.Normal; md.IsBodyHtml = true; EmbeddedMailObject logo = new EmbeddedMailObject(); logo.Path = Server.MapPath(CSAAWeb.Constants.PC_LOGO_PATH); logo.Name = "logo"; md.EmbeddedObjects.Add(logo); EmbeddedMailObject fail = new EmbeddedMailObject(); fail.Path = Server.MapPath("/PaymentToolimages/cancel-icon.png"); fail.Name = "fail"; md.EmbeddedObjects.Add(fail); } ListDictionary replacements = new ListDictionary(); replacements.Add("<%ACCOUNTHOLDNAME%>", Context.Items[CSAAWeb.Constants.PC_CUST_NAME].ToString()); //PC Phase II 4/20 - Modified the date time format if echeck enrollment success sceanrio replacements.Add("<%DATE%>", DateTime.Now.ToString(CSAAWeb.Constants.FULL_DATE_TIME_FORMAT)); //replacements.Add("<%RECEIPT%>", Context.Items[CSAAWeb.Constants.PC_CNFRMNUMBER].ToString()); replacements.Add("<%ACCOUNTTYPE%>", Context.Items[CSAAWeb.Constants.PC_EC_ACCOUNT_TYPE].ToString()); replacements.Add("<%BANKNAME%>", Context.Items[CSAAWeb.Constants.PC_EC_BANK_NAME].ToString()); replacements.Add("<%ACCOUNTNUMBER%>", Context.Items[CSAAWeb.Constants.PC_EC_ACC_NUMBER].ToString()); replacements.Add("<%POLICYNO%>", PolicyNumber.ToString().ToUpper()); //CHG0072116 - PC Edit Card Details CH4: START - changed the content and subject for email WRT edit/Enrollment details. if (PaymentUpdated == CSAAWeb.Constants.PC_POL_ENROLL_STATUS) { replacements.Add("<%RESPONSE%>", CSAAWeb.Constants.PC_EDIT_RESPONSE); } else { replacements.Add("<%RESPONSE%>", Context.Items["Response"].ToString()); } //CHG0072116 - PC Edit Card Details CH4: END - changed the content and subject for email WRT edit/Enrollment details. System.Net.Mail.MailMessage fileMsg; fileMsg = md.CreateMailMessage(emailid, replacements, this); return(fileMsg); } }