示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["User"] != null)
                {
                    HtmlGenericControl ManageSongs = (HtmlGenericControl)Master.FindControl("ManageSongs");
                    ManageSongs.Attributes.Add("class", "select");
                    HtmlGenericControl ManageCompany = (HtmlGenericControl)Master.FindControl("ManageCompany");
                    ManageCompany.Attributes.Add("class", "select");
                    HtmlGenericControl ManageLabel = (HtmlGenericControl)Master.FindControl("ManageLabel");
                    ManageLabel.Attributes.Add("class", "select");
                    HtmlGenericControl ManageEmergenti = (HtmlGenericControl)Master.FindControl("ManageEmergenti");
                    ManageEmergenti.Attributes.Add("class", "select");
                    HtmlGenericControl ImportData = (HtmlGenericControl)Master.FindControl("ImportData");
                    ImportData.Attributes.Add("class", "current");
                    HtmlGenericControl audienceFigures = (HtmlGenericControl)Master.FindControl("audienceFigures");
                    audienceFigures.Attributes.Add("class", "select");
                    HtmlGenericControl digitalData = (HtmlGenericControl)Master.FindControl("digitalData");
                    digitalData.Attributes.Add("class", "select");
                    HtmlGenericControl MoveFiles = (HtmlGenericControl)Master.FindControl("MoveFiles");
                    MoveFiles.Attributes.Add("class", "select");
                    HtmlGenericControl Promoter = (HtmlGenericControl)Master.FindControl("Promoter");
                    Promoter.Attributes.Add("class", "select");

                    clsRecognizedFactory fac = new clsRecognizedFactory();
                    fac.GetAllRecognizedDelete();

                    ViewState["PageNumber"] = 1;

                    //BindTaskList();
                }
                else
                {
                    Response.Redirect("Login.aspx");
                }
            }
        }
示例#2
0
        protected void btn_Click(object sender, EventArgs e)
        {
            CultureInfo cinfo = new CultureInfo("it-IT");

            clsRecognizedFactory fac = new clsRecognizedFactory();

            if (!String.IsNullOrEmpty(hfname.Value))
            {
                if (IsEnglish(hfname.Value))
                {
                    if (filename.HasFile)
                    {
                        string FileName  = Path.GetFileName(filename.PostedFile.FileName);
                        string Extension = Path.GetExtension(filename.PostedFile.FileName);
                        if (Extension == ".csv")
                        {
                            try
                            {
                                string FolderPath = Server.MapPath("~/ImportFiles");
                                if (!Directory.Exists(FolderPath))
                                {
                                    Directory.CreateDirectory(FolderPath);
                                }
                                Guid   abc      = Guid.NewGuid();
                                string FilePath = FolderPath + "/" + abc.ToString();
                                if (System.IO.File.Exists(FilePath))
                                {
                                    System.IO.File.Delete(FilePath);
                                }
                                filename.SaveAs(FilePath);

                                fac.GetAllRecognizedDelete();

                                string ReadCSV = File.ReadAllText(FilePath);
                                foreach (string csvRow in ReadCSV.Split('\n'))
                                {
                                    if (!string.IsNullOrEmpty(csvRow))
                                    {
                                        string   csvFileName           = string.Empty;
                                        int      IdRadio               = 0;
                                        int      csvHour               = 0;
                                        DateTime FingerprintingTime    = DateTime.Now;
                                        string   FingerprintingDetails = string.Empty;

                                        string[] xxx   = csvRow.ToString().Split('\t');
                                        string   item1 = xxx[0];
                                        if (item1 != "\r")
                                        {
                                            if (item1 != null)
                                            {
                                                string[] inner = item1.Split('.');
                                                string   Ids   = inner[0].Replace(@"\ ", "").Replace(@"""", "");
                                                IdRadio = Convert.ToInt32(Ids);

                                                csvHour = GetInterval(inner[4]);

                                                string DatetimeFor = inner[1] + "-" + inner[2] + "-" + inner[3] + " " + inner[4] + ":" + inner[5] + ":" + inner[6] + ".000";
                                                FingerprintingTime = Convert.ToDateTime(DatetimeFor);
                                            }
                                            csvFileName           = xxx[2];
                                            FingerprintingDetails = xxx[3];

                                            clsRecognized recognized = new clsRecognized();
                                            if (csvFileName.EndsWith(".mp3"))
                                            {
                                                recognized.FileName = csvFileName;
                                            }
                                            else
                                            {
                                                recognized.FileName = csvFileName + ".mp3";
                                            }
                                            recognized.IdRadio               = IdRadio;
                                            recognized.Hour                  = csvHour;
                                            recognized.FingerprintingTime    = FingerprintingTime;
                                            recognized.FingerprintingDetails = FingerprintingDetails;
                                            try
                                            {
                                                int ID = fac.Insert(recognized);
                                            }
                                            catch (Exception ex)
                                            {
                                                string errorMessage = string.Empty;
                                            }
                                        }
                                    }
                                }

                                int       pageNumber  = Convert.ToInt32(ViewState["PageNumber"]);
                                int       PageSize    = 100;
                                DataSet   Recognized  = fac.GetAllRecognized(pageNumber, PageSize);
                                DataTable myDataTable = Recognized.Tables[0]; //Set your DataTable here
                                ViewState["Count"] = Recognized.Tables[1];
                                grd.DataSource     = myDataTable;
                                grd.DataBind();

                                Div1.Style.Add("display", "block");
                                divBtnSave.Style.Add("display", "block");
                            }
                            catch (Exception ex)
                            {
                                pnlError.Visible = true;
                                lblError.Text    = ex.Message.ToString();// "Error occured! Please try again later.";
                            }
                        }
                        else
                        {
                            pnlError.Visible = true;
                            lblError.Text    = "Upload only csv files.";
                        }
                    }
                }
                else
                {
                    pnlError.Visible = true;
                    lblError.Text    = "File name contains illegal characters";
                }
            }
            else
            {
                pnlError.Visible = true;
                lblError.Text    = "Please select a file first";
            }
        }