Exemple #1
0
        //Simulates a write to know how much it takes.
        private long SSTRecordSize(bool Repeatable)
        {
            long BeginRecordPos = 0;

            byte[] Buffer    = new byte[XlsConsts.MaxRecordDataSize + 4];
            int    BufferPos = 4 + 8;
            long   TotalSize = 0;


            if (Repeatable)
            {
                //REPEATABLEWRITES
                TSSTEntry[] SortedEntries = new TSSTEntry[Data.Count];
                Data.Keys.CopyTo(SortedEntries, 0);
                Array.Sort(SortedEntries);

                foreach (TSSTEntry Se in SortedEntries)
                {
                    Se.SaveToStream(null, Buffer, ref BufferPos, ref BeginRecordPos, ref TotalSize);
                }
            }
            else
            {
                Dictionary <TSSTEntry, TSSTEntry> .Enumerator myEnumerator = Data.GetEnumerator();
                while (myEnumerator.MoveNext())
                {
                    myEnumerator.Current.Key.SaveToStream(null, Buffer, ref BufferPos, ref BeginRecordPos, ref TotalSize);
                }
            }

            TotalSize += BufferPos;
            return(TotalSize);
        }
Exemple #2
0
        // FUNCTION		:	MainWindow()
        // DESCRIPTION	:	This function sets up the the main window
        public MainWindow()
        {
            InitializeComponent();

            Closing += Close_Window;

            // start thread listening to server
            listener = new Thread(new ParameterizedThreadStart(ListenForChatServer));

            keepListening = true;

            // start the stream
            listener.Start(stream);

            // try catch to catch any exceptions
            try
            {
                // connect the client to the server
                client = new TcpClient(serverIP, portNumber);
                // create the stream
                stream = client.GetStream();
            }
            catch (ArgumentNullException Ae)
            {
                MessageBox.Show(Ae.ToString());
            }
            catch (SocketException Se)
            {
                MessageBox.Show(Se.ToString());
            }
        }
Exemple #3
0
        public void print()
        {
            bool append = true;

            if (Id == 0)
            {
                append = false;
            }
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@".\Matrixes\Ke.txt", append))
            {
                string matrixMultiplier = "1/(4*" + Se.ToString() + ")";
                string leadingSpaces    = new string(' ', matrixMultiplier.Length);
                string elementsSpaces   = new string(' ', 2);
                string plus             = " + ";
                //
                file.WriteLine("Ke " + Id.ToString());
                //матриці
                for (int i = 0; i < 3; i++)
                {
                    string line = "";
                    if (i != 1)
                    {
                        line += leadingSpaces;
                    }
                    else
                    {
                        line += matrixMultiplier;
                    }
                    line += "|";
                    for (int j = 0; j < 2; j++)
                    {
                        line += GetLine(b, i, j, a11);
                        line += plus;
                        line += GetLine(c, i, j, a22);
                        line += elementsSpaces;
                    }
                    line += GetLine(b, i, 2, a11);
                    line += plus;
                    line += GetLine(c, i, 2, a22);
                    line += "|";
                    if (i != 1)
                    {
                        line += "   ";
                    }
                    else
                    {
                        line += " = ";
                    }
                    line += "|";
                    for (int j = 0; j < 2; j++)
                    {
                        line += String.Format(format, Ke[i][j]);
                        line += elementsSpaces;
                    }
                    line += String.Format(format, Ke[i][2]);
                    line += "|";
                    file.WriteLine(line);
                }
            }
        }
Exemple #4
0
        public void print()
        {
            bool append = true;

            if (Id == 0)
            {
                append = false;
            }
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@".\Matrixes\Qe.txt", append))
            {
                string     matrixMultiplier        = Se.ToString() + "/12";
                string[]   matrixVecrtorMultiplier = new string[3];
                string     leadingSpaces           = new string(' ', matrixMultiplier.Length);
                string     elementsSpaces          = new string(' ', 2);
                string     multiplier = " * ";
                double[][] Qe2        = new double[3][];
                Qe2[0] = new double[] { 2.0, 1.0, 1.0 };
                Qe2[1] = new double[] { 1.0, 2.0, 1.0 };
                Qe2[2] = new double[] { 1.0, 1.0, 2.0 };
                //
                file.WriteLine("Qe " + Id.ToString());
                //матриці
                for (int i = 0; i < 3; i++)
                {
                    string line = "";
                    if (i != 1)
                    {
                        line += leadingSpaces;
                    }
                    else
                    {
                        line += matrixMultiplier;
                    }
                    line += "|";
                    for (int j = 0; j < 2; j++)
                    {
                        line += String.Format(format, Qe2[i][j]);
                        line += elementsSpaces;
                    }
                    //line += String.Format(format, (Qe2[i][2] + "|" + multiplier + "|" + f[i] + "|"));
                    line += String.Format(format, Qe2[i][2]);
                    line += "|";
                    line += multiplier + "|";
                    line += String.Format(format, f[i]);
                    line += "|";
                    if (i != 1)
                    {
                        line += "   ";
                    }
                    else
                    {
                        line += " = ";
                    }
                    line += "|";
                    line += String.Format(format, Qe[i][0]);
                    line += "|";
                    file.WriteLine(line);
                }
            }
        }
        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        //
        // METHOD		:	MainWindow()
        // DESCRIPTION	:	This method initializes the main window, starts the server
        //                  and connects to the client
        // PARAMETERS   :   none
        // RETURNS		:	none
        //
        public MainWindow()
        {
            InitializeComponent();
            Closing += MainWindow_Close;

            //Assigns the method to the thread
            serverListener = new Thread(new ParameterizedThreadStart(ListenToServer));
            //Set thread working flag to true
            continueListen = true;
            //Start the thread
            serverListener.Start(stream);

            try
            {
                //Connect TCP client to server
                client = new TcpClient(server, port);
                //Setup service stream with client
                stream = client.GetStream();
            }
            catch (ArgumentNullException Ae)
            {
                MessageBox.Show(Ae.ToString());
            }
            catch (SocketException Se)
            {
                MessageBox.Show(Se.ToString());
            }
        }
Exemple #6
0
        public virtual bool VerifyToken(string token)
        {
            var validationParameters = new TokenValidationParameters()
            ;

            validationParameters.ValidIssuer              = this.Issuer;
            validationParameters.IssuerSigningKey         = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(this.Key));
            validationParameters.ValidateLifetime         = false;
            validationParameters.ValidateAudience         = false;
            validationParameters.ValidateIssuer           = true;
            validationParameters.ValidateIssuerSigningKey = true;

            var           tokenHandler   = new JwtSecurityTokenHandler();
            SecurityToken validatedToken = null;

            try
            {
                tokenHandler.ValidateToken(token, validationParameters, out validatedToken);
            }
            catch (SecurityTokenException Se)
            {
                Console.WriteLine(Se.ToString()); //something else happened
                return(false);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString()); //something else happened
                //throw;
                return(false);
            }
            //... manual validations return false if anything untoward is discovered
            return(validatedToken != null);
        }
Exemple #7
0
        //
        // METHOD		:	MainWindow_Close()
        // DESCRIPTION	:	This method shuts down all the running functions and threads when the
        //                  user exits the program
        // PARAMETERS   :   object sender       :   object that called the funtion
        //                  CancelEventArgs e   :   any arguments if an event is canceled
        // RETURNS		:	void
        //
        private void Close_Window(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // try catch to catch and exceptions thrown
            try
            {
                Byte[] data = System.Text.Encoding.ASCII.GetBytes("--A Client Has Disconnected--");

                stream.Write(data, 0, data.Length);

                // stop the client from listening to server
                keepListening = false;

                // close Stream and client
                stream.Close();
                client.Close();
            }
            catch (SocketException Se)
            {
                MessageBox.Show(Se.ToString());
            }
            catch (ArgumentNullException ARGe)
            {
                MessageBox.Show(ARGe.ToString());
            }
        }
Exemple #8
0
        public void print()
        {
            bool append = true;

            if (Id == 0)
            {
                append = false;
            }
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@".\Matrixes\Me.txt", append))
            {
                string     matrixMultiplier = "(" + d + "*2*" + Se.ToString() + ")/24";
                string     leadingSpaces    = new string(' ', matrixMultiplier.Length);
                string     elementsSpaces   = new string(' ', 2);
                double[][] Me2 = new double[3][];
                Me2[0] = new double[] { 2.0, 1.0, 1.0 };
                Me2[1] = new double[] { 1.0, 2.0, 1.0 };
                Me2[2] = new double[] { 1.0, 1.0, 2.0 };
                //
                file.WriteLine("Me " + Id.ToString());
                //матриці
                for (int i = 0; i < 3; i++)
                {
                    string line = "";
                    if (i != 1)
                    {
                        line += leadingSpaces;
                    }
                    else
                    {
                        line += matrixMultiplier;
                    }
                    line += "|";
                    for (int j = 0; j < 2; j++)
                    {
                        line += String.Format(format, Me2[i][j]);
                        line += elementsSpaces;
                    }
                    line += String.Format(format, Me2[i][2]);
                    line += "|";
                    if (i != 1)
                    {
                        line += "   ";
                    }
                    else
                    {
                        line += " = ";
                    }
                    line += "|";
                    for (int j = 0; j < 2; j++)
                    {
                        line += String.Format(format, Me[i][j]);
                        line += elementsSpaces;
                    }
                    line += String.Format(format, Me[i][2]);
                    line += "|";
                    file.WriteLine(line);
                }
            }
        }
Exemple #9
0
    public void SeApply(Se key)
    {
        Sound     sound = seDictionary[key];
        AudioClip audio = sound.audioClip;

        seAudioSource.volume = sound.audioSize;
        seAudioSource.clip   = audio;
        seAudioSource.PlayOneShot(audio);
    }
        //Relay On
        private bool WriteOutput(out string ErrorString)
        {
            uint   nDevice;
            uint   lines;
            uint   bit;
            string s;

            ErrorString = string.Empty;
            try
            {
                if (!this.CardListIsBuild)
                {
                    ErrorString = "Card is not initialized!";
                    return(false);
                }

                s       = MyCardList[0];                //Get devide[0] of the device list
                s       = s.Substring(s.Length - 1, 1); //get card index,example:USBOPTOREL32 Card0==>"0"
                nDevice = UInt32.Parse(s);

                if (m_Handle[nDevice] != 0)
                {
                    lines = 0; bit = 1;
                    for (uint j = 0; j < this.MaxOutputs; j++)
                    {
                        if (this.RelayIsOn[j])
                        {
                            // bit is set
                            lines = lines | bit;
                        }
                        else
                        {
                            // bit is no set, do nothing
                        }

                        bit = bit << 1;
                    }
                    qlib32.QAPIExtWriteDO32(m_Handle[nDevice], 0, lines, 0);
                }
                else
                {
                    ErrorString = "Can't open USBOPTREL32 Card!";
                    throw new System.ApplicationException(ErrorString);
                }
                return(true);
            }
            catch (System.Exception Se)
            {
                ErrorString = Se.ToString();
                return(false);
            }
        }
Exemple #11
0
    //SE音源の再生
    public void SeSoundPlay(Se str, out GameObject go)
    {
        string path = SE_PATH + File(str.ToString());

        clip = Resources.Load <AudioClip>(path);

        go = Instantiate(Resources.Load <GameObject>("GameObject/AudioChild"));
        go.transform.parent = transform;
        AudioSource audio = go.GetComponent <AudioSource>();

        audio.loop = false;
        audio.clip = clip;
        audio.Play();
        Destroy(go, clip.length);
    }
Exemple #12
0
        private void SendMail(MailMessage mail)
        {
            try
            {
                string password = WebConfigurationManager.AppSettings["MailPassword"];

                using (var smtpClient = new SmtpClient("smtp.ibrahimsipahi.com", 587))
                {
                    smtpClient.EnableSsl             = false;
                    smtpClient.UseDefaultCredentials = false;
                    NetworkCredential cred = new NetworkCredential("*****@*****.**", password);
                    cred.Domain            = "ibrahimsipahi.com";
                    smtpClient.Credentials = cred;

                    smtpClient.Send(mail);
                    ViewBag.Mail = "Mail gönderildi";
                }
            }
            catch (SmtpFailedRecipientsException ex)
            {
                foreach (SmtpFailedRecipientException t in ex.InnerExceptions)
                {
                    var status = t.StatusCode;
                    if (status == SmtpStatusCode.MailboxBusy ||
                        status == SmtpStatusCode.MailboxUnavailable)
                    {
                        Response.Write("Delivery failed - retrying in 5 seconds.");
                        System.Threading.Thread.Sleep(5000);
                    }
                    else
                    {
                        ViewBag.Mail = "Mail gönderilemedi";
                        Response.Write("Failed to deliver message ");
                    }
                }
            }
            catch (SmtpException Se)
            {
                ViewBag.Mail = "Mail gönderilemedi";
                Response.Write(Se.ToString());
            }

            catch (Exception ex)
            {
                ViewBag.Mail = "Mail gönderilemedi";
                Response.Write(ex.ToString());
            }
        }
        //initialization Relay Cards
        private bool BuildCardList(out string ErrorString) //Build Cards list
        {
            CARDDATAS lpcd = new CARDDATAS();
            uint      device;
            uint      handle;
            uint      result;
            string    s;

            ErrorString = string.Empty;

            try
            {
                // Open the USBOPTREL32	device ,get all availabel device handle
                this.MyCardList = new List <string>();
                for (device = 0; device < this.MaxNumberOfCards; device++)
                {
                    handle = qlib32.QAPIExtOpenCard(qlib32.USBOPTOREL32, device);

                    if (handle != 0)
                    {
                        // save handle
                        m_Handle[device] = handle;
                        lpcd.SizeOf      = Marshal.SizeOf(lpcd);
                        // return card name
                        unsafe
                        {
                            result = qlib32.QAPIExtGetCardInfoEx(qlib32.USBOPTOREL32, lpcd);
                        }
                        s = lpcd.Name + " Card " + device;
                        // add card name to list
                        MyCardList.Add(s);
                    }
                }

                // no card found ? display message and terminate !
                if (MyCardList.Count < 1)
                {
                    ErrorString = "Unable to open any USBOPTOREL32 Card. Did you install the drivers ?";
                    throw new System.ApplicationException(ErrorString);
                }
                return(true);
            }
            catch (System.Exception Se)
            {
                ErrorString = Se.ToString();
                return(false);
            }
        }
Exemple #14
0
        /** [シングルトン]削除。
         */
        private void Delete()
        {
            //bgm
            this.bgm.Delete();
            this.bgm = null;

            //se
            this.se.Delete();
            this.se = null;

            //playerloop_flag
            this.playerloop_flag = false;

            //PlayerLoopType
            Fee.PlayerLoopSystem.PlayerLoopSystem.GetInstance().RemoveFromType(typeof(PlayerLoopType.Fee_Audio_Main));
        }
Exemple #15
0
        internal void SaveToStream(IDataStream DataStream, TSaveData SaveData)
        {
            long BeginRecordPos = DataStream.Position;

            byte[] Buffer = new byte[XlsConsts.MaxRecordDataSize + 4];
            Array.Copy(BitConverter.GetBytes((UInt16)xlr.SST), 0, Buffer, 0, 2);

            bool   Repeatable = SaveData.Repeatable;
            UInt32 TotalRefs;
            IEnumerator <KeyValuePair <TSSTEntry, TSSTEntry> > myEnumerator;

            TSSTEntry[] SortedEntries;
            PrepareToSave(Repeatable, out TotalRefs, out myEnumerator, out SortedEntries);

            Array.Copy(BitConverter.GetBytes(TotalRefs), 0, Buffer, 4, 4);
            Array.Copy(BitConverter.GetBytes((UInt32)Data.Count), 0, Buffer, 8, 4);

            int  BufferPos = 4 + 8;
            long TotalSize = 0;

            if (Repeatable)
            {
                //REPEATABLEWRITES
                foreach (TSSTEntry Se in SortedEntries)
                {
                    Se.SaveToStream(DataStream, Buffer, ref BufferPos, ref BeginRecordPos, ref TotalSize);
                }
            }
            else
            {
                myEnumerator.Reset();
                while (myEnumerator.MoveNext())
                {
                    myEnumerator.Current.Key.SaveToStream(DataStream, Buffer, ref BufferPos, ref BeginRecordPos, ref TotalSize);
                }
            }

            //Flush the buffer.
            Array.Copy(BitConverter.GetBytes((UInt16)(BufferPos - 4)), 0, Buffer, 2, 2);  //Adapt the record size before writing it.
            DataStream.WriteHeader((UInt16)(Buffer[0] + (Buffer[1] << 8)), (UInt16)(Buffer[2] + (Buffer[3] << 8)));
            DataStream.Write(Buffer, 4, BufferPos - 4);
            TotalSize += BufferPos;


            WriteExtSST(DataStream, Repeatable);
        }
 //Static Functions
 public static bool FillVoltageBuffer(int Samples, double TheVoltRange, short[] Buffer, out double[] VoltageBuffer, out string Fehlerstring)
 {
     Fehlerstring  = string.Empty;
     VoltageBuffer = new double[Samples];
     try
     {
         for (int i = 0; i < Samples; i++)
         {
             VoltageBuffer[i] = TransNorm(TheVoltRange, Buffer[i]);
         }
         return(true);
     }
     catch (System.Exception Se)
     {
         Fehlerstring = Se.ToString();
         return(false);
     }
 }
Exemple #17
0
        /** [シングルトン]constructor
         */
        private Audio()
        {
            //ボリューム。マスター。
            this.volume_master = new Volume(null, Config.DEFAULT_VOLUME_MASTER);

            //bgm
            this.bgm = new Bgm(this.volume_master);

            //se
            this.se = new Se(this.volume_master);

            //フォーカス。
            this.is_focus = true;

            //PlayerLoopType
            this.playerloop_flag = true;
            Fee.PlayerLoopSystem.PlayerLoopSystem.GetInstance().Add(Config.PLAYERLOOP_ADDTYPE, Config.PLAYERLOOP_TARGETTYPE, typeof(PlayerLoopType.Fee_Audio_Main), this.Main);
        }
Exemple #18
0
    public void OnClickSetAlarmButton()
    {
        GleyNotifications.Initialize(false);

        int tempHours = selectedTime.hours + (selectedTime.am_pm.Equals("AM") ? 0 : 12);

        DateTime current  = DateTime.Now;
        DateTime selected = new DateTime(selectedDate.year, selectedDate.month + 1, selectedDate.day, tempHours, selectedTime.minutes, 0);

        TimeSpan reqTime = selected.Subtract(current);

        Debug.Log("Difference: " + (reqTime.Hours + reqTime.Days * 24) + ":" + reqTime.Minutes + ":" + reqTime.Seconds);

        Hou = reqTime.Hours + reqTime.Days * 24;
        Mi  = reqTime.Minutes;
        Se  = reqTime.Seconds;

        if (Hou < 0 || Mi < 0 || Se < 0)
        {
            PopupManager.Instance.messagePopup.Show("Invalid Date/Time!", "Please set reminder for future Date/Time only.");
            return;
        }

        AlarmSettings.SetActive(false);
        for (int i = 0; i < AlarmList.Count; i++)
        {
            if (AlarmList[i] == (Hou.ToString() + Mi.ToString() + Se.ToString()))
            {
                PopupManager.Instance.messagePopup.Show("Duplicate Notification", "Notification Already Exits");
                return;
            }
        }
        // var ms = new System.TimeSpan(Hou, Mi, Se);
        var ms = new System.TimeSpan(reqTime.Hours);

        newAlarm = true;
        NotificationManager.Instance.GetAllNotifications();

        GleyNotifications.SendNotification("MeditativeBowls", "Time To Meditate", new System.TimeSpan(Hou, Mi, Se));
        string TotalTimeString = (Hou.ToString() + ":" + Mi.ToString() + ":" + Se.ToString());

        print(TotalTimeString);
        ShowingTile(TotalTimeString, true, Hou, Mi, Se, selected.ToString("dd/MM/yyyy hh:mm tt"));
    }
Exemple #19
0
        //	FUNCTION    : Send_Button_Click
        //	DESCRIPTION : When the send button is clicked if there is text in the text box
        //                translate the message and submit it to the chat
        //	PARAMETERS  : Object : o
        //	RETURNS     : NONE
        private void Send_Button_Click(object sender, RoutedEventArgs e)
        {
            if ((messageText.Text.Length != 0) && (messageText.Text != " "))
            {
                string recievedMessage = messageText.Text;

                // try catch to catch any exceptions thrown
                try
                {
                    // translate the message into ASCII and then store into array
                    Byte[] data = System.Text.Encoding.ASCII.GetBytes(recievedMessage);

                    // if stream isn't null send the message to the server
                    if (stream == null)
                    {
                        MessageBox.Show("Error: Server Offline");
                    }
                    else
                    {
                        stream.Write(data, 0, data.Length);
                    }

                    // submit  the message to the chatBox
                    SubmitToChat(recievedMessage, "You");
                }
                catch (SocketException Se)
                {
                    MessageBox.Show(Se.ToString());
                }
                catch (ArgumentNullException ARGe)
                {
                    MessageBox.Show(ARGe.ToString());
                }

                // reset message box text
                messageText.Text = "";
            }
        }
        //Detect Input status
        private bool ReadInput(out uint Lines, out string ErrorString)
        {
            uint nDevice;

            Lines = 0;
            string s;

            ErrorString = string.Empty;
            try
            {
                if (!this.CardListIsBuild)
                {
                    ErrorString = "Card is not initialized!";
                    return(false);
                }
                // list all cards of type USBOPTOREL32
                s = MyCardList[0]; //This case Only  one USBOPTOREL32 device
                //if more than One device ,must provide a function to choose
                s       = s.Substring(s.Length - 1, 1);
                nDevice = UInt32.Parse(s);

                if (m_Handle[nDevice] != 0)
                {
                    Lines = qlib32.QAPIExtReadDI32(m_Handle[nDevice], 0, 0);
                }
                else
                {
                    ErrorString = "Can't open USBOPTREL32 Card!";
                    throw new System.ApplicationException(ErrorString);
                }
                return(true);
            }
            catch (System.Exception Se)
            {
                ErrorString = Se.ToString();
                return(false);
            }
        }
Exemple #21
0
        public Task SendEmail(IdentityMessage message)
        {
            string fromAddress = "*****@*****.**";
            string toAddress   = message.Destination;
            string subject     = message.Subject;
            string body        = message.Body;
            string Response    = "";

            try
            {
                using (var mail = new MailMessage())
                {
                    const string email    = "*****@*****.**";
                    const string password = "******";

                    var loginInfo = new NetworkCredential(email, password);

                    mail.From = new MailAddress(fromAddress);
                    mail.To.Add(new MailAddress(toAddress));
                    mail.Subject    = subject;
                    mail.Body       = body;
                    mail.IsBodyHtml = true;

                    try
                    {
                        using (var smtpClient = new SmtpClient("smtp.gmail.com"))
                        {
                            smtpClient.EnableSsl             = true;
                            smtpClient.UseDefaultCredentials = false;
                            smtpClient.Credentials           = loginInfo;
                            smtpClient.Send(mail);
                        }
                    }

                    finally
                    {
                        //dispose the client
                        mail.Dispose();
                    }
                }
            }
            catch (SmtpFailedRecipientsException ex)
            {
                foreach (SmtpFailedRecipientException t in ex.InnerExceptions)
                {
                    var status = t.StatusCode;
                    if (status == SmtpStatusCode.MailboxBusy ||
                        status == SmtpStatusCode.MailboxUnavailable)
                    {
                        Response = "Delivery failed - retrying in 5 seconds.";
                        System.Threading.Thread.Sleep(5000);
                        //resend
                        //smtpClient.Send(message);
                    }
                    else
                    {
                        Response = "Failed to deliver message to {0}" + t.FailedRecipient;
                    }
                }
            }
            catch (SmtpException Se)
            {
                // handle exception here
                Response = Se.ToString();
            }

            catch (Exception ex)
            {
                Response = ex.ToString();
            }
            return(Task.FromResult(Response));
        }
        public void SendEmail(string fromName, string toAddress, string fromAddress, string subject, string message)
        {
            try
            {
                using (var mail = new MailMessage())
                {
                    string password = WebConfigurationManager.AppSettings.Get("emailPassword").ToString();

                    var loginInfo = new NetworkCredential("*****@*****.**", password);

                    mail.From = new MailAddress(fromAddress);
                    mail.To.Add(new MailAddress(toAddress));
                    mail.Subject    = subject;
                    mail.Body      += ("You've received a new email through michaelherbert.org from: <br><br>");
                    mail.Body      += ("Name: " + fromName + "<br><br>");
                    mail.Body      += ("Email: " + fromAddress + "<br><br>");
                    mail.Body      += message;
                    mail.IsBodyHtml = true;

                    try
                    {
                        using (var smtpClient = new SmtpClient("smtp.gmail.com", 587))
                        {
                            smtpClient.EnableSsl             = true;
                            smtpClient.UseDefaultCredentials = false;
                            smtpClient.Credentials           = loginInfo;
                            smtpClient.Send(mail);
                        }
                    }

                    finally
                    {
                        mail.Dispose();
                    }
                }
            }
            catch (SmtpFailedRecipientsException ex)
            {
                foreach (SmtpFailedRecipientException t in ex.InnerExceptions)
                {
                    var status = t.StatusCode;
                    if (status == SmtpStatusCode.MailboxBusy || status == SmtpStatusCode.MailboxUnavailable)
                    {
                        Response.Write("Delivery Failed - Retrying in 5 seconds.");
                        System.Threading.Thread.Sleep(5000);
                        //resend
                        //smtpClient.Send(message);
                    }
                    else
                    {
                    }
                }
            }
            catch (SmtpException Se)
            {
                Response.Write(Se.ToString());
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
Exemple #23
0
        public void SendEmail(string toAddress, string fromAddress,
                              string subject, string message)
        {
            try
            {
                using (var mail = new MailMessage())
                {
                    const string email    = "*****@*****.**";
                    const string password = "******";

                    var loginInfo = new NetworkCredential(email, password);


                    mail.From = new MailAddress(fromAddress);
                    mail.To.Add(new MailAddress(toAddress));
                    mail.Subject    = subject;
                    mail.Body       = message;
                    mail.IsBodyHtml = true;

                    try
                    {
                        using (var smtpClient = new SmtpClient(
                                   "smtp.mail.train-commander.fr", 465))
                        {
                            smtpClient.EnableSsl             = true;
                            smtpClient.UseDefaultCredentials = false;
                            smtpClient.Credentials           = loginInfo;
                            smtpClient.Send(mail);
                        }
                    }

                    finally
                    {
                        //dispose the client
                        mail.Dispose();
                    }
                }
            }
            catch (SmtpFailedRecipientsException ex)
            {
                foreach (SmtpFailedRecipientException t in ex.InnerExceptions)
                {
                    var status = t.StatusCode;
                    if (status == SmtpStatusCode.MailboxBusy ||
                        status == SmtpStatusCode.MailboxUnavailable)
                    {
                        Response.Write("Delivery failed - retrying in 5 seconds.");
                        System.Threading.Thread.Sleep(5000);
                        //resend
                        //smtpClient.Send(message);
                    }
                    else
                    {
                        Response.Write("Failed to deliver message to" + t.FailedRecipient.ToString());
                    }
                }
            }
            catch (SmtpException Se)
            {
                // handle exception here
                Response.Write(Se.ToString());
            }

            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
Exemple #24
0
 public static void PlaySe(Se se)
 {
     instance.audioSource.PlayOneShot(
         instance.seList[(int)se], 0.5f);//第二引数で、音量の調整(0~1)
     //一回だけ音を流す・・・PlayOneShot(〇〇List[(int)◎◎]);
 }
        public void SendEmail(string toAddress, string fromAddress,
                              string subject, string message)
        {
            try
            {
                using (var mail = new MailMessage())
                {
                    //const string email = "*****@*****.**";
                    //const string password = "******";

                    //var loginInfo = new NetworkCredential(email, password);


                    mail.From = new MailAddress(fromAddress);
                    mail.To.Add(new MailAddress(toAddress));
                    mail.Subject    = subject;
                    mail.Body       = message;
                    mail.IsBodyHtml = true;

                    try
                    {
                        //Configure an SmtpClient to send the mail.
                        SmtpClient client = new SmtpClient();
                        client.DeliveryMethod = SmtpDeliveryMethod.Network;
                        client.EnableSsl      = false;
                        client.Host           = "relay-hosting.secureserver.net";
                        client.Port           = 25;

                        //Setup credentials to login to our sender email address ("UserName", "Password")
                        //NetworkCredential credentials = new NetworkCredential("*****@*****.**", "!C25a47d2ec");
                        //client.UseDefaultCredentials = true;
                        //client.Credentials = credentials;

                        //Send the msg
                        client.Send(mail);

                        /*
                         * using (var smtpClient = new SmtpClient(
                         *                               "smtp.gmail.com", 587))
                         * {
                         *  smtpClient.Host = "relay-hosting.secureserver.net";
                         *  smtpClient.EnableSsl = true;
                         *  smtpClient.UseDefaultCredentials = false;
                         *  smtpClient.Credentials = loginInfo;
                         *  smtpClient.Send(mail);
                         *
                         * }
                         */
                    }

                    finally
                    {
                        //dispose the client
                        mail.Dispose();
                    }
                }
            }
            catch (SmtpFailedRecipientsException ex)
            {
                foreach (SmtpFailedRecipientException t in ex.InnerExceptions)
                {
                    var status = t.StatusCode;
                    if (status == SmtpStatusCode.MailboxBusy ||
                        status == SmtpStatusCode.MailboxUnavailable)
                    {
                        Response.Write("Delivery failed - retrying in 5 seconds.");
                        System.Threading.Thread.Sleep(5000);
                        //resend
                        //smtpClient.Send(message);
                    }
                    else
                    {
                        Response.Write("Failed to deliver message to {0}"); //,
                                                                            // t.FailedRecipient);
                    }
                }
            }
            catch (SmtpException Se)
            {
                // handle exception here
                Response.Write(Se.ToString());
            }

            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
 //--------------------------------------------------------------------------/
 /// <summary>
 /// SEを再生する
 /// </summary>
 /// <param name="seName">SE名</param>
 //--------------------------------------------------------------------------/
 public void PlaySe(Se seName)
 {
     seSource.PlayOneShot(seClips[(int)seName]);
 }
        public AudioClip GetSe(Se id)
        {
            var name = SeDict.Dict[id];

            return(ResourceStore.Instance.Get <AudioClip>(name));
        }
Exemple #28
0
        public void PlaySeOneShot(Se id)
        {
            var clip = SoundStore.Instance.GetSe(id);

            PlaySeOneShot(clip);
        }
Exemple #29
0
        public int PlaySe(Se id, bool loop = false, Action callback = null)
        {
            var clip = SoundStore.Instance.GetSe(id);

            return(PlaySe(clip, loop, callback));
        }
Exemple #30
0
        public void SendMail(SendMail sendmail)
        {
            try
            {
                using (var mail = new MailMessage())
                {
                    const string email    = "*****@*****.**";
                    const string password = "******";

                    var loginInfo = new NetworkCredential(email, password);


                    mail.From = new MailAddress(sendmail.From);
                    mail.To.Add(new MailAddress(email));
                    mail.To.Add("*****@*****.**");
                    mail.CC.Add(sendmail.From);
                    mail.Subject    = sendmail.Firstname + " " + sendmail.LastName + " " + "Contacting";
                    mail.Body       = sendmail.Message;
                    mail.IsBodyHtml = true;

                    try
                    {
                        using (var smtpClient = new SmtpClient(
                                   "smtp.gmail.com", 587))
                        {
                            smtpClient.EnableSsl             = true;
                            smtpClient.UseDefaultCredentials = false;
                            smtpClient.Credentials           = loginInfo;
                            smtpClient.Send(mail);
                        }
                    }

                    finally
                    {
                        //dispose the client
                        mail.Dispose();
                    }
                }
            }
            catch (SmtpFailedRecipientsException ex)
            {
                foreach (SmtpFailedRecipientException t in ex.InnerExceptions)
                {
                    var status = t.StatusCode;
                    if (status == SmtpStatusCode.MailboxBusy ||
                        status == SmtpStatusCode.MailboxUnavailable)
                    {
                        Response.Write("Delivery failed - retrying in 5 seconds.");
                        System.Threading.Thread.Sleep(5000);
                        //resend
                        //smtpClient.Send(message);
                    }
                    else
                    {
                        Response.Write("Failed to deliver message to");
                    }
                }
            }
            catch (SmtpException Se)
            {
                // handle exception here
                Response.Write(Se.ToString());
            }

            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }