Exemplo n.º 1
0
        private static IState GetState(this RunTypes type, string runLocation = null)
        {
            switch (type)
            {
            case RunTypes.Clone:
                return(new CloneState(runLocation));

            case RunTypes.LocalRevert:
                return(new LocalRevertState(runLocation));

            case RunTypes.Reclone:
                return(new ReCloneState(runLocation));

            case RunTypes.Update:
                return(new UpdateState(runLocation));

            case RunTypes.Settings:
                return(new SettingsState());

            case RunTypes.Setup:
                return(new SetupState());

            case RunTypes.Uninstall:
                return(new UninstallState());

            default:
                throw new NotImplementedException($"The runType {type.ToString()} has not been implemented.");
            }
        }
Exemplo n.º 2
0
 private RunTypes CheckRegistration()
 {
     try
     {
         if (File.Exists(hideFilePath))
         {
             trialDays = CheckHideFile();
             if (trialDays == 0)
             {
                 runType = RunTypes.Expired;
             }
             else
             {
                 runType = RunTypes.Trial;
             }
         }
         else
         {
             runType = RunTypes.Unknown;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Failed to check the registration condition.\n" + ex.Message, "TrialMaker:CheckRegistration", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     return(runType);
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {            
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            
            Settings.programPath = Application.ExecutablePath.Substring(0, 1 + Application.ExecutablePath.LastIndexOf("\\"));

            InitGraphDraw(args);
            InitRegister();

            Register reg = new Register();

            RunTypes run = reg.Check();
            if (run == RunTypes.Activated)
            if (1==1)
            {
                About about = new About();
                about.Start();

                System.Threading.Thread.Sleep(1000);

                Application.Run(mainForm);
            }
            else
            {
                if (run == RunTypes.NotActivated)
                {
                    Application.Run(registerForm);
                }
                else
                {
                    //
                }
            }
        }
Exemplo n.º 4
0
        public TrialMakerForm(TrialMaker trial)
        {
            trialMaker = trial;
            runType    = trialMaker.RunType;
            InitializeComponent();

            DisplaySettings();
        }
Exemplo n.º 5
0
 public AuditReverter(Func <IAuditContext> getDb, RunTypes runType)
 {
     _getDb   = getDb;
     _runType = runType;
     using (var db = getDb()) {
         var lastAudit = db.Audits.OrderByDescending(a => a.Id).FirstOrDefault();
         _auditCheckpoint = lastAudit?.Id ?? 0;
     }
 }
Exemplo n.º 6
0
        //  Extension Methods
        //  =================

        public static void Open(this RunTypes type, string[] args)
        {
            switch (type)
            {
            case RunTypes.Clone:
            case RunTypes.LocalRevert:
            case RunTypes.Reclone:
            case RunTypes.Update:
                string runLocation;

                if (args.Length > 0)
                {
                    runLocation = args[0];
                }
                else if (CommonFileDialog.IsPlatformSupported)
                {
                    runLocation = SelectWinVistaFolder();
                }
                else
                {
                    runLocation = SelectWinXPFolder();
                }

                if (!Directory.Exists(runLocation))
                {
                    System.Windows.MessageBox.Show("Given location is not a valid directory!",
                                                   "Command Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                    return;
                }

                IState state = type.GetState(runLocation);
                state.InitialActions(args);

                OpenMainWindow(state);
                return;

            case RunTypes.Settings:
            case RunTypes.Setup:
            case RunTypes.Uninstall:
                type.GetState().InitialActions(args);
                return;

            default:
                throw new NotImplementedException($"The runType {type.ToString()} has not been implemented.");
            }
        }
Exemplo n.º 7
0
        public void setRunType(RunTypes runType)
        {
            this.runType = runType;

            switch (runType)
            {
            case RunTypes.Rest:
                this.Background = Brushes.LightBlue;
                break;

            case RunTypes.Easy:
                this.Background = Brushes.LightGreen;
                break;

            case RunTypes.Long:
                this.Background = Brushes.Green;
                break;

            case RunTypes.Interval:
                this.Background = Brushes.Orange;
                break;

            case RunTypes.Tempo:
                this.Background = Brushes.Orange;
                break;

            case RunTypes.Strides:
                this.Background = Brushes.Pink;
                break;

            default:
                this.Background = Brushes.DarkGray;
                break;
            }

            //update label
            if (this.runType == RunTypes.Rest)
            {
                this.Content = "Rest";
            }
            else
            {
                this.Content = this.runType.ToString() + " " + (Math.Round(totalMileage * 2) / 2).ToString();
            }
        }
Exemplo n.º 8
0
        public TrialMaker(string toolName, string hideFile)
        {
            productName  = toolName;
            hideFilePath = hideFile;
            Guid guid = new Guid("{A81E6B45-A8FF-49B7-8AF3-1EF5FC8F3027}");

            productGuid = guid.ToString();

            runType = CheckRegistration();
            if (runType == RunTypes.Trial && trialDays > 10)
            {
                isPassed = true;
            }
            else
            {
                isPassed = false;
            }
        }
Exemplo n.º 9
0
        public RunTypes Check()
        {
            RunTypes result = RunTypes.NotActivated;

            Settings.activated = false;

            RegistryKey regKeyAppRoot = Registry.CurrentUser.CreateSubKey(strPath);

            st1 = (string)regKeyAppRoot.GetValue("st1");

            //first run
            if (st1 == null)
            {
                SaveDateTime(DateTime.Now, out st2, out st3, out st4);

                try
                {
                    regKeyAppRoot.SetValue("st1", "465re66");
                    regKeyAppRoot.SetValue("st2", st2);
                    regKeyAppRoot.SetValue("st3", st3);
                    regKeyAppRoot.SetValue("st4", st4);
                    regKeyAppRoot.SetValue("st5", "");
                    regKeyAppRoot.SetValue("st6", GetRegistrationCode());
                }
                catch
                {
                    MessageBox.Show("Can not write to registry!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(RunTypes.Error);
                }
            }

            try
            {
                st1 = (string)regKeyAppRoot.GetValue("st1");
                st2 = (string)regKeyAppRoot.GetValue("st2");
                st3 = (string)regKeyAppRoot.GetValue("st3");
                st4 = (string)regKeyAppRoot.GetValue("st4");
                st5 = (string)regKeyAppRoot.GetValue("st5");
                st6 = (string)regKeyAppRoot.GetValue("st6");
            }
            catch
            {
                MessageBox.Show("Can not read from registry!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(RunTypes.Error);
            }

            Settings.regNumber = st6;

            string actCode = GenerateActivationCode(st6);

            if (st5 == actCode)
            {
                result             = RunTypes.Activated;
                Settings.activated = true;
                Settings.shdays    = -1;
            }
            else
            {
                Settings.shdays = GoodTime(GetDateTime(st2, st3, st4));

                if (Settings.shdays != -1)
                {
                    result = RunTypes.Activated;
                }
            }

            return(result);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Process Record
        /// </summary>
        protected override void ProcessRecord()
        {
            var qb = new QuerystringBuilder();

            if (!string.IsNullOrWhiteSpace(JobName))
            {
                var job = RestApiCommon.GetProtectionJobByName(Session.ApiClient, JobName);
                JobId = job.Id;
            }

            if (JobId.HasValue && JobId != null)
            {
                qb.Add("jobId", JobId.Value);
            }

            if (StartedTime.HasValue && StartedTime != null)
            {
                qb.Add("startedTimeUsecs", StartedTime.Value);
            }

            if (EndTime.HasValue && EndTime != null)
            {
                qb.Add("endTimeUsecs", EndTime.Value);
            }

            if (NumRuns.HasValue && NumRuns != null)
            {
                qb.Add("numRuns", NumRuns.Value);
            }

            if (ExcludeTasks.IsPresent)
            {
                qb.Add("excludeTasks", true);
            }

            if (SourceId.HasValue && SourceId != null)
            {
                qb.Add("sourceId", SourceId.Value);
            }

            if (ExcludeErrorRuns.IsPresent)
            {
                qb.Add("excludeErrorRuns", true);
            }

            if (StartTime.HasValue && StartTime != null)
            {
                qb.Add("startTimeUsecs", StartTime.Value);
            }

            if (RunTypes != null && RunTypes.Any())
            {
                qb.Add("runTypes", string.Join(",", RunTypes));
            }

            if (ExcludeNonRestoreableRuns.IsPresent)
            {
                qb.Add("excludeNonRestoreableRuns", true);
            }

            var url     = $"/public/protectionRuns{ qb.Build()}";
            var results = Session.ApiClient.Get <IEnumerable <ProtectionRunInstance> >(url);

            // Hide deleted protection jobs unless explicitly asked for
            if (!IncludeDeleted.IsPresent)
            {
                results = results.Where(x => !(x.JobName.StartsWith("_DELETED"))).ToList();
            }
            WriteObject(results, true);
        }