示例#1
0
        private void LoadConfig()
        {
            if (!Directory.Exists(@"cfg\"))
            {
                Directory.CreateDirectory(@"cfg\");
            }

            string rawJSON;
            string file = @"cfg\settings.json";

            if (File.Exists(file))
            {
                // settings.json
                Encoding encoding = GetEncoding(file);
                rawJSON  = File.ReadAllText(file, encoding);
                settings = JsonConvert.DeserializeObject <SettingsObject>(rawJSON);

                serverNameTextBox.Text            = settings.serverName;
                adminPasswordTextBox.Text         = settings.adminPassword;
                joinPasswordTextBox.Text          = settings.password;
                spectatorPasswordTextBox.Text     = settings.spectatorPassword;
                centraEntryListPathTextBox.Text   = settings.centralEntryListPath;
                carClassComboBox.SelectedItem     = settings.carGroup != null && settings.carGroup.Length > 0 ? "    " + settings.carGroup : "    FreeForAll";
                maxCarSlotsNumericUpDown.Value    = InNumUpDnRange(settings.maxCarSlots, maxCarSlotsNumericUpDown);
                TRRequirementNumericUpDown.Value  = InNumUpDnRange(settings.trackMedalsRequirement, TRRequirementNumericUpDown);
                SARequirementNumericUpDown.Value  = InNumUpDnRange(settings.safetyRatingRequirement, SARequirementNumericUpDown);
                RCRequirementNumericUpDown.Value  = InNumUpDnRange(settings.racecraftRatingRequirement, RCRequirementNumericUpDown);
                isRaceLockedCheckBox.Checked      = settings.isRaceLocked == 1 ? true : false;
                shortFormationCheckBox.Checked    = settings.shortFormationLap == 1 ? true : false;
                dumpEntryListCheckBox.Checked     = settings.dumpEntryList == 1 ? true : false;
                dumpLeaderboardsCheckBox.Checked  = settings.dumpLeaderboards == 1 ? true : false;
                randomizeTrackCheckBox.Checked    = settings.randomizeTrackWhenEmpty == 1 ? true : false;
                autoDQCheckBox.Checked            = settings.allowAutoDQ == 1 ? true : false;
                isPrepPhaseLockedCheckBox.Checked = settings.isLockedPrepPhase == 1 ? true : false;
                switch (settings.formationLapType)
                {
                case 0:
                    formationLapTypeComboBox.SelectedItem = "Old";
                    break;

                case 1:
                    formationLapTypeComboBox.SelectedItem = "Manual";
                    break;

                default:
                    formationLapTypeComboBox.SelectedItem = "Default";
                    break;
                }
            }

            file = @"cfg\assistRules.json";
            if (File.Exists(file))
            {
                // assistRules.json
                Encoding encoding = GetEncoding(file);
                rawJSON = File.ReadAllText(file, encoding);
                assist  = JsonConvert.DeserializeObject <AssistObject>(rawJSON);

                idealLineCheckBox.Checked       = assist.disableIdealLine == 0;
                autoSteeringCheckBox.Checked    = assist.disableAutosteer == 0;
                autoPitLimiterCheckBox.Checked  = assist.disableAutoPitLimiter == 0;
                autoShiftingCheckBox.Checked    = assist.disableAutoGear == 0;
                autoStartEngineCheckBox.Checked = assist.disableAutoEngineStart == 0;
                autoWipersCheckBox.Checked      = assist.disableAutoWiper == 0;
                autoLightsCheckBox.Checked      = assist.disableAutoLights == 0;
                autoClutchCheckBox.Checked      = assist.disableAutoClutch == 0;
                maxStabilityNumericUpDown.Value = InNumUpDnRange(assist.stabilityControlLevelMax, maxStabilityNumericUpDown);
            }

            file = @"cfg\event.json";
            if (File.Exists(file))
            {
                // event.json
                Encoding encoding = GetEncoding(file);
                rawJSON     = File.ReadAllText(file, encoding);
                eventObject = JsonConvert.DeserializeObject <EventObject>(rawJSON);

                for (int i = 0; i < TrackComboBox.Items.Count; i++)
                {
                    if (((Track)TrackComboBox.Items[i]).alias == eventObject.track)
                    {
                        TrackComboBox.SelectedIndex = i;
                        break;
                    }
                }
                preRaceWaitTimeNumericUpDown.Value  = InNumUpDnRange(eventObject.preRaceWaitingTimeSeconds, preRaceWaitTimeNumericUpDown);
                postRaceWaitTimeNumericUpDown.Value = InNumUpDnRange(eventObject.postRaceSeconds, postRaceWaitTimeNumericUpDown);
                overTimeNumericUpDown.Value         = InNumUpDnRange(eventObject.sessionOverTimeSeconds, overTimeNumericUpDown);
                tempTrackBar.Value                          = InTrackBarRange(eventObject.ambientTemp, tempTrackBar);
                cloudCoverageTrackBar.Value                 = InTrackBarRange((int)(eventObject.cloudLevel * 10), cloudCoverageTrackBar);
                rainTrackBar.Value                          = InTrackBarRange((int)(eventObject.rain * 10), rainTrackBar);
                weatherRandomnessTrackBar.Value             = InTrackBarRange(eventObject.weatherRandomness, weatherRandomnessTrackBar);
                simracerWeatherConditionsCheckBox.Checked   = eventObject.simracerWeatherConditions == 1 ? true : false;
                fixedConditionQualificationCheckBox.Checked = eventObject.isFixedConditionQualification == 1 ? true : false;

                foreach (Session session in eventObject.sessions)
                {
                    switch (session.sessionType.ToUpper())
                    {
                    case "P":
                        pCheckBox.Checked             = true;
                        pStartTimeNumericUpDown.Value = InNumUpDnRange(session.hourOfDay, pStartTimeNumericUpDown);
                        pTimeScaleNumericUpDown.Value = InNumUpDnRange(session.timeMultiplier, pTimeScaleNumericUpDown);
                        pDurationNumericUpDown.Value  = InNumUpDnRange(session.sessionDurationMinutes, pDurationNumericUpDown);
                        switch (session.dayOfWeekend)
                        {
                        case 1:
                            pFridayRadioButton.Checked = true;
                            break;

                        case 2:
                            pSaturdayRadioButton.Checked = true;
                            break;

                        case 3:
                            pSundayRadioButton.Checked = true;
                            break;

                        default:
                            break;
                        }
                        break;

                    case "Q":
                        qCheckBox.Checked             = true;
                        qStartTimeNumericUpDown.Value = InNumUpDnRange(session.hourOfDay, qStartTimeNumericUpDown);
                        qTimeScaleNumericUpDown.Value = InNumUpDnRange(session.timeMultiplier, qTimeScaleNumericUpDown);
                        qDurationNumericUpDown.Value  = InNumUpDnRange(session.sessionDurationMinutes, qDurationNumericUpDown);
                        switch (session.dayOfWeekend)
                        {
                        case 1:
                            qFridayRadioButton.Checked = true;
                            break;

                        case 2:
                            qSaturdayRadioButton.Checked = true;
                            break;

                        case 3:
                            qSundayRadioButton.Checked = true;
                            break;

                        default:
                            break;
                        }
                        break;

                    case "R":
                        rCheckBox.Checked             = true;
                        rStartTimeNumericUpDown.Value = InNumUpDnRange(session.hourOfDay, rStartTimeNumericUpDown);
                        rTimeScaleNumericUpDown.Value = InNumUpDnRange(session.timeMultiplier, rTimeScaleNumericUpDown);
                        rDurationNumericUpDown.Value  = InNumUpDnRange(session.sessionDurationMinutes, rDurationNumericUpDown);
                        switch (session.dayOfWeekend)
                        {
                        case 1:
                            rFridayRadioButton.Checked = true;
                            break;

                        case 2:
                            rSaturdayRadioButton.Checked = true;
                            break;

                        case 3:
                            rSundayRadioButton.Checked = true;
                            break;

                        default:
                            break;
                        }
                        break;

                    default:
                        break;
                    }
                }
                if (!pCheckBox.Checked && !qCheckBox.Checked)
                {
                    pCheckBox.Checked = true;
                }
            }

            file = @"cfg\eventRules.json";
            if (File.Exists(file))
            {
                // eventRules.json
                Encoding encoding = GetEncoding(file);
                rawJSON    = File.ReadAllText(file, encoding);
                eventRules = JsonConvert.DeserializeObject <EventRulesObject>(rawJSON);

                pitWindowsLengthNumericUpDown.Value      = InNumUpDnRange(eventRules.pitWindowLengthSec, pitWindowsLengthNumericUpDown);
                driverStintTimeNumericUpDown.Value       = InNumUpDnRange(eventRules.driverStintTimeSec, driverStintTimeNumericUpDown);
                mandatoryPitStopCountNumericUpDown.Value = InNumUpDnRange(eventRules.mandatoryPitstopCount, mandatoryPitStopCountNumericUpDown);
                maxTotalDrivingTimeNumericUpDown.Value   = InNumUpDnRange(eventRules.maxTotalDrivingTime, maxTotalDrivingTimeNumericUpDown);
                maxDriversCountNumericUpDown.Value       = InNumUpDnRange(eventRules.maxDriversCount, maxDriversCountNumericUpDown);
                tyreSetsNumericUpDown.Value         = InNumUpDnRange(eventRules.tyreSetCount, tyreSetsNumericUpDown);
                refuellingAllowedCheckBox.Checked   = eventRules.isRefuellingAllowedInRace;
                refuellingTimeFixedCheckBox.Checked = eventRules.isRefuellingTimeFixed;
                refuellingRequiredCheckBox.Checked  = eventRules.isMandatoryPitstopRefuellingRequired;
                tyreChangeRequiredCheckBox.Checked  = eventRules.isMandatoryPitstopTyreChangeRequired;
                driverSwapRequiredCheckBox.Checked  = eventRules.isMandatoryPitstopSwapDriverRequired;
            }

            file = @"cfg\configuration.json";
            if (File.Exists(file))
            {
                // configuration.json
                Encoding encoding = GetEncoding(file);
                rawJSON       = File.ReadAllText(file, encoding);
                configuration = JsonConvert.DeserializeObject <ConfigurationObject>(rawJSON);

                UDPNumericUpDown.Value            = InNumUpDnRange(configuration.udpPort, UDPNumericUpDown);
                TCPNumericUpDown.Value            = InNumUpDnRange(configuration.tcpPort, TCPNumericUpDown);
                maxConnectionsNumericUpDown.Value = InNumUpDnRange(configuration.maxConnections, maxConnectionsNumericUpDown);
                lanDiscoveryCheckBox.Checked      = configuration.lanDiscovery == 1 ? true : false;
                registerToLobbyCheckBox.Checked   = configuration.registerToLobby == 1 ? true : false;
            }
        }
示例#2
0
        protected override bool AfterApproval(string instanceId, string option, string action)
        {
            ///对于加签
            if (IsAddSign())
            {
                return(true);
            }
            var context    = DBContext.GetSysContext();
            var bizContext = DBContext.GetBizContext();
            ///更新当前步骤审批人处理记录
            ///
            var bizInfo = bizContext.OA_ITSupport_Form.FirstOrDefault(x => x.FormID == _BPMContext.ProcInst.FormId);

            var currentStep = bizContext.OA_ITSupport_Step.FirstOrDefault(x => x.Id == bizInfo.CurrentStepId);

            currentStep.FinishTime = DateTime.Now;
            currentStep.StartType  = (int)ITSupportStatus.已转出;

            ITSupportStatus nextStatus = ITSupportStatus.结束;

            switch (action)
            {
            case "转出":
                nextStatus = ITSupportStatus.待领取;
                break;

            case "领取":
                nextStatus = ITSupportStatus.处理;
                break;

            default:
                break;
            }
            if (nextStatus != ITSupportStatus.结束)
            {
                string stepId = Guid.NewGuid().ToString();
                if (nextStatus == ITSupportStatus.待领取)
                {
                    bizInfo.ProcessGroupId = AssistObject.ToString();//更换组
                }

                bizContext.OA_ITSupport_Step.InsertOnSubmit(new Pkurg.PWorldBPM.Business.BIZ.OA_ITSupport_Step()
                {
                    Id             = stepId,
                    FormID         = _BPMContext.ProcInst.FormId,
                    InstanceId     = _BPMContext.ProcID,
                    StartTime      = DateTime.Now,
                    OrderId        = currentStep.OrderId.Value + 1,
                    StartType      = (int)nextStatus,
                    ProcessGroupId = bizInfo.ProcessGroupId
                });

                List <Pkurg.PWorldBPM.Business.Sys.V_Pworld_UserInfo> stepUsers = new List <Pkurg.PWorldBPM.Business.Sys.V_Pworld_UserInfo>();
                if (nextStatus == ITSupportStatus.待领取)
                {
                    stepUsers = ITSupportCommon.GetUserListByGroupId(int.Parse(AssistObject.ToString()));
                    NotifyUsers(stepUsers);
                }
                else if (nextStatus == ITSupportStatus.处理)
                {
                    stepUsers.Add(new Pkurg.PWorldBPM.Business.Sys.V_Pworld_UserInfo()
                    {
                        LoginName    = _BPMContext.CurrentUser.LoginId,
                        EmployeeCode = _BPMContext.CurrentPWordUser.EmployeeCode
                    });
                }

                foreach (var item in stepUsers)
                {
                    bizContext.OA_ITSupport_Step_Users.InsertOnSubmit(new OA_ITSupport_Step_Users()
                    {
                        StepId    = stepId,
                        UserCode  = item.EmployeeCode,
                        LoginName = item.LoginName
                    });
                }

                bizInfo.CurrentStepId = stepId;//更换步骤
            }
            else//处理或驳回
            {
                bizInfo.CurrentStepId = "-1";
                if (action == "处理")
                {
                    bizInfo.ProcessResult = 1;
                }
                if (action == "驳回")
                {
                    bizInfo.ProcessResult = 2;
                }
            }

            bizContext.SubmitChanges();

            return(true);
        }