public JsonResult Register(string ObjectName, string Password)
        {
            bool finishTag = true;

            ContactPerson contactPerson = new ContactPerson();

            contactPerson.ObjectID    = Guid.NewGuid().ToString();
            contactPerson.ContactName = ObjectName;
            contactPerson.Password    = Password;

            for (int i = 0; i < cacheManage.GetCache <IList <MMSServer> >("MMSServers").Count; i++)
            {
                string returnstr = CommonVariables.syncSocketClient.SendMsgWithReceive(cacheManage.GetCache <IList <MMSServer> >("MMSServers")[i].MMS_IP,
                                                                                       cacheManage.GetCache <IList <MMSServer> >("MMSServers")[i].MMS_Port,
                                                                                       Common.CommonFlag.F_PSSendMMSUser + CommonVariables.javaScriptSerializer.Serialize(contactPerson));

                if (returnstr != contactPerson.ObjectID)
                {
                    finishTag = false;
                }
            }

            if (finishTag)
            {
                if (contactPersonService.InsertNewPerson(contactPerson) > 0)
                {
                    return(Json("register success", JsonRequestBehavior.AllowGet));
                }
            }
            return(Json("register failed", JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        //
        // 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));
        }