Ejemplo n.º 1
0
        /// <summary>
        /// Updates internally cached profile with data from profile info
        /// </summary>
        /// <param name="pi">Interface to Profile Info</param>
        /// <param name="AllowCreation">True allows to add a new profile when it does not exist in cache already</param>
        public void SaveProfile(IProfileInfo pi, bool AllowCreation = false)
        {
            Profile prof;

            // look for existing one and create if not exists
            if (!_FindProfile(pi.GetProfileName(), out prof))
            {
                if (!AllowCreation)
                {
                    return;
                }

                prof      = new Profile();
                prof.Name = pi.GetProfileName();
                _Profiles.Add(prof);
            }

            prof.Rows.Clear();

            // collecting data, nom nom nom
            prof.Attempts = pi.GetAttemptsCount();
            for (int r = 0; r < pi.GetSplitCount(); r++)
            {
                ProfileRow ProfileRow = new ProfileRow();
                ProfileRow.Title = pi.GetSplitTitle(r);
                ProfileRow.Hits  = pi.GetSplitHits(r);
                ProfileRow.Diff  = pi.GetSplitDiff(r);
                ProfileRow.PB    = pi.GetSplitPB(r);
                prof.Rows.Add(ProfileRow);
            }
        }
Ejemplo n.º 2
0
        // private methods
        private void CheckProfile()
        {
            switch (profileInfo)
            {
            case ProfileInfoEnum.Administrator:
                Profile = AdministratorProfile.CreateProfile();
                break;

            case ProfileInfoEnum.Consultant:
                Profile = ConsultantProfile.CreateProfile();
                break;

            case ProfileInfoEnum.ExternalCustomer:
                Profile = ExternalCustomerProfile.CreateProfile();
                break;

            case ProfileInfoEnum.InternalCustomer:
                Profile = InternalCustomerProfile.CreateProfile();
                break;

            case ProfileInfoEnum.Producer:
                Profile = ProducerProfile.CreateProfile();
                break;

            case ProfileInfoEnum.Carrier:
                Profile = CarrierProfile.CreateProfile();
                break;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates profile info based on a specific internally cached profile.
        /// </summary>
        /// <param name="Name">Name of profile that gets loaded</param>
        /// <param name="pi_dst">Target ProfileInfo interface</param>
        public void LoadProfile(string Name, IProfileInfo pi_dst)
        {
            if (null == pi_dst)
            {
                return;                 // just for safety should never happen
            }
            Profile prof;

            pi_dst.ProfileUpdateBegin();
            pi_dst.ProfileName   = Name;
            pi_dst.AttemptsCount = 0;
            pi_dst.ClearSplits();
            if (_FindProfile(Name, out prof))
            {
                pi_dst.AttemptsCount = prof.Attempts;
                foreach (ProfileRow row in prof.Rows)
                {
                    pi_dst.AddSplit(row.Title, row.Hits, row.WayHits, row.PB, row.Duration, row.DurationPB, row.DurationGold);
                }
                pi_dst.ActiveSplit = prof.ActiveSplit;
                pi_dst.SetSessionProgress(prof.GetSessionProgress(), true);
            }
            else
            {
                pi_dst.SetSessionProgress(0, true);
            }
            pi_dst.ProfileUpdateEnd();
        }
 public static void AssignUserData(SignInViewModel data)
 {
     FullName = data.FullName;
     Dni      = data.Dni;
     Email    = data.Email;
     Profile  = ProfileInfo.CreateProfile((ProfileType)data.ProfileId).GetProfile;
 }
Ejemplo n.º 5
0
 public ExternalOrderForm(IProfileInfo profile)
 {
     InitializeComponent();
     this.profile     = profile;
     idSelected       = string.Empty;
     idClientSelected = string.Empty;
     nodeIndex        = 0;
 }
Ejemplo n.º 6
0
        public Form1()
        {
            InitializeComponent();
            pi = DataGridView1; // for better capsulation
            om = new OutModule(pi);
            sc = new Shortcuts(Handle);

            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
            ServicePointManager.ServerCertificateValidationCallback += (sender2, certificate, chain, errors) => { return(true); };
        }
Ejemplo n.º 7
0
        public void ProfilePB()
        {
            UpdateDuration();

            // Apply on all tabs
            foreach (ProfileViewControl pvc_tab in ptc.ProfileViewControls)
            {
                IProfileInfo pi_tab = pvc_tab.ProfileInfo;
                pi_tab.setPB();
                profs.SaveProfile(pi_tab); // save tab's profile
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Updates profile info based on a specific internally cached profile
        /// </summary>
        /// <param name="Name">Name of profile that gets loaded</param>
        /// <param name="pi">Interface to Profile Info</param>
        public void LoadProfile(string Name, IProfileInfo pi)
        {
            Profile prof;

            pi.SetProfileName(Name);
            pi.SetAttemptsCount(0);
            pi.ClearSplits();
            if (_FindProfile(Name, out prof))
            {
                pi.SetAttemptsCount(prof.Attempts);
                foreach (ProfileRow row in prof.Rows)
                {
                    pi.AddSplit(row.Title, row.Hits, row.PB);
                }
            }
            pi.SetSessionProgress(0);
        }
Ejemplo n.º 9
0
 public static string ToPSHashtable(this IProfileInfo p)
 {
     return
         (String.Format(
              @"@{{
         AllUsersAllHosts = '{0}';
         AllUsersCurrentHost = '{1}';
         AllUsersPowerShellHost = '{2}';
         CurrentUserAllHosts = '{3}';
         CurrentUserCurrentHost = '{4}';
         CurrentUserPowerShellHost = '{5}'}}",
              p.AllUsersAllHosts,
              p.AllUsersCurrentHost,
              p.AllUsersPowerShellHost,
              p.CurrentUserAllHosts,
              p.CurrentUserCurrentHost,
              p.CurrentUserPowerShellHost));
 }
Ejemplo n.º 10
0
        public Form1()
        {
            // The designer sometimes orders the control creation in an order
            // that would call event handlers already during initialization.
            // But not all variables are available yet, so we prevent access to them.
            gpSuccession_ValueChangedSema = true;
            InitializeComponent();
            gpSuccession_ValueChangedSema = false;

            gpSuccession_Height = gpSuccession.Height; // remember expanded size from designer settings

            pi = DataGridView1;                        // for better capsulation
            om = new OutModule(pi);
            sc = new Shortcuts(Handle);

            pi.ProfileChanged += DataGridView1_ProfileChanged;

            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
            ServicePointManager.ServerCertificateValidationCallback += (sender2, certificate, chain, errors) => { return(true); };
        }
Ejemplo n.º 11
0
        public void GetCalculatedSums(out int TotalSplits, out int TotalActiveSplit, out int TotalHits, out int TotalHitsWay, out int TotalPB, out long TotalTime, bool PastOnly)
        {
            bool ActiveProfileFound = false;

            TotalSplits = TotalActiveSplit = TotalHits = TotalHitsWay = TotalPB = 0;
            TotalTime   = 0;

            foreach (ProfileViewControl pvc_tab in ptc.ProfileViewControls)
            {
                IProfileInfo pi_tab = pvc_tab.ProfileInfo;
                int          Splits = pi_tab.SplitCount;

                if ((pi_tab == SelectedProfileInfo) && PastOnly) // When the past should be calculated only, stop when active profile tab found
                {
                    break;
                }

                TotalSplits += Splits;
                for (int i = 0; i < Splits; i++)
                {
                    TotalHits    += pi_tab.GetSplitHits(i);
                    TotalHitsWay += pi_tab.GetSplitWayHits(i);
                    TotalPB      += pi_tab.GetSplitPB(i);
                    TotalTime    += pi_tab.GetSplitDuration(i);
                }

                if (!ActiveProfileFound)
                {
                    if (pi_tab == SelectedProfileInfo) // Active profile tab found
                    {
                        TotalActiveSplit  += pi_tab.ActiveSplit;
                        ActiveProfileFound = true;
                    }
                    else
                    {
                        TotalActiveSplit += Splits;  // Add all splits of preceeding profiles
                    }
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Updates internally cached profile with data from profile info
        /// </summary>
        /// <param name="pi_src">Source ProfileInfo interface</param>
        public void SaveProfile(IProfileInfo pi_src)
        {
            if (null == pi_src)
            {
                return;                 // just for safety should never happen
            }
            if (null == pi_src.ProfileName)
            {
                return;
            }

            Profile prof;

            // look for existing one and create if not exists
            if (!_FindProfile(pi_src.ProfileName, out prof))
            {
                prof      = new Profile();
                prof.Name = pi_src.ProfileName;
                _Profiles.Add(prof);
            }

            prof.Rows.Clear();

            // collecting data, nom nom nom
            prof.Attempts    = pi_src.AttemptsCount;
            prof.ActiveSplit = pi_src.ActiveSplit;
            for (int r = 0; r < pi_src.SplitCount; r++)
            {
                ProfileRow ProfileRow = new ProfileRow();
                ProfileRow.Title        = pi_src.GetSplitTitle(r);
                ProfileRow.Hits         = pi_src.GetSplitHits(r);
                ProfileRow.WayHits      = pi_src.GetSplitWayHits(r);
                ProfileRow.PB           = pi_src.GetSplitPB(r);
                ProfileRow.Duration     = pi_src.GetSplitDuration(r);
                ProfileRow.DurationPB   = pi_src.GetSplitDurationPB(r);
                ProfileRow.DurationGold = pi_src.GetSplitDurationGold(r);
                prof.Rows.Add(ProfileRow);
            }
            prof.SetSessionProgress(pi_src.GetSessionProgress());
        }
Ejemplo n.º 13
0
        }                                                              // used by XML serialization!

        /// <summary>
        /// Set the profile info interface that will be used for all operations
        /// </summary>
        /// <param name="pi">Interface to Profile Info</param>
        public void SetProfileInfo(IProfileInfo pi)
        {
            _pi = pi;
        }
Ejemplo n.º 14
0
 private void ChangeFormStatus(IProfileInfo profile)
 {
     Profile = profile;
     ConfigureForm();
 }
Ejemplo n.º 15
0
 public MaintenanceCarrierForm()
 {
     InitializeComponent();
     Profile = ProfileInfo.CreateProfileInfo(ProfileInfoEnum.ExternalCustomer).Profile;
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Bind object to a data grid
 /// </summary>
 /// <param name="dgv">object to set binding</param>
 public OutModule(IProfileInfo ProfileInfo)
 {
     pi = ProfileInfo;
 }
Ejemplo n.º 17
0
 public static string CreateRunProfileScript(IProfileInfo profileInfo)
 {
     return(String.Format(@"{0} -profile {1}", RunProfiles, profileInfo.ToPSHashtable()));
 }
Ejemplo n.º 18
0
 public ContractMaintenanceForm()
 {
     InitializeComponent();
     profile = ProfileInfo.CreateProfileInfo(ProfileInfoEnum.Producer).Profile;
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Use buffer to create outputfile while patching some data
        /// </summary>
        public void Update()
        {
            //Console.Beep(); // For debugging to check whenever output is beeing generated :)

            if (null == _settings)
            {
                return;
            }
            if (null == _settings.OutputFile)
            {
                return;
            }
            if (null == template) // no valid template read yet?
            {
                ReloadTemplate(); // try to read template again
                if (null == template)
                {
                    return;                   // still invalid, avoid writing empty output file
                }
            }

            StreamWriter sr;
            bool         IsWritingList = false; // Kept for old designs before version 1.10
            bool         IsWritingJson = false;

            try
            {
                sr = new StreamWriter(_settings.OutputFile, false, System.Text.Encoding.Unicode); // UTF16LE
            }
            catch { return; }
            sr.NewLine = Environment.NewLine;

            profCtrl.UpdateDuration();
            IProfileInfo pi = profCtrl.SelectedProfileInfo;

            foreach (string line in template.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (IsWritingJson)
                {
                    if (line.Contains("HITCOUNTER_JSON_END"))
                    {
                        IsWritingJson = false;
                    }
                }
                else if (IsWritingJson)
                {
                    if (line.Contains("HITCOUNTER_LIST_END"))
                    {
                        IsWritingList = false;
                    }
                }
                else if (line.Contains("HITCOUNTER_JSON_START")) // Format data according to RFC 4627 (JSON)
                {
                    int  TotalSplits, TotalActiveSplit, SuccessionHits, SuccessionHitsWay, SuccessionHitsPB;
                    long TotalTime;
                    profCtrl.GetCalculatedSums(out TotalSplits, out TotalActiveSplit, out SuccessionHits, out SuccessionHitsWay, out SuccessionHitsPB, out TotalTime, true);

                    int active      = pi.ActiveSplit;
                    int iSplitCount = pi.SplitCount;
                    int iSplitFirst;
                    int iSplitLast;
                    int InjectedSplitCount = 0;
                    int HiddenSplitCount   = 0;
                    int RunIndex           = 1;
                    int RunIndexActive;

                    sr.WriteLine("{");

                    sr.WriteLine("\"list\": [");

                    // ----- Splits of all previous runs:
                    if (_settings.Succession.IntegrateIntoProgressBar)
                    {
                        // Dump all splits of the (previous) non-visible profiles
                        foreach (ProfileViewControl pvc in profCtrl.ProfileTabControl.ProfileViewControls)
                        {
                            IProfileInfo pi_pvc = pvc.ProfileInfo;
                            if (pi_pvc == pi)
                            {
                                break;               // stop at current profile
                            }
                            for (int r = 0; r < pi_pvc.SplitCount; r++)
                            {
                                if (0 < r + HiddenSplitCount)
                                {
                                    sr.WriteLine(",");                           // separator
                                }
                                sr.Write("[\"" + SimpleHtmlEscape(pi_pvc.GetSplitTitle(r)) + "\", " + (pi_pvc.GetSplitHits(r) + pi_pvc.GetSplitWayHits(r)) + ", " + pi_pvc.GetSplitPB(r) + ", " + pi_pvc.GetSplitWayHits(r) + ", " + RunIndex + ", " + 0 /*NoTime*/ + ", " + 0 /*NoPBTime*/ + "]");
                            }
                            HiddenSplitCount += pi_pvc.SplitCount;
                            RunIndex++;
                        }
                    }

                    // ----- Splits of the current run:
                    RunIndexActive = RunIndex;
                    if (_settings.Succession.HistorySplitVisible && (1 < RunIndex))
                    {
                        // Insert the "history" split
                        InjectedSplitCount++;
                        if (0 < HiddenSplitCount)
                        {
                            sr.WriteLine(",");                       // separator
                        }
                        sr.Write("[\"" + SimpleHtmlEscape(_settings.Succession.HistorySplitTitle) + "\", "
                                 + (SuccessionHits + SuccessionHitsWay) + ", " + SuccessionHitsPB + ", " + SuccessionHitsWay + ", "
                                 + 0 /*Invalid-RunIndex*/ + ", " + 0 /*NoTime*/ + ", " + 0 /*NoPBTime*/ + ", " + 0 /*NoGoldTime*/ + "]");
                    }
                    for (int r = 0; r < iSplitCount; r++)
                    {
                        // Dump all actually visible splits of the current run
                        if (0 < r + HiddenSplitCount + InjectedSplitCount)
                        {
                            sr.WriteLine(",");                                                // separator
                        }
                        sr.Write("[\"" + SimpleHtmlEscape(pi.GetSplitTitle(r)) + "\", "
                                 + (pi.GetSplitHits(r) + pi.GetSplitWayHits(r)) + ", " + pi.GetSplitPB(r) + ", " + pi.GetSplitWayHits(r) + ", "
                                 + RunIndex + ", " + pi.GetSplitDuration(r) + ", " + pi.GetSplitDurationPB(r) + ", " + pi.GetSplitDurationGold(r) + "]");
                    }

                    // ----- Splits of the upcoming runs:
                    RunIndex++;
                    if (_settings.Succession.IntegrateIntoProgressBar)
                    {
                        bool found_active = false;
                        // Dump all splits of the (upcoming) non-visible profiles
                        foreach (ProfileViewControl pvc in profCtrl.ProfileTabControl.ProfileViewControls)
                        {
                            IProfileInfo pi_pvc = pvc.ProfileInfo;
                            if (found_active) // only walk over upcoming profiles
                            {
                                for (int r = 0; r < pi_pvc.SplitCount; r++)
                                {
                                    if (0 < r + HiddenSplitCount + InjectedSplitCount + iSplitCount)
                                    {
                                        sr.WriteLine(",");                                                              // separator
                                    }
                                    sr.Write("[\"" + SimpleHtmlEscape(pi_pvc.GetSplitTitle(r)) + "\", "
                                             + (pi_pvc.GetSplitHits(r) + pi_pvc.GetSplitWayHits(r)) + ", " + pi_pvc.GetSplitPB(r) + ", " + pi_pvc.GetSplitWayHits(r) + ", "
                                             + RunIndex + ", " + 0 /*NoTime*/ + ", " + 0 /*NoPBTime*/ + ", " + 0 /*NoGoldTime*/ + "]");
                                }
                                RunIndex++;
                            }
                            else if (pi_pvc == pi)
                            {
                                found_active = true;
                            }
                        }
                    }
                    sr.WriteLine(""); // no trailing separator
                    sr.WriteLine("],");

                    active      += InjectedSplitCount;
                    iSplitCount += InjectedSplitCount;
                    WriteJsonSimpleValue(sr, "session_progress", pi.GetSessionProgress() + InjectedSplitCount + HiddenSplitCount);

                    // Calculation to show same amount of splits independent from active split:
                    // Example: ShowSplitsCountFinished = 3 , ShowSplitsCountUpcoming = 2 , iSplitCount = 7 (0-6)
                    //  A:  B:  C:  D:  E:  F:  G:
                    // <0>  0   0   0
                    //  1  <1>  1   1   1   1   1
                    //  2   2  <2>  2   2   2   2
                    //  3   3   3  <3>  3   3   3
                    //  4   4   4   4  <4>  4   4
                    //  5   5   5   5   5  <5>  5
                    //                  6   6  <6>

                    if (active < _settings.ShowSplitsCountFinished) // A-C: less previous, more upcoming
                    {
                        iSplitFirst = 0;
                        iSplitLast  = _settings.ShowSplitsCountUpcoming + _settings.ShowSplitsCountFinished;
                    }
                    else if (iSplitCount - active > _settings.ShowSplitsCountUpcoming) // D-E: previous and upcoming as it is
                    {
                        iSplitFirst = active - _settings.ShowSplitsCountFinished;
                        iSplitLast  = active + _settings.ShowSplitsCountUpcoming;
                    }
                    else // F-G: more previous, less upcoming
                    {
                        iSplitFirst = iSplitCount - 1 - _settings.ShowSplitsCountUpcoming - _settings.ShowSplitsCountFinished;
                        iSplitLast  = iSplitCount - 1;
                    }

                    // safety limiters
                    if (iSplitFirst < 0)
                    {
                        iSplitFirst = 0;
                    }
                    if (iSplitCount <= iSplitLast)
                    {
                        iSplitLast = iSplitCount - 1;
                    }

                    active      += HiddenSplitCount;
                    iSplitFirst += HiddenSplitCount;
                    iSplitLast  += HiddenSplitCount;
                    WriteJsonSimpleValue(sr, "run_active", RunIndexActive);
                    WriteJsonSimpleValue(sr, "split_active", active);
                    WriteJsonSimpleValue(sr, "split_first", iSplitFirst);
                    WriteJsonSimpleValue(sr, "split_last", iSplitLast);

                    WriteJsonSimpleValue(sr, "attempts", profCtrl.CurrentAttempts);
                    WriteJsonSimpleValue(sr, "show_attempts", _settings.ShowAttemptsCounter);
                    WriteJsonSimpleValue(sr, "show_headline", _settings.ShowHeadline);
                    WriteJsonSimpleValue(sr, "show_footer", _settings.ShowFooter);
                    WriteJsonSimpleValue(sr, "show_session_progress", _settings.ShowSessionProgress);
                    WriteJsonSimpleValue(sr, "show_progress_bar", _settings.ShowProgressBar);
                    WriteJsonSimpleValue(sr, "show_hits", _settings.ShowHits);
                    WriteJsonSimpleValue(sr, "show_hitscombined", _settings.ShowHitsCombined);
                    WriteJsonSimpleValue(sr, "show_numbers", _settings.ShowNumbers);
                    WriteJsonSimpleValue(sr, "show_pb", _settings.ShowPB);
                    WriteJsonSimpleValue(sr, "show_diff", _settings.ShowDiff);
                    WriteJsonSimpleValue(sr, "show_time", _settings.ShowTimeCurrent);
                    WriteJsonSimpleValue(sr, "show_time_pb", _settings.ShowTimePB);
                    WriteJsonSimpleValue(sr, "show_time_diff", _settings.ShowTimeDiff);
                    WriteJsonSimpleValue(sr, "show_time_footer", _settings.ShowTimeFooter);
                    WriteJsonSimpleValue(sr, "purpose", (int)Purpose);
                    WriteJsonSimpleValue(sr, "severity", (int)Severity);

                    WriteJsonSimpleValue(sr, "font_name", (_settings.StyleUseCustom ? _settings.StyleFontName : null));
                    WriteJsonSimpleValue(sr, "font_url", (_settings.StyleUseCustom ? _settings.StyleFontUrl : ""));
                    WriteJsonSimpleValue(sr, "css_url", (_settings.StyleUseCustom ? _settings.StyleCssUrl : "stylesheet.css"));
                    WriteJsonSimpleValue(sr, "high_contrast", _settings.StyleUseHighContrast);
                    WriteJsonSimpleValue(sr, "high_contrast_names", _settings.StyleUseHighContrastNames);
                    WriteJsonSimpleValue(sr, "use_roman", _settings.StyleUseRoman);
                    WriteJsonSimpleValue(sr, "highlight_active_split", _settings.StyleHightlightCurrentSplit);
                    WriteJsonSimpleValue(sr, "progress_bar_colored", _settings.StyleProgressBarColored);
                    WriteJsonSimpleValue(sr, "width", _settings.StyleDesiredWidth);
                    WriteJsonSimpleValue(sr, "supPB", _settings.StyleSuperscriptPB);

                    WriteJsonSimpleValue(sr, "update_time", (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds);
                    WriteJsonSimpleValue(sr, "timer_paused", !profCtrl.TimerRunning);

                    sr.WriteLine("}");

                    IsWritingJson = true;
                }
                else if (line.Contains("HITCOUNTER_LIST_START")) // Kept for old designs before version 1.10
                {
                    int active = pi.ActiveSplit;

                    for (int r = 0; r < pi.SplitCount; r++)
                    {
                        sr.Write("[\"" + SimpleHtmlEscape(pi.GetSplitTitle(r)) + "\", " + pi.GetSplitHits(r) + pi.GetSplitWayHits(r) + ", " + pi.GetSplitPB(r) + ", " + (r == active ? "1" : "0") + "]");
                    }

                    IsWritingList = true;
                }
                else if ((!IsWritingList) && (!IsWritingJson))
                {
                    sr.WriteLine(line.Replace(Environment.NewLine, ""));
                }
            }

            sr.Close();
        }
 private ProfileInfo(ProfileType profileType)
 {
     _profileType = profileType;
     GetProfile   = CheckProfile();
 }
Ejemplo n.º 21
0
 public static string CreateRunProfileScript( IProfileInfo profileInfo )
 {
     return String.Format(@"{0} -profile {1}", RunProfiles, profileInfo.ToPSHashtable());
 }
Ejemplo n.º 22
0
 public ProfileViewControl()
 {
     InitializeComponent();
     pi = DataGridView1; // for better encapsulation
 }