示例#1
0
        public static Guid addRequest(byte[] datum, string mime)
        {
            if (reqs == null)
                reqs = new Dictionary<Guid, FileRec>();
            foreach (Guid key in reqs.Keys) {
                FileRec rec = reqs[key];

                if (DateTime.Now.Subtract(rec.time).Hours > 1)
                    reqs.Remove(key);
            }
            Guid id = Guid.NewGuid();
            reqs[id] = new FileRec { time = DateTime.Now, data = datum, Mime = mime };
            return id;
        }
示例#2
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            SetProgressValue locdel = new SetProgressValue(SetLocationsProgressValue);
            SetProgressValue yrdel  = new SetProgressValue(SetYearsProgressvalue);

            List <FileRec>   files     = new List <FileRec>();
            HashSet <string> countries = new HashSet <string>();

            GCDisplaySettings stateDetailedText = new GCDisplaySettings("Detailed Calendar");
            GCDisplaySettings stateText         = new GCDisplaySettings("Brief Calendar");
            GCDisplaySettings stateOrig         = GCDisplaySettings.Current;

            try
            {
//                stateText.Clear();
                stateText.setValue(GCDS.CAL_DST_CHANGE, 1);
                stateText.setValue(GCDS.CAL_EKADASI_PARANA, 1);
                stateText.setValue(GCDS.CAL_FEST_0, 1);
                stateText.CalHeaderType = 1;
                stateText.setValue(GCDS.CAL_MASA_CHANGE, 1);
                stateText.setValue(GCDS.CAL_MOON_LONG, 0);
                stateText.setValue(GCDS.CAL_MOON_RISE, 0);
                stateText.setValue(GCDS.CAL_MOON_SET, 0);
                stateText.setValue(GCDS.CAL_SANKRANTI, 0);
                stateText.setValue(GCDS.CAL_SUN_LONG, 0);
                stateText.setValue(GCDS.CAL_SUN_RISE, 0);
                stateText.setValue(GCDS.CAL_SUN_SANDHYA, 0);
                stateText.setValue(GCDS.CAL_VRDDHI, 0);
                stateText.setValue(GCDS.COREEVENTS_ABHIJIT_MUHURTA, 0);
                stateText.setValue(GCDS.COREEVENTS_ASCENDENT, 0);
                stateText.setValue(GCDS.COREEVENTS_CONJUNCTION, 0);
                stateText.setValue(GCDS.COREEVENTS_GULIKALAM, 0);
                stateText.setValue(GCDS.COREEVENTS_MOON, 0);
                stateText.setValue(GCDS.COREEVENTS_MOONRASI, 0);
                stateText.setValue(GCDS.COREEVENTS_NAKSATRA, 0);
                stateText.setValue(GCDS.COREEVENTS_RAHUKALAM, 0);
                stateText.setValue(GCDS.COREEVENTS_SANKRANTI, 0);
                stateText.setValue(GCDS.COREEVENTS_SUN, 0);
                stateText.setValue(GCDS.COREEVENTS_TITHI, 0);
                stateText.setValue(GCDS.COREEVENTS_YAMAGHANTI, 0);
                stateText.setValue(GCDS.COREEVENTS_YOGA, 0);

                stateDetailedText.setValue(GCDS.CAL_ARUN_TIME, 0);
                stateDetailedText.setValue(GCDS.CAL_ARUN_TITHI, 0);
                stateDetailedText.setValue(GCDS.CAL_AYANAMSHA, 0);
                stateDetailedText.setValue(GCDS.CAL_BRAHMA_MUHURTA, 1);
                stateDetailedText.setValue(GCDS.CAL_COREEVENTS, 1);
                stateDetailedText.setValue(GCDS.CAL_DST_CHANGE, 1);
                stateDetailedText.setValue(GCDS.CAL_EKADASI_PARANA, 1);
                stateDetailedText.setValue(GCDS.CAL_FEST_0, 1);
                stateDetailedText.CalHeaderType = 1;
                stateDetailedText.setValue(GCDS.CAL_JULIAN, 0);
                stateDetailedText.setValue(GCDS.CAL_KSAYA, 0);
                stateDetailedText.setValue(GCDS.CAL_MASA_CHANGE, 1);
                stateDetailedText.setValue(GCDS.CAL_SUN_RISE, 1);
                stateDetailedText.setValue(GCDS.CAL_SUN_SANDHYA, 1);
                stateDetailedText.setValue(GCDS.COREEVENTS_CONJUNCTION, 1);
                stateDetailedText.setValue(GCDS.COREEVENTS_GULIKALAM, 0);
                stateDetailedText.setValue(GCDS.COREEVENTS_MOON, 1);
                stateDetailedText.setValue(GCDS.COREEVENTS_MOONRASI, 1);
                stateDetailedText.setValue(GCDS.COREEVENTS_NAKSATRA, 1);
                stateDetailedText.setValue(GCDS.COREEVENTS_TITHI, 1);
                stateDetailedText.setValue(GCDS.COREEVENTS_YAMAGHANTI, 0);
                stateDetailedText.setValue(GCDS.COREEVENTS_YOGA, 1);
                stateDetailedText.setValue(GCDS.GENERAL_FIRST_DOW, stateOrig.getValue(GCDS.GENERAL_FIRST_DOW));


                string  content;
                FileRec currentFileRec;

                for (int locIndex = 0; locIndex < SelectedLocations.Count; locIndex++)
                {
                    TLocation loc = SelectedLocations[locIndex];
                    if (!countries.Contains(loc.Country.Name))
                    {
                        countries.Add(loc.Country.Name);
                    }
                    progressBar1.Invoke(locdel, locIndex);
                    for (int year = StartYear; year <= EndYear; year++)
                    {
                        if (backgroundWorker1.CancellationPending)
                        {
                            return;
                        }
                        if (CancelRequested)
                        {
                            return;
                        }

                        progressBar2.Invoke(yrdel, year);
                        //                        Thread.Sleep(1000);

                        TResultCalendar calendar;
                        GCLocation      locRef = loc.GetLocationRef();


                        currentFileRec = new FileRec()
                        {
                            filename       = year.ToString() + "_" + ToFilePart(loc.CityName) + ".html",
                            filenameDetail = year.ToString() + "_" + ToFilePart(loc.CityName) + "_d.html",
                            filenamePdf    = year.ToString() + "_" + ToFilePart(loc.CityName) + ".pdf",
                            city           = loc.CityName,
                            country        = loc.Country.Name,
                            year           = year
                        };

                        files.Add(currentFileRec);

                        GCDisplaySettings.Current = stateText;
                        calendar = new TResultCalendar(loc.GetLocationRef(), year);
                        content  = calendar.formatText(GCDataFormat.HTML);
                        // print plain TXT
                        File.WriteAllText(Path.Combine(OutputDir, currentFileRec.filename), content);
                        // print PDF
                        PrintPdfYear(calendar, year, Path.Combine(OutputDir, currentFileRec.filenamePdf));

                        GCDisplaySettings.Current = stateDetailedText;
                        calendar = new TResultCalendar(loc.GetLocationRef(), year);
                        content  = calendar.formatText(GCDataFormat.HTML);
                        // print detailed TXT
                        File.WriteAllText(Path.Combine(OutputDir, currentFileRec.filenameDetail), content);
                    }

                    // write location index file
                    if (StartYear != EndYear)
                    {
                        File.WriteAllText(Path.Combine(OutputDir, ToFilePart(loc.CityName) + ".html"), GenerateYearIndex(loc, StartYear, EndYear));
                    }
                }

                for (int year = StartYear; year <= EndYear; year++)
                {
                    // write main index file
                    File.WriteAllText(Path.Combine(OutputDir, "y" + year.ToString() + ".html"), GenerateMainIndex(countries, year, year));
                }

                // write main index file
                File.WriteAllText(Path.Combine(OutputDir, "index.html"), GenerateMainIndex(countries, StartYear, EndYear));

                // write main years file
                //File.WriteAllText(Path.Combine(OutputDir, "years.html"), GenerateYearsOverview(StartYear, EndYear));

                progressBar1.Invoke(new SetProgressValue(SetDialogCompleted), 0);
            }
            catch (Exception ex)
            {
                Debugger.Log(0, "", "Error: " + ex.Message + "\n" + ex.StackTrace + "\n");
            }
            finally
            {
                GCDisplaySettings.Current = stateOrig;
            }
        }
示例#3
0
        public JsonResult AddNewAdsWithImage()
        {
            try
            {
                var filePath = "";
                // HttpResponseMessage result = null;
                var httpRequest = Request;
                if (httpRequest.Files.Count > 0)
                {
                    var docfiles = new List <string>();
                    foreach (string av in httpRequest.Files)
                    {
                        var postedFile = httpRequest.Files[av];

                        filePath = Server.MapPath("~/Content/Upload/BulkTickets" + postedFile.FileName);
                        postedFile.SaveAs(filePath);
                        docfiles.Add(filePath);
                    }
                    //result = Request.CreateResponse(HttpStatusCode.Created, docfiles);
                }
                else
                {
                    //result = Request.CreateResponse(HttpStatusCode.BadRequest);
                }

                //Creating object of datatable
                DataTable tblcsv = new DataTable();
                //creating columns
                tblcsv.Columns.Add("Barcode");
                tblcsv.Columns.Add("Nombre");
                tblcsv.Columns.Add("Seccion");
                tblcsv.Columns.Add("Fila");
                tblcsv.Columns.Add("Asiento");
                tblcsv.Columns.Add("Precio");
                tblcsv.Columns.Add("Orden");
                tblcsv.Columns.Add("TicketStatus");
                tblcsv.Columns.Add("CreatedOn");
                string ReadCSV = System.IO.File.ReadAllText(filePath);
                //spliting row after new line
                foreach (string csvRow in ReadCSV.Split('\n'))
                {
                    if (!string.IsNullOrEmpty(csvRow))
                    {
                        //Adding each row into datatable
                        tblcsv.Rows.Add();
                        int count = 0;
                        foreach (string FileRec in csvRow.Split(','))
                        {
                            // GenerateBacode(FileRec.Replace("\"", "'"), "");
                            tblcsv.Rows[tblcsv.Rows.Count - 1][count] = FileRec.Replace("\"", "").Replace("''", "");
                            if (count == 6)
                            {
                                tblcsv.Rows[tblcsv.Rows.Count - 1][7] = false;
                                tblcsv.Rows[tblcsv.Rows.Count - 1][8] = DateTime.Now;
                            }
                            count++;
                        }
                    }
                }
                InsertCSVRecords(tblcsv);
                string MessageError = "";
                MessageError = "success";
                return(Json(MessageError, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json("error", JsonRequestBehavior.AllowGet));
            }
        }
示例#4
0
        private void BindDataGridPaging()
        {
            //Creating a datatable object
            DataTable tblcsv = new DataTable();

            //Adding the first row which is pre-defined.
            tblcsv.Columns.AddRange(new DataColumn[8] {
                new DataColumn("Admission Number", typeof(int)),
                new DataColumn("Name", typeof(string)),
                new DataColumn("Father's Name", typeof(string)),
                new DataColumn("Mother's Name", typeof(string)),
                new DataColumn("Class Section", typeof(string)),
                new DataColumn("Mobile Number", typeof(long)),
                new DataColumn("Gender", typeof(string)),
                new DataColumn("Address", typeof(string))
            });
            //Getting the CSV Location from session which is saved in temporary storage.
            string CSVLocation = Session["CSVLocation"].ToString();
            //Reading all the text from CSV File.
            string ReadCSV = File.ReadAllText(CSVLocation);

            //spliting row after new line
            foreach (string csvRow in ReadCSV.Split('\n'))
            {
                //Checking whether the data is empty.
                if (!string.IsNullOrEmpty(csvRow))
                {
                    //Adding each row into datatable
                    tblcsv.Rows.Add();
                    //Creating count variable for splitting data in columns.
                    int count = 0;
                    //Creating Address Count Varaible for splitting Address Column from other data.
                    int AddressCount = 0;
                    //Creating an array to split Address Column from Other Columns.
                    string[] def = csvRow.Split('"');
                    //Checking whether Address field has commas with "" or not.
                    if (def.Count() == 1)
                    {
                        foreach (string x in csvRow.Split(','))
                        {
                            tblcsv.Rows[tblcsv.Rows.Count - 1][count] = x;
                            count++;
                        }
                    }
                    //Address field doesn't have commas and "".
                    else
                    {
                        foreach (string FileRec in def.Take(def.Length - 1))
                        {
                            string[] abc = FileRec.Split(',');
                            foreach (string x in abc.Take(abc.Length - 1))
                            {
                                if (AddressCount != 0)
                                {
                                    break;
                                }
                                tblcsv.Rows[tblcsv.Rows.Count - 1][count] = x;
                                count++;
                            }
                            if (AddressCount == 0)
                            {
                                AddressCount++;
                                continue;
                            }
                            tblcsv.Rows[tblcsv.Rows.Count - 1][count] = FileRec;
                            count++;
                        }
                    }
                }
            }
            //Calling Bind Grid Functions
            grdViewStudent.DataSource = tblcsv;
            grdViewStudent.DataBind();
        }
示例#5
0
 protected void btnConfirm_Click(object sender, EventArgs e)
 {
     try
     {
         //Creating Collection of StudentCL for storing multiple data entries provided by excel file.
         Collection <StudentCL> studentCol = new Collection <StudentCL>();
         //Getting the CSV Location from session which is saved in temporary storage.
         string CSVLocation = Session["CSVLocation"].ToString();
         //Reading All text
         string ReadCSV = File.ReadAllText(CSVLocation);
         //spliting row after new line
         foreach (string csvRow in ReadCSV.Split('\n'))
         {
             //Checking whether the data is empty.
             if (!string.IsNullOrEmpty(csvRow))
             {
                 //Creating StudentCL instance for storing single data entry in loop.
                 StudentCL studentCL = new StudentCL();
                 //Creating studentCount variable for counting student data entries.
                 int studentCount = 0;
                 //Creating count variable for splitting data in columns.
                 int count = 0;
                 //Creating Address Count Varaible for splitting Address Column from other data.
                 int AddressCount = 0;
                 //Creating an array to split Address Column from Other Columns.
                 string[] def = csvRow.Split('"');
                 //Checking whether Address field has commas with "" or not.
                 if (def.Count() == 1)
                 {
                     //Loop for splitting the data and inputting the data in StudentCL intance.
                     foreach (string FileRec in csvRow.Split(','))
                     {
                         if (count == 0)
                         {
                             studentCL.admissionNo = Convert.ToInt32(FileRec);
                         }
                         if (count == 1)
                         {
                             studentCL.name = FileRec;
                         }
                         if (count == 2)
                         {
                             studentCL.fathersname = FileRec;
                         }
                         if (count == 3)
                         {
                             studentCL.mothername = FileRec;
                         }
                         if (count == 4)
                         {
                             studentCL.studentClass = FileRec.Remove(FileRec.Length - 1);
                             studentCL.section      = FileRec.Substring(FileRec.Length - 1);
                         }
                         if (count == 5)
                         {
                             studentCL.mobileNumber = Convert.ToInt64(FileRec);
                         }
                         if (count == 6)
                         {
                             bool gender = true;
                             if (FileRec == "Male")
                             {
                                 gender = true;
                             }
                             else
                             {
                                 gender = false;
                             }
                             studentCL.gender = gender;
                         }
                         if (count == 7)
                         {
                             studentCL.address = FileRec;
                             break;
                         }
                         count++;
                     }
                 }
                 //Address field doesn't have commas and "".
                 else
                 {
                     //Loop for splitting the data and inputting the data in StudentCL intance.
                     foreach (string FileRec in def.Take(def.Length - 1))
                     {
                         string[] abc = FileRec.Split(',');
                         foreach (string x in abc.Take(abc.Length - 1))
                         {
                             if (AddressCount != 0)
                             {
                                 break;
                             }
                             if (count == 0)
                             {
                                 studentCL.admissionNo = Convert.ToInt32(x);
                             }
                             if (count == 1)
                             {
                                 studentCL.name = x;
                             }
                             if (count == 2)
                             {
                                 studentCL.fathersname = x;
                             }
                             if (count == 3)
                             {
                                 studentCL.mothername = x;
                             }
                             if (count == 4)
                             {
                                 studentCL.studentClass = x.Remove(x.Length - 1);
                                 studentCL.section      = x.Substring(x.Length - 1);
                             }
                             if (count == 5)
                             {
                                 studentCL.mobileNumber = Convert.ToInt64(x);
                             }
                             if (count == 6)
                             {
                                 bool gender = true;
                                 if (x == "Male")
                                 {
                                     gender = true;
                                 }
                                 else
                                 {
                                     gender = false;
                                 }
                                 studentCL.gender = gender;
                             }
                             count++;
                         }
                         if (AddressCount == 0)
                         {
                             AddressCount++;
                             continue;
                         }
                         studentCL.address = FileRec;
                     }
                 }
                 //Increasing the studentCount to input in Id Field to store multiple entries in Entity Framework.
                 studentCount++;
                 studentCL.dateCreated  = DateTime.Now;
                 studentCL.dateModified = DateTime.Now;
                 studentCL.isDeleted    = false;
                 studentCL.id           = studentCount;
                 //Adding StudentCL instance in Collection instance.
                 studentCol.Add(studentCL);
             }
         }
         //Sending the data to database from Collection data.
         int AddedStudents = backUserBLL.createStudentCollection(studentCol);
         //Redirecting to the same page on successful tranmission.
         Response.Redirect("CreateStudent.aspx");
     }
     catch (Exception ex)
     {
         throw(new Exception(ex.Message));
     }
 }
        public void BindDataGrid()
        {
            //Creating object of datatable
            DataTable tblcsv = new DataTable();

            //Adding the first row which is pre-defined.
            tblcsv.Columns.AddRange(new DataColumn[8] {
                new DataColumn("Admission Number", typeof(int)),
                new DataColumn("Student's Name", typeof(string)),
                new DataColumn("Father's Name", typeof(string)),
                new DataColumn("Mother's Name", typeof(string)),
                new DataColumn("Mobile Number", typeof(string)),
                new DataColumn("Gender", typeof(string)),
                new DataColumn("Date Of Birth", typeof(DateTime)),
                new DataColumn("Address", typeof(string))
            });
            //Creating the CSV Location which is saved in temporary storage.
            string CSVFilePath = Path.GetTempFileName() + flExcelUpload.FileName;

            flExcelUpload.SaveAs(CSVFilePath);
            //Storing the CSV Location in Session for further usage.
            Session["CSVLocation"] = CSVFilePath;
            //Reading All text
            string ReadCSV = File.ReadAllText(CSVFilePath);

            //spliting row after new line
            foreach (string csvRow in ReadCSV.Split('\n'))
            {
                if (ReadCSV.IndexOf(csvRow) != 0)
                {
                    //Checking whether the data is empty.
                    if (!string.IsNullOrEmpty(csvRow))
                    {
                        //Adding each row into datatable
                        tblcsv.Rows.Add();
                        //Creating count variable for splitting data in columns.
                        int count = 0;
                        //Creating Address Count Varaible for splitting Address Column from other data.
                        int AddressCount = 0;
                        //Creating an array to split Address Column from Other Columns.
                        string[] def = csvRow.Split('"');
                        //Checking whether Address field has commas with "" or not.
                        if (def.Count() == 1)
                        {
                            foreach (string x in csvRow.Split(','))
                            {
                                tblcsv.Rows[tblcsv.Rows.Count - 1][count] = x;
                                count++;
                            }
                        }
                        //Address field doesn't have commas and "".
                        else
                        {
                            foreach (string FileRec in def.Take(def.Length - 1))
                            {
                                string[] abc = FileRec.Split(',');
                                foreach (string x in abc.Take(abc.Length - 1))
                                {
                                    if (AddressCount != 0)
                                    {
                                        break;
                                    }
                                    tblcsv.Rows[tblcsv.Rows.Count - 1][count] = x;
                                    count++;
                                }
                                if (AddressCount == 0)
                                {
                                    AddressCount++;
                                    continue;
                                }
                                tblcsv.Rows[tblcsv.Rows.Count - 1][count] = FileRec;
                                count++;
                            }
                        }
                    }
                }
            }
            //Calling Bind Grid Functions
            grdStudent.DataSource = tblcsv;
            ViewState["students"] = tblcsv;
            grdStudent.DataBind();
        }