public object fuzzySearchField(HttpContext context) { ExecuteBcfMethodResult result = new ExecuteBcfMethodResult(); string data = context.Request["data"]; MDictionary <string, string> dic = new MDictionary <string, string>(); if (!string.IsNullOrEmpty(data)) { dic = JsonConvert.DeserializeObject <MDictionary <string, string> >(data); } BillService service = new BillService(); string handle = dic["Handle"]; string relSource = dic["RelSource"]; string query = dic["Query"]; string condition = dic["Condition"]; Int16 tableIndex = LibSysUtils.ToInt16(dic["TableIndex"]); string selectSql = dic["SelectSql"]; string selectFields = dic["SelectFields"]; result.Result = service.FuzzySearchField1(handle, relSource, selectFields, query, condition, tableIndex, selectSql); //result.Result = service.FuzzySearchField(handle, relSource, query, condition, tableIndex); return(result); }
/// <summary> /// 清除所有缓存 /// </summary> public override void Clear() { try { if (theCache.Count > 0) { System.Collections.IDictionaryEnumerator e = theCache.GetEnumerator(); while (e.MoveNext()) { theCache.Remove(Convert.ToString(e.Key)); } } lock (lockObj) { try { theState.Clear(); theState = null; theState = new MDictionary <string, CacheDependencyInfo>(500, StringComparer.OrdinalIgnoreCase); } catch { } } } catch { errorCount++; } }
public WordsDictControl(SettingsViewModel vmSettings, MDictionary Dict) { InitializeComponent(); this.vmSettings = vmSettings; vmDict = new OnlineDictViewModel(vmSettings, this); vmDict.Dict = Dict; }
/// <summary> /// 重置静态变量(方便回收内存,避免大量导数据后内存不回收) /// </summary> internal static void ResetStaticVar() { _tableList.Clear(); _tableList = null; //静态字典置为Null才能释放内存。 _tableList = new MDictionary <string, MDataTable>(5, StringComparer.OrdinalIgnoreCase); //重新初始化。 //_needToSaveState.Clear(); //_lockNextidObj.Clear(); //_maxid.Clear(); }
public DictsDetailDlg(Window owner, MDictionary item, DictsViewModel vm) { InitializeComponent(); SourceInitialized += (x, y) => this.HideMinimizeAndMaximizeButtons(); tbDictName.Focus(); Owner = owner; vmDetail = new DictsDetailViewModel(Item = item, vm); DataContext = vmDetail.ItemEdit; cbLangTo.ItemsSource = vm.vmSettings.LanguagesAll; cbDictType.ItemsSource = vm.vmSettings.DictTypeCodes; }
public object SaveBillListingScheme(HttpContext context) { string data = context.Request["data"]; MDictionary <string, string> dic = new MDictionary <string, string>(); if (!string.IsNullOrEmpty(data)) { dic = JsonConvert.DeserializeObject <MDictionary <string, string> >(data); } BillService service = new BillService(); return(service.SaveDisplayScheme1(dic["Handle"], dic["ProgId"], dic["EntryParam"], dic["DisplayScheme"])); }
public static Message TryParseToObject(MDictionary <MString, Message> obj) { if (obj.ContainsKey("Type")) { Guid guid = new Guid(((MString)obj["Type"]).Value); if (_types.ContainsKey(guid)) { Message mobj = (Message)Activator.CreateInstance(_types[guid]); mobj.FromDictionary(obj); return(mobj); } } return(obj); }
public void testMDictionariesEqual_SameOrder() { // Data setup MDictionary <string, string> actual = new MDictionary <string, string>(); actual.Add("1", "start"); actual.Add("2", "start"); // Expectations MDictionary <string, string> expected = new MDictionary <string, string>(); expected.Add("1", "start"); expected.Add("2", "start"); // Test and Assert Assert.AreEqual(actual, expected); }
public void testMDictionariesNotEqual_differentValues() { // Data setup MDictionary <string, string> actual = new MDictionary <string, string>(); actual.Add("1", "start"); actual.Add("2", "node1"); // Expectations MDictionary <string, string> expected = new MDictionary <string, string>(); expected.Add("1", "node1"); expected.Add("2", "node2"); // Test and Assert Assert.IsFalse(actual.Equals(expected)); }
//加载菜单 public object LoadMenuSetting(HttpContext context) { ExecuteBcfMethodResult result = new ExecuteBcfMethodResult(); string data = context.Request["data"]; MDictionary <string, string> dic = new MDictionary <string, string>(); if (!string.IsNullOrEmpty(data)) { dic = JsonConvert.DeserializeObject <MDictionary <string, string> >(data); } FileTransferService service = new FileTransferService(); string handle = dic["Handle"]; result.Result = service.LoadMenuSetting(handle); return(result); }
public object BatchImportData(HttpContext context) { string data = context.Request["data"]; MDictionary <string, string> dic = new MDictionary <string, string>(); if (!string.IsNullOrEmpty(data)) { dic = JsonConvert.DeserializeObject <MDictionary <string, string> >(data); } string handle = dic["handle"]; string progId = dic["progId"]; string fileName = dic["fileName"]; BillService service = new BillService(); return(service.BatchImportData1(handle, progId, fileName)); }
public object SelectFuncField(HttpContext context) { string data = context.Request["data"]; MDictionary <string, string> dic = new MDictionary <string, string>(); if (!string.IsNullOrEmpty(data)) { dic = JsonConvert.DeserializeObject <MDictionary <string, string> >(data); } string handle = dic["handle"]; string progId = dic["progId"]; int tableIndex = LibSysUtils.ToInt16(dic["tableIndex"]); BillService service = new BillService(); return(service.SelectFuncField1(handle, progId, tableIndex)); }
public object GetRptFields(HttpContext context) { ExecuteBcfMethodResult result = new ExecuteBcfMethodResult(); string data = context.Request["data"]; MDictionary <string, string> dic = new MDictionary <string, string>(); if (!string.IsNullOrEmpty(data)) { dic = JsonConvert.DeserializeObject <MDictionary <string, string> >(data); } BillService service = new BillService(); string progId = dic["Progid"]; result.Result = service.GetRptFields(progId); return(result); }
private GraphNode createNode(CharacterTypeEnum character, string sentence, AnnotationEnum annotation, string linkedNodeID) { GraphNode node = new GraphNode(); List <string> conversations = new List <string>(); conversations.Add(sentence); List <string> linkedIds = new List <string>(); linkedIds.Add(linkedNodeID); MDictionary <string, List <string> > nodeLinks = new MDictionary <string, List <string> >(); nodeLinks.Add(annotation.ToString(), linkedIds); node = createNode(character, conversations, nodeLinks); return(node); }
public override void FromDictionary(MDictionary <MString, Message> mobj) { foreach (var kv in mobj) { if (kv.Key.Value == "Method") { Method = ((MString)kv.Value).Value; } else if (kv.Key.Value == "Session") { Session = ((MString)kv.Value).Value; } else if (kv.Key.Value == "ErrorCode") { ErrorCode = (int)((MLong)kv.Value).Value; } else if (kv.Key.Value == "Results" && kv.Value is MDictionary <MString, Message> ) { MDictionary <MString, Message> dict = (MDictionary <MString, Message>)kv.Value; foreach (var d in dict) { if (d.Value is MDictionary <MString, Message> ) { Results.Add(d.Key, TryParseToObject((MDictionary <MString, Message>)d.Value)); } else { Results.Add(d.Key, d.Value); } } } else if (kv.Key.Value == "Type") { // 忽略Type } else { throw new Exception("RPCResult格式不正确 " + kv.Key + " : " + mobj.ToJson()); } } }
public object Login(HttpContext context) { ExecuteBcfMethodResult result = new ExecuteBcfMethodResult(); string data = context.Request["data"]; MDictionary <string, string> dic = new MDictionary <string, string>(); if (!string.IsNullOrEmpty(data)) { dic = JsonConvert.DeserializeObject <MDictionary <string, string> >(data); } string userId = dic["userId"]; string password = dic["password"]; bool quitOther = false; SystemService service = new SystemService(); result.Result = service.Login1(userId, password, quitOther); return(result); }
public object UpLoadFile(HttpContext context) { string data = context.Request["data"]; MDictionary <string, string> dic = new MDictionary <string, string>(); if (!string.IsNullOrEmpty(data)) { dic = JsonConvert.DeserializeObject <MDictionary <string, string> >(data); } string progId = dic["ProgId"]; HttpFileCollection postedFile = context.Request.Files; FileTransferService service = new FileTransferService(); for (int i = 0; i < postedFile.Count; i++) { UpLoadFileResult ret = service.UpLoadFile1(postedFile[i], progId); return(new { uploaded = 1, fileName = ret.FileName, url = ret.FileName, }); } return(null); }
public object checkFieldValue(HttpContext context) { ExecuteBcfMethodResult result = new ExecuteBcfMethodResult(); string data = context.Request["data"]; MDictionary <string, string> dic = new MDictionary <string, string>(); if (!string.IsNullOrEmpty(data)) { dic = JsonConvert.DeserializeObject <MDictionary <string, string> >(data); } BillService service = new BillService(); string handle = dic["Handle"]; string fields = dic["Fields"]; string relSource = dic["RelSource"]; string curPk = dic["CurPk"]; string condition = dic["Condition"]; Int16 tableIndex = LibSysUtils.ToInt16(dic["TableIndex"]); result.Result = service.CheckFieldValue(handle, fields, relSource, curPk, condition, tableIndex); return(result); }
/// <summary> /// ���þ�̬��������������ڴ棬������������ݺ��ڴ治���գ� /// </summary> internal static void ResetStaticVar() { _tableList.Clear(); _tableList = null;//��̬�ֵ���ΪNull�����ͷ��ڴ档 _tableList = new MDictionary<string, MDataTable>(5, StringComparer.OrdinalIgnoreCase);//���³�ʼ���� //_needToSaveState.Clear(); //_lockNextIDObj.Clear(); //_maxID.Clear(); }
public override void FromDictionary(MDictionary <MString, Message> mobj) { Value = ((MList <T>)mobj["Value"]).Value; }
public virtual void FromDictionary(MDictionary <MString, Message> mobj) { throw new NotImplementedException(); }
public Graph() { Nodes = new MDictionary <string, GraphNode>(); }
public static Message ParserJson(string json) { json = json.Trim(); if (json.StartsWith("{") && json.EndsWith("}")) { // 对象或字典(先转化为字典,再通过Type转化为对象) MDictionary <MString, Message> obj = new MDictionary <MString, Message>(); int match = 0; int last = 0; int index; string key, value, elm; json = json.Substring(1, json.Length - 2); for (int i = 0; i < json.Length; ++i) { if (json[i] == '{' || json[i] == '[') { ++match; } else if (json[i] == '}' || json[i] == ']') { --match; } else if (match == 0 && json[i] == ',') { elm = json.Substring(last, i - last); index = elm.IndexOf(':'); if (-1 == index) { throw new Exception("数据格式错误"); } key = elm.Substring(0, index).Trim().Trim('\"'); value = elm.Substring(index + 1); obj.Add(new MString(key), ParserJson(value)); last = i + 1; } } elm = json.Substring(last); index = elm.IndexOf(':'); key = elm.Substring(0, index).Trim().Trim('\"'); value = elm.Substring(index + 1); obj.Add(new MString(key), ParserJson(value)); return(obj); } else if (json.StartsWith("[") && json.EndsWith("]")) { // 数组 MList <Message> list = new MList <Message>(); int match = 0; int last = 0; json = json.Substring(1, json.Length - 2); for (int i = 0; i < json.Length; ++i) { if (json[i] == '{' || json[i] == '[') { ++match; } else if (json[i] == '}' || json[i] == ']') { --match; } else if (match == 0 && json[i] == ',') { list.Add(ParserJson(json.Substring(last, i - last))); last = i + 1; } } list.Add(ParserJson(json.Substring(last))); return(list); } else if (json.StartsWith("\"") && json.EndsWith("\"")) { // 字符串 return(new MString(json.Trim('\"'))); } else if (json.StartsWith("\'") && json.EndsWith("\'")) { // 字符 return(new MChar(json[1])); } else if (-1 != json.IndexOf('.')) { // 浮点数 double num; double.TryParse(json, out num); return(new MDouble(num)); } else { // 整数 long num; long.TryParse(json, out num); return(new MLong(num)); } }
private GraphNode createNode(CharacterTypeEnum character, List <string> conversations, MDictionary <string, List <string> > links) { GraphNode node = new GraphNode(); node.Links = links; node.Character = character.ToString(); node.Conversations = conversations; return(node); }
/// <summary> /// ���þ�̬������ÿ���������º���ã� /// </summary> internal static void ResetStaticVar() { _tableList.Clear(); _tableList = null;//��̬�ֵ���ΪNull���ܼ�ʱ�ͷ��ڴ档 _tableList = new MDictionary<string, MDataTable>(3);//���³�ʼ���� _needToSaveState.Clear(); _lockNextIDObj.Clear(); _lockWriteTxtObj.Clear(); _maxID.Clear(); //_InsertRows.Clear(); //_InsertRows = null;//��Null //_InsertRows = new List<MDataRow>(); _lastWriteTimeUtc = DateTime.Now; }
private void BuildRss() { object propValue = null; XmlNode cNode = rssDoc.XmlDoc.DocumentElement.ChildNodes[0]; CreateNode(cNode, channel);//Channel处理 XmlNode iNode = null; if (img != null) { iNode = rssDoc.CreateNode("image", string.Empty); cNode.AppendChild(iNode); CreateNode(iNode, img);//Channel-Image处理 } if (channel.Items.Count > 0) { foreach (RssItem item in channel.Items) { iNode = rssDoc.CreateNode("item", string.Empty); cNode.AppendChild(iNode); CreateNode(iNode, item);//Channel-Items处理 } } else if (_MTable != null && mapList.Count > 0) { foreach (MDataRow row in _MTable.Rows) { iNode = rssDoc.CreateNode("item", string.Empty); cNode.AppendChild(iNode); //foreach (RssItemMap item in mapList) RssItemMap item = null; for (int k = 0; k < mapList.Count; k++) { item = mapList[k]; if (item.TableColumnNames.Length > 0) { MDictionary <string, string> dic = new MDictionary <string, string>(item.TableColumnNames.Length, StringComparer.OrdinalIgnoreCase); object[] values = new object[item.TableColumnNames.Length]; for (int i = 0; i < item.TableColumnNames.Length; i++) { string columnName = item.TableColumnNames[i].ToString(); values[i] = row[columnName].Value; dic.Set(columnName, Convert.ToString(values[i])); } if (OnForeach != null) { item.FormatText = OnForeach(item.FormatText, dic, k); } if (string.IsNullOrEmpty(item.FormatText)) { propValue = values[0]; } else { propValue = string.Format(item.FormatText, values); } } //else if (item.TableColumnNames.Length > 0) //{ // propValue = row[item.TableColumnNames[0].ToString()].Value; // if (!string.IsNullOrEmpty(item.FormatText)) // { // propValue = string.Format(item.FormatText, propValue); // } //} else { propValue = item.FormatText; } if (propValue == null || propValue == DBNull.Value) { continue; } if (item.RssItemName == "Description") { propValue = rssDoc.SetCDATA(propValue.ToString()); } rssDoc.CreateNodeTo(iNode, item.RssItemName.Substring(0, 1).ToLower() + item.RssItemName.Substring(1), propValue.ToString()); } } } }
/// <summary> /// �������� /// </summary> public override void Clear() { try { if (theCache.Count > 0) { System.Collections.IDictionaryEnumerator e = theCache.GetEnumerator(); while (e.MoveNext()) { theCache.Remove(Convert.ToString(e.Key)); } } lock (lockObj) { try { theState.Clear(); theState = null; theState = new MDictionary<string, CacheDependencyInfo>(500, StringComparer.OrdinalIgnoreCase); } catch { } } } catch { errorCount++; } }
/// <summary> /// 清理服务主机。 /// </summary> internal static void ClearServerTable() { while (true) { try { lock (Const.tableLockObj) { if (Server._HostList != null && Server._HostList.Count > 0) { MDictionary <string, List <HostInfo> > keyValuePairs = Server._HostList;//拿到引用 MDictionary <string, List <HostInfo> > newKeyValuePairs = new MDictionary <string, List <HostInfo> >(StringComparer.OrdinalIgnoreCase); foreach (var item in keyValuePairs) { List <HostInfo> newList = new List <HostInfo>(); foreach (var info in item.Value) { if (info.RegTime < DateTime.Now.AddSeconds(-11) || info.Version < 0) { Server.IsChange = true; } else { newList.Add(info); } } if (newList.Count > 0) { newKeyValuePairs.Add(item.Key, newList); } } if (Server.IsChange) { Server.IsChange = false; Server.Tick = DateTime.Now.Ticks; if (newKeyValuePairs.Count > 0) { Server._HostListJson = JsonHelper.ToJson(newKeyValuePairs); IO.Write(Const.ServerHostListJsonPath, Server._HostListJson); } else { Server._HostListJson = String.Empty; IO.Delete(Const.ServerHostListJsonPath); } Server._HostList = newKeyValuePairs; } else { newKeyValuePairs.Clear(); newKeyValuePairs = null; } } } } catch (Exception err) { LogWrite(err.Message, "MicroService.Run.ClearServerTable()", "", Config.ServerName); } Thread.Sleep(5000);//测试并发。 } }