MATLABfromCSharp.MainControl.importLog C# (CSharp) Method

importLog() public method

Imports a saved file into Matlab.
public importLog ( string path ) : string[]
path string The path to the importe File.
return string[]
        public string[] importLog(string path)
        {
            try
            {
                string[] lines = LogSystem.ImportLog(path);
                foreach (string line in lines)
                {
                    if (line != string.Empty)
                    {
                        string[] info = Regex.Split(line, @"=");
                        mainForm.Status("Importing: " + info[1] + " as " + info[0]);

                        if (info.Length == 2)
                        {
                            _curServer = info[0];
                            _curDatabase = info[1];
                        }
                        else if (info.Length == 6) //Absolute Time
                        {
                            if (info[5] != string.Empty)
                                mainForm.dataPrefDialog.setupDataPreferences(info[5]);
                            string srv_db = "'" + _curServer + "'_'" + _curDatabase + "'";
                            if (info[2] == "PI.Point")
                                getPIData(info[1], _curServer, info[0], info[3], info[4], true);
                            else
                                getAFData(srv_db, info[1], info[0], info[2], info[3], info[4], true);
                        }
                        else // Dates
                        {
                            string[] time = Regex.Split(info[3], @"-");
                            if (info[4] != string.Empty)
                                mainForm.dataPrefDialog.setupDataPreferences(info[4]);
                            string srv_db = "'" + _curServer + "'_'" + _curDatabase + "'";
                            if (info[2] == "PI.Point")
                                getPIData(info[1], _curServer, info[0], time[0], time[1], true);
                            else
                            {
                                try
                                {
                                    List<string> paths = new List<string>() { info[2] };
                                    AFKeyedResults<string, AFEventFrame> frames = AFEventFrame.FindEventFramesByPath(paths, null);

                                    int i = frames.Count;
                                    AFEventFrame frame = frames[paths[0]];
                                    AFAccess.getEventFrameData(srv_db, info[1], info[0], frame, true);

                                }
                                catch
                                {
                                    getAFData(srv_db, info[1], info[0], info[2], time[0], time[1], true);
                                }
                            }

                        }
                    }
                }
            }
            catch
            {
                mainForm.Status("ERROR: Invalid import file. Please choose a different file.");
            }
            return new string[] { _curServer, _curDatabase };
        }