Exemple #1
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            ImportFiles import = new ImportFiles();

            import.SetPara(m_ArrayListFiles, te_ProName.Text, te_ProNum.Text, te_DesignUnit.Text, te_Designer.Text, cb_DesignPhase.Text, de_ProDate.DateTime);
            import.Import();
        }
Exemple #2
0
        /// <summary>
        /// BTNs the ok click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BtnOkClick(object sender, EventArgs e)
        {
            if (chkFolderContainsMovies.Checked == false && chkFolderContainsTvShows.Checked == false)
            {
                XtraMessageBox.Show("Please select an import type");
                return;
            }

            switch (actionType)
            {
            case MediaPathActionType.Add:
                // This can probably be prettier
                foreach (var model in MediaPathDBFactory.MediaPathDB)
                {
                    if (model.MediaPath == this.editingMediaPathModel.MediaPath)
                    {
                        XtraMessageBox.Show("You can't add the same source twice!");
                        return;
                    }
                }
                MediaPathDBFactory.MediaPathDB.Add(this.editingMediaPathModel);
                break;
            }

            MediaPathDBFactory.CurrentMediaPath = this.editingMediaPathModel;

            this.Close();

            DatabaseIOFactory.Save(DatabaseIOFactory.OutputName.MediaPathDb);

            ImportFiles.ScanMediaPath(MediaPathDBFactory.CurrentMediaPath);
        }
Exemple #3
0
 private void btnImportFiles_Click(object sender, EventArgs e)
 {
     using (View.ImportFiles f = new ImportFiles(PersonnelNumberTextBox.Text, null))
     {
         f.ShowDialog(this);
         SetDossierDocumentsCount(PersonnelNumberTextBox.Text);
     }
 }
Exemple #4
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            ImportFiles import = new ImportFiles();

            import.SetPara(m_ArrayListFiles, "", te_FileVersion.Text, me_Discription.Text, me_Mark.Text, cb_FileClass.Text, te_Saver.Text, te_ProMulgateUnit.Text,
                           "", de_PromulgateDate.DateTime);
            import.Import();
        }
Exemple #5
0
        /// <summary>
        /// Refresh the files found from the mediapaths.
        /// </summary>
        /// <param name="progress">The progress.</param>
        public static void RefreshFiles(Progress progress)
        {
            foreach (MediaPathModel mediaPath in MediaPathDB)
            {
                progress.Message = string.Format("Scanning: {0}", mediaPath.MediaPath);

                ImportFiles.ScanMediaPath(mediaPath);
            }

            progress.Message = "Scan complete. Processing";

            GeneratateUnsortedList();

            progress.Message = "Idle.";
        }
Exemple #6
0
        /// <summary>
        /// BTNs the ok click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BtnOkClick(object sender, EventArgs e)
        {
            if (chkFolderContainsMovies.Checked == false && chkFolderContainsTvShows.Checked == false)
            {
                XtraMessageBox.Show("Please select an import type");
                return;
            }

            this.Close();

            if (actionType == MediaPathActionType.Add)
            {
                MediaPathDBFactory.CommitNewRecord();
            }
            else if (actionType == MediaPathActionType.Edit)
            {
                MediaPathDBFactory.CommitChangedRecord();
            }

            ImportFiles.ScanMediaPath(MediaPathDBFactory.CurrentMediaPath);
        }
Exemple #7
0
        // Display Open File Dialog box to allow users to select CVS, JSON and XML files
        private void btnSelect_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Title            = "Select Files";
                ofd.Filter           = "Data Files (*.csv, *.json, *.xml)| *.csv; *.json; *.xml|All Files (*.*)|*.*";
                ofd.RestoreDirectory = true;
                ofd.Multiselect      = true;
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    selectedFiles     = ofd.FileNames;
                    btnSelect.Enabled = false;

                    foreach (string file in selectedFiles)
                    {
                        string fileExtension = Path.GetExtension(file);

                        if (fileExtension == ".json")
                        {
                            users.AddRange(ImportFiles.LoadJSON(file));
                        }
                        else if (fileExtension == ".xml")
                        {
                            users.AddRange(ImportFiles.LoadXML(file));
                        }
                        else if (fileExtension == ".csv")
                        {
                            users.AddRange(ImportFiles.LoadCSV(file));
                        }
                    }

                    MessageBox.Show("Files have been imported!", "Success", MessageBoxButtons.OK);
                    btnDisplay.Enabled = true;
                }
            }
        }
 private void ImportFiles_Clicked(object sender, PointerRoutedEventArgs e)
 {
     ImportFiles.Execute(null);
 }
Exemple #9
0
 private void ImportFiles_Clicked(object sender, MouseButtonEventArgs e)
 {
     ImportFiles.Execute(null);
 }
Exemple #10
0
        public ActionResult Import([Bind(Include = "ImportId,Month,Year")] Import import,
                                   HttpPostedFileBase bip,
                                   HttpPostedFileBase biq,
                                   HttpPostedFileBase biqd,
                                   HttpPostedFileBase aiq,
                                   HttpPostedFileBase ta,
                                   HttpPostedFileBase npt)
        {
            string logon_user = Session["logon_user"].ToString();

            ViewBag.Months = db.months;
            ViewBag.Years  = db.years;
            #region "BIP"
            if (bip == null || bip.ContentLength == 0)
            {
                ViewBag.ErrorBIP = "No file selected";
            }
            else
            {
                if (bip.FileName.EndsWith("xls") || bip.FileName.EndsWith("xlsx"))
                {
                    string fname = Path.GetFileName(bip.FileName);
                    string path  = Server.MapPath("~/ImportFile/" + fname);
                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }
                    bip.SaveAs(path);
                    ImportFiles i       = new ImportFiles();
                    int         result1 = i.ImportBIProd(path, import, DateTime.Now, logon_user);
                    if (result1 == 1)
                    {
                        ViewBag.MessageBIP = "Success";
                    }
                    else
                    {
                        ViewBag.ErrorBIP = "Failed";
                    }
                }
                else
                {
                    ViewBag.ErrorBIP = "File type is incorrect";
                }
            }
            #endregion "BIP"
            #region "BIQ"
            if (biq == null || biq.ContentLength == 0)
            {
                ViewBag.ErrorBIQ = "No file selected";
            }
            else
            {
                if (biq.FileName.EndsWith("xls") || biq.FileName.EndsWith("xlsx"))
                {
                    string fname = Path.GetFileName(biq.FileName);
                    string path  = Server.MapPath("~/ImportFile/" + fname);
                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }
                    biq.SaveAs(path);
                    ImportFiles i       = new ImportFiles();
                    int         result2 = i.ImportBIQual(path, import, DateTime.Now, logon_user);
                    if (result2 == 1)
                    {
                        ViewBag.MessageBIQ = "Success";
                    }
                    else
                    {
                        ViewBag.ErrorBIQ = "Failed";
                    }
                }
                else
                {
                    ViewBag.ErrorBIQ = "File type is incorrect";
                }
            }
            #endregion "BIQ"
            #region "BIQD"
            if (biqd == null || biqd.ContentLength == 0)
            {
                ViewBag.ErrorBIQD = "No file selected";
            }
            else
            {
                if (biqd.FileName.EndsWith("xls") || biqd.FileName.EndsWith("xlsx"))
                {
                    string fname = Path.GetFileName(biqd.FileName);
                    string path  = Server.MapPath("~/ImportFile/" + fname);
                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }
                    biqd.SaveAs(path);
                    ImportFiles i       = new ImportFiles();
                    int         result2 = i.ImportBIQualD(path, import, DateTime.Now, logon_user);
                    if (result2 == 1)
                    {
                        ViewBag.MessageBIQD = "Success";
                    }
                    else
                    {
                        ViewBag.ErrorBIQD = "Failed";
                    }
                }
                else
                {
                    ViewBag.ErrorBIQD = "File type is incorrect";
                }
            }
            #endregion "BIQD"
            #region "AIQ"
            if (aiq == null || aiq.ContentLength == 0)
            {
                ViewBag.ErrorAIQ = "No file selected";
            }
            else
            {
                if (aiq.FileName.EndsWith("xls") || aiq.FileName.EndsWith("xlsx"))
                {
                    string fname = Path.GetFileName(aiq.FileName);
                    string path  = Server.MapPath("~/ImportFile/" + fname);
                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }
                    aiq.SaveAs(path);
                    #region "EXCEL"
                    Excel.Application    application = new Excel.Application();
                    Excel.Workbook       workbook    = application.Workbooks.Open(path);
                    Excel.Worksheet      worksheet   = workbook.ActiveSheet;
                    Excel.Range          range       = worksheet.UsedRange;
                    List <OSC_ImportAIQ> list        = new List <OSC_ImportAIQ>();
                    for (int row = 2; row <= range.Rows.Count; row++)
                    {
                        OSC_ImportAIQ obj = new OSC_ImportAIQ();
                        obj.Agent = ((Excel.Range)range.Cells[row, 1]).Text;
                        obj.IntervalStaffedDuration = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 2]).Text);
                        obj.TotalPercServiceTime    = Convert.ToDouble(((Excel.Range)range.Cells[row, 3]).Text);
                        obj.TotalACDCalls           = Convert.ToInt32(((Excel.Range)range.Cells[row, 4]).Text);
                        obj.ExtInCalls         = Convert.ToInt32(((Excel.Range)range.Cells[row, 5]).Text);
                        obj.ExtInAvgActiveDur  = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 6]).Text);
                        obj.ExtOutCalls        = Convert.ToInt32(((Excel.Range)range.Cells[row, 7]).Text);
                        obj.AvgExtOutActiveDur = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 8]).Text);
                        obj.ACDWrapUpTime      = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 9]).Text);
                        obj.ACDTalkTime        = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 10]).Text);
                        obj.ACDRingTime        = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 11]).Text);
                        obj.Aux             = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 12]).Text);
                        obj.AvgHoldDur      = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 13]).Text);
                        obj.IntervalIdleDur = af.GetSecondsFormat(((Excel.Range)range.Cells[row, 14]).Text);
                        obj.Transfers       = Convert.ToInt32(((Excel.Range)range.Cells[row, 15]).Text);
                        obj.HeldContacts    = Convert.ToInt32(((Excel.Range)range.Cells[row, 16]).Text);
                        obj.Redirects       = Convert.ToInt32(((Excel.Range)range.Cells[row, 17]).Text);
                        obj.Month           = import.Month;
                        obj.Year            = import.Year;
                        obj.DateUploaded    = DateTime.Now;
                        obj.UploadedBy      = User.Identity.Name;
                        list.Add(obj);
                    }
                    foreach (OSC_ImportAIQ obj in list)
                    {
                        obj.RepId  = db.Representatives.Where(r => (r.AIQUserId == obj.Agent) && ((bool)r.IsCurrent)).FirstOrDefault().RepId;
                        obj.TeamId = db.Representatives.Where(r => (r.AIQUserId == obj.Agent) && ((bool)r.IsCurrent)).FirstOrDefault().TeamId;
                        db.AIQ.Add(obj);
                    }
                    try
                    {
                        db.SaveChanges();
                        ViewBag.MessageBIP = "Success";
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                    }
                    catch (Exception ex)
                    {
                        ViewBag.ErrorBIP = "Error: " + ex.Message.ToString();
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                    }
                    #endregion "EXCEL"
                }
                else
                {
                    ViewBag.ErrorAIQ = "File type is incorrect";
                }
            }
            #endregion "AIQ"
            #region "TA"
            if (ta == null || ta.ContentLength == 0)
            {
                ViewBag.ErrorTA = "No file selected";
            }
            else
            {
                if (ta.FileName.EndsWith("xls") || ta.FileName.EndsWith("xlsx"))
                {
                    string fname = Path.GetFileName(ta.FileName);
                    string path  = Server.MapPath("~/ImportFile/" + fname);
                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }
                    ta.SaveAs(path);
                    #region "EXCEL"
                    Excel.Application   application = new Excel.Application();
                    Excel.Workbook      workbook    = application.Workbooks.Open(path);
                    Excel.Worksheet     worksheet   = workbook.ActiveSheet;
                    Excel.Range         range       = worksheet.UsedRange;
                    List <OSC_ImportTA> list        = new List <OSC_ImportTA>();
                    for (int row = 2; row <= range.Rows.Count; row++)
                    {
                        OSC_ImportTA obj = new OSC_ImportTA();
                        obj.AssignedId       = ((Excel.Range)range.Cells[row, 1]).Text;
                        obj.Group            = ((Excel.Range)range.Cells[row, 2]).Text;
                        obj.FirstName        = ((Excel.Range)range.Cells[row, 3]).Text;
                        obj.MiddleInt        = ((Excel.Range)range.Cells[row, 4]).Text;
                        obj.LastName         = ((Excel.Range)range.Cells[row, 5]).Text;
                        obj.CreateDateTime   = ((Excel.Range)range.Cells[row, 6]).Text;
                        obj.BusinessArea     = ((Excel.Range)range.Cells[row, 7]).Text;
                        obj.WorkType         = ((Excel.Range)range.Cells[row, 8]).Text;
                        obj.Status           = ((Excel.Range)range.Cells[row, 9]).Text;
                        obj.Queue            = ((Excel.Range)range.Cells[row, 10]).Text;
                        obj.Suspended        = ((Excel.Range)range.Cells[row, 11]).Text;
                        obj.SuspendDate      = ((Excel.Range)range.Cells[row, 12]).Text;
                        obj.UnsuspendDate    = ((Excel.Range)range.Cells[row, 13]).Text;
                        obj.LastStatusUpdate = ((Excel.Range)range.Cells[row, 14]).Text;
                        obj.Account          = ((Excel.Range)range.Cells[row, 15]).Text;
                        obj.GAC                = ((Excel.Range)range.Cells[row, 16]).Text;
                        obj.Assoc              = ((Excel.Range)range.Cells[row, 17]).Text;
                        obj.Certificate        = ((Excel.Range)range.Cells[row, 18]).Text;
                        obj.CheckAmount        = ((Excel.Range)range.Cells[row, 19]).Text;
                        obj.First_Name         = ((Excel.Range)range.Cells[row, 20]).Text;
                        obj.Last_Name          = ((Excel.Range)range.Cells[row, 21]).Text;
                        obj.CustomerNo         = ((Excel.Range)range.Cells[row, 22]).Text;
                        obj.ProductType        = ((Excel.Range)range.Cells[row, 23]).Text;
                        obj.AdminSystem        = ((Excel.Range)range.Cells[row, 24]).Text;
                        obj.CheckAmountTotal   = ((Excel.Range)range.Cells[row, 25]).Text;
                        obj.UCIVendorMatchDate = ((Excel.Range)range.Cells[row, 26]).Text;
                        obj.ReasonCodeForAdv   = ((Excel.Range)range.Cells[row, 27]).Text;
                        obj.ReasonDescription  = ((Excel.Range)range.Cells[row, 28]).Text;
                        obj.TinSourceType      = ((Excel.Range)range.Cells[row, 29]).Text;
                        obj.SSBusinessUnit     = ((Excel.Range)range.Cells[row, 30]).Text;
                        obj.Month              = import.Month;
                        obj.Year               = import.Year;
                        obj.DateUploaded       = DateTime.Now;
                        obj.UploadedBy         = User.Identity.Name;
                        list.Add(obj);
                    }
                    foreach (OSC_ImportTA obj in list)
                    {
                        if (Convert.ToDateTime(obj.CreateDateTime).Month == obj.Month)
                        {
                            obj.RepId  = db.Representatives.Where(r => (r.PRDUserId == obj.AssignedId) && ((bool)r.IsCurrent)).FirstOrDefault().RepId;
                            obj.TeamId = af.GetTeamIdByGroupId(obj.Group, "BI").TeamId;
                            db.TA.Add(obj);
                        }
                    }
                    try
                    {
                        db.SaveChanges();
                        ViewBag.MessageBIP = "Success";
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                    }
                    catch (Exception ex)
                    {
                        ViewBag.ErrorBIP = "Error: " + ex.Message.ToString();
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                    }
                    #endregion "EXCEL"
                }
                else
                {
                    ViewBag.ErrorTA = "File type is incorrect";
                }
            }
            #endregion "TA"
            #region "NPT"
            if (npt == null || npt.ContentLength == 0)
            {
                ViewBag.ErrorNPT = "No file selected";
            }
            else
            {
                if (npt.FileName.EndsWith("xls") || npt.FileName.EndsWith("xlsx"))
                {
                    string fname = Path.GetFileName(npt.FileName);
                    string path  = Server.MapPath("~/ImportFile/" + fname);
                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }
                    npt.SaveAs(path);
                    #region "EXCEL"
                    Excel.Application    application = new Excel.Application();
                    Excel.Workbook       workbook    = application.Workbooks.Open(path);
                    Excel.Worksheet      worksheet   = workbook.ActiveSheet;
                    Excel.Range          range       = worksheet.UsedRange;
                    List <OSC_ImportNPT> list        = new List <OSC_ImportNPT>();
                    for (int row = 2; row <= range.Rows.Count; row++)
                    {
                        OSC_ImportNPT obj = new OSC_ImportNPT();
                        obj.Activity       = ((Excel.Range)range.Cells[row, 1]).Text;
                        obj.DateOfActivity = Convert.ToDateTime(((Excel.Range)range.Cells[row, 2]).Text);
                        obj.TimeSpent      = Convert.ToDouble(((Excel.Range)range.Cells[row, 3]).Text) * 60;
                        obj.TypeOfActivity = ((Excel.Range)range.Cells[row, 4]).Text;
                        obj.CreatedBy      = ((Excel.Range)range.Cells[row, 5]).Text;
                        obj.ItemType       = ((Excel.Range)range.Cells[row, 6]).Text;
                        obj.Path           = ((Excel.Range)range.Cells[row, 7]).Text;
                        obj.Month          = import.Month;
                        obj.Year           = import.Year;
                        obj.DateUploaded   = DateTime.Now;
                        obj.UploadedBy     = User.Identity.Name;
                        obj.Source         = "Import";
                        list.Add(obj);
                    }
                    foreach (OSC_ImportNPT obj in list)
                    {
                        if (Convert.ToDateTime(obj.DateOfActivity).Month == obj.Month)
                        {
                            obj.RepId = db.Representatives.Where(r => (r.LastName + ", " + r.FirstName == obj.CreatedBy) &&
                                                                 ((bool)r.IsCurrent)).FirstOrDefault().RepId;
                            obj.TeamId = db.Representatives.Where(r => (r.LastName + ", " + r.FirstName == obj.CreatedBy) &&
                                                                  ((bool)r.IsCurrent)).FirstOrDefault().TeamId;
                            db.NPT.Add(obj);
                        }
                    }
                    try
                    {
                        db.SaveChanges();
                        ViewBag.MessageBIP = "Success";
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                    }
                    catch (Exception ex)
                    {
                        ViewBag.ErrorBIP = "Error: " + ex.Message.ToString();
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                    }
                    #endregion "EXCEL"
                }
                else
                {
                    ViewBag.ErrorNPT = "File type is incorrect";
                }
            }
            #endregion "NPT"
            return(View("Index"));
        }