Esempio n. 1
0
        public static Objects.AllotmentXpathObject GetAllotmentXPath()
        {
            var elbo         = new BO.ElementLabelBO();
            var px           = new Objects.AllotmentXpathObject();
            var elmAllotment = elbo.GetLabel(45);
            var elmDate      = elbo.GetLabel(43);
            var elmCloseOut  = elbo.GetLabel(46);
            var elmRoomName  = elbo.GetLabel(44);
            var elmRowXPath  = elbo.GetLabel(42);

            px.Allotment = new Objects.XPathItem {
                AttributeName = "value", XPath = elmAllotment.XPath
            };
            px.CloseOut = new Objects.XPathItem {
                AttributeName = "checked", XPath = elmCloseOut.XPath
            };
            px.DateXPath = new Objects.XPathItem {
                AttributeName = "value", XPath = elmDate.XPath
            };
            px.RoomName = new Objects.XPathItem {
                AttributeName = "value", XPath = elmRoomName.XPath
            };
            px.RowXPath = new Objects.XPathItem {
                AttributeName = null, XPath = elmRowXPath.XPath
            };
            return(px);
        }
        public List <Objects.LabelObject> GetLabelObjects()
        {
            var lbo  = new BO.ElementLabelBO();
            var lst  = lbo.GetQueryable(_ActionData.ActionId).ToList();
            var objs = new List <Objects.LabelObject>();

            foreach (var lbl in lst)
            {
                objs.Add(new LabelObject(lbl, this._ReturnDataCollection));
            }
            return(objs);
        }
        /* A routine can execute flawless but not get what we want, e.g node selected but not have value, or select nodes
         * return count = 0 so we
         * need to return a boolean to tell the action to stop, not throw error everywhere */
        /// <summary>
        /// Make this public so we can call directly to test on a routine.
        /// </summary>
        /// <param name="routine"></param>
        /// <returns></returns>
        protected virtual void InnerExecuteAction(bool reportLabel)
        {
            BO.ElementLabelBO elbo   = new BO.ElementLabelBO();
            List <int>        lblIds = elbo.GetQueryable(_ActionData.ActionId).OrderBy(l => l.LabelOrder).Select(l => l.LabelId).ToList();

            Objects.LabelObject objLabel;
            for (int i = 0; i < lblIds.Count; i++)
            {
                if (_wk != null && _wk.CancellationPending)
                {
                    break;
                }
                //well this should be enough to refresh data
                elbo = new BO.ElementLabelBO();
                var label = elbo.GetLabel(lblIds[i]);
                //In this case we use special wait not just sleep
                if (label.ExpectedBehavior != (int)WebElementBehavior.WaitForSomethingHappen)
                {
                    var sleep = label.WaitSeconds == 0 ? DefaultLabelWaitMiliseconds : label.WaitSeconds * 1000;
                    System.Threading.Thread.Sleep(sleep);
                }
                if (_wk != null && _wk.CancellationPending)
                {
                    break;
                }
                if (_wk != null && reportLabel)
                {
                    _wk.ReportProgress(0, "execute label \"" + label.LabelName + "\"");
                }
                objLabel             = new LabelObject(label, this._inputDatas);
                objLabel._NodeParent = _CurrentHtmlAgilityNodeParent;
                objLabel._wk         = _wk;
                try
                {
                    objLabel.ExecuteBehavior();
                    //do not wait by label.seconds because it is for behavior like waitforvisible etc
                    System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
                    if (objLabel._ReturnData != null)
                    {
                        if (_ReturnDataCollection == null)
                        {
                            _ReturnDataCollection = new Dictionary <string, object>();
                        }
                        _ReturnDataCollection[objLabel._LabelData.ReturnDataKey] = objLabel._ReturnData;
                    }
                }
                catch (MyExceptions.BreakRoutineIfFoundException)
                {
                    if (_wk != null)
                    {
                        _wk.ReportProgress(0, "Found label " + label.LabelName + ", break routine" + Environment.NewLine);
                    }
                    break;
                }
                catch (MyExceptions.BreakRoutineIfNOTFoundException)
                {
                    if (_wk != null)
                    {
                        _wk.ReportProgress(0, "Not found label " + label.LabelName + ", break routine" + Environment.NewLine);
                    }
                    break;
                }
                catch (Exception ex)
                {
                    //we should make the error short for easy reading
                    string message = "Error on action: " + _ActionData.ActionName + Environment.NewLine;
                    message += "Label: " + label.LabelName + Environment.NewLine;
                    message += "Label Error Type: " + ex.GetType() + Environment.NewLine;
                    message += "Detail message: " + ex.Message;
                    //if the error is handle we don't need to add it to error collection
                    objLastError            = new ErrorObject();
                    objLastError.Label      = label;
                    objLastError.ActionName = _ActionData.ActionName;
                    //we throw to handle the error upper so we can cover all overload method
                    throw;
                }
            }
        }