예제 #1
0
        private void searchResponse(string strResult)
        {
            //in contrast:
            //netc.SendTCPString(remoteIEP, SearchResponseHead + clientLocal.ToString() + GlobalVar.SplitChar_Path + strResult);
            int          locaSplit    = strResult.LastIndexOf(GlobalVar.SplitChar_Path);
            ClientBrief  clientRemote = new ClientBrief(strResult.Substring(0, locaSplit));
            List <TDocs> listResult   = JsonConvert.DeserializeObject <List <TDocs> >(strResult.Substring(locaSplit + 1));

            object[] obj = new object[3];
            obj[0] = clientRemote;
            obj[1] = listResult;
            if (RemoteSearchResponse != null)
            {
                System.ComponentModel.ISynchronizeInvoke aSynch = RemoteSearchResponse.Target as System.ComponentModel.ISynchronizeInvoke;
                if (aSynch.InvokeRequired)
                {
                    MessageEventArgs msarg = new MessageEventArgs(obj);
                    object[]         args  = new object[2] {
                        this, msarg
                    };
                    aSynch.Invoke(RemoteSearchResponse, args);
                }
                else
                {
                    RemoteSearchResponse(this, new MessageEventArgs(obj));
                }
            }
        }
예제 #2
0
 public void InitCon(TDocs indoc, ClientBrief target)
 {
     if (indoc == null)
     {
         return;
     }
     tdoc         = indoc;
     TargetClient = target;
     updateCon();
 }
예제 #3
0
        private void RemoteSearchResponseCallBack(object sender, MessageEventArgs e)
        {
            ClientBrief client        = e.MessageObj[0] as ClientBrief;
            string      strRemoteName = client.Name;

            changeStatusBar("[正在加载局域网搜索结果]", "节点:" + client.Name, true);
            List <TDocs> listResult = e.MessageObj[1] as List <TDocs>;

            addResultItemCons(listResult, client);
            changeStatusBar("[局域网搜索结果加载完成]", "节点:" + client.Name + "  新增结果" + listResult.Count + "项", false);
        }
예제 #4
0
 private void addResultItemCons(List <TDocs> doclist, ClientBrief targetClient)
 {
     foreach (TDocs tdoc in doclist)
     {
         ResultItemCon resultCon = new ResultItemCon(tdoc, targetClient);
         lcResult.Controls.Add(resultCon);
         LayoutControlItem lci = new LayoutControlItem(lcResult, resultCon);
         lci.TextVisible      = false;
         lci.ControlAlignment = ContentAlignment.TopLeft;
         resultCon.OpenFile  += new EventHandler <MessageEventArgs>(OpenFileCallBack);
     }
 }
예제 #5
0
        private void OpenFileCallBack(object sender, MessageEventArgs e)
        {
            ClientBrief target     = e.MessageObj[0] as ClientBrief;
            string      sourcePath = e.MessageObj[1] as string;

            if (target.Name == GlobalVar.LocalPath)
            {
                try
                {
                    System.Diagnostics.Process.Start(sourcePath);
                }
                catch (Exception ex) {
                    Debug.WriteLine(ex.Message);
                }
            }
            else
            {
                netopt.FileRequest(target.IEP, sourcePath);
            }
        }
예제 #6
0
        public void SendSearchResult(SearchObj sobj, List <TDocs> listResult)
        {
            IPEndPoint remoteIEP = sobj.ReqSource.IEP;

            /*
             * JavaScriptSerializer:
             * obj.ToScriptJsonString<T>()
             * obj.ToScriptJsonObject<T>()
             * reference to System.Runtime.Serialization.dll
             * using System.Runtime.Serialization.Json;
             * DataContract:
             * obj.ToJsonString<T>()
             * obj.ToJsonObject<T>()
             * reference to System.Web.Extensions.dll
             * using System.Web.Script.Serialization;
             */
            string      strResult   = JsonConvert.SerializeObject(listResult);
            ClientBrief clientLocal = new ClientBrief(netc.LocalServiceIEP, Dns.GetHostName());

            netc.SendTCPString(remoteIEP, SearchResponseHead + clientLocal.ToString() + GlobalVar.SplitChar_Path + strResult);
        }
예제 #7
0
 public ResultItemCon(TDocs indoc, ClientBrief target)
     : this(indoc)
 {
     InitCon(indoc, target);
 }