Exemple #1
0
        static void Main(string[] args)
        {
            RecorderController frmRecorderController = new RecorderController();

            Application.EnableVisualStyles();
            Application.Run(frmRecorderController);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            VideoCaptureController.EnsureWeHaveAFileWithCSVPathInIt();

            RecorderController frmRecorderController = new RecorderController();

            Application.EnableVisualStyles();
            Application.Run(frmRecorderController);
        }
Exemple #3
0
 public static bool EnsureWeHaveAFileWithCSVPathInIt(string sNewCSVPath = null)
 {
     if (null != sNewCSVPath && false == File.Exists(sNewCSVPath))
     {
         return(false);
     }
     if (false == File.Exists(sFileContainingInfoAboutCSVFilePath))
     {
         File.WriteAllText(sFileContainingInfoAboutCSVFilePath, sNewCSVPath ?? "../OAStudioLog"
                           + DateTime.Now.Year.ToString()
                           + RecorderController.add_zeros(DateTime.Now.Month.ToString())
                           + RecorderController.add_zeros(DateTime.Now.Day.ToString())
                           + ".csv");
         return(true);
     }
     else
     {
         if (null != sNewCSVPath)
         {
             File.WriteAllText(sFileContainingInfoAboutCSVFilePath, sNewCSVPath);
         }
         return(true);
     }
 }
Exemple #4
0
        /// <summary>
        /// amocmebs CSV fails, aris tu ara axali gadacemis chanaceri
        /// </summary>
        /// <returns>abrunebs true-s tu axali gadacema daicko, tuarada false-s.</returns>
        public static bool nextCSVResult(out string sShemdegiGadacemisSaxeli
                                         , out DateTime dtAxaliGadacemisDackebisDro)
        {
            //string[] lsAllLines = File.ReadAllLines(File.ReadAllText(VideoCaptureController.sFileContainingInfoAboutCSVFilePath));

            FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create("ftp://92.241.90.13/" + "OAStudioLog"
                                                                    + DateTime.Now.Year.ToString()
                                                                    + RecorderController.add_zeros(DateTime.Now.Month.ToString())
                                                                    + RecorderController.add_zeros(DateTime.Now.Day.ToString())
                                                                    + ".csv");

            ftp.Credentials = new NetworkCredential("log", "log");
            ftp.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);//nocachenostore?
            try
            {
                System.Net.FtpWebResponse resp = (FtpWebResponse)ftp.GetResponse();
                StreamReader csv = new StreamReader(resp.GetResponseStream(), Encoding.ASCII);
                //
                string[] lsAllLines = csv.ReadToEnd().Replace("\r", "").Split('\n');
                //
                int lastValidLineNum = lsAllLines.Length - 1;
                while ("" == lsAllLines[lastValidLineNum] ||
                       lsAllLines[lastValidLineNum].Split(',').Length < 7 ||
                       "On Air Studio terminated" == lsAllLines[lastValidLineNum].Split(',')[6] ||
                       (lsAllLines[lastValidLineNum].Split(',').Length > 7 && "Playback Stopped" == lsAllLines[lastValidLineNum].Split(',')[7]) ||
                       !(lsAllLines[lastValidLineNum].LastIndexOf(',') > lsAllLines[lastValidLineNum].IndexOf(',')) ||
                       !("RED" == lsAllLines[lastValidLineNum].Split(',')[1] || "PLAY" == lsAllLines[lastValidLineNum].Split(',')[1] || "NEWS PLAY" == lsAllLines[lastValidLineNum].Split(',')[1])
                       )
                {
                    if (0 > lastValidLineNum)
                    {
                        Console.WriteLine("CSV File not valid. Press any key to exit!");
                        Console.ReadLine();
                        Application.Exit();
                        break;
                    }
                    lastValidLineNum--;
                }
                if (lsAllLines.Length > unLineCountLastTime &&
                    sGadacemisSaxeliLastTime != lsAllLines[lastValidLineNum].Split(',')[4])
                {
                    unLineCountLastTime = lsAllLines.Length;
                    string[] arrBoloStriqonisMonacemebi = lsAllLines[lastValidLineNum].Split(',');
                    sGadacemisSaxeliLastTime = TrimFileNameFromUnwantedChars(arrBoloStriqonisMonacemebi[4]);
                    //todo guess name from arrBoloStriqonisMonacemebi[4]
                    sShemdegiGadacemisSaxeli
                        = TrimFileNameFromUnwantedChars(
                              arrBoloStriqonisMonacemebi[4].Substring(arrBoloStriqonisMonacemebi[4].LastIndexOf('\\') + 1));
                    try
                    {
                        dtAxaliGadacemisDackebisDro = DateTime.ParseExact(arrBoloStriqonisMonacemebi[5] + " " + arrBoloStriqonisMonacemebi[6]
                                                                          //, @"dd\/M\/yyyy HH:mm:ss"
                                                                          , @"M\/d\/yyyy HH:mm:ss"
                                                                          //was dd
                                                                          , CultureProvider);
                        if (dtAxaliGadacemisDackebisDro.Month != DateTime.Now.Month)
                        {
                            dtAxaliGadacemisDackebisDro = DateTime.ParseExact(arrBoloStriqonisMonacemebi[5] + " " + arrBoloStriqonisMonacemebi[6]
                                                                              //, @"dd\/M\/yyyy HH:mm:ss"
                                                                              , @"d\/M\/yyyy HH:mm:ss"
                                                                              , CultureProvider);
                        }
                    }
                    catch (FormatException)
                    {
                        dtAxaliGadacemisDackebisDro = DateTime.ParseExact(arrBoloStriqonisMonacemebi[5] + " " + arrBoloStriqonisMonacemebi[6]
                                                                          //, @"dd\/M\/yyyy HH:mm:ss"
                                                                          , @"dd\/M\/yyyy HH:mm:ss"
                                                                          , CultureProvider);
                    }
                    return(true);
                }
                else
                {
                    sShemdegiGadacemisSaxeli    = null;
                    dtAxaliGadacemisDackebisDro = DateTime.Now;
                    return(false);
                }
            }
            catch (WebException)
            {
                sShemdegiGadacemisSaxeli    = null;
                dtAxaliGadacemisDackebisDro = DateTime.Now;
                Console.WriteLine("CSV File not found for current day. ");
                return(false);
            }
        }