Example #1
0
        public void StartServer(delReceivedMessageHandler handler)
        {
            msgHandler = handler;
             fuSocket = new FuSocket().CreateInstance(GlobalVariables.SocketPort);

            fuSocket.StartServer(ServerAction);
        }
Example #2
0
 public FuSocket CreateInstance(int socketport)
 {
     if (fuSocket == null)
     {
         port = socketport;
         fuSocket = new FuSocket();
     }
     return fuSocket;
 }
Example #3
0
        public static void UploadFiles()
        {
            new SiteVariables().Init();

            Guid operationId = Guid.NewGuid();
            Logger.MyLogger.Info("###开始扫描" + operationId);
            FuSocket fusocket = new FuSocket().CreateInstance(SiteVariables.SocketPort);
            try
            {
                 
                IList<LocalCallRec> records =DbUnit.GetRecordsToBeUpload(
                    new UploadLogger().GetLastUploadedFileIndex());
                Logger.MyLogger.Info("需要处理的通话记录数量:" + records.Count);
                
                foreach (LocalCallRec call in records)
                {
                    if (records.IndexOf(call) == 0)
                    { 
                     //检验客户端合法性.
                        fusocket.ClientActions(SiteVariables.ServerIP, ValidClient);

                        if (!isClientValid)
                        {
                            Logger.MyLogger.Info("不是有效的设备号,服务停止.");
                            fusocket.ClientActions(SiteVariables.ServerIP, ValidError);
                            if (SiteVariables.ServiceTimer != null) { SiteVariables.ServiceTimer.Stop(); }
                            break;
                        }
                    }

                    currentUploadFile = call.FileSavePath;
                    currentDeviceNo = call.DeviceNo;
                    Logger.MyLogger.Info("开始处理:" + currentUploadFile);
                    bool result = UploadSingleFile(call);
                    fusocket.ClientActions(SiteVariables.ServerIP, SendUploadMsg);
                }
            }
            catch (Exception ex)
            {
                Logger.MyLogger.Error("###" + ex.Message + ex.StackTrace);
                fusocket.ClientActions(SiteVariables.ServerIP, SendUploadError);
            }
            Logger.MyLogger.Info("###操作结束" + operationId);
        }