Example #1
0
        private bool Read()
        //читаем из базы наши статусы
        {
            bool result = true;

            OpenConnection();

            if (atexConnect == null)
            {
                return(false);
            }

            SqlCommand    myCommand = new SqlCommand();
            SqlDataReader myReader1;
            string        codeEdition = Startup.myData.GetEditionCodebyID(Startup.Edition);

            myCommand.CommandText = "SELECT page_number, status_id, item_name, data_no FROM dbo.pritem LEFT JOIN dbo.prdatareference ON dbo.pritem.item_id = dbo.prdatareference.item_id LEFT JOIN dbo.pritemdata ON dbo.prdatareference.data_id = dbo.pritemdata.data_id WHERE dbo.pritem.item_name LIKE @PageName AND (dbo.prdatareference.data_no > 0 ) AND dbo.pritem.item_name NOT LIKE '%_SC_%' AND dbo.pritem.item_name NOT LIKE '%_BF_%' AND (dbo.prdatareference.data_type=2) ORDER BY item_name, data_no";
            myCommand.Connection  = atexConnect;

            statusesList.Clear();

            string pageName = Startup.issueDate() + "_" + codeEdition + "_%"; //предусмотреть если null!!!

            myCommand.Parameters.AddWithValue("@PageName", pageName);

            try
            {
                myReader1 = myCommand.ExecuteReader();
                while (myReader1.Read())
                {
                    sInfo o = new sInfo(Convert.ToInt32(myReader1.GetValue(0)), myReader1.GetValue(1).ToString(), myReader1.GetValue(2).ToString(), (int)myReader1.GetValue(3));
                    statusesList.Add(o);
                }
                if (!myReader1.IsClosed)
                {
                    myReader1.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Atex base error!");
                result = false;
            }
            Close();
            if (Startup.UserRole == Startup.Roles.Advert)
            {
                ColorsStatuses();
            }
            else
            {
                ReadSendedBase();
            }
            return(result);
        }
Example #2
0
 private void ColorsStatuses()
 //это для рекламы - вместо статусов Атекса
 //ставит статусы цветности полосы по схеме цветности
 {
     for (int i = 0; i < statusesList.Count; i++)
     {
         int   status      = Startup.myData.GetColorForPage(statusesList[i].PageNum, statusesList[i].IssueId, (int)Startup.globalDate.DayOfWeek);
         sInfo tempElement = new sInfo(statusesList[i].PageNum, (status != 1 ? "1043" : "1010"), statusesList[i].FileName, statusesList[i].Data_No);
         statusesList[i] = tempElement;
     }
 }
Example #3
0
        private void ReadSendedBase()
        //здесь читаем нашу базу на предмет уже отправленных файлов
        {
            SqlConnection pdfConnect = new SqlConnection(Startup.APSDBConnectionString);

            SqlCommand readData = new SqlCommand();

            readData.CommandText = "SELECT DISTINCT page_name FROM pdffiles WHERE page_name LIKE @data AND is_original = 'True'";
            readData.Connection  = pdfConnect;
            readData.Parameters.AddWithValue("@data", Startup.issueDate() + "%");

            SqlCommand readData2 = new SqlCommand();

            readData2.CommandText = "SELECT DISTINCT page_name FROM pdffiles WHERE page_name LIKE @data AND is_original = 'False'";
            readData2.Connection  = pdfConnect;
            readData2.Parameters.AddWithValue("@data", Startup.issueDate() + "%");

            SqlDataReader myReader;

            try
            {
                pdfConnect.Open();
            }
            catch
            {
                return;
            }

            try
            {
                myReader = readData.ExecuteReader();
                while (myReader.Read())
                {
                    int index = statusesList.FindIndex(p => p.FileName == System.IO.Path.GetFileNameWithoutExtension(myReader.GetValue(0).ToString()));
                    if (index != -1)
                    {
                        if (statusesList[index].Status == StatusMark.FindIndex(p => p == "1014"))
                        {
                            sInfo o = new sInfo(statusesList[index].PageNum, "Отправлен", statusesList[index].FileName, statusesList[index].Data_No);
                            statusesList[index] = o;
                        }
                    }
                }
                if (!myReader.IsClosed)
                {
                    myReader.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "PDF-files read base error!");
            }

            try
            {
                myReader = readData2.ExecuteReader();
                while (myReader.Read())
                {
                    int index = statusesList.FindIndex(p => p.FileName == System.IO.Path.GetFileNameWithoutExtension(myReader.GetValue(0).ToString()));
                    if (index != -1)
                    {
                        if (statusesList[index].Status == StatusMark.FindIndex(p => p == "1043"))
                        {
                            sInfo o = new sInfo(statusesList[index].PageNum, "1043-1", statusesList[index].FileName, statusesList[index].Data_No);
                            statusesList[index] = o;
                        }
                    }
                }
                if (!myReader.IsClosed)
                {
                    myReader.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "PDF-files read base error!");
            }

            pdfConnect.Close();

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

            outFiles.AddRange(System.IO.Directory.GetFiles(Startup.Paths.GetValue("outputPDF"), "*.pdf", System.IO.SearchOption.TopDirectoryOnly));
            outFiles.AddRange(System.IO.Directory.GetFiles(Startup.Paths.GetValue("recolorPDF"), "*.pdf", System.IO.SearchOption.TopDirectoryOnly));

            foreach (string s in outFiles)
            {
                int index = statusesList.FindIndex(p => p.FileName == System.IO.Path.GetFileNameWithoutExtension(s).Substring(0, 17));
                if (index != -1)
                {
                    sInfo o = new sInfo(statusesList[index].PageNum, "Wait", statusesList[index].FileName, statusesList[index].Data_No);
                    statusesList[index] = o;
                }
            }

            outFiles.Clear();

            try
            {
                outFiles.AddRange(System.IO.Directory.GetFiles(Startup.Paths.GetValue("inputPDF"), "*.pdf", System.IO.SearchOption.TopDirectoryOnly));
                foreach (string s in outFiles)
                {
                    int index = statusesList.FindIndex(p => p.FileName == System.IO.Path.GetFileNameWithoutExtension(s));
                    if (index != -1)
                    {
                        sInfo o = new sInfo(statusesList[index].PageNum, "1014", statusesList[index].FileName, statusesList[index].Data_No);
                        statusesList[index] = o;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }