예제 #1
0
        // Regner ut ** ALLE ** seriene
        public static void calculateAllSeriesAndEpisodes(NordubbProductions productions, string searchString, ListBox flowLayoutPanel1, CheckBox chckIntro, TextBlock lblTotalNumLines)
        {
            int totNumLines = 0;

            foreach (var item in productions.productions)
            {
                //string seriesName = "";

                List <Episode> episodeList = calculateSearchResultsByEpisode(item.frontPageDataTable, searchString);

                if (episodeList.Count > 0)
                {
                    //seriesName = item.seriesName.ToString();
                    totNumLines = totNumLines + PrintResult.printResultByEpisode(episodeList, flowLayoutPanel1, chckIntro);
                }

                // Må gi Utskriften en mulighet til å skrive ut navn på eps
            }
            ;

            decimal t = decimal.Round((Convert.ToDecimal(totNumLines) / 90), 2);

            lblTotalNumLines.Text = "TOTALT antall replikker: " + totNumLines.ToString() + ".  Det vil ta " + t + " timer å dubbe ferdig.";

            //TextBlockProps.TotNumLines = "TOTALT antall replikker: " + totNumLines.ToString() + ".  Det vil ta " + t + " timer å dubbe ferdig.";
        }
        private void mainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            if (DateTime.Compare(systemTime, expDate) > 0)
            {
                string svar = Utils.Prompt.ShowDialog("Enter password");
                if (svar != "drikk")
                {
                    System.Diagnostics.Process.GetCurrentProcess().Kill();
                }
            }

            txtActorName.Focus();

            //string userDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString();

            //GlobalVariables.dubToolDir = "";

            //GlobalVariables.dubToolDir = userDocumentsPath + @"\dubtool\";

            allProductions = ExcelScanning.scanDubtoolFolder(lboxShowFiles, txtActorName.Text.ToString());
        }
 private void btnRescanFolder_Click(object sender, RoutedEventArgs e)
 {
     lboxShowFiles.Items.Clear();
     spShowResult.Items.Clear();
     allProductions = ExcelScanning.scanDubtoolFolder(lboxShowFiles, txtActorName.Text.ToString());
 }
예제 #4
0
        // Scanner folder og henter inn alle manusene i minnet og fyller opp listboks og comboboks
        public static NordubbProductions scanDubtoolFolder(ListBox lboxShowFiles, string searchString)
        {
            string conStr;

            conStr = string.Empty;
            string             sheetName        = "";
            NordubbProductions allNDProductions = new NordubbProductions();

            List <string> dubToolFolderContent = new List <string>();

            dubToolFolderContent = getDubtoolFolderContent();

            // Fyller opp listboksen og comboboksen:
            Utils.listFilesFromMemoryList(dubToolFolderContent, lboxShowFiles);

            int counter = 0;

            foreach (var excelFile in dubToolFolderContent) // Fylle opp en liste med DataTables
            {
                if (excelFile.EndsWith(".xls"))
                {
                    conStr = string.Format(GlobalVariables.Excel03ConString, excelFile);
                }
                else
                {
                    MessageBox.Show("Excel-format-problem!");
                    //conStr = string.Format(MyVariables.Excel07ConString, excelFile);
                }


                //Get the name of the First Sheet.
                using (OleDbConnection con = new OleDbConnection(conStr))
                {
                    using (OleDbCommand cmd = new OleDbCommand())
                    {
                        try
                        {
                            cmd.Connection = con;
                            con.Open();
                            DataTable dtExcelSchema = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);

                            // Ruller gjennom alle arkene for å finne Forsiden eller #00
                            for (var sheets = 0; sheets < dtExcelSchema.Rows.Count; sheets++)
                            {
                                //sheetName = dtExcelSchema.Rows[sheets]["TABLE_NAME"].ToString();
                                if (dtExcelSchema.Rows[sheets]["TABLE_NAME"].ToString().Contains("Forside") || dtExcelSchema.Rows[sheets]["TABLE_NAME"].ToString().Contains("#00") || dtExcelSchema.Rows[sheets]["TABLE_NAME"].ToString().Contains("Oversikt"))
                                {
                                    sheetName = dtExcelSchema.Rows[sheets]["TABLE_NAME"].ToString();
                                    break;
                                }
                            }

                            con.Close();
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show("Får ikke åpnet en av Excel-filene. Virker som den er åpen et annet sted...", e.Message);
                            break;
                        }
                    }
                }

                //Read Data from the First Sheet.
                using (OleDbConnection con = new OleDbConnection(conStr))
                {
                    using (OleDbCommand cmd = new OleDbCommand())
                    {
                        using (OleDbDataAdapter oda = new OleDbDataAdapter())
                        {
                            // Finner forsiden og fyller opp en DataTable
                            DataTable dt = new DataTable();
                            //sheetName = "Forside";
                            cmd.CommandText = "SELECT * From [" + sheetName + "]";
                            cmd.Connection  = con;
                            con.Open();
                            oda.SelectCommand = cmd;
                            oda.Fill(dt);

                            var excelFrontPage = new excelFrontPage();
                            excelFrontPage.frontPageDataTable = dt;
                            excelFrontPage.seriesName         = dt.Rows[0][0].ToString();
                            excelFrontPage.excelFileName      = dubToolFolderContent[counter];
                            counter++;

                            // Fyller opp med faktiske episodenummer
                            for (int i = 4; i < 16; i++)
                            {
                                excelFrontPage.numEpisodesList.Add(dt.Rows[2][i].ToString());
                            }
                            allNDProductions.productions.Add(excelFrontPage);
                            con.Close();
                        }
                    }
                }
            }
            return(allNDProductions);
        }