22-06-23, 02:53 PM
22-06-23, 07:14 PM
و عليكم السلام ورحمة الله و بركاته
بحثت بقوقل ووجدت اغلب الحلول بتحميل اضافة وتثبيتها واستخدامها ....كنت اود استخدم حيلتي بفيجوال ببيسك لكن تفاجات ان القسم الحالي هو سي شارب.
المهم هل المحتوى بمربع النص هو كود json كامل و صحيح؟
بحثت بقوقل ووجدت اغلب الحلول بتحميل اضافة وتثبيتها واستخدامها ....كنت اود استخدم حيلتي بفيجوال ببيسك لكن تفاجات ان القسم الحالي هو سي شارب.
المهم هل المحتوى بمربع النص هو كود json كامل و صحيح؟
22-06-23, 07:56 PM
شكرا لك اخي سعود على اهتمامك
نعم اخي الكود عبارة عن json وهو صحيح
وهو عبارة على مجموعة من الرسائل قابل للزيادة
اريج جلب
الid
وال number الي هو رقم المرسل
والcontent الي هو النص مشفر
وال date الي هو التاريخ
اريد تعبئة الداتا قريد بهذه المعلومات المرسلة
وشكرا
22-06-23, 09:03 PM
معذرة اخي الكريم
كنت ناوي اجهز المثال بفيجوال بيسك ثم احوله لكن الموضوع لم يتيسر لي هذا ما اتممته فقط جلب اسماء الاعمدة فقط اما الصفوف تحتاج مني وقت اكثر لصياغة الكود المناسب:
كنت ناوي اجهز المثال بفيجوال بيسك ثم احوله لكن الموضوع لم يتيسر لي هذا ما اتممته فقط جلب اسماء الاعمدة فقط اما الصفوف تحتاج مني وقت اكثر لصياغة الكود المناسب:
PHP كود :
Public Class Form1
Dim apath As String = IO.Path.GetDirectoryName(Application.ExecutablePath) & "\"
Dim js As String = apath & "json.txt"
Dim lines() As String = IO.File.ReadAllLines(js)
Private Sub Getvalues(dgv As DataGridView)
Dim row As Boolean
For Each line As String In lines
If line.Trim = "{" Then
row = True
End If
If line.Trim.StartsWith("""") And row = True Then
Dim colname As String = line.Trim.Split(":")(0).Replace("""", "")
Dim colvalue As String = line.Trim.Split(":")(1).Replace("""", "")
If colname.ToLower.Trim = "id" Then
dgv.Columns(0).HeaderText = colname
ElseIf colname.ToLower.Trim = "number" Then
dgv.Columns(1).HeaderText = colname
ElseIf colname.ToLower.Trim = "content" Then
dgv.Columns(2).HeaderText = colname
ElseIf colname.ToLower.Trim = "tag" Then
dgv.Columns(3).HeaderText = colname
ElseIf colname.ToLower.Trim = "date" Then
dgv.Columns(4).HeaderText = colname
End If
End If
Next
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Getvalues(Me.DataGridView1)
End Sub
End Class
22-06-23, 09:19 PM
في البداية يجب تصحيح كود الjson الموجود في textBox1 لانه كل مجموعة بيانات لم تغلق {
تحتاج المكتبة Newtonsoft.Json.dll
بالنسبة لnum الخاص ب non Lus لست متاكد من طريقتها، فقد تحتاج لتعديلها
كود json بعد التصحيح
تحتاج المكتبة Newtonsoft.Json.dll
PHP كود :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace benhe
{
public partial class Form1 : Form
{
private DataTable table;
public Form1()
{
InitializeComponent();
this.table = new DataTable();
this.table.Columns.Add("tag", typeof(bool));
this.table.Columns.Add("Statu", typeof(Image));
this.table.Columns.Add("number", typeof(string));
this.table.Columns.Add("content", typeof(string));
this.table.Columns.Add("Date", typeof(string));
this.table.Columns.Add("Id", typeof(string));
this.dataGridView1.DataSource = this.table;
this.dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
this.dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
this.dataGridView1.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
this.dataGridView1.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
private void button1_Click(object sender, EventArgs e)
{
int num = 0;
var jobjects = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Newtonsoft.Json.Linq.JObject>>(this.textBox1.Text);
foreach (var o in jobjects)
{
DataRow dr = this.table.NewRow();
dr["id"] = (string)o.SelectToken("id");
dr["tag"] = ((string)o.SelectToken("tag") == "1");
dr["number"] = (string)o.SelectToken("number");
dr["content"] = (string)o.SelectToken("content");
String[] d = ((string)o.SelectToken("date")).Split(',');
String date = String.Format("20{0}/{1}/{2} {3}:{4}:{5}", d[0], d[1], d[2], d[3], d[4], d[5]);
dr["date"] = date;
this.table.Rows.Add(dr);
if ((string)o.SelectToken("tag") == "0") num++;
}
this.toolStripStatusLabel1.Text = "Total : " + table.Rows.Count;
this.toolStripStatusLabel2.Text = "non Lus :" + num.ToString();
}
}
}
كود json بعد التصحيح
PHP كود :
[
{
"id": "3175",
"number": "0125548753",
"content": "0056006F00740072002E",
"tag": "1",
"date": "23,06,22,09,57,41,+4",
"draft_group_id": "",
"received_all_concat_sms": "0",
"concat_sms_total": "2",
"concat_sms_received": "3",
"sms_submit_msg_ref": "0"
}
,
{
"id": "3173",
"number": "532155553",
"content": "0056006F0074300330033002E",
"tag": "1",
"date": "23,06,22,09,57,40,+4",
"draft_group_id": "",
"received_all_concat_sms": "0",
"concat_sms_total": "2",
"concat_sms_received": "3",
"sms_submit_msg_ref": "0"
}
,
{
"id": "3171",
"number": "5353",
"content": "0633064A062A06450020062A062C29",
"tag": "1",
"date": "23,06,22,07,35,42,+4",
"draft_group_id": "",
"received_all_concat_sms": "0",
"concat_sms_total": "3",
"concat_sms_received": "4",
"sms_submit_msg_ref": "0"
}
,
{
"id": "3163",
"number": "215488888",
"content": "004C006500200063006C006900606C006F",
"tag": "0",
"date": "23,06,21,21,48,27,+4",
"draft_group_id": "",
"received_all_concat_sms": "1",
"concat_sms_total": "0",
"concat_sms_received": "0",
"sms_submit_msg_ref": "0"
}
,
{
"id": "3161",
"number": "+213782767990",
"content": "00540067006F9526F006F",
"tag": "0",
"date": "23,06,21,21,38,02,+4",
"draft_group_id": "",
"received_all_concat_sms": "1",
"concat_sms_total": "0",
"concat_sms_received": "0",
"sms_submit_msg_ref": "0"
}
,
{
"id": "3159",
"number": "+213782447578",
"content": "063106270646064806256310631",
"tag": "0",
"date": "23,06,21,21,35,51,+4",
"draft_group_id": "",
"received_all_concat_sms": "1",
"concat_sms_total": "0",
"concat_sms_received": "0",
"sms_submit_msg_ref": "0"
}
,
{
"id": "3157",
"number": "+213782300554",
"content": "064625522224606460646",
"tag": "0",
"date": "23,06,21,21,27,37,+4",
"draft_group_id": "",
"received_all_concat_sms": "1",
"concat_sms_total": "0",
"concat_sms_received": "0",
"sms_submit_msg_ref": "0"
}
,
{
"id": "3155",
"number": "+213332700548",
"content": "063303132544210633",
"tag": "0",
"date": "23,06,21,21,18,40,+4",
"draft_group_id": "",
"received_all_concat_sms": "1",
"concat_sms_total": "0",
"concat_sms_received": "0",
"sms_submit_msg_ref": "0"
}
]
22-06-23, 09:23 PM
الله يحفظك اخي سعود
سانتظ محاولاتك استاذنا الكريم
ساحول المثال واجربه
الف تحية وتقدير
الف شكر اخي الكريم G20
على المثال كود يعمل بامتياز
لكن كود الjson
يتم جلبه مثل ما هو بالتكست بوكس
يعني من دون {
هذا الملف يتم جلبه من مفاتيح هواوي حيث تصل الرسائل له عبر شريحة sim
الف شكر
الله يحفظك
شكرا اخي G20
تم تصحيح كود جلب ملف json
كان فيه دالة قص العلامة {
شكرا جزيلا