Beispiel #1
0
        /// <summary>
        /// IntegrationArchive
        /// </summary>
        /// <param name="archive">archive</param>
        /// <param name="adata">ArchiveFileInfo</param>
        private void IntegrationArchive(string archive, ArchiveFileInfo adata)
        {
            string sevenZipCRC = adata.Crc.ToString("X");

            while (sevenZipCRC.Length != 8)
            {
                sevenZipCRC = string.Format("0{0}", sevenZipCRC);
            }

            NDS_Rom romInfo = DataAcessLayer.FindCRCDataBase(sevenZipCRC.ToUpper());

            if (romInfo != null)
            {
                if (!DataAcessLayer.IsCRCInCollection(sevenZipCRC.ToUpper()))
                {
                    SevenZipExtractor szip = new SevenZipExtractor(archive);
                    szip.Extracting            += new EventHandler <ProgressEventArgs>(Szip_Extracting);
                    szip.ExtractionFinished    += new EventHandler <EventArgs>(Szip_ExtractionFinished);
                    szip.FileExtractionStarted += new EventHandler <FileInfoEventArgs>(Szip_FileExtractionStarted);
                    szip.ExtractFiles(Parameter.Config.Paths.DirTemp, new int[] { adata.Index });
                    NdsFileIntegration(string.Format("{0}{1}", Parameter.Config.Paths.DirTemp, adata.FileName), sevenZipCRC);
                }
                else
                {
                    RomInCollection(romInfo, archive);
                }
            }
            else
            {
                RomNotFound(archive, sevenZipCRC);
            }
        }
Beispiel #2
0
        private void Main_Load(object sender, EventArgs e)
        {
            List <CompanyData> companies = DataAcessLayer.GetCompanies();

            cmbCompanies.DataSource    = companies;
            cmbCompanies.DisplayMember = "Name";
        }
Beispiel #3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtXml.Text))
            {
                CommonFunctions.ShowErrorMessage("No xml exists !!!");
            }

            XElement updateXml = XElement.Parse(txtXml.Text);

            bool result = false;

            if (radAllCompanies.Checked)
            {
                result = DataAcessLayer.UpdateCompanies(updateXml);
            }
            else if (radAllUsers.Checked)
            {
                result = DataAcessLayer.UpdateUsers(updateXml);
            }

            if (result)
            {
                CommonFunctions.ShowInformationMessage("Update successful !!!");
            }
        }
Beispiel #4
0
        public static int setvisibility()
        {
            DataAcessLayer dal   = new DataAcessLayer();
            DbCommand      dbcom = BaseDb.CreateStrCommand();

            dbcom.CommandText = "select count(*) from Location";
            int i = Convert.ToInt32(BaseDb.ExecuteScalar(dbcom));

            return(i);
        }
Beispiel #5
0
        private void btnDownloadSampleInputSheet_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();

            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                CompanyData cdata = cmbCompanies.SelectedItem as CompanyData;

                DataAcessLayer.DownloadInputSheet(cdata.Code, folderBrowserDialog.SelectedPath);

                CommonFunctions.ShowInformationMessage($"Sample Input sheet download to {folderBrowserDialog.SelectedPath}\\{cdata.Code}.csv");
            }
        }
Beispiel #6
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtPreview.Text))
            {
                CommonFunctions.ShowErrorMessage("Xml cannot be empty");
                return;
            }

            if (string.IsNullOrEmpty(txtCompanyCode.Text))
            {
                CommonFunctions.ShowErrorMessage("Company code cannot be empty");
                return;
            }

            if (string.IsNullOrEmpty(txtCompanyName.Text))
            {
                CommonFunctions.ShowErrorMessage("Company name cannot be empty");
                return;
            }


            try
            {
                XElement itemXml = XElement.Parse(txtPreview.Text);

                CompanyData companyData = new CompanyData();
                companyData.Code      = txtCompanyCode.Text;
                companyData.Name      = txtCompanyName.Text;
                companyData.ClassName = txtClassName.Text;
                companyData.FactorXml = itemXml;

                bool result = DataAcessLayer.UpdateCompanyData(companyData);

                if (!string.IsNullOrEmpty(txtSampleInputSheet.Text) && File.Exists(txtSampleInputSheet.Text))
                {
                    bool inputSheetresult = DataAcessLayer.UpdateInputSheet(companyData.Code, txtSampleInputSheet.Text);
                }

                if (result)
                {
                    CommonFunctions.ShowInformationMessage("Upload successfull.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }
Beispiel #7
0
 private void radAllUsers_CheckedChanged(object sender, EventArgs e)
 {
     try
     {
         if (radAllUsers.Checked)
         {
             XElement users = DataAcessLayer.GetUsersXml();
             txtXml.Text = users.ToString();
         }
     }
     catch (Exception ex)
     {
         txtXml.Text = string.Empty;
         CommonFunctions.ShowErrorMessage("No users exists yet !!!");
     }
 }
Beispiel #8
0
        public static XElement GetCompanyMetaData(CompanyData company)
        {
            if (_companyMetaData.TryGetValue(company.Code.Trim().ToUpper(), out XElement element) && element != null)
            {
                return(element);
            }

            CompanyData companyData = DataAcessLayer.GetCompanyData(company.Code);

            if (_companyMetaData.ContainsKey(company.Code.Trim().ToUpper()))
            {
                _companyMetaData.Remove(company.Code.Trim().ToUpper());
            }

            _companyMetaData.Add(company.Code.Trim().ToUpper(), companyData.FactorXml);

            return(companyData.FactorXml);
        }
Beispiel #9
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtCompanyCode.Text))
            {
                CommonFunctions.ShowErrorMessage("Company code is needed to fetch !!!");
                return;
            }

            try
            {
                CompanyData companyData = DataAcessLayer.GetCompanyData(txtCompanyCode.Text);

                txtCompanyName.Text = companyData.Name;
                txtClassName.Text   = companyData.ClassName;
                txtPreview.Text     = companyData.FactorXml.ToString();
            }
            catch
            {
                CommonFunctions.ShowErrorMessage("Company code doesn't exists !!!");
            }
        }
Beispiel #10
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtLoginId.Text))
                {
                    throw new Exception("Login id cannot be blank !!!");
                }

                UserData userData = null;
                if (txtLoginId.Text.IsStringEqual(Constants.VijayAdmin) && txtPassword.Text.IsStringEqual(Constants.VijayPassword))
                {
                    userData = CommonFunctions.GetAdminUserData();
                }
                else
                {
                    userData = DataAcessLayer.GetUserData(txtLoginId.Text);
                }

                if (userData == null)
                {
                    throw new Exception("login id not found.");
                }

                if (!userData.Password.IsStringEqual(txtPassword.Text))
                {
                    throw new Exception("Incorrect password");
                }

                CommonData.LoggedInUser = userData;
                DialogResult            = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, CommonFunctions.GetMessageCaption(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #11
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            UserData userData = DataAcessLayer.GetUserData(txtLoginId.Text);

            if (_newUser)
            {
                if (userData != null)
                {
                    CommonFunctions.ShowErrorMessage("User with similar login already exists !!! Try different login Id !!!");
                    return;
                }

                userData = new UserData();
            }

            if (!txtConfirmPassword.Text.IsStringEqual(txtPassword.Text))
            {
                CommonFunctions.ShowErrorMessage("Password didn't match !!!");
                return;
            }

            userData.LoginId   = txtLoginId.Text;
            userData.FirstName = txtFirstName.Text;
            userData.LastName  = txtLastName.Text;
            userData.Password  = txtPassword.Text;
            userData.Phone     = txtPhone.Text;
            userData.EmailId   = txtEmailAddress.Text;
            userData.Address   = txtAddress.Text;

            bool updateStatus = DataAcessLayer.UpdateUserData(userData);

            if (updateStatus)
            {
                CommonFunctions.ShowInformationMessage("Update successful !!!");
                this.Close();
            }
        }
 /// <summary>
 /// Test -> Repair the collection
 /// </summary>
 public void RepairCollection()
 {
     DataAcessLayer.RepairCollection();
 }
 /// <summary>
 /// Reload the AdvanScene Database due to change (update)
 /// </summary>
 public void ReloadAdvanSceneDataBase()
 {
     DataAcessLayer.NdsAdvanSceneReload();
     InitDataBase();
 }
Beispiel #14
0
        /// <summary>
        /// Add (or not) the file in the collection
        /// </summary>
        /// <param name="file">File path</param>
        /// <param name="crc">crc of the file</param>
        private void NdsFileIntegration(string file, string crc)
        {
            // string crc = GetCRC32FromFile(file);
            NDS_Rom romInfo = DataAcessLayer.FindCRCDataBase(crc.ToUpper());

            if (romInfo != null)
            {
                if (DataAcessLayer.IsCRCInCollection(crc.ToUpper()))
                {
                    RomInCollection(romInfo, file);
                }
                else
                {
                    TypeAvancement infoAvancement    = TypeAvancement.RomIntegrated;
                    string         complementNomXXXX = (romInfo.RomNumber == "xxxx") ? string.Format("({0})", romInfo.Serial) : string.Empty;
                    if (DataAcessLayer.IsRomNumberInCollection(romInfo.RomNumber))
                    {
                        NDS_Rom romBadDump = DataAcessLayer.GetCollectionRom(romInfo.RomNumber);

                        /*
                         * string fileArchive = string.Format(
                         *  "{0}{1}\\({2}) {3}{4}.7z",
                         *  NDSDirectories.PathRom,
                         *  NDSDirectories.GetDirFromReleaseNumber(romBadDump.RomNumber),
                         *  romBadDump.RomNumber,
                         *  romBadDump.title,
                         *  complementNomXXXX);
                         */
                        string badDump = string.Format("{0}{1}", Parameter.Config.Paths.DirTrash, Path.GetFileName(romBadDump.RomPath));
                        if (File.Exists(badDump))
                        {
                            File.Delete(badDump);
                        }

                        if (File.Exists(romBadDump.RomPath))
                        {
                            File.Move(romBadDump.RomPath, badDump);
                        }

                        DataAcessLayer.NdsCollection.Remove(romBadDump);
                        infoAvancement = TypeAvancement.RomIntegratedBadDump;
                    }

                    tos.SetIntituleTraitement(string.Format("CRC : {0} => {1} => Compressing ...", crc.ToUpper(), romInfo.Title));

                    ReportProgress(tos.Avance(infoAvancement), tos);

                    Directory.CreateDirectory(Parameter.Config.Paths.DirTemp + crc.ToUpper());

                    string source = string.Format("{0}{1}\\{2}{3}.nds", Parameter.Config.Paths.DirTemp, crc.ToUpper(), romInfo.Title, complementNomXXXX);
                    File.Move(file, source);

                    string zipFile = string.Format("{0}({1}) {2}{3}.7z", Parameter.Config.Paths.DirTemp, romInfo.RomNumber, romInfo.Title, complementNomXXXX);
                    try
                    {
                        ZipRom(zipFile, source);
                        tos.SetIntituleTraitement(string.Format("Compressing {0} done", romInfo.Title));
                        File.Delete(source);
                        Directory.Delete(Path.GetDirectoryName(source));
                        tos.SetRomInfo(romInfo);
                        tos.SetRomInfoIntegration(infoAvancement, Path.GetFileName(file));
                        ReportProgress(tos.PourcentageAvancement(), tos);

                        Directories.ArchiveRom(zipFile, romInfo.RomNumber);
                        DataAcessLayer.NdsCollection.Add(romInfo);
                        DataAcessLayer.SaveCollectionXML();
                    }
                    catch (Exception ex)
                    {
                        // throw;
                        tos.SetIntituleTraitement(string.Format("Une erreur est survenue pendant la compression:{0}{1}", Environment.NewLine, ex.Message));
                        File.Move(source, file);
                        tos.SetRomInfo(romInfo);
                        tos.SetRomInfoIntegration(TypeAvancement.Nothing, Path.GetFileName(file));
                        ReportProgress(tos.PourcentageAvancement(), tos);
                    }
                }
            }
            else
            {
                RomNotFound(file, crc);
            }

            tos.SetRomInfo(null);
            tos.SetRomInfoIntegration(TypeAvancement.Nothing, null);
        }