Exemplo n.º 1
0
        /// <summary>
        /// Get ControlPointInfo by Type and Index
        /// </summary>
        /// <param name="Type">Identifier Type</param>
        /// <param name="Index">Zero based index</param>
        /// <returns>Full Control Point Info</returns>
        public ControlPointInfo GetControlPointInfo(IdentifierTypes Type, int Index)
        {
            ControlPointInfo cp = new ControlPointInfo();

            switch (Type)
            {
            case IdentifierTypes.OUTS:
                cp = Outputs[Index];
                break;

            case IdentifierTypes.INS:
                cp = Inputs[Index];
                break;

            case IdentifierTypes.VARS:
                cp = Variables[Index];
                break;

            case IdentifierTypes.PIDS:

                break;
            //TODO: Return apropiate ControlPointInfo

            //case IdentifierTypes.PRGS:
            //    break;
            //case IdentifierTypes.SCHS:
            //    break;
            //case IdentifierTypes.HOLS:
            //    break;
            default:
                break;
            }

            return(cp);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add new control points
        /// </summary>
        /// <param name="LabelName">Label</param>
        /// <param name="Type">Optional Type, defaults to VARS</param>
        public void Add(string LabelName, IdentifierTypes Type = IdentifierTypes.VARS)
        {
            ControlPointInfo newControlPoint = new ControlPointInfo(LabelName, Type);

            switch (Type)
            {
            case IdentifierTypes.VARS:
                Variables.Add(newControlPoint);
                break;

            case IdentifierTypes.INS:
                Inputs.Add(newControlPoint);
                break;

            case IdentifierTypes.OUTS:
                Outputs.Add(newControlPoint);
                break;

            case IdentifierTypes.PRGS:
                Programs.Add(newControlPoint);
                break;

            case IdentifierTypes.SCHS:
                Schedules.Add(newControlPoint);
                break;

            case IdentifierTypes.HOLS:
                Holidays.Add(newControlPoint);
                break;

            default:
                break;
            }
        }
Exemplo n.º 3
0
        public DUOJU_IDENTIFIERS GenerateIdentifier(IdentifierTypes type, DateTime expiresTime, IList <KeyValuePair <string, string> > settings, int operatorId)
        {
            DateTime createTime;
            string   identifierNO;

            while (true)
            {
                createTime   = DateTime.Now;
                identifierNO = string.Format(
                    "{0}{1}",
                    ((int)type).ToString().PadLeft(2, '0'),
                    WeChat.ConvertTimeStamp(createTime)
                    );

                if (IdentifierRepository.IsIdentifierNOUnique(identifierNO))
                {
                    break;
                }

                Thread.Sleep(1);
            }

            var identifier = new DUOJU_IDENTIFIERS
            {
                IDENTIFIER_TYPE  = (int)type,
                IDENTIFIER_NO    = identifierNO,
                EXPIRES_TIME     = expiresTime,
                STATUS           = (int)IdentifierStatuses.NEW,
                CREATE_BY        = operatorId,
                CREATE_TIME      = createTime,
                LAST_UPDATE_BY   = operatorId,
                LAST_UPDATE_TIME = DateTime.Now
            };

            if (settings != null && settings.Count > 0)
            {
                foreach (var setting in settings)
                {
                    identifier.DUOJU_IDENTIFIER_SETTINGS.Add(new DUOJU_IDENTIFIER_SETTINGS
                    {
                        SETTING_CODE     = setting.Key,
                        SETTING_VALUE    = setting.Value,
                        CREATE_BY        = operatorId,
                        CREATE_TIME      = DateTime.Now,
                        LAST_UPDATE_BY   = operatorId,
                        LAST_UPDATE_TIME = DateTime.Now
                    });
                }
            }

            IdentifierRepository.AddIdentifier(identifier);
            IdentifierRepository.SaveChanges();

            return(identifier);
        }
Exemplo n.º 4
0
        public override void Start()
        {
            IdentifierTypes  = _lookupService.GetIdentifierTypes().ToList();
            Practices        = _lookupService.GetPractices().ToList();
            SelectedPractice = _lookupService.GetDefault();
            try
            {
                SelectedIdentifierType = IdentifierTypes.FirstOrDefault();
            }
            catch
            {
            }

            base.Start();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Add a new ControlPointInfo reference in TimeBuffer from Type and Index
        /// </summary>
        /// <param name="Type">Identifier Type</param>
        /// <param name="Index">Real Index</param>
        /// <returns>New Position</returns>
        public int Add(IdentifierTypes Type, int Index)
        {
            int NewPosition = 5;

            if (Elements.Count > 0)
            {
                NewPosition = Elements.Last().Position + 9; //9 bytes
            }
            TBufferElement newElement = new TBufferElement();

            newElement.Position = NewPosition;
            newElement.Info     = Identifiers.GetControlPointInfo(Type, Index);

            Elements.Add(newElement);
            return(NewPosition);
        }
Exemplo n.º 6
0
 public override void LoadFromStore(VMStore modelStore)
 {
     try
     {
         Enrollment             = JsonConvert.DeserializeObject <ClientEnrollmentDTO>(modelStore.Store);
         ClientId               = Enrollment.ClientId;
         SelectedIdentifierType = IdentifierTypes.FirstOrDefault(x => x.Id == Enrollment.IdentifierTypeId);
         Identifier             = Enrollment.Identifier;
         RegistrationDate       = Enrollment.RegistrationDate;
         Id         = Enrollment.Id;
         practiceId = Enrollment.PracticeId;
     }
     catch (Exception e)
     {
         Mvx.Error(e.Message);
     }
 }
Exemplo n.º 7
0
        public override void ViewAppeared()
        {
            base.ViewAppeared();

            AutoGenId();

            var indexJson = _settings.GetValue(nameof(IndexClientDTO), "");

            if (!string.IsNullOrWhiteSpace(indexJson))
            {
                IndexClientDTO = JsonConvert.DeserializeObject <IndexClientDTO>(indexJson);
                if (null != IndexClientDTO)
                {
                    Title = $"Enrollment [{IndexClientDTO.RelType}]";
                }
            }

            IdentifierTypes = _lookupService.GetIdentifierTypes().ToList();
            Practices       = _lookupService.GetPractices().ToList();

            if (!practiceId.IsNullOrEmpty())
            {
                if (Practices.Any(x => x.Id == practiceId))
                {
                    SelectedPractice = Practices.First(x => x.Id == practiceId);
                }
                else
                {
                    SelectedPractice = _lookupService.GetDefault();
                }
            }
            else
            {
                SelectedPractice = _lookupService.GetDefault();
            }

            try
            {
                SelectedIdentifierType = IdentifierTypes.FirstOrDefault();
            }
            catch
            {
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// TimeBuffer from source code (byte array)
        /// </summary>
        /// <param name="source"></param>
        public TimeBuffer(ControlPoints identifiers, byte[] source = null)
        {
            int i   = 0;
            int POS = 0;

            byte[] len = { 0x00, 0x00 };
            Identifiers = identifiers;
            if (source == null)
            {
                return;
            }

            try
            {
                if (source.Length > 2000)
                {
                    throw new ArgumentOutOfRangeException($"Program Lenght exceeds 2000 bytes: {source.Length}");
                }
                else
                {
                    //find EOF byte, do not trust PROG SIZE in control point
                    do
                    {
                        i++;
                    }while (source[i] != (byte)LINE_TOKEN.EOF);

                    if (i >= 2000)
                    {
                        throw new IndexOutOfRangeException($"Out of bounds or no EOF found at index: {i}");
                    }
                    POS = i + 1; //Position of TimeBuffer -> first byte after 0xFE (EOF)

                    i = POS + 4; //Jump first 4 bytes, those are always 0x00
                    //next two bytes are the buffer lenght
                    len[0] = source[i];
                    len[1] = source[i + 1];
                    int _BufferSize  = BytesExtensions.ToInt16(len);
                    int _BufferCount = (BufferSize) / 9;
                    //Copy the time buffer
                    //If BufferSize = 0 then Buffer will stay empty
                    for (i = 0; i <= _BufferSize + 5; i++)
                    {
                        Buffer.Add(source[POS + i]);
                    }

                    //Convert every byte sequence into Elements
                    for (i = 6; i < _BufferSize + 5; i += 9)
                    {
                        //skip first byte 0x00;
                        byte            TOKEN  = Buffer[i];
                        byte            INDEX  = Buffer[i + 1];
                        IdentifierTypes TYPE   = (IdentifierTypes)Buffer[i + 2];
                        byte            Marker = Buffer[i + 3];
                        if (Marker != (byte)LINE_TOKEN.EOE)
                        {
                            throw new Exception($"EOF not found. Instead of marker, I found  this: {Marker}");
                        }

                        if (Identifiers != null)
                        {
                            switch ((IdentifierTypes)TYPE)
                            {
                            case IdentifierTypes.OUTS:
                            case IdentifierTypes.INS:
                            case IdentifierTypes.VARS:
                                Add(Identifiers.GetControlPointInfo(TYPE, INDEX));
                                break;

                            default:
                                throw new NotSupportedException("Identifier type not supported by TimeBuffer()");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.Show(ex, "TimeBuffer");
            }
        }
Exemplo n.º 9
0
 public Identifier Allocate(string name, object value = null, IdentifierTypes idType = IdentifierTypes.idVariable)
 {
     return(_scopes[_scopes.Count() - 1].Allocate(name, value, idType));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Constructor with initialization
 /// </summary>
 /// <param name="LabelName">Label</param>
 /// <param name="Type">optional Type, default = VARS</param>
 public ControlPointInfo(string LabelName, IdentifierTypes Type = IdentifierTypes.VARS)
 {
     this.Label = LabelName;
     this.Type  = Type;
 }
Exemplo n.º 11
0
 /// <remarks/>
 public void GetLastSaleByIdentifiersAsync(string Identifiers, IdentifierTypes IdentifierType, object userState) {
     if ((this.GetLastSaleByIdentifiersOperationCompleted == null)) {
         this.GetLastSaleByIdentifiersOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetLastSaleByIdentifiersOperationCompleted);
     }
     this.InvokeAsync("GetLastSaleByIdentifiers", new object[] {
                 Identifiers,
                 IdentifierType}, this.GetLastSaleByIdentifiersOperationCompleted, userState);
 }
Exemplo n.º 12
0
 /// <remarks/>
 public void GetLastSaleByIdentifiersAsync(string Identifiers, IdentifierTypes IdentifierType) {
     this.GetLastSaleByIdentifiersAsync(Identifiers, IdentifierType, null);
 }
Exemplo n.º 13
0
 public LastSaleQuote[] GetLastSaleByIdentifiers(string Identifiers, IdentifierTypes IdentifierType) {
     object[] results = this.Invoke("GetLastSaleByIdentifiers", new object[] {
                 Identifiers,
                 IdentifierType});
     return ((LastSaleQuote[])(results[0]));
 }