Пример #1
0
 public int GetFreeSpace(DateTime date, int delegation)
 {
     try
     {
         var specialdays = _context.SpecialDays.Where(r => r.DelegationId == delegation && r.Date == date.Date);
         if (specialdays.Any())
         {
             var specialDay = specialdays.FirstOrDefault();
             if (specialDay.IsNonWorking)
             {
                 return(0);
             }
             var speSche =
                 _context.SpecialDaysSchedules.Where(r => r.DelegationId == delegation && r.Date == date.Date);
             return(speSche.Any() ? speSche.Sum(r => r.Capacity) : 0);
         }
         var weekday = ConverterData.GetWeekEnumDay(date.DayOfWeek);
         var query   = _context.Schedules.Where(r => r.DelegationId == delegation && r.WeekdayId == (int)weekday);
         return(query.Any() ? query.Sum(r => r.Capacity) : 0);
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Пример #2
0
        public ConverterData GetInvoiceConverterData(int invoiceId, string converterUrl, string storageUrl, string revisionId)
        {
            if (invoiceId <= 0)
            {
                throw new ArgumentException();
            }

            var invoice = DaoFactory.GetInvoiceDao().GetByID(invoiceId);

            if (invoice == null)
            {
                throw new ItemNotFoundException();
            }

            if (!CRMSecurity.CanAccessTo(invoice))
            {
                throw CRMSecurity.CreateSecurityException();
            }

            var converterData = new ConverterData
            {
                ConverterUrl = converterUrl,
                StorageUrl   = storageUrl,
                RevisionId   = revisionId,
                InvoiceId    = invoiceId
            };

            var existingFile = invoice.GetInvoiceFile();

            if (existingFile != null)
            {
                converterData.FileId = invoice.FileID;
                return(converterData);
            }

            if (string.IsNullOrEmpty(converterUrl) || string.IsNullOrEmpty(storageUrl) || string.IsNullOrEmpty(revisionId))
            {
                return(PdfCreator.StartCreationFileAsync(invoice));
            }
            else
            {
                var convertedFile = PdfCreator.GetConvertedFile(converterData);
                if (convertedFile != null)
                {
                    invoice.FileID = Int32.Parse(convertedFile.ID.ToString());
                    Global.DaoFactory.GetInvoiceDao().UpdateInvoiceFileID(invoice.ID, invoice.FileID);
                    Global.DaoFactory.GetRelationshipEventDao().AttachFiles(invoice.ContactID, invoice.EntityType, invoice.EntityID, new[] { invoice.FileID });

                    converterData.FileId = invoice.FileID;
                    return(converterData);
                }
                else
                {
                    return(converterData);
                }
            }
        }
Пример #3
0
        //public async Task<int> CancelAppointment(Guid appointmentId)
        //{
        //    try
        //    {
        //        int count = 0;
        //        Guid requestId = appointmentId;
        //        string userId = string.Empty;
        //        var value = Convert.ToInt32(_context.Configurations.FirstOrDefault(r => r.Name == "NumberOfDates").Value);
        //        var appoinments = _context.Appoinments.Where(r => r.AppoinmentId.Equals(appointmentId));
        //        foreach (var apoin in appoinments)
        //        {
        //            var allAppoinments = _context.Appoinments.Where(r => r.RequestId.Equals(apoin.RequestId)).ToList();
        //            foreach (var all in allAppoinments)
        //            {
        //                count = count + 1;
        //                requestId = all.RequestId;
        //            }
        //        }
        //        if (count == value)
        //        {
        //            /* CANCELAR Appoinments */
        //            var apps = _context.Appoinments.Find(appointmentId);
        //            var reqStas = new List<RequestStatu>();
        //            apps.IsAttended = false;
        //            apps.IsCancelled = true;
        //            //_context.Appoinments.AddOrUpdate(apps);

        //            /* CANCELAR RequestStatus (Cancelar los IsCurrentStatus = 1 y Agregar nueva fila) */
        //            var selectRequestStatus = _context.RequestStatus.Where(r => r.RequestId == requestId && r.IsCurrentStatus == true);
        //            foreach (var query in selectRequestStatus)
        //            {
        //                query.IsCurrentStatus = false;
        //                //userId = query.UserId;
        //            }
        //            var reqStatus = new RequestStatu
        //            {
        //                RequestId = requestId,
        //                StatusId = 410,
        //                Date = DateTime.Now,
        //                IsCurrentStatus = true,
        //                //UserId = userId,
        //                Observations = "",
        //                //ElapsedDays = 0,
        //                //ElapsedWorkDays = 0,
        //                //Data = null
        //            };

        //            Request req = new Request();
        //            req.RequestId = reqStatus.RequestId;
        //            req.IsComplete = false;
        //            reqStas.Add(reqStatus);
        //          //  _context.Requests.AddOrUpdate(req);
        //            _context.RequestStatus.AddOrUpdate(reqStatus);
        //        }
        //        else
        //        {
        //            var app = _context.Appoinments.Find(appointmentId);
        //            app.IsAttended = false;
        //            app.IsCancelled = true;
        //            _context.Appoinments.AddOrUpdate(app);
        //        }
        //        return await _context.SaveChangesAsync();
        //    }
        //    catch (Exception exception)
        //    {
        //        throw exception;
        //    }
        //}


        public async Task <CalendarApi> GetCalendarByMonthAndDelegation(int delegationId, DateTime montYear)


        {
            try
            {
                var calendar = new CalendarApi {
                    Days = new DayCalendar[6, 7]
                };
                var initDate = new DateTime(montYear.Year, montYear.Month, 1, 0, 0, 0);
                var init     = new DateTime(montYear.Year, montYear.Month, 1, 0, 0, 0);
                var day      = ConverterData.GetWeekEnumDay(init.DayOfWeek);
                var space    = 0;
                var occu     = 0;

                for (var i = 0; i < 6; i++)
                {
                    for (var j = 0; j < 7; j++)
                    {
                        if (i == 0)
                        {
                            if (j + 1 >= (int)day)
                            {
                                init  = j + 1 == (int)day ? init : init.AddDays(1);
                                space = GetFreeSpace(init, delegationId);
                                occu  = GetOccupiedSpace(init, delegationId);
                                calendar.Days[i, j] = FillAvalitiyAndRate(space, occu, init);
                            }
                            else
                            {
                                calendar.Days[i, j] = FillAvalitiyAndRate(space, occu, null);
                            }
                        }
                        else
                        {
                            if (init.AddDays(1).Month == initDate.Month)
                            {
                                init  = init.AddDays(1);
                                space = GetFreeSpace(init, delegationId);
                                occu  = GetOccupiedSpace(init, delegationId);
                                calendar.Days[i, j] = FillAvalitiyAndRate(space, occu, init);
                            }
                            else
                            {
                                calendar.Days[i, j] = FillAvalitiyAndRate(space, occu, null);
                            }
                        }
                    }
                }
                return(calendar);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
        public async Task <Entitle> GetEntitleByCurp(string curp)
        {
            try
            {
                var entitle = await _sipeAv.GetEntitleByCurpAsync(curp);

                if (entitle == null)
                {
                    return(null);
                }

                if (entitle.DirectType == "ER")
                {
                    string mensaje = _penContext.Messages.ToList().Where(x => x.Key == ConfigurationManager.AppSettings["tDirectoER"]).Select(x => new Message
                    {
                        MessageId   = x.MessageId,
                        Key         = x.Key,
                        Description = x.Description,
                    }).FirstOrDefault().Description;
                }
                var ent   = ConverterData.EntitleConverter(entitle);
                var entdb = _context.Entitles.FirstOrDefault(r => r.CURP == curp);
                //if (String.IsNullOrEmpty(entitle.DelegationCode))
                //{
                //    ent.Delegation = new Delegation();
                //    ent.Delegation.DelegationId = -999;
                //    return ent;
                //}
                //var delegationCode = int.Parse(entitle.DelegationCode);
                //var delegation = _context.Delegations.FirstOrDefault(r => r.DelegationId == delegationCode);
                //if (delegation != null)
                //{
                //    ent.DelegationId = delegation.DelegationId;
                //    ent.Delegation = delegation;
                //}
                //var regimen = await _sipeAv.GetRegimenByNoIsssteAsync(noIssste);
                //if (regimen != null)
                //    ent.RegimeType = regimen.RegimenDescription;
                if (entdb != null && String.IsNullOrEmpty(ent.Email) && String.IsNullOrEmpty(ent.Telephone))
                {
                    ent.Email     = entdb.Email;
                    ent.Telephone = entdb.Telephone;
                }
                var res = await SaveEntitle(ent);

                return(ent);
                // return _context.Entitles.Find(curp);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Пример #5
0
        public LinearConverter(ConverterData privateData)
        {
            if (privateData.Channels < 1)
            {
                throw new BadChannelCountException();
            }

            MagicMarker   = default;
            ConverterData = privateData;

            Channels = privateData.Channels;
        }
Пример #6
0
    // Update is called once per frame
    void Update()
    {
        GenericUpdateData gud = TubeSimulate.generic[1].genericUpdateData[converterId];

        timeLeft = gud.timeLeft;
        ConverterData convDat = TubeSimulate.self.getConverterData(converterId);

        for (int i = 0; i < current.Length; ++i)
        {
            current[i] = convDat.srcCurrent[i];
        }
    }
        public async Task <List <Debtor> > GetDebtorsbyNoIssste(string noIssste)
        {
            try
            {
                var debtorsSipe = await _sipeAv.GetRelativesByNoIsssteAsync(noIssste);

                return(debtorsSipe.Select(debtor => ConverterData.RelativeConverter(debtor)).ToList());
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Пример #8
0
    public int addConverter()
    {
        int ret = converterCount;

        converterCount++;
        //converters.Add(new ConverterData());
        ConverterData conv = converters[ret];

        conv.init(12f, registerHeadState());
        conv.setItemRequirements(new ushort[] { 1, 2 }, new byte[] { 2, 3 }, 1, 1);
        converters[ret] = conv;
        return(ret);
    }
        public async Task <Entitle> GetEntitleByNoIssste(string noIssste)
        {
            try
            {
                var entitle = await _sipeAv.GetEntitleByNoIsssteAsync(noIssste);

                if (entitle == null)
                {
                    return(null);
                }

                if (entitle.DirectType == "ER")
                {
                    //return null;
                    string mensaje = _penContext.Messages.ToList().Where(x => x.Key == ConfigurationManager.AppSettings["tDirectoER"]).Select(x => new Message
                    {
                        Description = x.Description,
                        MessageId   = x.MessageId,
                        Key         = x.Key,
                    }).FirstOrDefault().Description;
                }
                var ent = ConverterData.EntitleConverter(entitle);
                //if (_context.Entitles.Select(x => x.DelegationId) != null)
                //{
                var entdb = _context.Entitles.FirstOrDefault(r => r.NoISSSTE == noIssste);


                //var regimen = await _sipeAv.GetRegimenByNoIsssteAsync(noIssste);

                //if (regimen != null)
                //{
                //    ent.RegimeType = regimen.RegimenDescription;
                //    ent.RegimeKey = regimen.RegimenKey;
                //}
                if (entdb != null && String.IsNullOrEmpty(ent.Email) && String.IsNullOrEmpty(ent.Telephone))
                {
                    ent.Email     = entdb.Email;
                    ent.Telephone = entdb.Telephone;
                }
                //    }

                var res = await SaveEntitle(ent);

                return(ent);
            }
            catch (Exception exception)
            {
                throw (exception);
            }
        }
Пример #10
0
    void linkTubeToConverter(int converterIdx, int tubeIdx) // converter ==> tube
    {
        CanTakeState cts = headStates[tubes[tubeIdx].headArrayIdx];

        cts.init();
        cts.tailType = CTS_Tube;
        cts.tailIdx  = tubeIdx;
        cts.addNewHead(CTS_Converter, converterIdx);
        headStates[tubes[tubeIdx].headArrayIdx] = cts;

        ConverterData conv = converters[converterIdx];

        conv.tailArrayIdx        = tubes[tubeIdx].headArrayIdx;
        converters[converterIdx] = conv;
    }
Пример #11
0
    void linkConverterToTubes(int[] tubeIdx, int converterIdx) // tubes ==> converter
    {
        ConverterData conv = converters[converterIdx];

        //TubeData tube = tubes[tubeIdx];
        CanTakeState cts = headStates[conv.headArrayIdx];

        cts.init();
        cts.tailType = CTS_Converter;
        cts.tailIdx  = converterIdx;

        for (int i = 0; i < tubeIdx.Length; ++i)
        {
            cts.addNewHead(CTS_Tube, tubeIdx[i]);
            TubeData tube = tubes[tubeIdx[i]];
            tube.tailArrayIdx = conv.headArrayIdx;
            tubes[tubeIdx[i]] = tube;
        }
        headStates[conv.headArrayIdx] = cts;
    }
Пример #12
0
        public async Task <ObservableCollection <PeliculaDetalleType> > BuscarPelicula(string peliculaBuscar)
        {
            ObservableCollection <Db_Peliculas> datosRetorno = new ObservableCollection <Db_Peliculas> ();

            if (_hayInternet)
            {
                datosRetorno = await webService.ObtenerListaPeliculas();
            }
            else
            {
                datosRetorno = dataRepository.DameListaPeliculas();
            }

            ObservableCollection <Db_Peliculas> nuevo = new ObservableCollection <Db_Peliculas>();

            if (datosRetorno != null)
            {
                nuevo = new ObservableCollection <Db_Peliculas> (datosRetorno.Where(x => x.Titulo.ToUpper().Contains(peliculaBuscar.ToUpper())));
            }
            return(ConverterData.ConverteCollectionPeliculasToType(nuevo));
        }
Пример #13
0
        public async Task <ObservableCollection <PeliculaDetalleType> > DameListaPelis()
        {
            ObservableCollection <Db_Peliculas> datosRetorno = new ObservableCollection <Db_Peliculas>();

            if (HayInternet())
            {
                datosRetorno = await webService.ObtenerListaPeliculas();

                if (datosRetorno != null)
                {
                    Task.Factory.StartNew(() =>
                    {
                        dataRepository.GuardarListaPeliculas(datosRetorno);
                    });
                }
            }
            else
            {
                datosRetorno = dataRepository.DameListaPeliculas();
            }
            return(ConverterData.ConverteCollectionPeliculasToType(datosRetorno));
        }
Пример #14
0
        protected override Value <string> ConvertTo(ConverterData <object> input)
        {
            if (input.ActualValue.GetType().IsArray)
            {
                if (input.ActualValue is IList list)
                {
                    var result = string.Empty;

                    var j     = 0;
                    var count = list.Count;

                    foreach (var i in list)
                    {
                        result += (j == count - 1 ? $"{i}" : $"{i}{input.Parameter?.ToString().Char()}");
                        j++;
                    }

                    return(result);
                }
                return(input.ActualValue.ToString());
            }
            return(default);
Пример #15
0
 protected override Value <Input> ConvertBack(ConverterData <Output> input) => ConvertOutput != null?ConvertOutput.Invoke(input.ActualValue) : Nothing.Do;
Пример #16
0
 protected abstract Value <Input> ConvertBack(ConverterData <Output> input);
Пример #17
0
 protected override Value <Output> ConvertTo(ConverterData <Input> input) => ConvertInput(input.ActualValue);
Пример #18
0
 protected override Value <Input> ConvertBack(ConverterData <Output> input) => ConvertOutput != null?ConvertOutput(input) : Nothing.Do;
Пример #19
0
 protected abstract Value <Output> ConvertTo(ConverterData <Input> input);
Пример #20
0
        //// POST api/values
        //public void Post([FromBody]string value)
        //{
        //}

        // PUT api/values/
        public async Task <HttpResponseMessage> PostFormData()
        {
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            var provider = new MultipartMemoryStreamProvider();

            await Request.Content.ReadAsMultipartAsync(provider);

            ConverterData converterData = new ConverterData( );

            foreach (var file in provider.Contents)
            {
                if (file.Headers.ContentDisposition.FileName != null)
                {
                    var filename = file.Headers.ContentDisposition.FileName.Trim('\"');
                    var buffer   = await file.ReadAsByteArrayAsync();

                    if (buffer.Length == 0)
                    {
                        continue;
                    }

                    converterData.Files.Add(new ConvertedFileInfo()
                    {
                        Data = buffer, FileName = filename
                    });
                }
                else
                {
                    var disposition = file.Headers.ContentDisposition;

                    var value = await file.ReadAsStringAsync();

                    if (disposition.Name.Trim('\"') == "format")
                    {
                        converterData.Format = value;
                    }
                    else
                    {
                        converterData.Options.Add(disposition.Name, value);
                    }

                    System.Diagnostics.Trace.WriteLine(value);
                }
            }

            var responseContent = new DicomConverterService().Convert(converterData);

            var response = Request.CreateResponse(responseContent.Status);

            if (responseContent.Content != null)
            {
                var cd = new System.Net.Mime.ContentDisposition
                {
                    // for example foo.bak
                    FileName = responseContent.FileName,

                    // always prompt the user for downloading, set to true if you want
                    // the browser to try to show the file inline
                    Inline = false,
                };

                response.Content = responseContent.Content;
                response.Content.Headers.Add("Content-Disposition", cd.ToString());
            }

            return(response);
        }
 protected override Value <MathDifficulty> ConvertBack(ConverterData <double> input) => (MathDifficulty)(int)input.ActualValue;
Пример #22
0
        protected override Value <Thickness> ConvertTo(ConverterData <TreeViewItem> input)
        {
            double depth = input.ActualValue.GetDepth();

            return(new Thickness(depth * input.Parameter.Double(), 0, 0, 0));
        }
Пример #23
0
    void procTransfer()
    {
        // generator output
        for (int i = 0; i < generic[0].tempGenericUpdateOps.Length; ++i)
        {
            if (generic[0].tempGenericUpdateOps[i] != 0)
            {
                GeneratorData gen = generators[i];
                CanTakeState  cts = headStates[gen.tailArrayIdx];
                // check if this generator has space at its end?
                if (tubes[cts.tailIdx].hasSpace(gen.itemId))
                {
                    tubes[cts.tailIdx].push(gen.itemId);
                    // consume a unit of resource.
                    //Debug.LogFormat("generator {0} makes one at {1}", i, elapsedTime);
                    gen.pop();
                    generators[i] = gen;
                }
                else
                {
                    Debug.LogFormat("generator {0} got blocked.", i);
                    gen.block();
                    generators[i] = gen;
                }
            }
        }

        // tubes output
        for (int i = 0; i < arrayLength; ++i)
        {
            if (updateTubesJob.outputOps[i] != 0)
            {
                CanTakeState cts     = headStates[tubes[i].tailArrayIdx];
                TubeData     srcTube = tubes[i];
                if (cts.tailType == CTS_Tube) // tube
                {
                    if (tubes[cts.tailIdx].hasSpace(srcTube.itemId))
                    {
                        srcTube.pop();
                        tubes[cts.tailIdx].push(srcTube.itemId);
                        Debug.LogFormat("{0} Tube {1} pops into {2}.", elapsedTime, i, cts.tailIdx);
                        cts = headStates[srcTube.headArrayIdx];
                        cts.invokeUnblock();
                    }
                    else
                    {
                        Debug.LogFormat("{0} Tube {1} blocked", elapsedTime, i);
                        srcTube.block();
                    }
                }
                else if (cts.tailType == CTS_Converter) // converter
                {
                    ConverterData conv = converters[cts.tailIdx];
                    if (conv.hasSpace(srcTube.itemId))
                    {
                        srcTube.pop();
                        if (converters[cts.tailIdx].push(srcTube.itemId))
                        {
                            Debug.LogFormat("{0} Tube {1} pops into converter {2}.", elapsedTime, i, cts.tailIdx);
                            cts = headStates[srcTube.tailArrayIdx];
                            cts.invokeUnblock();
                        }
                    }
                    else
                    {
                        srcTube.block();
                        Debug.LogFormat("{0} Tube {1} got blocked by converter {2}.", elapsedTime, i, cts.tailIdx);
                    }
                    //Debug.LogFormat("{0} converter @ {1}, {2}", elapsedTime, conv.srcCurrent[0], conv.srcCurrent[1]);
                }
                else if (cts.tailType == CTS_Consumer)  // consumer
                {
                    ConsumerData consData = consumers[cts.tailIdx];
                    consData.attemptToTake(srcTube.itemId);
                    srcTube.pop();
                    consumers[cts.tailIdx] = consData;

                    Debug.LogFormat("{0} Tube {1} pops into consumer {2}.", elapsedTime, i, cts.tailIdx);
                    cts = headStates[srcTube.headArrayIdx];
                    cts.invokeUnblock();
                }
                tubes[i] = srcTube;
            }
        }

        // converter output
        for (int i = 0; i < generic[1].tempGenericUpdateOps.Length; ++i)
        {
            if (generic[1].tempGenericUpdateOps[i] != 0)
            {
                CanTakeState  cts  = headStates[converters[i].tailArrayIdx];
                ConverterData conv = converters[i];
                // check if this converter has space at its end?
                if (cts.tailType == CTS_Tube)   // the end entity of this converter is a tube
                {
                    if (tubes[cts.tailIdx].hasSpace(conv.targetId))
                    {
                        Debug.Log("converter out!");
                        tubes[cts.tailIdx].push(conv.targetId);

                        //headStates[conv.headArrayIdx].invokeUnblock();
                        Debug.LogFormat("{0} converter {1} pops into tube {2}.", elapsedTime, i, cts.tailIdx);
                    }
                    else
                    {
                        //head_cts
                        Debug.LogFormat("{0} converter {1} got blocked by tube {2}.", elapsedTime, i, cts.tailIdx);
                    }
                }
                else if (cts.tailType == CTS_Converter)  // converter
                {
                    Debug.LogFormat("{0} converter {1} pops into converter {2}.", elapsedTime, i, cts.tailIdx);
                }
                if (conv.allMet())
                {
                    converters[i].startUpdate();
                    headStates[conv.headArrayIdx].invokeUnblock();
                }
            }
        }

        sampler.End();
    }
Пример #24
0
        public async Task <List <ScheduleApi> > GetTimeCalendar(DateTime date, int delegation)
        {
            try
            {
                //if (date == null)
                //    return new List<ScheduleApi>();
                var dateN = date;
                var query = new List <ScheduleApi>();
                var res   = new List <ScheduleApi>();
                var apps  =
                    _context.Appoinments.Where(
                        r => r.Delegationid == delegation && !r.IsCancelled && r.Date == dateN.Date);
                var specialdays = _context.SpecialDays.Where(r => r.DelegationId == delegation && r.Date == dateN.Date);
                if (specialdays.Any())
                {
                    var specialDay = specialdays.FirstOrDefault();
                    if (specialDay.IsNonWorking)
                    {
                        return(new List <ScheduleApi>());
                    }
                    var speSche =
                        _context.SpecialDaysSchedules.Where(r => r.DelegationId == delegation && r.Date == dateN.Date);
                    query = (from s in speSche
                             select new ScheduleApi
                    {
                        Date = s.Date,
                        DelegationId = s.DelegationId,
                        Time = s.Time,
                        Capacity = s.Capacity
                    }).ToList();
                }
                else
                {
                    var weekday = ConverterData.GetWeekEnumDay(dateN.DayOfWeek);

                    int dia = (int)weekday;


                    // revisar por que no funciona la consulta por delegacion y dia: MFP 12-01-2017
                    query =
                        _context.Schedules
                        .Where(x => x.WeekdayId.Equals(dia))
                        .Select(s => new ScheduleApi
                    {
                        Date         = dateN.Date,
                        DelegationId = s.DelegationId,
                        Time         = s.Time,
                        Capacity     = s.Capacity
                    }).ToList();
                }


                foreach (var api in query)
                {
                    var count = apps.Count(r => r.Date == api.Date && r.Time == api.Time);
                    if (count < api.Capacity)
                    {
                        res.Add(api);
                    }
                }
                return(res);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Пример #25
0
 protected override Value <TreeViewItem> ConvertBack(ConverterData <Thickness> input) => Nothing.Do;
Пример #26
0
 protected override Value <string> ConvertTo(ConverterData <object> input) => input.ActualValue.ToString().ToUpper();
Пример #27
0
 protected override Value <object> ConvertBack(ConverterData <string> input) => Nothing.Do;
 protected override Value <double> ConvertTo(ConverterData <MathDifficulty> input) => (int)input.ActualValue;