public declerationList()
        {
            this.v_downloadPath = Environment.CurrentDirectory + "\\Files\\rwmms\\decleration\\";
            this.v_dt           = new declerationListDataTable();

            this.v_webBrowserService = ChromeDriverService.CreateDefaultService();
            this.v_webBrowserService.HideCommandPromptWindow = true;

            this.v_webBrowserOptions = new ChromeOptions();
            this.v_webBrowserOptions.AddArgument("--headless");
            this.v_webBrowserOptions.AddUserProfilePreference("download.default_directory", this.v_downloadPath);
            this.v_webBrowser = new ChromeDriver(this.v_webBrowserService, this.v_webBrowserOptions);

            this.v_pageCount = seleniumDownloader.fnc_getPageCountWithRowCount(this.v_webBrowser, this.v_url, this.v_spanPageRowCountId, this.v_buttonSearchId, true);
        }
        private void sb_saveToDB(declerationListDataTable dt, int cycleNumber, int pageIndex, string ownerName, string typeName
                                 , bool getDetail, bool getAttachment)
        {
            if (dt == null)
            {
                return;
            }
            int  i;
            bool add;
            long wagonNo;

            Model.rwmmsDeclerationList entry_declerationList;
            using (var entityLogistic = new Model.logisticEntities())
            {
                for (i = 0; i <= dt.Rows.Count - 1; i++)
                {
                    add = false;
                    if (!Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_wagonNo]))
                    {
                        wagonNo = long.Parse(dt.Rows[i][declerationListDataTable.fld_wagonNo].ToString());
                        entry_declerationList = entityLogistic.rwmmsDeclerationLists.FirstOrDefault(o => o.wWagonNo == wagonNo &&
                                                                                                    o.wOwnerName == ownerName && o.wTypeName == typeName);
                        if (entry_declerationList == null)
                        {
                            add = true;
                            entry_declerationList = new Model.rwmmsDeclerationList();
                        }
                    }
                    else
                    {
                        entry_declerationList = new Model.rwmmsDeclerationList();
                        add = true;
                    }

                    entry_declerationList.CycleNumber    = cycleNumber;
                    entry_declerationList.FetchTime      = DateTime.Now;
                    entry_declerationList.PageIndex      = pageIndex;
                    entry_declerationList.Source         = this.v_url;
                    entry_declerationList.vehicleOwnerId = Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_ownerName]) ? null : vehicleOwners.Fnc_getVehicleOwnerId(dt.Rows[i][declerationListDataTable.fld_ownerName].ToString());
                    entry_declerationList.wDeclerationNo = Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_declerationNo]) ? null : dt.Rows[i][declerationListDataTable.fld_declerationNo].ToString();

                    entry_declerationList.wOwnerName = Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_ownerName]) ? null : dt.Rows[i][declerationListDataTable.fld_ownerName].ToString();
                    entry_declerationList.wOwnerRepresentativeName = Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_ownerRepresentativeName]) ? null : dt.Rows[i][declerationListDataTable.fld_ownerRepresentativeName].ToString();
                    entry_declerationList.wRowNo    = Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_rowNo]) ? null : (int?)int.Parse(dt.Rows[i][declerationListDataTable.fld_rowNo].ToString());
                    entry_declerationList.wStatus   = Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_status]) ? null : dt.Rows[i][declerationListDataTable.fld_status].ToString();
                    entry_declerationList.wWagonNo  = Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_wagonNo]) ? null : (long?)long.Parse(dt.Rows[i][declerationListDataTable.fld_wagonNo].ToString());
                    entry_declerationList.wTypeName = Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_typeName]) ? null : dt.Rows[i][declerationListDataTable.fld_typeName].ToString();

                    if (getDetail)
                    {
                        entry_declerationList.issueDate = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_issueDate]) ? null : (DateTime?)Functions.solarToMiladi(dt.Rows[i][declerationListDataTable.fld_issueDate].ToString()));
                        entry_declerationList.wConfirmEdareBazargani            = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmEdareBazargani]) ? null : (bool?)(dt.Rows[i][declerationListDataTable.fld_confirmEdareBazargani]));
                        entry_declerationList.wConfirmEdareBazarganiDescription = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmEdareBazargani]) ? null : dt.Rows[i][declerationListDataTable.fld_confirmEdareBazarganiDescription].ToString());
                        entry_declerationList.wConfirmEdareSeir            = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmEdareSeir]) ? null : (bool?)(dt.Rows[i][declerationListDataTable.fld_confirmEdareSeir]));
                        entry_declerationList.wConfirmEdareSeirDescription = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmEdareSeirDescription]) ? null : dt.Rows[i][declerationListDataTable.fld_confirmEdareSeirDescription].ToString());

                        entry_declerationList.wConfirmEdareWagon            = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmEdareWagon]) ? null : (bool?)(dt.Rows[i][declerationListDataTable.fld_confirmEdareWagon]));
                        entry_declerationList.wConfirmEdareWagonDescription = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmEdareWagonDescription]) ? null : dt.Rows[i][declerationListDataTable.fld_confirmEdareWagonDescription].ToString());

                        entry_declerationList.wConfirmFinal            = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmFinal]) ? null : (bool?)(dt.Rows[i][declerationListDataTable.fld_confirmFinal]));
                        entry_declerationList.wConfirmFinalDescription = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmFinalDescription]) ? null : dt.Rows[i][declerationListDataTable.fld_confirmFinalDescription].ToString());

                        entry_declerationList.wConfirmHoghoghi            = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmHoghoghi]) ? null : (bool?)(dt.Rows[i][declerationListDataTable.fld_confirmHoghoghi]));
                        entry_declerationList.wConfirmHoghoghiDescription = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmHoghoghi]) ? null : dt.Rows[i][declerationListDataTable.fld_confirmHoghoghiDescription].ToString());

                        entry_declerationList.wConfirmMali            = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmMali]) ? null : (bool?)(dt.Rows[i][declerationListDataTable.fld_confirmMali]));
                        entry_declerationList.wConfirmMaliDescription = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmMaliDescription]) ? null : dt.Rows[i][declerationListDataTable.fld_confirmMaliDescription].ToString());

                        entry_declerationList.wConfirmOwner            = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmOwner]) ? null : (bool?)(dt.Rows[i][declerationListDataTable.fld_confirmOwner]));
                        entry_declerationList.wConfirmOwnerDescription = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmOwnerDescription]) ? null : dt.Rows[i][declerationListDataTable.fld_confirmOwnerDescription].ToString());

                        entry_declerationList.wConfirmSarmaye            = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmSarmaye]) ? null : (bool?)(dt.Rows[i][declerationListDataTable.fld_confirmSarmaye]));
                        entry_declerationList.wConfirmSarmayeDescription = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmSarmayeDescription]) ? null : dt.Rows[i][declerationListDataTable.fld_confirmSarmayeDescription].ToString());

                        entry_declerationList.wConfirmTajhiz            = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmTajhiz]) ? null : (bool?)(dt.Rows[i][declerationListDataTable.fld_confirmTajhiz]));
                        entry_declerationList.wConfirmTajhizDescription = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_confirmTajhizDescription]) ? null : dt.Rows[i][declerationListDataTable.fld_confirmTajhizDescription].ToString());

                        entry_declerationList.wIssueDate      = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_issueDate]) ? null : dt.Rows[i][declerationListDataTable.fld_issueDate].ToString());
                        entry_declerationList.wNoteNo         = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_noteNo]) ? null : dt.Rows[i][declerationListDataTable.fld_noteNo].ToString());
                        entry_declerationList.wOtherRights    = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_otherRights]) ? null : dt.Rows[i][declerationListDataTable.fld_otherRights].ToString());
                        entry_declerationList.wOwnerDocuments = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_ownerDocuments]) ? null : dt.Rows[i][declerationListDataTable.fld_ownerDocuments].ToString());
                        entry_declerationList.wPageNo         = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_pageNo]) ? null : dt.Rows[i][declerationListDataTable.fld_pageNo].ToString());
                        entry_declerationList.wRegisterNo     = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_registerNo]) ? null : dt.Rows[i][declerationListDataTable.fld_registerNo].ToString());
                    }

                    if (getAttachment)
                    {
                        entry_declerationList.wAttachmentPath = (Functions.IsNull(dt.Rows[i][declerationListDataTable.fld_attachmentPath]) ? null : dt.Rows[i][declerationListDataTable.fld_attachmentPath].ToString());
                    }
                    if (add)
                    {
                        entityLogistic.rwmmsDeclerationLists.Add(entry_declerationList);
                    }
                    else
                    {
                        entityLogistic.Entry(entry_declerationList).State = System.Data.Entity.EntityState.Modified;
                    }
                    entityLogistic.SaveChanges();

                    PWS0.trainBarryWagons.fnc_saveWagonFromRWMMS(dt, i);
                }
            }
        }