public static void Main(string[] args) { dict<int,string> Klasa = new dict<int, string>(); for(int i=0; i<2; i++) { string t=Console.ReadLine(); int t1=t[0]-'0'; string t2= Console.ReadLine(); Console.WriteLine(Klasa.dodaj(t1, t2)); //Console.WriteLine(t1); //Console.WriteLine(t2); } for(int i=0;; i++) { string t=Console.ReadLine(); int t1=t[0]-'0'; //Console.WriteLine(t1); string x = Klasa.znajdz(t1); if(x!=null) Console.WriteLine(x); else Console.WriteLine ("not found"); t=Console.ReadLine(); t1=t[0]-'0'; //Console.WriteLine(t1); Console.WriteLine(Klasa.usun(t1)); } }
/// <summary> /// 查询 /// </summary> public List <dict> query(dict record) { using (qdbEntities myDb = new qdbEntities()) { IQueryable <dict> db = myDb.dict; if (record.ID != null) { db = db.Where <dict>(p => p.ID.Equals(record.ID)); } if (!String.IsNullOrEmpty(record.NAME)) { db = db.Where <dict>(p => p.NAME.Equals(record.NAME)); } if (!String.IsNullOrEmpty(record.REMARK)) { db = db.Where <dict>(p => p.REMARK.Equals(record.REMARK)); } if (record.CREATE_TIME != null) { db = db.Where <dict>(p => p.CREATE_TIME.Equals(record.CREATE_TIME)); } return(db.ToList()); } }
public static Dictionary <string, string> ParseInfo(string backupFolder) { try { string infoFile = Path.Combine(backupFolder, "Info.plist"); if (!File.Exists(infoFile)) { throw new Exception("No valid backup folder."); } XmlSerializer serializer = new XmlSerializer(typeof(plist)); plist info = (plist)serializer.Deserialize(File.OpenRead(infoFile)); if (info.Item.GetType() != typeof(dict)) { return(null); } dict _dict = (dict)info.Item; Dictionary <string, string> ret = new Dictionary <string, string>(); for (var i = 0; i < _dict.key.Length; i++) { ret.Add(_dict.key[i], _dict.Items[i].ToString()); } return(ret); } catch (Exception) { return(null); } }
public xdict(object d) { if (d.GetType() == typeof(dict)) { this._dict = (dict)d; } }
private void ctor() { for (var i = 0; i < m_Data.Length; i++) { m_Data[i] = new dict(); } }
private void Print(dict dict_dict) { //if (dict_dict["username"] == this.userName) // return; if (dict_dict["type"] == "TEXT_MES") { if (dict_dict.ContainsKey("content")) { string Out = ""; Out += (dict_dict["localname"] + " " + dict_dict["username"] + " " + dict_dict["time"] + "\n"); Out += (dict_dict["content"] + "\n"); if (dict_dict["username"] != this.userName) { this.Invoke(() => { this._chat_box_tool.Receive("http://www.jf258.com/uploads/2013-07-21/073810328.jpg", dict_dict["username"], dict_dict["content"], dict_dict["time"]); }); //this.TextOutput.Text += (dict_dict["localname"] + " " + dict_dict["username"] + " " + dict_dict["time"]+"\n"); //this.TextOutput.Text += (dict_dict["content"]+"\n"); } else if ((dict_dict["username"] == this.userName && dict_dict["localname"] != this.local_name)) { this.Invoke(() => { this._chat_box_tool.Send("http://www.jf258.com/uploads/2013-07-21/073810328.jpg", dict_dict["username"], dict_dict["content"], dict_dict["time"]); }); } } } }
public dict MakeDict(string str) { //Console.WriteLine("get dict:" + str); dict dict_dict = JsonConvert.DeserializeObject <dict>(str); return(dict_dict); }
/// <summary> /// 分页查询 /// </summary> public List <dict> queryPage(dict record) { int _total = 0; Expression <Func <dict, bool> > whereLambda = PredicateExtensions.True <dict>(); if (record.ID != null) { whereLambda.And(p => p.ID.Equals(record.ID)); } if (!String.IsNullOrEmpty(record.NAME)) { whereLambda.And(p => p.NAME.Equals(record.NAME)); } if (!String.IsNullOrEmpty(record.REMARK)) { whereLambda.And(p => p.REMARK.Equals(record.REMARK)); } if (record.CREATE_TIME != null) { whereLambda.And(p => p.CREATE_TIME.Equals(record.CREATE_TIME)); } return(LoadPageItems(5, 2, out _total, whereLambda, p => p.ID, true)); // return LoadPageItems(5, 2, out _total, whereLambda, p => p.id, true); }
public static void Main(string[] args) { dict <int, string> Klasa = new dict <int, string>(); for (int i = 0; i < 2; i++) { string t = Console.ReadLine(); int t1 = t[0] - '0'; string t2 = Console.ReadLine(); Console.WriteLine(Klasa.dodaj(t1, t2)); //Console.WriteLine(t1); //Console.WriteLine(t2); } for (int i = 0;; i++) { string t = Console.ReadLine(); int t1 = t[0] - '0'; //Console.WriteLine(t1); string x = Klasa.znajdz(t1); if (x != null) { Console.WriteLine(x); } else { Console.WriteLine("not found"); } t = Console.ReadLine(); t1 = t[0] - '0'; //Console.WriteLine(t1); Console.WriteLine(Klasa.usun(t1)); } }
} // signout public Dictionary <string, object> verify(IContext ctx) { dict Return = new dict(); // your code goes here; add return values to 'Return' Return.Add("status", true); return(Return); } // verify
} // get public dict grant(IContext ctx, idstring userid, idstring permission) { dict Return = new dict(); // your code goes here; add return values to 'Return' Return.Add("status", Helpers.Default <bool>()); return(Return); } // grant
/// <summary> /// 添加 /// </summary> public int add(dict record) { using (qdbEntities myDb = new qdbEntities()) { myDb.dict.Add(record); return(myDb.SaveChanges()); } }
public dict deactivate(IContext ctx, idstring userid) { dict Return = new dict(); // your code goes here; add return values to 'Return' Return.Add("status", Helpers.Default<bool>()); Return.Add("activationkey", Helpers.Default<varchar>()); return Return; }
public dict MakeDict(byte[] dict_bytes) { string str = Encoding.UTF8.GetString(dict_bytes); //Console.WriteLine("get dict:" + str); dict dict_dict = JsonConvert.DeserializeObject <dict>(Encoding.UTF8.GetString(dict_bytes)); return(dict_dict); }
public dict MakeLoginRequestDict(string publickey) { dict requestDict = new dict(); publickey = publickey.Replace('\n', '*'); requestDict.Add("type", "LOGIN_REQUEST"); requestDict.Add("publickey", publickey); return(requestDict); }
private dict Recieve()//类型待议 { byte[] dict_bytes = new byte[2048]; sockServer.Receive(dict_bytes); dict dict_mes = DictMaker.MakeDict(dict_bytes); DecryptDict(dict_mes); return(dict_mes); }
/// <summary> /// 更新 /// </summary> public int updateById(dict record) { using (qdbEntities myDb = new qdbEntities()) { myDb.dict.Attach(record); myDb.Entry(record).State = EntityState.Modified; return(myDb.SaveChanges()); } }
} // activate public dict deactivate(IContext ctx, idstring userid) { dict Return = new dict(); // your code goes here; add return values to 'Return' Return.Add("status", Helpers.Default <bool>()); Return.Add("activationkey", Helpers.Default <varchar>()); return(Return); } // deactivate
public dict MakeTextDict(string userName, string content, string local_ip, string local_name) { dict TextDict = new dict(); TextDict.Add("type", "TEXT_MES"); TextDict.Add("username", Decrypt(userName)); TextDict.Add("content", Decrypt(content)); TextDict.Add("ip", local_ip); TextDict.Add("localname", local_name); return(TextDict); }
} // signin public Dictionary <string, object> signout(IContext ctx) { dict Return = new dict(); if (ctx.Session != null) { ctx.Session.Invalidate(ctx); } // your code goes here; add return values to 'Return' return(Return); } // signout
} // deactivate public dict get(IContext ctx, idstring userid) { dict Return = new dict(); // your code goes here; add return values to 'Return' Return.Add("status", Helpers.Default <bool>()); Return.Add("realname", Helpers.Default <varchar>()); Return.Add("email", Helpers.Default <email>()); Return.Add("activationkey", Helpers.Default <varchar>()); Return.Add("permissions", Helpers.Default <list>()); return(Return); } // get
public dict MakeRegisterDict(String userName, String password, String local_ip, String local_name) { dict RegisterDict = new dict(); RegisterDict.Add("username", userName); RegisterDict.Add("type", "REGISTER_MES"); RegisterDict.Add("status", "register"); RegisterDict.Add("ip", local_ip); RegisterDict.Add("localname", local_name); RegisterDict.Add("password", password); return(RegisterDict); }
public dict MakeLoginDict(String userName, String password, String local_ip, String local_name) { dict LoginDict = new dict(); LoginDict.Add("username", Decrypt(userName)); LoginDict.Add("password", Decrypt(password)); LoginDict.Add("type", "LOGIN_MES"); LoginDict.Add("status", "login"); LoginDict.Add("ip", local_ip); LoginDict.Add("localname", local_name); return(LoginDict); }
public Dictionary <string, object> signin(IContext ctx, idstring userid, password password) { dict Return = new dict(); // your code goes here; add return values to 'Return' if (userid.str != "jwatte" || password.str != "123456") { throw new InvalidOperationException("Bad user name or password."); } UserSession sess = UserSession.Create(ctx, userid.str); Return.Add("token", new idstring(sess.sid)); return(Return); } // signin
public Status Register(String userName, String passWord) { try { sockServer.Connect(hostIp, port); Toast("Successfully Connect the Server:\n" + this.hostIp); } catch { sockServer.Close(); Toast("Server Connect Failure!"); return(Status.CONNECT_ERROR); } dict RegisterDict = DictMaker.MakeRegisterDict(userName, passWord, local_ip, local_name); byte[] dict_bytes = new byte[2048]; dict dict_dict = new dict(); try { Send(RegisterDict); sockServer.Receive(dict_bytes); dict_dict = DictMaker.MakeDict(dict_bytes); if (dict_dict["type"] == "REGISTER_MES") { if (dict_dict["status"] == "AC") { return(Status.REGISTER_AC); } else if (dict_dict["status"] == "SAME_NAME") { return(Status.SAME_NAME); } else if (dict_dict["status"] == "REGISTER_ERROR") { return(Status.REGISTER_ERROR); } } } catch { sockServer.Close(); Toast("Server Connect Error!"); return(Status.CONNECT_ERROR); } return(Status.CONNECT_ERROR); }
private void DecryptDict(dict dict_mes) { if (dict_mes.ContainsKey("content")) { dict_mes["content"] = RsaMaker.DecodeOrNull(dict_mes["content"]); } if (dict_mes.ContainsKey("ftpusername")) { dict_mes["ftpusername"] = RsaMaker.DecodeOrNull(dict_mes["ftpusername"]); } if (dict_mes.ContainsKey("ftppassword")) { dict_mes["ftppassword"] = RsaMaker.DecodeOrNull(dict_mes["ftppassword"]); } }
/// <summary> /// 删除 /// </summary> public int deleteById(int id) { using (qdbEntities myDb = new qdbEntities()) { // TODO 生成代码后需要检查一下是否找到正确的主键,这里做一个错误代码,避免直接使用 dict record = new dict() { ID = id }; myDb.dict.Attach(record); myDb.Entry(record).State = EntityState.Deleted; return(myDb.SaveChanges()); } }
public dict activate(IContext ctx, idstring userid, varchar activationkey) { dict Return = new dict(); // your code goes here; add return values to 'Return' bool status = false; long pver; dict u = KeyValueStore.Find("user:"******"activationkey"].Equals(activationkey.str)) { u["activationkey"] = ""; status = KeyValueStore.Store("user:"******"status", status); return Return; }
} // create public dict activate(IContext ctx, idstring userid, varchar activationkey) { dict Return = new dict(); // your code goes here; add return values to 'Return' bool status = false; long pver; dict u = KeyValueStore.Find("user:"******"activationkey"].Equals(activationkey.str)) { u["activationkey"] = ""; status = KeyValueStore.Store("user:"******"status", status); return(Return); } // activate
public dict create(IContext ctx, idstring userid, password password, varchar realname, email email) { dict Return = new dict(); // your code goes here; add return values to 'Return' bool status = false; string message = "unknown error"; long pver; if (userid.str.Length < 5 || !Helpers.IsValidId(userid.str)) { message = "bad user id format: non-special characters, at least length 5 required"; } else if (KeyValueStore.Find("user:"******"the user id " + userid + " already exists"; } else if (KeyValueStore.Find("email:" + email, out pver) != null) { message = "the email address " + email + " is already tied to another user id"; } else { dict user = new dict(); user.Add("userid", userid.str); user.Add("password", password.str); user.Add("realname", realname.str); user.Add("email", email.str); user.Add("activationkey", Helpers.RandomString(24)); if (KeyValueStore.Store("user:"******"user " + userid + " created"; status = true; } else { message = "database error when trying to create user " + userid; } } Return.Add("status", status); Return.Add("message", message); return(Return); } // create
public dict create(IContext ctx, idstring userid, password password, varchar realname, email email) { dict Return = new dict(); // your code goes here; add return values to 'Return' bool status = false; string message = "unknown error"; long pver; if (userid.str.Length < 5 || !Helpers.IsValidId(userid.str)) { message = "bad user id format: non-special characters, at least length 5 required"; } else if (KeyValueStore.Find("user:"******"the user id " + userid + " already exists"; } else if (KeyValueStore.Find("email:" + email, out pver) != null) { message = "the email address " + email + " is already tied to another user id"; } else { dict user = new dict(); user.Add("userid", userid.str); user.Add("password", password.str); user.Add("realname", realname.str); user.Add("email", email.str); user.Add("activationkey", Helpers.RandomString(24)); if (KeyValueStore.Store("user:"******"user " + userid + " created"; status = true; } else { message = "database error when trying to create user " + userid; } } Return.Add("status", status); Return.Add("message", message); return Return; }
public byte[] MakeBytesDict(dict dict_dict) { String dict_str = "{"; int count = 1; foreach (var item in dict_dict) { dict_str += (" \"" + item.Key + "\": "); dict_str += (" \"" + item.Value); if (count != dict_dict.Count) { dict_str += "\" ,"; } else { dict_str += "\" }"; } count++; } //Console.WriteLine(dict_str); return(Encoding.UTF8.GetBytes(dict_str)); }
public dict get(IContext ctx, idstring userid) { dict Return = new dict(); // your code goes here; add return values to 'Return' Return.Add("status", Helpers.Default<bool>()); Return.Add("realname", Helpers.Default<varchar>()); Return.Add("email", Helpers.Default<email>()); Return.Add("activationkey", Helpers.Default<varchar>()); Return.Add("permissions", Helpers.Default<list>()); return Return; }
public dict test(IContext ctx, idstring userid, idstring permission) { dict Return = new dict(); // your code goes here; add return values to 'Return' Return.Add("status", Helpers.Default<bool>()); return Return; }
public xdict(dict d) { this._dict = d; }
public xdictEnum(dict list) { _dict = list; }
public trMeaning (dict zargan,dict tureng) { this.zargan = zargan; this.tureng = tureng; }