/// <summary>
        /// Retrieves list of Machine objects from SqlCommand, after database query
        /// number of rows retrieved and returned depends upon the rows field value
        /// </summary>
        /// <param name="cmd">The command object to use for query</param>
        /// <param name="rows">Number of rows to process</param>
        /// <returns>A list of Machine objects</returns>
        private MachineList GetList(SqlCommand cmd, long rows)
        {
            // Select multiple records
            SqlDataReader reader;
            long          result = SelectRecords(cmd, out reader);

            //Machine list
            MachineList list = new MachineList();

            using ( reader )
            {
                // Read rows until end of result or number of rows specified is reached
                while (reader.Read() && rows-- != 0)
                {
                    Machine machineObject = new Machine();
                    FillObject(machineObject, reader);

                    list.Add(machineObject);
                }

                // Close the reader in order to receive output parameters
                // Output parameters are not available until reader is closed.
                reader.Close();
            }

            return(list);
        }
Exemplo n.º 2
0
    IEnumerator LoadLocalJson()
    {
        //Debug.Log("111");
        WWW www = new WWW(Application.dataPath + "/Resources/ConfigProfiles/CriteriaInfo.json");

        yield return(www);

        Debug.Log(www.text);
        ListCritera = JsonConvert.DeserializeObject <CriteriaList>(www.text);

        www = new WWW(Application.dataPath + "/Resources/ConfigProfiles/MachineInfo.json");
        yield return(www);

        Debug.Log(www.text);
        ListMachine = JsonConvert.DeserializeObject <MachineList>(www.text);

        www = new WWW(Application.dataPath + "/Resources/ConfigProfiles/SubCriteriaInfo.json");
        yield return(www);

        Debug.Log(www.text);
        ListSubCriteria = JsonConvert.DeserializeObject <SubCriteriaList>(www.text);

        www = new WWW(Application.dataPath + "/Resources/ConfigProfiles/AspectInfo.json");
        yield return(www);

        Debug.Log(www.text);
        ListAspect = JsonConvert.DeserializeObject <AspectList>(www.text);

        OnInitStatisticsData();
    }
Exemplo n.º 3
0
 static Client()
 {
     Machines                         = new MachineList();
     Macros                           = new List <Macro>();
     StartWithWindows                 = bool.Parse(Defaults.START_WITH_WINDOWS);
     UserOwnsControlPanel             = bool.Parse(Defaults.USER_OWNS_CONTROL_PANEL);
     KeepControlPanelTopMost          = bool.Parse(Defaults.KEEP_CONTROL_PANEL_TOP_MOST);
     LogTypeMinLevel                  = (LogType)Enum.Parse(typeof(LogType), Defaults.LOG_TYPE_MIN_LEVEL);
     CFG_SelectedHostName             = Defaults.SELECTED_HOST_NAME;
     CFG_SelectedConfigurationSection = Defaults.SELECTED_CONFIGURATION_SECTION;
     CP_SelectedTab                   = Defaults.SELECTED_TAB;
     P_SelectedGrouping               = Defaults.SELECTED_PROCESS_GROUPING;
     P_SelectedFilterMachine          = Defaults.SELECTED_PROCESS_FILTER_MACHINE;
     P_SelectedFilterGroup            = Defaults.SELECTED_PROCESS_FILTER_GROUP;
     P_SelectedFilterApplication      = Defaults.SELECTED_PROCESS_FILTER_APPLICATION;
     P_CheckedNodes                   = new List <Guid>();
     P_CollapsedNodes                 = new Dictionary <ProcessGrouping, List <Guid> >()
     {
         { ProcessGrouping.MachineGroupApplication, new List <Guid>() },
         { ProcessGrouping.GroupMachineApplication, new List <Guid>() }
     };
     D_SelectedGrouping                 = Defaults.SELECTED_DISTRIBUTION_GROUPING;
     D_SelectedFilterSourceMachine      = Defaults.SELECTED_DISTRIBUTION_FILTER_SOURCE_MACHINE;
     D_SelectedFilterGroup              = Defaults.SELECTED_DISTRIBUTION_FILTER_GROUP;
     D_SelectedFilterApplication        = Defaults.SELECTED_DISTRIBUTION_FILTER_APPLICATION;
     D_SelectedFilterDestinationMachine = Defaults.SELECTED_DISTRIBUTION_FILTER_DESTINATION_MACHINE;
     D_CheckedNodes   = new List <Guid>();
     D_CollapsedNodes = new Dictionary <DistributionGrouping, List <Guid> >()
     {
         { DistributionGrouping.MachineGroupApplicationMachine, new List <Guid>() },
         { DistributionGrouping.GroupMachineApplicationMachine, new List <Guid>() }
     };
     M_CheckedNodes   = new List <Guid>();
     M_CollapsedNodes = new List <Guid>();
 }
Exemplo n.º 4
0
 public void InstantiateMachine(MachineList tm)
 {
     this.tmName      = tm.mName;
     this.alph        = tm.alph;
     this.states      = tm.states;
     this.description = tm.description;
 }
Exemplo n.º 5
0
        public static IMachine GetMachine(string com)
        {
            MachineModel machine = MachineList.Find(item => item.Com == com);

            if (machine == null)
            {
                FileLogger.LogError("根据串口号获取接口失败,找不到该串口" + com + "号对应的接口");
                throw new Exception("根据串口号获取接口失败,找不到该串口" + com + "号对应的接口");
            }
            return(machine.Machine);
        }
Exemplo n.º 6
0
        public void RemoveMachine(Machine machine)
        {
            int index = MachineList.IndexOf(machine);

            if (index < 0 || machine == null)
            {
                return;
            }

            RemoveMachine(index);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="type">Type of field.</param>
 /// <param name="name">Name user has given the state.</param>
 /// <param name="bytes">List representing each byte in the state.</param>
 /// <param name="lib">Library (DLL) containing the helper methods.</param>
 /// <param name="classname">Class (with namespace) containing the static methods.</param>
 /// <param name="format">Method to format the field as a string.</param>
 /// <param name="validate">Method to validate the bytes. Invoked when all bytes match.</param>
 /// <param name="dt">DateTime method if it's a timestamp.</param>
 public UserState(MachineList type, string name, List <UserByte> bytes, string lib,
                  string classname, string format, string validate, string dt)
 {
     MachineType       = type;
     Name              = name;
     Bytes             = bytes;
     strLibrary        = lib;
     strClass          = classname;
     strMethodFormat   = format;
     strMethodValidate = validate;
     strMethodDatetime = (type == MachineList.TimeStamp_User) ? dt : null;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Loads the machine list
        /// </summary>
        public void Load(bool quietMode = false)
        {
            string fileName = SaveName;

            try
            {
                using (Stream stream = new FileStream(fileName, FileMode.OpenOrCreate))
                {
                    MachineList.Clear();
                    MachineList = (ObservableCollection <Machine>)formatter.Deserialize(stream);
                    _hasLoaded  = true;
                    RefreshConfigurations();
                }
            }
            catch (Exception exception)
            {
                // don't show the dialog if calling from the instance usage.
                if (quietMode)
                {
                    return;
                }

                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.DefaultExt  = "dat";
                openFileDialog.Filter      = "Data Files (.dat)|*.dat|All Files|*";
                openFileDialog.Multiselect = false;
                openFileDialog.Title       = "Open machine data file";

                bool?accept = openFileDialog.ShowDialog();
                if (accept == true)
                {
                    fileName = openFileDialog.FileName;
                    try
                    {
                        using (Stream stream = new FileStream(fileName, FileMode.OpenOrCreate))
                        {
                            MachineList.Clear();
                            MachineList = (ObservableCollection <Machine>)formatter.Deserialize(stream);
                            RefreshConfigurations();
                            _hasLoaded = true;
                        }
                    }
                    catch (Exception inException)
                    {
                        MessageBox.Show("Unable to load Machine configuration. Error: " + inException.Message, "ERROR", MessageBoxButton.OK);
                    }
                }
            }
        }
Exemplo n.º 9
0
    public void LoadAllData()
    {
        //StartCoroutine(LoadLocalJson());
        TextAsset str1 = Resources.Load <TextAsset>("ConfigProfiles/CriteriaInfo");
        TextAsset str2 = Resources.Load <TextAsset>("ConfigProfiles/MachineInfo");
        TextAsset str3 = Resources.Load <TextAsset>("ConfigProfiles/SubCriteriaInfo");
        TextAsset str4 = Resources.Load <TextAsset>("ConfigProfiles/AspectInfo");

        ListCritera     = JsonConvert.DeserializeObject <CriteriaList>(str1.text);
        ListMachine     = JsonConvert.DeserializeObject <MachineList>(str2.text);
        ListSubCriteria = JsonConvert.DeserializeObject <SubCriteriaList>(str3.text);
        ListAspect      = JsonConvert.DeserializeObject <AspectList>(str4.text);

        OnInitStatisticsData();
    }
Exemplo n.º 10
0
        /// <summary>
        /// Retrieves all Machine objects by PageRequest
        /// </summary>
        /// <returns>A list of Machine objects</returns>
        public MachineList GetPaged(PagedRequest request)
        {
            using (SqlCommand cmd = GetSPCommand(GETPAGEDMACHINE))
            {
                AddParameter(cmd, pInt32Out("TotalRows"));
                AddParameter(cmd, pInt32("PageIndex", request.PageIndex));
                AddParameter(cmd, pInt32("RowPerPage", request.RowPerPage));
                AddParameter(cmd, pNVarChar("WhereClause", 4000, request.WhereClause));
                AddParameter(cmd, pNVarChar("SortColumn", 128, request.SortColumn));
                AddParameter(cmd, pNVarChar("SortOrder", 4, request.SortOrder));

                MachineList _MachineList = GetList(cmd, ALL_AVAILABLE_RECORDS);
                request.TotalRows = Convert.ToInt32(GetOutParameter(cmd, "TotalRows"));
                return(_MachineList);
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// Called by the ExtractField() method of Viterbi class, to get a readable format of a Viterbi field
 /// whose corresponding bytes are passed through input. This metohd is used with user-defined states.
 /// </summary>
 /// <param name="machineName">The state's machine name.</param>
 /// <param name="input">The bytes to ne interpreted.</param>
 /// <param name="uState">The UserState object, which references the method for interpreting the input.</param>
 /// <returns>The string representation.</returns>
 public static string GetUserField(MachineList machineName, byte[] input, UserState uState)
 {
     try {
         if ((machineName == MachineList.PhoneNumber_User) || (machineName == MachineList.Text_User))
         {
             return((string)uState.MethodFormat.Invoke(null, new object[] { input }));
         }
         else
         {
             // For timestamps get the DateTime and format it, rather than use the user's
             // format method. This is for consistency.
             DateTime dt = (DateTime)uState.MethodDatetime.Invoke(null, new object[] { input });
             return(dt.ToString());
         }
     } catch {
         return("???");
     }
 }
        public virtual void RefreshWithLoadedConfiguration(Configuration conf, PolicyProvider
                                                           provider)
        {
            IDictionary <Type, AccessControlList[]> newAcls = new IdentityHashMap <Type, AccessControlList
                                                                                   []>();
            IDictionary <Type, MachineList[]> newMachineLists = new IdentityHashMap <Type, MachineList
                                                                                     []>();
            string defaultAcl = conf.Get(CommonConfigurationKeys.HadoopSecurityServiceAuthorizationDefaultAcl
                                         , AccessControlList.WildcardAclValue);
            string defaultBlockedAcl = conf.Get(CommonConfigurationKeys.HadoopSecurityServiceAuthorizationDefaultBlockedAcl
                                                , string.Empty);
            string defaultServiceHostsKey = GetHostKey(CommonConfigurationKeys.HadoopSecurityServiceAuthorizationDefaultAcl
                                                       );
            string defaultMachineList = conf.Get(defaultServiceHostsKey, MachineList.WildcardValue
                                                 );
            string defaultBlockedMachineList = conf.Get(defaultServiceHostsKey + Blocked, string.Empty
                                                        );

            // Parse the config file
            Service[] services = provider.GetServices();
            if (services != null)
            {
                foreach (Service service in services)
                {
                    AccessControlList acl = new AccessControlList(conf.Get(service.GetServiceKey(), defaultAcl
                                                                           ));
                    AccessControlList blockedAcl = new AccessControlList(conf.Get(service.GetServiceKey
                                                                                      () + Blocked, defaultBlockedAcl));
                    newAcls[service.GetProtocol()] = new AccessControlList[] { acl, blockedAcl };
                    string      serviceHostsKey = GetHostKey(service.GetServiceKey());
                    MachineList machineList     = new MachineList(conf.Get(serviceHostsKey, defaultMachineList
                                                                           ));
                    MachineList blockedMachineList = new MachineList(conf.Get(serviceHostsKey + Blocked
                                                                              , defaultBlockedMachineList));
                    newMachineLists[service.GetProtocol()] = new MachineList[] { machineList, blockedMachineList };
                }
            }
            // Flip to the newly parsed permissions
            protocolToAcls         = newAcls;
            protocolToMachineLists = newMachineLists;
        }
        /// <exception cref="Org.Apache.Hadoop.Security.Authorize.AuthorizationException"/>
        public virtual void Authorize(UserGroupInformation user, string remoteAddress)
        {
            UserGroupInformation realUser = user.GetRealUser();

            if (realUser == null)
            {
                return;
            }
            AccessControlList acl = proxyUserAcl[configPrefix + realUser.GetShortUserName()];

            if (acl == null || !acl.IsUserAllowed(user))
            {
                throw new AuthorizationException("User: "******" is not allowed to impersonate "
                                                 + user.GetUserName());
            }
            MachineList MachineList = proxyHosts[GetProxySuperuserIpConfKey(realUser.GetShortUserName
                                                                                ())];

            if (MachineList == null || !MachineList.Includes(remoteAddress))
            {
                throw new AuthorizationException("Unauthorized connection for super-user: "******" from IP " + remoteAddress);
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// Gets the first available machine that produces the passed item.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public Machine GetAvailableMachine(ProductMasterItem item)
 {
     return
         (MachineList.FirstOrDefault(
              machine => machine.ConfigurationList.Any(config => config.CanMake(item))));
 }
Exemplo n.º 15
0
        public void GenerateMaps()
        {
            //Clear ClientToStoreMap
            this.ClientToStoreMap.Clear();
            this.StoreToDatabaseServiceMap.Clear();
            this.StoreToEsbServiceMap.Clear();
            this.MachineList.Clear();

            //Generate machine to store map
            if (ClientMachines.Count > 0 &&
                Stores.Count > 0 &&
                ClientStoreMapList.Count > 0)
            {
                foreach (var machine in ClientMachines)
                {
                    if (machine == null)
                    {
                        continue;
                    }
                    ulong machineId = machine.Machine.ClientId;
                    var   mapEntry  =
                        ClientStoreMapList.Find(
                            x =>
                            (x.ClientRegistryId == machineId &&
                             x.StoreNumber.Equals(this.StoreNumber)));
                    if (mapEntry == null)
                    {
                        continue;
                    }
                    var pwnSecStore =
                        this.Stores.Find(
                            x => x.StoreSite.StoreNumber.Equals(mapEntry.StoreNumber));
                    if (pwnSecStore == null)
                    {
                        continue;
                    }
                    //Add client to store map entry
                    ClientToStoreMap.Add(machine, pwnSecStore);
                    MachineList.Add(new StoreMachineVO(machine.Machine.MachineName,
                                                       machine.Machine.IsAllowed,
                                                       machine.Machine.IsConnected));
                    //Create entry for database service and esb service if and only if the store
                    //does not already exist as a key in the list
                    if (StoreToDatabaseServiceMap.ContainsKey(pwnSecStore))
                    {
                        continue;
                    }
                    var sConfig = pwnSecStore.StoreConfiguration;
                    var sConfigDbServMapList = DatabaseServiceMapList.FindAll(x => x.StoreConfigId == sConfig.Id);
                    if (CollectionUtilities.isNotEmpty(sConfigDbServMapList))
                    {
                        var dbServList =
                            from dbServ in DatabaseServiceList
                            join dbServMap in sConfigDbServMapList
                            on dbServ.Id equals dbServMap.DatabaseServiceId
                            select dbServ;
                        StoreToDatabaseServiceMap.Add(pwnSecStore, new List <DatabaseServiceVO>(dbServList));
                    }
                    if (StoreToEsbServiceMap.ContainsKey(pwnSecStore))
                    {
                        continue;
                    }

                    var sConfigEsbServMapList = ESBServiceMapList.FindAll(x => x.StoreConfigId == sConfig.Id);
                    if (CollectionUtilities.isNotEmpty(sConfigEsbServMapList))
                    {
                        var esbServList =
                            from esbServ in ESBServiceList
                            join esbServMap in sConfigEsbServMapList
                            on esbServ.Id equals esbServMap.ESBServiceId
                            select esbServ;
                        StoreToEsbServiceMap.Add(pwnSecStore, new List <EsbServiceVO>(esbServList));
                    }
                }
            }

            //If these three conditions are true, the maps are valid
            if (CollectionUtilities.isNotEmpty(ClientToStoreMap) &&
                CollectionUtilities.isNotEmpty(StoreToDatabaseServiceMap) &&
                CollectionUtilities.isNotEmpty(StoreToEsbServiceMap) &&
                CollectionUtilities.isNotEmpty(MachineList))
            {
                this.MapsValid = true;
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Parses the response received from the server.
        /// </summary>
        /// <param name="responseReader">The binary stream reader that should
        /// be used to read any response data necessary.</param>
        protected override void UnpackResponse()
        {
            base.UnpackResponse();
            MemoryStream responseStream = new MemoryStream(m_responsePayload);
            BinaryReader responseReader = new BinaryReader(responseStream, Encoding.Unicode);

            if (responseStream.Length < MinResponseMessageLength)
            {
                throw new MessageWrongSizeException("Get Machine Status");
            }

            try
            {
                responseReader.BaseStream.Seek(sizeof(int), SeekOrigin.Begin);

                UInt16 MachineCount = responseReader.ReadUInt16();
                MachineList.Clear();

                for (ushort x = 0; x < MachineCount; x++)
                {
                    Machine  machine      = new Machine();
                    Staff    staff        = new Staff();
                    Operator operatordata = new Operator();

                    //MachineID
                    machine.MachineID = responseReader.ReadInt32();

                    //MachineClientID
                    machine.MachineClientID = ReadString(responseReader);

                    //Machine Description
                    machine.MachineDescription = ReadString(responseReader);

                    //Machine LoginDate
                    machine.MachineLoginDate = ReadDateTime(responseReader) ?? DateTime.MinValue;

                    //StaffID
                    staff.Id = responseReader.ReadInt32();

                    //Staff FirstName
                    staff.FirstName = ReadString(responseReader);

                    //Staff LastName
                    staff.LastName = ReadString(responseReader);

                    //Operator ID
                    operatordata.Id = responseReader.ReadInt32();

                    //Operator Name
                    operatordata.Name = ReadString(responseReader);

                    machine.staffdata    = staff;
                    machine.operatorData = operatordata;
                    MachineList.Add(machine);
                }
            }
            catch (EndOfStreamException e)
            {
                throw new MessageWrongSizeException("Get Machine status", e);
            }
            catch (Exception e)
            {
                throw new ServerException("Get Machine status", e);
            }
            finally
            {
                if (responseReader != null)
                {
                    responseReader.Close();
                }
            }
        }
Exemplo n.º 17
0
 /// <summary>
 /// Called by the ExtractField() method of Viterbi class, to get a readable format of a Viterbi field
 /// whose corresponding bytes are passed through input. This metohd is used with user-defined states.
 /// </summary>
 /// <param name="machineName">The state's machine name.</param>
 /// <param name="input">The bytes to ne interpreted.</param>
 /// <param name="uState">The UserState object, which references the method for interpreting the input.</param>
 /// <returns>The string representation.</returns>
 public static string GetUserField(MachineList machineName, byte[] input, UserState uState)
 {
     try {
         if ((machineName == MachineList.PhoneNumber_User) || (machineName == MachineList.Text_User)) {
             return (string)uState.MethodFormat.Invoke(null, new object[] { input });
         } else {
             // For timestamps get the DateTime and format it, rather than use the user's
             // format method. This is for consistency.
             DateTime dt = (DateTime)uState.MethodDatetime.Invoke(null, new object[] { input });
             return dt.ToString();
         }
     } catch {
         return "???";
     }
 }
Exemplo n.º 18
0
 public void Unsubscribe()
 {
     MessageService.Unsubscribe(this);
     MachineList.Unsubscribe();
     MachineDetails.Unsubscribe();
 }
Exemplo n.º 19
0
 public void Subscribe()
 {
     MessageService.Subscribe <MachineListViewModel>(this, OnMessage);
     MachineList.Subscribe();
     MachineDetails.Subscribe();
 }
Exemplo n.º 20
0
 public void Unload()
 {
     MachineDetails.CancelEdit();
     MachineList.Unload();
 }
Exemplo n.º 21
0
 public async Task LoadAsync(MachineListArgs args)
 {
     await MachineList.LoadAsync(args);
 }
Exemplo n.º 22
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="type">Type of field.</param>
 /// <param name="name">Name user has given the state.</param>
 /// <param name="bytes">List representing each byte in the state.</param>
 /// <param name="lib">Library (DLL) containing the helper methods.</param>
 /// <param name="classname">Class (with namespace) containing the static methods.</param>
 /// <param name="format">Method to format the field as a string.</param>
 /// <param name="validate">Method to validate the bytes. Invoked when all bytes match.</param>
 /// <param name="dt">DateTime method if it's a timestamp.</param>
 public UserState(MachineList type, string name, List<UserByte> bytes, string lib,
     string classname, string format, string validate, string dt)
 {
     MachineType = type;
     Name = name;
     Bytes = bytes;
     strLibrary = lib;
     strClass = classname;
     strMethodFormat = format;
     strMethodValidate = validate;
     strMethodDatetime = (type == MachineList.TimeStamp_User) ? dt : null;
 }
Exemplo n.º 23
0
        /// <summary>
        /// Called by the ExtractField() method of Viterbi class, to get a readable format of a Viterbi field whose corresponding bytes are passed through input.
        /// </summary>
        /// <param name="machineName">Name of the parent state machine to which the field belongs to.</param>
        /// <param name="input">Sequence of bytes corresponding to the field whose readable format is desired.</param>
        /// <returns>A readable format of the Viterbi field.</returns>
        public static string GetField(MachineList machineName, byte[] input)
        {
            string result;

            switch (machineName)
            {
                case MachineList.Sql_SqliteRecord:
                    result = GetUTFPrintableChars(input);
                    break;

                case MachineList.Text_SevenBitWithLength:
                    result = GetSevenBitWithLength(input);
                    break;

                case MachineList.TimeStamp_MotoSms:
                    result = GetMotoSmsTimeStamp(input);
                    break;

                case MachineList.TimeStamp_Sms:
                    result = GetSmsTimeStamp(input);
                    break;

                case MachineList.TimeStamp_SmsGsm:
                    result = GetSmsGsmTimeStamp(input);
                    break;

                case MachineList.CallLogType_Samsung:
                    result = GetSamsungCallLogStatus(input);
                    break;

                case MachineList.TimeStamp_Samsung:
                    result = GetSamsungTimeStamp(input);
                    break;

                case MachineList.TimeStamp_Unix:
                    result = GetUnixTimeStamp(input);
                    break;

                case MachineList.TimeStamp_Epoch1900Tuple:
                    result = GetEpoch1900TimeStamp(input);
                    break;

                case MachineList.CallLogType_SimpleLE:
                    result = GetSimpleCallLogStatusLE(input);
                    break;

                case MachineList.CallLogType_Moto:
                    result = GetMotoCallLogStatus(input);
                    break;

                case MachineList.PhoneNumber_NokiaSevenDigit:
                case MachineList.PhoneNumber_NokiaEightDigit:
                case MachineList.PhoneNumber_NokiaTenDigit:
                case MachineList.PhoneNumber_NokiaElevenDigit:
                case MachineList.PhoneNumber_NokiaTwelveDigit:
                    result = GetNokiaPhoneString(input);
                    break;

                case MachineList.PhoneNumber_InternationalFormatSevenDigit:
                case MachineList.PhoneNumber_InternationalFormatTenDigit:
                case MachineList.PhoneNumber_InternationalFormatElevenDigit:
                case MachineList.PhoneNumber_BCDPrepended:
                    result = GetInternationalPhoneString(input);
                    break;

                case MachineList.PhoneNumber_BCD:
                    result = GetBCDPhoneString(input);
                    break;

                case MachineList.PhoneNumber_SamsungElevenDigitAscii:
                case MachineList.PhoneNumber_SamsungTenDigitAscii:
                case MachineList.PhoneNumber_SamsungSevenDigitAscii:
                    result = GetAsciiPhoneString(input);
                    break;

                case MachineList.PhoneNumber_MotoSevenUnicode:
                case MachineList.PhoneNumber_MotoTenUnicode:
                case MachineList.PhoneNumber_MotoElevenUnicode:
                    result = GetUnicodePhoneString(input);
                    break;

                case MachineList.PhoneNumber_MotoElevenDigit:
                case MachineList.PhoneNumber_MotoTenDigit:
                case MachineList.PhoneNumber_MotoSevenDigit:
                    result = GetMotoPhoneString(input);
                    break;

                case MachineList.PhoneNumberIndex_Nokia:
                    result = GetStringFromNumber(input);
                    break;

                case MachineList.Text_AsciiStringWithLength:
                case MachineList.Text_Unicode:
                case MachineList.Text_UnicodeEndian:
                case MachineList.Text_AsciiBigram:
                case MachineList.Text_AsciiPrintable:
                case MachineList.Marker_SamsungSms:
                    result = GetTextString(input);
                    break;

                case MachineList.TimeStamp_Nokia:
                    result = GetNokiaTimeStamp(input, false);
                    break;

                case MachineList.TimeStamp_NokiaEndian:
                    result = GetNokiaTimeStamp(input, true);
                    break;

                case MachineList.PhoneNumber_User:
                case MachineList.TimeStamp_User:
                case MachineList.Text_User:
                    // Should not get here.
                    result = "???";
                    break;

                default:
                    result = "???";
                    break;
            }

            return result;
        }
Exemplo n.º 24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="index"></param>
        /// <returns>The first index after the end of the field</returns>
        private ViterbiField ExtractField(List <State> path, int index)
        {
            int         startIndex  = index;
            MachineList machineName = path[index].ParentStateMachine.Name;
            string      fieldHex    = "0x";
            string      fieldAscii  = "";
            List <byte> fieldBytes  = new List <byte>();

            while (index < path.Count && machineName == path[index].ParentStateMachine.Name)
            {
                fieldBytes.Add(_observations[index]);

                //If this is an anchor run, no need to print fields
                if (!_isAnchor)
                {
                    string observation = Convert.ToString(_observations[index], 16).PadLeft(2, '0');

                    fieldHex   += observation;
                    fieldAscii += (char)_observations[index];

#if PRINT_ALL
                    Console.WriteLine("{0}\t:\t{1}\t{2}", path[index], observation, (char)_observations[index]);
#endif
                }
                index++;

                //Allows us to distinguish between adjacent fields of the same type
                if (path[index - 1].IsSplitState)
                {
                    break;
                }
            }

            string fieldString;
            if (!_isAnchor && ((machineName == MachineList.PhoneNumber_User) ||
                               (machineName == MachineList.TimeStamp_User) ||
                               (machineName == MachineList.TimeStamp_User)))
            {
                // If we're printing a user-defined field then we need to use the user-defined
                // methods.
                try {
                    UserDefinedState udState = path[index - 1] as UserDefinedState;
                    fieldString = Printer.GetUserField(machineName, fieldBytes.ToArray(), udState.UserStateObj);
                } catch {
                    fieldString = "???";
                }
            }
            else
            {
                fieldString = _isAnchor ? "" : Printer.GetField(machineName, fieldBytes.ToArray());
            }

            var field = new ViterbiField
            {
                OffsetPath  = startIndex,
                OffsetFile  = _fileOffset + startIndex,
                HexString   = fieldHex,
                AsciiString = fieldAscii,
                FieldString = fieldString,
                MachineName = machineName,
                Raw         = fieldBytes.ToArray()
            };

            _textList.Add(fieldString);
            _fieldList.Add(field);

            #if PRINT_FIELD
            Console.WriteLine(field);
            #endif

            return(field);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Called by the ExtractField() method of Viterbi class, to get a readable format of a Viterbi field whose corresponding bytes are passed through input.
        /// </summary>
        /// <param name="machineName">Name of the parent state machine to which the field belongs to.</param>
        /// <param name="input">Sequence of bytes corresponding to the field whose readable format is desired.</param>
        /// <returns>A readable format of the Viterbi field.</returns>
        public static string GetField(MachineList machineName, byte[] input)
        {
            string result;

            switch (machineName)
            {
            case MachineList.Sql_SqliteRecord:
                result = GetUTFPrintableChars(input);
                break;

            case MachineList.Text_SevenBitWithLength:
                result = GetSevenBitWithLength(input);
                break;

            case MachineList.TimeStamp_MotoSms:
                result = GetMotoSmsTimeStamp(input);
                break;

            case MachineList.TimeStamp_Sms:
                result = GetSmsTimeStamp(input);
                break;

            case MachineList.TimeStamp_SmsGsm:
                result = GetSmsGsmTimeStamp(input);
                break;

            case MachineList.CallLogType_Samsung:
                result = GetSamsungCallLogStatus(input);
                break;

            case MachineList.TimeStamp_Samsung:
                result = GetSamsungTimeStamp(input);
                break;

            case MachineList.TimeStamp_Unix:
                result = GetUnixTimeStamp(input);
                break;

            case MachineList.TimeStamp_Epoch1900Tuple:
                result = GetEpoch1900TimeStamp(input);
                break;

            case MachineList.CallLogType_SimpleLE:
                result = GetSimpleCallLogStatusLE(input);
                break;

            case MachineList.CallLogType_Moto:
                result = GetMotoCallLogStatus(input);
                break;

            case MachineList.PhoneNumber_NokiaSevenDigit:
            case MachineList.PhoneNumber_NokiaEightDigit:
            case MachineList.PhoneNumber_NokiaTenDigit:
            case MachineList.PhoneNumber_NokiaElevenDigit:
            case MachineList.PhoneNumber_NokiaTwelveDigit:
                result = GetNokiaPhoneString(input);
                break;

            case MachineList.PhoneNumber_InternationalFormatSevenDigit:
            case MachineList.PhoneNumber_InternationalFormatTenDigit:
            case MachineList.PhoneNumber_InternationalFormatElevenDigit:
            case MachineList.PhoneNumber_BCDPrepended:
                result = GetInternationalPhoneString(input);
                break;

            case MachineList.PhoneNumber_BCD:
                result = GetBCDPhoneString(input);
                break;

            case MachineList.PhoneNumber_SamsungElevenDigitAscii:
            case MachineList.PhoneNumber_SamsungTenDigitAscii:
            case MachineList.PhoneNumber_SamsungSevenDigitAscii:
                result = GetAsciiPhoneString(input);
                break;

            case MachineList.PhoneNumber_MotoSevenUnicode:
            case MachineList.PhoneNumber_MotoTenUnicode:
            case MachineList.PhoneNumber_MotoElevenUnicode:
                result = GetUnicodePhoneString(input);
                break;

            case MachineList.PhoneNumber_MotoElevenDigit:
            case MachineList.PhoneNumber_MotoTenDigit:
            case MachineList.PhoneNumber_MotoSevenDigit:
                result = GetMotoPhoneString(input);
                break;

            case MachineList.PhoneNumberIndex_Nokia:
                result = GetStringFromNumber(input);
                break;

            case MachineList.Text_AsciiStringWithLength:
            case MachineList.Text_Unicode:
            case MachineList.Text_UnicodeEndian:
            case MachineList.Text_AsciiBigram:
            case MachineList.Text_AsciiPrintable:
            case MachineList.Marker_SamsungSms:
                result = GetTextString(input);
                break;


            case MachineList.TimeStamp_Nokia:
                result = GetNokiaTimeStamp(input, false);
                break;

            case MachineList.TimeStamp_NokiaEndian:
                result = GetNokiaTimeStamp(input, true);
                break;

            case MachineList.PhoneNumber_User:
            case MachineList.TimeStamp_User:
            case MachineList.Text_User:
                // Should not get here.
                result = "???";
                break;

            default:
                result = "???";
                break;
            }

            return(result);
        }
Exemplo n.º 26
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="field"></param>
        /// <returns>Returns the meta machine. If the machine is not known, then it will return binary</returns>
        private MetaMachine GetMetaMachine(MachineList field)
        {
            bool isPhone = (Convert.ToString(field).StartsWith("PhoneNumber_"));

            if (isPhone)
                return MetaMachine.PhoneNumber;

            bool isTimeStamp = Convert.ToString(field).StartsWith("TimeStamp_");

            if (isTimeStamp)
                return MetaMachine.TimeStamp;

            bool isText = Convert.ToString(field).StartsWith("Text_");

            if (isText)
                return MetaMachine.Text;

            bool isSmsPrepend = Convert.ToString(field).StartsWith("Prepend_");

            if (isSmsPrepend)
                return MetaMachine.SmsPrepend;

            bool isCallLogType = Convert.ToString(field).StartsWith("CallLogType_");

            if (isCallLogType)
                return MetaMachine.CallLogType;

            bool isCallLogNumberIndex = Convert.ToString(field).StartsWith("PhoneNumberIndex_");

            if (isCallLogNumberIndex)
                return MetaMachine.CallLogNumberIndex;

            bool isCallLogTypePrepend = Convert.ToString(field).StartsWith("CallLogTypePrepend_");

            if (isCallLogTypePrepend)
                return MetaMachine.CallLogTypePrepend;

            bool isSamsungSmsMarker = Convert.ToString(field).StartsWith("Marker_SamsungSms");

            if (isSamsungSmsMarker)
                return MetaMachine.MarkerSamsungSms;

            return MetaMachine.Binary;
        }
Exemplo n.º 27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="field"></param>
        /// <returns>Returns the meta machine. If the machine is not known, then it will return binary</returns>
        private MetaMachine GetMetaMachine(MachineList field)
        {
            bool isPhone = (Convert.ToString(field).StartsWith("PhoneNumber_"));

            if (isPhone)
            {
                return(MetaMachine.PhoneNumber);
            }

            bool isTimeStamp = Convert.ToString(field).StartsWith("TimeStamp_");

            if (isTimeStamp)
            {
                return(MetaMachine.TimeStamp);
            }

            bool isText = Convert.ToString(field).StartsWith("Text_");

            if (isText)
            {
                return(MetaMachine.Text);
            }

            bool isSmsPrepend = Convert.ToString(field).StartsWith("Prepend_");

            if (isSmsPrepend)
            {
                return(MetaMachine.SmsPrepend);
            }

            bool isCallLogType = Convert.ToString(field).StartsWith("CallLogType_");

            if (isCallLogType)
            {
                return(MetaMachine.CallLogType);
            }

            bool isCallLogNumberIndex = Convert.ToString(field).StartsWith("PhoneNumberIndex_");

            if (isCallLogNumberIndex)
            {
                return(MetaMachine.CallLogNumberIndex);
            }

            bool isCallLogTypePrepend = Convert.ToString(field).StartsWith("CallLogTypePrepend_");

            if (isCallLogTypePrepend)
            {
                return(MetaMachine.CallLogTypePrepend);
            }


            bool isSamsungSmsMarker = Convert.ToString(field).StartsWith("Marker_SamsungSms");

            if (isSamsungSmsMarker)
            {
                return(MetaMachine.MarkerSamsungSms);
            }

            return(MetaMachine.Binary);
        }
Exemplo n.º 28
0
        public static void PrintMenu()
        {
            var  machines = new MachineList();
            bool menu     = true;

            while (menu)
            {
                Console.Clear();
                Console.WriteLine("\t=====Welcome to Slynet 1.7=====");
                Console.WriteLine("\n\tPlease choose your option below.");
                Console.WriteLine("\t[1]Select Terminator");
                Console.WriteLine("\t[2]Set Mission");
                Console.WriteLine("\t[3]Quit");
                string menuChoice = Console.ReadLine();

                switch (menuChoice)
                {
                case "1":
                {
                    Console.Clear();
                    Console.WriteLine("\tPlease select Terminator");
                    machines.ListMachine();
                    Console.WriteLine("\n\tActivate Terminator: ");
                    string select = Console.ReadLine();

                    if (select == "1")
                    {
                        MachineMenu.Menu(1, machines);
                    }
                    if (select == "2")
                    {
                        MachineMenu.Menu(2, machines);
                    }
                    if (select == "3")
                    {
                        MachineMenu.Menu(3, machines);
                    }
                    if (select == "4")
                    {
                        MachineMenu.Menu(4, machines);
                    }
                    Console.Clear();
                    break;
                }

                case "2":
                {
                    Console.Clear();
                    Console.WriteLine("\tPlease select Terminator");
                    machines.ListMachine();
                    string select = Console.ReadLine();

                    if (select == "1")
                    {
                        MachineMenu.Menu(1, machines);
                    }
                    if (select == "2")
                    {
                        MachineMenu.Menu(2, machines);
                    }
                    if (select == "3")
                    {
                        MachineMenu.Menu(3, machines);
                    }
                    if (select == "4")
                    {
                        MachineMenu.Menu(4, machines);
                    }
                    Console.Clear();
                    break;
                }

                case "3":
                {
                    Console.Clear();
                    Console.Write("\tDo you want to quit? Y/N: ");
                    string quit = Console.ReadLine();
                    if (quit == "Y" || quit == "y")
                    {
                        menu = false;
                    }
                    break;
                }

                default:
                    Console.WriteLine("\tChoose a number between 1-4");
                    break;
                }
            }
        }