public static bool fnc_saveWagonFromRWMMS(rwmms.declerationListDataTable dt, int rowIndex) { if (dt == null) { throw new Exception("dt is null"); } if (rowIndex < 0 || rowIndex >= dt.Rows.Count) { throw new Exception("rowIndex " + rowIndex + " is outofbound"); } DataRow dr = dt.Rows[rowIndex]; long wagonNo = long.Parse(dr[rwmms.declerationListDataTable.fld_wagonNo].ToString()); try { using (var entityLogistic = new Model.logisticEntities()) { bool add = false; var entryWagon = entityLogistic.Wagons.FirstOrDefault(o => o.wagonNo == wagonNo); if (entryWagon == null) { add = true; entryWagon = new Model.Wagon(); } //entryWagon.capacity ; entryWagon.companyId = Functions.IsNull(dr[rwmms.declerationListDataTable.fld_ownerName]) ? null : rwmms.vehicleOwners.Fnc_getVehicleOwnerId(dr[rwmms.declerationListDataTable.fld_ownerName].ToString()); entryWagon.wagonNo = wagonNo; entryWagon.wagonTypeId = Functions.IsNull(dr[rwmms.declerationListDataTable.fld_wagonTypeName]) ? null : trainBarryWagons.fnc_getWagonTypeName(dr[rwmms.declerationListDataTable.fld_wagonTypeName].ToString(), true, true); entryWagon.wrAxisCount = Functions.IsNull(dr[rwmms.declerationListDataTable.fld_wagonAxisCount]) ? null : (int?)int.Parse(dr[rwmms.declerationListDataTable.fld_wagonAxisCount].ToString()); entryWagon.wrBoogieType = Functions.IsNull(dr[rwmms.declerationListDataTable.fld_wagonBoogieType]) ? null : dr[rwmms.declerationListDataTable.fld_wagonBoogieType].ToString(); entryWagon.wrBrakeType = Functions.IsNull(dr[rwmms.declerationListDataTable.fld_wagonBrakeType]) ? null : dr[rwmms.declerationListDataTable.fld_wagonBrakeType].ToString(); entryWagon.wrCapacity = Functions.IsNull(dr[rwmms.declerationListDataTable.fld_wagonCapacity]) ? null : (double?)double.Parse(dr[rwmms.declerationListDataTable.fld_wagonCapacity].ToString()); entryWagon.wrChassisSerial = Functions.IsNull(dr[rwmms.declerationListDataTable.fld_wagonChassisSerialNo]) ? null : dr[rwmms.declerationListDataTable.fld_wagonChassisSerialNo].ToString(); entryWagon.wrCompanyManufacturer = Functions.IsNull(dr[rwmms.declerationListDataTable.fld_wagonCompanyManufacturer]) ? null : dr[rwmms.declerationListDataTable.fld_wagonCompanyManufacturer].ToString(); entryWagon.wrCountry = Functions.IsNull(dr[rwmms.declerationListDataTable.fld_wagonCountry]) ? null : dr[rwmms.declerationListDataTable.fld_wagonCountry].ToString(); entryWagon.wrHookType = Functions.IsNull(dr[rwmms.declerationListDataTable.fld_wagonHookType]) ? null : dr[rwmms.declerationListDataTable.fld_wagonHookType].ToString(); entryWagon.wrNetWeight = Functions.IsNull(dr[rwmms.declerationListDataTable.fld_wagonNetWeight]) ? null : (double?)double.Parse(dr[rwmms.declerationListDataTable.fld_wagonNetWeight].ToString()); entryWagon.wrProductionYear = Functions.IsNull(dr[rwmms.declerationListDataTable.fld_wagonProductionYear]) ? null : (int?)int.Parse(dr[rwmms.declerationListDataTable.fld_wagonProductionYear].ToString()); entryWagon.wrRivNo = Functions.IsNull(dr[rwmms.declerationListDataTable.fld_wagonRIVNo]) ? null : dr[rwmms.declerationListDataTable.fld_wagonRIVNo].ToString(); entryWagon.wrWagonTypeName = Functions.IsNull(dr[rwmms.declerationListDataTable.fld_wagonTypeName]) ? null : dr[rwmms.declerationListDataTable.fld_wagonTypeName].ToString(); if (add) { entityLogistic.Wagons.Add(entryWagon); } else { entityLogistic.Entry(entryWagon).State = EntityState.Modified; } entityLogistic.SaveChanges(); } return(true); } catch (Exception ex) { return(false); } }
private void sb_saveGroupsToDB(wagonPartsGroupsDataTable dt, int?idGroupParent) { if (dt == null) { return; } int i; bool add; string groupName; Model.rwmmsWagonPartsGroup entry_wagonPartsGroup; using (var entityLogistic = new Model.logisticEntities()) { for (i = 0; i <= dt.Rows.Count - 1; i++) { add = false; if (Functions.IsNull(dt.Rows[i][wagonPartsGroupsDataTable.fld_groupName])) { continue; } groupName = dt.Rows[i][wagonPartsGroupsDataTable.fld_groupName].ToString(); entry_wagonPartsGroup = entityLogistic.rwmmsWagonPartsGroups.FirstOrDefault(o => o.IdGroupParent == idGroupParent && o.wGroupName == groupName); if (entry_wagonPartsGroup == null) { add = true; entry_wagonPartsGroup = new Model.rwmmsWagonPartsGroup(); } entry_wagonPartsGroup.FetchTime = DateTime.Now; entry_wagonPartsGroup.IdGroupParent = idGroupParent; entry_wagonPartsGroup.wGroupName = Functions.IsNull(dt.Rows[i][wagonPartsGroupsDataTable.fld_groupName]) ? null : dt.Rows[i][wagonPartsGroupsDataTable.fld_groupName].ToString(); entry_wagonPartsGroup.wPSID = Functions.IsNull(dt.Rows[i][wagonPartsGroupsDataTable.fld_psid]) ? null : dt.Rows[i][wagonPartsGroupsDataTable.fld_psid].ToString(); entry_wagonPartsGroup.wSerialNo = Functions.IsNull(dt.Rows[i][wagonPartsGroupsDataTable.fld_serialNo]) ? null : dt.Rows[i][wagonPartsGroupsDataTable.fld_serialNo].ToString().Replace(" ", "").Replace("\r\n", ""); if (add) { entityLogistic.rwmmsWagonPartsGroups.Add(entry_wagonPartsGroup); } else { entityLogistic.Entry(entry_wagonPartsGroup).State = System.Data.Entity.EntityState.Modified; } try { entityLogistic.SaveChanges(); dt.Rows[i][wagonPartsGroupsDataTable.fld_id] = entry_wagonPartsGroup.Id; } catch (Exception ex) { } } } }
private void sb_saveOwnersDetailsToDB(DataTable dt, int cycleNumber) { if (dt == null) { return; } int i; Model.rwmmsVehicleOwnersDetail entry_vehicleOwnersDetail; bool add; string meliNo; using (var entityLogistic = new Model.logisticEntities()) { for (i = 0; i <= dt.Rows.Count - 1; i++) { add = false; if (!Functions.IsNull(dt.Rows[i][vehicleOwnersDetailDataTable.fld_meliNo])) { meliNo = dt.Rows[i][vehicleOwnersDetailDataTable.fld_meliNo].ToString(); entry_vehicleOwnersDetail = entityLogistic.rwmmsVehicleOwnersDetails.FirstOrDefault(o => o.wMeliNo == meliNo); if (entry_vehicleOwnersDetail == null) { add = true; entry_vehicleOwnersDetail = new Model.rwmmsVehicleOwnersDetail(); } } else { entry_vehicleOwnersDetail = new Model.rwmmsVehicleOwnersDetail(); add = true; } //entry_vehicleOwnersDetail.companyId = companyId; entry_vehicleOwnersDetail.CycleNumber = cycleNumber; entry_vehicleOwnersDetail.FetchTime = DateTime.Now; entry_vehicleOwnersDetail.Source = "rwmms"; entry_vehicleOwnersDetail.wEmail = Functions.IsNull(dt.Rows[i][vehicleOwnersDetailDataTable.fld_email]) ? null : dt.Rows[i][vehicleOwnersDetailDataTable.fld_email].ToString(); entry_vehicleOwnersDetail.wFName = Functions.IsNull(dt.Rows[i][vehicleOwnersDetailDataTable.fld_fname]) ? null : dt.Rows[i][vehicleOwnersDetailDataTable.fld_fname].ToString(); entry_vehicleOwnersDetail.wLName = Functions.IsNull(dt.Rows[i][vehicleOwnersDetailDataTable.fld_lname]) ? null : dt.Rows[i][vehicleOwnersDetailDataTable.fld_lname].ToString(); entry_vehicleOwnersDetail.wMeliNo = Functions.IsNull(dt.Rows[i][vehicleOwnersDetailDataTable.fld_meliNo]) ? null : dt.Rows[i][vehicleOwnersDetailDataTable.fld_meliNo].ToString(); entry_vehicleOwnersDetail.wMobileNumber = Functions.IsNull(dt.Rows[i][vehicleOwnersDetailDataTable.fld_mobileNumber]) ? null : dt.Rows[i][vehicleOwnersDetailDataTable.fld_mobileNumber].ToString(); if (add) { entityLogistic.rwmmsVehicleOwnersDetails.Add(entry_vehicleOwnersDetail); } else { entityLogistic.Entry(entry_vehicleOwnersDetail).State = System.Data.Entity.EntityState.Modified; } entityLogistic.SaveChanges(); } } }
private void sb_readExtraDetailAndSaveToDB(int cycleNumber, int pageIndex) { int rowIndex = 1; string htmlEditPage; nextRecord : pageIndex = this.fnc_gotoPage(pageIndex, true); if (pageIndex == -1) { return; } var table = this.v_webBrowser.FindElementById(v_tableId); if (table != null) { var rows = table.FindElements(By.TagName("tr")); if (rows != null && rows.Count > 0 && rowIndex <= rows.Count - 2) {//first and last row are header and footer using (var entityLogistic = new Model.logisticEntities()) { var columns = rows[rowIndex].FindElements(By.TagName("td")); if (columns.Count >= 6) { var href = columns[6].FindElement(By.TagName("a")); if (href != null) { href.Click(); SharedFunctions.sb_waitForReady(this.v_webBrowser); htmlEditPage = this.v_webBrowser.PageSource; string firstName = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtFirstName"); string lastName = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtLastName"); string fatherName = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtFatherName"); string certNo = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtIdentityNumber"); string registerCity = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtIdentityRegisterLocation"); string meliNo = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtNationalCode"); string postalCode = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtAgentPostCode"); string email = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtAgentEmail"); string mobileNumber = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtMobileNumber"); string birthDate = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtBirthDate"); string address = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtAgentAddress"); if (!string.IsNullOrEmpty(meliNo)) { var entryOwnerExtraDetail = entityLogistic.rwmmsVehicleOwnersDetails.FirstOrDefault(o => o.wMeliNo == meliNo); if (entryOwnerExtraDetail != null) { //entryOwnerExtraDetail.companyId entryOwnerExtraDetail.CycleNumber = cycleNumber; entryOwnerExtraDetail.FetchTime = DateTime.Now; entryOwnerExtraDetail.Source = "http://rwmms.rai.ir/VehicleOwnerDetailInfo.aspx"; entryOwnerExtraDetail.wAddress = (Functions.IsNull(address) ? null : address); entryOwnerExtraDetail.wBirthDate = (Functions.IsNull(birthDate) ? null : birthDate); entryOwnerExtraDetail.wCertNo = (Functions.IsNull(certNo) ? null : certNo); entryOwnerExtraDetail.wEmail = (Functions.IsNull(email) ? null : email); entryOwnerExtraDetail.wFatherName = (Functions.IsNull(fatherName) ? null : fatherName); entryOwnerExtraDetail.wFName = (Functions.IsNull(firstName) ? null : firstName); entryOwnerExtraDetail.wLName = (Functions.IsNull(lastName) ? null : lastName); entryOwnerExtraDetail.wMeliNo = (Functions.IsNull(meliNo) ? null : meliNo); entryOwnerExtraDetail.wMobileNumber = (Functions.IsNull(mobileNumber) ? null : mobileNumber); entryOwnerExtraDetail.wPostalCode = (Functions.IsNull(postalCode) ? null : postalCode); entryOwnerExtraDetail.wRegisterCity = (Functions.IsNull(registerCity) ? null : registerCity); entityLogistic.Entry(entryOwnerExtraDetail).State = System.Data.Entity.EntityState.Modified; entityLogistic.SaveChanges(); } } rowIndex++; goto nextRecord; } } } } } }
private void sb_savePartsToDB(wagonPartsDataTable dt, int?idGroup) { if (dt == null) { return; } int i; bool add; string partName; Model.rwmmsWagonPart entry_wagonParts; using (var entityLogistic = new Model.logisticEntities()) { for (i = 0; i <= dt.Rows.Count - 1; i++) { add = false; if (!Functions.IsNull(dt.Rows[i][wagonPartsDataTable.fld_partName]) && idGroup.HasValue) { partName = dt.Rows[i][wagonPartsDataTable.fld_partName].ToString(); entry_wagonParts = entityLogistic.rwmmsWagonParts.FirstOrDefault(o => o.IdGroup == idGroup && o.wPartName == partName); if (entry_wagonParts == null) { add = true; entry_wagonParts = new Model.rwmmsWagonPart(); } } else { entry_wagonParts = new Model.rwmmsWagonPart(); } entry_wagonParts.FetchTime = DateTime.Now; entry_wagonParts.IdGroup = idGroup; entry_wagonParts.wCountInGroup = Functions.IsNull(dt.Rows[i][wagonPartsDataTable.fld_countInGroup]) ? null : (int?)int.Parse(dt.Rows[i][wagonPartsDataTable.fld_countInGroup].ToString()); entry_wagonParts.wCountInWagon = Functions.IsNull(dt.Rows[i][wagonPartsDataTable.fld_countInWagon]) ? null : (int?)int.Parse(dt.Rows[i][wagonPartsDataTable.fld_countInWagon].ToString()); entry_wagonParts.wMapNumber = Functions.IsNull(dt.Rows[i][wagonPartsDataTable.fld_mapNumber]) ? null : dt.Rows[i][wagonPartsDataTable.fld_mapNumber].ToString(); entry_wagonParts.wMapPic1Path = Functions.IsNull(dt.Rows[i][wagonPartsDataTable.fld_mapPic1Path]) ? null : dt.Rows[i][wagonPartsDataTable.fld_mapPic1Path].ToString(); entry_wagonParts.wMapPic2Path = Functions.IsNull(dt.Rows[i][wagonPartsDataTable.fld_mapPic2Path]) ? null : dt.Rows[i][wagonPartsDataTable.fld_mapPic2Path].ToString(); entry_wagonParts.wMapPic3Path = Functions.IsNull(dt.Rows[i][wagonPartsDataTable.fld_mapPic3Path]) ? null : dt.Rows[i][wagonPartsDataTable.fld_mapPic3Path].ToString(); entry_wagonParts.wMapPic4Path = Functions.IsNull(dt.Rows[i][wagonPartsDataTable.fld_mapPic4Path]) ? null : dt.Rows[i][wagonPartsDataTable.fld_mapPic4Path].ToString(); entry_wagonParts.wMapPicPath = Functions.IsNull(dt.Rows[i][wagonPartsDataTable.fld_mapPicPath]) ? null : dt.Rows[i][wagonPartsDataTable.fld_mapPicPath].ToString(); entry_wagonParts.wPartName = Functions.IsNull(dt.Rows[i][wagonPartsDataTable.fld_partName]) ? null : dt.Rows[i][wagonPartsDataTable.fld_partName].ToString(); entry_wagonParts.wPartNameLatin = Functions.IsNull(dt.Rows[i][wagonPartsDataTable.fld_partNameLatin]) ? null : dt.Rows[i][wagonPartsDataTable.fld_partNameLatin].ToString(); entry_wagonParts.wWeight = Functions.IsNull(dt.Rows[i][wagonPartsDataTable.fld_weight]) ? null : (decimal?)decimal.Parse(dt.Rows[i][wagonPartsDataTable.fld_weight].ToString()); if (add) { entityLogistic.rwmmsWagonParts.Add(entry_wagonParts); } else { entityLogistic.Entry(entry_wagonParts).State = System.Data.Entity.EntityState.Modified; } try { entityLogistic.SaveChanges(); } catch (Exception ex) { } } } }
private void sb_saveToDB(DataTable dt, int cycleNumber, string introductionFilePath, out Model.rwmmsVehicleOwner entry_vehicleOwner) { entry_vehicleOwner = null; if (dt == null) { return; } int i; //Model.rwmmsVehicleOwner entry_company; bool add; string companyName; using (var entityLogistic = new Model.logisticEntities()) { for (i = 0; i <= dt.Rows.Count - 1; i++) { add = false; if (Functions.IsNull(dt.Rows[i][vehicleOwnersDataTable.fld_companyName])) { continue; } companyName = dt.Rows[i][vehicleOwnersDataTable.fld_companyName].ToString(); var ownerId = Fnc_getVehicleOwnerId(companyName); if (!ownerId.HasValue) { add = true; entry_vehicleOwner = new Model.rwmmsVehicleOwner(); } else { entry_vehicleOwner = entityLogistic.rwmmsVehicleOwners.FirstOrDefault(o => o.Id == ownerId); } //if (entry_vehicleOwner == null) //{ // add = true; // entry_vehicleOwner = new Model.rwmmsVehicleOwner(); //} //entry_company.AlternateNames = //entry_company.companyName = entry_vehicleOwner.CycleNumber = cycleNumber; //entry_company.Description entry_vehicleOwner.FetchTime = DateTime.Now; //entry_company.PostalCode entry_vehicleOwner.registerDate = Functions.IsNull(dt.Rows[i][vehicleOwnersDataTable.fld_registerPersianDate]) ? null : (DateTime?)Functions.solarToMiladi(dt.Rows[i][vehicleOwnersDataTable.fld_registerPersianDate].ToString()); //entry_company.ShenaseMeli= entry_vehicleOwner.Source = "rwmms"; entry_vehicleOwner.wCompanyName = companyName; entry_vehicleOwner.wIntroductionFile = Functions.IsNull(introductionFilePath) ? null : introductionFilePath; entry_vehicleOwner.wRegisterCityName = Functions.IsNull(dt.Rows[i][vehicleOwnersDataTable.fld_registerCityName]) ? null : dt.Rows[i][vehicleOwnersDataTable.fld_registerCityName].ToString(); entry_vehicleOwner.wRegisterNo = Functions.IsNull(dt.Rows[i][vehicleOwnersDataTable.fld_registerNo]) ? null : dt.Rows[i][vehicleOwnersDataTable.fld_registerNo].ToString(); entry_vehicleOwner.wRegsiterPersianDate = Functions.IsNull(dt.Rows[i][vehicleOwnersDataTable.fld_registerPersianDate]) ? null : dt.Rows[i][vehicleOwnersDataTable.fld_registerPersianDate].ToString(); if (add) { entityLogistic.rwmmsVehicleOwners.Add(entry_vehicleOwner); } else { entityLogistic.Entry(entry_vehicleOwner).State = System.Data.Entity.EntityState.Modified; } entityLogistic.SaveChanges(); //companyId = entry_company.Id; } } }
public void sb_readAndSaveToDB(bool getOwners, bool getIntroductionFiles, int cycleNumber) { try { int i; login lg = new login(); start: if (login.v_cookieCollection == null) { if (!lg.fnc_login()) { //cannot login return; } } Uri uri; Model.rwmmsVehicleOwner entry_company; uri = new Uri(this.v_url); string postData; string introductionFilePath; HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(uri); //webRequest.Headers.Add("Accept-Language", "en-US,en;q=0.8"); webRequest.Proxy = null; webRequest.Method = "POST"; //webRequest.Headers.Add("Cache-Control", "no-cache"); webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.CookieContainer = new CookieContainer(); foreach (System.Net.Cookie cookie in login.v_cookieCollection) { webRequest.CookieContainer.Add(cookie); } postData = "__EVENTTARGET=" + "&__EVENTARGUMENT=" + "&__VIEWSTATE=19gB2KPXunfoY1KhdzKAuxbd%2FOoFmZ3EhsltmoK2s2VkBDy6lwwZr7rC25jXm%2BQIJEpBZnx2gjOlf8C0mpGh%2FkEaSfPTf9k%2BqaLrna5Oyeq%2BPbp9AU6oxxViHFeoRwvzEz%2FawXFACHm5L3aqOHniXVtwr%2FH5EgML96nGzzM6ycEhi56B%2B56Lt2045a%2Fy%2F0fOAXo3c2qy%2F6Wb4tWlH3WHViqY2XkJT12CIxTRoupHoPcVNeYbLMPR1Y99aYAbNkYtCCiLd263Z725l8153%2FwQDh%2FUWvjAaBNxS7%2B%2BhI9TKl0ZrVavHXtuNi6HKNeAJ8j0Q6%2BwQG60HDkYtTdaZbmNeGwhHgNf7XZqnwNuUsJFFd7nYZeKQWTSL%2FvIQXrK2n2X1eX0S1EjWzxUR8VcRu7IrjsIJYcEVYvpSoDfAKSO0qpL6cuCFXcP5rGqxKJNN8a0oJomJ%2FlQnaOAJPl%2BMDV0q%2BRltsfZuYbrOXeT%2FZv78ssfhb8tNygoaE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0bvdyW0AipjMV%2BbZYvHjsRXo8ewuRvvnPeTKaupWsPFJXZsZs7H2Qi92pFFkr%2BGeFDWaHnQ50Vm3KAHn2Fl7HX6Ch9sgw57SUz4jDowNyaSYZBx3vKB%2BLmy1DY%2B8iueprOqM0mbn9Zpgfh23%2BvFR3%2FBaqrDUx9xk34l4Bt7RJPvAzvmLsesA8aGrwT7npF2N0bTN4y5uOQpQWX3BpbhNJi1VuM%2F7PlN5apaEXnSQUVUrwnZKd3bw5h4eF0BLUYlli1XmK%2BdCj3MwSsWF%2Fl9YS03wCvKvU2oeWyv%2Fyd49t7BJupZWp1YyXb6OpUb9HQxeHb7xg6YNHDuiMkJYmsLQB0IZMp%2FUYM%2BoBpl2wbq1AvK4c0Q1KEaMK" + "&ctl00%24ContentPlaceHolder1%24txtRegisterDate=" + "&ctl00%24ContentPlaceHolder1%24txtRegisterNumber=" + "&ctl00%24ContentPlaceHolder1%24txtNationalCode=" + "&ctl00%24ContentPlaceHolder1%24txtRegisterLocation=" + "&ctl00%24ContentPlaceHolder1%24btnSearch=%D8%AC%D8%B3%D8%AA%D8%AC%D9%88"; byte[] formData = Encoding.ASCII.GetBytes(postData); webRequest.ContentLength = formData.Length; Stream streamRequest = webRequest.GetRequestStream(); streamRequest.Write(formData, 0, formData.Length); streamRequest.Flush(); streamRequest.Close(); HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); if (webResponse != null) { if (webResponse.ResponseUri == null || string.IsNullOrEmpty(webResponse.ResponseUri.AbsoluteUri)) { webResponse.Close(); return; } if (login.fnc_isLoginPage(webResponse, this.v_url)) { //we haven't loginned yet if (lg.fnc_login()) { goto start; } else { //cannot login inform or log !!!!! webResponse.Close(); return; } } string result; using (StreamReader rd = new StreamReader(webResponse.GetResponseStream(), Encoding.GetEncoding("utf-8"))) { result = rd.ReadToEnd(); } webResponse.Close(); if (!string.IsNullOrEmpty(result)) { this.v_dt.Rows.Clear(); Functions.sb_fillDatatableWithHtmlTableId(result, "ContentPlaceHolder1_dgVehicleOwners", 1, 1, 0, 0, this.v_dt); for (i = 0; i <= this.v_dt.Rows.Count - 1; i++) { introductionFilePath = null; this.sb_saveToDB(this.v_dt, cycleNumber, introductionFilePath, out entry_company); if (getIntroductionFiles && entry_company != null) { introductionFilePath = this.fnc_getIntroductionFile(entry_company.Id, entry_company.wCompanyName, i); entry_company.wIntroductionFile = introductionFilePath; using (var entityLogistic = new Model.logisticEntities()) { entityLogistic.Entry(entry_company).State = System.Data.Entity.EntityState.Modified; entityLogistic.SaveChanges(); } } if (getOwners && entry_company != null) { this.sb_readOwnerDetail(entry_company.Id, cycleNumber); //this.readAndSaveOwnerDetailToDB(entry_company.Id, cycleNumber); } } } } } catch (Exception ex) { } }
private void sb_readOwnerDetail(int companyId, int cycleNumber) { login lg = new login(); lg.fnc_loginWithSelenium(this.v_webBrowser); bool add; string tableId = "ContentPlaceHolder1_dgVehicleOwners"; this.v_webBrowser.Navigate().GoToUrl(this.v_url); SharedFunctions.sb_waitForReady(this.v_webBrowser); var btnSearch = this.v_webBrowser.FindElement(By.Id("ContentPlaceHolder1_btnSearch")); if (btnSearch == null) { return; } btnSearch.Click(); SharedFunctions.sb_waitForReady(this.v_webBrowser); var table = this.v_webBrowser.FindElement(By.Id(tableId)); if (table == null) { return; } var rows = table.FindElements(By.TagName("tr")); if (rows == null || rows.Count < 3) { return; } var columns = rows[1].FindElements(By.TagName("td")); if (columns.Count >= 6) { var href = columns[6].FindElement(By.TagName("a")); if (href != null) { href.Click(); SharedFunctions.sb_waitForReady(this.v_webBrowser); table = this.v_webBrowser.FindElement(By.Id("ContentPlaceHolder1_dgVehicleOwnerDetails")); if (table == null) { return; } rows = table.FindElements(By.TagName("tr")); if (rows == null || rows.Count < 3) { return; } columns = rows[1].FindElements(By.TagName("td")); if (columns.Count >= 6) { href = columns[6].FindElement(By.TagName("a")); if (href != null) { href.Click(); //SharedFunctions.sb_waitForReady(this.v_webBrowser); SharedFunctions.sb_waitForReady(this.v_webBrowser); string htmlEditPage = this.v_webBrowser.PageSource; string firstName = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtFirstName"); string lastName = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtLastName"); string fatherName = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtFatherName"); string certNo = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtIdentityNumber"); string registerCity = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtIdentityRegisterLocation"); string meliNo = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtNationalCode"); string postalCode = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtAgentPostCode"); string email = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtAgentEmail"); string mobileNumber = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtMobileNumber"); string birthDate = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtBirthDate"); string address = Functions.fnc_getElementValue(htmlEditPage, "ContentPlaceHolder1_txtAgentAddress"); using (var entityLogistic = new Model.logisticEntities()) { if (!string.IsNullOrEmpty(meliNo)) { add = false; var entryOwnerExtraDetail = entityLogistic.rwmmsVehicleOwnersDetails.FirstOrDefault(o => o.wMeliNo == meliNo); if (entryOwnerExtraDetail == null) { entryOwnerExtraDetail = new Model.rwmmsVehicleOwnersDetail(); add = true; } entryOwnerExtraDetail.CycleNumber = cycleNumber; entryOwnerExtraDetail.FetchTime = DateTime.Now; entryOwnerExtraDetail.Source = this.v_url; entryOwnerExtraDetail.vehicleOwnerId = companyId; entryOwnerExtraDetail.wAddress = (Functions.IsNull(address) ? null : address); entryOwnerExtraDetail.wBirthDate = (Functions.IsNull(birthDate) ? null : birthDate); entryOwnerExtraDetail.wCertNo = (Functions.IsNull(certNo) ? null : certNo); entryOwnerExtraDetail.wEmail = (Functions.IsNull(email) ? null : email); entryOwnerExtraDetail.wFatherName = (Functions.IsNull(fatherName) ? null : fatherName); entryOwnerExtraDetail.wFName = (Functions.IsNull(firstName) ? null : firstName); entryOwnerExtraDetail.wLName = (Functions.IsNull(lastName) ? null : lastName); entryOwnerExtraDetail.wMeliNo = (Functions.IsNull(meliNo) ? null : meliNo); entryOwnerExtraDetail.wMobileNumber = (Functions.IsNull(mobileNumber) ? null : mobileNumber); entryOwnerExtraDetail.wPostalCode = (Functions.IsNull(postalCode) ? null : postalCode); entryOwnerExtraDetail.wRegisterCity = (Functions.IsNull(registerCity) ? null : registerCity); if (add) { entityLogistic.rwmmsVehicleOwnersDetails.Add(entryOwnerExtraDetail); } else { entityLogistic.Entry(entryOwnerExtraDetail).State = System.Data.Entity.EntityState.Modified; } entityLogistic.SaveChanges(); } } } } } } }
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); } } }