惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
D
Docker
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
宝玉的分享
宝玉的分享
腾讯CDC
Google Online Security Blog
Google Online Security Blog
Recorded Future
Recorded Future
T
The Exploit Database - CXSecurity.com
T
The Blog of Author Tim Ferriss
V
V2EX
S
Securelist
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
Y
Y Combinator Blog
P
Proofpoint News Feed
T
Tor Project blog
AWS News Blog
AWS News Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
T
Threat Research - Cisco Blogs
B
Blog
Attack and Defense Labs
Attack and Defense Labs
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
N
News and Events Feed by Topic
博客园 - 司徒正美
H
Help Net Security
C
Cisco Blogs
C
Check Point Blog
S
Secure Thoughts

博客园 - czh

基于MDB_ICP协议的纸币识别器与自动售货机通讯的研究 How could you login to ms sql server if you lost system admin password to setup windows auto-login Compile DLLs referenced into exe/dll 族谱软件系统的使用介绍 javascript在vs2003中调试随笔和javascript使用小总结[转载] 世界互联网正处于剧变前夜! 系统分析师 考试 DVD playable asp.net 页面事件:顺序与回传 创业还是读研? C#判断文件名是否合法 Window消息大全 关于STRONG NAME 好东西 一名25岁的董事长给大学生的18条忠告(不想虚度年华的进来) ZT SQL*PLUS命令的使用大全 如何做一个增加系统DSN的过程 ASP连接11种数据库语法总结
Mobile Network auto-Connection
czh · 2018-07-25 · via 博客园 - czh
        private static string GetProviderAPN(string providerName)
        {
            if(providerName .Trim ()=="3")
            {
                return "ipc.three.com.hk";
            }

            if (providerName.Trim().ToLower () == "cmhk")
            {
                return "CMHK";
            }

            if (providerName.Trim().ToLower() == "smartone")
            {
                return "smartone";
            }

            return string.Empty;
        }
 private static string GetProfile(string PfName, string SubscriberID, string SimIccID, string HomeProviderName, string AccessString,string DisplayProviderName)
        {
               return  $@"<?xml version=""1.0""?>
<MBNProfile xmlns = ""http://www.microsoft.com/networking/WWAN/profile/v1"">
    <Name>{PfName}</Name>
	<IsDefault>true</IsDefault>
	<ProfileCreationType>UserProvisioned</ProfileCreationType>
	<SubscriberID>{SubscriberID}</SubscriberID>
	<SimIccID>{SimIccID}</SimIccID>
	<HomeProviderName>{HomeProviderName}</HomeProviderName>
	<ConnectionMode>auto</ConnectionMode>
	<Context>
		<AccessString>{AccessString}</AccessString>
		<Compression>DISABLE</Compression>
		<AuthProtocol>NONE</AuthProtocol>
	</Context>
	<DisplayProviderName xmlns = ""http://www.microsoft.com/networking/WWAN/profile/v2"">{DisplayProviderName}</DisplayProviderName>
</MBNProfile>
";
    }
 public static void AddProfile(string profileName)
       {
            try
            {
                XmlDocument xdoc = new XmlDocument();
                string profileString = System.IO.File.ReadAllText(Path.Combine(pfFolder, profileName));
                xdoc.LoadXml(profileString);
                string ProfileInfo = xdoc["MBNProfile"]["HomeProviderName"].InnerText +"/"+ xdoc["MBNProfile"]["Name"].InnerText +"/"+ xdoc["MBNProfile"]["SimIccID"].InnerText  ;
                AddProfileWithXML(xdoc.OuterXml);
                Global.LogLocalThingsInfo($"AddProfile:{ProfileInfo}");
            }
            catch(Exception ex )
            {
                Global.LogLocalThingsError(ex);
            }
        }

        public static void AddProfileWithXML(string xml)
        {
            try
            {   
                MbnConnectionProfileManager mbnConnProfileMgr = new MbnConnectionProfileManager();
                IMbnConnectionProfileManager mbnConnProfileMgrInterface = mbnConnProfileMgr as IMbnConnectionProfileManager;               
                mbnConnProfileMgrInterface.CreateConnectionProfile(xml);
            }
            catch (Exception ex)
            {
                Global.LogLocalThingsError(ex);
            }
        }

 Calling:

if(!string.IsNullOrEmpty (HomeProviderName))
                        {
                            uint id;
                            string DisplayProviderName = "3";
                            string PfName = DisplayProviderName;
                            string v = GetProfile(PfName, SubscriberID, SimIccID, HomeProviderName, AccessString, DisplayProviderName);
                            System.IO.File.WriteAllText(Path.Combine(Network.pfFolder, PfName), v);

                            message += " Pf is empty, Connect with new Profile:" + Environment.NewLine + v + Environment.NewLine;

                            Network.AddProfile(PfName);
                            conn.Connect(MBN_CONNECTION_MODE.MBN_CONNECTION_MODE_PROFILE, PfName, out id);
                        }