Example #1
0
        /// <summary>
        /// This overload attempts to fix a broken back end without reporting its progress.
        /// </summary>
        /// <returns></returns>
        public bool TryFixBrokenBackEnd()
        {
            bool success = false;

            try
            {
                //1. Check for back end settings file;
                if (!Validator.BackEndSettingsFileExists())
                {
                    CreateXmlFile.CreateBackEndSettingsXMLFile(this.RollOutDirectory, _connectionString);
                }
                //2. Check for Rollouts folder. If doesn't exist, completely reinstall backend
                if (!Directory.Exists(this.RollOutDirectory + "Rollouts"))
                {
                    createNecessaryDirectories();
                    CreateXmlFile.CreateBackEndXmlFileInRolloutDirectory();
                }
                //3. If folder exists, loop through files in rollouts folder and reconstruct backend xml file.
                else
                {
                    reconstructBackEndFromRolloutsFolder();
                }

                success = true;
            }
            catch (Exception)
            {
                success = false;
            }
            return(success);
        }
Example #2
0
        private void reconstructBackEndFromRolloutsFolder(object sender, DoWorkEventArgs e)
        {
            //1. Create back end xml file to be updated.
            CreateXmlFile.CreateBackEndXmlFileInRolloutDirectory();
            var directory          = new DirectoryInfo(this.RollOutDirectory + "Rollouts\\");
            var fileCount          = directory.EnumerateFiles("FE-*.zip").Count();
            int progressPercentage = Convert.ToInt32(((double)1 / (fileCount + 1)) * 100);

            (sender as BackgroundWorker).ReportProgress(progressPercentage, e.Argument);
            int progress = 1;

            //2. Loop through the zipped files in the rollouts folder
            foreach (var file in directory.EnumerateFiles("FE-*.zip"))
            {
                //For each file, read the file into a ZipArchive object
                ZipArchive zipfile = ZipFile.OpenRead(file.FullName);
                //Find the only .xml file in the zip file and extract it to the reconstruction path.
                zipfile.Entries.FirstOrDefault(p => p.Name.Contains(".xml")).ExtractToFile(this.ReconstructionPath, true);
                //Release the object reference in memory to the zip file.
                zipfile.Dispose();
                //Create a rolloutInfo file (which is plain object with only properties and not methods) out of
                //the newly extracted xml file.
                DTO.RolloutInfo rollout = GetDataFromXml.GetReconstructedInfo(this.ReconstructionPath);
                //Add a rollout record with the info in the rollout record.
                UpdateXmlFile.AddRolloutRecord(rollout);
                progressPercentage = Convert.ToInt32(((double)++progress / fileCount) * 100);
                (sender as BackgroundWorker).ReportProgress(progressPercentage, "Reconstructed " + file.Name);
            }
        }
Example #3
0
 /// <summary>
 /// This overload attempts to fix a broken back end making use of a background worker to report progess on the reconstruction
 /// </summary>
 /// <param name="worker"></param>
 /// <returns></returns>
 public void TryFixBrokenBackEnd(ref BackgroundWorker worker)
 {
     worker.WorkerSupportsCancellation = true;
     try
     {
         //1. Check for back end settings file;
         if (!Validator.BackEndSettingsFileExists())
         {
             CreateXmlFile.CreateBackEndSettingsXMLFile(this.RollOutDirectory, _connectionString);
         }
         //2. Check for Rollouts folder. If doesn't exist, completely reinstall backend
         if (!Directory.Exists(this.RollOutDirectory + "Rollouts"))
         {
             createNecessaryDirectories();
             CreateXmlFile.CreateBackEndXmlFileInRolloutDirectory();
         }
         //3. If folder exists, loop through files in rollouts folder and reconstruct backend xml file.
         else
         {
             worker.DoWork += reconstructBackEndFromRolloutsFolder;
             worker.RunWorkerAsync("Reconstructing rollouts...");
         }
     }
     catch (Exception)
     {
         worker.CancelAsync();
     }
 }
Example #4
0
        protected void ExpertDownloadButtonClick(object sender, EventArgs e)
        {
            Button button = (Button)sender;
            {
                var appIdTmp = Session["ApplicationID"];
                if (appIdTmp == null)
                {
                    Response.Redirect("Main.aspx");
                }
                int applicationId = Convert.ToInt32(appIdTmp);
                int userid        = Convert.ToInt32(button.CommandArgument);


                string templateFilePath = Server.MapPath("~/documents/expertdoc/expertpoint.xml");
                string newFileName      = "Заключение на заявку №" + applicationId.ToString() + ".doc";

                string newFileDirectory = Server.MapPath("~/documents/generated") + "\\" + userid.ToString();
                string newFilePath      = newFileDirectory + "\\" + newFileName;

                Directory.CreateDirectory(newFileDirectory);

                CreateXmlFile createXmlFile = new CreateXmlFile();
                createXmlFile.CreateExpertDocument(templateFilePath, newFilePath, applicationId, userid);


                HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
                HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=Заключение на заявку №" + applicationId.ToString() + ".doc");
                HttpContext.Current.Response.BinaryWrite(ReadByteArryFromFile(newFilePath));
                HttpContext.Current.Response.End();
                Response.End();
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            InstallActionEnum installAction    = InstallActionEnum.FreshInstall;
            string            launcherLocation = "";

            if (args.Length != 0)
            {
                if (args[0] == "update")
                {
                    installAction    = InstallActionEnum.Update;
                    launcherLocation = args[1];
                }
            }
            string rolloutDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()).Parent.FullName + "\\";

            createDirectories();
            copyFilesToAppDataFolder();
            int currentLauncherVersion = Domain.FrontEndInstaller.InstallerService.GetCurrentLauncherVersion();

            if (installAction == InstallActionEnum.Update)
            {
                Domain.FrontEndInstaller.InstallerService.UpdateFrontEndLauncherVersion(currentLauncherVersion);
                Domain.FrontEndInstaller.InstallerService.LaunchFrontEnd(launcherLocation);;
            }
            else
            {
                CreateXmlFile.CreateFrontEndXMLFile(rolloutDirectory, Domain.FrontEnd.GetInfo.GetAppDataPath(), currentLauncherVersion);
                createDesktopShortcut();
            }
        }
Example #6
0
        protected void GetDocButtonClick(object sender, EventArgs e)
        {
            Button button = (Button)sender;
            {
                var userIdtmp = Session["UserID"];
                if (userIdtmp == null)
                {
                    Response.Redirect("~/Default.aspx");
                }
                int userId = (int)userIdtmp;
                var appid  = button.CommandArgument;
                int idapp  = Convert.ToInt32(appid);
                CompetitionDataContext competitionDataBase = new CompetitionDataContext();
                zCompetitionsTable     currentCompetition  = (from a in competitionDataBase.zCompetitionsTable
                                                              join b in competitionDataBase.zApplicationTable
                                                              on a.ID equals b.FK_CompetitionTable
                                                              where b.ID == idapp
                                                              select a).FirstOrDefault();

                string dirPath          = Server.MapPath("~/documents/byApplication/" + idapp);
                string templateFilePath = Server.MapPath("~/documents/templates") + "\\" + currentCompetition.ID.ToString() + "\\" + currentCompetition.TemplateDocName;
                string newFileName      = "Заявка " + currentCompetition.TemplateDocName + ".doc";
                newFileName = newFileName.Replace(":", "_");
                string        newFilePath   = dirPath + "\\" + newFileName;
                string        zipFile       = Server.MapPath("~/documents/generatedZipFiles/") + idapp + ".zip";
                string        extractPath   = Server.MapPath("~/documents/extract/");
                CreateXmlFile createXmlFile = new CreateXmlFile();
                string        asdadasdda    = System.Web.HttpContext.Current.Server.MapPath("~/") + @"documents\generatedZipFiles\" + idapp + ".zip";
                createXmlFile.CreateDocument(templateFilePath, newFilePath, idapp, 0);

                if (File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/") + @"documents\generatedZipFiles\" + idapp + ".zip"))
                {
                    File.Delete(System.Web.HttpContext.Current.Server.MapPath("~/") + @"documents\generatedZipFiles\" + idapp + ".zip");
                    ZipFile.CreateFromDirectory(dirPath, zipFile);
                    HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
                    HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=file.zip");
                    HttpContext.Current.Response.BinaryWrite(ReadByteArryFromFile(zipFile));
                    HttpContext.Current.Response.End();
                }
                else
                {
                    ZipFile.CreateFromDirectory(dirPath, zipFile);
                    HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
                    HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=file.zip");
                    HttpContext.Current.Response.BinaryWrite(ReadByteArryFromFile(zipFile));
                    HttpContext.Current.Response.End();
                }
                Response.End();
            }
        }
Example #7
0
 public void Install()
 {
     createNecessaryDirectories();
     createManifest();
     copyFilesToRolloutDirectory();
     CreateXmlFile.CreateBackEndSettingsXMLFile(this.RollOutDirectory, _connectionString);
     CreateXmlFile.CreateManifestXMLFile(PathManager.GetInstallerFilesDirectory(this.RollOutDirectory), this.InstallerManifest);
     createInstallerShortcut();
     if (rolloutsExist())
     {
         reconstructBackEndFromRolloutsFolder();
     }
     else
     {
         CreateXmlFile.CreateBackEndXmlFileInRolloutDirectory();
     }
 }
Example #8
0
        private void reconstructBackEndFromRolloutsFolder()
        {
            //1. Create back end xml file to be updated.
            CreateXmlFile.CreateBackEndXmlFileInRolloutDirectory();
            var directory = new DirectoryInfo(this.RollOutDirectory + "Rollouts\\");

            //2. Loop through the zipped files in the rollouts folder
            foreach (var file in directory.EnumerateFiles("FE-*.zip"))
            {
                //For each file, read the file into a ZipArchive object
                ZipArchive zipfile = ZipFile.OpenRead(file.FullName);
                //Find the only .xml file in the zip file and extract it to the reconstruction path.
                zipfile.Entries.FirstOrDefault(p => p.Name.Contains(".xml")).ExtractToFile(this.ReconstructionPath, true);
                //Release the object reference in memory to the zip file.
                zipfile.Dispose();
                //Create a rolloutInfo file (which is plain object with only properties and not methods) out of
                //the newly extracted xml file.
                DTO.RolloutInfo rollout = GetDataFromXml.GetReconstructedInfo(this.ReconstructionPath);
                //Add a rollout record with the info in the rollout record.
                UpdateXmlFile.AddRolloutRecord(rollout);
            }
        }
Example #9
0
        protected void GetDocButtonClick(object sender, EventArgs e)
        {
            Button button = (Button)sender;
            {
                int iD = Convert.ToInt32(button.CommandArgument);
                CompetitionDataContext competitionDataBase = new CompetitionDataContext();

                zCompetitionsTable currentCompetition = (from a in competitionDataBase.zCompetitionsTable
                                                         join b in competitionDataBase.zApplicationTable
                                                         on a.ID equals b.FK_CompetitionTable
                                                         where b.ID == iD
                                                         select a).FirstOrDefault();
                if (currentCompetition != null)
                {
                    var userIdtmp = Session["UserID"];
                    if (userIdtmp == null)
                    {
                        Response.Redirect("~/Default.aspx");
                    }
                    int userId = (int)userIdtmp;

                    if (currentCompetition.TemplateDocName != null)
                    {
                        if (currentCompetition.TemplateDocName.Any())
                        {
                            string templateFilePath = Server.MapPath("~/documents/templates") + "\\" + currentCompetition.ID.ToString() + "\\" + currentCompetition.TemplateDocName;
                            string newFileName      = "Заявка пользователя на конкурс " + currentCompetition.TemplateDocName;
                            newFileName = newFileName.Replace(":", "_");
                            string newFileDirectory = Server.MapPath("~/documents/generated") + "\\" + iD.ToString();
                            string newFilePath      = newFileDirectory + "\\" + newFileName;


                            Directory.CreateDirectory(newFileDirectory);
                            CreateXmlFile createXmlFile = new CreateXmlFile();
                            int           docType       = 0;

                            try
                            {
                                RadioButtonList newRadioButtonList =
                                    button.Parent.FindControl("RadioButtonList1") as RadioButtonList;
                                docType = Convert.ToInt32(newRadioButtonList.SelectedValue);
                            }
                            catch (Exception)
                            {
                                throw;
                            }
                            createXmlFile.CreateDocument(templateFilePath, newFilePath, iD, docType);
                            string convertedFilePath = createXmlFile.ConvertedFilePath;



                            HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
                            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=document." + createXmlFile.ConvertedFileExtension);
                            HttpContext.Current.Response.BinaryWrite(ReadByteArryFromFile(convertedFilePath));
                            HttpContext.Current.Response.End();
                            Response.End();

                            /*  System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                             * response.ClearContent();
                             * response.Clear();
                             * response.ContentType = "text/plain";
                             * response.AddHeader("Content-Disposition", "attachment; filename=document." + createXmlFile.ConvertedFileExtension);
                             * response.TransmitFile(convertedFilePath);
                             * response.Flush();
                             * response.Clear();
                             * response.Redirect("~/User/UserMainPage.aspx");
                             * response.End();
                             *
                             */
                            /*
                             * Response.WriteFile(convertedFilePath);
                             * Response.Redirect("~/User/UserMainPage.aspx");*/
                        }
                    }
                }
            }
            //Response.Redirect("UserMainPage.aspx");
        }