Exemple #1
0
 public UpdateForm(VERSION v)
 {
     InitializeComponent();
     this.v = v;
     this.textBox1.Text = v.Description;
     this.label2.Text = String.Format("현재 버젼 : {0:0.0.0} 새로운 버젼 : {1:0.0.0}", MainForm.VERSION, v.Version);
 }
Exemple #2
0
 public MinMax(VERSION version, IGameRules <GAME_BOARD, GAME_MOVE_DESCRIPTION> rules, int max_depth = 0)
 {
     this.version   = version;
     this.rules     = rules;
     this.max_depth = max_depth;
     useSmartDepth  = max_depth == USE_SMART_DEPTH;
 }
        /// <summary>
        /// create a challenge packet. This packet contains CHALLENGE_MESSAGE. The CHALLENGE_MESSAGE defines an NTLM 
        /// challenge message that is sent from the server to the client. The CHALLENGE_MESSAGE is used by the server  
        /// to challenge the client to prove its identity.
        /// </summary>
        /// <param name="negotiateFlags">The client sets flags to indicate options it supports.</param>
        /// <param name="version">
        /// This structure is used for debugging purposes only. In normal (non-debugging) protocol messages, it is
        /// ignored and does not affect the NTLM message processing.
        /// </param>
        /// <param name="serverChallenge">contains the NTLM challenge. The challenge is a 64-bit nonce.</param>
        /// <param name="targetName">
        /// TargetName contains the name of the server authentication realm, and MUST be expressed in the negotiated 
        /// character set. A server that is a member of a domain returns the domain of which it is a member, and a 
        /// server that is not a member of a domain returns the server name. This param can be null.
        /// </param>
        /// <param name="targetInfo">
        /// TargetInfo contains a sequence of AV_PAIR structures.This param can be null.
        /// </param>
        /// <returns>the NlmpChallengePacket</returns>
        /// <noException></noException>
        public NlmpChallengePacket CreateChallengePacket(
            NegotiateTypes negotiateFlags,
            VERSION version,
            ulong serverChallenge,
            string targetName,
            ICollection<AV_PAIR> targetInfo
            )
        {
            NlmpChallengePacket packet = new NlmpChallengePacket();

            packet.SetNegotiateFlags(negotiateFlags);

            if (NlmpUtility.IsVersionRequired(negotiateFlags))
            {
                packet.SetVersion(version);
            }

            packet.SetServerChallenge(serverChallenge);

            if (NlmpUtility.IsDomainType(negotiateFlags) || NlmpUtility.IsServerType(negotiateFlags))
            {
                packet.SetTargetName(targetName);
            }

            // generate bytes of targetinfo
            byte[] targetInfoBytes = NlmpUtility.AvPairCollectionGetBytes(targetInfo);

            // initialize targetinfofield
            packet.SetTargetInfo(targetInfoBytes);

            return packet;
        }
        private void btnLuuThongTin_Click(object sender, EventArgs e)
        {
            //connectionString = string.Format("Data Source = {0}; Initial Catalog = {1}; ", txtTenServer.Text, cboDatabase.Text);

            //if (cboKieuXacThuc.SelectedIndex == 0)
            //    connectionString += "Integrated Security = True; ";
            //else
            //    connectionString += string.Format("User Id = {0}; Password = {1}; ", txtTenDangNhap.Text, txtMatKhau.Text);

            //GlobalSettings.ConnectionString = connectionString;
            //GlobalSettings.ServerName = txtTenServer.Text;
            //GlobalSettings.ServerCatalog = cboDatabase.Text;

            //GlobalSettings.SaveDatabaseConnection();

            LuuLaiCauHinhFileConfig();
            //luu lai duong dan cap nhat CDSL
            VERSION _version = VersionLogic.Select();

            _version.AppLink = txtUpdateVersionLink.Text;
            if (VersionLogic.Update(_version))
            {
                O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CO_LOI_XAY_RA);
                frmthongbao.Show();
            }
        }
Exemple #5
0
        public MainWindow(VERSION version)
        {
            InitializeComponent();
            this.WindowStyle = System.Windows.WindowStyle.SingleBorderWindow;
            this.ResizeMode  = System.Windows.ResizeMode.NoResize;

            mVersion = version;
        }
        private IRestRequest CreateAuthenticatedRequest(Method requestType, string resource, object requestParameters, object requestBody, bool nativeAPI = false)
        {
            SortedDictionary <string, string> queryParams = GetObjectProperties(requestParameters);

            int timeNow = (int)((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds);

            queryParams.Add("auth_key", this._appKey);
            queryParams.Add("auth_timestamp", timeNow.ToString());
            queryParams.Add("auth_version", "1.0");

            if (requestBody != null)
            {
                JsonSerializer serializer   = new JsonSerializer();
                var            bodyDataJson = serializer.Serialize(requestBody);
                var            bodyMD5      = CryptoHelper.GetMd5Hash(bodyDataJson);
                queryParams.Add("body_md5", bodyMD5);
            }

            string queryString = string.Empty;

            foreach (KeyValuePair <string, string> parameter in queryParams)
            {
                queryString += parameter.Key + "=" + parameter.Value + "&";
            }
            queryString = queryString.TrimEnd('&');

            resource = resource.TrimStart('/');
            string path;

            if (!nativeAPI)
            {
                path = string.Format("/apps/{0}/{1}", this._appId, resource);
            }
            else
            {
                path = string.Format("/{0}/{1}/apps/{2}/{3}", _options.Notification_Prefix, _options.Notificaiton_Version, this._appId, resource);
            }

            string authToSign = String.Format(
                Enum.GetName(requestType.GetType(), requestType) +
                "\n{0}\n{1}",
                path,
                queryString);

            var authSignature = CryptoHelper.GetHmac256(_appSecret, authToSign);

            var requestUrl = path + "?" + queryString + "&auth_signature=" + authSignature;
            var request    = new RestRequest(requestUrl);

            request.RequestFormat = DataFormat.Json;
            request.Method        = requestType;
            request.AddBody(requestBody);

            request.AddHeader("Pusher-Library-Name", LIBRARY_NAME);
            request.AddHeader("Pusher-Library-Version", VERSION.ToString(3));

            return(request);
        }
 private void KiemTraVaCopyFileLaucherNew()
 {
     try
     {
         VERSION dataversion = BusinessLogic.VersionLogic.Select();
         if (dataversion != null)
         {
             CopyFolder_CheckSum(dataversion.AppLink, Environment.CurrentDirectory);
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Error(ex);
     }
 }
 private void LoadCauHinhUpdateVersion()
 {
     try
     {
         VERSION _version = VersionLogic.Select();
         if (_version != null)
         {
             txtUpdateVersionLink.Text = _version.AppLink;
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Warn(ex);
     }
 }
        public static bool Insert(VERSION _version)
        {
            try
            {
                Database.VERSIONs.InsertOnSubmit(_version);
                Database.SubmitChanges();
                return(true);
            }
            catch (System.Exception ex)
            {
                return(false);

                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
Exemple #10
0
        public GoogleTranslator(string queryTerm, VERSION version, LANGUAGE languageFrom,
                                LANGUAGE languageTo, string key)
        {
            _q        = HttpUtility.UrlPathEncode(queryTerm);
            _v        = HttpUtility.UrlEncode(EnumStringUtil.GetStringValue(version));
            _langPair =
                HttpUtility.UrlEncode(EnumStringUtil.GetStringValue(languageFrom) +
                                      "|" + EnumStringUtil.GetStringValue(languageTo));
            _key = HttpUtility.UrlEncode(key);

            string encodedRequestUrlFragment =
                string.Format("?v={0}&q={1}&langpair={2}&key={3}",
                              _v, _q, _langPair, _key);

            _requestUrl = EnumStringUtil.GetStringValue(BASEURL.TRANSLATE) + encodedRequestUrlFragment;

            GetTranslation();
        }
Exemple #11
0
        private void DoUpdate()
        {
            UpdateChecker updateChecker = new UpdateChecker(AppName);
            VERSION       NewistVersion = updateChecker.Get();

            if (!NewistVersion.SUCCEED)
            {
                MessageBox.Show("업데이트를 확인할 수 없습니다!", "에러", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (NewistVersion.Version > CurrentVersion)
            {
                if (MessageBox.Show("업데이트 하시겠습니까?", "업데이트", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start(NewistVersion.DownloadLink);
                    isUpdating = true;
                }
            }
        }
Exemple #12
0
        public string ConvertToISBN13(string input)
        {
            // Sanitize input
            var sanitized = Recognizer.SanitizeISBN(input);

            // Try to determine the ISBN Version used
            VERSION version = Recognizer.RecognizeISBN(sanitized);

            // Throw if unable to determine (likely malformed string)
            if (version == VERSION.INVALID)
            {
                throw new FormatException($"Invalid ISBN Format for {input} detected!");
            }

            var isbn = (version == VERSION.ISBN13
                ? sanitized
                : Converter.ConvertISBN10ToISBN13(sanitized));

            return(isbn);
        }
 private void KiemTraTonTaiVaInsertLinkVersion()
 {
     try
     {
         VERSION _version = VersionLogic.Select();
         if (_version == null)
         {
             VERSION _versionInsert = new VERSION()
             {
                 AppVersion = "1.0.0.0",
                 //AppLink = txtUpdateVersionLink.Text,
                 AppType = 0,
             };
             VersionLogic.Insert(_version);
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Warn(ex);
     }
 }
Exemple #14
0
        public PCATTableRoutine(ConnectionInfo info, VERSION ver)
        {
            mVersion = ver;

            try
            {
                mConnInfo = info;

                if (mVersion == VERSION.MANAGER ||
                    mVersion == VERSION.CLIENT)
                {
                    initMySQL();
                }
            }
            catch (MySqlException e)
            {
                if (e.Number == 1042)
                {
                    throw e;
                }
            }
        }
        public static bool Update(VERSION _version)
        {
            try
            {
                var temp = (from p in Database.VERSIONs
                            select p).Single();

                temp.AppVersion = _version.AppVersion;
                temp.AppLink    = _version.AppLink;
                //temp.AppResults = _version.AppResults;
                temp.AppMD5Hash = _version.AppMD5Hash;
                temp.SqlVersion = _version.SqlVersion;
                temp.SqlResults = _version.SqlResults;

                Database.SubmitChanges();
                return(true);
            }
            catch (System.Exception ex)
            {
                return(false);

                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
 public static MessageClass Packer(VERSION version)
 {
     return(new Builder(version.GetCode()));
 }
Exemple #17
0
        /// <summary>
        /// Converts the isbn.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns></returns>
        /// <exception cref="System.FormatException">
        /// </exception>
        public string ConvertISBN(string input)
        {
            // Sanitize input
            var sanitized = Recognizer.SanitizeISBN(input);

            // Try to determine the ISBN Version used
            VERSION version = Recognizer.RecognizeISBN(sanitized);

            // Throw if unable to determine (likely malformed string)
            if (version == VERSION.INVALID)
            {
                throw new FormatException($"Invalid ISBN Format for {input} detected!");
            }

            // Throw if the ISBN contains invalid characters
            if (!(version == VERSION.ISBN10
                                ? Spec.IsISBN10SpecCompliant(sanitized)
                                : Spec.IsISBN13SpecCompliant(sanitized)))
            {
                throw new FormatException($"{input} is not spec compliant!");
            }

            // Throw if checksum calculated is not the one in the ISBN (malformed/incorrect ISBN)
            var checksum = (version == VERSION.ISBN10
                                ? Spec.CalculateChecksum10(sanitized)
                                : Spec.CalculateChecksum13(sanitized));

            if (checksum != sanitized[sanitized.Length - 1])
            {
                throw new FormatException(
                          $"Checksum mismatch for {input}! It should be {checksum.ToString().ToUpper()}!");
            }

            var isbn = (version == VERSION.ISBN10
                                ? Converter.ConvertISBN10ToISBN13(sanitized)
                                : Converter.ConvertISBN13ToISBN10(sanitized));

            // Check if input already contains separation (and thus can simply copied)
            if (input.Contains("-") || input.Contains(" "))
            {
                // Remove the prefix and the first separator if it exists
                if (version == VERSION.ISBN13)
                {
                    input = input.Substring(Spec.PREFIX.Length + 1);
                }

                var separator = "-";

                // Check if '-' or ' ' are used for separation
                if (input.Contains(" "))
                {
                    separator = " ";
                }

                // Place the separators into the new string
                while (input.Contains(separator))
                {
                    var index = input.IndexOf(separator);
                    isbn  = isbn.Insert((version == VERSION.ISBN10 ? Spec.PREFIX.Length : 0) + index, "-");
                    input = input.Substring(0, index) + "+" + input.Substring(index + 1);
                }

                // We also need to hyphenate the prefix if it exists
                // This and the check above are inverted since we need to modify the target ISBN version
                if (version == VERSION.ISBN10)
                {
                    isbn = isbn.Insert(Spec.PREFIX.Length, "-");
                }
            }
            else
            {
                isbn = HyphenateISBN(isbn);
            }

            return(isbn);
        }
 /// <summary>
 /// set the version
 /// </summary>
 /// <param name="version">the new version</param>
 public abstract void SetVersion(
     VERSION version
     );
 /// <summary>
 /// set the version
 /// </summary>
 /// <param name="version">the new version</param>
 public override void SetVersion(
     VERSION version
     )
 {
     payload.Version = version;
 }
Exemple #20
0
 private void NewVersionReleased(VERSION v)
 {
     UpdateForm uf = new UpdateForm(v);
     uf.ShowDialog();
 }
        /// <summary>
        /// this function create a negotiate packet.
        /// client send the negotiate packet to server to indicate the supported capabilities.
        /// in connection-oriented mode, this is the first packet that client send to server.
        /// </summary>
        /// <param name="negotiateFlags">this flags indicates the capabilities that client supports.</param>
        /// <param name="version">
        /// This structure is used for debugging purposes only. In normal (non-debugging) protocol messages, it is 
        /// ignored and does not affect the NTLM message processing.
        /// </param>
        /// <param name="domainName">
        /// DomainName contains the name of the client authentication domain that MUST be encoded using the OEM 
        /// character set. This param can not be null.
        /// </param>
        /// <param name="workstationName">
        /// WorkstationName contains the name of the client machine that MUST be encoded using the OEM character 
        /// set. Otherwise, this data is not present. This param can not be null.
        /// </param>
        /// <returns>the negotiate packet</returns>
        /// <exception cref="ArgumentNullException">domainName must not be null</exception>
        /// <exception cref="ArgumentNullException">workstationName must not be null</exception>
        /// <exception cref="ArgumentException">
        /// when version is required, the domainName and workstationName must be string.Empty
        /// </exception>
        public NlmpNegotiatePacket CreateNegotiatePacket(
            NegotiateTypes negotiateFlags,
            VERSION version,
            string domainName,
            string workstationName
            )
        {
            if (NlmpUtility.IsConnectionless(negotiateFlags))
            {
                throw new NotSupportedException("NEGOTIATE message is not supported under Connectionless mode.");
            }

            if (domainName == null)
            {
                throw new ArgumentNullException("domainName");
            }

            if (workstationName == null)
            {
                throw new ArgumentNullException("workstationName");
            }

            #region Parameter validation

            if (NlmpUtility.IsVersionRequired(negotiateFlags))
            {
                if (domainName.Length != 0)
                {
                    throw new ArgumentException(
                        "when version is required, the domainName should be string.Empty!", "domainName");
                }

                if (workstationName.Length != 0)
                {
                    throw new ArgumentException(
                        "when version is required, the workstationName should be string.Empty!", "workstationName");
                }
            }
            else
            {
                if (NlmpUtility.IsDomainNameSupplied(negotiateFlags) && domainName.Length == 0)
                {
                    throw new ArgumentException(
                        "when version is not required, the domainName should not be string.Empty!", "domainName");
                }

                if (NlmpUtility.IsWorkstationSupplied(negotiateFlags) && workstationName.Length == 0)
                {
                    throw new ArgumentException(
                        "when version is not required, the workstationName should not be string.Empty!",
                        "workstationName");
                }
            }

            #endregion

            NlmpNegotiatePacket packet = new NlmpNegotiatePacket();

            packet.SetNegotiateFlags(negotiateFlags);

            if (NlmpUtility.IsVersionRequired(negotiateFlags))
            {
                packet.SetVersion(version);
            }
            else
            {
                if (NlmpUtility.IsDomainNameSupplied(negotiateFlags))
                {
                    packet.SetDomainName(domainName);
                }

                if (NlmpUtility.IsWorkstationSupplied(negotiateFlags))
                {
                    packet.SetWorkstationName(workstationName);
                }
            }

            return packet;
        }
        /// <summary>
        /// this function create an authenticate packet.
        /// after client received the challenge packet from server, client create an authenticate packet to server.
        /// the authenticate packet contains the authentication information of user that is generated by the credential
        /// of user.
        /// this function does not set the mic field of packet. it must be set manually if need.
        /// </summary>
        /// <param name="negotiateFlags">this flags indicates the capabilities that client supports.</param>
        /// <param name="version">
        /// This structure is used for debugging purposes only. In normal (non-debugging) protocol messages, it is 
        /// ignored and does not affect the NTLM message processing.
        /// </param>
        /// <param name="lmChallengeResponse">
        /// An LM_RESPONSE or LMv2_RESPONSE structure that contains the computed LM response to the challenge. If 
        /// NTLM v2 authentication is configured, LmChallengeResponse MUST be an LMv2_RESPONSE structure. Otherwise, 
        /// it MUST be an LM_RESPONSE structure.
        /// </param>
        /// <param name="ntChallengeResponse">
        /// An NTLM_RESPONSE or NTLMv2_RESPONSE structure that contains the computed NT response to the challenge. 
        /// If NTLM v2 authentication is configured, NtChallengeResponse MUST be an NTLMv2_RESPONSE. Otherwise, it 
        /// MUST be an NTLM_RESPONSE structure.
        /// </param>
        /// <param name="domainName">
        /// The domain or computer name hosting the user account. DomainName MUST be encoded in the negotiated 
        /// character set. This param can not be null.
        /// </param>
        /// <param name="userName">
        /// The name of the user to be authenticated. UserName MUST be encoded in the negotiated character set. This 
        /// param can not be null.
        /// </param>
        /// <param name="workstation">
        /// The name of the computer to which the user is logged on. Workstation MUST be encoded in the negotiated 
        /// character set. This param can not be null.
        /// </param>
        /// <param name="encryptedRandomSessionKey">
        /// The client's encrypted random session key. This param can be null.
        /// </param>
        /// <returns>the authenticate packet</returns>
        /// <exception cref="System.ArgumentNullException">
        /// when LM is using, the ntChallengeResponse should be null!
        /// </exception>
        public NlmpAuthenticatePacket CreateAuthenticatePacket(
            NegotiateTypes negotiateFlags,
            VERSION version,
            byte[] lmChallengeResponse,
            byte[] ntChallengeResponse,
            string domainName,
            string userName,
            string workstation,
            byte[] encryptedRandomSessionKey
            )
        {
            #region Parameter check

            if (domainName == null)
            {
                throw new ArgumentNullException("domainName");
            }

            if (userName == null)
            {
                throw new ArgumentNullException("userName");
            }

            if (workstation == null)
            {
                throw new ArgumentNullException("workstation");
            }

            if (NlmpUtility.IsLm(negotiateFlags) && ntChallengeResponse != null)
            {
                throw new ArgumentException(
                    "when LM is using, the ntChallengeResponse should be null!", "ntChallengeResponse");
            }

            #endregion

            NlmpAuthenticatePacket packet = new NlmpAuthenticatePacket();

            // update flags
            packet.SetNegotiateFlags(negotiateFlags);

            // if version required, update version
            if (NlmpUtility.IsVersionRequired(negotiateFlags))
            {
                packet.SetVersion(version);
            }

            // update domain name
            packet.SetDomainName(domainName);

            // update user name
            packet.SetUserName(userName);

            // if version required, update workstation
            if (NlmpUtility.IsVersionRequired(negotiateFlags))
            {
                packet.SetWorkstation(workstation);
            }

            // update lmChallengeResponse
            packet.SetLmChallengeResponse(lmChallengeResponse);

            // update ntChallengeResponse
            packet.SetNtChallengeResponse(ntChallengeResponse);

            // update encryptedRandomSessionKey
            packet.SetEncryptedRandomSessionKey(encryptedRandomSessionKey);

            return packet;
        }
        private void LoadVersionAndState()
        {
            //NOT USED ANYMORE
            STATE        currentState    = state;
            VERSION      currentVersion  = version;
            WTM_ACTIVITY currentActivity = activity;
            string       currentTestplan = string.Empty;

            //Check if Wtm is open
            mainHWnd = AppManipulation.FindWindowByClassName("WindowsForms10.Window.8.app3");

            //Set version
            if (mainHWnd != IntPtr.Zero)
            {
                wtmHwnd = AppManipulation.FindWindowByWindowName("E6567C Agilent cdma2000/IS-95/AMPS/1xEV-DO Wireless Test Manager");
                if (wtmHwnd != IntPtr.Zero)
                {
                    version = VERSION.AGILENT_E6567;
                }
                if (wtmHwnd == IntPtr.Zero)
                {
                    wtmHwnd = AppManipulation.FindWindowByWindowName("Agilent E6567D cdma2000/IS-95/AMPS/1xEV-DO/LTE Wireless Test Manager");
                    if (wtmHwnd != IntPtr.Zero)
                    {
                        version = VERSION.AGILENT_E6567;
                    }
                }
                if (wtmHwnd == IntPtr.Zero)
                {
                    wtmHwnd = AppManipulation.FindWindowByWindowName("Agilent E6567E cdma2000/IS-95/AMPS/1xEV-DO/LTE Wireless Test Manager");
                    if (wtmHwnd != IntPtr.Zero)
                    {
                        version = VERSION.AGILENT_E6567;
                    }
                }
                if (wtmHwnd == IntPtr.Zero)
                {
                    wtmHwnd = AppManipulation.FindWindowByWindowName("Agilent E6560C cdma2000/IS-95/AMPS Wireless Test Manager");
                    if (wtmHwnd != IntPtr.Zero)
                    {
                        version = VERSION.AGILENT_E6560;
                    }
                }
                if (wtmHwnd == IntPtr.Zero)
                {
                    wtmHwnd = AppManipulation.FindWindowByWindowName("Agilent E6568C WCDMA/GSM/GPRS/EGPRS Wireless Test Manager");
                    if (wtmHwnd != IntPtr.Zero)
                    {
                        version = VERSION.AGILENT_E6568;
                    }
                }
                if (wtmHwnd == IntPtr.Zero)
                {
                    wtmHwnd = AppManipulation.FindWindowByWindowName("Agilent E6568E WCDMA/GSM/GPRS/EGPRS/LTE Wireless Test Manager");
                    if (wtmHwnd != IntPtr.Zero)
                    {
                        version = VERSION.AGILENT_E6568;
                    }
                }
            }
            else
            {
                wtmHwnd  = AppManipulation.FindWindowByWindowName("PoST- 8924C/E & E8285A CDMA Mobile Tests");
                mainHWnd = wtmHwnd;
                if (wtmHwnd != IntPtr.Zero)
                {
                    version = VERSION.POST_E8285;
                }
            }

            //Set state
            if (mainHWnd != IntPtr.Zero)
            {
                if (wtmHwnd != IntPtr.Zero)
                {
                    state = STATE.OPEN;
                }
                else
                {
                    state = STATE.OPENING;
                }
            }
            else
            {
                state = STATE.CLOSED;
            }

            //Set current wtm activity
            if (mainHWnd != IntPtr.Zero && state == STATE.OPEN && version != VERSION.NONE)
            {
                if (version != VERSION.POST_E8285)
                {
                    try
                    {
                        #region Set the activity for the Wtm versions
                        if (this.gettingStatus)
                        {
                            if (!AppManipulation.IsWindowMinimized(wtmHwnd))
                            {
                                //Get all the handlers for all the Wtm versions
                                int ContainerCount = AppManipulation.FindChildWindowCountByClassName(mainHWnd, "WindowsForms10.Window.8.app3");
                                if (ContainerCount > 0)
                                {
                                    ContainerCount = (ContainerCount > 30) ? 30 : ContainerCount;
                                    activity       = WTM_ACTIVITY.NONE;
                                    string[] captions;
                                    bool     somethingFound = false;
                                    for (int j = ContainerCount - 3; j < ContainerCount; j++)
                                    {
                                        IntPtr statusContainer = AppManipulation.FindChildWindowByClassNameByIndex(mainHWnd, "WindowsForms10.Window.8.app3", j);//27
                                        if (statusContainer != IntPtr.Zero)
                                        {
                                            int count = AppManipulation.FindChildWindowCountByClassName(statusContainer, "WindowsForms10.msctls_statusbar32.app3");//6 o 7

                                            for (int i = 6; i < count; i++)
                                            {
                                                IntPtr statusPtr = AppManipulation.FindChildWindowByClassNameByIndex(statusContainer, "WindowsForms10.msctls_statusbar32.app3", i);
                                                if (statusPtr != IntPtr.Zero)
                                                {
                                                    Valutech.IO.StatusBar status = new Valutech.IO.StatusBar(statusPtr);
                                                    captions = status.Captions;
                                                    if (captions.Length > 1)
                                                    {
                                                        string statusText = captions[1];
                                                        if (statusText != string.Empty)
                                                        {
                                                            somethingFound = true;
                                                            if (activity == WTM_ACTIVITY.NONE)
                                                            {
                                                                if (statusText == "	")
                                                                {
                                                                    activity = WTM_ACTIVITY.FIRST_TIME_START;
                                                                }
                                                                Regex regex = new Regex("Performing CDMAVoiceQuality . . .|Performing GSMMobileInitiatedCall . . .");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.CHECKING_VOICE_QUALITY;
                                                                }
                                                                regex = new Regex("Performing CDMAPage . . .");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.PERFORMING_CDMA_PAGE;
                                                                }
                                                                regex = new Regex("Performing WCDMAOrigination . . .");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.PERFORMING_CDMA_PAGE;
                                                                }
                                                                regex = new Regex("Passed = [0-9]{1,}[ ]{1,}Failed = [0-9]{1,}|Test Plan Aborted");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.TEST_FINISHED;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    if (somethingFound && activity == WTM_ACTIVITY.NONE)
                                    {
                                        activity = WTM_ACTIVITY.TESTING;
                                    }
                                }

                                //Get the testplan directly from window
                                int comboboxCount = AppManipulation.FindChildWindowCountByClassName(mainHWnd, "WindowsForms10.COMBOBOX.app3");
                                if (comboboxCount > 0)
                                {
                                    IntPtr comboBoxItem  = IntPtr.Zero;
                                    int    windowsNumber = 15;
                                    while (comboBoxItem == IntPtr.Zero && windowsNumber < 18)
                                    {
                                        comboBoxItem    = AppManipulation.FindChildWindowByClassNameByIndex(mainHWnd, "WindowsForms10.COMBOBOX.app3", windowsNumber);
                                        currentTestplan = AppManipulation.GetText(comboBoxItem);
                                        windowsNumber++;
                                    }
                                }
                            }
                        }
                        else
                        {
                            //AppManipulation.WriteInNotepad("Not getting status");
                        }
                        #endregion
                    }
                    catch { }
                }
                else
                {
                    try
                    {
                        #region Set the activity for the 8285 equipment

                        IntPtr statusContainer = AppManipulation.FindWindowByWindowName("PoST Operator Instructions");
                        if (statusContainer != IntPtr.Zero)
                        {
                            IntPtr statusPtr = AppManipulation.FindChildWindowByClassName(statusContainer, "RichTextWndClass");
                            if (statusPtr != IntPtr.Zero)
                            {
                                string caption = AppManipulation.GetText(statusPtr);
                                if (caption != String.Empty)
                                {
                                    activity = WTM_ACTIVITY.PERFORMING_CDMA_PAGE;
                                    Regex regex = new Regex("Waiting for operator to answer call");
                                    if (regex.IsMatch(caption))
                                    {
                                        activity = WTM_ACTIVITY.WAITING_TO_ANSWER_CALL;
                                    }
                                    regex = new Regex("Speak into the phone");
                                    if (regex.IsMatch(caption))
                                    {
                                        activity = WTM_ACTIVITY.CHECKING_VOICE_QUALITY;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (currentActivity != WTM_ACTIVITY.WAITING_TO_ANSWER_CALL)
                            {
                                GetBtnHwnds();
                                if (stopBtnHwnd != IntPtr.Zero)
                                {
                                    if (AppManipulation.IsWindowVisible(stopBtnHwnd))
                                    {
                                        activity = WTM_ACTIVITY.TESTING;
                                    }
                                    else
                                    {
                                        activity = WTM_ACTIVITY.TEST_FINISHED;
                                    }
                                }
                            }
                            else
                            {
                                activity = currentActivity;
                            }
                        }

                        #endregion
                    } catch { }
                }
            }
            else
            {
                stopBtnHwnd = IntPtr.Zero;
                runBtnHwnd  = IntPtr.Zero;
            }

            //Send events depending on the change
            if (currentState != state)
            {
                if (StateChanged != null)
                {
                    StateChanged(this, EventArgs.Empty);
                }
            }
            if (currentActivity != activity)
            {
                if (ActivityChanged != null)
                {
                    ActivityChanged(this, EventArgs.Empty);
                }
            }
            if (currentVersion != version)
            {
                if (VersionChanged != null)
                {
                    VersionChanged(this, EventArgs.Empty);
                }
            }
            if (currentTestplan != testplan && currentState == STATE.OPEN && !currentTestplan.Contains("Data terminal ready:") && currentTestplan != string.Empty)
            {
                testplan = currentTestplan;
                if (TestplanChanged != null)
                {
                    TestplanChanged(testplan);
                }
            }
        }
Exemple #24
0
        static void Main()
        {
            XORCISMEntities model = new XORCISMEntities();

            //https://stackoverflow.com/questions/5940225/fastest-way-of-inserting-in-entity-framework
            model.Configuration.AutoDetectChangesEnabled = false;
            model.Configuration.ValidateOnSaveEnabled    = false;

            int    iVocabularyCYBOXID = 0;     // 11;
            string sCYBOXVersion      = "2.1"; //HARDCODED TODO

            #region vocabularycybox
            try
            {
                iVocabularyCYBOXID = model.VOCABULARY.Where(o => o.VocabularyName == "CYBOX" && o.VocabularyVersion == sCYBOXVersion).Select(o => o.VocabularyID).FirstOrDefault();
            }
            catch (Exception ex)
            {
            }
            if (iVocabularyCYBOXID <= 0)
            {
                try
                {
                    VOCABULARY oVocabulary = new VOCABULARY();
                    oVocabulary.CreatedDate       = DateTimeOffset.Now;
                    oVocabulary.VocabularyName    = "CYBOX"; //HARDCODED
                    oVocabulary.VocabularyVersion = sCYBOXVersion;
                    model.VOCABULARY.Add(oVocabulary);
                    model.SaveChanges();
                    iVocabularyCYBOXID = oVocabulary.VocabularyID;
                    Console.WriteLine("DEBUG iVocabularyCYBOXID=" + iVocabularyCYBOXID);
                }
                catch (Exception ex)
                {
                }
            }
            #endregion vocabularycybox

            XmlDocument doc;
            doc = new XmlDocument();
            //TODO: download the file
            doc.Load(@"C:\nvdcve\cybox_default_vocabularies.xsd");  //HARDCODED
            //TODO: Validate XSD

            XmlNamespaceManager mgr = new XmlNamespaceManager(doc.NameTable);

            mgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");

            XmlNodeList nodes1;
            nodes1 = doc.SelectNodes("/xs:schema/xs:simpleType", mgr);
            Console.WriteLine(nodes1.Count);



            foreach (XmlNode node in nodes1)    //enumeration
            {
                //Console.WriteLine("DEBUG node.Name="+node.Name);
                string sNodeName = node.Attributes["name"].InnerText;
                Console.WriteLine(sNodeName);

                if (sNodeName.Contains("Enum-"))    //HARDCODED
                {
                    bool bEnumerationProcessed = false;
                    //Get the EnumerationName and Version
                    //ActionNameEnum-1.1
                    string[] words               = sNodeName.Split('-');
                    string   sEnumerationName    = words[0];
                    string   sEnumerationVersion = words[1];

                    //Check if we have this EnumerationVersion in the database
                    //First check the Version
                    #region version
                    XORCISMModel.VERSION oVersion;
                    int iVersionID = 0;
                    try
                    {
                        iVersionID = model.VERSION.FirstOrDefault(o => o.VersionValue == sEnumerationVersion).VersionID;
                    }
                    catch (Exception ex)
                    {
                    }
                    if (iVersionID <= 0)
                    {
                        oVersion = new VERSION();
                        oVersion.VersionValue = sEnumerationVersion;
                        oVersion.VocabularyID = iVocabularyCYBOXID;
                        model.VERSION.Add(oVersion);
                        model.SaveChanges();
                        iVersionID = oVersion.VersionID;
                    }
                    else
                    {
                        //Update VERSION
                    }
                    #endregion version

                    #region enumerationversion
                    XORCISMModel.ENUMERATIONVERSION oEnumerationVersion;
                    int iEnumerationVersionID = 0;
                    try
                    {
                        iEnumerationVersionID = model.ENUMERATIONVERSION.FirstOrDefault(o => o.EnumerationName == sEnumerationName && o.VersionID == iVersionID).EnumerationVersionID;
                    }
                    catch (Exception ex)
                    {
                    }
                    if (iEnumerationVersionID <= 0)
                    {
                        oEnumerationVersion = new ENUMERATIONVERSION();
                        oEnumerationVersion.EnumerationName = sEnumerationName;
                        oEnumerationVersion.VersionID       = iVersionID;
                        oEnumerationVersion.VocabularyID    = iVocabularyCYBOXID;
                        model.ENUMERATIONVERSION.Add(oEnumerationVersion);
                        model.SaveChanges();
                        iEnumerationVersionID = oEnumerationVersion.EnumerationVersionID;
                    }
                    else
                    {
                        //Update ENUMERATIONVERSION
                    }
                    #endregion enumerationversion

                    //***********************************************************************************************************************************
                    if (sNodeName.Contains("ActionTypeEnum"))   //HARDCODED
                    {
                        #region actiontype
                        foreach (XmlNode node2 in node)
                        {
                            //Console.WriteLine(node2.Name);
                            if (node2.Name == "xs:restriction")            //HARDCODED
                            {
                                foreach (XmlNode nodeEnumeration in node2) //xs:enumeration
                                {
                                    string sEnumerationValue = nodeEnumeration.Attributes["value"].InnerText;
                                    XORCISMModel.ACTIONTYPE myActionType;
                                    myActionType = model.ACTIONTYPE.FirstOrDefault(o => o.ActionTypeName == sEnumerationValue && o.EnumerationVersionID == iEnumerationVersionID);// && o.VocabularyID == iVocabularyCYBOXID);
                                    if (myActionType == null)
                                    {
                                        Console.WriteLine("DEBUG Adding new ACTIONTYPE " + sEnumerationValue);
                                        myActionType = new ACTIONTYPE();
                                        myActionType.ActionTypeName       = sEnumerationValue;
                                        myActionType.VocabularyID         = iVocabularyCYBOXID;
                                        myActionType.EnumerationVersionID = iEnumerationVersionID;
                                        model.ACTIONTYPE.Add(myActionType);
                                        model.SaveChanges();
                                    }
                                    else
                                    {
                                        //Update ACTIONTYPE
                                    }
                                    foreach (XmlNode node3 in nodeEnumeration)    //xs:annotation
                                    {
                                        foreach (XmlNode node4 in node3)          //xs:documentation
                                        {
                                            if (node4.Name == "xs:documentation") //HARDCODED
                                            {
                                                Console.WriteLine("DEBUG documentation=" + node4.InnerText);
                                                myActionType.ActionTypeDescription = node4.InnerText;
                                                model.SaveChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion actiontype
                        bEnumerationProcessed = true;
                    }

                    //***********************************************************************************************************************************
                    if (sNodeName.Contains("ActionNameEnum"))
                    {
                        #region actionname
                        foreach (XmlNode node2 in node)
                        {
                            //Console.WriteLine(node2.Name);
                            if (node2.Name == "xs:restriction")
                            {
                                foreach (XmlNode nodeEnumeration in node2)  //xs:enumeration
                                {
                                    string sEnumerationValue = nodeEnumeration.Attributes["value"].InnerText;
                                    XORCISMModel.ACTIONNAME myActionName;
                                    myActionName = model.ACTIONNAME.FirstOrDefault(o => o.ActionNameName == sEnumerationValue && o.EnumerationVersionID == iEnumerationVersionID);// && o.VocabularyID == iVocabularyCYBOXID);
                                    if (myActionName == null)
                                    {
                                        Console.WriteLine("DEBUG Adding new ACTIONNAME " + sEnumerationValue);
                                        myActionName = new ACTIONNAME();
                                        myActionName.ActionNameName       = sEnumerationValue;
                                        myActionName.VocabularyID         = iVocabularyCYBOXID;
                                        myActionName.EnumerationVersionID = iEnumerationVersionID;
                                        model.ACTIONNAME.Add(myActionName);
                                        model.SaveChanges();
                                    }
                                    else
                                    {
                                        //Update ACTIONNAME
                                    }

                                    foreach (XmlNode node3 in nodeEnumeration) //xs:annotation
                                    {
                                        foreach (XmlNode node4 in node3)       //xs:documentation
                                        {
                                            if (node4.Name == "xs:documentation")
                                            {
                                                Console.WriteLine("DEBUG documentation=" + node4.InnerText);
                                                myActionName.ActionNameDescription = node4.InnerText;
                                                model.SaveChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion actionname
                        bEnumerationProcessed = true;
                    }
                    //***

                    //***********************************************************************************************************************************
                    if (sNodeName.Contains("ActionArgumentNameEnum"))
                    {
                        #region actionargument
                        foreach (XmlNode node2 in node)
                        {
                            //Console.WriteLine(node2.Name);
                            if (node2.Name == "xs:restriction")
                            {
                                foreach (XmlNode nodeEnumeration in node2)  //xs:enumeration
                                {
                                    string sEnumerationValue = nodeEnumeration.Attributes["value"].InnerText;
                                    XORCISMModel.ACTIONARGUMENTNAME myActionArgumentName;
                                    myActionArgumentName = model.ACTIONARGUMENTNAME.FirstOrDefault(o => o.ActionArgumentNameName == sEnumerationValue);// && o.VocabularyID == iVocabularyCYBOXID);
                                    if (myActionArgumentName == null)
                                    {
                                        Console.WriteLine("DEBUG Adding new ACTIONARGUMENTNAME " + sEnumerationValue);
                                        myActionArgumentName = new ACTIONARGUMENTNAME();
                                        myActionArgumentName.ActionArgumentNameName = sEnumerationValue;
                                        myActionArgumentName.VocabularyID           = iVocabularyCYBOXID;
                                        model.ACTIONARGUMENTNAME.Add(myActionArgumentName);
                                        model.SaveChanges();
                                    }

                                    foreach (XmlNode node3 in nodeEnumeration) //xs:annotation
                                    {
                                        foreach (XmlNode node4 in node3)       //xs:documentation
                                        {
                                            if (node4.Name == "xs:documentation")
                                            {
                                                myActionArgumentName.ActionArgumentNameDescription = node4.InnerText;
                                                model.SaveChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion actionargument
                        bEnumerationProcessed = true;
                    }
                    //***

                    //***********************************************************************************************************************************
                    if (sNodeName.Contains("ActionObjectAssociationTypeEnum"))
                    {
                        #region actionobjectassociation
                        foreach (XmlNode node2 in node)
                        {
                            //Console.WriteLine(node2.Name);
                            if (node2.Name == "xs:restriction")
                            {
                                foreach (XmlNode nodeEnumeration in node2)  //xs:enumeration
                                {
                                    string sEnumerationValue = nodeEnumeration.Attributes["value"].InnerText;
                                    XORCISMModel.ACTIONOBJECTASSOCIATIONTYPE myActionObjectAssociationType;
                                    myActionObjectAssociationType = model.ACTIONOBJECTASSOCIATIONTYPE.FirstOrDefault(o => o.ActionObjectAssociationTypeName == sEnumerationValue);// && o.VocabularyID == iVocabularyCYBOXID);
                                    if (myActionObjectAssociationType == null)
                                    {
                                        Console.WriteLine("DEBUG Adding new ACTIONOBJECTASSOCIATIONTYPE " + sEnumerationValue);
                                        myActionObjectAssociationType = new ACTIONOBJECTASSOCIATIONTYPE();
                                        myActionObjectAssociationType.ActionObjectAssociationTypeName = sEnumerationValue;
                                        myActionObjectAssociationType.VocabularyID = iVocabularyCYBOXID;
                                        model.ACTIONOBJECTASSOCIATIONTYPE.Add(myActionObjectAssociationType);
                                        model.SaveChanges();
                                    }

                                    foreach (XmlNode node3 in nodeEnumeration) //xs:annotation
                                    {
                                        foreach (XmlNode node4 in node3)       //xs:documentation
                                        {
                                            if (node4.Name == "xs:documentation")
                                            {
                                                myActionObjectAssociationType.ActionObjectAssociationTypeDescription = node4.InnerText;
                                                model.SaveChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion actionobjectassociation
                        bEnumerationProcessed = true;
                    }
                    //***

                    //***********************************************************************************************************************************
                    if (sNodeName.Contains("ActionRelationshipTypeEnum"))
                    {
                        #region actionrelationtype
                        foreach (XmlNode node2 in node)
                        {
                            //Console.WriteLine(node2.Name);
                            if (node2.Name == "xs:restriction")
                            {
                                foreach (XmlNode nodeEnumeration in node2)  //xs:enumeration
                                {
                                    string sEnumerationValue = nodeEnumeration.Attributes["value"].InnerText;
                                    XORCISMModel.ACTIONRELATIONSHIPTYPE myActionRelationshipType;
                                    myActionRelationshipType = model.ACTIONRELATIONSHIPTYPE.FirstOrDefault(o => o.ActionRelationshipTypeName == sEnumerationValue);// && o.VocabularyID == iVocabularyCYBOXID);
                                    if (myActionRelationshipType == null)
                                    {
                                        Console.WriteLine("DEBUG Adding new ACTIONRELATIONSHIPTYPE " + sEnumerationValue);
                                        myActionRelationshipType = new ACTIONRELATIONSHIPTYPE();
                                        myActionRelationshipType.ActionRelationshipTypeName = sEnumerationValue;
                                        myActionRelationshipType.VocabularyID = iVocabularyCYBOXID;
                                        model.ACTIONRELATIONSHIPTYPE.Add(myActionRelationshipType);
                                        model.SaveChanges();
                                    }

                                    foreach (XmlNode node3 in nodeEnumeration) //xs:annotation
                                    {
                                        foreach (XmlNode node4 in node3)       //xs:documentation
                                        {
                                            if (node4.Name == "xs:documentation")
                                            {
                                                myActionRelationshipType.ActionRelationshipTypeDescription = node4.InnerText;
                                                model.SaveChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion actionrelationtype
                        bEnumerationProcessed = true;
                    }
                    //***

                    //***********************************************************************************************************************************
                    if (sNodeName.Contains("EventTypeEnum"))
                    {
                        #region eventtype
                        foreach (XmlNode node2 in node)
                        {
                            //Console.WriteLine(node2.Name);
                            if (node2.Name == "xs:restriction")
                            {
                                foreach (XmlNode nodeEnumeration in node2)  //xs:enumeration
                                {
                                    string sEnumerationValue = nodeEnumeration.Attributes["value"].InnerText;
                                    XORCISMModel.EVENTTYPE myEventType;
                                    myEventType = model.EVENTTYPE.FirstOrDefault(o => o.EventTypeName == sEnumerationValue);// && o.VocabularyID == iVocabularyCYBOXID);
                                    if (myEventType == null)
                                    {
                                        Console.WriteLine("DEBUG Adding new EVENTTYPE " + sEnumerationValue);
                                        myEventType = new EVENTTYPE();
                                        myEventType.EventTypeName = sEnumerationValue;
                                        myEventType.VocabularyID  = iVocabularyCYBOXID;
                                        model.EVENTTYPE.Add(myEventType);
                                        model.SaveChanges();
                                    }

                                    foreach (XmlNode node3 in nodeEnumeration) //xs:annotation
                                    {
                                        foreach (XmlNode node4 in node3)       //xs:documentation
                                        {
                                            if (node4.Name == "xs:documentation")
                                            {
                                                myEventType.EventTypeDescription = node4.InnerText;
                                                model.SaveChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion eventtype
                        bEnumerationProcessed = true;
                    }
                    //***

                    //***********************************************************************************************************************************
                    if (sNodeName.Contains("ObjectRelationshipEnum"))
                    {
                        #region objectrelation
                        foreach (XmlNode node2 in node)
                        {
                            //Console.WriteLine(node2.Name);
                            if (node2.Name == "xs:restriction")
                            {
                                foreach (XmlNode nodeEnumeration in node2)  //xs:enumeration
                                {
                                    string sEnumerationValue = nodeEnumeration.Attributes["value"].InnerText;
                                    XORCISMModel.OBJECTRELATIONSHIP myObjectRelationship;
                                    myObjectRelationship = model.OBJECTRELATIONSHIP.FirstOrDefault(o => o.ObjectRelationshipName == sEnumerationValue);// && o.VocabularyID == iVocabularyCYBOXID);
                                    if (myObjectRelationship == null)
                                    {
                                        Console.WriteLine("DEBUG Adding new OBJECTRELATIONSHIP " + sEnumerationValue);
                                        myObjectRelationship = new OBJECTRELATIONSHIP();
                                        myObjectRelationship.ObjectRelationshipName = sEnumerationValue;
                                        myObjectRelationship.VocabularyID           = iVocabularyCYBOXID;
                                        model.OBJECTRELATIONSHIP.Add(myObjectRelationship);
                                        model.SaveChanges();
                                    }

                                    foreach (XmlNode node3 in nodeEnumeration) //xs:annotation
                                    {
                                        foreach (XmlNode node4 in node3)       //xs:documentation
                                        {
                                            if (node4.Name == "xs:documentation")
                                            {
                                                myObjectRelationship.ObjectRelationshipDescription = node4.InnerText;
                                                model.SaveChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion objectrelation
                        bEnumerationProcessed = true;
                    }
                    //***

                    //***********************************************************************************************************************************
                    if (sNodeName.Contains("ObjectStateEnum"))
                    {
                        #region objectstate
                        foreach (XmlNode node2 in node)
                        {
                            //Console.WriteLine(node2.Name);
                            if (node2.Name == "xs:restriction")
                            {
                                foreach (XmlNode nodeEnumeration in node2)  //xs:enumeration
                                {
                                    string sEnumerationValue = nodeEnumeration.Attributes["value"].InnerText;
                                    XORCISMModel.OBJECTSTATE myObjectState;
                                    myObjectState = model.OBJECTSTATE.FirstOrDefault(o => o.ObjectStateName == sEnumerationValue);// && o.VocabularyID == iVocabularyCYBOXID);
                                    if (myObjectState == null)
                                    {
                                        Console.WriteLine("DEBUG Adding new OBJECTSTATE " + sEnumerationValue);
                                        myObjectState = new OBJECTSTATE();
                                        myObjectState.ObjectStateName = sEnumerationValue;
                                        myObjectState.VocabularyID    = iVocabularyCYBOXID;
                                        model.OBJECTSTATE.Add(myObjectState);
                                        model.SaveChanges();
                                    }

                                    foreach (XmlNode node3 in nodeEnumeration) //xs:annotation
                                    {
                                        foreach (XmlNode node4 in node3)       //xs:documentation
                                        {
                                            if (node4.Name == "xs:documentation")
                                            {
                                                myObjectState.ObjectStateDescription = node4.InnerText;
                                                model.SaveChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion objectstate
                        bEnumerationProcessed = true;
                    }
                    //***

                    //***********************************************************************************************************************************
                    if (sNodeName.Contains("CharacterEncodingEnum"))
                    {
                        #region characterencoding
                        foreach (XmlNode node2 in node)
                        {
                            //Console.WriteLine(node2.Name);
                            if (node2.Name == "xs:restriction")
                            {
                                foreach (XmlNode nodeEnumeration in node2)  //xs:enumeration
                                {
                                    string sEnumerationValue = nodeEnumeration.Attributes["value"].InnerText;
                                    XORCISMModel.CHARACTERENCODING myCharacterEncoding;
                                    myCharacterEncoding = model.CHARACTERENCODING.FirstOrDefault(o => o.CharacterEncodingName == sEnumerationValue);// && o.VocabularyID == iVocabularyCYBOXID);
                                    if (myCharacterEncoding == null)
                                    {
                                        Console.WriteLine("DEBUG Adding new CHARACTERENCODING " + sEnumerationValue);
                                        myCharacterEncoding = new CHARACTERENCODING();
                                        myCharacterEncoding.CharacterEncodingName = sEnumerationValue;
                                        myCharacterEncoding.VocabularyID          = iVocabularyCYBOXID;
                                        model.CHARACTERENCODING.Add(myCharacterEncoding);
                                        model.SaveChanges();
                                    }

                                    foreach (XmlNode node3 in nodeEnumeration) //xs:annotation
                                    {
                                        foreach (XmlNode node4 in node3)       //xs:documentation
                                        {
                                            if (node4.Name == "xs:documentation")
                                            {
                                                myCharacterEncoding.CharacterEncodingDescription = node4.InnerText;
                                                model.SaveChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion characterencoding
                        bEnumerationProcessed = true;
                    }
                    //***

                    //***********************************************************************************************************************************
                    if (sNodeName.Contains("InformationSourceTypeEnum"))
                    {
                        #region infosourcetype
                        foreach (XmlNode node2 in node)
                        {
                            //Console.WriteLine(node2.Name);
                            if (node2.Name == "xs:restriction")
                            {
                                foreach (XmlNode nodeEnumeration in node2)  //xs:enumeration
                                {
                                    string sEnumerationValue = nodeEnumeration.Attributes["value"].InnerText;
                                    XORCISMModel.INFORMATIONSOURCETYPE myInformationSourceType;
                                    myInformationSourceType = model.INFORMATIONSOURCETYPE.FirstOrDefault(o => o.InformationSourceTypeName == sEnumerationValue);// && o.VocabularyID == iVocabularyCYBOXID);
                                    if (myInformationSourceType == null)
                                    {
                                        Console.WriteLine("DEBUG Adding new INFORMATIONSOURCETYPE " + sEnumerationValue);
                                        myInformationSourceType = new INFORMATIONSOURCETYPE();
                                        myInformationSourceType.InformationSourceTypeName = sEnumerationValue;
                                        myInformationSourceType.VocabularyID = iVocabularyCYBOXID;
                                        model.INFORMATIONSOURCETYPE.Add(myInformationSourceType);
                                        model.SaveChanges();
                                    }

                                    foreach (XmlNode node3 in nodeEnumeration) //xs:annotation
                                    {
                                        foreach (XmlNode node4 in node3)       //xs:documentation
                                        {
                                            if (node4.Name == "xs:documentation")
                                            {
                                                myInformationSourceType.InformationSourceTypeDescription = node4.InnerText;
                                                model.SaveChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion infosourcetype
                        bEnumerationProcessed = true;
                    }
                    //***

                    //***********************************************************************************************************************************
                    if (sNodeName.Contains("HashNameEnum"))
                    {
                        #region hashname
                        foreach (XmlNode node2 in node)
                        {
                            //Console.WriteLine(node2.Name);
                            if (node2.Name == "xs:restriction")
                            {
                                foreach (XmlNode nodeEnumeration in node2)  //xs:enumeration
                                {
                                    string sEnumerationValue = nodeEnumeration.Attributes["value"].InnerText;
                                    XORCISMModel.HASHNAME myHashName;
                                    myHashName = model.HASHNAME.FirstOrDefault(o => o.HashingAlgorithmName == sEnumerationValue);// && o.VocabularyID == iVocabularyCYBOXID);
                                    if (myHashName == null)
                                    {
                                        Console.WriteLine("DEBUG Adding new HASHNAME " + sEnumerationValue);
                                        myHashName = new HASHNAME();
                                        myHashName.HashingAlgorithmName = sEnumerationValue;
                                        myHashName.VocabularyID         = iVocabularyCYBOXID;
                                        model.HASHNAME.Add(myHashName);
                                        model.SaveChanges();
                                    }

                                    foreach (XmlNode node3 in nodeEnumeration) //xs:annotation
                                    {
                                        foreach (XmlNode node4 in node3)       //xs:documentation
                                        {
                                            if (node4.Name == "xs:documentation")
                                            {
                                                myHashName.HashingAlgorithmDescription = node4.InnerText;
                                                model.SaveChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion hashname
                        bEnumerationProcessed = true;
                    }
                    //***

                    //***********************************************************************************************************************************
                    if (sNodeName.Contains("ToolTypeEnum"))
                    {
                        #region tooltype
                        foreach (XmlNode node2 in node)
                        {
                            //Console.WriteLine(node2.Name);
                            if (node2.Name == "xs:restriction")
                            {
                                foreach (XmlNode nodeEnumeration in node2)  //xs:enumeration
                                {
                                    string sEnumerationValue = nodeEnumeration.Attributes["value"].InnerText;
                                    XORCISMModel.TOOLTYPE myToolType;
                                    myToolType = model.TOOLTYPE.FirstOrDefault(o => o.ToolTypeName == sEnumerationValue);// && o.VocabularyID == iVocabularyCYBOXID);
                                    if (myToolType == null)
                                    {
                                        Console.WriteLine("DEBUG Adding new TOOLTYPE " + sEnumerationValue);
                                        myToolType = new TOOLTYPE();
                                        myToolType.ToolTypeName = sEnumerationValue;
                                        myToolType.VocabularyID = iVocabularyCYBOXID;
                                        model.TOOLTYPE.Add(myToolType);
                                        model.SaveChanges();
                                    }

                                    foreach (XmlNode node3 in nodeEnumeration) //xs:annotation
                                    {
                                        foreach (XmlNode node4 in node3)       //xs:documentation
                                        {
                                            if (node4.Name == "xs:documentation")
                                            {
                                                myToolType.ToolTypeDescription = node4.InnerText;
                                                model.SaveChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion tooltype
                        bEnumerationProcessed = true;
                    }
                    //***


                    if (!bEnumerationProcessed)
                    {
                        Console.WriteLine("ERROR Missing Code for " + sNodeName);
                        //sCurrentEnum = "";
                    }
                }
            }

            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());
        }
Exemple #25
0
 public PCATTableRoutine(String dbPath)
 {
     mVersion = VERSION.STANDALONE;
     InitSQLite(dbPath);
 }
 /// <summary>
 /// set the version
 /// </summary>
 /// <param name="version">the new version</param>
 /// <exception cref="ArgumentException">Reserved of VERSION must be 0!</exception>
 public override void SetVersion(
     VERSION version
     )
 {
     if (version.Reserved.Reserved1 != 0 || version.Reserved.Reserved2 != 0 || version.Reserved.Reserved3 != 0)
     {
         throw new ArgumentException("Reserved of VERSION must be 0!", "version");
     }
 }
Exemple #27
0
        private void LoadVersionAndState()
        {
            STATE        currentState    = state;
            VERSION      currentVersion  = version;
            WTM_ACTIVITY currentActivity = activity;
            string       currentTestplan = testplan;

            //Check if Wtm is open
            mainHWnd = AppManipulation.FindWindowByClassName("WindowsForms10.Window.8.app3");

            //Set version
            if (mainHWnd != IntPtr.Zero)
            {
                string wName = AppManipulation.GetWindowName(mainHWnd);
                wtmHwnd = mainHWnd;
                if (wName.IndexOf("E6560") > -1)
                {
                    version = VERSION.AGILENT_E6560;
                }
                else if (wName.IndexOf("E6567") > -1)
                {
                    version = VERSION.AGILENT_E6567;
                }
                else if (wName.IndexOf("E6568") > -1)
                {
                    version = VERSION.AGILENT_E6568;
                }

                //Get the testplan directly from window
                bool next = false;
                foreach (IntPtr hWnd in AppManipulation.GetChildWindows(mainHWnd))
                {
                    if (next == true)
                    {
                        if (currentState == STATE.OPEN)
                        {
                            this.testplan = AppManipulation.GetText(hWnd);
                        }
                        next = false;
                    }
                    if (AppManipulation.GetText(hWnd).IndexOf("DUT serial number") > -1)
                    {
                        next = true;
                    }
                }
            }
            else
            {
                wtmHwnd  = AppManipulation.FindWindowByWindowName("PoST- 8924C/E & E8285A CDMA Mobile Tests");
                mainHWnd = wtmHwnd;
                if (wtmHwnd != IntPtr.Zero)
                {
                    version = VERSION.POST_E8285;
                }
            }

            //Set state
            if (mainHWnd != IntPtr.Zero)
            {
                if (wtmHwnd != IntPtr.Zero)
                {
                    state = STATE.OPEN;
                }
                else
                {
                    state = STATE.OPENING;
                }
            }
            else
            {
                state = STATE.CLOSED;
            }

            //Set current wtm activity
            if (mainHWnd != IntPtr.Zero && state == STATE.OPEN && version != VERSION.NONE)
            {
                if (version != VERSION.POST_E8285)
                {
                    try
                    {
                        #region Set the activity for the Wtm versions
                        if (this.gettingStatus)
                        {
                            if (!AppManipulation.IsWindowMinimized(wtmHwnd))
                            {
                                //Get all the handlers for all the Wtm versions
                                int ContainerCount = AppManipulation.FindChildWindowCountByClassName(mainHWnd, "WindowsForms10.Window.8.app3");
                                if (ContainerCount > 0)
                                {
                                    ContainerCount = (ContainerCount > 30) ? 30 : ContainerCount;
                                    activity       = WTM_ACTIVITY.NONE;
                                    string[] captions;
                                    bool     somethingFound = false;
                                    for (int j = ContainerCount - 3; j < ContainerCount; j++)
                                    {
                                        IntPtr statusContainer = AppManipulation.FindChildWindowByClassNameByIndex(mainHWnd, "WindowsForms10.Window.8.app3", j);//27
                                        if (statusContainer != IntPtr.Zero)
                                        {
                                            int count = AppManipulation.FindChildWindowCountByClassName(statusContainer, "WindowsForms10.msctls_statusbar32.app3");//6 o 7

                                            for (int i = 6; i < count; i++)
                                            {
                                                IntPtr statusPtr = AppManipulation.FindChildWindowByClassNameByIndex(statusContainer, "WindowsForms10.msctls_statusbar32.app3", i);
                                                if (statusPtr != IntPtr.Zero)
                                                {
                                                    Valutech.IO.StatusBar status = new Valutech.IO.StatusBar(statusPtr);
                                                    captions = status.Captions;
                                                    if (captions.Length > 1)
                                                    {
                                                        string statusText = captions[1];
                                                        if (statusText != string.Empty)
                                                        {
                                                            somethingFound = true;
                                                            if (activity == WTM_ACTIVITY.NONE)
                                                            {
                                                                if (statusText == "	")
                                                                {
                                                                    activity = WTM_ACTIVITY.FIRST_TIME_START;
                                                                }
                                                                Regex regex = new Regex("Performing CDMAVoiceQuality . . .|Performing GSMMobileInitiatedCall . . .");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.CHECKING_VOICE_QUALITY;
                                                                }
                                                                regex = new Regex("Performing CDMAPage . . .");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.PERFORMING_CDMA_PAGE;
                                                                }
                                                                regex = new Regex("Performing WCDMAOrigination . . .");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.PERFORMING_CDMA_PAGE;
                                                                }
                                                                regex = new Regex("Passed = [0-9]{1,}[ ]{1,}Failed = [0-9]{1,}|Test Plan Aborted");
                                                                if (regex.IsMatch(statusText))
                                                                {
                                                                    activity = WTM_ACTIVITY.TEST_FINISHED;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    if ((somethingFound && activity == WTM_ACTIVITY.NONE))
                                    {
                                        activity = WTM_ACTIVITY.TESTING;
                                    }
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("Not getting status");
                        }
                        #endregion
                    }
                    catch { }
                }
                else
                {
                    try
                    {
                        #region Set the activity for the 8285 equipment

                        IntPtr statusContainer = AppManipulation.FindWindowByWindowName("PoST Operator Instructions");
                        if (statusContainer != IntPtr.Zero)
                        {
                            IntPtr statusPtr = AppManipulation.FindChildWindowByClassName(statusContainer, "RichTextWndClass");
                            if (statusPtr != IntPtr.Zero)
                            {
                                string caption = AppManipulation.GetText(statusPtr);
                                if (caption != String.Empty)
                                {
                                    activity = WTM_ACTIVITY.PERFORMING_CDMA_PAGE;
                                    Regex regex = new Regex("Waiting for operator to answer call");
                                    if (regex.IsMatch(caption))
                                    {
                                        activity = WTM_ACTIVITY.WAITING_TO_ANSWER_CALL;
                                    }
                                    regex = new Regex("Speak into the phone");
                                    if (regex.IsMatch(caption))
                                    {
                                        activity = WTM_ACTIVITY.CHECKING_VOICE_QUALITY;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (currentActivity != WTM_ACTIVITY.WAITING_TO_ANSWER_CALL)
                            {
                                GetBtnHwnds();
                                if (stopBtnHwnd != IntPtr.Zero)
                                {
                                    if (AppManipulation.IsWindowVisible(stopBtnHwnd))
                                    {
                                        activity = WTM_ACTIVITY.TESTING;
                                    }
                                    else
                                    {
                                        activity = WTM_ACTIVITY.TEST_FINISHED;
                                    }
                                }
                            }
                            else
                            {
                                activity = currentActivity;
                            }
                        }

                        #endregion
                    }
                    catch { }
                }
            }
            else
            {
                stopBtnHwnd         = IntPtr.Zero;
                runBtnHwnd          = IntPtr.Zero;
                dutSerialNumberHwnd = IntPtr.Zero;
            }

            //Send events depending on the change
            if (currentState != state)
            {
                if (StateChanged != null)
                {
                    StateChanged(this, EventArgs.Empty);
                }
                if (state == STATE.OPEN)
                {
                    this.model = GetModelInUse();
                    if (ModelInUseChanged != null)
                    {
                        ModelInUseChanged(this.model);
                    }
                }
            }
            if (currentActivity != activity)
            {
                if (ActivityChanged != null)
                {
                    ActivityChanged(this, EventArgs.Empty);
                }
            }
            if (currentVersion != version)
            {
                if (VersionChanged != null)
                {
                    VersionChanged(this, EventArgs.Empty);
                }
            }
            if (currentTestplan != this.testplan && currentState == STATE.OPEN)
            {
                if (TestplanChanged != null)
                {
                    TestplanChanged(this.testplan);
                }
            }
        }