new public void Load(enuEdit enuNew_Edit, DataRow drEdit) { //this.drEdit = drEdit; //this.enuNew_Edit = enuNew_Edit; //this.Tag = (char)enuNew_Edit + ", " + this.Tag; this.cboFile_Type.DataSource = SQLExec.ExecuteReturnDt("SELECT DISTINCT 'DOC' AS File_Type UNION ALL SELECT DISTINCT 'IMG' AS File_Type UNION ALL SELECT DISTINCT 'XLS' AS File_Type UNION ALL SELECT DISTINCT 'EXE' AS File_Type "); this.cboFile_Type.DisplayMember = "File_Type"; this.cboFile_Type.ValueMember = "File_Type"; //Common.ScaterMemvar(this, ref drEdit); //this.ShowDialog(); this.drEdit = drEdit; this.enuNew_Edit = enuNew_Edit; this.Tag = ((char)((ushort)enuNew_Edit)) + ", " + this.Tag; if (enuNew_Edit == enuEdit.New) { Ident00 = 0; drEdit["Ident00"] = 0; drEdit["Duyet"] = 0; drEdit["IsZaloSend"] = 0; drEdit["Nguoi_Ky"] = ""; this.objFileContent = ImageToByte(picImage.Image); } Common.ScaterMemvar(this, ref drEdit); Ident00 = (int)drEdit["Ident00"]; if (enuNew_Edit == enuEdit.Edit) { //Edit: Disable Ma_Vt txtFile_Id.Enabled = false; this.cboFile_Type.Enabled = false; this.objFileContent = SaveZaloResource.LoadResource(Ident00); if (this.objFileContent != null) { using (Stream stream = new MemoryStream()) { new BinaryFormatter().Serialize(stream, this.objFileContent); this.lblSize.Text = "(" + stream.Length.ToString() + ")"; } } if ((bool)(drEdit["IsZaloSend"])) { btgAccept.btAccept.Enabled = false; btUpLoad.Enabled = false; } } this.ShowImage(); this.LoadDicName(); this.ShowDialog(); }
private void UpdateFollower() { string strMa_Cbnv, strZalo_ID; DataTable dtEm = SQLExec.ExecuteReturnDt("TUANVIET_OFFICIAL.dbo.Z_GetAllEmployee"); foreach (DataRow drP in dtEm.Rows) { //if ((Boolean)drP["Sent_Mail"]) // continue; strMa_Cbnv = drP["Ma_Cbnv"].ToString(); strZalo_ID = drP["Zalo_ID"].ToString(); JObject jInfo = client.getProfileOfFollower(strZalo_ID); dynamic dynjInfo = JsonConvert.DeserializeObject(jInfo.ToString()); if (dynjInfo.error != "0") { continue; } Follower User = new Follower(); User.id = dynjInfo.data.user_id; User.gender = dynjInfo.data.user_gender; User.name = dynjInfo.data.display_name; User.shared_info = false; User.Addr = dynjInfo.data.user_id_by_app; User.Avatar = dynjInfo.data.avatar; if (dynjInfo.data.shared_info != null)//User có chia sẻ thông tin { User.Addr = dynjInfo.data.shared_info.address + "#" + dynjInfo.data.shared_info.ward + "#" + dynjInfo.data.shared_info.district + "#" + dynjInfo.data.shared_info.city; User.Phone = dynjInfo.data.shared_info.phone; User.name = dynjInfo.data.shared_info.name; User.shared_info = true; if (dynjInfo.data.shared_info.birth_date != "0")// Có ngày sinh nhật { User.birthday = dynjInfo.data.shared_info.birth_date; } } if (dynjInfo.data.tags_and_notes_info.tag_names != null)//User có chia sẻ thông tin { //User.TagName = dynjInfo.data.tags_and_notes_info.tag_names; JArray items = (JArray)dynjInfo.data.tags_and_notes_info["tag_names"]; int length = items.Count; for (int i = 0; i < items.Count; i++) { string tag = items[i].ToString(); User.TagName += tag + ";"; //do something with item } } SaveZaloResource.SQLUpdateFollowerInfor(User); } EpointProcessBox.AddMessage("Số lượng người được cập nhật : " + dtEm.Rows.Count.ToString()); }
private bool Save() { Common.GatherMemvar(this, ref this.drEdit); this.drEdit["File_Tag"] = this.lbtFile_Tag.Text; if (!this.FormCheckValid()) { return(false); } //int Ident00 = Convert.ToInt32(this.drEdit["Ident00"]); DataTable dtupdate = SaveZaloResource.SaveZaloResoure(Ident00, this.drEdit["File_Id"].ToString(), this.drEdit["File_Name"].ToString(), this.drEdit["Ma_Nhom"].ToString(), this.drEdit["Catalog"].ToString(), this.drEdit["File_Type"].ToString(), this.drEdit["File_Tag"].ToString(), this.objFileContent, (DateTime)this.drEdit["Ngay_Ky"], this.drEdit["Nguoi_Ky"].ToString(), (bool)this.drEdit["Duyet"] , this.drEdit["Description"].ToString(), this.drEdit["ZALOLINK"].ToString(), this.drEdit["MA_KV_LIST"].ToString(), this.drEdit["MA_BP_LIST"].ToString(), this.drEdit["Tag_List"].ToString()); if (dtupdate.Rows.Count > 0) { Ident00 = Convert.ToInt32(this.drEdit["Ident00"]); this.drEdit["Ident00"] = dtupdate.Rows[0]["Ident00"]; this.drEdit["File_Id"] = dtupdate.Rows[0]["File_Id"]; this.drEdit["File_Id_Parent"] = dtupdate.Rows[0]["File_Id_Parent"]; } else { return(false); } //if (Ident00 != 0) //{ //} //if (DataTool.SQLCheckExist("SYSRESOURCES", "File_Id", this.drEdit["File_Id"].ToString()) && enuNew_Edit == enuEdit.New) //{ // EpointMessage.MsgOk("Mã tập tin đã tồn tại !"); // return false; //} //if (!SQLExec.Execute("Sp_UpdateResource", drEdit, CommandType.StoredProcedure)) //{ // return false; //} //if (drEdit["File_Type"].ToString() == "IMG") // SaveResource.SaveImage(this.drEdit["File_Id"].ToString(), this.drEdit["File_Name"].ToString(), this.drEdit["Ma_Nhom"].ToString(), this.drEdit["Catalog"].ToString(), this.drEdit["File_Type"].ToString(), this.drEdit["File_Tag"].ToString(), picImage, (DateTime)this.drEdit["Ngay_Ky"], this.drEdit["Nguoi_Ky"].ToString(), (bool)this.drEdit["Duyet"]); //else // SaveResource.Save(this.drEdit["File_Id"].ToString(), this.drEdit["File_Name"].ToString(), this.drEdit["Ma_Nhom"].ToString(), this.drEdit["Catalog"].ToString(), this.drEdit["File_Type"].ToString(), this.drEdit["File_Tag"].ToString(), this.objFileContent, (DateTime)this.drEdit["Ngay_Ky"], this.drEdit["Nguoi_Ky"].ToString(), (bool)this.drEdit["Duyet"]); return(true); }
public static void SendMessageToZalo(ZaloClient client, string FilePathZalo, string Is_SendZalo) { string strMsgLog = string.Empty; try { object objImage; string strMsg = string.Empty; string AttachmentId = string.Empty; string ZaloLink, FileName; string FileImg; //string strMa_Cbnv, strTen_Cbnv, strEmail, strMa_Kv, strMa_Loai2, strSubject; DataTable dtMsg = SQLExec.ExecuteReturnDt("Z_GetMessage_ToZalo"); if (dtMsg == null || dtMsg.Rows.Count == 0) { return; } foreach (DataRow drmsg in dtMsg.Rows) { int MsgID = Convert.ToInt32(drmsg["Ident00"]); ZaloLink = drmsg["ZaloLink"].ToString(); objImage = drmsg["File_Content"]; FileImg = FilePathZalo + @"\" + (drmsg["File_Tag"].ToString() == string.Empty ? String.Empty : drmsg["File_ID"].ToString() + "." + drmsg["File_Tag"].ToString()); //Common.WriteToFileZaloLog("Start Send Message ToZalo : " + FileImg); if (SaveZaloResource.LoadResourceImage(FileImg, objImage)) { ZaloFile Zfile = new ZaloFile(FileImg); Zfile.setMediaTypeHeader("Image/PNG"); JObject updatefile = client.uploadImageForOfficialAccountAPI(Zfile); dynamic dynObjFile = JsonConvert.DeserializeObject(updatefile.ToString()); AttachmentId = dynObjFile.data.attachment_id; } //Get list employee in branch //string strSQLEm = "Z_GetEmployee_ByTag " + drmsg["Ident00"] + ""; if (Is_SendZalo == "Y") { DataTable dtEmployee_Br = SQLExec.ExecuteReturnDt("Z_GetEmployee_ByTag " + MsgID.ToString()); if (dtEmployee_Br == null || dtEmployee_Br.Rows.Count == 0) { continue; } foreach (DataRow drR in dtEmployee_Br.Rows) { JObject jSendbr = client.sendImageMessageToUserIdByAttachmentId(drR["Zalo_ID"].ToString(), ZaloLink, AttachmentId); } } else { JObject jSend_hungnv = client.sendImageMessageToUserIdByAttachmentId("5643947530772678208", ZaloLink, AttachmentId); } SQLExec.Execute("Z_UpdateMessageZaloAfterSend " + MsgID.ToString()); } } catch (Exception ex) { //Common.WriteToFileZaloLog("Send Message to Zalo : " + strMsgLog + "-------------\n" + ex.ToString()); } }
public override void EpointRelease() { if (ReleaseType == "S") { string strMsgLog = string.Empty; try { if (!Directory.Exists(FilePathZalo)) { Directory.CreateDirectory(FilePathZalo); } object objImage; string strMsg = string.Empty; string AttachmentId = string.Empty; string ZaloLink, File_Name, Description; string FileImg; //string FilePathZalo //string strMa_Cbnv, strTen_Cbnv, strEmail, strMa_Kv, strMa_Loai2, strSubject; EpointProcessBox.AddMessage("Lấy dữ liệu tin nhắn"); DataTable dtMsg = SQLExec.ExecuteReturnDt(" EXEC TUANVIET_OFFICIAL.dbo.Z_GetMessage_ToZalo " + MsgIDCur.ToString()); if (dtMsg == null || dtMsg.Rows.Count == 0) { EpointProcessBox.AddMessage("không lấy được dữ liệu tin nhắn"); return; } EpointProcessBox.AddMessage("Bắt đầu gửi tin nhắn"); //foreach (DataRow drmsg in dtMsg.Rows) //{ DataRow drmsg = dtMsg.Rows[0]; //int MsgID = Convert.ToInt32(drmsg["Ident00"]); ZaloLink = drmsg["ZaloLink"].ToString(); objImage = drmsg["File_Content"]; File_Name = drmsg["File_Name"].ToString(); Description = drmsg["Description"].ToString(); FileImg = FilePathZalo + @"\" + (drmsg["File_Tag"].ToString() == string.Empty ? String.Empty : drmsg["File_ID"].ToString() + "." + drmsg["File_Tag"].ToString()); //Common.WriteToFileZaloLog("Start Send Message ToZalo : " + FileImg); if (SaveZaloResource.LoadResourceImage(FileImg, objImage)) { ZaloFile Zfile = new ZaloFile(FileImg); Zfile.setMediaTypeHeader("Image/PNG"); JObject updatefile = client.uploadImageForOfficialAccountAPI(Zfile); dynamic dynObjFile = JsonConvert.DeserializeObject(updatefile.ToString()); AttachmentId = dynObjFile.data.attachment_id; } //Get list employee in branch //string strSQLEm = "Z_GetEmployee_ByTag " + drmsg["Ident00"] + ""; strMsg = File_Name + "\n" + Description + "\n" + ZaloLink; if (true) { DataTable dtEmployee_Br = SQLExec.ExecuteReturnDt("EXEC Z_GetEmployee_ByTag " + MsgIDCur.ToString()); if (dtEmployee_Br == null || dtEmployee_Br.Rows.Count == 0) { return; } foreach (DataRow drR in dtEmployee_Br.Rows) { JObject jSendbr = client.sendImageMessageToUserIdByAttachmentId(drR["Zalo_ID"].ToString(), strMsg, AttachmentId); } } else { JObject jSend_hungnv = client.sendImageMessageToUserIdByAttachmentId("5643947530772678208", strMsg, AttachmentId); } SQLExec.Execute("EXEC TUANVIET_OFFICIAL.dbo.Z_UpdateMessageZaloAfterSend " + MsgIDCur.ToString()); EpointProcessBox.AddMessage("Kết thúc"); } catch (Exception ex) { EpointProcessBox.AddMessage("Fail Send Message to Zalo : " + strMsgLog + "-------------\n" + ex.ToString()); } } else if (ReleaseType == "G") { EpointProcessBox.AddMessage("Đang cập nhật thông tin người theo dõi!..................."); UpdateFollower(); ReleaseType = string.Empty; EpointProcessBox.AddMessage("....................Kết thúc..................."); } }