예제 #1
0
    // Use this for initialization
    void Start()
    {
        var options = new DataSyncClientOptions()
        {
            EndpointAddress = "http://localhost:4000/api/data",
            ProjectId       = "testproject",
            LogFilePath     = testDataPath + "/ log.txt"
        };

        //Docker
        options.EndpointAddress = "http://localhost/api/data";

        //server
        options.EndpointAddress = "http://api.mindfrog.cn/api/data";


        if (!Directory.Exists("TestStore"))
        {
            Directory.CreateDirectory("TestStore");
        }
        applicationLifecycle = new SimpleApplicationLifecycle();


        _client = new DataSyncClient(new UnityApplicationFolderProvider(testDataPath + "/TestStore"),
                                     applicationLifecycle, options, () => "testUser");

        _client.Init();


        StartUpload();
    }
예제 #2
0
        /// <summary>
        /// 传入UserID初始化LabDataCollect
        /// </summary>
        /// <param name="userId"></param>
        public void LabDataCollectInit(Func <string> userId)
        {
            if (_isClientInit)
            {
                return;
            }

            #region 初始化本地存储
            _localSaveDataTimeLayout = LabTools.GetConfig <LabDataConfig>().LocalSaveDataTimeLayout;
            _userId       = userId;
            _saveDataPath = Application.dataPath + "/Output";
            LabTools.CreatSaveDataFolder(_saveDataPath);
            var userStr = _userId.Invoke().PadLeft(2, '0');
            _saveDataPath = string.Join("_", _saveDataPath + "/" + DateTime.Now.ToString(_localSaveDataTimeLayout), userStr);
            _saveDataPath = LabTools.CreatSaveDataFolder(_saveDataPath);
            #endregion

            #region 初始化上传服务

            var options = new DataSyncClientOptions()
            {
                EndpointAddress = "http://localhost:4000/api/data",
                ProjectId       = LabTools.GetConfig <LabDataConfig>().ProjectId,
                LogFilePath     = labDataSavePath + "/ log.txt"
            };

            //Docker
            options.EndpointAddress = "http://localhost/api/data";

            //server
            _sendToServer           = LabTools.GetConfig <LabDataConfig>().SendToServer;
            options.EndpointAddress = LabTools.GetConfig <LabDataConfig>().ServerPath;


            if (!Directory.Exists("TestStore"))
            {
                Directory.CreateDirectory("TestStore");
            }
            _applicationLifecycle = new SimpleApplicationLifecycle();


            _client = new DataSyncClient(new UnityApplicationFolderProvider(labDataSavePath + "/TestStore"),
                                         _applicationLifecycle, options, _userId);

            _client.Init();

            _isClientInit = true;

            StartUpload();

            #endregion

            Application.wantsToQuit += () => !IsClientRunning;
            _dataWriterDic           = new Dictionary <Type, LabDataWriter>();
            _dataQueue   = new ConcurrentQueue <LabDataBase>();
            _writeThread = new Thread(Queue2Send);
            _writeThread.Start();
        }
예제 #3
0
        /// <summary>
        /// 传入UserID初始化LabDataCollect
        /// </summary>
        /// <param name="userId"></param>
        public void LabDataCollectInit(string userId)
        {
            _localSaveDataTimeLayout = LabTools.GetConfig <LabDataConfig>().LocalSaveDataTimeLayout;
            if (_isClientInit)
            {
                return;
            }
            _userId = userId;
            //StartAutoDataCollect();
            var options = new DataSyncClientOptions()
            {
                EndpointAddress = "http://localhost:4000/api/data",
                ProjectId       = LabTools.GetConfig <LabDataConfig>().ProjectId,
                LogFilePath     = labDataSavePath + "/ log.txt"
            };

            //Docker
            options.EndpointAddress = "http://localhost/api/data";

            //server

            /*
             * _sendToServer = LabTools.GetConfig<LabDataConfig>().SendToServer;
             * options.EndpointAddress = LabTools.GetConfig<LabDataConfig>().ServerPath;
             * //SendDataToServer(0,0,0);
             */



            if (!Directory.Exists("TestStore"))
            {
                Directory.CreateDirectory("TestStore");
            }
            _applicationLifecycle = new SimpleApplicationLifecycle();


            _client = new DataSyncClient(new UnityApplicationFolderProvider(labDataSavePath + "/TestStore"),
                                         _applicationLifecycle, options, () => _userId);

            _client.Init();

            _isClientInit = true;

            StartUpload();
        }