本文整理汇总了C#中Select.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Select.Save方法的具体用法?C# Select.Save怎么用?C# Select.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Select
的用法示例。
在下文中一共展示了Select.Save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveTmpAuthCode
/// <summary>
/// 保存服务器推送临时授权码
/// </summary>
/// <param name="tb"></param>
public void SaveTmpAuthCode(Hashtable tb)
{
SuiteKeyInfo suiteKeyInfo = new SuiteKeyInfo(tb["SuiteKey"]);
DingApiDispatch dingApi = new DingApiDispatch(suiteKeyInfo.SuiteKey, suiteKeyInfo.SuiteSecret,
suiteKeyInfo.SuiteTicket);
//用临时授权码获得永久授权码
PermanentCode permanentCode = dingApi.GetPermanentCode(suiteKeyInfo.SuiteToken, tb["AuthCode"].ToString());
SuiteCorpInfo suiteCorp = new SuiteCorpInfo(SuiteCorpInfo.Columns.Corpid,
permanentCode.auth_corp_info.corpid);
suiteCorp.SuiteKey = suiteKeyInfo.SuiteKey;
suiteCorp.TmpAuthCode = tb["AuthCode"].ToString();
suiteCorp.PermanentCode = permanentCode.permanent_code;
suiteCorp.Corpid = permanentCode.auth_corp_info.corpid;
suiteCorp.CorpName = permanentCode.auth_corp_info.corp_name;
//获取企业授权的access_token
CorpAccessToken corpAccessToken = dingApi.GetCorpToken(suiteKeyInfo.SuiteToken, suiteCorp.Corpid,
suiteCorp.PermanentCode);
suiteCorp.AccessToken = corpAccessToken.access_token;
suiteCorp.TokenExpires = DateTime.Now.AddSeconds(corpAccessToken.expires_in);
//获取企业授权的授权数据
AuthCorp authCorp = dingApi.GetAuthInfo(suiteKeyInfo.SuiteKey, suiteKeyInfo.SuiteToken, suiteCorp.Corpid,
suiteCorp.PermanentCode);
suiteCorp.CorpLogoUrl = authCorp.auth_corp_info.corp_logo_url;
suiteCorp.Mobile = authCorp.auth_user_info.mobile;
suiteCorp.Name = authCorp.auth_user_info.name;
suiteCorp.Save();
try
{
foreach (AgentInfo angInfo in authCorp.auth_info.agent)
{
SuiteCorpAgent suiteCorpAgent = new Select().From(SuiteCorpAgent.Schema)
.Where(SuiteCorpAgent.Columns.CorpId).IsEqualTo(suiteCorp.Corpid)
.And(SuiteCorpAgent.Columns.AgentId).IsEqualTo(angInfo.agentid)
.ExecuteSingle<SuiteCorpAgent>() ?? new SuiteCorpAgent();
suiteCorpAgent.SuiteKey = suiteKeyInfo.SuiteKey;
suiteCorpAgent.CorpId = suiteCorp.Corpid;
suiteCorpAgent.AgentId = angInfo.agentid;
suiteCorpAgent.AgentName = angInfo.agent_name;
suiteCorpAgent.LogoUrl = angInfo.logo_url;
suiteCorpAgent.Appid = angInfo.appid;
dingApi.ActivateSuite(suiteKeyInfo.SuiteKey, suiteKeyInfo.SuiteToken, suiteCorp.Corpid,
suiteCorp.PermanentCode);
Agent agent = dingApi.GetAgent(suiteKeyInfo.SuiteKey, suiteKeyInfo.SuiteToken, suiteCorp.Corpid,
suiteCorp.PermanentCode, suiteCorpAgent.AgentId);
suiteCorpAgent.Description = agent.description;
suiteCorpAgent.IsClose = agent.close;
suiteCorpAgent.Save();
}
}
catch (Exception ex)
{
Helper.WriteLog("Err:" + ex.Message);
}
}