示例#1
0
        public override ICompilationResult GetResult()
        {
            var declaredElemMethod = myConstructorDeclaration.DeclaredElement;

            if (declaredElemMethod == null)
            {
                return(new ElementCompilationResult());
            }

            var instructionBlock = GetInstructionsConnectedSequentially(MyResults);

            var method = MyParams.GetCurrentMethod();

            method.FillWithInstructions(instructionBlock);
//      var baseMembers = MyParams.HierarchyMembers?.GetValuesSafe(declaredElemMethod);
//      if (baseMembers != null)
//      {
//        foreach (var baseMember in baseMembers)
//        {
//          var baseMethodId = CompilerUtils.GetMethodId(baseMember);
//          method.AddBase(baseMethodId);
//        }
//      }

            MyParams.FinishCurrentMethod();
            return(new ElementCompilationResult());
        }
        private async void generateProductionPlanButton_Click(object sender, EventArgs e)
        {
            settings = Properties.Settings.Default;
            MyParams myParams;

            // Hledame nejnovejsi plan, ktery je od prihlaseneho uzivatele a je active
            myParams = new MyParams
            {
                Query = $"{{\"$and\":[{{\"owner\": \"{settings.idUser}\"}},{{\"status\":\"active\"}}]}}",
                Limit = "1",
                Sort  = "-created"
            };
            SuperiorPlan activePlan = (await new SuperiorPlanTDG().GetSuperiorPlansAsync(myParams))[0];

            activePlan.Status = "done";

            // Hledame nejnovejsi plan, ktery je od prihlaseneho uzivatele a je pending
            myParams = new MyParams
            {
                Query = $"{{\"$and\":[{{\"owner\": \"{settings.idUser}\"}},{{\"status\":\"pending\"}}]}}",
                Limit = "1",
                Sort  = "-created"
            };
            SuperiorPlan pendingPlan = (await new SuperiorPlanTDG().GetSuperiorPlansAsync(myParams))[0];

            pendingPlan.Status = "active";

            List <Shift> shifts = await new ShiftTDG().GetShiftsByIdSuperiorPlanAsync(pendingPlan.Id);
            Random       rnd    = new Random();

            foreach (Shift shift in shifts)
            {
                bool changed = false;
                while (shift.IdWorkers.Count > shift.WorkersCount)
                {
                    changed = true;
                    shift.IdWorkers.RemoveAt(rnd.Next(0, shift.IdWorkers.Count));
                }
                if (changed)
                {
                    new ShiftTDG().PatchShiftAsync(shift);
                }
            }
            new SuperiorPlanTDG().PatchSuperiorPlanAsync(pendingPlan);
            new SuperiorPlanTDG().PatchSuperiorPlanAsync(activePlan);
        }
示例#3
0
        public async Task <Notification> GetNotificationByIdAsync(string id)
        {
            var myParams = new MyParams {
                Query = $"{{\"_id\":\"{id}\"}}"
            };
            var client = RefitClient.Service;
            var result = await client.GetNotification(id);

            Notification notification = new Notification
            {
                Id               = result.Id,
                Etag             = result.Etag,
                IdForUsers       = result.IdForUsers,
                IdShift          = result.IdShift,
                IdFromUser       = result.IdFromUser,
                Message          = result.Message,
                NotificationType = result.NotificationType,
                Show             = result.Show
            };

            return(notification);
        }