Example #1
0
        //public webpageCombo(ChromeDriver webbrowser, string name, string alias, string controlId
        //    , enumControlType controlType) : this(webbrowser, name, alias, controlId, controlType)
        //{

        //}
        //public webpageCombo(ChromeDriver webbrowser, string name, string alias, string controlId
        //  , enumControlType controlType)
        //    : this(webbrowser, name, alias, controlId, controlType, null)
        //{

        //}
        /// <summary>
        ///
        /// </summary>
        /// <param name="webbrowser"></param>
        /// <param name="name"></param>
        /// <param name="alias"></param>
        /// <param name="controlId">controlId or xpath should be specified</param>
        /// <param name="xpath">controlId or xpath should be specified</param>
        /// <param name="controlAtt">text or value</param>
        /// <param name="controlType"></param>
        /// <param name="tableSource"></param>
        public webpageCombo(ChromeDriver webbrowser, webpage page, string name, string alias, By controlBy
                            , string controlAtt, enumControlType controlType
                            , Model.htmlTable tableSource)
            : base(webbrowser, page, name, alias, controlBy, controlAtt, controlType)
        {
            this.prp_tableSource = tableSource;
        }
        private void sb_fillDatatablePSID(string html, string tableId, int editColIndex, Model.htmlTable dt)
        {
            if (string.IsNullOrEmpty(html))
            {
                throw new Exception("html is null or empty");
            }
            if (string.IsNullOrEmpty(tableId))
            {
                throw new Exception("tableId is null or empty");
            }


            if (dt == null)
            {
                throw new Exception("dt is null");
            }
            HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
            document.LoadHtml(html);
            var table = document.GetElementbyId(tableId);

            HtmlAgilityPack.HtmlNodeCollection rows;
            if (table == null)
            {
                return;
            }
            HtmlAgilityPack.HtmlNode tbody = table.SelectSingleNode("tbody");
            if (tbody != null)
            {
                rows = tbody.SelectNodes("tr");
            }
            else
            {
                rows = table.SelectNodes("tr");
            }
            int     i;
            DataRow dr;

            int skipRowCountAtBegining = dt.prp_skipRowTop;
            int skipRowCountAtEnd      = dt.prp_skipRowBottom;

            for (i = skipRowCountAtBegining; i <= rows.Count - 1 - skipRowCountAtEnd; i++)
            {
                if (dt.prp_skipRowIndecies != null && dt.prp_skipRowIndecies.Any(o => o == i))
                {
                    continue;
                }
                var cells = rows[i].SelectNodes("td");
                dr = dt.Rows[i - skipRowCountAtBegining];
                var queryStringCollection = HttpUtility.ParseQueryString(cells[editColIndex].ChildNodes[0].Attributes["href"].Value.Split('?')[1]);

                if (queryStringCollection != null && !Functions.IsNull(queryStringCollection["psid"]))
                {
                    dr[wagonPartsGroupsDataTable.fld_psid] = queryStringCollection["psid"];
                }
                //dt.Rows.Add(dr);
            }
        }
        public static void sb_readAndSaveToDatatable(IWebDriver webBrowser, string url, string tableId, Model.htmlTable dt
                                                     , bool logoutAndLogin)
        {
            login lg = new login();

            if (logoutAndLogin)
            {
                lg.fnc_logoutWithSelenium(webBrowser);
            }
            if (login.fnc_isLoginPage(webBrowser.Url, url))
            {
                lg.fnc_loginWithSelenium(webBrowser);
                webBrowser.Navigate().GoToUrl(url);
            }

            if (webBrowser.Url.ToLower() != url.ToLower())
            {
                webBrowser.Navigate().GoToUrl(url);
                SharedFunctions.sb_waitForReady(webBrowser);
            }

            string html = webBrowser.PageSource;

            if (!string.IsNullOrEmpty(html))
            {
                Functions.sb_fillDatatableWithHtmlTableId(html, tableId, dt);
            }
        }
Example #4
0
 public webpageGrid(ChromeDriver webbrowser, webpage page, string name, string alias, By controlBy
                    , enumControlType controlType, Model.htmlTable tableSource)
     : this(webbrowser, page, name, alias, controlBy, "", controlType, tableSource)
 {
     this.prp_tableSource = tableSource;
 }
        public webpageWagonRepairInfo(string url) : base(url)
        {
            Model.htmlTable tableRepairContractor = new Model.htmlTable("rwmmsRepairContractors", 1, 0, null, new string[] { "contractorName" });
            tableRepairContractor.Columns.Add(new Model.htmlColumn("contractorName", typeof(string), null, null, "text", "alternateNames", Model.htmlColumn.enum_controlType.input));
            tableRepairContractor.Columns.Add(new Model.htmlColumn("contractorId", typeof(string), null, null, "value", null, Model.htmlColumn.enum_controlType.input));

            this.prp_controls = new List <webpageControl>();
            this.prp_controls.Add(new webpageCombo(this.v_webBrowser, this, "repairContractor", "پیمانکار تعمیرات", By.Id("ContentPlaceHolder1_repCombo_DropDown")
                                                   , "", enumControlType.combo, tableRepairContractor));

            Model.htmlTable tableRepairRegions = new Model.htmlTable("rwmmsRepairRegions", 1, 0, null, new string[] { "regionName" });
            tableRepairRegions.Columns.Add(new Model.htmlColumn("regionName", typeof(string), null, null, "text", "alternateNames", Model.htmlColumn.enum_controlType.input));
            tableRepairRegions.Columns.Add(new Model.htmlColumn("regeionId", typeof(string), null, null, "value", null, Model.htmlColumn.enum_controlType.input));
            this.prp_controls.Add(new webpageCombo(this.v_webBrowser, this, "repairRegion", "ناحیه تعمیراتی", By.Id("ContentPlaceHolder1_regCombo_cmbRegion")
                                                   , "", enumControlType.combo, tableRepairRegions));

            Model.htmlTable tableRepairTypes = new Model.htmlTable("rwmmsRepairTypes", 1, 0, null, new string[] { "typeName" });
            tableRepairTypes.Columns.Add(new Model.htmlColumn("typeName", typeof(string), null, null, "text", "alternateNames", Model.htmlColumn.enum_controlType.input));
            tableRepairTypes.Columns.Add(new Model.htmlColumn("typeId", typeof(string), null, null, "value", null, Model.htmlColumn.enum_controlType.input));
            this.prp_controls.Add(new webpageCombo(this.v_webBrowser, this, "repairType", "نوع تعمیر", By.Id("ContentPlaceHolder1_cboRepairKind")
                                                   , "", enumControlType.combo, tableRepairTypes));

            Model.htmlTable tableRepairControllers = new Model.htmlTable("rwmmsRepairControllers", 1, 0, null, new string[] { "ControllerName" });
            tableRepairControllers.Columns.Add(new Model.htmlColumn("controllerName", typeof(string), null, null, "text", "alternateNames", Model.htmlColumn.enum_controlType.input));
            tableRepairControllers.Columns.Add(new Model.htmlColumn("controllerId", typeof(string), null, null, "value", null, Model.htmlColumn.enum_controlType.input));
            this.prp_controls.Add(new webpageCombo(this.v_webBrowser, this, "repairController", "شرکت بازرسی", By.Id("ContentPlaceHolder1_cboController_DropDown")
                                                   , "", enumControlType.combo, tableRepairControllers));

            Model.htmlTable tableRepairDelayTypes = new Model.htmlTable("rwmmsRepairDelayTypes", 1, 0, null, new string[] { "typeName" });
            tableRepairDelayTypes.Columns.Add(new Model.htmlColumn("typeName", typeof(string), null, null, "text", "alternateNames", Model.htmlColumn.enum_controlType.input));
            tableRepairDelayTypes.Columns.Add(new Model.htmlColumn("typeId", typeof(string), null, null, "value", null, Model.htmlColumn.enum_controlType.input));
            this.prp_controls.Add(new webpageCombo(this.v_webBrowser, this, "repairDelayTypes", "نوع تاخیر", By.Id("ContentPlaceHolder1_cboDelayReason")
                                                   , "", enumControlType.combo, tableRepairDelayTypes));

            Model.htmlTable tableVehicleOwners = new Model.htmlTable("rwmmsVehicleOwners", 1, 0, null, new string[] { "CompanyName" });
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("CompanyName", typeof(string), null, null, "text", "alternateNames", Model.htmlColumn.enum_controlType.input));
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("wCompanyId", typeof(string), null, null, "value", null, Model.htmlColumn.enum_controlType.input));
            this.prp_controls.Add(new webpageCombo(this.v_webBrowser, this, "rwmmsVehicleOwner", "مالک واگن", By.Id("ContentPlaceHolder1_cboOwner_DropDown")
                                                   , "", enumControlType.combo, tableVehicleOwners));

            Model.htmlTable tableRepairs = new Model.htmlTable("rwmmsRepairs", 1, 1, null, new string[] { "wagonNo" });
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("WagonNo", typeof(string), 1, null, "text", null, Model.htmlColumn.enum_controlType.gridCell));
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("dateEntrance", typeof(string), 2, null, "text", null, Model.htmlColumn.enum_controlType.gridCell));
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("dateExit", typeof(string), 3, null, "text", null, Model.htmlColumn.enum_controlType.gridCell));
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("datePlan", typeof(string), 4, null, "text", null, Model.htmlColumn.enum_controlType.gridCell));
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("dateOwnerRepair", typeof(string), 5, null, "text", null, Model.htmlColumn.enum_controlType.gridCell));
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("dateStencil", typeof(string), 6, null, "text", null, Model.htmlColumn.enum_controlType.gridCell));
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("repairType", typeof(string), 7, null, "text", null, Model.htmlColumn.enum_controlType.gridCell));
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("repairArea", typeof(string), 8, null, "text", null, Model.htmlColumn.enum_controlType.gridCell));
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("contractorName", typeof(string), 9, null, "text", null, Model.htmlColumn.enum_controlType.gridCell));
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("controllerName", typeof(string), 10, null, "text", null, Model.htmlColumn.enum_controlType.gridCell));
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("confirmRaja", typeof(string), 11, null, "text", null, Model.htmlColumn.enum_controlType.gridCell));
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("confirmArea", typeof(string), 12, null, "text", null, Model.htmlColumn.enum_controlType.gridCell));
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("confirmOwner", typeof(string), 13, null, "text", null, Model.htmlColumn.enum_controlType.gridCell));
            tableVehicleOwners.Columns.Add(new Model.htmlColumn("confirmContractor", typeof(string), 14, null, "text", null, Model.htmlColumn.enum_controlType.gridCell));

            //this.prp_controls.Add(new webpageGrid(this.v_webBrowser, "ContentPlaceHolder1_dgWagonRepair", "اطلاعات تعمیرات", "ContentPlaceHolder1_dgWagonRepair", enumControlType.grid, tableRepairs));
            //this.prp_controls.Add(new webpageButton("btnSearch", "جستجو", "ContentPlaceHolder1_cmdSearch", null, enumControlType.button));

            //this.prp_controls.Add(new webpageGrid("ContentPlaceHolder1_dgWagonRepair", null, enumControlType.grid));
        }