Exemplo n.º 1
0
        public Worker(Miscellaneous.Action action, TimeSpan interval)
        {
            if (action == null)
            throw new ArgumentNullException("action");

              _thread = new Thread(new ThreadStart(Run));
              _action = action;
              _interval = interval;
        }
Exemplo n.º 2
0
 public ResolveCardBinResponse ResolveCardBin(string cardBin) => Miscellaneous.ResolveCardBin(cardBin);
Exemplo n.º 3
0
 /// <summary>
 /// 获取电量。
 /// </summary>
 /// <returns>电量比例。0-100</returns>
 public static int GetBatteryLevel()
 {
     return(Miscellaneous.GetBatteryLevel());
 }
Exemplo n.º 4
0
 private AboutGUI()
 {
     InitializeComponent();
     _Tool_Version   = DealManagement.GetInstance().GetToolVersion();
     lblVersion.Text = Convert.ToString(_Tool_Version.ValueAmount);
 }
Exemplo n.º 5
0
        void datePickerWeekSelect_ValueChanged(object sender, EventArgs e)
        {
            //DateTime dt = datePickerWeekSelect.Value;
            DateTime dt        = monthCalendar.SelectionStart;
            int      a         = Convert.ToInt16(dt.DayOfWeek);
            DateTime startWeek = dt.AddDays(1 - Convert.ToInt16(dt.DayOfWeek.ToString("d")));
            string   dayOfWeek = startWeek.DayOfWeek.ToString();

            panelWeekDay.Controls.Clear();

            int P_int_x       = 10;
            int l2_int_x      = 10;
            int l_morning_x   = 10;
            int l_afternoon_x = 70;

            for (int i = 0; i < 7; i++)
            {
                DateTime offSet = startWeek.AddDays(i);

                Label l = new Label();
                l.Width       = 120;
                l.Height      = 25;
                l.Location    = new Point(P_int_x, 0);
                P_int_x      += 120;
                l.BorderStyle = BorderStyle.FixedSingle;
                l.TextAlign   = ContentAlignment.MiddleCenter;
                l.Text        = offSet.ToString("yyyy-MM-dd");

                Label l2 = new Label();
                l2.Text     = offSet.DayOfWeek.ToString();
                l2.Width    = 120;
                l2.Height   = 25;
                l2.Location = new Point(l2_int_x, 20);
                l2_int_x   += 120;

                l2.TextAlign   = ContentAlignment.MiddleCenter;
                l2.BorderStyle = BorderStyle.FixedSingle;

                Label l_morning = new Label();
                l_morning.Text        = "上午";
                l_morning.Width       = 60;
                l_morning.Height      = 25;
                l_morning.BorderStyle = BorderStyle.FixedSingle;
                l_morning.TextAlign   = ContentAlignment.MiddleCenter;
                l_morning.Location    = new Point(l_morning_x, 40);
                l_morning_x          += 120;

                Label l_afternoon = new Label();
                l_afternoon.Text        = "下午";
                l_afternoon.Width       = 60;
                l_afternoon.Height      = 25;
                l_afternoon.BorderStyle = BorderStyle.FixedSingle;
                l_afternoon.TextAlign   = ContentAlignment.MiddleCenter;

                l_afternoon.Location = new Point(l_afternoon_x, 40);
                l_afternoon_x       += 120;


                panelWeekDay.Controls.Add(l);
                panelWeekDay.Controls.Add(l2);
                panelWeekDay.Controls.Add(l_morning);
                panelWeekDay.Controls.Add(l_afternoon);
            }
            pictureBox1.Visible  = true;
            panelWeekDay.Visible = true;


            string weekFirstDay = Miscellaneous.GetWeekFirstDayStr(startWeek);

            InitGridData(weekFirstDay);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Transforms the direction in local coordinate to parent transform's coordinate.
 /// </summary>
 /// <param name="localDirection">The direction vector in local coordinate.</param>
 /// <returns>The vector in parent transform's coordinate.</returns>
 protected Vector3 TransformDirectionFromLocalToParent(Vector3 localDirection)
 {
     return(Miscellaneous.TransformDirectionFromLocalToParent(transform, localDirection));
 }
Exemplo n.º 7
0
 public static void IgnoreOutParameter <T>(out T value)
 {
     Miscellaneous.IgnoreOutParameter(out value);
 }
Exemplo n.º 8
0
            public static void Prefix(AttackStackSequence __instance, MessageCenterMessage message)
            {
                try
                {
                    if (!(message is AttackCompleteMessage attackCompleteMessage) || attackCompleteMessage.stackItemUID != __instance.SequenceGUID)
                    {
                        return;
                    }

                    //@ToDo: Find "Stray Shot" targets and call rolls too?
                    List <string> allEffectedTargetIds = __instance.directorSequences[0].allAffectedTargetIds;
                    foreach (string id in allEffectedTargetIds)
                    {
                        ICombatant combatant = __instance.directorSequences[0].Director.Combat.FindCombatantByGUID(id);
                        Logger.Debug($"[AttackStackSequence_OnAttack_Complete_PREFIX] ------> AFFECTED TARGET: {combatant.DisplayName}");

                        if ((combatant is Mech mech) && Attack.TryPenetrateStressResistance(mech, attackCompleteMessage.attackSequence, out int stressLevel, out float ejectionChance))
                        {
                            if (Actor.RollForEjection(mech, stressLevel, ejectionChance))
                            {
                                mech.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(new ShowActorInfoSequence(mech, "PANICKED!", FloatieMessage.MessageNature.PilotInjury, true)));
                                mech.EjectPilot(mech.GUID, attackCompleteMessage.stackItemUID, DeathMethod.PilotEjection, false);

                                // Ejections as a direct result of an attack should count as kills
                                if (__instance.directorSequences[0].attacker is Mech attackingMech && attackingMech.GetPilot() != null)
                                {
                                    Pilot attackingPilot = attackingMech.GetPilot();
                                    attackingPilot.LogMechKillInflicted(-1, attackingPilot.GUID);
                                }
                            }
                            else
                            {
                                string floatieMessage = Miscellaneous.GetStressLevelString(stressLevel);
                                mech.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(new ShowActorInfoSequence(mech, floatieMessage, FloatieMessage.MessageNature.PilotInjury, true)));
                            }
                        }
                    }



                    /* Only rolling on chosen target, ignoring stray shots...
                     * if ((__instance.directorSequences[0].chosenTarget is Mech mech) && Attack.TryPenetrateStressResistance(mech, attackCompleteMessage.attackSequence, out int stressLevel, out float ejectionChance))
                     * {
                     *  if (Actor.RollForEjection(mech, stressLevel, ejectionChance))
                     *  {
                     *      mech.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(new ShowActorInfoSequence(mech, "PANICKED!", FloatieMessage.MessageNature.PilotInjury, true)));
                     *      mech.EjectPilot(mech.GUID, attackCompleteMessage.stackItemUID, DeathMethod.PilotEjection, false);
                     *
                     *      // Ejections as a direct result of an attack should count as kills
                     *      if (__instance.directorSequences[0].attacker is Mech attackingMech && attackingMech.GetPilot() != null)
                     *      {
                     *          Pilot attackingPilot = attackingMech.GetPilot();
                     *          attackingPilot.LogMechKillInflicted(-1, attackingPilot.GUID);
                     *      }
                     *  }
                     *  else
                     *  {
                     *      string floatieMessage = Miscellaneous.GetStressLevelString(stressLevel);
                     *      mech.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(new ShowActorInfoSequence(mech, floatieMessage, FloatieMessage.MessageNature.PilotInjury, true)));
                     *  }
                     * }
                     */
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                }
            }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            long progressSinceLast = (long)value;

            if (job.IsComplete)
            {
                if (this.completed == default(DateTime)) // bugfix, it cant be null it is a value type apparently, so always would say min-value 1/1/0001 if you check against null
                {
                    this.completed = DateTime.Now;
                }

                if (job is FileWriteJob dj)
                {
                    return($"{dj.JobName}\n{dj.FileName}\nCompleted on {this.completed.ToLongDateString()}");
                }
                else
                {
                    return($"Task \"{job.JobName}\" finished! Completed on {this.completed.ToLongDateString()}");
                }
            }
            else if (job.ProgressCompleted > 0)
            {
                if (job is FileWriteJob dj)
                {
                    double speed = 0;// job.ProgressSpeed;

                    string ts = speed == 0 ? "Unknown Date" : DateTime.Now.AddSeconds(job.ProgressRemaining / speed).ToLongDateString();

                    return($"{dj.JobName}\n{dj.FileName}\n{Miscellaneous.ToFileSize(job.ProgressCompleted)} / {Miscellaneous.ToFileSize(job.ExpectedSize)}  -  {Miscellaneous.ToFileSize(speed)} / sec (avg) - Complete on {ts}\nDouble-click progress bar to cancel");
                }
                else
                {
                    double percent = job.PercentCompleted;
                    return($"Task \"{job.JobName}\" is {percent:P1} complete.");
                }
            }
            else
            {
                if (job is FileWriteJob dj)
                {
                    return($"{dj.JobName}\n{dj.FileName}\n{Miscellaneous.ToFileSize(job.ProgressCompleted)} / {Miscellaneous.ToFileSize(job.ExpectedSize)}\nDouble-click progress bar to cancel");
                }
                else
                {
                    return($"Task \"{job.JobName}\" is starting.");
                }
            }
        }
Exemplo n.º 10
0
 public void insert(Miscellaneous miscellaneous)
 {
     miscellaneousData.insertcharges(miscellaneous);
 }
Exemplo n.º 11
0
 public void update1(int Id, Miscellaneous Misc)
 {
     miscellaneousData.update(Id, Misc);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Get the latest Frame maintained by libdexmo client and update all hand controllers
        /// with the corresponding hand data from the Frame.
        /// </summary>
        private void UpdateHandMotion()
        {
            // Get the latest Frame received from libdexmo server.
            Frame newFrame = LibdexmoClientController.GetFrame();

            if (newFrame == null)
            {
                Debug.Log("No new frame.");
                return;
            }
            _connectedHandIdsTemp.Clear();
            // latestHands is a dictionary:
            // Key: ID of the Dexmo device that libdexmo server decides. During the lifetime of the server,
            // each Dexmo device will be assigned a unique id.
            // Value: Latest hand data of the Dexmo device with the corresponding ID.
            Dictionary <int, Hand> latestHands = LibdexmoClientController.LatestHands;
            // connectedDexmoInfos is a dictionary:
            // Key: ID of the Dexmo device that libdexmo server decides.
            // Value: The detailed information of dexmo device with the corresponding ID. This includes
            // the Dexmo device's physical ID that uniquely identifies the device in the world.
            Dictionary <int, DexmoInfo> connectedDexmoInfos = LibdexmoClientController.ConnectedDexmoInfos;

            // Extract all IDs corresponding to the connected Dexmo devices.
            foreach (int id in latestHands.Keys)
            {
                Hand hand = latestHands[id];
                if (hand != null && connectedDexmoInfos[id].Connected)
                {
                    _connectedHandIdsTemp.Add(id);
                }
            }
            if (_connectedHandIdsTemp.Count == 0)
            {
                Debug.Log("No dexmo is connected at the moment");
            }

            // Update each hand controller with the latest hand mocap data
            foreach (UnityHandController handController in _handControllers)
            {
                Hand handData  = null;
                int  matchedId = 0;
                // Hand controller is only active when it receives hand data of the Dexmo
                // device that it binds to.
                if (handController.Active)
                {
                    int id = handController.DeviceInfo.AssignedId;
                    // Check if the Dexmo device that hand controller previously matches is
                    // still connected. Although ID is unique during the lifetime of the
                    // server, when server restarts, the id for the same Dexmo device may change.
                    // Hence, we need to check if the physical ID matches as well.
                    if (_connectedHandIdsTemp.Contains(id) &&
                        handController.DeviceInfo.Equals(connectedDexmoInfos[id]))
                    {
                        // Both ID and physical ID matches, so Dexmo device that hand controller
                        // previously binds is still connected.
                        handData = latestHands[id];
                        _connectedHandIdsTemp.Remove(id);
                        matchedId = id;
                    }
                }
                // Hand controller is not active or the dexmo device that hand controller previously
                // binds is no longer connected. Need to find a new Dexmo device for this hand controller.
                if (handData == null)
                {
                    // Find new dexmo hand that matches the hand controller's left/right property.
                    if (MatchDeviceHand(handController.IsRight,
                                        _connectedHandIdsTemp, latestHands, out matchedId, out handData))
                    {
                        // Matched hand found. The corresponding hand data is stored in handData, which
                        // will later be used to update this hand controller. Remove the matchedId from
                        // the pool of unassigned handIDs.
                        _connectedHandIdsTemp.Remove(matchedId);
                    }
                }
                if (handData == null)
                {
                    // No matched Dexmo device is found. Set hand controller to be inactive.
                    handController.Active = false;
                }
                else
                {
                    // Matched Dexmo device is found. Set hand controller to be active and
                    // update the hand controller with handData and DeviceInfo.
                    handController.Active = true;
                    RawHandDataEventArgs args = new RawHandDataEventArgs(handData);
                    Miscellaneous.InvokeEvent(UpdateRawHandDataEvent, this, args);
                    handController.FixedUpdate(handData);
                    handController.DeviceInfo = connectedDexmoInfos[matchedId];
                }
            }
        }
Exemplo n.º 13
0
 public string GetSensorsString()
 {
     bool[] sensorsArray = new bool[sensors.Count];
     sensors.Values.CopyTo(sensorsArray, 0);
     return(Miscellaneous.ArrayToString(sensorsArray));
 }
        public void Initialize(ILiveEventsOperations sourceOperations, ILiveEventsOperations destinationOperations, ServicePrincipalAuth sourceAuth, ServicePrincipalAuth destinationAuth, Miscellaneous miscellaneous, ILiveOutputsOperations sourceLiveOutputOperations, ILiveOutputsOperations destinationLiveOutputOperations)
        {
            Initialize(sourceOperations, destinationOperations, sourceAuth, destinationAuth, miscellaneous);

            _sourceLiveOutputOperations      = sourceLiveOutputOperations;
            _destinationLiveOutputOperations = destinationLiveOutputOperations;
        }
Exemplo n.º 15
0
 /// <summary>
 /// Invoke event when the this picker is forced to release the held object
 /// because other picker is grabbing the pickable object from this picker.
 /// </summary>
 protected void OnSwitchPickerRelease()
 {
     Miscellaneous.InvokeEvent(SwitchPickerReleaseEvent, this);
 }
Exemplo n.º 16
0
        private void JobStarted(ProgressJob job)
        {
            JobTracker tracker = new JobTracker {
                Job = job
            };

            jobs.Add(job, tracker);

            Dispatcher?.InvokeOrExecute(delegate
            {
                var p             = new StackPanel();
                tracker.Container = p;

                // New progress bar
                ProgressBar bar = new ProgressBar
                {
                    Minimum = 0, Maximum = job.ExpectedSize, Height = 25, Background = Brushes.LightGray,
                };

                // Bind the Progress value to the Value property
                bar.SetBinding(ProgressBar.ValueProperty,
                               new Binding("ProgressCompleted")
                {
                    Source = job,
                    Mode   = BindingMode.OneWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                });


                var colorConverter = new DownloadProgressColorConverter();
                bar.SetBinding(ProgressBar.ForegroundProperty,
                               new Binding("Status")
                {
                    Source = job,
                    Mode   = BindingMode.OneWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                    Converter           = colorConverter,
                });

                bar.MouseDoubleClick += (s, a) => job.Cancel();

                TextBlock t = new TextBlock();
                t.SetBinding(TextBlock.TextProperty,
                             new Binding("ProgressSinceLastUpdate")
                {
                    Source = job,
                    Mode   = BindingMode.OneWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                    Converter           = new DownloadProgressTextConverter(job)
                });

                p.Children.Add(bar);
                p.Children.Add(t);
                p.UpdateLayout();

                DownloadsPanel.Children.Insert(0, p);
                DownloadsPanel.ScrollOwner?.ScrollToTop();
                DownloadsPanel.UpdateLayout();
            });

            if (job is FileWriteJob dj)
            {
                string kind = dj is DownloadJob ? "download" : "file write";
                if (job.ProgressCompleted == 0)
                {
                    logger.Info($"Starting {kind} of size {Miscellaneous.ToFileSize(job.ExpectedSize)}, File: '{dj.FileName}'.");
                }
                else
                {
                    logger.Info($"Resuming {kind} at {Miscellaneous.ToFileSize(job.ProgressCompleted)}/{Miscellaneous.ToFileSize(job.ExpectedSize)}, File: '{dj.FileName}'.");
                }
            }
            else
            {
                logger.Info($"Starting job '{job.JobName}'");
            }
        }
Exemplo n.º 17
0
        private static TObject BytesToObject(byte[] data)
        {
            var inObject = new TObject();

            //Get the header and set its data
            var type   = SerializationHelper.GetFieldOrPropertyType(FieldSizeProvider);
            var header = Miscellaneous.BytesToStruct(type, data, 0);

            SerializationHelper.SetValue(FieldSizeProvider, inObject, header);

            //Get the payload
            int size    = data.Length - Marshal.SizeOf(type);
            var payload = new byte[size];

            Array.ConstrainedCopy(data, data.Length - size, payload, 0, size);

            int offset = 0;

            foreach (var valueOrdinal in FieldValueOrdinals)
            {
                MemberInfo sizeOrdinal;

                if (!FieldSizeOrdinals.TryGetValue(valueOrdinal.Key, out sizeOrdinal))
                {
                    throw new V4ObjectSerializationException("Failed to deserialize object.");
                }

                var length     = Convert.ToInt32(SerializationHelper.GetValue(sizeOrdinal, header));
                var targetType = SerializationHelper.GetFieldOrPropertyType(valueOrdinal.Value);


                if (targetType == null)
                {
                    throw new V4ObjectSerializationException("Failed to deserialize object.");
                }

                if (targetType == typeof(string))
                {
                    var asString = Encoding.UTF8.GetString(payload, offset, length);
                    SerializationHelper.SetValue(valueOrdinal.Value, inObject, asString);
                }
                else if (targetType.GetInterface("ICollection") != null)
                {
                    var genericArguments = targetType.GetGenericArguments();
                    if (genericArguments.Length != 1)
                    {
                        throw new V4ObjectSerializationException("Failed to deserialize object.");
                    }

                    var structCollection = Activator.CreateInstance(targetType) as IList;
                    if (structCollection == null)
                    {
                        throw new V4ObjectSerializationException("Failed to deserialize object.");
                    }

                    var structType     = genericArguments[0];
                    int structSize     = Marshal.SizeOf(structType) + 1;
                    int totalStructs   = length / structSize;
                    int structPosition = offset;

                    for (int i = 0; i < totalStructs; ++i)
                    {
                        structCollection.Add(Miscellaneous.BytesToStruct(structType, payload, structPosition));
                        structPosition += structSize;
                    }

                    SerializationHelper.SetValue(valueOrdinal.Value, inObject, structCollection);
                }

                offset += length;
            }

            return(inObject);
        }
Exemplo n.º 18
0
        public Payslip addThirteenMonthPayToPayslip(Employee employee, Payslip payslip)
        {
            Miscellaneous thirteenMonthPay = miscellaneousService.fetchEmployeeMiscellaneousBenefitByEmployeeId(employee, "ThirteenMonthAllowance");

            return(payrollService.updatePayslipThirteenMonthPay(payslip, thirteenMonthPay));
        }
Exemplo n.º 19
0
 /// <summary>
 /// Transform point in world coordinate to point in parent transform's
 /// coordinate.
 /// </summary>
 /// <param name="worldPoint">Point in world coordinate.</param>
 /// <returns>Point in parent transform's coordinate.</returns>
 protected Vector3 InverseTransformPointInParentCoordinate(Vector3 worldPoint)
 {
     return(Miscellaneous.InverseTransformPointInParentCoordinate(
                transform, worldPoint));
 }
Exemplo n.º 20
0
        public Payslip createPayslip(DateTime startDatePeriod, DateTime endDatePeriod, Employee employee)
        {
            // attendanceLogSheet
            Payslip payslip = new Payslip();

            payslip.employee        = employee;
            payslip.startDatePeriod = startDatePeriod;
            payslip.endDatePeriod   = endDatePeriod;
            List <Attendance> attendances   = attendanceService.fetchEmployeeAttendance(startDatePeriod, endDatePeriod, employee);
            decimal           monthlySalary = decimal.Multiply(employee.jobPosition.salary, AVERAGE_WORKING_DAY_PER_MONTH);

            decimal dailyBasedSalary = 0.00M;

            dailyBasedSalary = employee.jobPosition.salary;
            decimal periodSalary = decimal.Round(salaryService.calculatePeriodSalary(attendances, dailyBasedSalary), 2);

            AttendanceControllerInterface attendanceController = new AttendanceController();
            TimeSpan timeSpent = fetchTotalHoursSpent(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, attendanceController);

            periodSalary    = calculateTotalBasePay(timeSpent, payslip.employee.jobPosition.salary);
            payslip.basePay = periodSalary;

            decimal totalAllowanceAmount = 0.00M;
            MiscellaneousControllerInterface miscellaneousController = new MiscellaneousController();
            decimal foodAllowanceAmount      = fetchFoodAllowance(payslip, miscellaneousController);
            decimal totalFoodAllowanceAmount = calculateTotalSpecificAllowance(foodAllowanceAmount, timeSpent);

            totalAllowanceAmount += totalFoodAllowanceAmount;

            decimal transpoAllowanceAmount      = fetchTranspoAllowance(payslip, miscellaneousController);
            decimal totalTranspoAllowanceAmount = calculateTotalSpecificAllowance(transpoAllowanceAmount, timeSpent);

            totalAllowanceAmount += totalTranspoAllowanceAmount;

            List <Request> overtimeRequests = requestService.fetchOvertimeRequests(employee, startDatePeriod, endDatePeriod);

            payslip.requests = overtimeRequests;

            List <Request> leaveRequests = requestService.fetchLeaveRequest(employee, startDatePeriod, endDatePeriod);

            payslip.requests.AddRange(leaveRequests);

            decimal totalLeaveAmount = decimal.Round(salaryService.calculateDailBasedSalaryWithLeaveRequest(leaveRequests, dailyBasedSalary), 2);

            List <Miscellaneous> benefits = miscellaneousService.fetchMiscellaneousByBenefitType(employee);

            payslip.miscellaneous = benefits;

            RequestControllerInterface requestController = new RequestController();
            SalaryControllerInterface  salaryController  = new SalaryController();
            decimal totalOvertimeAmount = calculateDailyBasedSalaryWithOvertimeRequests(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, requestController, salaryController);

            totalAllowanceAmount += totalOvertimeAmount;

            payslip.totalBenefits = totalAllowanceAmount + totalLeaveAmount;

            decimal cashAdvanceAmount = calculateTotalCashAdvanceAmount(payslip.startDatePeriod, payslip.endDatePeriod, payslip.employee, requestController, salaryController);

            payslip.sssDeduction = decimal.Divide(salaryService.fetchSssDeductionsWithPeriodSalary(monthlySalary), 2);
            payslip.sssDeduction = decimal.Round(payslip.sssDeduction, 2);

            payslip.pagIbigDeduction = decimal.Divide(salaryService.fetchPagIbigDeductionWithPeriodSalary(monthlySalary), 2);
            payslip.pagIbigDeduction = decimal.Round(payslip.pagIbigDeduction, 2);

            payslip.philHealthDeduction = decimal.Divide(salaryService.fetchPhilHealthDeductionWithPeriodSalary(monthlySalary), 2);
            payslip.philHealthDeduction = decimal.Round(payslip.philHealthDeduction, 2);

            Miscellaneous thirteenMonth = miscellaneousService.calculateThirteenMonth(employee, endDatePeriod);

            payslip.taxDeduction = decimal.Divide(salaryService.calculatePeriodSalaryTax(employee, monthlySalary), 2);

            decimal totalDeductions = (decimal.Round(payslip.taxDeduction, 2) + decimal.Round(payslip.sssDeduction, 2) + decimal.Round(payslip.pagIbigDeduction, 2) + decimal.Round(payslip.philHealthDeduction, 2) + decimal.Round(cashAdvanceAmount, 2));

            payslip.totalDeduction = totalDeductions;

            decimal totalSalary = payslip.basePay + payslip.totalBenefits - totalDeductions;

            payslip.netPay = totalSalary;

            return(payrollService.createPayslip(employee, payslip));

            /*
             * List<Request> overtimeRequests = requestService.fetchOvertimeRequests(employee, startDatePeriod, endDatePeriod);
             * payslip.requests = overtimeRequests;
             *
             * periodSalary += decimal.Round(salaryService.calculateDailyBasedSalaryWithOvertimeRequests(overtimeRequests, dailyBasedSalary), 2);
             * Console.WriteLine("periodSalaryWithOvertime---->>" + periodSalary);
             *
             * List<Request> leaveRequests = requestService.fetchLeaveRequest(employee, startDatePeriod, endDatePeriod);
             * payslip.requests.AddRange(leaveRequests);
             *
             * periodSalary += decimal.Round(salaryService.calculateDailBasedSalaryWithLeaveRequest(leaveRequests, dailyBasedSalary), 2);
             * Console.WriteLine("periodSalaryWithLeave---->>" + periodSalary);
             *
             * List<Miscellaneous> benefits = miscellaneousService.fetchMiscellaneousByBenefitType(employee);
             * payslip.miscellaneous = benefits;
             *
             * periodSalary += decimal.Round(salaryService.fetchTotalAmountOfBenefits(benefits, attendances, leaveRequests), 2);
             * Console.WriteLine("periodSalaryWIthBenefits---->>" + periodSalary);
             *
             * //List<Miscellaneous> bonuses = miscellaneousService.fetchBonusMiscellaneousByDescriptionAsDate(employee, startDatePeriod, endDatePeriod);
             * //payslip.miscellaneous.AddRange(bonuses);
             *
             * //periodSalary += salaryService.fetchTotalBonus(bonuses);
             * //Console.WriteLine("periodSalaryWIthBonus---->>" + periodSalary);
             *
             * List<Request> cashAdvanceList = requestService.fetchAllApprovedCashAdvanceRequests(startDatePeriod, endDatePeriod, employee);
             * periodSalary -= decimal.Round(salaryService.fetchTotalCashAdvanceAmount(cashAdvanceList), 2);
             * Console.WriteLine("periodSalaryWIthCashAdvance---->>" + periodSalary);
             *
             * //List<Miscellaneous> deductions = miscellaneousService.fetchMiscellaneousByDeductionType(employee);
             *
             * //periodSalary -= decimal.Round(salaryService.fetchTotalDeductions(deductions), 2);
             *
             * payslip.sssDeduction = decimal.Divide(salaryService.fetchSssDeductionsWithPeriodSalary(monthlySalary), 2);
             * payslip.sssDeduction = decimal.Round(payslip.sssDeduction, 2);
             *
             * payslip.pagIbigDeduction = decimal.Divide(salaryService.fetchPagIbigDeductionWithPeriodSalary(monthlySalary), 2);
             * payslip.pagIbigDeduction = decimal.Round(payslip.pagIbigDeduction, 2);
             *
             * payslip.philHealthDeduction = decimal.Divide(salaryService.fetchPhilHealthDeductionWithPeriodSalary(monthlySalary), 2);
             * payslip.philHealthDeduction = decimal.Round(payslip.philHealthDeduction, 2);
             *
             * periodSalary -= payslip.sssDeduction;
             * periodSalary -= payslip.pagIbigDeduction;
             * periodSalary -= payslip.philHealthDeduction;
             * Console.WriteLine("periodSalaryWIthDeductions---->>" + periodSalary);
             *
             * payslip.taxDeduction = decimal.Divide(salaryService.calculatePeriodSalaryTax(employee, monthlySalary), 2);
             * periodSalary -= payslip.taxDeduction;
             *
             * payslip.netPay = decimal.Round(periodSalary, 2);
             * Console.WriteLine("periodSalaryWithholdingTax---->>" + periodSalary);
             */
        }
Exemplo n.º 21
0
 public static GemData RandomGem()
 {
     return(Miscellaneous.Choose(instance.gems));
 }
        protected void OnSwitchHandCollisionDetection(bool enableCollision)
        {
            GenericEventArgs <bool> args = new GenericEventArgs <bool>(enableCollision);

            Miscellaneous.InvokeEvent(SwitchHandCollisionDetection, this, args);
        }
        public override string ToString()
        {
            string s = "";

            if (From.X == To.X) // vertical line
            {
                s = string.Format("{0}{1}", Miscellaneous.TranslateAxisToLetter(CoordinateFrom.Item1 < CoordinateTo.Item1 ? CoordinateFrom.Item1 : CoordinateTo.Item1), (CoordinateFrom.Item2 < CoordinateTo.Item2 ? CoordinateFrom.Item2 : CoordinateTo.Item2));
            }
            else                        // horizontal line
            {
                s = string.Format("{0}{1}", (CoordinateFrom.Item1 < CoordinateTo.Item1 ? CoordinateFrom.Item1 : CoordinateTo.Item1), Miscellaneous.TranslateAxisToLetter(CoordinateFrom.Item2 < CoordinateTo.Item2 ? CoordinateFrom.Item2 : CoordinateTo.Item2));
            }

            return(s);
        }
        protected void OnSwitchHandMotionTransition(bool enableMotionTransition)
        {
            GenericEventArgs <bool> args = new GenericEventArgs <bool>(enableMotionTransition);

            Miscellaneous.InvokeEvent(SwitchHandMotionTransition, this, args);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Saves the character class level.
        /// </summary>
        /// <returns>CharacterSkill Object</returns>
        public CharacterSkill SaveCharacterSkill()
        {
            SqlDataReader      result;
            DatabaseConnection dbconn     = new DatabaseConnection();
            SqlCommand         command    = new SqlCommand();
            SqlConnection      connection = new SqlConnection(dbconn.SQLSEVERConnString);

            try
            {
                connection.Open();
                command.Connection  = connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "InsertUpdate_CharacterSkill";
                command.Parameters.Add(dbconn.GenerateParameterObj("@CharacterID", SqlDbType.Int, CharacterID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@SkillID", SqlDbType.Int, SkillID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@HalfLevel", SqlDbType.Int, HalfLevel.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@AbilityMod", SqlDbType.Int, AbilityMod.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Trained", SqlDbType.Int, Trained.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@SkillFocus", SqlDbType.Int, SkillFocus.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Miscellaneous", SqlDbType.Int, Miscellaneous.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@FeatTalentMod", SqlDbType.Int, FeatTalentMod.ToString(), 0));
                result = command.ExecuteReader();

                result.Read();
                SetReaderToObject(ref result);
            }
            catch
            {
                Exception e = new Exception();
                this._insertUpdateOK = false;
                this._insertUpdateMessage.Append(e.Message + "                     Inner Exception= " + e.InnerException);
                throw e;
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
            return(this);
        }
        public SendMessageResult SendCommand(string chatRoomId, string token, string targetUserId, string command)
        {
            var    result = new SendMessageResult();
            string userId = chatRoomStorage.GetUserIdByToken(token);

            if (userId == null)
            {
                result.Error = "Chat disconnected!";
                return(result);
            }

            if (!chatRoomStorage.IsUserInRoom(chatRoomId, userId))
            {
                result.Error = "Chat disconnected!";
                return(result);
            }

            var user       = chatUserProvider.GetUser(userId);
            var targetUser = chatUserProvider.GetUser(targetUserId);

            if (command == "ignore")
            {
                chatUserProvider.IgnoreUser(userId, targetUserId);
            }
            else if (command == "kick")
            {
                if (chatUserProvider.IsChatAdmin(userId, chatRoomId) && chatRoomStorage.IsUserInRoom(chatRoomId, targetUserId))
                {
                    chatRoomStorage.RemoveUserFromRoom(chatRoomId, targetUserId);

                    chatRoomStorage.AddMessage(chatRoomId, new Message
                    {
                        Content =
                            string.Format("User {0} has been kicked off the room by {1}.",
                                          targetUser.DisplayName, user.DisplayName),
                        FromUserId  = targetUserId,
                        MessageType = MessageTypeEnum.Kicked,
                        Timestamp   = Miscellaneous.GetTimestamp()
                    });
                }
            }
            else if (command == "ban")
            {
                if (chatUserProvider.IsChatAdmin(userId, chatRoomId) && chatRoomStorage.IsUserInRoom(chatRoomId, targetUserId))
                {
                    chatRoomStorage.RemoveUserFromRoom(chatRoomId, targetUserId);

                    chatRoomStorage.AddMessage(chatRoomId, new Message
                    {
                        Content =
                            string.Format("User {0} has been kicked off the room by {1} (Banned).",
                                          targetUser.DisplayName, user.DisplayName),
                        FromUserId  = targetUserId,
                        MessageType = MessageTypeEnum.Kicked,
                        Timestamp   = Miscellaneous.GetTimestamp()
                    });

                    chatRoomProvider.BanUser(chatRoomId, userId, targetUserId);
                }
            }
            else if (command == "slap")
            {
                chatRoomStorage.AddMessage(chatRoomId, new Message
                {
                    Content =
                        string.Format("{0} slaps {1} around with a large trout.",
                                      user.DisplayName, targetUser.DisplayName),
                    FromUserId  = userId,
                    MessageType = MessageTypeEnum.System,
                    Timestamp   = Miscellaneous.GetTimestamp()
                });
            }

            return(result);
        }
Exemplo n.º 27
0
            // Completeley overriding original method
            public static bool Prefix(CombatHUDMWStatus __instance, Pilot pilot)
            {
                try
                {
                    if (!(pilot.ParentActor is Mech mech))
                    {
                        return(true);
                    }
                    Logger.Info($"[CombatHUDMWStatus_RefreshPilot_PREFIX] Pilot: {pilot.Callsign}");

                    Color inspired = LazySingletonBehavior <UIManager> .Instance.UIColorRefs.blue;
                    Color good     = LazySingletonBehavior <UIManager> .Instance.UIColorRefs.white;
                    Color medium   = LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.StabilityPipsShown.color;
                    Color bad      = LazySingletonBehavior <UIManager> .Instance.UIColorRefs.orange;
                    Color critical = LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.FloatiePilotDamage.color;

                    // Utilize the former injuries item as a general state description
                    CombatHUDStatusStackItem pilotStateHeader = __instance.InjuriesItem;
                    int           stressLevel           = pilot.GetStressLevel();
                    Localize.Text stressLevelDescriptor = new Localize.Text(Miscellaneous.GetStressLevelString(stressLevel), Array.Empty <object>());
                    Localize.Text unknownDescriptor     = new Localize.Text("UNKNOWN", Array.Empty <object>());
                    Localize.Text stateDescriptor       = pilot.IsIncapacitated || pilot.HasEjected ? unknownDescriptor : stressLevelDescriptor;

                    SVGAsset stateIcon = __instance.InjuriesItem.Icon.vectorGraphics;
                    //SVGAsset stateIcon = LazySingletonBehavior<UIManager>.Instance.UILookAndColorConstants.FloatieIconPilotInjury;
                    Color stateColor = Miscellaneous.GetStressLevelColor(stressLevel);

                    //pilotStateHeader.ShowIcon(stateIcon, stateDescription, stateColor);
                    pilotStateHeader.ShowExistingIcon(stateDescriptor, stateColor);
                    pilotStateHeader.AddTooltipString(new Localize.Text("???WILL THIS BE VISIBLE ANYWHERE AT ALL???", new object[] { }), EffectNature.Buff);

                    __instance.InspiredItem.Free();

                    /* TRY: Put pilots personal morale (high|low spirits) in InspiredItem?
                     * if (pilot.HasHighMorale)
                     * {
                     *  Localize.Text highSpiritsDescriptor = new Localize.Text("HIGH SPIRITS", Array.Empty<object>());
                     *  Color highSpiritsColor = LazySingletonBehavior<UIManager>.Instance.UIColorRefs.blue;
                     *  __instance.InspiredItem.ShowExistingIcon(highSpiritsDescriptor, highSpiritsColor);
                     * }
                     * else if (pilot.HasLowMorale)
                     * {
                     *  Localize.Text lowSpiritsDescriptor = new Localize.Text("LOW SPIRITS", Array.Empty<object>());
                     *  Color lowSpiritsColor = LazySingletonBehavior<UIManager>.Instance.UIColorRefs.orange;
                     *  __instance.InspiredItem.ShowExistingIcon(lowSpiritsDescriptor, lowSpiritsColor);
                     * }
                     */



                    // Passives
                    // BEWARE: This needs to be cleared everytime as there's a limited number of stackslots available and there are no control mechanisms or safeguards available!
                    __instance.PassivesList.ClearAllStatuses();

                    // Injuries
                    SVGAsset      injuriesIcon = LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.FloatieIconPilotInjury;
                    Localize.Text injuriesText;
                    Color         injuriesColor;
                    if (pilot.IsIncapacitated)
                    {
                        injuriesText  = new Localize.Text("INCAPACITATED", new object[] { });
                        injuriesColor = critical;
                    }
                    else
                    {
                        injuriesText = new Localize.Text("INJURIES: {0}/{1}", new object[]
                        {
                            pilot.Injuries,
                            pilot.Health
                        });
                        float pilotRemainingHealth = pilot.Health - pilot.Injuries;
                        injuriesColor = (pilotRemainingHealth == 1) ? critical : (pilotRemainingHealth == 2) ? bad : (pilotRemainingHealth < pilot.Health) ? medium : good;
                    }
                    __instance.PassivesList.ShowItem(injuriesIcon, injuriesText, new List <Localize.Text>(), new List <Localize.Text>()).Icon.color = injuriesColor;



                    // StressLevel
                    SVGAsset      stressLevelIcon = LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.FloatieIconPilotInjury;
                    Localize.Text stressLevelText = new Localize.Text("STRESS: {0}/{1}", new object[]
                    {
                        stressLevel,
                        4
                    });
                    Color stressLevelColor = Miscellaneous.GetStressLevelColor(stressLevel);
                    __instance.PassivesList.ShowItem(stressLevelIcon, stressLevelText, new List <Localize.Text>(), new List <Localize.Text>()).Icon.color = stressLevelColor;



                    // Fortitude (Derived from resists, morale and combat experience)
                    int fortitudeValue = (int)Math.Round(Assess.GetResistanceModifiers(mech, true, false));

                    SVGAsset      fortitudeIcon = LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.MoraleDefendButtonIcon;
                    Localize.Text fortitudeText = new Localize.Text("FORTITUDE: {0}{1}", new object[]
                    {
                        fortitudeValue,
                        ""
                    });
                    Color fortitudeColor = pilot.HasMoraleInspiredEffect ? inspired : good;
                    __instance.PassivesList.ShowItem(fortitudeIcon, fortitudeText, new List <Localize.Text>(), new List <Localize.Text>()).Icon.color = fortitudeColor;



                    /* High|Low spirits
                     * if (pilot.HasHighMorale)
                     * {
                     *  SVGAsset highSpiritsIcon = LazySingletonBehavior<UIManager>.Instance.UILookAndColorConstants.StatusInspiredIcon;
                     *  Localize.Text highSpiritsDescriptor = new Localize.Text("HIGH SPIRITS", Array.Empty<object>());
                     *  Color highSpiritsColor = LazySingletonBehavior<UIManager>.Instance.UIColorRefs.blue;
                     *  __instance.PassivesList.ShowItem(highSpiritsIcon, highSpiritsDescriptor, new List<Localize.Text>(), new List<Localize.Text>()).Icon.color = highSpiritsColor;
                     *
                     *  // REF: This variant doesn't change anything regarding color updates
                     *  //CombatHUDStatusStackItem passiveStackItemHighSpirits = __instance.PassivesList.ShowItem(highSpiritsIcon, new Text("DUMMY", Array.Empty<object>()), new List<Localize.Text>(), new List<Localize.Text>());
                     *  //passiveStackItemHighSpirits.ShowExistingIcon(highSpiritsDescriptor, highSpiritsColor);
                     * }
                     * else if (pilot.HasLowMorale)
                     * {
                     *  SVGAsset lowSpiritsIcon = LazySingletonBehavior<UIManager>.Instance.UILookAndColorConstants.StatusInspiredIcon;
                     *  Localize.Text lowSpiritsDescriptor = new Localize.Text("LOW SPIRITS", Array.Empty<object>());
                     *  Color lowSpiritsColor = LazySingletonBehavior<UIManager>.Instance.UIColorRefs.orange;
                     *  __instance.PassivesList.ShowItem(lowSpiritsIcon, lowSpiritsDescriptor, new List<Localize.Text>(), new List<Localize.Text>()).Icon.color = lowSpiritsColor;
                     * }
                     */



                    // Weapons
                    int   functionalWeapons   = mech.Weapons.FindAll(w => w.DamageLevel == ComponentDamageLevel.Functional).Count;
                    int   penalizedWeapons    = mech.Weapons.FindAll(w => w.DamageLevel == ComponentDamageLevel.Penalized).Count;
                    float weaponHealthRatio   = (float)(functionalWeapons - penalizedWeapons / 2) / (float)mech.Weapons.Count;
                    int   weaponHealthPercent = (int)Math.Round(weaponHealthRatio * 100);

                    SVGAsset      weaponHealthIcon = LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.SmallHardpointIcon;
                    Localize.Text weaponHealthText = new Localize.Text("WEAPONS: {0}{1}", new object[]
                    {
                        weaponHealthPercent,
                        "%"
                    });
                    Color weaponHealthColor = (weaponHealthPercent <= 25) ? critical : (weaponHealthPercent <= 50) ? bad : (weaponHealthPercent <= 75) ? medium : good;
                    __instance.PassivesList.ShowItem(weaponHealthIcon, weaponHealthText, new List <Localize.Text>(), new List <Localize.Text>()).Icon.color = weaponHealthColor;



                    // Mech Health
                    float mechHealthRatio   = (mech.SummaryStructureCurrent + mech.SummaryArmorCurrent) / (mech.SummaryStructureMax + mech.SummaryArmorMax);
                    int   mechHealthPercent = (int)Math.Round(mechHealthRatio * 100);

                    SVGAsset      mechHealthIcon       = LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.StatusCoverIcon;
                    Localize.Text mechHealthDescriptor = new Localize.Text("MECH: {0}{1}", new object[] { mechHealthPercent, "%" });
                    Color         mechHealthColor      = (mechHealthPercent <= 25) ? critical : (mechHealthPercent <= 55) ? bad : (mechHealthPercent <= 85) ? medium : good;
                    __instance.PassivesList.ShowItem(mechHealthIcon, mechHealthDescriptor, new List <Localize.Text>(), new List <Localize.Text>()).Icon.color = mechHealthColor;



                    // Skipping original method
                    return(false);
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                    return(true);
                }
            }
        public JoinChatRoomResult JoinChatRoom(string chatRoomId, string href)
        {
            if (href != null)
            {
                HttpContext.Current.Items["href"] = href;
            }

            var result = new JoinChatRoomResult
            {
                FileTransferEnabled = chatSettingsProvider.EnableFileTransfer,
                VideoChatEnabled    = chatSettingsProvider.EnableVideoChat,
                FlashMediaServer    = chatSettingsProvider.FlashMediaServer
            };

            User user;

            try
            {
                user = chatUserProvider.GetCurrentlyLoggedUser();
            }
            catch (System.Security.SecurityException err)
            {
                result.Error = err.Message;
                return(result);
            }

            if (user == null)
            {
                string loginUrl = chatUserProvider.GetLoginUrl(href);
                result.Error = "You need to login in order to use the chat!";
                if (loginUrl != null)
                {
                    result.Error      += " Redirecting to login page...";
                    result.RedirectUrl = loginUrl;
                }
                return(result);
            }

            Room room = chatRoomProvider.GetChatRoom(chatRoomId);

            if (room == null)
            {
                result.Error = "The specified chat room does not exist!";
                return(result);
            }

            #region Messenger
            var  url              = (new Uri(href));
            var  queryKeyValues   = HttpUtility.ParseQueryString(url.Query);
            var  isInitiator      = queryKeyValues["init"];
            var  targetUserId     = queryKeyValues["target"];
            bool alreadyConnected = href.IndexOf('#') == -1 ? false : (href.Substring(href.IndexOf('#')) == "#connected");
            #endregion

            string reason;

            //if messenger
            if (room.Id == "-2")
            {
                //check chat access only for the initiators
                if (isInitiator == "1" && !chatRoomProvider.HasChatAccess(user.Id, room.Id, out reason))
                {
                    if (String.IsNullOrEmpty(reason))
                    {
                        result.Error = "You don't have access to the messenger.";
                    }
                    else
                    {
                        result.Error = reason;
                    }

                    return(result);
                }
            }
            else
            {
                if (!chatRoomProvider.HasChatAccess(user.Id, room.Id, out reason))
                {
                    if (String.IsNullOrEmpty(reason))
                    {
                        result.Error = String.Format("You don't have access to chat room '{0}'.", room.Name);
                    }
                    else
                    {
                        result.Error = reason;
                    }

                    return(result);
                }
            }

            // Ignore max users limit for messengerRoom (roomId = -2)
            if (room.Id != "-2" && chatRoomStorage.GetUsersInRoom(room.Id).Length >= room.MaxUsers)
            {
                result.Error = String.Format("The chat room '{0}' is full. Please try again later.", room.Name);

                return(result);
            }

            chatRoomStorage.AddUserToRoom(room.Id, user.Id);
            chatRoomStorage.AddMessage(room.Id, new Message
            {
                Content =
                    string.Format("User {0} has joined the chat.",
                                  user.DisplayName),
                FromUserId  = user.Id,
                ToUserId    = String.IsNullOrEmpty(targetUserId) ? null : targetUserId,
                MessageType = MessageTypeEnum.UserJoined,
                Timestamp   = Miscellaneous.GetTimestamp()
            });

            #region Messenger

            //delete all messages when starting messenger (not reloading it)
            if (isInitiator != null && !alreadyConnected)
            {
                chatRoomStorage.DeleteAllMessagesFor(room.Id, user.Id);
            }

            if (!alreadyConnected && isInitiator == "1" && !String.IsNullOrWhiteSpace(targetUserId))
            {
                try
                {
                    var targetUser = chatUserProvider.GetUser(targetUserId);

                    //Not sure that MessengerUrl should be constructed here?! timestamp and hash are tied to
                    //the implementation
                    var timestamp = DateTime.Now.ToFileTimeUtc();
                    var hash      = Miscellaneous.CalculateChatAuthHash(targetUserId, user.Id, timestamp.ToString());

                    var request = new ChatRequest
                    {
                        FromThumbnailUrl = user.ThumbnailUrl,
                        FromProfileUrl   = user.ProfileUrl,
                        FromUserId       = user.Id,
                        FromUsername     = user.DisplayName,
                        ToUserId         = targetUserId,
                        ToUsername       = targetUser.DisplayName,
                        MessengerUrl     =
                            String.Format("{0}?init=0&id={1}&target={2}&timestamp={3}&hash={4}",
                                          url.GetLeftPart(UriPartial.Path), targetUserId, user.Id,
                                          timestamp, hash)
                    };

                    messengerProvider.AddChatRequest(request);
                }
                catch (System.Security.SecurityException) { }
            }
            #endregion

            result.ChatRoomName  = room.Name;
            result.ChatRoomTopic = room.Topic;
            result.Users         = chatRoomStorage.GetUsersInRoom(room.Id).Select(chatUserProvider.GetUser).ToArray();
            result.Token         = chatRoomStorage.GenerateUserToken(user.Id);
            result.UserId        = user.Id;
            result.IsAdmin       = chatUserProvider.IsChatAdmin(user.Id, room.Id);

            StopVideoBroadcast(user.Id, room.Id);
            result.Broadcasts = chatRoomStorage.GetBroadcasts(room.Id, user.Id);

            return(result);
        }
Exemplo n.º 29
0
 public override string ToString()
 {
     return(Miscellaneous.TrimPath(Filename, 60));
 }
Exemplo n.º 30
0
 // Initialized the Items Type
 public void InitializeType()
 {
     if (itemType == ItemTypes.Accessory)
     {
         Accessory accessory = new Accessory();
         if (item_Id == -1)
         {
             accessory.InitializeAccessory(Item_Database.GetRandomAccessory(itemLevel), this);
         }
         else
         {
             accessory.InitializeAccessory(Item_Database.GetAccessory(item_Id), this);
         }
     }
     else if (itemType == ItemTypes.Armor)
     {
         Armor armor = new Armor();
         if (item_Id == -1)
         {
             armor.InitializeArmor(Item_Database.GetRandomArmor(itemLevel), this);
         }
         else
         {
             armor.InitializeArmor(Item_Database.GetArmor(item_Id), this);
         }
     }
     else if (itemType == ItemTypes.Monster)
     {
         Miscellaneous misc = new Miscellaneous();
         if (item_Id == -1)
         {
             misc.InitializeMiscellaneous(Item_Database.GetRandomMobDrop(), this);
         }
         else
         {
             misc.InitializeMiscellaneous(Item_Database.GetMobDrop(item_Id), this);
         }
     }
     else if (itemType == ItemTypes.Potion)
     {
         Potion potion = new Potion();
         if (item_Id == -1)
         {
             potion.InitializePotion(Item_Database.GetRandomPotion(), this);
         }
         else
         {
             potion.InitializePotion(Item_Database.GetPotion(item_Id), this);
         }
     }
     else if (itemType == ItemTypes.Quest)
     {
     }
     else if (itemType == ItemTypes.Weapon)
     {
         Weapon weapon = new Weapon();
         if (item_Id == -1)
         {
             weapon.InitializeWeapon(Item_Database.GetRandomWeapon(itemLevel), this);
         }
         else
         {
             weapon.InitializeWeapon(Item_Database.GetWeapon(item_Id), this);
         }
     }
     else if (itemType == ItemTypes.Food)
     {
         Food food = new Food();
         if (item_Id == -1)
         {
             food.InitializeFood(Item_Database.GetRandomFoodDrop(), this);
         }
         else
         {
             food.InitializeFood(Item_Database.GetFoodDrop(item_Id), this);
         }
     }
 }
 private void SetCreateAndEditViewbag(Miscellaneous misc)
 {
     ViewBag.MiscellaneousType = GenericSelectList(db, typeof(Miscellaneous), "MiscellaneousType", misc.MiscellaneousType);
     ViewBag.Supplier = GenericSelectList(db, typeof(Asset), "Supplier", misc.Supplier);
     ViewBag.Owner = GenericSelectList(db, typeof(Asset), "Owner", misc.Owner);
     ViewBag.Manufacturer = GenericSelectList(db, typeof(Miscellaneous), "Manufacturer", misc.Manufacturer);
     ViewBag.ModelName = GenericSelectList(db, typeof(Miscellaneous), "ModelName", misc.ModelName);
 }
Exemplo n.º 32
0
        /// <summary>
        /// Trigger the TriggerStatusChanged event.
        /// </summary>
        protected virtual void OnTriggerStatusChanged()
        {
            AnalogTriggerEventArgs args = new AnalogTriggerEventArgs(_analogValue);

            Miscellaneous.InvokeEvent(TriggerStatusChanged, this, args);
        }