Exemple #1
0
        private bool WriteCommand(NextLine cmd)
        {
            if (cmd == null)
            {
                return(false);
            }

            Write("T*");

            return(true);
        }
        private void Tick()
        {
            if (!Focused || !Capture)
            {
                List <string> NewLines = new List <string>();
                for (;;)
                {
                    string NextLine;
                    if (!QueuedLines.TryDequeue(out NextLine))
                    {
                        break;
                    }
                    NewLines.Add(NextLine.TrimEnd('\r', '\n') + "\n");
                }
                if (NewLines.Count > 0)
                {
                    StringBuilder TextToAppendBuilder = new StringBuilder();
                    foreach (string NewLine in NewLines)
                    {
                        TextToAppendBuilder.AppendLine(NewLine.TrimEnd('\n'));
                    }

                    string TextToAppend = TextToAppendBuilder.ToString();
                    if (LogFileStream != null)
                    {
                        byte[] Data = Encoding.UTF8.GetBytes(TextToAppend);
                        try
                        {
                            LogFileStream.Write(Data, 0, Data.Length);
                            LogFileStream.Flush();
                        }
                        catch (Exception Ex)
                        {
                            TextToAppend += String.Format("Failed to write to log file ({0}): {1}\n", LogFileStream.Name, Ex.ToString());
                        }
                    }

                    AddLinesInternal(NewLines);
                }
            }
        }
        private static void CopyStoredPlayerSettingsOverCurrent(string TargetDirectory)
        {
            string[] SourceFilesPaths = Directory.GetFiles(TargetDirectory);

            if (SourceFilesPaths.Length > 0)
            {
                Debug.Log("Overriding player settings with data from " + TargetDirectory + "...");
                foreach (string SourceFilePath in SourceFilesPaths)
                {
                    string DestFilePath = SourceFilePath.Replace(TargetDirectory, "ProjectSettings");
                    DestFilePath = Path.ChangeExtension(DestFilePath, ".asset");
                    IgorRuntimeUtils.CopyFile(SourceFilePath, DestFilePath, true);

                    Debug.Log("Replaced " + Path.GetFileName(DestFilePath));

                    // We need to find the ProjectSettings file and locate the defines text manually because otherwise
                    // the recompile (if it even triggers; it's inconsistent) won't use the new defines.
                    const string ScriptingDefineSymbolsTag = "scriptingDefineSymbols:\n";
                    if (DestFilePath.Contains("ProjectSettings.asset"))
                    {
                        string ProjectSettingsText = File.ReadAllText(SourceFilePath);
                        int    StartIndex          = ProjectSettingsText.IndexOf(ScriptingDefineSymbolsTag) + ScriptingDefineSymbolsTag.Length;
                        string StartOfDefinesBlock = ProjectSettingsText.Substring(StartIndex);

                        HashSet <BuildTargetGroup> MatchedBuildTargetGroups = new HashSet <BuildTargetGroup>();

                        string       NextLine;
                        StringReader StringReader = new StringReader(StartOfDefinesBlock);
                        bool         bContinue    = true;
                        do
                        {
                            NextLine = StringReader.ReadLine();
                            if (NextLine != null)
                            {
                                NextLine = NextLine.Trim();
                                if (NextLine.Length > 0 && char.IsNumber(NextLine[0]))
                                {
                                    int    IndexOfColon   = NextLine.IndexOf(':');
                                    string BuildGroupText = NextLine.Substring(0, IndexOfColon);
                                    string Define         = NextLine.Substring(IndexOfColon + 1);

                                    int BuildGroupAsInt = 0;
                                    Int32.TryParse(BuildGroupText, out BuildGroupAsInt);
                                    BuildTargetGroup TargetGroup = (BuildTargetGroup)BuildGroupAsInt;

                                    if (TargetGroup != BuildTargetGroup.Unknown)
                                    {
                                        PlayerSettings.SetScriptingDefineSymbolsForGroup(TargetGroup, Define);
                                        MatchedBuildTargetGroups.Add(TargetGroup);
                                    }
                                }
                                else
                                {
                                    bContinue = false;
                                }
                            }
                        }while(bContinue);

                        // Make sure we wipe out defines on any other build targets.
                        BuildTargetGroup[] AllTargetGroups = System.Enum.GetValues(typeof(BuildTargetGroup)) as BuildTargetGroup[];
                        foreach (BuildTargetGroup Group in AllTargetGroups)
                        {
                            if (!MatchedBuildTargetGroups.Contains(Group))
                            {
                                PlayerSettings.SetScriptingDefineSymbolsForGroup(Group, string.Empty);
                            }
                        }
                    }
                }

                AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
            }
        }
Exemple #4
0
        // This will run when the form is loaded
        private void Form1_Load(object sender, EventArgs e)
        {
            // Holds the file path for the base directory (the same one containing the .exe file)
            string DataPath = AppDomain.CurrentDomain.BaseDirectory + "\\data.txt";

            // These will be used to store and assign values to CSV data
            string NextLine;

            string[] SplitLine = new string[7];
            int      HeadCount = 0;

            string[] Headers = new string[7];

            // This creates a new list to store Developer objects
            List <Developer> Developers = new List <Developer>();

            // This will read the .txt file and create developer objects with the data in comma delimited format
            System.IO.StreamReader CommaDelimitedInput = new System.IO.StreamReader(@DataPath);
            while ((NextLine = CommaDelimitedInput.ReadLine()) != null)
            {
                SplitLine = NextLine.Split(',');

                // Stores the first line as header information for the table
                if (HeadCount != 1)
                {
                    for (int n = 0; n < SplitLine.Length; n++)
                    {
                        Headers[n] = SplitLine[n].Trim();
                    }
                    HeadCount++;
                }
                // Otherwise, create a new Developer object using the data
                else
                {
                    Developers.Add(new Developer(SplitLine[0].Trim(), SplitLine[1].Trim(), Convert.ToInt32(SplitLine[2].Trim()), Convert.ToDouble(SplitLine[3].Trim()), SplitLine[4].Trim(), SplitLine[5].Trim(), SplitLine[6].Trim()));
                }
            }

            // Closes the data.txt file since the information needed is stored appropriately
            CommaDelimitedInput.Close();

            // Create information for a new DataTable and add header information from the file specifying the data type
            DataTable EmployeeDataTable = new DataTable();

            EmployeeDataTable.Columns.Add(Headers[0], typeof(string));
            EmployeeDataTable.Columns.Add(Headers[1], typeof(string));
            EmployeeDataTable.Columns.Add(Headers[2], typeof(int));
            EmployeeDataTable.Columns.Add(Headers[3], typeof(double));
            EmployeeDataTable.Columns.Add(Headers[4], typeof(string));
            EmployeeDataTable.Columns.Add(Headers[5], typeof(string));
            EmployeeDataTable.Columns.Add(Headers[6], typeof(string));

            // Add entries for each developer object that was read and stored from the data.txt file
            foreach (Developer _dev in Developers)
            {
                EmployeeDataTable.Rows.Add(_dev.Name, _dev.Address, _dev.Age, _dev.GrossPay, _dev.Department, _dev.DeveloperType, _dev.TaxType);
            }

            // Finally, populate the data grid in the form using the information above
            dataGridView1.DataSource = EmployeeDataTable;
        }
Exemple #5
0
        static void Main(string[] args)
        {
            // Create a new Scanner object (defined on line 280) which handles the collection
            // of user input and includes limited validation for types string and double
            Scanner InputScanner = new Scanner();

            // Create a list of Software Developers as Employee objects
            List <Employee> Employees = new List <Employee>();

            Console.WriteLine("D. Paul Barden, POS/408, Week 5");
            Console.WriteLine("Welcome to Software Development, LLC");
            Console.WriteLine("=================================");
            Console.WriteLine("");

            // create a counter to hold the number of developers to increase for loop below
            int counter = 0;

            while (counter < 5)
            {
                Console.WriteLine("Please enter the number of developers (must be at least 5):");
                counter = Convert.ToInt16(Console.ReadLine());
            }

            // actions are performed n times, one for each employee
            // as per the application requirements
            for (int n = 0; n < counter; n++)
            {
                // Use the Scanner object to read user input. The user prompt is passed in.
                // InputScanner() returns a string which is assigned to the UserInput string variable
                string UserInput = InputScanner.Read("Please enter a name for employee " + (n + 1) + " (Software Developer): ");

                // Create a new Employee object using the name assigned to the UserInput variable above
                // Employee SoftwareDeveloper = new Employee(UserInput);
                Employees.Add(new Employee(UserInput));

                // InputScanner() returns a string which is assigned to the UserInput string variable
                UserInput = InputScanner.Read("Please enter the employment type for " + Employees[n].GetName() + ": ");
                bool EmpTypeCheck = false;

                // checks for possible variations of W-2 and correct them
                if ((UserInput.ToUpper() == "W2") || (UserInput.ToUpper() == "W-2"))
                {
                    // correct user input and set the boolean to true to bypass the while loop below
                    UserInput    = "W-2";
                    EmpTypeCheck = true;
                }

                // if the user input is acceptable, set the boolean to true to bypass the while loop below
                if ((UserInput == "1099") || (UserInput == "W-2"))
                {
                    EmpTypeCheck = true;
                }

                // if input wasn't acceptable and the boolean wasn't set, this loop executes until
                // the user inputs an acceptable answer for the employment type
                while (!EmpTypeCheck)
                {
                    // display error message to user
                    Console.WriteLine("Incorrect format. Please enter '1099' or 'W-2'.");
                    Console.WriteLine("");

                    // prompt for another entry and perform checks/corrections
                    UserInput = InputScanner.Read("Please enter the employment type for " + Employees[n].GetName() + ": ");
                    if ((UserInput.ToUpper() == "W2") || (UserInput.ToUpper() == "W-2"))
                    {
                        UserInput    = "W-2";
                        EmpTypeCheck = true;
                    }
                    else if (UserInput == "1099")
                    {
                        EmpTypeCheck = true;
                    }
                }

                // set employee type if it passes the above error checks
                Employees[n].SetEmploymentType(UserInput);

                // InputScanner() returns a string which is assigned to the UserInput string variable
                UserInput = InputScanner.Read("Please enter an address for " + Employees[n].GetName() + ": ");

                // Use UserInput to assign a new address to the employee
                Employees[n].SetAddress(UserInput);

                // InputScanner() returns a double which is assigned to the UserNumInput double variable
                double UserNumInput = InputScanner.ReadDouble("Please enter a monthly pay rate for " + Employees[n].GetName() + ": ");
                Employees[n].SetMonthlyGrossPay(UserNumInput);

                if (Employees[n].GetEmploymentType() == "W-2")
                {
                    // Sets a tax rate for W-2 employees
                    Employees[n].SetTaxRate(7.0);
                }

                // Create space bwtween sets of input for easier viewing
                Console.WriteLine("");
            }

            // create array to store csv line values
            string[] CommaDelimitedValues = new string[counter];
            string   BuildCSV             = "";

            for (int n = 0; n < counter; n++)
            {
                // Display all employee information stored
                // Now updated to display each employee's info
                string _Name        = Employees[n].GetName();
                string _EmpType     = Employees[n].GetEmploymentType();
                string _Addr        = Employees[n].GetAddress();
                double _GrossMo     = Employees[n].GetMonthlyGrossPay();
                double _GrossYr     = Employees[n].GetYearlyGrossPay();
                double _TaxRate     = Employees[n].GetTaxRate();
                double _MoTaxPaid   = Employees[n].GetTaxesPaid();
                double _NetMo       = Employees[n].GetNetPay();
                double _YrTaxesPaid = Employees[n].GetYearlyTaxesPaid();
                double _NetYr       = Employees[n].GetYearlyNetPay();

                Console.WriteLine("");
                Console.WriteLine("Employee " + (n + 1) + " Role: Software Developer");
                Console.WriteLine("=================================");
                Console.WriteLine("Name: {0}", _Name);
                Console.WriteLine("Employment Type: {0}", _EmpType);
                Console.WriteLine("Address: {0}", _Addr);
                Console.WriteLine("Monthly Gross Pay: ${0:n2}", _GrossMo);
                Console.WriteLine("Yearly Gross Pay: ${0:n2}", _GrossYr);
                Console.WriteLine("Tax Rate: {0}%", _TaxRate);
                Console.WriteLine("Monthly Taxes Paid: ${0:n2}", _MoTaxPaid);
                Console.WriteLine("Monthly Net Pay: ${0:n2}", _NetMo);
                Console.WriteLine("Yearly Taxes Paid: ${0:n2}", _YrTaxesPaid);
                Console.WriteLine("Yearly Net Pay: ${0:n2}", _NetYr);
                Console.WriteLine("");

                // format data for csv
                BuildCSV = _Name + ", " + _EmpType + ", " + _Addr + ", " + _GrossMo + ", " + _GrossYr + ", " + _TaxRate + ", " + _MoTaxPaid + ", " + _NetMo + ", " + _YrTaxesPaid + ", " + _NetYr + ", ";
                CommaDelimitedValues[n] = BuildCSV;
            }

            // collect file path from the user
            string FilePath = InputScanner.Read("Please enter the CSV output path (enter the folder name, not the expected file name): ");

            // append file name
            FilePath += "\\data.txt";

            // create csv and add data for each array item by index
            using (System.IO.StreamWriter MyCSV = new System.IO.StreamWriter(@FilePath))
            {
                for (int n = 0; n < counter; n++)
                {
                    MyCSV.WriteLine(CommaDelimitedValues[n]);
                }
                MyCSV.Close();
            }

            // read the csv that was just created
            int    LineCounter = 0;
            string NextLine;

            string[] SplitLine = new string[10];

            // read the file and display the information back onto the screen
            System.IO.StreamReader MyCSVInput = new System.IO.StreamReader(@FilePath);
            while ((NextLine = MyCSVInput.ReadLine()) != null)
            {
                SplitLine = NextLine.Split(',');

                Console.WriteLine("");
                Console.WriteLine("Employee Role: Software Developer");
                Console.WriteLine("=================================");
                Console.WriteLine("Name: {0}", SplitLine[0]);
                Console.WriteLine("Employment Type: {0}", SplitLine[1]);
                Console.WriteLine("Address: {0}", SplitLine[2]);
                Console.WriteLine("Monthly Gross Pay: ${0:n2}", Convert.ToDouble(SplitLine[3]));
                Console.WriteLine("Yearly Gross Pay: ${0:n2}", Convert.ToDouble(SplitLine[4]));
                Console.WriteLine("Tax Rate: {0}%", Convert.ToDouble(SplitLine[5]));
                Console.WriteLine("Monthly Taxes Paid: ${0:n2}", Convert.ToDouble(SplitLine[6]));
                Console.WriteLine("Monthly Net Pay: ${0:n2}", Convert.ToDouble(SplitLine[7]));
                Console.WriteLine("Yearly Taxes Paid: ${0:n2}", Convert.ToDouble(SplitLine[8]));
                Console.WriteLine("Yearly Net Pay: ${0:n2}", Convert.ToDouble(SplitLine[9]));
                Console.WriteLine("");

                LineCounter++;
            }

            MyCSVInput.Close();

            // Added to prevent the application from closing until user has a chance to view information output above
            Console.WriteLine("Press ENTER to exit the program.");
            string NewInput = Console.ReadLine();
        }
Exemple #6
0
        public bool Run(params object[] args)
        {
            string NextLine;
            double result     = 0;
            double lastValue  = 0;
            int    numberLine = 0;
            string outInfo;
            char   operationType;
            var    mathBuffer    = (ValuesBuffer)args[0];
            var    historyBuffer = (HistoryOperations)args[2];
            Socket socket        = (Socket)args[3];

            ServerIO _ServerIO = new ServerIO(socket);

            mathBuffer.variables.Clear();
            mathBuffer.TopValue = 0;

            _ServerIO.WriteLine("Enter file name without extension:");
            string pathFile = Directory.GetCurrentDirectory() + "\\" + _ServerIO.ReadString() + ".txt";

            if (!File.Exists(pathFile))
            {
                _ServerIO.WriteLine("Such file does not exist");
                return(true);
            }


            using (var file = new StreamReader(pathFile))
            {
                while ((NextLine = file.ReadLine()) != null)
                {
                    numberLine++;
                    string[] ParseLine = NextLine.Split(' ');

                    switch (ParseLine.Length)
                    {
                    case 1:
                        outInfo = ParseLine[0];
                        if (Double.TryParse(outInfo, out result))
                        {
                            _ServerIO.WriteLine($"[#{numberLine}] - {result}");
                            mathBuffer.HideSaveValue(result);
                        }
                        else
                        {
                            result = ConvertToInteger(outInfo);
                            _ServerIO.WriteLine($"[#{numberLine}] - {outInfo} = {result}");
                            mathBuffer.HideSaveValue(result);
                        }
                        break;

                    case 3:
                        outInfo       = ParseLine[0];
                        operationType = Convert.ToChar(ParseLine[1]);
                        result        = Convert.ToDouble(ParseLine[2]);
                        lastValue     = SearchLastValue(operationType, mathBuffer.ReturnTopValue(), result);
                        _ServerIO.WriteLine($"[#{numberLine}] - {outInfo} {operationType} {lastValue} = " +
                                            $"{mathBuffer.ReturnTopValue()} {operationType} {lastValue} = {result}");
                        mathBuffer.HideSaveValue(result);
                        break;

                    default:
                        _ServerIO.Write("Parse error!\n");
                        break;
                    }
                }
            }


            return(true);
        }
Exemple #7
0
        private bool WriteCommand(NextLine cmd)
        {
            if (cmd == null)
                return false;

            Write("T*");

            return true;
        }
Exemple #8
0
        public static void Load(string FileName)
        {
            string NextLine;

            cfg.Clear();

            try
            {
                if (File.Exists(FileName))
                {
                    StreamReader sr = new StreamReader(FileName, System.Text.Encoding.GetEncoding(1251));

                    while ((NextLine = sr.ReadLine()) != null)
                    {
                        if (NextLine.Trim() == "")
                        {
                            continue;
                        }
                        if (NextLine.Trim().Substring(0, 1) == "#")
                        {
                            continue;
                        }

                        int pos = NextLine.IndexOf(' ');
                        if (pos != -1) //NextLine[pos] = '\t';
                        {
                            NextLine = NextLine.Remove(pos, 1).Insert(pos, "\t");
                        }
                        //NextLine = NextLine.Replace("  ", " ");
                        //NextLine = NextLine.Replace("  ", " ");
                        string[] a = NextLine.Trim().Split('\t');
                        if (a.Length > 1)
                        {
                            cfg.Add(a[0].Trim(), a[1].Trim());
                        }
                    }
                    sr.Close();
                    commandMySQLTimeout = Convert.ToInt32(GetValue("MySQL_Timeout", "1000"));
                }
                else
                {
                    WriteLog("Нет файла конфигурации");
                    Environment.Exit(-1);
                }
            }
            catch (Exception e)
            {
                WriteLog(String.Format("The process Parse CFG failed: {0}", e.ToString()));
                Environment.Exit(-1);
            }

            if (!cfg.ContainsKey("TimeoutWriteKKM"))
            {
                cfg.Add("TimeoutWriteKKM", "30");
            }
            if (!cfg.ContainsKey("TimeoutReadKKM"))
            {
                cfg.Add("TimeoutReadKKM", "30");
            }

            if (!cfg.ContainsKey("SMS_Server"))
            {
                cfg.Add("SMS_Server", "");
            }
            if (!cfg.ContainsKey("SMS_User"))
            {
                cfg.Add("SMS_User", "");
            }
            if (!cfg.ContainsKey("SMS_Passwd"))
            {
                cfg.Add("SMS_Passwd", "");
            }
            if (!cfg.ContainsKey("SMS_Baza"))
            {
                cfg.Add("SMS_Baza", "");
            }

            if (!cfg.ContainsKey("MySQL_Server"))
            {
                cfg.Add("MySQL_Server", "");
            }
            if (!cfg.ContainsKey("MySQL_User"))
            {
                cfg.Add("MySQL_User", "");
            }
            if (!cfg.ContainsKey("MySQL_Passwd"))
            {
                cfg.Add("MySQL_Passwd", "");
            }
            if (!cfg.ContainsKey("Shop_Export"))
            {
                cfg.Add("Shop_Export", "20");
            }
        }