SmobilerApp開發筆記

1.環境搭建https://www.smobiler.com/guide/devenv.aspx

2.在Windows上爲Smobiler服務器端口添加防火牆出入口規則

3.音頻播放

this.Client.PlayAudio("開始.wav", AppDomain.CurrentDomain.BaseDirectory);

音頻的路徑在\Source\bin\Debug

4.在MessageBox.Show()中添加方法

 MessageBox.Show("成功", MessageBoxButtons.OK, (object sender1, MessageBoxHandlerArgs args) =>
            {
                if (args.Result == ShowResult.OK)
                {
                    int x = 5;
                    int a = x++ + ++x;
                    MessageBox.Show(a.ToString());
                    this.Client.PlayAudio("開始.wav", AppDomain.CurrentDomain.BaseDirectory);
                }
            });

5.在頁面中,模板控件中刷新數據的方法
頁面中:

KehuDindanAddForm rf = new KehuDindanAddForm();
   Show(rf, true,(MobileForm sender1, object args) =>
   {
       if (rf.ShowResult == ShowResult.Yes)
       {
         Bind();
       }
   });

模板中:

ChukuPlanEditForm boDetail = new ChukuPlanEditForm() { order_no = lbl_order_no.BindDataValue.ToString() };
   Form.Show(boDetail, true, (MobileForm sender1, object args) =>
   {
      if (boDetail.ShowResult == ShowResult.Yes)
      {
          ((ChukuPlanForm)Form).Bind();
        }
   });

ShowResult = ShowResult.Yes;
Toast("添加成功");
Close();

6.在服務端可以使用 this.Client.Session 用於保存單個Client中的全局變量,在客戶端可以在窗體中使用LoadClientData和ReadClientData來保存數據

 //記住用戶名
 LoadClientData(MobileServer.ServerID + "user", user_name);

 //記住密碼
 LoadClientData(MobileServer.ServerID + "pwd", user_pwd);

//讀取用戶名
ReadClientData(MobileServer.ServerID + "user", (object sender1, ClientDataResultHandlerArgs e1) =>
{
     if (String.IsNullOrEmpty(e1.error))
     {
          txtname.Text = e1.Value;
     }
});
//讀取密碼
ReadClientData(MobileServer.ServerID + "pwd", (object sender1, ClientDataResultHandlerArgs e1) =>
 {
      if (String.IsNullOrEmpty(e1.error))
      {
           txtpwd.Text = e1.Value;
           if (txtpwd.Text.Length > 0)
           {
                 checkRemb.Checked = true;
            }
        }
  });

//刪除客戶端數據
RemoveClientData(MobileServer.ServerID + "pwd", (object s, ClientDataResultHandlerArgs args) => txtpwd.Text = "");

//寫緩存數據

Client.Session["name"] = "緩存數據";

//讀緩存數據窗體中和模板中

Session["name"]

Client.Session["name"]

7.Apk爲了區分唯一設備,需要用到一個device id

this.Client.DeviceID

每個手機設備的DeviceID都是唯一的,在每次登錄時,保存當前設備號,並與上次登錄的設備號進行比較;如果不同,可以通過代碼ClientVariables.GetCurrentClient(上一個設備的DeviceID).ReStart()關閉上一個會話。

8.跳轉網頁

在窗體中用  RedirectUrl("https://www.baidu.com/");

在模板控件中用 this.Form.RedirectUrl("https://www.baidu.com/");

9.獲取控件綁定的值(由於控件綁定的值和展示的值不一樣),用如下方法獲取綁定的值

string bdvalue = kj_name.BindDataValue.ToString();

10.獲取客戶端粘貼板內容

this.Client.GetClipboard

https://www.smobiler.com/Help/html/M_Smobiler_Core_ClientVariables_GetClipboard.htm

11.SwipeView控件,側滑控件

側滑控件介紹

基本的官網已經介紹了,以下是細節操作代碼:

列表的模板控件中需要定義一個變量,用來獲取操作當前項的依據,這裏根據編號

/// <summary>
/// 編號
/// </summary>
internal string IID
{
    get
     {
          return this.lbl_id.BindDataValue.ToString();
     }
 }

在swipeView右側滑模板的點擊事件中

private void btnDelRow_Press(object sender, EventArgs e)
        {
            try
            {
                MessageBox.Show("你確定刪除嗎?", "系統提醒", MessageBoxButtons.OKCancel, (object sender1, MessageBoxHandlerArgs args) =>
                {
                    try
                    {
                        if (args.Result == ShowResult.OK)     //刪除該盤點單
                        {
                            string a = ((DControl)Parent.Parent).IID;
                            MessageBox.Show(a);
                            ((DemoForm)Form).Bind();
                        }
                    }
                    catch (Exception ex)
                    {
                        Form.Toast(ex.Message);
                    }
                });
            }
            catch (Exception ex)
            {
                Form.Toast(ex.Message);
            }
        }

12.響應佈局參考demo 

SmobilerSamples

13.VS2017看不到那個SmobilerApplication

在羣文件中下載SmobilerDesignerVSIX.vsix,放在c盤,運行以下命令 "C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service\VSIXInstaller.exe" "C:\SmobilerDesignerVSIX.vsix"

14.Smobiler App 後臺進程關閉的時候如何讓它第一次打開是登錄頁或者是指定的頁面

MobileGLobal.cs中的 OnSessionConnect方法,可以在裏面跳轉初始或者寫ReStart,或者OnSessionConnect方法中e.Client.GetActiveForm().Show

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章