Beispiel #1
0
 public bool SaveData(MPcs mPcs)
 {
     string path = TbLocal.Text.Trim();
     if (string.IsNullOrEmpty(path))
     {
         MessageBox.Show("请输入或选择本地存储路径!");
         TbLocal.Focus();
         return false;
     }
     if (!Directory.Exists(path))
     {
         MessageBox.Show("您选择的目录不存在!");
         return false;
     }
     try
     {
         string file = Path.Combine(path, "amon.sync");
         FileInfo info = new FileInfo(file);
         if (!info.Exists)
         {
             StreamWriter writer = info.CreateText();
             writer.Write("Demo");
             writer.Close();
         }
         mPcs.LocalRoot = path;
         return true;
     }
     catch (Exception exp)
     {
         MessageBox.Show(exp.Message);
         TbLocal.Focus();
         return false;
     }
 }
Beispiel #2
0
 public void ShowData(MPcs mPcs)
 {
     if (mPcs != null)
     {
         CbServer.SelectedItem = new Items { K = mPcs.ServerType };
     }
 }
Beispiel #3
0
 public void SavePcs(MPcs pcs)
 {
     if (!CharUtil.IsValidateCode(pcs.UserCode))
     {
         pcs.UserCode = _UserModel.Code;
     }
     _DbEngine.Save(pcs);
 }
Beispiel #4
0
        public PcsView(WPcs wPcs, MPcs mPcs, PcsClient pcsClient, UserModel userModel, DataModel dataModel)
        {
            _WPcs = wPcs;
            MPcs = mPcs;
            _UserModel = userModel;
            _DataModel = dataModel;
            _PcsClient = pcsClient;

            InitializeComponent();
        }
Beispiel #5
0
 public PcsClient GetClient(MPcs pcs)
 {
     switch (pcs.ServerType)
     {
         case "native":
             return NewNative(pcs);
         case "kuaipan":
             return NewKuaipan(pcs);
         default:
             return null;
     }
 }
Beispiel #6
0
 public void ShowData(MPcs mPcs)
 {
     switch (mPcs.ServerType)
     {
         case CPcs.PCS_TYPE_KUAIPAN:
             _Client = new Me.Amon.Open.V1.App.Pcs.KuaipanClient(OAuthConsumer.KuaipanConsumer(), true);
             if (!_Client.RequestToken())
             {
                 return;
             }
             WbBrowser.Navigate(_Client.GetAuthorizeUrl());
             break;
     }
 }
Beispiel #7
0
        public bool SaveData(MPcs mPcs)
        {
            var item = CbServer.SelectedItem as Items;
            if (item == null || string.IsNullOrWhiteSpace(item.K))
            {
                MessageBox.Show("请选择服务提供商!");
                CbServer.Focus();
                return false;
            }

            mPcs.ServerType = item.K;
            mPcs.ServerName = item.V;
            return true;
        }
Beispiel #8
0
        public bool SaveData(MPcs mPcs)
        {
            string token = TbToken.Text.Trim();
            if (string.IsNullOrEmpty(token))
            {
                MessageBox.Show("请输入授权码!");
                TbToken.Focus();
                return false;
            }
            //mPcs.Token = token;

            if (_Client == null)
            {
                return false;
            }
            if (!_Client.AccessToken())
            {
                return false;
            }
            mPcs.Token = _Client.Token.oauth_token;
            mPcs.TokenSecret = _Client.Token.oauth_token_secret;
            return true;
        }
Beispiel #9
0
        private void LbItem_SelectedIndexChanged(object sender, EventArgs e)
        {
            var pcs = LbItem.SelectedItem as MPcs;
            if (pcs == null)
            {
                return;
            }
            if (pcs.Account != null)
            {
                return;
            }

            if (BwWorker.IsBusy)
            {
                BwWorker.CancelAsync();
            }
            _MPcs = pcs;
            BwWorker.RunWorkerAsync();
            BtUpdate.Enabled = false;
        }
Beispiel #10
0
 public void ShowData(MPcs mPcs)
 {
     TbLocal.Text = mPcs.LocalRoot;
 }
Beispiel #11
0
        private void NewKuaipan(MPcs mPcs)
        {
            var client = _PcsList.GetClient(mPcs);

            TabPage ntp = new TabPage();
            ntp.Text = mPcs.UserName;
            ntp.ImageKey = CPcs.PCS_TYPE_KUAIPAN;
            TcMeta.TabPages.Add(ntp);

            var pcs = new PcsView(this, mPcs, client, _UserModel, _DataModel);
            pcs.Init();
            pcs.MetaUri = UcUri;
            pcs.Dock = DockStyle.Fill;
            ntp.Controls.Add(pcs);

            TcMeta.SelectedTab = ntp;
        }
Beispiel #12
0
        private void NewNative(MPcs mPcs)
        {
            var client = new NativeClient();

            TabPage ntp = new TabPage();
            ntp.Text = NativeIndex < 1 ? "本地" : string.Format("本地 ({0})", NativeIndex);
            ntp.ImageKey = CPcs.PCS_TYPE_NATIVE;
            TcMeta.TabPages.Add(ntp);

            var pcs = new PcsView(this, mPcs, client, _UserModel, _DataModel);
            pcs.Init();
            pcs.MetaUri = UcUri;
            pcs.Dock = DockStyle.Fill;
            ntp.Controls.Add(pcs);

            TcMeta.SelectedTab = ntp;
            NativeIndex += 1;
        }
Beispiel #13
0
 private PcsClient NewKuaipan(MPcs pcs)
 {
     var token = new Me.Amon.Open.V1.OAuthTokenV1();
     token.oauth_token = pcs.Token;
     token.oauth_token_secret = pcs.TokenSecret;
     token.UserId = pcs.UserId;
     KuaipanClient client = new KuaipanClient(OAuthConsumer.KuaipanConsumer(), token, false);
     if (token.oauth_token.Length != 24 && token.oauth_token_secret.Length != 32)
     {
         client.Verify();
     }
     return client;
 }
Beispiel #14
0
 public void OpenPcs(MPcs mPcs)
 {
     switch (mPcs.ServerType)
     {
         case "native":
             NewNative(mPcs);
             break;
         case "kuaipan":
             NewKuaipan(mPcs);
             break;
         default:
             break;
     }
 }
Beispiel #15
0
 public void RemovePcs(MPcs pcs)
 {
 }
Beispiel #16
0
 public void DeletePcs(MPcs pcs)
 {
     _DbEngine.Delete(pcs);
 }
Beispiel #17
0
 public void Init()
 {
     MPcs = new MPcs();
     ShowServer();
 }
Beispiel #18
0
 private PcsClient NewNative(MPcs mPcs)
 {
     return new NativeClient();
 }
Beispiel #19
0
        public void Init()
        {
            string path = Path.Combine(_UserModel.SysHome, "Pcs");
            string file = Path.Combine(path, "native24.png");
            MPcs mPcs = new MPcs();
            mPcs.ServerType = CPcs.PCS_TYPE_NATIVE;
            mPcs.ServerName = "本地演示";
            mPcs.UserId = "0";
            mPcs.UserName = Environment.UserName;
            if (File.Exists(file))
            {
                mPcs.Logo = Image.FromFile(file);
            }
            LbItem.Items.Add(mPcs);

            foreach (var pcs in _DataModel.ListPcs())
            {
                pcs.Init();
                file = Path.Combine(path, pcs.ServerType + "24.png");
                if (File.Exists(file))
                {
                    pcs.Logo = Image.FromFile(file);
                }
                LbItem.Items.Add(pcs);
            }
        }