public client client_insert()
 {
     client.client_status = Insert_client_status_txt.Text;
     client.ethnicity = Insert_ethnicity_txt.Text;
     client.eye_color = Insert_eye_color_txt.Text;
     client = client.Insert(client);
     Insert_Client_GridView.DataBind();
     return client;
 }
Example #2
0
 // Use this for initialization
 void Start()
 {
     IPAddress = "127.0.0.1";
     stringPort = "9090";
     port = 9090;
     mode = NOTCONNECTED;
     GameObject obj = GameObject.Find ("client");
     c = obj.GetComponent<client> ();
 }
        public client Insert_client_select(int ID)
        {
            client = client.Select(ID);
            Insert_client_id_txt.Text = Convert.ToString(client.client_id);
            Insert_client_status_txt.Text = Convert.ToString(client.client_status);
            Insert_ethnicity_txt.Text = Convert.ToString(client.ethnicity);
            Insert_eye_color_txt.Text = Convert.ToString(client.eye_color);

            return client;
        }
Example #4
0
    public static void Main()
    {
        TcpListener server=null;
        try
        {
            IPHostEntry iph = Dns.GetHostEntry(Dns.GetHostName());
            server = new TcpListener(iph.AddressList[1], 13000);
            server.Start();

            Console.WriteLine("Server Started at {0}",iph.AddressList[1]);

                while (true)
                {
                    TcpClient Client = server.AcceptTcpClient();
                    client cl = new client();
                    IPEndPoint IPend = (IPEndPoint)Client.Client.RemoteEndPoint;
                    cl.ip = IPend.Address.ToString();

                    StreamReader sr = new StreamReader(Client.GetStream());
                    char[] data = new char[20];
                    sr.Read(data, 0, data.Length);
                    cl.name = new string(data);
                    cl.name=cl.name.Substring(0,cl.name.IndexOf('\0'));

                  Console.WriteLine(cl.name+" "+cl.ip);

                      StreamWriter sw = new StreamWriter(Client.GetStream());
                      sw.AutoFlush = true;
                      StringBuilder names = new StringBuilder();
                      StringBuilder ips = new StringBuilder();
                      foreach (client c in clients)
                      {
                          names.Append(c.name + "*");
                          ips.Append(c.ip + "*");
                      }

                      string write = names + "&" + ips;
                      if (clients.Count == 0)
                          write = "No One Available*&";
                      sw.Write(write.ToCharArray());
                      clients.Add(cl);
           }
        }

        catch (SocketException e)
        {
            Console.WriteLine("SocketException: {0}", e);
            Console.Read();
        }
        finally
        {
           server.Stop();
        }
    }
 public client client_update(int ID)
 {
     client = client.Select(ID);
     client.client_id = Convert.ToInt32(Update_client_id_txt.Text);
     client.client_status = Update_client_status_txt.Text;
     client.ethnicity = Update_ethnicity_txt.Text;
     client.eye_color = Update_eye_color_txt.Text;
     client.Update(client);
     Update_Client_GridView.DataBind();
     return client;
 }
        static void Main(string[] args)
        {
            //FactoryClient clnt = new FactoryClient();
            //clnt.Process();
            //Console.Read();

            //LinqClient clnt = new LinqClient();

            //DataStructure
            //NodeClient clnt = new NodeClient();
            //            clnt.Process();
            //OOP Test
            client clnt = new client();
            clnt.Process();
            Console.ReadLine();
        }
Example #7
0
    public static client create(string _email, string _password)
    {
        client cli = new client
        {
            email = _email,
            password = _password,
            is_admin = false
        };

        if (validateClient(cli))
        {
            db.clients.InsertOnSubmit(cli);
            db.SubmitChanges();
            return cli;
        }

        return null;
    }
 public ClientViewModel()
 {
     _client = new client {BirthDate = DateTime.Today};
     RegistrNewClientCommand = new RelayCommand(arg =>
     {
         if ((string.IsNullOrEmpty(Client.Email) && !string.IsNullOrEmpty(Client.Password)) ||
             (!string.IsNullOrEmpty(Client.Email) && string.IsNullOrEmpty(Client.Password)))
         {
             MessageBox.Show("Пожалуйста укажите пароль и Email", "Неверно заполненны поля",
                 MessageBoxButton.OK, MessageBoxImage.Warning);
         }
         else
         {
             if (SaveClient())
                 OnRegistration();
         }
     });
     AddNewDocumentICommand = new RelayCommand(act =>
     {
         var newWindow = new CreateNewDocumentWindow(true);
         newWindow.Show();
         newWindow.ViewModel.RegistrationDocumentIEvent += ViewModel_RegistrationDocumentIEvent;
         newWindow.Closed += NewWindow_Closed;
     });
     AddNewDocumentMCommand = new RelayCommand(act =>
     {
         var newWindow = new CreateNewDocumentWindow(false);
         newWindow.Show();
         newWindow.ViewModel.RegistrationDocumentMEvent += ViewModel_RegistrationDocumentMEvent;
         newWindow.Closed += NewWindow_Closed;
     });
     AutoGeneratePassword = new RelayCommand(arg =>
     {
         Client.Password = ProjectSettings.GenerateKey();
         OnPropertyChanged("Client");
     });
 }
Example #9
0
 AuditLogType.MembersDisconnected => new RestMembersDisconnectedAuditLog(client, log, entry),
Example #10
0
 /// <summary>
 /// 关闭套接字
 /// </summary>
 /// <param name="socket">套接字</param>
 private static void dispose(client socket)
 {
     socket.Socket.shutdown();
 }
Example #11
0
 AuditLogType.MemberRolesUpdated => new RestMemberRolesUpdatedAuditLog(client, log, entry),
    register (client c)
	{
	    client_list.add (c)
	}
        //INSERT
        protected void insert_Click(object sender, EventArgs e)
        {
            try
            {
                address = address_insert();
                person = person_insert();
                client = client_insert();
                missing = missing_insert();

                if (Insert_deceasedYes.Checked == true)
                {
                    deceased = deceased_insert();
                }
                case_intake = case_intake_insert();
                case_client = case_client_insert();
                encounter = encounter_insert();
            }
            catch { Insert_lbl_Client_Error.Text = "There has been an error updating information for the missing client."; }
            finally { Insert_lbl_Client_Error.Text = "The missing client's information has been successfully updated."; }
        }
Example #14
0
 ActivityType.Custom => new TransientCustomActivity(client, model),
Example #15
0
 ActivityType.Listening when model.Id != null && model.Id.StartsWith("spotify:") => new TransientSpotifyActivity(client, model),
Example #16
0
 ["c"] = ("Create Key", async(email, product) => await CreateKeyAsync(client, product, email))
Example #17
0
 RequestAppInfoAsync(client, i);
Example #18
0
 get => new RedisClientSortedSet(client, setId);
Example #19
0
 ["q"] = ("Query", async(email, product) => await QueryKeyAsync(client, product, email)),
Example #20
0
 internal IEnumerable donemContactes(client clientSeleccionat)
 {
     return(tContacte.getByClient(clientSeleccionat));
 }
Example #21
0
 public EditClient(client client)
 {
     InitializeComponent();
     this.DataContext = new EditclientVievModel(client);
 }
Example #22
0
    public static void Main()
    {
        ReaderWriter rwlock = new ReaderWriter();

        for(int i = 0; i<5; i++) {
          client w = new client(i,rwlock);
        }

        Console.ReadLine();
    }
        protected void Save_Client_information()
        {
            decimal[] add1cord = new decimal[2];
            decimal[] add2cord = new decimal[2];

            clientperson.SetColumnDefaults();
            clientAddress.SetColumnDefaults();
            clientAddress2.SetColumnDefaults();
            client.SetColumnDefaults();

            clientperson.person_id = GlobalVariables.PersonID;
            clientperson.address_id = GlobalVariables.ClientAddressID;
            clientperson.address_id2 = GlobalVariables.ClientAddressID2;
            clientAddress.address_id = GlobalVariables.ClientAddressID;
            clientAddress2.address_id = GlobalVariables.ClientAddressID2;

            client.client_id = GlobalVariables.ClientID;
            client.Info_Field = null;

            clientperson.f_name = txt_F_Name.Text;
            clientperson.l_name = txt_L_Name.Text;
            clientperson.person_type = "C";
            clientperson.m_initial = txt_M_Initial.Text;
            clientperson.Maiden_Name = txt_Maiden_Name.Text;
            clientperson.gender = ddl_Gender.SelectedValue;
            clientperson.email = txt_email.Text;
            if (txt_SSN.Text != "")
            {
                clientperson.ssn = Convert.ToInt32(txt_SSN.Text);
            }
            clientperson.Driver_State_ID = txt_DrvLic.Text;
            if (txt_Birthdate.Text != "")
            {
                clientperson.birthdate = Convert.ToDateTime(txt_Birthdate.Text);
            }
            clientperson.phone_primary = txt_Phone_Primary.Text;
            clientperson.phone_secondary = txt_Phone_Secondary.Text;
            clientperson.Marital_Status = ddl_Marital_Status.SelectedValue.ToString();
            clientperson.Citizenship = ddl_CitizenShip.SelectedValue.ToString();
            Set_Visa_Type();
            if (TxtVisaIssDate.Text != "")
            {
                clientperson.Visa_Issue_Date = Convert.ToDateTime(TxtVisaIssDate.Text.ToString());
            }
            if (TxtVisaExpDate.Text != "")
            {
                clientperson.Visa_Expire_Date = Convert.ToDateTime(TxtVisaExpDate.Text.ToString());
            }
            if (TxtUSCISNum.Text != "")
            {
                clientperson.Perm_Resident_Alien_USCIS_number = Convert.ToInt32(TxtUSCISNum.Text);
            }
            if (TxtANumber.Text != "")
            {
                clientperson.Perm_Resident_Alien_A_number = Convert.ToInt32(TxtANumber.Text);
            }
            if (TxtresDate.Text != "")
            {
                clientperson.Perm_Resident_Alien_Resid_Date = Convert.ToDateTime(TxtresDate.Text);
            }
            if (TxtResExpDate.Text != "")
            {
                clientperson.Perm_Resident_Alien_Expire_Date = Convert.ToDateTime(TxtResExpDate.Text);
            }
            clientperson.Perm_Resident_Alien_Birth_Country = TxtCountryOfBirth.Text;
            clientperson.Perm_Resident_Alien_Category = TxtCategory.Text;

            clientAddress.address_type_id = 2;
            clientAddress.str_add = txtCurr_str_addr.Text;
            clientAddress.str_add2 = TxtCurr_str_addr2.Text;
            clientAddress.city = txtCurr_city.Text;
            clientAddress.state = ddlCurr_st.SelectedValue;
            clientAddress.zip_plus_four = txtCurr_zip.Text;
            clientAddress.country = TxtCurr_Country.Text;
            clientAddress.County_Township = TxtCurr_CountyTownship.Text;

            add1cord = GeoLocation.getCoordinates(clientAddress.str_add, clientAddress.str_add2, clientAddress.city, clientAddress.state, clientAddress.zip_plus_four, "DMCS");

            clientAddress.latitude = add1cord[0];
            clientAddress.longitude = add1cord[1];

            client.client_status = ddl_client_status.SelectedValue;

            if (clientAddress.address_id == 0)
            {
                clientAddress = clientAddress.Insert(clientAddress);
                clientperson.address_id = clientAddress.address_id;
            }
            else
            {
                clientAddress.Update(clientAddress);
            }

            if (txtPrev_city.Text != "" && TxtPrev_Country.Text != "" &&
               ddlPrev_st.SelectedValue != "" && txtPrev_str_addr.Text != "")
            {
                clientAddress2.address_type_id = 3;
                clientAddress2.str_add = txtPrev_str_addr.Text;
                clientAddress2.str_add2 = txtPrev_str_addr2.Text;
                clientAddress2.city = txtPrev_city.Text;
                clientAddress2.state = ddlPrev_st.SelectedValue;
                clientAddress2.zip_plus_four = txtPrev_zip.Text;
                clientAddress2.str_add2 = txtPrev_str_addr2.Text;
                clientAddress2.country = TxtPrev_Country.Text;
                clientAddress2.County_Township = TxtPrev_countyTownship.Text;

                add2cord = GeoLocation.getCoordinates(clientAddress2.str_add, clientAddress2.str_add2, clientAddress2.city, clientAddress2.state, clientAddress2.zip_plus_four, "DMCS");

                clientAddress2.latitude = add2cord[0];
                clientAddress2.longitude = add2cord[1];

                if (clientAddress2.address_id == 0)
                {
                    clientAddress2 = clientAddress2.Insert(clientAddress2);
                    clientperson.address_id2 = clientAddress2.address_id;
                }
                else
                {
                    clientAddress2.Update(clientAddress2);
                }

            }

            if (clientperson.person_id == 0)
            {
                clientperson = clientperson.Insert(clientperson);
            }
            else
            {
                clientperson.Update(clientperson);
            }

            if (client.client_id == 0)
            {
                client.client_id = clientperson.person_id;
                client = client.Insert(client);
            }
            else
            {
                client.Update(client);
            }
        }
Example #24
0
        public void OnDataReceived(IAsyncResult asyn)
        {
            try
            {
                SocketPacket theSockId = (SocketPacket)asyn.AsyncState;
                int iRx = theSockId.m_currentSocket.EndReceive(asyn);
                char[] chars = new char[iRx + 1];
                System.Text.Decoder d = System.Text.Encoding.Default.GetDecoder();
                int charLen = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
                System.String szData = new System.String(chars);

                string incoming = szData.Substring(0, szData.Length - 1);

                if (incoming.StartsWith("/chg"))
                {
            #if _SHOWMSG
                    MessageBox.Show("Mode Change Code recieved");
            #endif

                    string mode = incoming.Substring(4, 1);
                    cryptor.rijn.Mode = (CipherMode)Convert.ToInt32(mode);
                    tb_currentMode.Text = cryptor.rijn.Mode.ToString();

                }
                else if (incoming.StartsWith("/sIV"))
                {
            #if _SHOWMSG
                    MessageBox.Show("New IV recieved");
            #endif

                    string iv = incoming.Substring(4);
                    cryptor.rijn.IV = ToByteArray(iv);
                    tb_IV.Text = BytesToHex(cryptor.rijn.IV);
                }
                else if (incoming.StartsWith("/rsaS"))
                {
            #if _SHOWMSG
                    MessageBox.Show("RSA public key received");
            #endif

                    string rsaKey = incoming.Substring(5);

                    rsaserver = new RSACryptoServiceProvider(2048);
                    rsaserver.FromXmlString(rsaKey);

                    RSAParameters rsap = rsaserver.ExportParameters(false);

                    tb_RsaPublicKey.Text = BytesToHex(rsap.Modulus);
                    tb_RsaPublicKeyExpo.Text = BytesToHex(rsap.Exponent);

                    // do not need begin
                    cryptor.rijn.GenerateKey();
                    tb_aesKey.Text = BytesToHex(cryptor.rijn.Key);
                    byte[] rsaEncData = rsaserver.Encrypt(cryptor.rijn.Key, true);
                    string encKeyHex = BytesToHex(rsaEncData).Replace(" ", "");
                    tb_encKey.Text = encKeyHex;
                    //do not need end

                    string newKeyMsg = "/rsaC" + GetIP() + " " + myport + " " + rsa.ToXmlString(false);

                    try
                    {

                        Object objData = newKeyMsg;
                        byte[] byData = System.Text.Encoding.ASCII.GetBytes(objData.ToString());
                        if (m_clientSocket != null)
                        {

                            m_clientSocket.Send(byData);

                        }
                    }
                    catch (SocketException se)
                    {
                        MessageBox.Show(se.Message);
                    }

                }
                else if (incoming.StartsWith("/tck"))
                {
                    //recieved tickets

                    //receive tickets and import them to a arraylist.
                    mytickets tickets = new mytickets();
                    List<client> clientlist = new List<client>();

                    tickets.DecodeFromString(incoming.Substring(4));
                    int dest_count = tickets.GetClientCount();
                    for (int i = 0; i < dest_count; i++)
                    {
                        if ((!rsaserver.VerifyData(tickets.ticketlist[i].origFirst, new SHA1CryptoServiceProvider(), tickets.ticketlist[i].signFirst))
                            || (!rsaserver.VerifyData(tickets.ticketlist[i].origSecond, new SHA1CryptoServiceProvider(), tickets.ticketlist[i].signSecond)))
                        {
                            MessageBox.Show("AS is not authentic!");

                        }
                        else
                        {
                            ASCIIEncoding ByteConverter = new ASCIIEncoding();
                            string originalData = ByteConverter.GetString(tickets.ticketlist[i].origFirst);
                            string[] origfields = originalData.Split(' ');

                            if (!rsa.ToXmlString(false).Equals(origfields[2]))
                            {
                                MessageBox.Show("This ticket is not mine!");
                            }
                            else
                            {
                                string destData = ByteConverter.GetString(tickets.ticketlist[i].origSecond);
                                string[] destfields = destData.Split(' ');
                                client tempclient = new client();
                                tempclient.ip = destfields[0];
                                tempclient.port = destfields[1];
                                tempclient.publicKey = destfields[2];
                                tempclient.ticket = tickets.ExportSingleTicket(i);
                                clientlist.Add(tempclient);
                            }

                        }

                    }

                    int numParts = dest_count - 1; //because the final part is the parity

                    int lengthofEachPart = (int)(data.Length / numParts) + 1;//pad the last one

                    //hash = BitConverter.ToString(cryptoTransformSHA1.ComputeHash()).Replace("-", "");

                    List<byte[]> parts = new List<byte[]>();
                    for (int i = 0; i < numParts; i++)
                    {
                        byte[] temp = new byte[lengthofEachPart];

                        for (int j = 0; j < lengthofEachPart; j++)
                        {
                            if (i == numParts - 1 && i * lengthofEachPart + j >= data.Length) //padding
                            {
                                temp[j] = 0x00000000;
                            }
                            else
                            {
                                temp[j] = data[i * lengthofEachPart + j];
                            }
                        }

                        parts.Add(temp);
                    }

                    //we have the parts, calculate the parity part
                    byte[] parityPart = new byte[lengthofEachPart];

                    for (int j = 0; j < lengthofEachPart; j++)
                    {
                        byte xor = new byte();
                        xor = 0 ^ 0;
                        for (int i = 0; i < numParts; i++)
                        {
                            byte[] temp = (byte[])parts[i];
                            xor ^= temp[j];
                        }
                        parityPart[j] = xor;
                    }

                    parts.Add(parityPart);

                    //encrypt all parts with per file key
                    Random rand = new Random();
                    long randomNumToGenerateKey = rand.Next() % 25000;

                    byte[] randomNumToGenerateKeyByteEquivalent = new ASCIIEncoding().GetBytes(randomNumToGenerateKey.ToString());
                    perFileKey = cryptoTransformSHA1.ComputeHash(randomNumToGenerateKeyByteEquivalent);

                    byte[] reducedperfilekey = new byte[16];
                    for (int k = 0; k < 16; k++)
                    {
                        reducedperfilekey[k] = perFileKey[k];
                    }
                    cryptor.rijn.Key = reducedperfilekey;
                    for (int i = 0; i < numParts+1; i++)
                    {
                        string tempPart = cryptor.EncryptMessage(BytesToHex(parts[i]).Replace(" ", ""));
                        parts[i] = new ASCIIEncoding().GetBytes(tempPart);
                    }

                    //create the key and, secret share it with (n-1,n) threshold scheme.

                    ShamirSS sham = new ShamirSS((uint)parts.Count, (uint)parts.Count - 1, 25000);//burasý oldu lakin, reconstruct etmek c*k zor. GF(2^8) kullanmak lazým en azýndan

                    SharedData[] shamirOut = sham.ShareData(randomNumToGenerateKey);
                    //connect to each ticket granted user to send its assigned part
                    //out of scope

                    // TODO ticketlarý gönder herkese
                    //rsapeer = new RSACryptoServiceProvider(2048);
                    for (int i = 0; i < dest_count; i++)
                    {
                        try
                        {
                            UpdateControls(false);
                            // Create the socket instance
                            m_peerSockets[m_peerCount] = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                            // Cet the remote IP address
                            IPAddress ip = IPAddress.Parse(clientlist[i].ip);
                            int iPortNo = System.Convert.ToInt16(clientlist[i].port);
                            // Create the end point
                            IPEndPoint ipEnd = new IPEndPoint(ip, iPortNo);
                            // Connect to the remote host
                            m_peerSockets[m_peerCount].Connect(ipEnd);
                            if (m_peerSockets[m_peerCount].Connected)
                            {

                                UpdateControls(true);
                                //Wait for data asynchronously
                                WaitForPeerData(m_peerSockets[m_peerCount]);//????
                                m_peerCount++;

                            }
                        }
                        catch (SocketException se)
                        {
                            string str;
                            str = "\nConnection failed, is the peer online?\n" + se.Message;
                            MessageBox.Show(str);
                            UpdateControls(false);
                        }
                        if (m_peerSockets[m_peerCount - 1].Connected)
                        {
                            try
                            {
                                string functionID = "/req";

                                string request = functionID + clientlist[i].ticket;

                                //Object objData = request;

                                byte[] byData = System.Text.Encoding.ASCII.GetBytes(request);

                                if (m_peerSockets[m_peerCount - 1] != null)
                                {

                                    m_peerSockets[m_peerCount - 1].Send(byData);
                                }
                            }
                            catch (SocketException se)
                            {
                                MessageBox.Show(se.Message);
                            }
                        }
                        else
                            MessageBox.Show("shit load");

                        // TODO: Ks yarat encrypt et yolla
                        cryptor.rijn.GenerateKey();
                        client temp = new client();
                        temp = clientlist[i];
                        temp.sessionkey = cryptor.rijn.Key;
                        clientlist[i] = temp;
                        tb_aesKey.Text = BytesToHex(cryptor.rijn.Key);
                        rsapeer.FromXmlString(clientlist[i].publicKey);
                        byte[] rsaEncData = rsapeer.Encrypt(cryptor.rijn.Key, true);
                        byte[] rsaSigned;
                        rsaSigned = rsa.SignData(rsaEncData, new SHA1CryptoServiceProvider());
                        string rsaSignedEncHex = BytesToHex(rsaEncData).Replace(" ", "") + " " + BytesToHex(rsaSigned).Replace(" ", "");
                        tb_encKey.Text = rsaSignedEncHex;
                        try
                        {
                            string functionID = "/key";

                            string request = functionID + rsaSignedEncHex;

                            //Object objData = request;

                            byte[] byData = System.Text.Encoding.ASCII.GetBytes(request);

                            if (m_peerSockets[m_peerCount - 1] != null)
                            {

                                m_peerSockets[m_peerCount - 1].Send(byData);
                            }
                        }
                        catch (SocketException se)
                        {
                            MessageBox.Show(se.Message);
                        }

                        System.Threading.Thread.Sleep(50);
                        try
                        {
                            MessageBox.Show("sending file parts");
                            string functionID = "/file";

                            string filepart = hash + " " + data.Length.ToString() + " " + BytesToHex(parts[i]).Replace(" ", "");
                            filepart += " " + shamirOut[i].xi.ToString() + " " + shamirOut[i].yi.ToString();

                            string filemsg = cryptor.EncryptMessage(filepart);

                            string request = functionID + filemsg;

                            //Object objData = request;

                            byte[] byData = System.Text.Encoding.ASCII.GetBytes(request);

                            if (m_peerSockets[m_peerCount - 1] != null)
                            {

                                m_peerSockets[m_peerCount - 1].Send(byData);
                            }
                        }
                        catch (SocketException se)
                        {
                            MessageBox.Show(se.Message);
                        }

                    }

                }
                else if (incoming.StartsWith("/rectck"))
                {
                    //recieved tickets

                    //receive tickets and import them to a arraylist.
                    mytickets tickets = new mytickets();
                    List<client> clientlist = new List<client>();

                    tickets.DecodeFromString(incoming.Substring(7));
                    int dest_count = tickets.GetClientCount();
                    enoughParts = dest_count;
                    for (int i = 0; i < dest_count; i++)
                    {
                        if ((!rsaserver.VerifyData(tickets.ticketlist[i].origFirst, new SHA1CryptoServiceProvider(), tickets.ticketlist[i].signFirst))
                            || (!rsaserver.VerifyData(tickets.ticketlist[i].origSecond, new SHA1CryptoServiceProvider(), tickets.ticketlist[i].signSecond)))
                        {
                            MessageBox.Show("AS is not authentic!");

                        }
                        else
                        {
                            ASCIIEncoding ByteConverter = new ASCIIEncoding();
                            string originalData = ByteConverter.GetString(tickets.ticketlist[i].origFirst);
                            string[] origfields = originalData.Split(' ');

                            if (!rsa.ToXmlString(false).Equals(origfields[2]))
                            {
                                MessageBox.Show("This ticket is not mine!");
                            }
                            else
                            {
                                string destData = ByteConverter.GetString(tickets.ticketlist[i].origSecond);
                                string[] destfields = destData.Split(' ');
                                client tempclient = new client();
                                tempclient.ip = destfields[0];
                                tempclient.port = destfields[1];
                                tempclient.publicKey = destfields[2];
                                tempclient.ticket = tickets.ExportSingleTicket(i);
                                clientlist.Add(tempclient);
                            }

                        }

                    }

                    //partsFromOthers = new List<byte[]>();
                    for (int i = 0; i < clientlist.Count; i++)
                    {
                        //send tickets
                        //generate and send key
                        //send me the file
                        // TODO ticketlarý gönder herkese
                        try
                        {
                            UpdateControls(false);
                            // Create the socket instance
                            m_peerSockets[m_peerCount] = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                            // Cet the remote IP address
                            IPAddress ip = IPAddress.Parse(clientlist[i].ip);
                            int iPortNo = System.Convert.ToInt16(clientlist[i].port);
                            // Create the end point
                            IPEndPoint ipEnd = new IPEndPoint(ip, iPortNo);
                            // Connect to the remote host
                            m_peerSockets[m_peerCount].Connect(ipEnd);
                            if (m_peerSockets[m_peerCount].Connected)
                            {

                                UpdateControls(true);
                                //Wait for data asynchronously
                                WaitForPeerData(m_peerSockets[m_peerCount]);//????
                                m_peerCount++;

                            }
                        }
                        catch (SocketException se)
                        {
                            string str;
                            str = "\nConnection failed, is the peer online?\n" + se.Message;
                            MessageBox.Show(str);
                            UpdateControls(false);
                        }
                        if (m_peerSockets[m_peerCount - 1].Connected)
                        {
                            try
                            {
                                string functionID = "/sndreq";

                                string request = functionID + clientlist[i].ticket + " " + hash;

                                //Object objData = request;

                                byte[] byData = System.Text.Encoding.ASCII.GetBytes(request);

                                if (m_peerSockets[m_peerCount - 1] != null)
                                {

                                    m_peerSockets[m_peerCount - 1].Send(byData);
                                }
                            }
                            catch (SocketException se)
                            {
                                MessageBox.Show(se.Message);
                            }
                        }
                        else
                            MessageBox.Show("shit load");

                    }

                }

                else
                {
                    //decrypt message
                    tb_encRecv.Enabled = true;
                    tb_encRecv.Text = BytesToHex(Convert.FromBase64String(szData.Substring(0, szData.Length - 1)));
                    string decryptedText = cryptor.DecryptMessage(szData.Substring(0, szData.Length - 1));
                    richTextRxMessage.Text = decryptedText + "\n" + richTextRxMessage.Text;
                }

                WaitForData();
            }
            catch (ObjectDisposedException)
            {
                System.Diagnostics.Debugger.Log(0, "1", "\nOnDataReceived: Socket has been closed\n");
            }
            catch (SocketException se)
            {
                MessageBox.Show(se.Message);
            }
        }
Example #25
0
        /*
        =============================================================================

        DYNAMIC LIGHTS

        =============================================================================
        */
        /*
        =============
        R_MarkLights
        =============
        */
        static void R_MarkLights(client.dlight_t light, int bit, model.node_or_leaf_t _node)
        {
            model.mplane_t      splitplane;
            double              dist;
            model.msurface_t    surf;
            int                 i;

            if (_node.contents < 0)
                return;

            model.mnode_t node = (model.mnode_t)_node;
            splitplane = node.plane;
            dist = mathlib.DotProduct(light.origin, splitplane.normal) - splitplane.dist;

            if (dist > light.radius)
            {
                R_MarkLights(light, bit, node.children[0]);
                return;
            }
            if (dist < -light.radius)
            {
                R_MarkLights(light, bit, node.children[1]);
                return;
            }

            // mark the polygons
            for (i = 0; i < node.numsurfaces; i++)
            {
                surf = client.cl.worldmodel.surfaces[node.firstsurface + i];
                if (surf.dlightframe != r_dlightframecount)
                {
                    surf.dlightbits = 0;
                    surf.dlightframe = r_dlightframecount;
                }
                surf.dlightbits |= bit;
            }

            R_MarkLights(light, bit, node.children[0]);
            R_MarkLights(light, bit, node.children[1]);
        }
Example #26
0
        public void OnPeerDataReceived(IAsyncResult asyn)
        {
            try
            {
                SocketPacket socketData = (SocketPacket)asyn.AsyncState;

                int iRx = 0;
                // Complete the BeginReceive() asynchronous call by EndReceive() method
                // which will return the number of characters written to the stream
                // by the client
                iRx = socketData.m_currentSocket.EndReceive(asyn);
                char[] chars = new char[iRx + 1];
                System.Text.Decoder d = System.Text.Encoding.Default.GetDecoder();
                int charLen = d.GetChars(socketData.dataBuffer,
                                         0, iRx, chars, 0);
                System.String szData = new System.String(chars);

                string incoming = szData.Substring(0, szData.Length - 1);

                if (incoming.StartsWith("/file"))
                {
                    MessageBox.Show("receiving file");
                    //recieved file
                    //file infile = new file();

                    string infilemsg = incoming.Substring(5);
                    cryptor.rijn.Key = senderClient.sessionkey;
                    string infilepart = cryptor.DecryptMessage(infilemsg);
                    string[] infilefields = infilepart.Split(' ');
                    //infile.fileid = infilefields[0];
                    //infile.filesize = infilefields[1];
                    string concat = infilefields[2]+" "+infilefields[3]+" "+infilefields[4];
                    byte[] bytefile = System.Text.Encoding.ASCII.GetBytes(concat);
                    //infile.filedata = bytefile;

                    string filename = infilefields[0];
                    //infile.filename = filename;

                    //filelist.Add(infile);
                    FileStream fStream = new FileStream(filename, FileMode.CreateNew);

                    BinaryWriter bw = new BinaryWriter(fStream);

                    bw.Write(bytefile);

                    bw.Close();

                    fStream.Close();

                }
                else if (incoming.StartsWith("/req"))
                {
                    //MessageBox.Show("Give me a halelujah");
                    //recieved share request

                    //receive tickets and import them to a arraylist.
                    mytickets tickets = new mytickets();

                    //List<client> clientlist = new List<client>();

                    tickets.DecodeFromString(incoming.Substring(4));

                    if ((!rsaserver.VerifyData(tickets.ticketlist[0].origFirst, new SHA1CryptoServiceProvider(), tickets.ticketlist[0].signFirst))
                            || (!rsaserver.VerifyData(tickets.ticketlist[0].origSecond, new SHA1CryptoServiceProvider(), tickets.ticketlist[0].signSecond)))
                    {
                        MessageBox.Show("AS is not authentic!");

                    }
                    else
                    {
                        ASCIIEncoding ByteConverter = new ASCIIEncoding();
                        string originalData = ByteConverter.GetString(tickets.ticketlist[0].origSecond);
                        string[] origfields = originalData.Split(' ');

                        if (!rsa.ToXmlString(false).Equals(origfields[2]))
                        {
                            MessageBox.Show("This ticket is not mine!");
                        }
                        else
                        {
                            string destData = ByteConverter.GetString(tickets.ticketlist[0].origFirst);
                            string[] destfields = destData.Split(' ');
                            senderClient = new client();
                            senderClient.ip = destfields[0];
                            senderClient.port = destfields[1];
                            senderClient.publicKey = destfields[2];
                            senderClient.ticket = incoming.Substring(4);
                            //WaitForPeerData(); // gerek var mý ?

                        }

                    }

                }
                else if (incoming.StartsWith("/key"))
                {
                    //recieved shared key

                    string[] KeyFields = incoming.Substring(4).Split(' ');
                    rsapeer.FromXmlString(senderClient.publicKey);

                    if (!rsapeer.VerifyData(ToByteArray(KeyFields[0]), new SHA1CryptoServiceProvider(), ToByteArray(KeyFields[1])))
                    {
                        MessageBox.Show("Key is not authenticated by valid sender!");

                    }
                    else
                    {
                        byte[] SessionKey = rsa.Decrypt(ToByteArray(KeyFields[0]), true);
                        senderClient.sessionkey = SessionKey;

                    }

                }
                else if (incoming.StartsWith("/sndreq"))
                {
                    //file'i oku
                    string[] fields = incoming.Substring(7).Split(' ');

                    //receive tickets and import them to a arraylist.
                    mytickets tickets = new mytickets();

                    //List<client> clientlist = new List<client>();

                    tickets.DecodeFromString(fields[0]);

                    if ((!rsaserver.VerifyData(tickets.ticketlist[0].origFirst, new SHA1CryptoServiceProvider(), tickets.ticketlist[0].signFirst))
                            || (!rsaserver.VerifyData(tickets.ticketlist[0].origSecond, new SHA1CryptoServiceProvider(), tickets.ticketlist[0].signSecond)))
                    {
                        MessageBox.Show("AS is not authentic!");

                    }
                    else
                    {

                        try
                        {

                            string fname = fields[1];
                            FileInfo fInfo = new FileInfo(fname);

                            long numBytes = fInfo.Length;

                            FileStream fStream = new FileStream(fname, FileMode.Open, FileAccess.Read);

                            BinaryReader br = new BinaryReader(fStream);

                            data = br.ReadBytes((int)numBytes);
                            br.Close();
                            fStream.Close();

                            MessageBox.Show("sending file piece back");
                            string functionID = "/pback";

                            string request = functionID + BytesToHex(data).Replace(" ", "");

                            //Object objData = request;

                            byte[] byData = System.Text.Encoding.ASCII.GetBytes(request);

                            //who to send?
                            Socket tempSoc;
                            //try
                            //{
                            string target = new ASCIIEncoding().GetString(tickets.ticketlist[0].origFirst);
                            string[] targetFields = target.Split(' ');
                            string ipStr = targetFields[0];
                            string portStr = targetFields[1];

                            UpdateControls(false);
                            // Create the socket instance
                            tempSoc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                            // Cet the remote IP address
                            IPAddress ip = IPAddress.Parse(ipStr);
                            int iPortNo = System.Convert.ToInt16(portStr);
                            // Create the end point
                            IPEndPoint ipEnd = new IPEndPoint(ip, iPortNo);
                            // Connect to the remote host

                            tempSoc.Connect(ipEnd);
                            if (tempSoc.Connected)
                            {

                                UpdateControls(true);
                                //Wait for data asynchronously

                            }
                            //}
                            //catch (SocketException se)
                            //{
                            //  string str;
                            //str = "\nConnection failed, is the server running?\n" + se.Message;
                            //MessageBox.Show(str);
                            //UpdateControls(false);

                            //}

                            if (tempSoc != null)
                            {
                                tempSoc.Send(byData);
                            }
                        }
                        catch (SocketException se)
                        {
                            MessageBox.Show(se.Message);
                        }
                    }
                }
                else if (incoming.StartsWith("/pback"))
                {
                    string filePartMsg = incoming.Substring(6);
                    byte[] filePartb = ToByteArray(filePartMsg);

                    string bconcat = System.Text.Encoding.ASCII.GetString(filePartb);

                    string[] infilefields = bconcat.Split(' ');

                    byte[] tempPart = ToByteArray(infilefields[0]);

                    SharedData partOftheSecretThatWeAreTryingToAcquire = new SharedData();
                    partOftheSecretThatWeAreTryingToAcquire.xi = System.Convert.ToInt64(infilefields[1]);
                    partOftheSecretThatWeAreTryingToAcquire.yi = System.Convert.ToInt64(infilefields[2]);

                    secretsFromOthers.Add(partOftheSecretThatWeAreTryingToAcquire);
                    partsFromOthers.Add(tempPart);

                    if (partsFromOthers.Count >= enoughParts)
                    {
                        Reconstruct();
                    }
                }

                // Continue the waiting for data on the Socket
                WaitForPeerData(socketData.m_currentSocket);
            }
            catch (ObjectDisposedException)
            {
                System.Diagnostics.Debugger.Log(0, "1", "\nOnDataReceived: Socket has been closed\n");
            }
            catch (SocketException se)
            {
                MessageBox.Show(se.Message);
            }
        }
        //select a client and display data
        protected void Insert_gvClientSearchresult_SelectedIndexChanged(object sender, EventArgs e)
        {
            person = person.Select(Convert.ToInt32(Insert_gvClientSearchresult.SelectedDataKey.Value));
            GlobalVariables.PersonID = Convert.ToInt32(Insert_gvClientSearchresult.SelectedDataKey.Value);

            client = client.Select(GlobalVariables.PersonID);
            GlobalVariables.ClientID = client.client_id;

            Insert_txtFirstName.Text = person.f_name.ToString();
            Insert_txtLastName.Text = person.l_name.ToString();

            Insert_firstName_L.Visible = false;
            Insert_lastName_L.Visible = false;
            Insert_txtFirstName.Visible = false;
            Insert_txtLastName.Visible = false;
            Insert_btnNameSearch.Visible = false;
            Insert_changeClient.Visible = true;

            Insert_sClient_L.Text = "</br>" + person.f_name + " " + person.l_name + " is selected.";

            Insert_refreshcase();
        }
Example #28
0
 ComponentType.Row => new TransientRowComponent(client, model),
Example #29
0
 private static bool validateClient(client cli)
 {
     return cli.email != "" && cli.password != "" && isUnique(cli);
 }
Example #30
0
 ComponentType.Button => new TransientButtonComponent(client, model),
        public client client_insert()
        {
            client.client_id = person.person_id;
            if (Insert_deceasedYes.Checked == true)
            {
                client.client_status = "D";
            }
            else
            {
                client.client_status = "M";
            }
            client.ethnicity = Insert_ethnicity_txt.Text;
            client.eye_color = Insert_eye_color_ddl.SelectedValue;
            client.hair_color = Insert_hair_color_ddl.SelectedValue;
            client.height = Insert_height_ddl.SelectedValue;
            byte[] uploaded_picture = Insert_FileUpload.FileBytes;
            Insert_Save_Picture();
            client.picture = uploaded_picture;
            client.weight = Convert.ToInt32(Insert_weight_txt.Text);
            client.skin_color = Insert_skin_color_ddl.SelectedValue;
            client.Subscribed_Alerts = "N";
            client.Info_Field = "";
            client.Client_Shelter_ID = 0;
            client.Emergency_Contact_Name = "";
            client.Emergency_Contact_Number = "";

            client = client.Insert(client);
            //GridView1.DataBind();
            return client;
        }
Example #32
0
 _ => new TransientComponent(client, model)
        //select a client and display data
        protected void Update_gvClientSearchresult_SelectedIndexChanged(object sender, EventArgs e)
        {
            person = person.Select(Convert.ToInt32(Update_gvClientSearchresult.SelectedDataKey.Value));
            GlobalVariables.PersonID = Convert.ToInt32(Update_gvClientSearchresult.SelectedDataKey.Value);

            address = address.Select(person.address_id);
            missing = missing.Select(person.person_id);
            deceased = deceased.Select(person.person_id);

            client = client.Select(person.person_id);
            GlobalVariables.ClientID = client.client_id;

            Update_LocationDiscription_txt.Text = missing.last_known_location;
            Update_reason_of_death_txt.Text = deceased.reason_of_death;
            Update_time_of_death_txt.Text = Convert.ToString(deceased.time_of_death);
            Update_identifying_marks_txt.Text = deceased.identifying_marks;
            Update_external_exam_txt.Text = deceased.external_exam;
            Update_date_of_autopsy_txt.Text = Convert.ToString(deceased.date_of_autopsy.ToShortDateString());
            Update_internal_exam_txt.Text = deceased.external_exam;
            Update_client_other_info_txt.Text = missing.client_other_info;
            Update_Client_latitude_txt.Text = Convert.ToString(address.latitude);
            Update_Client_longitude_txt.Text = Convert.ToString(address.longitude);
            Update_Client_zip_plus_four_txt.Text = Convert.ToString(address.zip_plus_four);
            Update_Client_str_add2_txt.Text = address.str_add;
            Update_Client_str_add_txt.Text = address.str_add2;
            Update_Client_County_Township_txt.Text = address.County_Township;
            Update_Client_country_txt.Text = address.country;
            Update_Client_state_txt.Text = address.state;
            Update_Client_city_txt.Text = address.city;
            Update_hair_color_ddl.SelectedValue = client.hair_color;
            Update_skin_color_ddl.SelectedValue = client.skin_color;
            Update_eye_color_ddl.SelectedValue = client.eye_color;
            Update_ethnicity_txt.Text = client.ethnicity;
            Update_weight_txt.Text = Convert.ToString(client.weight);
            Update_height_ddl.SelectedValue = Convert.ToString(client.height);
            Update_date_of_disappearance_txt.Text = Convert.ToString(missing.date_of_disappearance.ToShortDateString());
            Update_clothing_txt.Text = missing.clothing;
            Update_phone_primary_txt.Text = person.phone_primary;
            Update_ssn_txt.Text = Convert.ToString(person.ssn);
            Update_gender_ddl.SelectedValue = person.gender;
            Update_l_name_txt.Text = person.l_name;
            Update_m_initial_txt.Text = person.m_initial;
            Update_f_name_txt.Text = person.f_name;

            //change condishions
            Update_txtFirstName.Text = person.f_name.ToString();
            Update_txtLastName.Text = person.l_name.ToString();

            if (client.client_status == "D")
            {
                Update_Deceased_Div.Style.Add("display", "block");
                Update_deceasedYes.Checked = true;
                Update_missingYes.Checked = false;
            }
            else
            {
                Update_Deceased_Div.Style.Add("display", "none");
                Update_deceasedYes.Checked = false;
                Update_missingYes.Checked = true;
            }

            Update_sClient_L.Text = "</br>" + person.f_name + " " + person.l_name + " is selected.";
        }
 // PUT: api/client/5
 public void Put(string id, [FromBody] client value)
 {
     value.id = id;
     this.repository.Update(value);
 }
Example #35
0
 AuditLogType.MemberUnbanned => new RestMemberUnbannedAuditLog(client, log, entry),
        // DELETE: api/client/5
        public void Delete(string id)
        {
            client client = this.repository.FindById(id);

            this.repository.Delete(client);
        }
Example #37
0
 AuditLogType.MembersMoved => new RestMembersMovedAuditLog(client, log, entry),
//==========================================================

        public void increase_chage_of_client(client clt, float total)
        {
            clt.charge          = clt.charge + total;
            DB.Entry(clt).State = EntityState.Modified;
            DB.SaveChanges();
        }
Example #39
0
 AuditLogType.BotAdded => new RestBotAddedAuditLog(client, log, entry),
 public void afegirClient(client client)
 {
 }
        protected void fill_Client_information()
        {
            client = client.Select(GlobalVariables.PersonID);
            GlobalVariables.ClientID = client.client_id;

            clientAddress = clientAddress.Select(clientperson.address_id);
            clientAddress2 = clientAddress2.Select(clientperson.address_id2);

            GlobalVariables.ClientAddressID = clientAddress.address_id;
            GlobalVariables.ClientAddressID2 = clientAddress2.address_id;

            ddl_client_status.SelectedValue = client.client_status;
            txt_L_Name.Text = clientperson.l_name.ToString();
            txt_F_Name.Text = clientperson.f_name.ToString();
            txt_M_Initial.Text = clientperson.m_initial.ToString();
            txt_email.Text = clientperson.email.ToString();
            txt_Maiden_Name.Text = clientperson.Maiden_Name.ToString();
            ddl_Gender.SelectedValue = clientperson.gender;
            txt_SSN.Text = clientperson.ssn.ToString();
            txt_DrvLic.Text = clientperson.Driver_State_ID;
            txt_Birthdate.Text = clientperson.birthdate.ToString();
            txt_Phone_Primary.Text = clientperson.phone_primary;
            txt_Phone_Secondary.Text = clientperson.phone_secondary;
            ddl_Marital_Status.SelectedValue = clientperson.Marital_Status;
            ddl_CitizenShip.SelectedValue = clientperson.Citizenship;

            get_visa_type();

            TxtVisaIssDate.Text = clientperson.Visa_Issue_Date.ToString();
            TxtVisaExpDate.Text = clientperson.Visa_Expire_Date.ToString();
            TxtUSCISNum.Text = clientperson.Perm_Resident_Alien_USCIS_number.ToString();
            TxtANumber.Text = clientperson.Perm_Resident_Alien_A_number.ToString();
            TxtresDate.Text = clientperson.Perm_Resident_Alien_Resid_Date.ToString();
            TxtResExpDate.Text = clientperson.Perm_Resident_Alien_Expire_Date.ToString();
            TxtCountryOfBirth.Text = clientperson.Perm_Resident_Alien_Birth_Country;
            TxtCategory.Text = clientperson.Perm_Resident_Alien_Category;

            txtCurr_str_addr.Text = clientAddress.str_add;
            TxtCurr_str_addr2.Text = clientAddress.str_add2;
            txtCurr_city.Text = clientAddress.city;
            if (clientAddress.state != null)
            {
                ddlCurr_st.SelectedValue = clientAddress.state;
            }
            txtCurr_zip.Text = clientAddress.zip_plus_four.ToString();
            TxtCurr_Country.Text = clientAddress.country;
            TxtCurr_CountyTownship.Text = clientAddress.County_Township;

            txtPrev_str_addr.Text = clientAddress2.str_add;
            txtPrev_str_addr2.Text = clientAddress2.str_add2;
            txtPrev_city.Text = clientAddress2.city;
            if (clientAddress2.state != "")
            {
                ddlPrev_st.SelectedValue = clientAddress2.state;
            }
            txtPrev_zip.Text = clientAddress2.zip_plus_four.ToString();
            TxtPrev_Country.Text = clientAddress2.country;
            TxtPrev_countyTownship.Text = clientAddress2.County_Township;
        }
Example #42
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            String email   = model.Email.ToString();
            var    request = (HttpWebRequest)WebRequest.Create("http://localhost:18080/21meeseeks-web/rest/authentication");

            request.Method      = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            byte[] bytes = Encoding.ASCII.GetBytes("username="******"&password="******"token"].Value = responseMessage;
                    //   Response.Cookies["userName"].Expires = DateTime.Now.AddDays(1);

                    //localhost:18080/21meeseeks-web/rest/[email protected]
                    ClientService cs = new ClientService();
                    client        c  = cs.Get(d => d.email.Equals(email));
                    if (c == null)
                    {
                        AdminService aserv = new AdminService();
                        admin        a     = aserv.Get(d => d.email.Equals(email));
                        Session["role"]     = "Admin";
                        Session["id"]       = a.idUser;
                        Session["token"]    = responseMessage;
                        Session["username"] = a.email;
                    }
                    else
                    {
                        Session["role"]     = "Client";
                        Session["id"]       = c.idUser;
                        Session["token"]    = responseMessage;
                        Session["username"] = c.email;
                        Session["logo"]     = c.logo;
                        Session["name"]     = c.clientName;
                    }
                    return(RedirectToAction("Index", "Client", new { area = "" }));
                }
            }
            catch (WebException e)
            {
                ViewBag.message = "Wrong credentials";
                return(View(model));
            }


            /*
             * if (!ModelState.IsValid)
             * {
             *  return View(model);
             * }
             *
             * // This doesn't count login failures towards account lockout
             * // To enable password failures to trigger account lockout, change to shouldLockout: true
             * var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
             * switch (result)
             * {
             *  case SignInStatus.Success:
             *      return RedirectToLocal(returnUrl);
             *  case SignInStatus.LockedOut:
             *      return View("Lockout");
             *  case SignInStatus.RequiresVerification:
             *      return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
             *  case SignInStatus.Failure:
             *  default:
             *      ModelState.AddModelError("", "Invalid login attempt.");
             *      return View(model);
             * }*/
        }
Example #43
0
 _ => new TransientRichActivity(client, model)
Example #44
0
 return(Send(client, sendFrame));
        //select a client and display data
        protected void Update_gvClientSearchresult_SelectedIndexChanged(object sender, EventArgs e)
        {
            Update_lbl_pet_Error.Text = "";
            person = person.Select(Convert.ToInt32(Update_gvClientSearchresult.SelectedDataKey.Value));
            GlobalVariables.PersonID = Convert.ToInt32(Update_gvClientSearchresult.SelectedDataKey.Value);

            client = client.Select(GlobalVariables.PersonID);
            GlobalVariables.ClientID = client.client_id;

            Update_txtfirstname.Text = person.f_name.ToString();
            Update_txtlastname.Text = person.l_name.ToString();

            Update_refreshcase();
        }
 var(client, guildId) = tuple;
        //update the pet records -- update btn
        protected void update(object sender, EventArgs e)
        {
            if (Update_GVcases.SelectedValue == null)
            {
                Update_lbl_pet_Error.Text = "You must first select a case to continue";
                return;
            }
            else if (Update_gvClientSearchresult.SelectedValue == null)
            {
                Update_lbl_pet_Error.Text = "You must first select a client to continue";
                return;
            }
            if (Update_DDL_Call_Center.SelectedValue == "-1")
            {
                Update_lbl_pet_Error.Text = "Please a call center to contuinue.";
                return;
            }
            else if (Update_DDlDisasters.SelectedValue == "-1")
            {
                Update_lbl_pet_Error.Text = "Please a disaster to contuinue.";
                return;
            }
            else
            {

                person = person.Select(Convert.ToInt32(Update_gvClientSearchresult.SelectedDataKey.Value));
                client = client.Select(Convert.ToInt32(Update_gvClientSearchresult.SelectedDataKey.Value));

                //PetType exchange
                Pet_Type.Pet_Type_ID = GlobalVariables.Pet_Type_ID;

                Pet_Type.Pet_Type = Update_petType_ddl.SelectedValue;
                Pet_Type.Pet_Breed = Update_petBreed_txt.Text;
                Pet_Type.Pet_Species = Update_petSpecies_ddl.SelectedValue;

                //Pet exchange
                pet.Pet_Record_ID = Convert.ToInt32(Update_gvPetSearchresult.SelectedDataKey.Value);
                pet.Pet_Type_ID = GlobalVariables.Pet_Type_ID;

                pet.Pet_Name = Update_petName_txt.Text;
                pet.Pet_Location_Found_ID = 1;
                if (Update_petDateOfBirth_txt.Text != "") { pet.Pet_Date_Of_Birth = Convert.ToDateTime(Update_petDateOfBirth_txt.Text); }
                pet.Pet_RFID = Update_petRFID_txt.Text;
                pet.Date_Modified = DateTime.Now;
                pet.Date_Created = DateTime.Now;
                pet.Pet_Description = Update_petDiscription_txt.Text;
                pet.Pet_Gender = Convert.ToString(Update_petGender_DDL.SelectedValue);
                pet.Pet_Color = Update_petColor_txt.Text;
                pet.Pet_Vet_ID = Update_petVetID_txt.Text;
                pet.Pet_License_Tag = Update_petLicenseTag_txt.Text;
                pet.Pet_Tatoo_No = Update_petTatooNumber_txt.Text;
                pet.Pet_Sterilized = Convert.ToString(Update_petNeutered_DDL.SelectedValue);
                pet.Pet_Weight = Convert.ToInt32(Update_petWeight_txt.Text);
                pet.Pet_Condition = Update_petConditionID_ddl.SelectedValue;
                pet.Pet_Status = Update_petStatusID_txt.Text;

                if (Update_Image_Name.Text != "")
                {
                    //=========
                    //Save Image to server then DB Object
                    string fileName = Update_gvPetSearchresult.SelectedDataKey.Value + "_" + Update_petName_txt.Text + ".jpg";
                    string smallPath = Server.MapPath("Pet_Images/100x100/" + fileName);
                    string mediumPath = Server.MapPath("Pet_Images/200x200/" + fileName);
                    string originalPath = Server.MapPath("Pet_Images/Original/" + fileName);
                    string originalTempPath = Server.MapPath("Pet_Images/Original/" + Update_Image_Name.Text);

                    //create clone image to re-size
                    System.Drawing.Image small_pet_picture = System.Drawing.Image.FromFile(originalTempPath);
                    //resize
                    small_pet_picture = resizeImage(small_pet_picture, new Size(100, 100));
                    //Convert back to byte[] array
                    byte[] small_pet_picture_bytes = imageToByteArray(small_pet_picture);

                    //create clone image to re-size
                    System.Drawing.Image medium_pet_picture = System.Drawing.Image.FromFile(originalTempPath);
                    //resize
                    medium_pet_picture = resizeImage(medium_pet_picture, new Size(200, 200));
                    //Convert back to byte[] array
                    byte[] medium_pet_picture_bytes = imageToByteArray(medium_pet_picture);

                    //create clone image to re-size
                    System.Drawing.Image original_pet_picture = System.Drawing.Image.FromFile(originalTempPath);
                    //Convert to byte[] array
                    byte[] original_pet_picture_bytes = imageToByteArray(original_pet_picture);

                    //save resized images
                    File.WriteAllBytes(@smallPath, small_pet_picture_bytes);
                    File.WriteAllBytes(@mediumPath, medium_pet_picture_bytes);
                    File.WriteAllBytes(@originalPath, original_pet_picture_bytes);
                    //save to database
                    pet.Pet_Picture = imageToByteArray(System.Drawing.Image.FromFile(originalPath));
                }
                else
                {
                    pet.Pet_Picture = new byte[0];
                }

                //ClientWPets
                ClientWPets.CLIENTWPETS_ID = GlobalVariables.CLIENTWPETS_ID;
                ClientWPets.Pet_Record_ID = pet.Pet_Record_ID;
                ClientWPets.Client_id = client.client_id;
                ClientWPets.Location_ID = GlobalVariables.Location_ID;
                ClientWPets.cp_Date = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));
                ClientWPets.ownership = Convert.ToString("y");

                //Location
                Location.Location_ID = GlobalVariables.Location_ID;
                Location.type = decideLocationType();
                Location.city = Update_city_txt.Text;
                Location.state = Update_state_txt.Text;
                Location.zip = Convert.ToInt32(Update_zip_txt.Text);
                Location.county = Update_county_txt.Text;
                Location.location_desc = Update_LocationDiscription_txt.Text;
                Location.n_long = Convert.ToDecimal(Update_long_txt.Text);
                Location.s_long = 0;
                Location.e_long = 0;
                Location.w_long = 0;
                Location.n_lat = Convert.ToDecimal(Update_lat_txt.Text);
                Location.s_lat = 0;
                Location.e_lat = 0;
                Location.w_lat = 0;

                //update

                if (Pet_Deceased.Pet_Deceased_ID == 0 && Update_deceasedYes.Checked == true)
                {
                    if (Update_DateDeceased_txt.Text == "" || Update_serviceType_DDL.SelectedValue == "-1")
                    {
                        Update_lbl_pet_Error.Text = "Please fill out The Date Found and or Service Type.";
                    }
                    else
                    {
                        //Pet_Deceased exchange
                        Pet_Deceased.Pet_Deceased_ID = pet.Pet_Record_ID;
                        Pet_Deceased.Date_Deceased = Convert.ToDateTime(Update_DateDeceased_txt.Text);
                        Pet_Deceased.Funeral = Update_funeral_txt.Text;
                        Pet_Deceased.Cemetary_Name = Update_cemetaryName_txt.Text;
                        Pet_Deceased.Deceased_Type = Update_serviceType_DDL.SelectedValue;
                        Pet_Deceased.Date_Modified = DateTime.Now;
                        Pet_Deceased.Date_Created = DateTime.Now;
                        Pet_Deceased.Location_ID = Location.Location_ID;
                        Pet_Deceased = Pet_Deceased.Insert(Pet_Deceased);
                    }
                }
                if (GlobalVariables.Pet_Deceased_ID != 0 && Update_deceasedYes.Checked == true)
                {
                    if (Update_DateDeceased_txt.Text == "" || Update_serviceType_DDL.SelectedValue == "")
                    {
                        Update_lbl_pet_Error.Text = "Please fill out The Date Found and or Service Type.";
                    }
                    else
                    {
                        //Pet_Deceased exchange
                        Pet_Deceased.Pet_Deceased_ID = pet.Pet_Record_ID;
                        Pet_Deceased.Date_Deceased = Convert.ToDateTime(Update_DateDeceased_txt.Text);
                        Pet_Deceased.Funeral = Update_funeral_txt.Text;
                        Pet_Deceased.Cemetary_Name = Update_cemetaryName_txt.Text;
                        Pet_Deceased.Deceased_Type = Update_serviceType_DDL.SelectedValue;
                        Pet_Deceased.Location_ID = Location.Location_ID;
                        //Pet_Deceased.Date_Created == null
                        Pet_Deceased.Date_Modified = DateTime.Now;

                        Pet_Deceased.Update(Pet_Deceased);
                    }
                }
                if (GlobalVariables.Pet_Missing_ID == 0 && Update_missingYes.Checked == true)
                {
                    //Pet_Missing exchange
                    Pet_Missing.Pet_Missing_ID = pet.Pet_Record_ID;
                    Pet_Missing.Last_Known_Location_ID = Location.Location_ID;
                    Pet_Missing.Date_Reported = DateTime.Now;
                    Pet_Missing.Date_Created = DateTime.Now;
                    Pet_Missing.Date_Missing = Convert.ToDateTime(Update_DateMissing_txt.Text);
                    Pet_Missing.Time_Lost = Convert.ToDateTime(Update_TimeLost_txt.Text);
                    Pet_Missing.Collar_Description = Update_collarDescription_txt.Text;
                    Pet_Missing.Lost_Explanation = Update_lostExplanation_txt.Text;
                    if (Update_LengthOwned_txt.Text != "") { Pet_Missing.Length_Owned = Convert.ToInt32(Update_LengthOwned_txt.Text); }
                    if (Update_RewardAmt_txt.Text != "") { Pet_Missing.Reward_Amt = Convert.ToDecimal(Update_RewardAmt_txt.Text); }
                    Pet_Missing.Breeder = Update_Breeder_txt.Text;
                    Pet_Missing.Date_Modified = DateTime.Now;

                    Pet_Missing = Pet_Missing.Insert(Pet_Missing);
                }
                if (GlobalVariables.Pet_Missing_ID != 0 && Update_missingYes.Checked == true)
                {
                    //Pet_Missing exchange
                    Pet_Missing.Pet_Missing_ID = pet.Pet_Record_ID;
                    Pet_Missing.Last_Known_Location_ID = Location.Location_ID;
                    Pet_Missing.Date_Reported = DateTime.Now;
                    Pet_Missing.Date_Created = DateTime.Now;
                    Pet_Missing.Date_Missing = Convert.ToDateTime(Update_DateMissing_txt.Text);
                    Pet_Missing.Time_Lost = Convert.ToDateTime(Update_TimeLost_txt.Text);
                    Pet_Missing.Collar_Description = Update_collarDescription_txt.Text;
                    Pet_Missing.Lost_Explanation = Update_lostExplanation_txt.Text;
                    if (Update_LengthOwned_txt.Text != "") { Pet_Missing.Length_Owned = Convert.ToInt32(Update_LengthOwned_txt.Text); }
                    if (Update_RewardAmt_txt.Text != "") { Pet_Missing.Reward_Amt = Convert.ToDecimal(Update_RewardAmt_txt.Text); }
                    Pet_Missing.Breeder = Update_Breeder_txt.Text;
                    Pet_Missing.Date_Modified = DateTime.Now;
                    Pet_Missing.Update(Pet_Missing);
                }

                pet.Update(pet);
                Pet_Type.Update(Pet_Type);
                Location.Update(Location);
                ClientWPets.Update(ClientWPets);

                ////////////////////////////////////////
                encounter.case_id = GlobalVariables.CaseID;
                encounter.agency_id = 0;
                encounter.call_center_id = Convert.ToInt32(Update_DDL_Call_Center.SelectedValue);
                encounter.client_id = GlobalVariables.ClientID;
                encounter.create_date = DateTime.Now;
                if (GlobalVariables.Pet_Deceased_ID != null || GlobalVariables.Pet_Deceased_ID != 0)
                {
                    encounter.close_date = DateTime.Now;
                }
                else
                {
                    encounter.close_date = Convert.ToDateTime("9/9/9");
                }

                encounter.disaster_id = Convert.ToInt32(Update_DDlDisasters.SelectedValue);
                encounter.Location_ID = Location.Location_ID;
                encounter.Pet_Record_ID = pet.Pet_Record_ID;

                encounter.Insert(encounter);

                Update_lbl_pet_Error.Text = "The selected pets informatin has been successfully updated.";
            }
        }
Example #48
0
 public int Add(client client)
 {
     return(dal.Add(client));
 }
Example #49
0
 private static bool isUnique(client cli)
 {
     return (from c in db.clients
             where c.email == cli.email
             select c.id).Count() == 0;
 }
 protected void Update_Select_Record(object sender, EventArgs e)
 {
     client = Update_client_select(Convert.ToInt32(Update_Client_GridView.SelectedValue));
 }
Example #51
0
        private void CreateGraph(ZedGraphControl zgc)
        {
            GraphPane myPane = zgc.GraphPane;
            button2.Visible = false;
            // Set the titles and axis labels
            myPane.Title.Text = "";
            myPane.XAxis.Title.Text = "Time (minutes)";
            myPane.YAxis.Title.Text = "Average Delay (seconds)";

            List<packetEntry> srcList = new List<packetEntry>();
            string[] fileArray = Directory.GetFiles(folderName+"1srcWifi/");
            for (int i = 0; i < fileArray.Length; i++)
            {
                if (fileArray[i].Contains("txt"))
                {
                    StreamReader sr = new StreamReader(fileArray[i]);

                    client c = new client();
                    c.totalInternetUsageTime = 0;
                    c.totalInternetUsageDelay = 0;
                    c.lastAuth = -1;
                    c.clientRole = "";
                    string lastline;
                    while (!sr.EndOfStream)
                    {
                        string line = sr.ReadLine();
                        if (line != "")
                        {
                            lastline = line;
                            string[] srcLine = line.Split('$');
                            string packetId = srcLine[4];
                            double packetTime = Convert.ToDouble(srcLine[5].Replace('.', ','));
                            string networkProtocol = srcLine[6];

                            if (c.clientRole == "")
                            {
                                c.clientRole = srcLine[7];
                                c.clientID = Convert.ToInt32(srcLine[8]);
                            }
                            if ((networkProtocol == "InitialAuth" || networkProtocol == "Reuse") && c.lastAuth == -1)
                            {
                                c.lastAuth = packetTime;
                            }
                            else if (networkProtocol == "Disconnection")
                            {
                                if(packetTime > c.lastAuth)
                                {
                                    double diff = packetTime - c.lastAuth;
                                    c.totalInternetUsageTime += diff;
                                    c.lastAuth = -1;
                                }
                            }

                            packetEntry pe = new packetEntry();
                            pe.id = packetId;
                            pe.time = packetTime;
                            pe.protocol = networkProtocol;
                            pe.clientRole = srcLine[7];
                            pe.clientID = Convert.ToInt32(srcLine[8]);
                            srcList.Add(pe);
                        }
                    }
                    sr.Close();
                    if (c.lastAuth != -1)
                    {
                        c.totalInternetUsageTime += 1440 - c.lastAuth;
                    }
                    clientArray[c.clientID] = c;
                }
            }

            srcList = MergeSort(srcList);
            //srcList.RemoveRange(0, userCount);
            StreamWriter destWrite = new StreamWriter("destTotal.txt");
            string[] fileArray2 = Directory.GetFiles(folderName + "5destMesh/");
            for (int i = 0; i < fileArray2.Length; i++)
            {
                if (fileArray2[i].Contains("txt"))
                {
                    StreamReader sr = new StreamReader(fileArray2[i]);
                    while (!sr.EndOfStream)
                    {
                        string line = sr.ReadLine();
                        if (line != "")
                        {
                            destWrite.WriteLine(line);
                        }
                    }
                    sr.Close();
                }
            }
            destWrite.Close();
            /*
            StreamWriter destWrite2 = new StreamWriter("destTotalPT.txt");
            string[] fileArray3 = Directory.GetFiles(folderName + "destPT/");
            for (int i = 0; i < fileArray3.Length; i++)
            {
                if (fileArray3[i].Contains("txt"))
                {
                    StreamReader sr = new StreamReader(fileArray3[i]);
                    while (!sr.EndOfStream)
                    {
                        string line = sr.ReadLine();
                        if (line != "")
                        {
                            destWrite2.WriteLine(line);
                        }
                    }
                    sr.Close();
                }
            }
            destWrite2.Close();
            */
            PointPairList list = new PointPairList();

            int count = 1;

            for(int i = 0; i < srcList.Count; i++)
            {
                string packetId = srcList[i].id;
                double sendTime = srcList[i].time;
                string networkProtocol = srcList[i].protocol;
                int clientID = srcList[i].clientID;
                if (networkProtocol == "InitialAuth" || networkProtocol == "Reuse")//networkProtocol == "PacketTransfer" || networkProtocol == "Reuse" || networkProtocol == "ChangeAlias" || networkProtocol == "Disconnection" || networkProtocol == "End-To-End")
                {
                    StreamReader dest = new StreamReader("destTotal.txt");
                    while (!dest.EndOfStream)
                    {
                        string[] destLine = dest.ReadLine().Split('$');
                        if (packetId == destLine[4])
                        {
                            double arriveTime = Convert.ToDouble(destLine[5].Replace('.', ','));
                            if (arriveTime - sendTime > 3) break;
                            clientArray[clientID].totalInternetUsageDelay += arriveTime - sendTime;
                            totalDelay = totalDelay + (arriveTime - sendTime);
                            double average = totalDelay / count;

                            list.Add(sendTime, average);

                            count++;

                            break;
                        }
                    }
                    dest.Close();
                }
                /*else if (networkProtocol == "SeamlessMobility" || networkProtocol == "Roaming" || networkProtocol == "PacketTransfer")
                {
                    StreamReader dest = new StreamReader("destTotalPT.txt");
                    while (!dest.EndOfStream)
                    {
                        string[] destLine = dest.ReadLine().Split('$');
                        if (packetId == destLine[4])
                        {
                            double arriveTime = Convert.ToDouble(destLine[5].Replace('.', ','));
                            if (arriveTime - sendTime > 3) break;
                            clientArray[clientID].totalInternetUsageDelay += arriveTime - sendTime;
                            totalDelay = totalDelay + (arriveTime - sendTime);
                            double average = totalDelay / count;

                            list.Add(sendTime, average);

                            count++;

                            break;
                        }
                    }
                    dest.Close();
                }*/
            }

            StreamWriter sw = new StreamWriter("clientArray.txt");
            for (int i = 0; i < clientArray.Length; i++)
            {
                client c = clientArray[i];
                sw.WriteLine(c.clientID.ToString() + " " + c.clientRole + " " + c.totalInternetUsageTime.ToString() + " " + c.totalInternetUsageDelay.ToString());
            }
            sw.Close();

            // Generate a blue curve with circle symbols, and "My Curve 2" in the legend
            LineItem myCurve = myPane.AddCurve( "Average Delay Curve", list, Color.Blue,
                                    SymbolType.None );
            // Fill the area under the curve with a white-red gradient at 45 degrees
            //myCurve.Line.Fill = new Fill( Color.White, Color.Red, 45F );
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill( Color.White );

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45F );

            // Fill the pane background with a color gradient
            myPane.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45F );

            // Calculate the Axis Scale Ranges
            zgc.AxisChange();
        }
Example #52
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     this.cl = new client();
     cl.sendToServer();
 }
    unregister (client c)
	{
	    client_list.remove (c);
	}
Example #54
0
 // Guild
 AuditLogType.GuildUpdated => new RestGuildUpdatedAuditLog(client, log, entry),
 public client client_update(int ID)
 {
     client = client.Select(ID);
     if (Update_deceasedYes.Checked == true)
     {
         client.client_status = "D";
     }
     else
     {
         client.client_status = "M";
     }
     client.ethnicity = Update_ethnicity_txt.Text;
     client.eye_color = Update_eye_color_ddl.SelectedValue;
     client.hair_color = Update_hair_color_ddl.SelectedValue;
     client.height = Update_height_ddl.SelectedValue;
     if (Update_FileUpload.HasFile == true)
     {
         byte[] uploaded_picture = Update_FileUpload.FileBytes;
         client.picture = uploaded_picture;
     }
     client.weight = Convert.ToInt32(Update_weight_txt.Text);
     client.skin_color = Update_skin_color_ddl.SelectedValue ;
     client.Update(client);
     //GridView1.DataBind();
     return client;
 }
Example #56
0
 AuditLogType.ChannelDeleted => new RestChannelDeletedAuditLog(client, log, entry),
 //UPDATE
 protected void update_Click(object sender, EventArgs e)
 {
     try
     {
         //check to see if a insert is needed for deceased
         person = person.Select(Convert.ToInt32(Update_gvClientSearchresult.SelectedValue));
         client = client.Select(person.person_id);
         if (Update_deceasedYes.Checked == true)
         {
             person = person_update(Convert.ToInt32(Update_gvClientSearchresult.SelectedValue));
             missing = missing_update(person.person_id);
             //check if update of insert of deceased
             deceased = deceased.Select(client.client_id);
             if (deceased.deceased_id == 0) { deceased = deceased_insert_For_Update(); }
             else { deceased = deceased_update(person.person_id); }
         }
         else
         {
             person = person_update(Convert.ToInt32(Update_gvClientSearchresult.SelectedValue));
             missing = missing_update(person.person_id);
         }
         address = address_update(person.address_id);
         client = client_update(person.person_id);
         encounter = encounter_insert();
         Update_refreshclient();
     }
     catch { Update_lbl_Client_Error.Text = "There has been an error updating information for the missing client."; }
     finally { Update_lbl_Client_Error.Text = "The missing client's information has been successfully updated."; }
 }
Example #58
0
 AuditLogType.OverwriteDeleted => new RestOverwriteDeletedAuditLog(client, log, entry),
Example #59
0
 get => new RedisClientSet(client, setId);
 /// <summary>
 /// HTTP转发代理
 /// </summary>
 /// <param name="socket">HTTP套接字</param>
 /// <param name="client">HTTP代理服务客户端</param>
 public forwardProxy(CommandClientPlus.socket socket, client client)
 {
     this.socket = socket;
     this.client = client;
     requestSocket = socket.Socket;
     proxySocket = client.NetSocket;
     requestBuffer = socket.HeaderReceiver.RequestHeader.Buffer;
     responseBuffer = socket.Buffer;
     onReceiveRequestHandle = onReceiveRequest;
     onReceiveResponseHandle = onReceiveResponse;
     onSendResponseHandle = onSendResponse;
 }