示例#1
0
        /// <summary>
        /// 获取用户使用痕迹
        /// </summary>
        /// <param name="path"></param>
        public static Stack <string> getUserTrack()
        {
            Stack <string> userIDStack = new Stack <string>();

            try
            {
                StreamReader trackReader = new StreamReader(PATH_USER_TRACK, Encoding.Default);
                string       line;
                string       userName;
                while ((line = trackReader.ReadLine()) != null)
                {
                    userName = CodeAnalysis.getValueString(line)[0];
                    if (!userIDStack.Contains(userName))
                    {
                        userIDStack.Push(userName);
                    }
                }
                trackReader.Close();
            }
            catch (Exception e)
            {
                Reporter.reportBug(e.ToString());
            }
            return(userIDStack);
        }
示例#2
0
        /// <summary>
        /// 同步线程方法
        /// </summary>
        public void threadSync()
        {
            //setSyncFormFileStatus(SyncResult.getSyncFileResult(userLocalInfo.SyncPath), SyncResult.FileSyncStatus.Fail);
            while (true)
            {
                try
                {
                    //setCloudDiskFormSyncLabel("正在尝试同步");
                    int    tempExitCode = CMDComand.syncDirectory(userLocalInfo.SyncPath, userInfo.UserID, userInfo.Password, userInfo.SyncServerAddress);
                    string syncResult   = SyncResult.getSyncResult();
                    if (tempExitCode == 0)
                    {
                        setCloudDiskFormSyncLabel(syncResult);

                        /*
                         * if (syncResult.Equals(SyncResult.RESULT_SYNC_SUCCESS))
                         * {
                         *  //setSyncFormFileStatus(SyncResult.getSyncFileResult(userLocalInfo.SyncPath), SyncResult.FileSyncStatus.Success);
                         * }
                         * else
                         * {
                         *  //setSyncFormFileStatus(SyncResult.getSyncFileResult(userLocalInfo.SyncPath), SyncResult.FileSyncStatus.Fail);
                         * }
                         */
                    }
                    else
                    {
                        setCloudDiskFormSyncLabel("同步进程未能正常执行");
                        //setSyncFormFileStatus(SyncResult.getSyncFileResult(userLocalInfo.SyncPath), SyncResult.FileSyncStatus.Fail);
                    }
                    Thread.Sleep(2000);
                    /* 清除同步记录 */
                    SyncResult.clearSyncResult();
                    if (!isAutoSync)
                    {
                        return;
                    }
                }
                catch (Exception e)
                {
                    Reporter.reportBug(e.ToString());
                }
            }
        }
示例#3
0
        /// <summary>
        /// 连接线程
        /// </summary>
        void thread_connect()
        {
            try
            {
                //lock (SocketClient)

                SocketClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(ServerIP), ServerPort);
                SocketClient.Connect(serverEndPoint);
                Reporter.writeLog(MyConfig.PATH_NET_LOG, "connect to " + ServerIP + ":" + ServerPort.ToString());
                if (SocketClient.Connected)
                {
                    SocketClient.BeginReceive(msgByte, 0, msgByte.Length, 0, asycnCallBack, null);
                }
            }
            catch (Exception e)
            {
                Reporter.reportBug(e.ToString());
                //throw e;
            }
        }
示例#4
0
        /// <summary>
        /// 获得指定的子树
        /// </summary>
        /// <param name="directoryPath"></param>
        /// <returns></returns>
        public FileTree getTargetTree(string directoryPath)
        {
            Stack <string> pathBlock = getPathBlock(directoryPath);

            if (pathBlock == null)
            {
                return(null);
            }
            FileTree fileTree = this;

            try
            {
                while (pathBlock.Count > 0)
                {
                    fileTree = fileTree.SubTree[pathBlock.Pop()];
                }
            }
            catch (Exception e)
            {
                Reporter.reportBug(e.ToString());
            }
            return(fileTree);
        }
示例#5
0
 /// <summary>
 /// 计时线程
 /// </summary>
 void thread_Timer()
 {
     try
     {
         int time_clock = 0;
         int time_step  = 100;
         while (time_clock < TimeToLive)
         {
             time_clock += time_step;
             Thread.Sleep(time_step);
         }
         lock (User_Info)
         {
             User_Info.login_result = false;
             User_Info.error_code   = ErrorCode.ERROR_CODE_CONNECT_TIMEOUT;
         }
         MethodInvoker methodInvokeNavigation = new MethodInvoker(navigateToLoginWindow);
         BeginInvoke(methodInvokeNavigation);
     }
     catch (Exception e)
     {
         Reporter.reportBug(e.ToString());
     }
 }
示例#6
0
        /// <summary>
        /// 收到消息后的处理
        /// </summary>
        /// <param name="iar"></param>
        void receiveCallBack(IAsyncResult iar)
        {
            try
            {
                int    REnd            = netHelper.SocketClient.EndReceive(iar);
                string receive_content = Encoding.UTF8.GetString(netHelper.msgByte, 0, REnd);
                string full_content    = "";
                if (!string.IsNullOrEmpty(receive_content) && receive_content != "")
                {
                    Reporter.writeLog(MyConfig.PATH_NET_LOG, "login : "******"李坑";
                        //userInfo.login_result = true;

                        Hashtable ht = JsonHelper.getDeserializeObject <Hashtable>(full_content);
                        if (ht.ContainsKey(UserInfo.NAME_USER_NAME))
                        {
                            userInfo.UserName = ht[UserInfo.NAME_USER_NAME].ToString();
                        }
                        if (ht.ContainsKey(UserInfo.NAME_ICON))
                        {
                            userInfo.Icon = ht[UserInfo.NAME_ICON].ToString();
                        }
                        if (ht.ContainsKey(UserInfo.NAME_LOGIN_RESULT))
                        {
                            userInfo.login_result = (bool)ht[UserInfo.NAME_LOGIN_RESULT];
                        }
                        if (ht.ContainsKey(UserInfo.NAME_ERRO_CODE))
                        {
                            userInfo.error_code = int.Parse(ht[UserInfo.NAME_ERRO_CODE].ToString());
                        }


                        User_Info = userInfo;
                        MethodInvoker methodInvokeNavigation = new MethodInvoker(navigateToLoginWindow);
                        BeginInvoke(methodInvokeNavigation);
                    }
                    netHelper.beginReceiveCallBack();
                }
            }
            catch (Exception e)
            {
                Reporter.reportBug(e.ToString());
            }
        }