public ActionResult Index() { MMSServer mMSModel = new MMSServer(); mMSModel.MMS_IP = cacheManage.GetCache <string>("MMSIP"); mMSModel.MMS_Port = cacheManage.GetCache <int>("MMSPort"); return(View(mMSModel)); }
public JsonResult LoginForAPI(string ObjectName,string Password) { if (string.IsNullOrEmpty(ObjectName)) { return null; } LoginReturnContext loginReturnContext = new LoginReturnContext(); MMSServer mmsServer=null; if (cacheManage.GetCache<IList<MMSServer>>("MMSServers") == null || cacheManage.GetCache<IList<MMSServer>>("MMSServers").Count<=0) { IList<MMSServer> mmsServers = appServerService.FindMMS(); if (mmsServers != null && mmsServers.Count>0) { cacheManage.AddCache<IList<MMSServer>>("MMSServers", mmsServers); } else { loginReturnContext.Status = 2; return Json(loginReturnContext, JsonRequestBehavior.AllowGet); } } ContactPerson contactPerson = contactPersonService.FindContactPerson(t=>t.ContactName==ObjectName); if (contactPerson == null) { loginReturnContext.Status = 3; } else { if (contactPerson.Password != Password) { loginReturnContext.Status = 1; } else { loginReturnContext.ObjectID = contactPerson.ObjectID; mmsServer = FindMMS(contactPerson.ObjectID); loginReturnContext.Status = 0; } } if (mmsServer!=null) { loginReturnContext.IP = mmsServer.MMS_IP; loginReturnContext.Port = mmsServer.MMS_Port; loginReturnContext.Status = 0; } return Json(loginReturnContext, JsonRequestBehavior.AllowGet); }
public MMSServer FindMMSServer(IList <MMSServer> servers, String objectID) { MMSServer server = null; foreach (MMSServer tempserver in servers) { if (tempserver.ArrangeStr.Contains(objectID.Substring(0, 1))) { return(tempserver); } } return(server); }
private MMSServer FindMMS(string objectID) { MMSServer mmsServer = null; IList<MMSServer> mmsServers = cacheManage.GetCache<IList<MMSServer>>("MMSServers"); foreach(MMSServer tempMMSServer in mmsServers) { if(tempMMSServer.ArrangeStr.Contains(objectID.Substring(0, 1))) { return tempMMSServer; } } return mmsServer; }
// // GET: /AppServer/ public ActionResult CollectMMS(string ip, int port, string arrangeStr) { MMSServer mmsServer = new MMSServer(); mmsServer.ArrangeStr = arrangeStr; mmsServer.MMS_IP = ip; mmsServer.MMS_Port = port; mmsServer.MMS_IP = System.Configuration.ConfigurationManager.AppSettings["LocalIP"].ToString(); lock (CommonFlag.lockobject) { if (cacheManage.GetCache <IList <MMSServer> >("MMSServers") == null) { IList <MMSServer> mmsServers = new List <MMSServer>(); mmsServers.Add(mmsServer); cacheManage.AddCache <IList <MMSServer> >("MMSServers", mmsServers); } else { if (cacheManage.GetCache <IList <MMSServer> >("MMSServers").Count > 0) { for (int i = cacheManage.GetCache <IList <MMSServer> >("MMSServers").Count - 1; i >= 0; i--) { if (cacheManage.GetCache <IList <MMSServer> >("MMSServers")[i].MMS_IP == mmsServer.MMS_IP && cacheManage.GetCache <IList <MMSServer> >("MMSServers")[i].MMS_Port == mmsServer.MMS_Port) { cacheManage.GetCache <IList <MMSServer> >("MMSServers").RemoveAt(i); } } } cacheManage.GetCache <IList <MMSServer> >("MMSServers").Add(mmsServer); } } return(Json("ok", JsonRequestBehavior.AllowGet)); }