public void SaveSysConfig(DataRequest request, DataResponse result, DataProvider datasource) { EntityList <EAP_SYSConfig> configs = TJson.Parse <EntityList <EAP_SYSConfig> >(request[0]); EntityList <XX_Column> columnConfigs = TJson.Parse <EntityList <XX_Column> >(request[1]); result.Value = ToJson(new ConfigsOP(request.LogIn).SaveSysConfig(configs, columnConfigs)); }
public void DeleteRoleFromUser(DataRequest request, DataResponse result, DataProvider datasource) { EAP_User user = TJson.Parse <EAP_User>(request["P0"]); string sRoleIDs = request["P1"]; result.Value = ToJson(new AccountOP(request.LogIn).DeleteRoleFromUser(user, sRoleIDs)); }
//載入資源列表 private void LoadVersion(string versionName) { #if UNITY_TVOS && !UNITY_EDITOR string path = Application.temporaryCachePath + "/" + TinyContext.Instance.LanguagePath + "/" + "Versions/"; #else string path = Application.persistentDataPath + "/" + TinyContext.Instance.LanguagePath + "/" + "Versions/"; #endif byte[] datas = TFile.Load(path, versionName); if (datas == null) { return; } string json = System.Text.UTF8Encoding.UTF8.GetString(datas); rMD5Info[] info = TJson.DeserializeObject <rMD5Info[]>(json); if (mRecordMap != null) { mRecordMap.Clear(); } else { mRecordMap = new Dictionary <string, string>(); } for (int i = 0; i < info.Length; i++) { mRecordMap.Add(info[i].FlieName, info[i].MD5Code); } return; }
public void Save(DataRequest request, DataResponse response, DataProvider datasource) { string entityName = request[0]; Type entityType = EntityMetaManager.Default.GetMetaByTypeName(entityName).EntityType; EntityBase entity = TJson.Parse(entityType, request[1]) as EntityBase; entity.Save(null, request.LogIn, datasource); response.Value = entity.ToJson(); }
public string ProcessRequest(string query) { request = TJson.Parse <DataRequest>(query); result = new DataResponse(); LogManager.OnLogEvent += new LogEvent(LogManager_OnLogEvent); ServiceContext serviceContext = null; try { SetCulture(request); result.ServiceName = request.ServiceName; serviceContext = new ServiceContext(request, result, DataSource, HttpContext.Current); DoProcess(serviceContext); if (result.Result != ReturnCode.Fail) { result.Result = ReturnCode.Success; } } catch (Exception ex) { result.Result = ReturnCode.Error; Exception logException = ex; while (logException.InnerException != null) { logException = logException.InnerException; } try { if (request != null) { new UtilOP(request.LogIn).LogError(result.ServiceName, logException); } } catch { } if (request.LogIn != null && request.LogIn.IsDebug) { result.Message = logException.Message; result.StackTrace = logException.ToString(); } else { result.Message = logException.Message; result.StackTrace = ""; } } result.DebugInfo = sbDebug.ToString(); sbDebug = null; LogManager.OnLogEvent -= new LogEvent(LogManager_OnLogEvent); return(result.ToJson()); }
public EntityStatus _S; //{ get; set; } public EntityStatus GetChildrenStatus() { var result = S; foreach (var p in TJson.LoadTypeProperty(this.GetType(), typeof(IEntity))) { var o = p.GetValue(this, null); if (o != null) { result = MergerStatus(result, ((IEntity)o).GetChildrenStatus()); } } return(result); }
public void Search(DataRequest request, DataResponse response, DataProvider datasource) { string entityName = request[0]; SearchCriteria criteria = TJson.Parse <SearchCriteria>(request[1]); var op = EntityMetaManager.Default.GetMetaByTypeName(entityName).GetOP(request.LogIn, datasource); var searchResult = op.Load(criteria); //Type entityType = EntityMetaManager.Default.GetMetaByTypeName(entityName).EntityType; //var searchType = typeof(SearchOP<>).MakeGenericType(new Type[] { entityType }); //var searchOP = Activator.CreateInstance(searchType, request.LogIn, datasource); //var searchMethod = searchType.GetMethod("Search", new[] { typeof(SearchCriteria) }); //var searchResult = searchMethod.Invoke(searchOP, new object[] { criteria }) as TJson; response.Value = searchResult.ToJson(); }
public static UserSetting Load(int stafferId) { UserSetting result = null; try { using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication()) { string FileName = GetFileName(stafferId); if (file.FileExists(FileName)) { IsolatedStorageFileStream filestream = file.OpenFile(FileName, FileMode.Open); int fileSize = (int)filestream.Length; byte[] context = new byte[fileSize]; filestream.Read(context, 0, fileSize); MemoryStream stream = new MemoryStream(context); StreamReader reader = new StreamReader(stream); string josnString = reader.ReadToEnd(); reader.Close(); try { result = TJson.Parse <UserSetting>(josnString); } catch { } } } } catch { } if (result == null) { result = new UserSetting(stafferId); } return(result); }
//讀Json -> 只提供給內部使用 private void LoadJson(string json) { T[] dataArray = TJson.DeserializeObject <T[]>(json); if (mDataList == null) { mDataList = new List <T>(); } else { mDataList.Clear(); } for (int i = 0; i < dataArray.Length; i++) { mDataList.Add(dataArray[i]); } dataArray = null; }
//存入資源列表 private void SaveVersion(string versionName) { #if UNITY_TVOS && !UNITY_EDITOR string path = Application.temporaryCachePath + "/" + TinyContext.Instance.LanguagePath + "/" + "Versions/"; #else string path = Application.persistentDataPath + "/" + TinyContext.Instance.LanguagePath + "/" + "Versions/"; #endif if (mRecordMap.Count > 0) { rMD5Info[] info = new rMD5Info[mRecordMap.Count]; int count = 0; foreach (KeyValuePair <string, string> pair in mRecordMap) { info[count].FlieName = pair.Key; info[count].MD5Code = pair.Value; count++; } string json = TJson.SerializeObject(info); TFile.Save(path, versionName, System.Text.UTF8Encoding.UTF8.GetBytes(json)); } }
protected override void AfterDeserialize(TJson obj) { base.AfterDeserialize(obj); LoadStatus(); }
protected override void BeforeSerialize(TJson obj) { base.BeforeSerialize(obj); SaveStatus(); }
public void UserRegister(DataRequest request, DataResponse result, DataProvider datasource) { LoginUser user = TJson.Parse <LoginUser>(request["P0"]); result.Value = ToJson(new AccountOP(request.LogIn).UserRegister(user)); }
public static T SaveObjectToFile <T>(T input, string fileSaveName) { JsonData TJson; TJson = JsonMapper.ToJson(input); File.WriteAllText(Application.dataPath + "/SavedData/" + fileSaveName + ".json", TJson.ToString()); return(input); }
public void UpdateUser(DataRequest request, DataResponse result, DataProvider datasource) { EAP_User user = TJson.Parse <EAP_User>(request["P0"]); result.Value = ToJson(new AccountOP(request.LogIn).UpdateUser(user)); }
public void UploadFileAsync(DataRequest request, DataResponse response, DataProvider dataprovider) { FileChunk fc = TJson.Parse <FileChunk>(request["P0"]); response.Value = ToJson(new FileZillaOP(request.LogIn, dataprovider).UploadFileAsync(fc)); }
public void GetLookUp(DataRequest request, DataResponse result, DataProvider datasource) { LookupCriteria criteria = TJson.Parse <LookupCriteria>(request["P0"]); result.Value = ToJson(new LookupOP(request.LogIn, datasource).GetLookup(criteria)); }
protected override void AfterDeserialize(TJson obj) { base.AfterDeserialize(obj); BindTagData(); }
public void TestMethod1() { TJson.Read(); }
protected IEnumerator IGetDownloadList(string ip, string hostName, string versionName, string version) { string path = GetLocation(ip, hostName) + TinyContext.Instance.LanguagePath + "/" + "Versions/"; string name = versionName; mStatus = eStatus.Updating; yield return(null); using (WWW bundle = new WWW(path + name)) { yield return(bundle); //檢查下載錯誤訊息 if (bundle.error != null) { mStatus = eStatus.Error; mOnError.InvokeGracefully(bundle.error); mLogger.Log(bundle.error); yield break; } //檢查是否下載完成 if (bundle.isDone == true) { byte[] xor = TFile.XOR(bundle.bytes); string json = System.Text.UTF8Encoding.UTF8.GetString(xor); rRes[] datas = TJson.DeserializeObject <rRes[]>(json); if (datas[0].Version != version) { mStatus = eStatus.Error; mOnError.InvokeGracefully("版本不符"); mLogger.Log("版本不符"); yield break; } if (mDownloadList == null) { mDownloadList = new List <rRes>(); } else { mDownloadList.Clear(); } mTotalSize = 0;; for (int i = 0; i < datas.Length; i++) { if (!CheckNeedUpdate(datas [i])) { continue; } mDownloadList.Add(datas[i]); mTotalSize += datas[i].FileSize; } } else { mStatus = eStatus.Error; mOnError.InvokeGracefully(string.Format("更新失敗 -> {0}", bundle.url)); mLogger.Log(string.Format("更新失敗 -> {0}", bundle.url)); yield break; } } }
public void SetCurrAccountSet(DataRequest request, DataResponse result, DataProvider datasource) { WMS_ACCOUNTSET obj = TJson.Parse <WMS_ACCOUNTSET>(request["P0"]); result.Value = ToJson(new ApplicationOP(request.LogIn).SetCurrAccountSet(obj)); }
public void UploadTextFile(ServiceContext context) { CommandResult returnCommand = new CommandResult(); UploadMeta meta = TJson.Parse <UploadMeta>(context.E9_Request["P0"]); string dataPath = context.HttpContext.Server.MapPath("~/") + "data/"; if (!Directory.Exists(dataPath)) { Directory.CreateDirectory(dataPath); } string fileName = dataPath + meta.FileName; if (meta.Index == 0) { if (File.Exists(fileName)) { File.Delete(fileName); } } using (FileStream stream = new FileStream(fileName, FileMode.Append)) { StreamWriter writer = new StreamWriter(stream); if (meta.IsBinery) { var bits = meta.GetBinary(); stream.Write(bits, 0, bits.Length); //writer.Write(meta.GetBinary()); } else { writer.Write(meta.Content); } writer.Flush(); stream.Flush(); writer.Close(); stream.Close(); } // if (meta.Index == meta.PackCount - 1) { returnCommand.Message = fileName; } returnCommand.Result = true; context.E9_Response.Value = ToJson(returnCommand); /* * CommandResult returnCommand = new CommandResult(); * UploadMeta meta = TJson.Parse<UploadMeta>(context.E9_Request["P0"]); * * string dataPath = context.HttpContext.Server.MapPath("~/") + "data/"; * if (!Directory.Exists(dataPath)) * { * Directory.CreateDirectory(dataPath); * } * string fileName = dataPath + meta.FileName; * if (meta.Index == 0) * { * if (File.Exists(fileName)) * File.Delete(fileName); * } * * using (FileStream stream = new FileStream(fileName, FileMode.Append)) * { * StreamWriter writer = new StreamWriter(stream); * writer.Write(meta.Content); * writer.Flush(); * stream.Flush(); * writer.Close(); * stream.Close(); * } * if (meta.Index == meta.PackCount - 1) * { * returnCommand.Message = fileName; * } * returnCommand.Result = true; * * context.E9_Response.Value = ToJson(returnCommand); */ }
//protected DataProvider EAP_DataSource //{ // get // { // if (null == _DataSource) // _DataSource = DataProvider.GetEAP_Provider(); // return _DataSource; // } //} public void ProcessRequest(HttpContext context) { Context = context; string method = context.Request.HttpMethod; result = new DataResponse(); //ClientMessage(); LogManager.OnLogEvent += new LogEvent(LogManager_OnLogEvent); if (method.ToLower() == "post") { context.Response.ContentType = "application/x-base64"; BinaryReader requestDataReader = new BinaryReader(context.Request.InputStream, Encoding.UTF8); byte[] buffer = new byte[context.Request.InputStream.Length]; context.Request.InputStream.Read(buffer, 0, buffer.Length); string requestString = HttpUtility.UrlDecode(DESEncrypt.ConvertToString(buffer)); requestString = requestString.Substring(requestString.IndexOf('=') + 1); ServiceContext serviceContext = null; try { request = TJson.Parse <DataRequest>(requestString); SetCulture(request); // request.Category = ServiceCategoryName; result.ServiceName = request.ServiceName; serviceContext = new ServiceContext(request, result, DataSource, context); DoProcess(serviceContext); // scope.Complete(); //} if (result.Result != ReturnCode.Fail) { result.Result = ReturnCode.Success; } } catch (Exception ex) { result.Result = ReturnCode.Error; Exception logException = ex; while (logException.InnerException != null) { logException = logException.InnerException; } //Exception logException = tempEx != null ? tempEx : ex; try { if (request != null) { new UtilOP(request.LogIn).LogError(result.ServiceName, logException); } } catch { } if (request.LogIn != null && request.LogIn.IsDebug) { result.Message = logException.Message; result.StackTrace = logException.ToString(); } else { result.Message = logException.Message; result.StackTrace = ""; } } result.DebugInfo = sbDebug.ToString(); sbDebug = null; LogManager.OnLogEvent -= new LogEvent(LogManager_OnLogEvent); if (!serviceContext.IsCustomerResponse) { string sendData = HttpUtility.UrlEncode(result.ToJson()); context.Response.BinaryWrite(DESEncrypt.ConvertToByteArray(sendData)); } } }
public void UpdateRole(DataRequest request, DataResponse result, DataProvider datasource) { EAP_Role role = TJson.Parse <EAP_Role>(request["P0"]); result.Value = ToJson(new AccountOP(request.LogIn).UpdateRole(role)); }