/** Serializes links placed by the user */ public override void SerializeUserConnections (UserConnection[] userConnections) { Debug.Log ("Loading from 3.0.1"); System.IO.BinaryWriter stream = writerStream; AddAnchor ("UserConnections"); if (userConnections != null) { stream.Write (userConnections.Length); for (int i=0;i<userConnections.Length;i++) { UserConnection conn = userConnections[i]; stream.Write (conn.p1.x); stream.Write (conn.p1.y); stream.Write (conn.p1.z); stream.Write (conn.p2.x); stream.Write (conn.p2.y); stream.Write (conn.p2.z); stream.Write (conn.overrideCost); stream.Write (conn.oneWay); stream.Write (conn.width); //stream.Write ((int)conn.type); Debug.Log ("End - "+stream.BaseStream.Position); } } else { stream.Write (0); } }
/** Deserializes links placed by the user */ public override UserConnection[] DeserializeUserConnections () { System.IO.BinaryReader stream = readerStream; if (MoveToAnchor ("UserConnections")) { int count = stream.ReadInt32 (); UserConnection[] userConnections = new UserConnection[count]; for (int i=0;i<count;i++) { UserConnection conn = new UserConnection (); conn.p1 = new Vector3 (stream.ReadSingle (),stream.ReadSingle (),stream.ReadSingle ()); conn.p2 = new Vector3 (stream.ReadSingle (),stream.ReadSingle (),stream.ReadSingle ()); conn.doOverrideCost = stream.ReadBoolean (); conn.overrideCost = stream.ReadInt32 (); conn.oneWay = stream.ReadBoolean (); conn.width = stream.ReadSingle (); conn.type = (ConnectionType)stream.ReadInt32 (); userConnections[i] = conn; } return userConnections; } else { return new UserConnection[0]; } }
public override EmbeddedProcess CreateEventsProcess(UserConnection userConnection) { return(new SysSettings_BaseEventsProcess(userConnection)); }
public async static Task LeaveGame(UserConnection connection) { var dateSuspended = DateTime.Now; var gameHubContext = GlobalHost.ConnectionManager.GetHubContext<GameHub>(); gameHubContext.Groups.Remove(connection.Id, connection.GameId); gameHubContext.Clients.Group(connection.GameId).userLeft(connection.User.UserName); using (var context = new MagicDbContext()) { var game = context.Games.Find(connection.GameId); if (game.Players.All(p => p.UserId != connection.UserId)) { // Remove observer who left. game.Observers.Remove(game.Observers.First(o => o.Id == connection.UserId)); return; } if (game.DateStarted.HasValue && !game.DateEnded.HasValue) { // TODO: STOP THE GAME, A PLAYER IS MISSING! Ask players to start game timeout? game.UpdateTimePlayed(dateSuspended); game.DateResumed = null; gameHubContext.Clients.Group(connection.GameId).pauseGame("has fled the battle!", connection.User.UserName, connection.User.ColorCode); var chatHubContext = GlobalHost.ConnectionManager.GetHubContext<ChatHub>(); chatHubContext.Clients.Group(connection.GameId).addMessage(connection.GameId, DateTime.Now.ToString("HH:mm:ss"), connection.User.UserName, connection.User.ColorCode, "has fled the battle, the game will be interrupted."); var playerStatus = game.Players.First(ps => ps.UserId == connection.UserId); playerStatus.Status = GameStatus.Unfinished; playerStatus.Player.Status = PlayerStatus.Missing; context.InsertOrUpdate(game, true); } else { var playerStatus = context.GameStatuses.Find(connection.UserId, connection.GameId); context.Delete(playerStatus, true); ResetReadyStatus(game.Id); } } }
// This subroutine is used a background listener thread to allow reading incoming // messages without lagging the user interface. private void DoListen() { try { // Listen for new connections. listener = new TcpListener(System.Net.IPAddress.Any, _serverPort); listener.Start(); do { // Create a new user connection using TcpClient returned by // TcpListener.AcceptTcpClient() UserConnection client = new UserConnection(listener.AcceptTcpClient()); // Create an event handler to allow the UserConnection to communicate // with the window. client.LineReceived += new LineReceive(OnLineReceived); //AddHandler client.LineReceived, AddressOf OnLineReceived; }while(true); } catch(Exception ex){ //MessageBox.Show(ex.ToString()); } }
private void sendResponse(UserConnection sender,BitArray emu_to_plc_bits,string temptrigger){ string bitstring = ""; /* //sender.SendData(emu_to_plc_bits.Length.ToString()); for(var i=0;i<emu_to_plc_bits.Length;i++) { if(i%8==0) { bitstring+=" |"; } if(i%4==0) { bitstring+=" "; } if(emu_to_plc_bits[i]==true){ bitstring += "1"; }else{ bitstring +="0"; } }*/ byte[] responsebytes = BitArrayToByteArray(emu_to_plc_bits); for(var i=0; i<responsebytes.Length;i++) { bitstring += responsebytes[i].ToString()+ " "; } sender.SendData(responsebytes); if(loggingenabled) { Debug.Log("Sent (trigger: "+ temptrigger +"):\r\n" + bitstring); } //sender.SendData("trigger:"+temptrigger + " output:" + bitstring);//Encoding.UTF8.GetString(BitArrayToByteArray(emu_to_plc_bits))); }
private void DoExcelListen() { // Excel listener try { // Listen for new connections. excelListener = new TcpListener(System.Net.IPAddress.Any, EXCEL_PORT_NUM); excelListener.Start(); do { // Create a new user connection using TcpClient returned by // TcpListener.AcceptTcpClient() UserConnection excelClient = new UserConnection(excelListener.AcceptTcpClient()); // Create an event handler to allow the UserConnection to communicate // with the window. excelClient.LineReceived += new LineReceive(ExcelOnLineReceived); //AddHandler client.LineReceived, AddressOf OnLineReceived; // UpdateStatus("new connection found: waiting for log-in"); }while(true); } catch(Exception ex){ //MessageBox.Show(ex.ToString()); } }
public override EmbeddedProcess CreateEventsProcess(UserConnection userConnnection) { return (new VwQueueSysProcess_OperatorSingleWindowEventsProcess(userConnnection)); }
public VwQueueSysProcess(UserConnection userConnection) : base(userConnection) { SchemaName = "VwQueueSysProcess"; }
public EmailProtocolEventsProcess(UserConnection userConnection) : base(userConnection) { }
public Currency(UserConnection userConnection) : base(userConnection) { }
public EmailProtocol(UserConnection userConnection) : base(userConnection) { SchemaName = "EmailProtocol"; }
public SysSettingsEventsProcess(UserConnection userConnection) : base(userConnection) { }
public SysSettings(UserConnection userConnection) : base(userConnection) { SchemaName = "SysSettings"; }
public override Task OnConnected() { using (var context = new MagicDbContext()) { var userId = Context.User.Identity.GetUserId(); var foundUser = context.Users.Find(userId); var connection = new UserConnection { Id = Context.ConnectionId, UserId = userId }; context.Connections.Add(connection); context.SaveChanges(); SubscribeChatRoom(DefaultRoomId); if (foundUser.Connections.Count == 1) { // If this is the user's only connection broadcast a chat info. UserStatusUpdate(userId, UserStatus.Online, DefaultRoomId); } UpdateChatRoomUsers(DefaultRoomId); foreach (var chatRoom in GetChatRoomsWithUser(userId)) { UpdateChatRoomUsers(chatRoom.Id); } SubscribeActiveChatRooms(Context.ConnectionId, userId); // TODO: What when: user disconnects, other user has private chat tab open, user connects again - chat tab is unsubscribed, typing message does not notify receiving user? // Solution: use message notifications for that - partially implemented. } System.Diagnostics.Debug.WriteLine("Connected: " + Context.ConnectionId); return base.OnConnected(); }
public VwQueueSysProcessEventsProcess(UserConnection userConnection) : base(userConnection) { }
private void sendResponse(UserConnection sender,string IATAstring,int lasttrigger){ int triggerLocation = 100; byte[] responsebytes = new byte[200]; //BitArrayToByteArray(emu_to_plc_bits); for(var i=0; i<IATAstring.Length;i++) { responsebytes[7+i]=(byte)IATAstring[i]; //(copies the IATA characters) } responsebytes[6] = (byte)IATAstring.Length; int triggerpointer = triggerLocation; //index of start of 40th dint; int trigger = lasttrigger; for(var i=0;i<4;i++){ int byteval = (int)Math.Floor(trigger/Math.Pow(256,3-i)); responsebytes[triggerpointer+3-i] = (byte)byteval; trigger=trigger - byteval; } sender.SendData(responsebytes); if(loggingenabled) { Debug.Log("Sent IATA:"+ IATAstring +"\r\n"); } }
public override Process CreateProcess(UserConnection userConnection) { return(new TranslationActualizationProcess(userConnection)); }
// This subroutine checks to see if username already exists in the clients // Hashtable. if it does, send a REFUSE message, otherwise confirm with a JOIN. private void ConnectUser(string userName, UserConnection sender) {; if (clients.Contains(userName)) { ReplyToSender("REFUSE", sender); } else { sender.Name = userName; // UpdateStatus(userName + " has joined the chat."); clients.Add(userName, sender); //lstPlayers.Items.Add(sender.Name); // Send a JOIN to sender, and notify all other clients that sender joined ReplyToSender("JOIN", sender); // SendToClients("CHAT|" + sender.Name + " has joined the chat.", sender); } }
public ProcessTranslationActualizationProcessLane(UserConnection userConnection, TranslationActualizationProcess process) : base(userConnection) { Owner = process; IsUsedParentUserContexts = false; }
// This is the event handler for the UserConnection when it receives a full line. // Parse the cammand and parameters and take appropriate action. private void OnLineReceived(UserConnection sender, byte[] data) { //Debug.Log("Received:\r\n"+data); byte[] iobytes = data; //encoding.GetBytes(data); int trigger = 0; if(iobytes.Length>=4){ trigger = Convert.ToInt32(iobytes[160])+(Convert.ToInt32(iobytes[161])*256)+(Convert.ToInt32(iobytes[162])*65536)+(Convert.ToInt32(iobytes[163])*16777216); } if(trigger == lasttrigger) { if(loggingenabled) { Debug.Log("Ignored Trigger " + trigger.ToString()); } return; } lasttrigger = trigger; BitArray iovals = new System.Collections.BitArray(iobytes); string plc_to_emu_bit_string_bits = ""; string plc_to_emu_bit_string = ""; for(var i=0; i<iobytes.Length;i++) { plc_to_emu_bit_string += iobytes[i].ToString()+ " "; } /* for(var i=0;i<iovals.Length;i++) { if(i%8==0) { plc_to_emu_bit_string_bits+=" |"; } if(i%4==0) { plc_to_emu_bit_string_bits+=" "; } if(iovals[i]==true){ plc_to_emu_bit_string_bits +=1; } else { plc_to_emu_bit_string_bits +=0; } }*/ /* string plc_to_emu_bit_string_bits = ""; string plc_to_emu_bit_string = ""; int tbyte = 0; int tbytecount = 7; for(var i=0;i<iovals.Length;i++) { if(i%8==0) { tbyte = 0; tbytecount =7; } //iovals[i] if(iovals[i]==true){ tbyte += (int) Math.Pow(2,tbytecount); //plc_to_emu_bit_string += "1"; plc_to_emu_bit_string_bits+="1"; }else{ //tbyte += (int)Math.Pow(2,tbytecount); //plc_to_emu_bit_string +="0"; plc_to_emu_bit_string_bits +="0"; } if(tbytecount==0) { plc_to_emu_bit_string += tbyte.ToString()+" "; } tbytecount--; }*/ if(loggingenabled) { Debug.Log("Received:\r\n"+plc_to_emu_bit_string); //Debug.Log("Received bits:\r\n"+plc_to_emu_bit_string_bits); } for(var i=0;i<conveyer.Length;i++) { if((bool)iovals[conveyerio[i]] != conveyerstate[i]) // The STATE HAS CHANGED!! { conveyerstate[i]=(bool)iovals[conveyerio[i]]; } } for(var i=0;i<conveyer_turn_run.Length;i++) { if((bool)iovals[conveyer_turn_run_io[i]] != conveyer_turn_run_state[i]) // The STATE HAS CHANGED!! { conveyer_turn_run_state[i]=(bool)iovals[conveyer_turn_run_io[i]]; } } for(var i=0;i<conveyer_merge_run.Length;i++) { if((bool)iovals[conveyer_merge_run_io[i]] != conveyer_merge_run_state[i]) // The STATE HAS CHANGED!! { conveyer_merge_run_state[i]=(bool)iovals[conveyer_merge_run_io[i]]; } } for(var i=0;i<hsd_cycle.Length;i++) { if((bool)iovals[hsd_cycle_io[i]] != hsd_last_cycle_io[i]) // The STATE HAS CHANGED!! { if(debuglogenabled) { Debug.Log("HSD "+ hsd_cycle_io[i]+ " cycle input changed to "+ ((bool)iovals[hsd_cycle_io[i]]).ToString()); } if((bool)iovals[hsd_cycle_io[i]]) // if rising edge. { if(debuglogenabled) { Debug.Log("HSD "+ hsd_cycle_io[i]+ " toggled to "+ (!hsd_cycle_state[i]).ToString()); } hsd_cycle_state[i]=!hsd_cycle_state[i]; // then toggle it. } hsd_last_cycle_io[i]=(bool)iovals[hsd_cycle_io[i]]; } } for(var i=0;i<vsu_cycle.Length;i++) { if((bool)iovals[vsu_cycle_io[i]] != vsu_last_cycle_io[i]) // The STATE HAS CHANGED!! { if((bool)iovals[vsu_cycle_io[i]]) // if rising edge. { vsu_cycle_state[i]=!vsu_cycle_state[i]; // then toggle it. } vsu_last_cycle_io[i]=(bool)iovals[vsu_cycle_io[i]]; } } for(var i=0;i<cs_button_output.Length;i++) { if((bool)iovals[cs_button_output_io[i]] != cs_button_output_state[i]) // The STATE HAS CHANGED!! { cs_button_output_state[i]=(bool)iovals[cs_button_output_io[i]]; } } for(var i=0;i<pe_assign_security_clear.Length;i++) { if((bool)iovals[pe_assign_security_clear_io[i]] != pe_assign_security_clear_state[i]) // The STATE HAS CHANGED!! { //Debug.Log ("changed Clear val"); pe_assign_security_clear_state[i]=(bool)iovals[pe_assign_security_clear_io[i]]; } } for(var i=0;i<pe_assign_security_alarmed.Length;i++) { if((bool)iovals[pe_assign_security_alarmed_io[i]] != pe_assign_security_alarmed_state[i]) // The STATE HAS CHANGED!! { pe_assign_security_alarmed_state[i]=(bool)iovals[pe_assign_security_alarmed_io[i]]; } } for(var i=0;i<pe_assign_security_pending.Length;i++) { if((bool)iovals[pe_assign_security_pending_io[i]] != pe_assign_security_pending_state[i]) // The STATE HAS CHANGED!! { pe_assign_security_pending_state[i]=(bool)iovals[pe_assign_security_pending_io[i]]; } } int heartlog = Logger.counter++; if(heartlog==100) { Logger.WriteLine("[INFO]","COM_SRV","Heartbeat",true); Logger.counter = 0; } // check if different. Loom.QueueOnMainThread(()=>{ for(var i=0;i<conveyer.Length;i++) { if(conveyerstate[i] !=conveyerlaststate[i]) { if(conveyer[i].GetType()!=System.Type.GetType("ConveyorForward")){ } else if(conveyer[i]==null){ Logger.WriteLine("[FATAL]","COM_SRV","NULL FOUND!!!! Somehow this reference has been lost!",true); //Debug.Log( } conveyer[i].setState(conveyerstate[i]); conveyerlaststate[i] = conveyerstate[i]; } } for(var i=0;i<conveyer_turn_run.Length;i++) { if(conveyer_turn_run_state[i] !=conveyer_turn_run_laststate[i]) { conveyer_turn_run[i].setState(conveyer_turn_run_state[i]); conveyer_turn_run_laststate[i] = conveyer_turn_run_state[i]; } } for(var i=0;i<conveyer_merge_run.Length;i++) { if(conveyer_merge_run_state[i] !=conveyer_merge_run_laststate[i]) { conveyer_merge_run[i].setState(conveyer_merge_run_state[i]); conveyer_merge_run_laststate[i] = conveyer_merge_run_state[i]; } } for(var i=0;i<hsd_cycle.Length;i++) { if(hsd_cycle_state[i] !=hsd_cycle_laststate[i]) { hsd_cycle[i].setState(hsd_cycle_state[i]); hsd_cycle_laststate[i] = hsd_cycle_state[i]; } } for(var i=0;i<vsu_cycle.Length;i++) { if(vsu_cycle_state[i] !=vsu_cycle_laststate[i]) { vsu_cycle[i].setState(vsu_cycle_state[i]); vsu_cycle_laststate[i] = vsu_cycle_state[i]; } } for(var i=0;i<cs_button_output.Length;i++) { if(cs_button_output_state[i] !=cs_button_output_laststate[i]) { cs_button_output[i].setState(cs_button_output_state[i]); cs_button_output_laststate[i] = cs_button_output_state[i]; } } for(var i=0;i<pe_assign_security_clear.Length;i++) { if(pe_assign_security_clear_state[i] !=pe_assign_security_clear_laststate[i]) { pe_assign_security_clear[i].setAssignClear(pe_assign_security_clear_state[i]); pe_assign_security_clear_laststate[i] = pe_assign_security_clear_state[i]; } } for(var i=0;i<pe_assign_security_alarmed.Length;i++) { if(pe_assign_security_alarmed_state[i] !=pe_assign_security_alarmed_laststate[i]) { pe_assign_security_alarmed[i].setAssignAlarmed(pe_assign_security_alarmed_state[i]); pe_assign_security_alarmed_laststate[i] = pe_assign_security_alarmed_state[i]; } } for(var i=0;i<pe_assign_security_pending.Length;i++) { if(pe_assign_security_pending_state[i] !=pe_assign_security_pending_laststate[i]) { pe_assign_security_pending[i].setAssignPending(pe_assign_security_pending_state[i]); pe_assign_security_pending_laststate[i] = pe_assign_security_pending_state[i]; } } }); // copy over last state //Loom.QueueOnMainThread(()=>{ // GameObject.Find("M_TC1_01").GetComponent<ConveyorForward>().setState(true); //}); //sender.SendData("Beltname:"+conveyern + " iopoint:" + iopointst + " previousstate:"+previousstate+" newstate:"+newstate + " input byte length:"+iovals.Length.ToString()); //return; /* byte[] overbyte = new byte[164]; for(var i=0;i<overbyte.Length;i++) { if(i%4==0) { overbyte[i] = (byte)(i/4+1); } } emu_to_plc_bits = new System.Collections.BitArray(overbyte); */ string triggerstring = ""; int triggerpointer = max_emu_to_plc_io-32; //index of start of 40th dint; int temptrigger = trigger; for(var i=0;i<32;i++){ int bit = (int)Math.Floor(trigger/Math.Pow(2,31-i)); triggerstring += trigger.ToString() + " "; if(bit ==1) { trigger = trigger - (int)Math.Pow (2,31-i); emu_to_plc_bits[triggerpointer+31-i] = true; } else { emu_to_plc_bits[triggerpointer+31-i] = false; //false; } } /*for(var i=0;i<emu_to_plc_bits.Length;i++) { emu_to_plc_bits[i]=i; }*/ if(!getnewinputs) { sendResponse(sender,emu_to_plc_bits,temptrigger.ToString()); return; } if(firstpass) { //firstpass = false; Loom.QueueOnMainThread(()=>{ for(var i=0;i<photoeye.Length;i++) { emu_to_plc_bits[photoeyeIO[i]] = photoeye[i].getState(); } for(var i=0;i<conveyer_disconnect.Length;i++) { emu_to_plc_bits[conveyer_disconnect_io[i]] = conveyer_disconnect[i].getDisconnect(); } for(var i=0;i<conveyer_turn_disconnect.Length;i++) { emu_to_plc_bits[conveyer_turn_disconnect_io[i]] = conveyer_turn_disconnect[i].getDisconnect(); } for(var i=0;i<conveyer_merge_disconnect.Length;i++) { emu_to_plc_bits[conveyer_merge_disconnect_io[i]] = conveyer_merge_disconnect[i].getDisconnect(); } for(var i=0;i<hsd_extended_prox.Length;i++) { emu_to_plc_bits[hsd_extended_prox_io[i]] = hsd_extended_prox[i].GetExtended(); } for(var i=0;i<hsd_retracted_prox.Length;i++) { emu_to_plc_bits[hsd_retracted_prox_io[i]] = hsd_retracted_prox[i].GetRetracted(); } for(var i=0;i<vsu_up_prox.Length;i++) { emu_to_plc_bits[vsu_up_prox_io[i]] = vsu_up_prox[i].GetExtended(); } for(var i=0;i<vsu_down_prox.Length;i++) { emu_to_plc_bits[vsu_down_prox_io[i]] = vsu_down_prox[i].GetRetracted(); } for(var i=0;i<cs_button_input.Length;i++) { emu_to_plc_bits[cs_button_input_io[i]] = cs_button_input[i].getState(); } for(var i=0;i<bmas.Length;i++) { emu_to_plc_bits[bma_OK_io[i]] = bmas[i].getBMA_OK(); emu_to_plc_bits[bma_OOG_io[i]] = bmas[i].getBMA_OOG(); } sendResponse(sender,emu_to_plc_bits,temptrigger.ToString()); }); } else{ Loom.QueueOnMainThread(()=>{ for(var i=0;i<photoeye.Length;i++) { emu_to_plc_bits[photoeyeIO[i]] = photoeye[i].getState(); } for(var i=0;i<conveyer_disconnect.Length;i++) { emu_to_plc_bits[conveyer_disconnect_io[i]] = conveyer_disconnect[i].getDisconnect(); } for(var i=0;i<conveyer_turn_disconnect.Length;i++) { emu_to_plc_bits[conveyer_turn_disconnect_io[i]] = conveyer_turn_disconnect[i].getDisconnect(); } for(var i=0;i<conveyer_merge_disconnect.Length;i++) { emu_to_plc_bits[conveyer_merge_disconnect_io[i]] = conveyer_merge_disconnect[i].getDisconnect(); } for(var i=0;i<hsd_extended_prox.Length;i++) { emu_to_plc_bits[hsd_extended_prox_io[i]] = hsd_extended_prox[i].GetExtended(); } for(var i=0;i<hsd_retracted_prox.Length;i++) { emu_to_plc_bits[hsd_retracted_prox_io[i]] = hsd_retracted_prox[i].GetRetracted(); } for(var i=0;i<vsu_up_prox.Length;i++) { emu_to_plc_bits[vsu_up_prox_io[i]] = vsu_up_prox[i].GetExtended(); } for(var i=0;i<vsu_down_prox.Length;i++) { emu_to_plc_bits[vsu_down_prox_io[i]] = vsu_down_prox[i].GetRetracted(); } for(var i=0;i<cs_button_input.Length;i++) { emu_to_plc_bits[cs_button_input_io[i]] = cs_button_input[i].getState(); } for(var i=0;i<bmas.Length;i++) { emu_to_plc_bits[bma_OK_io[i]] = bmas[i].getBMA_OK(); emu_to_plc_bits[bma_OOG_io[i]] = bmas[i].getBMA_OOG(); } }); sendResponse(sender,emu_to_plc_bits,temptrigger.ToString()); } //sender.SendData(Encoding.UTF8.GetString(BitArrayToByteArray(emu_to_plc_bits))); string[] dataArray; // Message parts are divided by "|" Break the string into an array accordingly. // Basically what happens here is that it is possible to get a flood of data during // the lock where we have combined commands and overflow // to simplify this proble, all I do is split the response by char 13 and then look // at the command, if the command is unknown, I consider it a junk message // and dump it, otherwise I act on it /* dataArray = data.Split((char) 13); dataArray = dataArray[0].Split((char) 124); // dataArray(0) is the command. switch( dataArray[0]) { case "CONNECT": ConnectUser(dataArray[1], sender); break; case "CHAT": SendChat(dataArray[1], sender); break; case "DISCONNECT": DisconnectUser(sender); break; default: // Message is junk do nothing with it. break; }*/ }
public SysUserInRole(UserConnection userConnection) : base(userConnection) { }
// This subroutine sends a response to the sender. private void ReplyToSender(string strMessage, UserConnection sender) { sender.SendData(strMessage); }
public InitTask(UserConnection uc, PlayerState player) { _uc = uc; _player = player; }
public ActionResult BlockedUser(int userAccountID) { var bu = new BlockedUser(); _ucon = new UserConnection(); if (_mu != null) _ucon.GetUserToUserConnection(userAccountID, Convert.ToInt32(_mu.ProviderUserKey)); _ucon.Delete(); bu.UserAccountIDBlocked = userAccountID; if (_mu != null) bu.UserAccountIDBlocking = Convert.ToInt32(_mu.ProviderUserKey); bu.Create(); return RedirectToAction("Visitors"); }
public Product(UserConnection userConnection) : base(userConnection) { }
/** Removes user connection \a conn from the script.astarData.userConnections array */ void RemoveConnection (UserConnection conn) { UserConnection[] conns = script.astarData.userConnections; List<UserConnection> connList = new List<UserConnection>(conns); connList.Remove (conn); script.astarData.userConnections = connList.ToArray (); selectedUserConnection = -1; HandleUtility.Repaint (); RepaintSceneView (); //Use the Event to avoid the annoying system beep (indicating a key which can't be used here, so we inform the system that it can... it prevents the beep anyway). Event.current.Use (); GUI.changed = true; }
public override EmbeddedProcess CreateEventsProcess(UserConnection userConnection) { return(new EmailDefRights_BaseEventsProcess(userConnection)); }
public ActionResult ContactRequest(NameValueCollection postedData) { NameValueCollection qury = Request.QueryString; UserAccount userToBe = new UserAccount(qury["username"]); UserConnection ucToSet = new UserConnection(); mu = Membership.GetUser(); ucToSet.GetUserToUserConnection( Convert.ToInt32(Membership.GetUser().ProviderUserKey), userToBe.UserAccountID); if (ucToSet.UserConnectionID == 0 && qury["rslt"] == "0") { // they never set anything up and are ending the request Response.Redirect("~/" + userToBe.UserName); } else if (ucToSet.UserConnectionID != 0 && qury["rslt"] == "0") { if (Convert.ToInt32(mu.ProviderUserKey) != ucToSet.CreatedByUserID) { // one user sent a request and now it's rejected ucToSet.StatusType = 'L'; ucToSet.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); ucToSet.IsConfirmed = true; ucToSet.Update(); Response.Redirect("/" + Membership.GetUser().UserName); } else { // this is assumed to be not a declude because it is a reject by the issuer Response.Redirect("/" + userToBe.UserName); } } else if (ucToSet.UserConnectionID == 0 && qury["rslt"] == "1") { // they are not yet connected and are requesting to begin a connection ucToSet.IsConfirmed = false; ucToSet.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); ucToSet.FromUserAccountID = Convert.ToInt32(mu.ProviderUserKey); ucToSet.ToUserAccountID = userToBe.UserAccountID; ucToSet.StatusType = Convert.ToChar(qury["contacttype"]); ucToSet.Create(); Response.Redirect("/" + userToBe.UserName); } else if (ucToSet.UserConnectionID > 0 && qury["rslt"] == "1") { // there was a request that is being confirmed if (ucToSet.StatusType == Convert.ToChar(qury["contacttype"])) { ucToSet.IsConfirmed = true; } else { // upgrading the request ucToSet.IsConfirmed = false; if (Convert.ToInt32(mu.ProviderUserKey) == ucToSet.ToUserAccountID) { // the opposite this time ucToSet.FromUserAccountID = Convert.ToInt32(mu.ProviderUserKey); ucToSet.ToUserAccountID = userToBe.UserAccountID; } } ucToSet.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); ucToSet.StatusType = Convert.ToChar(qury["contacttype"]); ucToSet.Update(); switch (Convert.ToChar(qury["contacttype"])) { case 'R': if (ucToSet.IsConfirmed) { Response.Redirect("~/account/irlcontacts/" + mu.UserName); } else { Response.Redirect("/" + userToBe.UserName); } break; case 'C': if (ucToSet.IsConfirmed) { Response.Redirect("~/account/CyberAssociates/" + mu.UserName); } else { Response.Redirect("~/" + userToBe.UserName); } break; case 'L': Response.Redirect("~/" + mu.UserName); break; default: break; } } else { // ??? } return View(); }
public EmailDefRights(UserConnection userConnection) : base(userConnection) { SchemaName = "EmailDefRights"; }
public ActionResult ProfileDetail(string userName) { ViewBag.VideoHeight = (Request.Browser.IsMobileDevice) ? 100 : 277; ViewBag.VideoWidth = (Request.Browser.IsMobileDevice) ? 225 : 400; ua = new UserAccount(userName); UserAccountDetail uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(ua.UserAccountID); uad.BandsSeen = ContentLinker.InsertBandLinks(uad.BandsSeen, false); uad.BandsToSee = ContentLinker.InsertBandLinks(uad.BandsToSee, false); MembershipUser mu = Membership.GetUser(); ProfileModel model = new ProfileModel(); if (ua.UserAccountID > 0) { model.UserAccountID = ua.UserAccountID; model.PhotoCount = PhotoItems.GetPhotoItemCountForUser(ua.UserAccountID); model.CreateDate = ua.CreateDate; } if (mu != null) { ViewBag.IsBlocked = BlockedUser.IsBlockedUser(ua.UserAccountID, Convert.ToInt32(mu.ProviderUserKey)); ViewBag.IsBlocking = BlockedUser.IsBlockedUser(Convert.ToInt32(mu.ProviderUserKey), ua.UserAccountID); if (ua.UserAccountID == Convert.ToInt32(mu.ProviderUserKey)) { model.IsViewingSelf = true; } else { UserConnection ucon = new UserConnection(); ucon.GetUserToUserConnection(Convert.ToInt32(mu.ProviderUserKey), ua.UserAccountID); model.UserConnectionID = ucon.UserConnectionID; if (BlockedUser.IsBlockedUser(Convert.ToInt32(mu.ProviderUserKey), ua.UserAccountID)) { return RedirectToAction("index", "home"); } } } else { if (uad.MembersOnlyProfile) { return RedirectToAction("Account", "LogOn"); } } // model.UserName = ua.UserName; model.CreateDate = ua.CreateDate; model.LastActivityDate = ua.LastActivityDate; // model.DisplayAge = uad.DisplayAge; model.Age = uad.YearsOld; model.BandsSeen = uad.BandsSeen; model.BandsToSee = uad.BandsToSee; model.HardwareAndSoftwareSkills = uad.HardwareSoftware; model.MessageToTheWorld = uad.AboutDescription; model.YouAreFull = uad.Sex; model.InterestedInFull = uad.InterestedFull; model.RelationshipStatusFull = uad.RelationshipStatusFull ; model.RelationshipStatus = uad.RelationshipStatus; model.InterestedIn = uad.InterestedIn; model.YouAre = uad.YouAre; model.Website = uad.ExternalURL; model.CountryCode = uad.Country; model.CountryName = uad.CountryName; model.IsBirthday = uad.IsBirthdayToday; model.ProfilePhotoMain = uad.FullProfilePicURL; model.ProfilePhotoMainThumb = uad.FullProfilePicThumbURL; model.DefaultLanguage = uad.DefaultLanguage; model.EnableProfileLogging = uad.EnableProfileLogging; model.Handed = uad.HandedFull; model.RoleIcon = uad.SiteBages; // StatusUpdate su = new StatusUpdate(); su.GetMostRecentUserStatus(ua.UserAccountID); if (su.StatusUpdateID > 0) { model.LastStatusUpdate = su.CreateDate; model.MostRecentStatusUpdate = su.Message; } model.ProfileVisitorCount = ProfileLog.GetUniqueProfileVisitorCount(ua.UserAccountID); PhotoItems ptiems = new PhotoItems(); ptiems.GetUserPhotos(ua.UserAccountID); if (ptiems.Count > 0) { ptiems.Sort((PhotoItem x, PhotoItem y) => (y.CreateDate.CompareTo(x.CreateDate))); PhotoItems ptiemsDisplay = new PhotoItems(); int maxPhotos = 8; foreach (PhotoItem pitm1 in ptiems) { pitm1.UseThumb = true; if (ptiemsDisplay.Count < maxPhotos) { ptiemsDisplay.Add(pitm1); } else break; } ptiemsDisplay.UseThumb = true; ptiemsDisplay.ShowTitle = false; model.HasMoreThanMaxPhotos = (ptiems.Count > maxPhotos); ptiemsDisplay.IsUserPhoto = true; model.PhotoItems = ptiemsDisplay.ToUnorderdList; } Contents conts = new Contents(); conts.GetContentForUser(ua.UserAccountID); model.NewsCount = conts.Count; if (conts.Count > 0) { conts.Sort((Content x, Content y) => (y.ReleaseDate.CompareTo(x.ReleaseDate))); Contents displayContents = new Contents(); int maxCont = 1; int currentCount = 0; foreach (Content ccn1 in conts) { currentCount++; if (maxCont >= currentCount) { displayContents.Add(ccn1); } else break; } displayContents.IncludeStartAndEndTags = false; model.NewsArticles = displayContents.ToUnorderdList; } model.MetaDescription = ua.UserName + " " + BootBaronLib.Resources.Messages.Profile + " " + FromDate.DateToYYYY_MM_DD(ua.LastActivityDate); // playlist BootBaronLib.AppSpec.DasKlub.BOL.Playlist plyst = new Playlist(); plyst.GetUserPlaylist(ua.UserAccountID); if (plyst.PlaylistID > 0 && PlaylistVideos.GetCountOfVideosInPlaylist(plyst.PlaylistID) > 0) { ViewBag.AutoPlay = plyst.AutoPlay; ViewBag.AutoPlayNumber = (plyst.AutoPlay) ? 1 : 0; ViewBag.UserPlaylistID = plyst.PlaylistID; } if (uad.UserAccountID > 0) { model.Birthday = uad.BirthDate; if (uad.ShowOnMapLegal) { byte[] myarray2 = Encoding.Unicode.GetBytes(string.Empty); // because of the foreign cultures, numbers need to stay in the English version unless a javascript encoding could be added string currentLang = Utilities.GetCurrentLanguageCode(); Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString()); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString()); Encoding iso = Encoding.GetEncoding("ISO-8859-1"); Encoding utf8 = Encoding.UTF8; model.DisplayOnMap = uad.ShowOnMapLegal; Random rnd = new Random(); int offset = rnd.Next(10, 100); SiteStructs.LatLong latlong = GeoData.GetLatLongForCountryPostal(uad.Country, uad.PostalCode); if (latlong.latitude != 0 && latlong.longitude != 0) { model.Latitude = Convert.ToDecimal(latlong.latitude + Convert.ToDouble("0.00" + offset)).ToString(); model.Longitude = Convert.ToDecimal(latlong.longitude + Convert.ToDouble("0.00" + offset)).ToString(); } else { model.DisplayOnMap = false; } Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(currentLang); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(currentLang); } ViewBag.ThumbIcon = uad.FullProfilePicThumbURL; LoadCurrentImagesViewBag(uad.UserAccountID); } ViewBag.UserAccountDetail = uad; ViewBag.UserAccount = ua; UserConnections ucons = new UserConnections(); ucons.GetUserConnections(ua.UserAccountID); ucons.Shuffle(); UserAccounts irlContacts = new UserAccounts(); UserAccounts CyberAssociates = new UserAccounts(); UserAccount userCon = null; foreach (UserConnection uc1 in ucons) { if (!uc1.IsConfirmed) continue; switch (uc1.StatusType) { case 'C': if (CyberAssociates.Count >= maxcountusers) continue; if (uc1.ToUserAccountID != ua.UserAccountID) { userCon = new UserAccount(uc1.ToUserAccountID); } else { userCon = new UserAccount(uc1.FromUserAccountID); } CyberAssociates.Add(userCon); break; case 'R': if (irlContacts.Count >= maxcountusers) continue; if (uc1.ToUserAccountID != ua.UserAccountID) { userCon = new UserAccount(uc1.ToUserAccountID); } else { userCon = new UserAccount(uc1.FromUserAccountID); } irlContacts.Add(userCon); break; default: break; } } if (irlContacts.Count > 0) { model.IRLFriendCount = irlContacts.Count; } if (CyberAssociates.Count > 0) { // ViewBag.CyberAssociatesCount = Convert.ToString( CyberAssociates.Count ); model.CyberFriendCount = CyberAssociates.Count; } mu = Membership.GetUser(); UserAccountDetail uadLooker = null; if (mu != null) { uadLooker = new UserAccountDetail(); uadLooker.GetUserAccountDeailForUser(Convert.ToInt32(mu.ProviderUserKey)); } if (mu != null && ua.UserAccountID > 0 && uadLooker.EnableProfileLogging && uad.EnableProfileLogging) { ProfileLog pl = new ProfileLog(); pl.LookedAtUserAccountID = ua.UserAccountID; pl.LookingUserAccountID = Convert.ToInt32(mu.ProviderUserKey); if (pl.LookingUserAccountID != pl.LookedAtUserAccountID) pl.Create(); ArrayList al = ProfileLog.GetRecentProfileViews(ua.UserAccountID); if (al != null && al.Count > 0) { UserAccounts uas = new UserAccounts(); UserAccount viewwer = null; foreach (int ID in al) { viewwer = new UserAccount(ID); if (!viewwer.IsLockedOut && viewwer.IsApproved) { if (uas.Count >= maxcountusers) break; uas.Add(viewwer); } } // model.ViewingUsers = uas.ToUnorderdList; } } UserAccountVideos uavs = null; if (ua.UserAccountID > 0) { uavs = new UserAccountVideos(); uavs.GetRecentUserAccountVideos(ua.UserAccountID, 'F'); if (uavs.Count > 0) { Videos favvids = new Videos(); Video f1 = new Video(); foreach (UserAccountVideo uav1 in uavs) { f1 = new Video(uav1.VideoID); if (f1.IsEnabled) favvids.Add(f1); } SongRecord sng1 = null; SongRecords sngrcds2 = new SongRecords(); foreach (Video v1 in favvids) { sng1 = new SongRecord(v1); sngrcds2.Add(sng1); } sngrcds2.IsUserSelected = true; ViewBag.UserFavorites = sngrcds2.VideosList();//.ListOfVideos(); } } // this is either a youtube user or this is a band Artist art = new Artist( ); art.GetArtistByAltname(userName); if (art.ArtistID > 0) { // try this way for dashers model.UserName = art.Name; } Videos vids = new Videos(); SongRecords sngrs = new SongRecords(); if (art.ArtistID == 0) { vids.GetAllVideosByUser(userName); uavs = new UserAccountVideos(); uavs.GetRecentUserAccountVideos(ua.UserAccountID, 'U'); Video f2 = null; foreach (UserAccountVideo uav1 in uavs) { f2 = new Video(uav1.VideoID); if (!vids.Contains(f2)) vids.Add(f2); } vids.Sort((Video x, Video y) => (y.PublishDate.CompareTo(x.PublishDate))); model.UserName = userName; } else { // photo ArtistProperty aprop = new ArtistProperty(); aprop.GetArtistPropertyForTypeArtist(art.ArtistID, SiteEnums.ArtistPropertyType.PH.ToString()); if (!string.IsNullOrEmpty(aprop.PropertyContent)) { ViewBag.ArtistPhoto = System.Web.VirtualPathUtility.ToAbsolute(aprop.PropertyContent); ViewBag.ThumbIcon = System.Web.VirtualPathUtility.ToAbsolute(aprop.PropertyContent); } // meta descriptione aprop = new ArtistProperty(); aprop.GetArtistPropertyForTypeArtist(art.ArtistID, SiteEnums.ArtistPropertyType.MD.ToString()); if (!string.IsNullOrEmpty(aprop.PropertyContent)) ViewBag.MetaDescription = aprop.PropertyContent; // description aprop = new ArtistProperty(); aprop.GetArtistPropertyForTypeArtist(art.ArtistID, SiteEnums.ArtistPropertyType.LD.ToString()); if (!string.IsNullOrEmpty(aprop.PropertyContent)) ViewBag.ArtistDescription = ContentLinker.InsertBandLinks(aprop.PropertyContent, false); #region rss ///// rss //RssResources rssrs = new RssResources(); //rssrs.GetArtistRssResource(art.ArtistID); //if (rssrs.Count > 0) //{ // RssItems ritems = new RssItems(); // RssItems ritemsOUT = new RssItems(); // foreach (RssResource rssre in rssrs) // { // ritems.GetTopRssItemsForResource(rssre.RssResourceID); // //ritm = new RssItem(rssre..ArtistID); // } // ritems.Sort((RssItem x, RssItem y) => (y.PubDate.CompareTo(x.PubDate))); // foreach (RssItem ritm in ritems) // { // if (ritemsOUT.Count < 10) // { // ritemsOUT.Add(ritm); // } // } // ViewBag.ArtistNews = ritemsOUT.ToUnorderdList; //} //else //{ // ViewBag.ArtistNews = null; //} //ViewBag.DisplayName = art.DisplayName; #endregion Songs sngss = new Songs(); sngss.GetSongsForArtist(art.ArtistID); SongRecord snrcd = new SongRecord(); foreach (Song sn1 in sngss) { vids.GetVideosForSong(sn1.SongID); } } vids.Sort(delegate(Video p1, Video p2) { return p2.PublishDate.CompareTo(p1.PublishDate); }); foreach (BootBaronLib.AppSpec.DasKlub.BOL.Video v1 in vids) { sngrs.Add(new SongRecord(v1)); } if (mu != null && ua.UserAccountID != Convert.ToInt32(mu.ProviderUserKey)) { UserConnection uc1 = new UserConnection(); uc1.GetUserToUserConnection(ua.UserAccountID, Convert.ToInt32(mu.ProviderUserKey)); if (uc1.UserConnectionID > 0) { switch (uc1.StatusType) { case 'C': if (uc1.IsConfirmed) { model.IsCyberFriend = true; } else { model.IsWatingToBeCyberFriend = true; } break; case 'R': if (uc1.IsConfirmed) { model.IsRealFriend = true; } else { model.IsWatingToBeRealFriend = true; } break; default: model.IsDeniedCyberFriend = true; model.IsDeniedRealFriend = true; break; } } } if (sngrs == null || sngrs.Count == 0 && art.ArtistID == 0 && ua.UserAccountID == 0) { // no longer exists Response.RedirectPermanent("/"); return new EmptyResult(); } //sngrs.Sort((SongRecord x, SongRecord y) => (y.cre.CompareTo(x.CreateDate))); SongRecords sngDisplay = new SongRecords(); Video vidToShow = null; foreach (SongRecord sr1 in sngrs) { vidToShow = new Video(sr1.VideoID); if (vidToShow.IsEnabled) { sngDisplay.Add(sr1); } } model.SongRecords = sngDisplay.VideosList(); return View(model); }
public EmailDefRightsEventsProcess(UserConnection userConnection) : base(userConnection) { }
// This is the event handler for the UserConnection when it receives a full line. // Parse the cammand and parameters and take appropriate action. private void OnLineReceived(UserConnection sender, byte[] data) { //Debug.Log("Received:\r\n"+data); byte[] iobytes = data; //encoding.GetBytes(data); int trigger = 0; if(iobytes.Length>=4){ trigger = Convert.ToInt32(iobytes[160])+(Convert.ToInt32(iobytes[161])*256)+(Convert.ToInt32(iobytes[162])*65536)+(Convert.ToInt32(iobytes[163])*16777216); } if(trigger == lasttrigger) { if(true||loggingenabled) { Debug.Log("Ignored Trigger " + trigger.ToString()); } return; } lasttrigger = trigger; Debug.Log(lasttrigger); BitArray iovals = new System.Collections.BitArray(iobytes); string plc_to_emu_bit_string_bits = ""; string plc_to_emu_bit_string = ""; for(var i=0; i<iobytes.Length;i++) { plc_to_emu_bit_string += iobytes[i].ToString()+ " "; } if(loggingenabled) { Debug.Log("Received:\r\n"+plc_to_emu_bit_string); //Debug.Log("Received bits:\r\n"+plc_to_emu_bit_string_bits); } Loom.QueueOnMainThread(()=>{ sendResponse(sender,IATA_last_bag,lasttrigger); }); }
public override EmbeddedProcess CreateEventsProcess(UserConnection userConnnection) { return (new ProjectFile_ProjectEventsProcess(userConnnection)); }
public void SerializeUserConnections (UserConnection[] conns) { #if !ASTAR_NO_JSON if (conns == null) conns = new UserConnection[0]; var output = GetStringBuilder ();//new System.Text.StringBuilder(); var writer = new JsonWriter (output,writerSettings); writer.Write (conns); var bytes = encoding.GetBytes (output.ToString()); output = null; //If length is <= 2 that means nothing was serialized (file is "[]") if (bytes.Length <= 2) return; AddChecksum (bytes); zip.AddEntry ("connections"+jsonExt,bytes); #endif }
public ProjectFile(UserConnection userConnection) : base(userConnection) { SchemaName = "ProjectFile"; }
// Send a chat message to all clients except sender. private void SendChat(string message, UserConnection sender) { // UpdateStatus(sender.Name + ": " + message); // SendToClients("CHAT|" + sender.Name + ": " + message, sender); }
public ProjectFileEventsProcess(UserConnection userConnection) : base(userConnection) { }
// This subroutine notifies other clients that sender left the chat, and removes // the name from the clients Hashtable private void DisconnectUser(UserConnection sender) { // UpdateStatus(sender.Name + " has left the chat."); // SendToClients("CHAT|" + sender.Name + " has left the chat.", sender); clients.Remove(sender.Name); //lstPlayers.Items.Remove(sender.Name); }
public override EmbeddedProcess CreateEventsProcess(UserConnection userConnection) { return(new ForecastIndicator_CoreForecastEventsProcess(userConnection)); }
/// This is the Excel event handler /// /// private void ExcelOnLineReceived(UserConnection sender, byte[] data) { byte[] responsebytes = GetBytes("s"); byte[] iobytes = new byte[640];//data; for(int i=0;i<1280;i++) { if(i-2*(i/2)==1) { iobytes[i/2] += (byte)(data[i]*16); }else{ iobytes[i/2] = (byte)(data[i]); } } string excel_to_emu_bit_string = ""; for(var i=0; i<iobytes.Length;i++) { if(i==320) { excel_to_emu_bit_string += "\r\n Inputs:"; } excel_to_emu_bit_string += iobytes[i].ToString()+ " "; } Debug.Log("excel override: Outputs:" + excel_to_emu_bit_string + "\r\n Length:"+iobytes.Length.ToString()+"\r\n"); //sender.SendData(responsebytes); //return; //byte[] iobytes = data; byte[] byte_io_enabled = new byte[320]; byte[] byte_iovals = new byte[320]; for(var i=0;i<160;i++) // lower motor output bits { byte_iovals[i] = iobytes[i]; } for(var i=0;i<160;i++) { byte_io_enabled[i] = iobytes[i+160]; } for(var i=0;i<160;i++) // higher photoEye INPUT bits { byte_iovals[i+160] = iobytes[i+320]; } for(var i=0;i<160;i++) { byte_io_enabled[i+160] = iobytes[i+320+160]; } excel_to_emu_bit_string = ""; for(var i=0; i<byte_io_enabled.Length;i++) { excel_to_emu_bit_string += byte_io_enabled[i].ToString()+ " "; } //Debug.Log("byte_io_enabled:" + excel_to_emu_bit_string + "\r\n Length:"+byte_io_enabled.Length.ToString()+"\r\n"); BitArray io_enabled = new System.Collections.BitArray(byte_io_enabled); BitArray iovals = new System.Collections.BitArray(byte_iovals); for(var i=0;i<conveyer.Length;i++) { conveyer_excel_override[i] = (bool)io_enabled[conveyerio[i]]; conveyer_excel_val[i] = (bool)iovals[conveyerio[i]]; } /*for(var i=0;i<conveyer_turn_run.Length;i++) { Debug.Log(i.ToString()+" "+conveyer_turn_run_excel_override.Length.ToString()+" "+conveyer_turn_run_excel_val.Length.ToString()+" "+iovals.Length.ToString()+" "+io_enabled.Length.ToString()+" "+conveyer_turn_run_io[i].ToString()+"\r\n"); }*/ for(var i=0;i<conveyer_turn_run.Length;i++) { conveyer_turn_run_excel_override[i] = (bool)io_enabled[conveyer_turn_run_io[i]]; conveyer_turn_run_excel_val[i] = (bool)iovals[conveyer_turn_run_io[i]]; } for(var i=0;i<conveyer_merge_run.Length;i++) { conveyer_merge_run_excel_override[i] = (bool)io_enabled[conveyer_merge_run_io[i]]; conveyer_merge_run_excel_val[i] = (bool)iovals[conveyer_merge_run_io[i]]; } for(var i=0;i<photoeye.Length;i++) { photoeye_excel_override[i] = (bool)io_enabled[photoeyeIO[i]+(160*8)]; // gets it from shifted input photoeye_excel_val[i] = (bool)iovals[photoeyeIO[i]+(160*8)]; // gets it from shifted input } Loom.QueueOnMainThread(()=>{ for(var i=0;i<conveyer.Length;i++) { conveyer[i].setExcelOverride(conveyer_excel_override[i],conveyer_excel_val[i]); } for(var i=0;i<conveyer_turn_run.Length;i++) { conveyer_turn_run[i].setExcelOverride(conveyer_turn_run_excel_override[i],conveyer_turn_run_excel_val[i]); } for(var i=0;i<conveyer_merge_run.Length;i++) { conveyer_merge_run[i].setExcelOverride(conveyer_merge_run_excel_override[i],conveyer_merge_run_excel_val[i]); } for(var i=0;i<photoeye.Length;i++) { photoeye[i].setExcelOverride(photoeye_excel_override[i],photoeye_excel_val[i]); } }); // byte[] responsebytes = GetBytes("success"); sender.SendData(responsebytes); }
public ForecastIndicator(UserConnection userConnection) : base(userConnection) { SchemaName = "ForecastIndicator"; }
// This subroutine checks to see if username already exists in the clients // Hashtable. if it does, send a REFUSE message, otherwise confirm with a JOIN. private void ConnectUser(string userName, UserConnection sender) { if (clients.Contains(userName)) { ReplyToSender("REFUSE", sender); } else { sender.Name=userName; clients.Add(userName, sender); System.Console.WriteLine("CONNECTED: "+sender.Name); ReplyToSender("JOIN", sender); } }
public ForecastIndicatorEventsProcess(UserConnection userConnection) : base(userConnection) { }
// This is the event handler for the UserConnection when it receives a full line. // Parse the cammand and parameters and take appropriate action. private void OnLineReceived(UserConnection sender, string data) { string[] dataArray; // Message parts are divided by "|" Break the string into an array accordingly. // Basically what happens here is that it is possible to get a flood of data during // the lock where we have combined commands and overflow // to simplify this proble, all I do is split the response by char 13 and then look // at the command, if the command is unknown, I consider it a junk message // and dump it, otherwise I act on it dataArray = data.Split((char) 13); dataArray = dataArray[0].Split((char) 124); //System.Console.WriteLine(dataArray[0]); // dataArray(0) is the command. switch( dataArray[0]) { case "CONNECT": ConnectUser(dataArray[1], sender); break; case "D": DataManager(dataArray[1],dataArray[2]); break; case "DISCONNECT": DisconnectUser(dataArray[1]); break; default: // Message is junk do nothing with it. break; } }
public Lookup(UserConnection userConnection) : base(userConnection) { }
public void Initialize() { var logger = new Mock<ILogger>(); _u = new UserConnection(logger.Object); }
public override EmbeddedProcess CreateEventsProcess(UserConnection userConnnection) { return (new CurrencyRateDetailGridPageEventsProcess(userConnnection)); }
public ActionResult ConfirmContactRequest(string input) { NameValueCollection qury = HttpUtility.ParseQueryString(input); var userToBe = new UserAccount(qury["username"]); var ucToSet = new UserConnection(); if (_mu != null) ucToSet.GetUserToUserConnection(Convert.ToInt32(_mu.ProviderUserKey), userToBe.UserAccountID); if (ucToSet.UserConnectionID == 0 && qury["rslt"] == "0") { // they never set anything up and are ending the request Response.Redirect("~/" + userToBe.UserName); } else if (ucToSet.UserConnectionID != 0 && qury["rslt"] == "0") { if (_mu != null && Convert.ToInt32(_mu.ProviderUserKey) != ucToSet.CreatedByUserID) { // one user sent a request and now it's rejected ucToSet.StatusType = 'L'; ucToSet.UpdatedByUserID = Convert.ToInt32(_mu.ProviderUserKey); ucToSet.IsConfirmed = true; ucToSet.Update(); if (_mu != null) Response.Redirect("/" + _mu.UserName); } else { // this is assumed to be not a declude because it is a reject by the issuer Response.Redirect("/" + userToBe.UserName); } } else if (ucToSet.UserConnectionID == 0 && qury["rslt"] == "1") { // they are not yet connected and are requesting to begin a connection ucToSet.IsConfirmed = false; if (_mu != null) { ucToSet.CreatedByUserID = Convert.ToInt32(_mu.ProviderUserKey); ucToSet.FromUserAccountID = Convert.ToInt32(_mu.ProviderUserKey); } ucToSet.ToUserAccountID = userToBe.UserAccountID; ucToSet.StatusType = Convert.ToChar(qury["contacttype"]); ucToSet.Create(); Response.Redirect("/" + userToBe.UserName); } else if (ucToSet.UserConnectionID > 0 && qury["rslt"] == "1") { // there was a request that is being confirmed if (ucToSet.StatusType == Convert.ToChar(qury["contacttype"])) { ucToSet.IsConfirmed = true; } else { // upgrading the request ucToSet.IsConfirmed = false; if (_mu != null && Convert.ToInt32(_mu.ProviderUserKey) == ucToSet.ToUserAccountID) { // the opposite this time ucToSet.FromUserAccountID = Convert.ToInt32(_mu.ProviderUserKey); ucToSet.ToUserAccountID = userToBe.UserAccountID; } } if (_mu != null) ucToSet.UpdatedByUserID = Convert.ToInt32(_mu.ProviderUserKey); ucToSet.StatusType = Convert.ToChar(qury["contacttype"]); ucToSet.Update(); switch (Convert.ToChar(qury["contacttype"])) { case 'R': if (ucToSet.IsConfirmed) { if (_mu != null) { Response.Redirect("~/account/irlcontacts/" + _mu.UserName); } } else { var requestedUserDetails = new UserAccountDetail(); requestedUserDetails.GetUserAccountDeailForUser(userToBe.UserAccountID); NotifyUserOfContactRequest(userToBe); Response.Redirect("/" + userToBe.UserName); } break; case 'C': if (ucToSet.IsConfirmed) { if (_mu != null) { Response.Redirect("~/account/CyberAssociates/" + _mu.UserName); } } else { NotifyUserOfContactRequest(userToBe); Response.Redirect("~/" + userToBe.UserName); } break; case 'L': if (_mu != null) Response.Redirect("~/" + _mu.UserName); break; } } return View(); }
public override EmbeddedProcess CreateEventsProcess(UserConnection userConnnection) { return (new VwSysAdminUnit_WebitelCollaborationsEventsProcess(userConnnection)); }
public ActionResult ProfileDetail(string userName) { ViewBag.VideoHeight = (Request.Browser.IsMobileDevice) ? 100 : 277; ViewBag.VideoWidth = (Request.Browser.IsMobileDevice) ? 225 : 400; _ua = new UserAccount(userName); var uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(_ua.UserAccountID); uad.BandsSeen = ContentLinker.InsertBandLinks(uad.BandsSeen, false); uad.BandsToSee = ContentLinker.InsertBandLinks(uad.BandsToSee, false); var model = new ProfileModel(); model.ProfilePhotoMainRaw = uad.RawProfilePicUrl; if (_ua.UserAccountID > 0) { model.UserAccountID = _ua.UserAccountID; model.PhotoCount = PhotoItems.GetPhotoItemCountForUser(_ua.UserAccountID); model.CreateDate = _ua.CreateDate; } if (_mu != null) { ViewBag.IsBlocked = BlockedUser.IsBlockedUser(_ua.UserAccountID, Convert.ToInt32(_mu.ProviderUserKey)); ViewBag.IsBlocking = BlockedUser.IsBlockedUser(Convert.ToInt32(_mu.ProviderUserKey), _ua.UserAccountID); if (_ua.UserAccountID == Convert.ToInt32(_mu.ProviderUserKey)) { model.IsViewingSelf = true; } else { var ucon = new UserConnection(); ucon.GetUserToUserConnection(Convert.ToInt32(_mu.ProviderUserKey), _ua.UserAccountID); model.UserConnectionID = ucon.UserConnectionID; if (BlockedUser.IsBlockedUser(Convert.ToInt32(_mu.ProviderUserKey), _ua.UserAccountID)) { return RedirectToAction("index", "home"); } } } else { if (uad.MembersOnlyProfile) { return RedirectToAction("LogOn", "Account"); } } ViewBag.ThumbIcon = uad.FullProfilePicURL; SetModelForUserAccount(model, uad); // var su = new StatusUpdate(); su.GetMostRecentUserStatus(_ua.UserAccountID); if (su.StatusUpdateID > 0) { model.LastStatusUpdate = su.CreateDate; model.MostRecentStatusUpdate = su.Message; } model.ProfileVisitorCount = ProfileLog.GetUniqueProfileVisitorCount(_ua.UserAccountID); GetUserPhotos(model); GetUserNews(model); model.MetaDescription = _ua.UserName + " " + Messages.Profile + " " + FromDate.DateToYYYY_MM_DD(_ua.LastActivityDate); GetUserPlaylist(); ForumThreads(_ua.UserAccountID, model); if (uad.UserAccountID > 0) { model.Birthday = uad.BirthDate; if (uad.ShowOnMapLegal) { // because of the foreign cultures, numbers need to stay in the English version unless a javascript encoding could be added string currentLang = Utilities.GetCurrentLanguageCode(); Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString()); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString()); model.DisplayOnMap = uad.ShowOnMapLegal; var rnd = new Random(); int offset = rnd.Next(10, 100); SiteStructs.LatLong latlong = GeoData.GetLatLongForCountryPostal(uad.Country, uad.PostalCode); if (latlong.latitude != 0 && latlong.longitude != 0) { model.Latitude = Convert.ToDecimal(latlong.latitude + Convert.ToDouble("0.00" + offset)) .ToString(CultureInfo.InvariantCulture); model.Longitude = Convert.ToDecimal(latlong.longitude + Convert.ToDouble("0.00" + offset)) .ToString(CultureInfo.InvariantCulture); } else { model.DisplayOnMap = false; } Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(currentLang); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(currentLang); } ViewBag.ThumbIcon = uad.FullProfilePicThumbURL; LoadCurrentImagesViewBag(uad.UserAccountID); } ViewBag.UserAccountDetail = uad; ViewBag.UserAccount = _ua; GetUserContacts(model); UserAccountDetail uadLooker = null; if (_mu != null) { uadLooker = new UserAccountDetail(); uadLooker.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey)); } if (uadLooker != null && (_mu != null && _ua.UserAccountID > 0 && uadLooker.EnableProfileLogging && uad.EnableProfileLogging)) { var pl = new ProfileLog { LookedAtUserAccountID = _ua.UserAccountID, LookingUserAccountID = Convert.ToInt32(_mu.ProviderUserKey) }; if (pl.LookingUserAccountID != pl.LookedAtUserAccountID) pl.Create(); ArrayList al = ProfileLog.GetRecentProfileViews(_ua.UserAccountID); if (al != null && al.Count > 0) { var uas = new UserAccounts(); foreach (UserAccount viewwer in al.Cast<int>().Select(id => new UserAccount(id)) .Where(viewwer => !viewwer.IsLockedOut && viewwer.IsApproved) .TakeWhile(viewwer => uas.Count < Maxcountusers)) { uas.Add(viewwer); } } } GetUserAccountVideos(); // this is either a youtube user or this is a band var art = new Artist(); art.GetArtistByAltname(userName); if (art.ArtistID > 0) { // try this way for dashers model.UserName = art.Name; } var vids = new Videos(); var sngrs = new SongRecords(); if (art.ArtistID == 0) { vids.GetAllVideosByUser(userName); var uavs = new UserAccountVideos(); uavs.GetRecentUserAccountVideos(_ua.UserAccountID, 'U'); foreach (Video f2 in uavs.Select(uav1 => new Video(uav1.VideoID)).Where(f2 => !vids.Contains(f2))) { vids.Add(f2); } vids.Sort((x, y) => (y.PublishDate.CompareTo(x.PublishDate))); model.UserName = _ua != null ? _ua.UserName : userName; } else { GetArtistProfile(art, vids); } vids.Sort((p1, p2) => p2.PublishDate.CompareTo(p1.PublishDate)); sngrs.AddRange(vids.Select(v1 => new SongRecord(v1))); if (_mu != null && _ua.UserAccountID != Convert.ToInt32(_mu.ProviderUserKey)) { var uc1 = new UserConnection(); uc1.GetUserToUserConnection(_ua.UserAccountID, Convert.ToInt32(_mu.ProviderUserKey)); if (uc1.UserConnectionID > 0) { switch (uc1.StatusType) { case 'C': if (uc1.IsConfirmed) { model.IsCyberFriend = true; } else { model.IsWatingToBeCyberFriend = true; } break; case 'R': if (uc1.IsConfirmed) { model.IsRealFriend = true; } else { model.IsWatingToBeRealFriend = true; } break; default: model.IsDeniedCyberFriend = true; model.IsDeniedRealFriend = true; break; } } } if (sngrs.Count == 0 && art.ArtistID == 0 && _ua.UserAccountID == 0) { // no longer exists Response.RedirectPermanent("/"); return new EmptyResult(); } var sngDisplay = new SongRecords(); sngDisplay.AddRange(from sr1 in sngrs let vidToShow = new Video(sr1.VideoID) where vidToShow.IsEnabled select sr1); model.SongRecords = sngDisplay.VideosList(); return View(model); }
public VwSysAdminUnit_WebitelCollaborations_Terrasoft(UserConnection userConnection) : base(userConnection) { SchemaName = "VwSysAdminUnit_WebitelCollaborations_Terrasoft"; }
public void DrawUserConnections () { UserConnection[] conns = script.astarData.userConnections; if (conns == null) { conns = new UserConnection[0]; } Rect r = new Rect(Screen.width - 180, Screen.height - 300, 168,252); if (editLinks) { //Add a small border around the window + add space for the header Rect r2 = r; r2.yMin -= 30; r2.xMin -= 10; r2.xMax += 10; r2.yMax += 10; Vector2 mouse = Event.current.mousePosition; if (r2.Contains (mouse) && Event.current.type == EventType.Layout) { int controlID = GUIUtility.GetControlID(1024,FocusType.Passive); HandleUtility.AddControl (controlID,0F); } if (Event.current.shift) { Ray ray = HandleUtility.GUIPointToWorldRay (Event.current.mousePosition); GraphNode node = script.GetNearest (ray); if (firstShiftNode != null) { Handles.color = Color.yellow; Handles.SphereCap (GUIUtility.GetControlID (FocusType.Passive),(Vector3)firstShiftNode.position,Quaternion.identity,HandleUtility.GetHandleSize ((Vector3)node.position)*0.12F); } if (node != null) { Handles.color = Color.yellow; Handles.SphereCap (GUIUtility.GetControlID (FocusType.Passive),(Vector3)node.position,Quaternion.identity,HandleUtility.GetHandleSize ((Vector3)node.position)*0.13F); if (firstShiftNode != null) { Handles.DrawLine ((Vector3)firstShiftNode.position,(Vector3)node.position); } if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { if (firstShiftNode == null) { firstShiftNode = node; } else { //Add a connection between 'node' and firstShiftNode selectedUserConnection = CreateNewUserConnection ((Vector3)firstShiftNode.position,(Vector3)node.position); firstShiftNode = null; Event.current.Use (); } } } else { Handles.BeginGUI (); GUI.Box (new Rect (Event.current.mousePosition.x+20,Event.current.mousePosition.y-2,115,18),"No graphs are scanned",helpBox); //GUI.Label (new Rect (Event.current.mousePosition.x+20,Event.current.mousePosition.y-5,150,30),); Handles.EndGUI (); } GUI.changed = true; } else { firstShiftNode = null; } } for (int i=0;i<conns.Length;i++) { UserConnection conn = conns[i]; int controlID = GUIUtility.GetControlID(i, FocusType.Native); if (Event.current.type == EventType.Layout && editLinks) { if (conn.type == ConnectionType.Connection) { HandleUtility.AddControl (controlID,HandleUtility.DistanceToLine (conn.p1,conn.p2)*0.5F); } else { HandleUtility.AddControl (controlID,HandleUtility.DistanceToLine (conn.p1,conn.p1)*0.5F); } } if (selectedUserConnection == i && editLinks) { conn.p1 = Handles.PositionHandle (conn.p1,Quaternion.identity); if (conn.type == ConnectionType.Connection) { conn.p2 = Handles.PositionHandle (conn.p2,Quaternion.identity); } Handles.color = new Color (0.603F,0.95F,0.28F,0.8F); } else { Handles.color = new Color (0.290F, 0.454F, 0.741F, 0.800F); } if (Event.current.type == EventType.MouseDown && editLinks && firstShiftNode == null) { if (HandleUtility.nearestControl == controlID) { selectedUserConnection = i; Event.current.Use (); HandleUtility.Repaint (); } } if (conn.type == ConnectionType.Connection) { if (conn.oneWay) { //Because of nothing... Why not? Vector3 goldenRatio = (conn.p2-conn.p1)*0.618F; Handles.ConeCap (controlID,conn.p1+goldenRatio,Quaternion.LookRotation (goldenRatio),goldenRatio.magnitude*0.07F); Handles.ConeCap (controlID,conn.p2-goldenRatio,Quaternion.LookRotation (goldenRatio),goldenRatio.magnitude*0.07F); Handles.DrawLine (conn.p1,conn.p2); } else { Handles.DrawLine (conn.p1,conn.p2); } if (conn.enable) { //Nice Blue Color Handles.color = new Color (0.290F, 0.454F, 0.741F, 0.600F); } else { //Nice Red Color Handles.color = new Color (0.651F, 0.125F, 0F, 0.6F); } Handles.SphereCap (controlID,conn.p1,Quaternion.identity,HandleUtility.GetHandleSize (conn.p1)*0.1F); Handles.SphereCap (controlID,conn.p2,Quaternion.identity,HandleUtility.GetHandleSize (conn.p2)*0.1F); } else { if (conn.enable) { //Nice Blue Color Handles.color = new Color (0.290F, 0.454F, 0.741F, 0.600F); } else { //Nice Red Color Handles.color = new Color (0.651F, 0.125F, 0F, 0.6F); } Handles.SphereCap (controlID,conn.p1,Quaternion.identity,HandleUtility.GetHandleSize (conn.p1)*0.15F); } } if (Event.current.type == EventType.Layout && linkSettings) { int cID = GUIUtility.GetControlID(654, FocusType.Passive); HandleUtility.AddDefaultControl (cID); } if (editLinks) { Handles.BeginGUI(); //GUILayout.Window (0,r,DrawUserConnectionsWindow,"Connection"); GUILayout.BeginArea (r,"Connection","Window"); DrawUserConnectionsWindow (); GUILayout.EndArea (); if (GUI.Button (new Rect (r.x,r.y,16,16),"",astarSkin.FindStyle ("CloseButton"))) { editLinks = false; Repaint (); } Handles.EndGUI(); } else { Handles.BeginGUI(); if (GUI.Button (new Rect (Screen.width-40,Screen.height-75,30,30),"Show Links",astarSkin.FindStyle ("LinkButton"))) { editLinks = true; Repaint (); GUI.changed = true; } Handles.EndGUI(); } //Debug.Log("id: " + GUIUtility.hotControl+" "+GUIUtility.keyboardControl+ " "+Event.current.GetTypeForControl (GUIUtility.hotControl) +" Name : "+GUI.GetNameOfFocusedControl ()); /*if (Event.current.type == EventType.MouseDown) { if (HandleUtility.nearestControl > 0 && HandleUtility.nearestControl <= conns.Length && selectedUserConnection != HandleUtility.nearestControl-1) { selectedUserConnection = HandleUtility.nearestControl-1; HandleUtility.nearestControl = 0; HandleUtility.Repaint (); //return; } }*/ }
public UnitForCalculation(UserConnection userConnection) : base(userConnection) { }
/** Creates a link between start and end. \see \link Pathfinding.AstarData.userConnections AstarData.userConnections \endlink */ public int CreateNewUserConnection (Vector3 start, Vector3 end) { UserConnection[] conns = script.astarData.userConnections; if ( conns == null ) conns = new UserConnection[0]; List<UserConnection> connList = new List<UserConnection>(conns); UserConnection conn = new UserConnection (); conn.p1 = start; conn.p2 = end; connList.Add (conn); script.astarData.userConnections = connList.ToArray (); return script.astarData.userConnections.Length-1; }
public override EmbeddedProcess CreateEventsProcess(UserConnection userConnnection) { return (new FileLead_LeadEventsProcess(userConnnection)); }
public ActionResult BlockedUser(int userAccountID) { mu = Membership.GetUser(); BootBaronLib.AppSpec.DasKlub.BOL.BlockedUser bu = new BlockedUser(); ucon = new UserConnection(); ucon.GetUserToUserConnection(userAccountID, Convert.ToInt32(mu.ProviderUserKey)); ucon.Delete(); bu.UserAccountIDBlocked = userAccountID; bu.UserAccountIDBlocking = Convert.ToInt32(mu.ProviderUserKey); bu.Create(); return RedirectToAction("Visitors"); }
public FileLead_Lead_Terrasoft(UserConnection userConnection) : base(userConnection) { SchemaName = "FileLead_Lead_Terrasoft"; }
public ActionResult DeleteContact(int userConnectionID) { mu = Membership.GetUser(); ucon = new UserConnection(userConnectionID); char conType = ucon.StatusType; if (ucon.IsConfirmed) { ucon.Delete(); } if (conType == 'R') { return RedirectToAction("irlcontacts"); } else if (conType == 'C') { return RedirectToAction("CyberAssociates"); } else { Utilities.LogError("deleted no existing contact type"); // something went wrong return new EmptyResult(); } }
public EmployeeTag(UserConnection userConnection) : base(userConnection) { }