示例#1
0
文件: Session.cs 项目: zhoulk/Lufy
    public LTTask <ErrorCode> Connect(IPEndPoint remoteEndPoint)
    {
        this.tcs            = new LTTaskCompletionSource <ErrorCode>();
        this.IsConnected    = false;
        this.RemoteEndPoint = remoteEndPoint;
        uint conv = ConvGenerator.Conv();

        Log.Debug($"connect:new conv:{conv}");

        //#if IPV4
        this.udpClient = new UdpClient(new IPEndPoint(IPAddress.Any, 0));
        //#elif IPV6
        //        this.udpClient = new UdpClient(new IPEndPoint(IPAddress.IPv6Any, 0));
        //#endif
        this.udpClient.BeginReceive(OnBeginReceive, null);
        this.channel = new KChannel(conv, udpClient, remoteEndPoint)
        {
            Name = "Client"
        };
        this.channel.OnReadCallback  = OnKcpRead;
        this.channel.OnErrorCallback = OnKcpError;

        //立刻发送连接请求
        byte     hid = 1;
        IMessage msg = MessagesFactory.Connect(hid);

        Send(msg.Encode());

        this.monoDriver.StartCoroutine(SimulationRecvConnected());
        return(this.tcs.Task);
    }
示例#2
0
        public void MessageToByteSerializationTest()
        {
            Status message = MessagesFactory.CreateEmptyMessage(MessageType.StatusMessage).Cast <Status>();

            message.Id      = 1234;
            message.Threads = new StatusThread[1]
            {
                new StatusThread()
                {
                    ProblemType      = "DVRP",
                    HowLong          = 1234,
                    HowLongSpecified = true,
                    State            = StatusThreadState.Busy
                }
            };
            MessageToBytesConverter converter = new MessageToBytesConverter();

            byte[]  bytes = converter.ToByteArray(message);
            Message messageDeserialized = converter.FromBytesArray(bytes);

            Assert.AreEqual(MessageType.StatusMessage, messageDeserialized.MessageType);
            Status mStatus = messageDeserialized.Cast <Status>();

            Assert.AreEqual(message.Id, mStatus.Id);
            Assert.AreEqual(message.Threads.Length, mStatus.Threads.Length);
        }
示例#3
0
    //--------------------------------------------------------
    #endregion

    #region --------------dgMessages_DeleteCommand--------------
    //---------------------------------------------------------
    //dgMessages_DeleteCommand
    //---------------------------------------------------------
    protected void dgMessages_DeleteCommand(object source, DataGridCommandEventArgs e)
    {
        //-------------------------------------------------------------------------------

        int            messageID = Convert.ToInt32(dgMessages.DataKeys[e.Item.ItemIndex]);
        MessagesEntity msg       = MessagesFactory.GetMessagesObject(messageID, UsersTypes.Admin, OwnerID);

        if (MessagesFactory.Delete(messageID))
        {
            //------------------------------------------------
            //RegisterInMailList
            if ((currentModule.MailListAutomaticRegistration || (msg.HasEmailService)) && !string.IsNullOrEmpty(msg.EMail))
            {
                MessagesFactory.UnRegisterInMailList(msg);
            }
            //------------------------------------------------
            //RegisterInSms
            if ((currentModule.SmsAutomaticRegistration || (msg.HasSmsService)) && !string.IsNullOrEmpty(msg.Mobile))
            {
                MessagesFactory.UnRegisterInSms(msg);
            }
            //------------------------------------------------
            General.MakeAlertSucess(lblResult, Resources.AdminText.DeletingOprationDone);
            //if one item in datagrid
            if (dgMessages.Items.Count == 1)
            {
                --pager.CurrentPage;
            }
            LoadData();
        }
        else
        {
            General.MakeAlertError(lblResult, Resources.AdminText.DeletingOprationFaild);
        }
    }
示例#4
0
        /// <inheritdoc />
        public void BroadcastDataToGamePad <T>(T data)
        {
            if (m_BridgeClass != null)
            {
                string content = m_Json.ToJson(data);

                m_Log.Debug($"Sdk BroadcastDataToGamePad : {content}");

                IMessage msg    = MessagesFactory.Msg(content);
                string   base64 = Convert.ToBase64String(msg.Encode());

                m_Log.Debug($"Sdk BroadcastDataToGamePad Base64: {base64}");

                m_BridgeClass.CallStatic("broadcastDataToGamePad", base64);
            }
            else
            {
                if (App.HasBind <IGamepadServer>())
                {
                    string content = m_Json.ToJson(data);
                    m_Log.Debug($"BroadcastDataToGamePad : {content}");

                    IMessage msg = MessagesFactory.Msg(content);
                    App.Make <IGamepadServer>().BroadcastToGamepad(msg.Encode());
                }
                else
                {
                    LTLog.Debug($"GamepadServer not register, Broadcast cannot be used. ");
                }
            }
        }
示例#5
0
    //--------------------------------------------------------
    #endregion

    #region --------------LoadData--------------
    //---------------------------------------------------------
    //LoadData
    //---------------------------------------------------------
    private void LoadData()
    {
        pager.PageSize = SiteSettings.Site_AdminPageSize;
        int totalRecords = 0;
        //--------------------------------------------------------------------
        Languages langID = Languages.Unknowen;

        if (SiteSettings.Languages_HasMultiLanguages)
        {
            langID = (Languages)Convert.ToInt32(ddlLanguages.SelectedValue);
        }
        //--------------------------------------------------------------------
        int typeID = 0;

        if (currentModule.HasType)
        {
            typeID = Convert.ToInt32(ddlType.SelectedValue);
        }
        //--------------------------------------------------------------------
        List <MessagesEntity> messagesList = MessagesFactory.GetAll(ModuleTypeID, -1, langID, typeID, ToItemID, ToUserId, false, false, false, pager.CurrentPage, pager.PageSize, out totalRecords, OwnerID);

        if (messagesList != null && messagesList.Count > 0)
        {
            dgMessages.DataSource   = messagesList;
            dgMessages.DataKeyField = "MessageID";
            dgMessages.AllowPaging  = false;
            pager.Visible           = true;
            pager.TotalRecords      = totalRecords;
            //------------------------------------
            dgMessages.Columns[1].Visible = currentModule.HasTitle;
            dgMessages.Columns[2].Visible = currentModule.HasEMail;
            dgMessages.Columns[3].Visible = currentModule.HasName && !currentModule.HasTitle;
            dgMessages.Columns[5].Visible = currentModule.HasReply;
            dgMessages.Columns[6].Visible = currentModule.HasIsAvailable;
            //------------------------------------
            dgMessages.DataBind();
            dgMessages.Visible = true;
            //-------------------------------------------------------------------------------
            //Security Premession
            //--------------------------
            //Check Edit permission
            if (!ZecurityManager.UserCanExecuteCommand(CommandName.Edit))
            {
                dgMessages.Columns[dgMessages.Columns.Count - 2].Visible = false;
            }
            //Check Delete permission
            if (!ZecurityManager.UserCanExecuteCommand(CommandName.Delete))
            {
                dgMessages.Columns[dgMessages.Columns.Count - 1].Visible = false;
            }
            //-------------------------------------------------------------------------------
        }
        else
        {
            dgMessages.Visible = false;
            pager.Visible      = false;
            lblResult.CssClass = "operation_error";
            lblResult.Text     = Resources.AdminText.ThereIsNoData;
        }
    }
示例#6
0
文件: Shooter.cs 项目: zhoulk/Lufy
        void ShootBall(float elapseTime)
        {
            //if (elapseTime < shotTimeMin)
            //{
            //    shotPower = shotPowerMax;
            //}
            //else if (shotTimeMax < elapseTime)
            //{
            //    shotPower = shotPowerMin;
            //}
            //else
            //{
            //    float tmin100 = shotTimeMin * 10000.0f;
            //    float tmax100 = shotTimeMax * 10000.0f;
            //    float ep100 = elapseTime * 10000.0f;
            //    float rate = (ep100 - tmin100) / (tmax100 - tmin100);
            //    shotPower = shotPowerMax - ((shotPowerMax - shotPowerMin) * rate);
            //}

            float len = ((Vector2)Input.mousePosition - startTouchPos).magnitude;
            //Debug.Log(len + " " + Input.mousePosition + "  " + startTouchPos);
            float   rate        = len / 750;
            Vector3 screenPoint = Input.mousePosition;

            screenPoint.z = targetZ;
            Vector3 worldPoint = cameraForShooter.ScreenToWorldPoint(screenPoint);

            // 发送消息
            IMessage msg = MessagesFactory.BasketBall(1, shotPoint.transform.position, worldPoint, rate);

            UDPManager.Instance.Send(msg);

            shotPower     = shotPowerMin + ((shotPowerMax - shotPowerMin) * rate);
            worldPoint.y += (offsetY / shotPower);

            //float tmax100 = shotTimeMax * 10000.0f;
            //float ep100 = elapseTime * 10000.0f;
            //rate = ep100 / tmax100;
            //worldPoint.y += (offsetY / 5) * rate;

            direction = (worldPoint - shotPoint.transform.position).normalized;

            //Debug.Log(direction + " " + worldPoint + "  " + shotPoint.transform.position + "  " + rate);

            //direction = new Vector3(0, 0.82f, 0.58f);

            Vector3 velocity = direction * shotPower;
            Vector3 _torque  = -shotPoint.transform.right * torque;

            if (Define.platForm.Equals(PlatForm.Phone))
            {
                ballRigidbody.velocity = velocity * 3;
                ballRigidbody.AddTorque(_torque);
            }
            else
            {
                ballRigidbody.velocity = velocity;
                ballRigidbody.AddTorque(_torque);
            }
        }
示例#7
0
    public static string SaveForm3Data(string name, string emial, string mobile, string mailbox, string city, string address, string needs, string knowen)
    {
        MessagesEntity msg = new MessagesEntity();

        msg.ModuleTypeID = 504;

        msg.Name = "0," + name.Replace(' ', ',');

        //msg.Name = name;
        msg.EMail        = emial;
        msg.Mobile       = mobile;
        msg.MailBox      = mailbox;
        msg.UserCityName = city;
        msg.Address      = address;
        msg.LangID       = Languages.En;
        try
        {
            msg.EducationLevel = Convert.ToInt32(needs);
        }
        catch { }
        try
        {
            msg.SocialStatus = Convert.ToInt32(knowen);
        }
        catch { }
        MessagesModuleOptions currentMessageModule = MessagesModuleOptions.GetType(504);
        bool createMessageFolder = (currentMessageModule.HasFileExtension || currentMessageModule.HasPhotoExtension || currentMessageModule.HasPhoto2Extension || currentMessageModule.HasVideoExtension || currentMessageModule.HasAudioExtension);

        bool status = MessagesFactory.Create(msg, createMessageFolder);

        return("worked");
    }
示例#8
0
    //-----------------------------------------------
    //Page_Load
    //-----------------------------------------------
    private void Page_Load(object sender, System.EventArgs e)
    {
        ItemsModulesOptions   currentModule         = (ItemsModulesOptions)HttpContext.Current.Items["CurrentItemsModule"];
        MessagesModuleOptions CurrentMessagesModule = MessagesModuleOptions.GetType(currentModule.MessagesModuleID);

        ucUpdate.ModuleTypeID    = CurrentMessagesModule.ModuleTypeID;
        ucUpdate.DefaultPagePath = "/AdminCP/Items/" + currentModule.Identifire + "/Messages/default.aspx";
        //-----------------------------------------------
        int messageID = -1;

        if (MoversFW.Components.UrlManager.ChechIsValidIntegerParameter("id"))
        {
            messageID = Convert.ToInt32(Request.QueryString["id"]);
        }
        //-----------------------------------------------
        if (messageID > 0)
        {
            MessagesEntity msg = MessagesFactory.GetMessagesObject(messageID, UsersTypes.Admin, SitesHandler.GetOwnerIDAsGuid());
            ucUpdate.DefaultPagePath += "?id=" + msg.ToItemID;
        }
        //-----------------------------------------------
        if (!IsPostBack)
        {
            if (currentModule.HasSpecialAdminText)
            {
                this.Page.Title = currentModule.GetModuleAdminSpecialTitle() + " - " + DynamicResource.GetText(currentModule, "Module_MessageData");
            }
            else
            {
                this.Page.Title = currentModule.GetModuleAdminSpecialTitle() + " - " + Resources.Modules.Module_MessageData;
            }
        }
        //-----------------------------------------------
    }
示例#9
0
        public static bool ContactUS(ContactUsModel model, out string resultMessage)
        {
            int moduleTypeID = 501;
            MessagesModuleOptions currentMessageModule = MessagesModuleOptions.GetType(moduleTypeID);
            //Preparing admin notification email
            string         mailBody = "<table style='width:auto; direction:" + DynamicResource.GetText("Lang", "Dir") + "'>";
            MessagesEntity msg      = new MessagesEntity();

            //-------------------------------------
            msg.ModuleTypeID = moduleTypeID;
            //--------------------------------------------------------------------------
            msg.Name    = model.Name;
            mailBody   += string.Format(rowTemplate, DynamicResource.GetMessageModuleText(currentMessageModule, "Name"), msg.Name);
            msg.EMail   = model.Email;
            mailBody   += string.Format(rowTemplate, DynamicResource.GetMessageModuleText(currentMessageModule, "Email"), msg.EMail);
            msg.Details = model.Message;
            mailBody   += string.Format(rowTemplate, DynamicResource.GetMessageModuleText(currentMessageModule, "Details"), model.Message);
            //-------------------------------------
            msg.LangID = SiteSettings.GetCurrentLanguage();
            bool createMessageFolder = (currentMessageModule.HasFileExtension || currentMessageModule.HasPhotoExtension || currentMessageModule.HasPhoto2Extension || currentMessageModule.HasVideoExtension || currentMessageModule.HasAudioExtension);
            bool status = MessagesFactory.Create(msg, createMessageFolder);

            if (status)
            {
                //-------------------------------------------------------------------------
                //RegisterInMailList
                if ((currentMessageModule.MailListAutomaticRegistration || (msg.HasEmailService)) && !string.IsNullOrEmpty(msg.EMail))
                {
                    MessagesFactory.RegisterInMailList(msg);
                }
                //------------------------------------------------------------------------
                //RegisterInSms
                if ((currentMessageModule.SmsAutomaticRegistration || (msg.HasSmsService)) && !string.IsNullOrEmpty(msg.Mobile))
                {
                    MessagesFactory.RegisterInSms(msg);
                }
                //------------------------------------------------------------------------
                //------------------------------------------------------------------------
                if (SiteSettings.Admininstration_HasAdminEmail)
                {
                    try
                    {
                        string subject = DynamicResource.GetMessageModuleText(currentMessageModule, "NewMessageRecieved");
                        SendMailToSiteAdmin(subject, mailBody);
                    }
                    catch (Exception exc)
                    {
                    }
                }
                //------------------------------------------------------------------------
                resultMessage = DynamicResource.GetMessageModuleText(currentMessageModule, "SendinogOperationDone");
            }
            else
            {
                resultMessage = DynamicResource.GetMessageModuleText(currentMessageModule, "SendinogOperationFaild");
            }
            return(status);
        }
示例#10
0
 public void BroadcastObjectiveRequest(string objective)
 {
     using (var bus = RabbitHutch.CreateBus("host=localhost").Advanced)
     {
         var fanout  = bus.ExchangeDeclare("BroadcastExchange", ExchangeType.Fanout);
         var request = MessagesFactory.GetMessage <ObjectiveRequestMessage>("Master", objective);
         bus.Publish(fanout, "Broadcast", true, request);
     }
 }
示例#11
0
 public void SendObjectiveRequest(string id, string objective)
 {
     using (var bus = RabbitHutch.CreateBus("host=localhost").Advanced)
     {
         var exchange = bus.ExchangeDeclare("ObjectiveExchange", ExchangeType.Direct);
         var request  = MessagesFactory.GetMessage <ObjectiveRequestMessage>("Master", objective);
         bus.Publish(exchange, "ObjectiveRequest" + id, true, request);
     }
 }
示例#12
0
 public void SendStatusRequest(string id)
 {
     using (var bus = RabbitHutch.CreateBus("host=localhost").Advanced)
     {
         var main    = bus.ExchangeDeclare("MainExchange", ExchangeType.Direct);
         var request = MessagesFactory.GetMessage <StatusRequestMessage>("Master", "payload");
         bus.Publish(main, "StatusRequest" + id, true, request);
     }
 }
示例#13
0
文件: Session.cs 项目: zhoulk/Lufy
 IEnumerator SendHeart()
 {
     while (IsConnected)
     {
         //Log.Debug("客户端发送了心跳.");
         byte     hid = 1;
         IMessage msg = MessagesFactory.Heart(hid);
         Send(msg.Encode());
         yield return(new WaitForSeconds(1f));
     }
 }
示例#14
0
        public void SolveRequestResponseMessageSerializationTest()
        {
            SolveRequestResponse response =
                MessagesFactory.CreateEmptyMessage(MessageType.SolveRequestResponseMessage).Cast <SolveRequestResponse>();

            response.Id = 100;
            string xml = _serializer.ToXmlString(response);
            SolveRequestResponse responseDeserialized = _serializer.FromXmlString(xml).Cast <SolveRequestResponse>();

            Assert.AreEqual(response.Id, responseDeserialized.Id);
        }
示例#15
0
            //-----------------------------------------------------------

            #region --------------LoadData--------------
            //---------------------------------------------------------
            //LoadData
            //---------------------------------------------------------
            public new void LoadData()
            {
                List <MessagesEntity> msgList = MessagesFactory.GetLast(ModuleTypeID, Count, OwnerID);
                Repeater r = (Repeater)this.FindControl(TemplateID);

                if (msgList != null && msgList.Count > 0)
                {
                    r.DataSource = msgList;
                    r.DataBind();
                }
            }
示例#16
0
        public async void Start()
        {
            Console.Write("Enter a unique ID number for the car: ");
            string id = Console.ReadLine();

            using (var bus = RabbitHutch.CreateBus("host=localhost").Advanced)
            {
                // Declare queues and exchanges:
                // Main (direct).
                var mainExchange = bus.ExchangeDeclare("MainExchange", ExchangeType.Direct);
                var mainQueue    = bus.QueueDeclare("StatusQueue" + id);
                bus.Bind(mainExchange, mainQueue, "StatusRequest" + id);

                // Objective (direct).
                var objectiveExchange = bus.ExchangeDeclare("ObjectiveExchange", ExchangeType.Direct);
                var objectiveQueue    = bus.QueueDeclare("ObjectiveQueue" + id);
                bus.Bind(objectiveExchange, objectiveQueue, "ObjectiveRequest" + id);

                // Broadcast (fanout).
                var broadcastExchange = bus.ExchangeDeclare("BroadcastExchange", ExchangeType.Fanout);
                var broadcastQueue    = bus.QueueDeclare("BroadcastQueue" + id);
                bus.Bind(broadcastExchange, broadcastQueue, "Broadcast");

                var message = MessagesFactory.GetMessage <ActorDeclarationMessage>(id, "");
                bus.Publish(mainExchange, "ActorDeclaration", true, message);

                // Consume messages using message handlers.
                // Status request:
                Action <IMessage <StatusRequestMessage>, MessageReceivedInfo> handleStatusRequest = (request, info) =>
                {
                    var req = request.Body;
                    Console.WriteLine("Received status request from " + req.Sender);
                    string status = arbitraryStatus();
                    Console.WriteLine("Declaring status: " + status);
                    IMessage <StatusResponseMessage> response = MessagesFactory.GetMessage <StatusResponseMessage>(id, status);
                    bus.Publish(mainExchange, "ActorStatus", true, response);
                };
                bus.Consume <StatusRequestMessage>(mainQueue, handleStatusRequest);
                bus.Consume <StatusRequestMessage>(broadcastQueue, handleStatusRequest);

                // Objective request:
                Action <IMessage <ObjectiveRequestMessage>, MessageReceivedInfo> handleObjectiveRequest = (request, info) =>
                {
                    var req = request.Body;
                    Console.WriteLine("Received objective from " + req.Sender + ": " + req.Payload);
                };
                bus.Consume <ObjectiveRequestMessage>(objectiveQueue, handleObjectiveRequest);
                bus.Consume <ObjectiveRequestMessage>(broadcastQueue, handleObjectiveRequest);

                await Task.Delay(1999999);
            }
        }
示例#17
0
        //-----------------------------------------------
        #endregion
        #region --------------LoadData--------------
        //---------------------------------------------------------
        //LoadData
        //---------------------------------------------------------
        public new void LoadData()
        {
            Languages langID = SiteSettings.GetCurrentLanguage();
            //List<MessagesEntity> msgList = MessagesFactory.GetAvailable(ModuleTypeID, categoryID, langID, Type, ToItemID, pager.CurrentPage, pager.PageSize, out totalRecords, OwnerID, keywords);
            List <MessagesEntity> msgList = MessagesFactory.GetAvailable(ModuleTypeID, CategoryID, langID, Type, ToItemID, OwnerID, "");
            Repeater r = (Repeater)this.FindControl(TemplateID);

            if (msgList != null && msgList.Count > 0)
            {
                r.DataSource = msgList;
                r.DataBind();
            }
        }
示例#18
0
文件: Session.cs 项目: zhoulk/Lufy
    /// <summary>
    /// 断开连接
    /// </summary>
    public void Disconnect()
    {
        if (!IsConnected)
        {
            return;
        }

        this.IsConnected = false;
        byte     hid = 1;
        IMessage msg = MessagesFactory.Disconnect(hid);

        Send(msg.Encode());
    }
示例#19
0
        public void RegisterResponseMessageSerializationTest()
        {
            RegisterResponse response =
                MessagesFactory.CreateEmptyMessage(MessageType.RegisterResponseMessage).Cast <RegisterResponse>();

            response.Id      = 1234;
            response.Timeout = 12345;
            string           xml = _serializer.ToXmlString(response);
            RegisterResponse responseDeserialized = _serializer.FromXmlString(xml).Cast <RegisterResponse>();

            Assert.AreEqual(response.Id, responseDeserialized.Id);
            Assert.AreEqual(response.Timeout, responseDeserialized.Timeout);
        }
示例#20
0
        public void RegisterMessageSerializationTest()
        {
            Message  message         = MessagesFactory.CreateEmptyMessage(MessageType.RegisterMessage);
            Register registerMessage = message.Cast <Register>();

            registerMessage.ParallelThreads  = 10;
            registerMessage.SolvableProblems = new[] { "DVRP" };
            string   xml = _serializer.ToXmlString(registerMessage);
            Message  m   = _serializer.FromXmlString(xml);
            Register registerMessageDeserialized = m.Cast <Register>();

            Assert.AreEqual(registerMessage.Id, registerMessageDeserialized.Id);
            Assert.AreEqual(registerMessage.SolvableProblems?.Length, registerMessageDeserialized.SolvableProblems?.Length);
        }
示例#21
0
        public void StatusMessageSerializationTest()
        {
            Message message       = MessagesFactory.CreateEmptyMessage(MessageType.StatusMessage);
            Status  statusMessage = message.Cast <Status>();

            statusMessage.Threads = new StatusThread[] { };
            statusMessage.Id      = 123;
            string  xml = _serializer.ToXmlString(statusMessage);
            Message m   = _serializer.FromXmlString(xml);
            Status  statusMessageDeserialized = m.Cast <Status>();

            Assert.AreEqual(statusMessage.Id, statusMessageDeserialized.Id);
            Assert.AreEqual(statusMessage.Threads?.Length, statusMessageDeserialized.Threads?.Length);
        }
示例#22
0
        public void NoOperationMessageSerializationTest()
        {
            Message     message     = MessagesFactory.CreateEmptyMessage(MessageType.NoOperationMessage);
            NoOperation noOperation = message.Cast <NoOperation>();

            noOperation.BackupServersInfo         = new BackupServerInfo[1];
            noOperation.BackupServersInfo[0]      = new BackupServerInfo();
            noOperation.BackupServersInfo[0].port = 1234;
            string      xml = _serializer.ToXmlString(noOperation);
            Message     m   = _serializer.FromXmlString(xml);
            NoOperation noOperationDeserialized = m.Cast <NoOperation>();

            Assert.AreEqual(noOperationDeserialized.BackupServersInfo[0].port,
                            noOperationDeserialized.BackupServersInfo[0].port);
        }
示例#23
0
    public static string SaveForm2Data(string name, string emial, string mobile, string question)
    {
        MessagesEntity msg = new MessagesEntity();

        msg.ModuleTypeID = 507;
        msg.Name         = name;
        msg.EMail        = emial;
        msg.Mobile       = mobile;
        msg.Details      = question;
        msg.LangID       = Languages.En;
        MessagesModuleOptions currentMessageModule = MessagesModuleOptions.GetType(507);
        bool createMessageFolder = (currentMessageModule.HasFileExtension || currentMessageModule.HasPhotoExtension || currentMessageModule.HasPhoto2Extension || currentMessageModule.HasVideoExtension || currentMessageModule.HasAudioExtension);
        bool status = MessagesFactory.Create(msg, createMessageFolder);

        return("worked");
    }
示例#24
0
        public void SolvePartialProblemsMessageSerializationTest()
        {
            SolvePartialProblems solveMessage =
                MessagesFactory.CreateEmptyMessage(MessageType.SolvePartialProblemsMessage).Cast <SolvePartialProblems>();

            solveMessage.CommonData              = new byte[150];
            solveMessage.Id                      = 123;
            solveMessage.SolvingTimeout          = 1344;
            solveMessage.SolvingTimeoutSpecified = true; //mandatory!
            string xml = _serializer.ToXmlString(solveMessage);
            SolvePartialProblems solveMessageDeserialized = _serializer.FromXmlString(xml).Cast <SolvePartialProblems>();

            Assert.AreEqual(solveMessage.CommonData.Length, solveMessageDeserialized.CommonData.Length);
            Assert.AreEqual(solveMessage.Id, solveMessageDeserialized.Id);
            Assert.AreEqual(solveMessage.SolvingTimeout, solveMessageDeserialized.SolvingTimeout);
        }
示例#25
0
        public void SolveRequestMessageSerializationTest()
        {
            SolveRequest request =
                MessagesFactory.CreateEmptyMessage(MessageType.SolveRequestMessage).Cast <SolveRequest>();

            request.Data                    = new byte[100];
            request.ProblemType             = "DVRP";
            request.SolvingTimeout          = 1500;
            request.SolvingTimeoutSpecified = true; //dziwne, że to trzeba podawać
            string       xml = _serializer.ToXmlString(request);
            SolveRequest requestDeserialized = _serializer.FromXmlString(xml).Cast <SolveRequest>();

            Assert.AreEqual(request.Data.Length, requestDeserialized.Data.Length);
            Assert.AreEqual(request.ProblemType, requestDeserialized.ProblemType);
            Assert.AreEqual(request.SolvingTimeout, requestDeserialized.SolvingTimeout);
        }
示例#26
0
        // Update is called once per frame
        void Update()
        {
            if (Input.GetMouseButton(0))
            {
                isClickDown = true;
            }
            else
            {
                if (isClickDown == true)
                {
                    isClickDown = false;
                    Debug.Log("acceleration " + Input.acceleration + "  " + go.attitude.eulerAngles);

                    IMessage msg = MessagesFactory.BowlingBall(1, Input.acceleration, go.attitude.eulerAngles);
                    UDPManager.Instance.Send(msg);
                }
            }
        }
示例#27
0
        //-----------------------------------------------
        #endregion
        #region --------------LoadData--------------
        //---------------------------------------------------------
        //LoadData
        //---------------------------------------------------------
        public new void LoadData()
        {
            //---------------------------------------------------------
            int categoryID = 0;

            if (MoversFW.Components.UrlManager.ChechIsValidIntegerParameter("id"))
            {
                categoryID = Convert.ToInt32(Request.QueryString["id"]);
            }
            //---------------------------------------------------------
            if (currentModule.CategoryLevel != 0 && categoryID == 0)
            {
                this.Visible = false;
            }
            else
            {
                //---------------------------------------------------------
                string keywords = "";
                if (trSearch.Visible)
                {
                    keywords = txtSearch.Text;
                }
                //---------------------------------------------------------
                pager.PageSize = currentModule.PageItemCount_UserDefault;
                List <MessagesEntity> msgList;
                //LoadListDesign();
                Languages langID = SiteSettings.GetCurrentLanguage();
                msgList = MessagesFactory.GetAvailable(ModuleTypeID, categoryID, langID, Type, ToItemID, pager.CurrentPage, pager.PageSize, out totalRecords, OwnerID, keywords);
                Control  c;
                DataList dl;
                Repeater r;
                c = this.FindControl(TemplateID);
                if (c is DataList)
                {
                    dl = (DataList)c;
                    LoadDataList(dl, msgList);
                }
                else
                {
                    r = (Repeater)c;
                    LoadRepeater(r, msgList);
                }
            }
        }
        //-----------------------------------------------------------

        #region --------------LoadData--------------
        //---------------------------------------------------------
        //LoadData
        //---------------------------------------------------------
        public new void LoadData()
        {
            List <MessagesEntity> msgList = MessagesFactory.GetLast(ModuleTypeID, Count, OwnerID);
            Control  c;
            DataList dl;
            Repeater r;

            c = this.FindControl(TemplateID);
            if (c is DataList)
            {
                dl = (DataList)c;
                LoadDataList(dl, msgList);
            }
            else
            {
                r = (Repeater)c;
                LoadRepeater(r, msgList);
            }
        }
示例#29
0
            //------------------------------------------
            #endregion

            #region --------------LoadData--------------
            //---------------------------------------------------------
            //LoadData
            //---------------------------------------------------------
            public void LoadData()
            {
                List <MessagesEntity> msgsList = MessagesFactory.GetLast(ModuleTypeID, ItemsCount, OwnerID);
                Repeater rList = (Repeater)this.FindControl("rList");

                //----------------------------------

                if (msgsList != null && msgsList.Count > 0 && rList != null)
                {
                    //-----------------------------------------
                    rList.DataSource = msgsList;
                    rList.DataBind();
                    rList.Visible = true;
                    //-----------------------------------------
                }
                else
                {
                    rList.Visible = false;
                }
            }
示例#30
0
    //---------------------------------------------------------
    //LoadList
    //---------------------------------------------------------
    public void LoadList()
    {
        StringDictionary      tempDictionary = new StringDictionary();
        List <MessagesEntity> arabicList     = null;
        List <MessagesEntity> englishList    = null;
        //--------------------------------------------------------------------
        Languages langID = Languages.Unknowen;

        if (!string.IsNullOrEmpty(Request.QueryString["lang"]))
        {
            langID = (Languages)Convert.ToInt32(Request.QueryString["lang"]);
        }
        else
        {
            if (SiteSettings.Languages_HasMultiLanguages)
            {
                langID = (Languages)Convert.ToInt32(ddlLanguages.SelectedValue);
            }
        }
        //--------------------------------------------------------------------
        int typeID = 0;

        if (!string.IsNullOrEmpty(Request.QueryString["type"]))
        {
            typeID = Convert.ToInt32(Request.QueryString["type"]);
        }
        else
        {
            if (currentModule.HasType)
            {
                typeID = Convert.ToInt32(ddlType.SelectedValue);
            }
        }
        //--------------------------------------------------------------------
        if (SiteSettings.Languages_HasMultiLanguages && langID == Languages.Unknowen)
        {
            messagesList = MessagesFactory.ExportData(ModuleTypeID, -1, Languages.Ar, typeID, -1, false, false, false, OwnerID);
            foreach (MessagesEntity msg in messagesList)
            {
                tempDictionary.Add(msg.MessageID.ToString(), null);
            }
            //------------------------------------------
            englishList = MessagesFactory.ExportData(ModuleTypeID, -1, Languages.En, typeID, -1, false, false, false, OwnerID);
            foreach (MessagesEntity msg in englishList)
            {
                if (!tempDictionary.ContainsKey(msg.MessageID.ToString()))
                {
                    messagesList.Add(msg);
                }
            }
        }
        //-------------------------------------------------------------------
        else
        {
            messagesList = MessagesFactory.ExportData(ModuleTypeID, -1, langID, typeID, -1, false, false, false, OwnerID);
            foreach (MessagesEntity msg in messagesList)
            {
                tempDictionary.Add(msg.MessageID.ToString(), null);
            }
        }

        //-------------------------------------------------------------------
    }