国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
1. User grouping, interface design in the management system
2. Group synchronization operation code display
Home WeChat Applet WeChat Development C# development of WeChat portal and applications - synchronizing WeChat user group information in the management system

C# development of WeChat portal and applications - synchronizing WeChat user group information in the management system

Feb 17, 2017 pm 03:11 PM

In the previous articles, we gradually transitioned from the original WeChat API encapsulation to the WeChat application platform management system, and gradually introduced the interface design of WeChat data in the management system, as well as the logic of related processing operations. and code, I hope to introduce you to the WeChat application development process from a higher level. This article mainly introduces how to realize the synchronization operation of WeChat user group information in the management system.

In fact, the reason why WeChat is so popular is mainly because of user information, so it is very important to synchronize and manage the user data of WeChat accounts. With the data of WeChat users, you can connect with any of your application systems to achieve system-mobile client data integration. You can also conduct marketing management for users, such as sending product news, service news, etc. that users are interested in, which can be well expanded. Corporate influence and market behavior.

In an earlier essay "C# Development of WeChat Portal and Application (5)--User Group Information Management", I once introduced various underlying API encapsulation operations of WeChat groups, which mainly include The .NET advanced grouping that provides API to WeChat exchanges all information and exchanges data through entity, making it more convenient for us to call API to handle various WeChat transactions, thereby laying the foundation for the management of WeChat application platform. This article introduces the API encapsulation process of all WeChat group management, user group management, including the following aspects:

1) Create a group
2) Query all groups
3) Query the group the user belongs to
4) Modify the group name
5) Move the user group

1. User grouping, interface design in the management system

Operations for the above WeChat grouping , we can design a module in the WeChat application management system to manage WeChat group data. In this module, we can create groups, modify groups, view groups and other basic operations, and can also implement the operation of synchronizing WeChat groups. The synchronization operation is mainly to add the newly added group information to WeChat. The modified group will also be modified in WeChat. Deletion is currently not supported by WeChat, so don't worry about it. Finally, we can synchronize the modified data from the WeChat server. In order to avoid submitting unsuccessful data to us during synchronization, we need to mark the modified records. This is my overall synchronization operation. The logic is processed.

In the management system, the list management interface design for WeChat groups is as follows.

C#開發(fā)微信門戶及應(yīng)用-在管理系統(tǒng)中同步微信用戶分組信息

When creating a group, we only need to add a group name. The interface design is also simple, but we design the created ID to be -1 as a future Synchronized new identifier.

C#開發(fā)微信門戶及應(yīng)用-在管理系統(tǒng)中同步微信用戶分組信息

The editing group information interface is as shown below. When groups are edited and saved, the system will remember those modified groups.

C#開發(fā)微信門戶及應(yīng)用-在管理系統(tǒng)中同步微信用戶分組信息

2. Group synchronization operation code display

In order to better realize the management of group synchronization, I encapsulated the group operation code in an MVC control In the server method, the page code can be synchronized through Ajax calls. If the synchronization is successful or fails, the user will be prompted to let us understand the results.

When synchronizing, create a group on the server for the newly added local content; modify the modified group name on the server, and then perform synchronization list processing. Before the synchronization operation, the list interface may be as follows As shown in the figure, there are new records with ID=-1, and there are also records with modification flags after modification.

C#開發(fā)微信門戶及應(yīng)用-在管理系統(tǒng)中同步微信用戶分組信息

The synchronization button operation of user grouping is to call a script code. The specific code is as follows.

????????//綁定提交按鈕的的點(diǎn)擊事件
????????function?BindSyncDataEvent()?{
????????????$("#btnSyncData").click(function?()?{
????????????????$.messager.confirm("提交確認(rèn)",?"您確認(rèn)需要和微信服務(wù)器同步分組信息嗎?",?function?(action)?{
????????????????????if?(action)?{
????????????????????????//提交數(shù)據(jù)
????????????????????????$("#loading").show();

????????????????????????$.ajax({
????????????????????????????url:?'/Group/SyncGroup',
????????????????????????????type:?'post',
????????????????????????????dataType:?'json',
????????????????????????????success:?function?(data)?{
????????????????????????????????if?(data.Success)?{
????????????????????????????????????$("#grid").datagrid("reload");
????????????????????????????????????$.messager.alert("提示",?"同步成功");
????????????????????????????????}
????????????????????????????????else?{
????????????????????????????????????$.messager.alert("提示",?"同步失敗:"?+?data.ErrorMessage);
????????????????????????????????}
????????????????????????????},
????????????????????????????data:?''
????????????????????????});

????????????????????????$("#loading").fadeOut(500);
????????????????????}
????????????????});
????????????});
????????}

The red part above is the MVC controller method called through Jquery. The specific function code is as follows.

????????///?<summary>
????????///?同步服務(wù)器的分組信息????????///?</summary>
????????///?<returns></returns>
????????public?ActionResult?SyncGroup()
????????{????????????string?accessToken?=?GetAccessToken();
????????????CommonResult?result?=?BLLFactory<Group>.Instance.SyncGroup(accessToken);????????????return?ToJsonContent(result);
????????}

從上面,我們沒有看到太多的邏輯,為了方便我對(duì)他們進(jìn)行了進(jìn)一步的封裝,把它放到了業(yè)務(wù)邏輯層進(jìn)行處理了。具體我們看看它的代碼邏輯吧,這里為了所有的數(shù)據(jù)庫(kù)操作更加快捷和完整,使用了事務(wù)的操作,我把相關(guān)的代碼貼出來,方便大家了解邏輯。

????????///?<summary>
????????///?同步服務(wù)器的分組信息????????///?</summary>
????????///?<returns></returns>
????????public?CommonResult?SyncGroup(string?accessToken)
????????{
????????????CommonResult?result?=?new?CommonResult();????????????try
????????????{
????????????????IUserApi?api?=?new?UserApi();????????????????using?(DbTransaction?trans?=?baseDal.CreateTransaction())
????????????????{????????????????????//先把本地標(biāo)志groupId?=?-1未上傳的記錄上傳到服務(wù)器,然后進(jìn)行本地更新
????????????????????string?condition?=?string.Format("GroupID?=?'-1'?");
????????????????????List<GroupInfo>?unSubmitList?=?base.Find(condition);????????????????????foreach?(GroupInfo?info?in?unSubmitList)
????????????????????{
????????????????????????GroupJson?groupJson?=?api.CreateGroup(accessToken,?info.Name);????????????????????????if?(groupJson?!=?null)
????????????????????????{
????????????????????????????info.GroupID?=?groupJson.id;
????????????????????????????baseDal.Update(info,?info.ID,?trans);
????????????????????????}
????????????????????}????????????????????//把標(biāo)志為修改狀態(tài)的記錄,在服務(wù)器上修改
????????????????????condition?=?string.Format("GroupID?>=0?and?Modified?=1?");
????????????????????List<GroupInfo>?unModifyList?=?base.Find(condition);????????????????????foreach?(GroupInfo?info?in?unModifyList)
????????????????????{
????????????????????????CommonResult?modifyed?=?api.UpdateGroupName(accessToken,?info.GroupID,?info.Name);????????????????????????if?(modifyed?!=?null?&&?modifyed.Success)
????????????????????????{
????????????????????????????info.Modified?=?0;//重置標(biāo)志????????????????????????????baseDal.Update(info,?info.ID,?trans);
????????????????????????}
????????????????????}????
?????
????????????????????//刪除具有刪除標(biāo)志的分組????????????????????//condition?=?string.Format("GroupID?>=100?and?Deleted=1?");????????????????????//List<GroupInfo>?unDeletedList?=?base.Find(condition);????????????????????//foreach?(GroupInfo?info?in?unDeletedList)????????????????????//{????????????????????//????CommonResult?deleted?=?api.DeleteGroup(accessToken,?info.GroupID,?info.Name);????????????????????//????if?(deleted?!=?null?&&?deleted.Success)????????????????????//????{????????????????????//????????baseDal.Delete(info.ID,?trans);????????????????????//????}????????????????????//}
????????????????????List<GroupJson>?list?=?api.GetGroupList(accessToken);????????????????????foreach?(GroupJson?info?in?list)
????????????????????{
????????????????????????UpdateGroup(info,?trans);
????????????????????}????????????????????try
????????????????????{
????????????????????????trans.Commit();
????????????????????????result.Success?=?true;
????????????????????}????????????????????catch?
????????????????????{
????????????????????????trans.Rollback();????????????????????????throw;
????????????????????}???????????????????
????????????????}
????????????}????????????catch?(Exception?ex)
????????????{
????????????????result.ErrorMessage?=?ex.Message;
????????????}????????????return?result;
????????}

在Jquery同步的時(shí)候,我們?yōu)榱吮苊獾却龝r(shí)間過久而無法判斷程序是否正常在工作,最好增加一個(gè)忙碌的提示操作,因?yàn)槲覀兪褂昧薃jax調(diào)用,所以我們可以統(tǒng)一設(shè)置Ajax的忙碌和完成狀態(tài),具體設(shè)置代碼如下所示。

????????//用來統(tǒng)一請(qǐng)求忙碌顯示的設(shè)置
????????$.ajaxSetup({
????????????beforeSend:?function?()?{
????????????????$("#loading").show();
????????????},
????????????complete:?function?()?{
????????????????$("#loading").hide();
????????????}
????????});

?

如果感興趣或者體驗(yàn)相關(guān)的微信功能,可以關(guān)注我的微信了解下。具體效果可以關(guān)注我的微信門戶:廣州愛奇迪,也可以掃描下面二維碼進(jìn)行關(guān)注了解。

C#開發(fā)微信門戶及應(yīng)用-在管理系統(tǒng)中同步微信用戶分組信息

更多C#開發(fā)微信門戶及應(yīng)用-在管理系統(tǒng)中同步微信用戶分組信息?相關(guān)文章請(qǐng)關(guān)注PHP中文網(wǎng)!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)