Ejemplo n.º 1
0
        private string GetCustomProfilesDirectory(bool preferencesProfile)
        {
            string permanentSettingsDirectory = System.IO.Directory.GetParent(Settings_Permanent.GetSettingFilePath()).ToString();
            string filesDirectory             = preferencesProfile ? "profiles" : "keyboard-shortcuts";
            string customProfilesDirectory    = System.IO.Path.Combine(permanentSettingsDirectory, filesDirectory);

            return(customProfilesDirectory);
        }
Ejemplo n.º 2
0
 public UserRegistration(Settings_Permanent settings, Settings set)
     : this()
 {
     m_Settings = settings;
     if (settings.UploadAttemptsCount == MaxUploadAttemptsAllowed)
     {
         m_btnRemindMeLater.Text = Localizer.Message("UserRegistrationBtn_DoNotRemind");
     }
     if (set.ObiFont != this.Font.Name)
     {
         this.Font = new Font(set.ObiFont, this.Font.Size, FontStyle.Regular);//@fontconfig
     }
 }
Ejemplo n.º 3
0
        public static void OpenEmailToSend(Settings_Permanent settings)
        {
            m_Settings = settings;
            try
            {
                string tempStr = "mailto:[email protected]? Subject=User Registration &body=";

                String[] temp = m_Settings.UsersInfoToUpload.Split(',');
                foreach (string s in temp)
                {
                    tempStr += "%0A" + s;
                }
                Process.Start(tempStr);
                //m_Settings.UsersInfoToUpload = Registered ;
                m_Settings.RegistrationComplete = true;
                m_Settings.SaveSettings();
            }
            catch (System.Exception ex)
            {
                ProjectView.ProjectView.WriteToLogFile_Static(ex.ToString());
            }
        }
Ejemplo n.º 4
0
        public static void UploadUserInformation(Settings_Permanent settings)
        {
            if (settings == null || m_BackgroundWorker.IsBusy)
            {
                return;
            }
            m_Settings = settings;
            string fileName           = GenerateFileName();
            string uploadPath         = Code.UploadCode.UploadDirectoryPath + fileName;
            string userName           = Code.UploadCode.userName;
            string pass               = Code.UploadCode.Code;
            string dataToUpload       = settings.UsersInfoToUpload;
            bool   isUploadSuccessful = false;

            m_BackgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(delegate(object sender, System.ComponentModel.DoWorkEventArgs e)
            {
                if (m_CurrentCulture != null)
                {
                    System.Threading.Thread.CurrentThread.CurrentUICulture = m_CurrentCulture;
                }
                System.IO.MemoryStream memoryStream = null;
                System.IO.Stream stream             = null;

                try
                {
                    byte[] byteArray = Encoding.UTF8.GetBytes(dataToUpload);
                    memoryStream     = new System.IO.MemoryStream(byteArray);

                    // Create FtpWebRequest object
                    FtpWebRequest ftpRequest = (System.Net.FtpWebRequest)System.Net.FtpWebRequest.Create(new Uri(uploadPath));
                    // Provide username and password
                    ftpRequest.Credentials = new System.Net.NetworkCredential(userName, pass);

                    // after a command is executed, do not keep connection alive
                    ftpRequest.KeepAlive = false;
                    ftpRequest.Timeout   = 30000;
                    // Specify the command to be executed
                    ftpRequest.Method    = System.Net.WebRequestMethods.Ftp.UploadFile;
                    ftpRequest.UseBinary = true;

                    ftpRequest.ContentLength = memoryStream.Length;
                    // buffer size is kept 2kb.
                    int bufferLength = 2048;
                    byte[] buff      = new byte[bufferLength];

                    stream = ftpRequest.GetRequestStream();
                    // Read the memory stream 2kb at a time and copy to ftpStream
                    int dataLength = memoryStream.Read(buff, 0, bufferLength);

                    while (dataLength != 0)
                    {
                        // Write Content from the memory stream to the FTP Upload Stream.
                        stream.Write(buff, 0, dataLength);
                        dataLength = memoryStream.Read(buff, 0, bufferLength);
                    }
                    isUploadSuccessful = true;
                }
                catch (System.Exception ex)
                {
                    m_Settings.UploadAttemptsCount++;
                    m_Settings.SaveSettings();
                    Console.WriteLine(ex.ToString());
                    ProjectView.ProjectView.WriteToLogFile_Static(ex.ToString());
                }
                finally
                {
                    if (stream != null)
                    {
                        stream.Close();
                        stream.Dispose();
                    }
                    if (memoryStream != null)
                    {
                        memoryStream.Close();
                        memoryStream.Dispose();
                    }
                }
            });

            m_BackgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(delegate(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
            {
                if (m_CurrentCulture != null)
                {
                    System.Threading.Thread.CurrentThread.CurrentUICulture = m_CurrentCulture;
                }
                if (!isUploadSuccessful)
                {
                    return;
                }
                try
                {
                    FtpWebRequest ftpRequest = (System.Net.FtpWebRequest)System.Net.FtpWebRequest.Create(new Uri(uploadPath));
                    ftpRequest.Credentials   = new System.Net.NetworkCredential(userName, pass);
                    ftpRequest.KeepAlive     = false;
                    ftpRequest.Timeout       = 20000;
                    ftpRequest.Method        = WebRequestMethods.Ftp.GetFileSize;
                    ftpRequest.UseBinary     = true;

                    // if successful then update settings for the same

                    if (ftpRequest.GetResponse().ContentLength > 0)
                    {
                        Console.WriteLine("registered");
                        //m_Settings.UsersInfoToUpload = Registered;
                        m_Settings.RegistrationComplete = true;
                        m_Settings.SaveSettings();
                        //MessageBox.Show("done");
                    }
                    else
                    {
                        m_Settings.UploadAttemptsCount++;
                        m_Settings.SaveSettings();
                    }
                }
                catch (System.Exception ex)
                {
                    m_Settings.UploadAttemptsCount++;
                    m_Settings.SaveSettings();
                    Console.WriteLine(ex.ToString());
                    ProjectView.ProjectView.WriteToLogFile_Static(ex.ToString());
                }
            });
            m_BackgroundWorker.RunWorkerAsync();
        }