/// <summary> /// changed this to private since this need to be called only from within generate range /// </summary> private void GenerateDeadAreas() { //get the service territory IWorkspaceEdit pWorkspaceEdit; pWorkspaceEdit = (IWorkspaceEdit)this._workspace; try { IFeatureWorkspace pFWorkspace = (IFeatureWorkspace)pWorkspaceEdit; // ServiceTerritory mainST = new ServiceTerritory(_workspace, "MAIN"); if (this.ServiceTerritoryFeature != null) { IGeometry pSVGeometry = ServiceTerritoryFeature.Shape; //IGeometry pRecptionGeometry = mainST.getReceptionArea(); //union all the signals and get one big reception area geometry //edit and add to fc IGeometry pDeadArea = getDeadArea(); //pWorkspaceEdit.StartEditing(true); IMultiuserWorkspaceEdit pMUWorkspaceEdit = (IMultiuserWorkspaceEdit)pWorkspaceEdit; pMUWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned); pWorkspaceEdit.StartEditOperation(); double deadCoverage = ((IArea)pDeadArea).Area * 100 / ((IArea)pSVGeometry).Area; double receptionCoverage = 100 - deadCoverage; IFeatureClass pDeadAreasFC = pFWorkspace.OpenFeatureClass("sde.DeadAreas"); //delete all features IFeatureCursor pcursor = pDeadAreasFC.Update(null, false); IFeature pfeaturerange = pcursor.NextFeature(); while (pfeaturerange != null) { //we need to change that later pfeaturerange.Delete(); pfeaturerange = pcursor.NextFeature(); } IFeature pDeadAreaFeature = pDeadAreasFC.CreateFeature(); pDeadAreaFeature.Shape = pDeadArea; pDeadAreaFeature.Store(); pWorkspaceEdit.StopEditOperation(); pWorkspaceEdit.StopEditing(true); updateCoverages(deadCoverage, receptionCoverage); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); pWorkspaceEdit.AbortEditOperation(); } }
public void updateCoverages(double deadCoverage, double receptionCoverage) { IWorkspaceEdit pWorkspaceEdit = null; try { pWorkspaceEdit = (IWorkspaceEdit)((IDataset)ServiceTerritoryFeature.Class).Workspace; IMultiuserWorkspaceEdit pMUWorkspaceEdit = (IMultiuserWorkspaceEdit)pWorkspaceEdit; pMUWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned); //pWorkspaceEdit.StartEditing(true); pWorkspaceEdit.StartEditOperation(); ServiceTerritoryFeature.set_Value(ServiceTerritoryFeature.Fields.FindField("DEADCOVERAGE"), deadCoverage); ServiceTerritoryFeature.set_Value(ServiceTerritoryFeature.Fields.FindField("RECEPTIONCOVERAGE"), receptionCoverage); ServiceTerritoryFeature.Store(); pWorkspaceEdit.StopEditOperation(); pWorkspaceEdit.StopEditing(true); } catch { pWorkspaceEdit.AbortEditOperation(); } }
/// <summary> /// updates the device information /// </summary> public void Store() { IFeatureWorkspace pFWorkspace = (IFeatureWorkspace)_workspace; IWorkspaceEdit pWorkspaceEdit = (IWorkspaceEdit)pFWorkspace; IMultiuserWorkspaceEdit pMUWorkspaceEdit = (IMultiuserWorkspaceEdit)pWorkspaceEdit; pMUWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned); // pWorkspaceEdit.StartEditing(true); pWorkspaceEdit.StartEditOperation(); IFeatureClass pDeviceFC = pFWorkspace.OpenFeatureClass("sde.Device"); IQueryFilter pQFilter = new QueryFilter(); pQFilter.WhereClause = "DEVICEID = '" + DeviceID + "'"; IFeatureCursor pFCursor = pDeviceFC.Search(pQFilter, false); IFeature pDeviceFeature = pFCursor.NextFeature(); if (pDeviceFeature != null) { if (connectedTower != null) { pDeviceFeature.set_Value(pDeviceFeature.Fields.FindField("CONNECTEDTOWERID"), connectedTower.ID); } else { pDeviceFeature.set_Value(pDeviceFeature.Fields.FindField("CONNECTEDTOWERID"), DBNull.Value); } pDeviceFeature.set_Value(pDeviceFeature.Fields.FindField("BARS"), Bars); pDeviceFeature.Shape = DeviceLocation; pDeviceFeature.Store(); } else { IFeature pNewFeature = pDeviceFC.CreateFeature(); pNewFeature.set_Value(pNewFeature.Fields.FindField("DEVICEID"), DeviceID); if (connectedTower != null) { pNewFeature.set_Value(pNewFeature.Fields.FindField("CONNECTEDTOWERID"), connectedTower.ID); } else { pNewFeature.set_Value(pNewFeature.Fields.FindField("CONNECTEDTOWERID"), DBNull.Value); } pNewFeature.set_Value(pNewFeature.Fields.FindField("BARS"), Bars); pNewFeature.Shape = DeviceLocation; pNewFeature.Store(); } pWorkspaceEdit.StopEditOperation(); pWorkspaceEdit.StopEditing(true); }
public override void StartEditing(bool versioned) { IMultiuserWorkspaceEdit workspaceEdit = GetEditingWorkspace; if (versioned && workspaceEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMVersioned)) { workspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned); } else if (!versioned && workspaceEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMNonVersioned)) { workspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMNonVersioned); } else { throw new WorkspaceEditHandlerException("Não é possível inicar uma edição multi-usuário."); } }
public bool StartEditing(IWorkspace TheWorkspace, bool IsUnversioned) // Start EditSession + create EditOperation { bool IsFileBasedGDB = (!(TheWorkspace.WorkspaceFactory.WorkspaceType == esriWorkspaceType.esriRemoteDatabaseWorkspace)); IWorkspaceEdit pWSEdit = (IWorkspaceEdit)TheWorkspace; if (pWSEdit.IsBeingEdited()) { MessageBox.Show("The workspace is being edited by another process."); return(false); } if (!IsFileBasedGDB) { IMultiuserWorkspaceEdit pMUWSEdit = (IMultiuserWorkspaceEdit)TheWorkspace; try { if (pMUWSEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMNonVersioned) && IsUnversioned) { pMUWSEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMNonVersioned); } else if (pMUWSEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMVersioned) && !IsUnversioned) { pMUWSEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned); } else { return(false); } } catch (COMException ex) { MessageBox.Show(ex.Message + " " + Convert.ToString(ex.ErrorCode), "Start Editing"); return(false); } } else { try { pWSEdit.StartEditing(false); } catch (COMException ex) { MessageBox.Show(ex.Message + " " + Convert.ToString(ex.ErrorCode), "Start Editing"); return(false); } } pWSEdit.DisableUndoRedo(); try { pWSEdit.StartEditOperation(); } catch { pWSEdit.StopEditing(false); return(false); } return(true); }
/// <summary> /// Generate the tower coverage /// </summary> public void GenerateReceptionArea() { IWorkspaceEdit pWorkspaceEdit; pWorkspaceEdit = (IWorkspaceEdit)this._workspace; try { //get all towers in this service territory Towers pTowers = GetTowers(); IFeatureWorkspace pFWorkspace = (IFeatureWorkspace)pWorkspaceEdit; IFeatureClass pTowerRangeFC = pFWorkspace.OpenFeatureClass("sde.TowerRange"); IMultiuserWorkspaceEdit pMUWorkspaceEdit = (IMultiuserWorkspaceEdit)pWorkspaceEdit; pMUWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned); // pWorkspaceEdit.StartEditing(true); pWorkspaceEdit.StartEditOperation(); //delete all ranges , we should later change that to delete only dirty towers IFeatureCursor pcursor = pTowerRangeFC.Update(null, false); IFeature pfeaturerange = pcursor.NextFeature(); while (pfeaturerange != null) { //we need to change that later pfeaturerange.Delete(); pfeaturerange = pcursor.NextFeature(); } foreach (Tower pTower in pTowers.Items) { ITopologicalOperator pTopo = (ITopologicalOperator)pTower.TowerLocation; IPolygon range3Bars = (IPolygon)pTopo.Buffer(pTower.TowerCoverage / 3); IPolygon range2BarsWhole = (IPolygon)pTopo.Buffer((pTower.TowerCoverage * 2) / 3); IPolygon range1BarsWhole = (IPolygon)pTopo.Buffer(pTower.TowerCoverage); ITopologicalOperator pIntTopo = (ITopologicalOperator)range2BarsWhole; ITopologicalOperator pIntTopo1 = (ITopologicalOperator)range1BarsWhole; IPolygon range2BarsDonut = (IPolygon)pIntTopo.SymmetricDifference(range3Bars); //,esriGeometryDimension.esriGeometry2Dimension); IPolygon range1BarsDonut = (IPolygon)pIntTopo1.SymmetricDifference(range2BarsWhole); //,esriGeometryDimension.esriGeometry2Dimension); IFeature pFeature = pTowerRangeFC.CreateFeature(); pFeature.set_Value(pFeature.Fields.FindField("TOWERID"), pTower.ID); pFeature.set_Value(pFeature.Fields.FindField("RANGE"), 3); pFeature.Shape = range3Bars; pFeature.Store(); IFeature pFeature2Bar = pTowerRangeFC.CreateFeature(); pFeature2Bar.set_Value(pFeature.Fields.FindField("TOWERID"), pTower.ID); pFeature2Bar.set_Value(pFeature.Fields.FindField("RANGE"), 2); pFeature2Bar.Shape = range2BarsDonut; pFeature2Bar.Store(); IFeature pFeature1Bar = pTowerRangeFC.CreateFeature(); pFeature1Bar.set_Value(pFeature1Bar.Fields.FindField("TOWERID"), pTower.ID); pFeature1Bar.set_Value(pFeature1Bar.Fields.FindField("RANGE"), 1); pFeature1Bar.Shape = range1BarsDonut; pFeature1Bar.Store(); } pWorkspaceEdit.StopEditOperation(); pWorkspaceEdit.StopEditing(true); //generate dead areas GenerateDeadAreas(); } catch (Exception ex) { //if anything went wrong, just roll back pWorkspaceEdit.AbortEditOperation(); System.Windows.Forms.MessageBox.Show(ex.ToString()); } }
public void UpdateAssetsTest() { RuntimeManager.Bind(ProductCode.Desktop); (new AoInitializeClass()).Initialize(esriLicenseProductCode.esriLicenseProductCodeStandard); IPropertySet propertySet = new PropertySetClass(); propertySet.SetProperty("Server", "RJMSDDBT02"); propertySet.SetProperty("Instance", "sde:oracle11g:gisdevl"); propertySet.SetProperty("Database", "GISDEVL"); propertySet.SetProperty("user", "MSD"); propertySet.SetProperty("password", "jc_tc1954"); propertySet.SetProperty("version", "MSD.QC"); int flag = 0; try { IWorkspace workspaceName = (new SdeWorkspaceFactoryClass()).Open(propertySet, 0); IVersionedWorkspace versionedWorkspace = (IVersionedWorkspace)workspaceName; IEnumVersionInfo enumVersionInfo = versionedWorkspace.Versions; enumVersionInfo.Reset(); IVersionInfo existversionInfo = enumVersionInfo.Next(); while (existversionInfo != null) { if (!existversionInfo.VersionName.Trim().Equals("MSD.DTS_EDIT")) { existversionInfo = enumVersionInfo.Next(); } else { versionedWorkspace.FindVersion("MSD.DTS_EDIT").Delete(); flag = 1; break; } } enumVersionInfo.Reset(); IVersion version = (IVersion)((IFeatureWorkspace)workspaceName); string name = version.VersionInfo.VersionName; IVersion dtsVersion = version.CreateVersion("DTS_EDIT"); dtsVersion.Access = esriVersionAccess.esriVersionAccessPublic; dtsVersion.Description = "Update DTS to MSD Ownership via DTS app"; if (dtsVersion.VersionName.Contains("DTS_EDIT")) { IMultiuserWorkspaceEdit multiuserWorkspaceEdit = (IMultiuserWorkspaceEdit)dtsVersion; IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)dtsVersion; IVersionEdit4 versionEdit = (IVersionEdit4)workspaceEdit; if (multiuserWorkspaceEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMVersioned)) { multiuserWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned); versionEdit.Reconcile4("MSD.QC", true, false, false, false); workspaceEdit.StartEditOperation(); IFeature featureEdit = ((IFeatureWorkspace)workspaceEdit).OpenFeatureClass("SWRAINGAUGE").GetFeature(330); // Convert.ToString(featureEdit[6]); Convert.ToString(featureEdit.Value[6]); int Totalfield = featureEdit.Fields.FieldCount; int ownershipindex = featureEdit.Fields.FindField("OWNERSHIP"); int lastmodifieddtindex = featureEdit.Fields.FindField("LAST_MODIFIED_DATE"); DateTime lastmodifieddt = DateTime.Now.Date; //featureEdit[ownershipindex] = "1"; //featureEdit[lastmodifieddtindex] = lastmodifieddt.Date; featureEdit.Value[ownershipindex] = "1"; featureEdit.Value[lastmodifieddtindex] = lastmodifieddt.Date; featureEdit.Store(); if (versionEdit.CanPost()) { versionEdit.Post("MSD.QC"); } workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(true); } } } catch (COMException cOMException) { if (cOMException.ErrorCode == -2147217147) { } } catch (Exception exception) { } }
public int UpdateAssets(List <AssetModified> assetModifieds) { int num; this.dtStartTime = DateTime.Now; Assets.logger.Debug(string.Concat("UpdateAssets start at ", this.dtStartTime.ToString())); IPropertySet propertySet = Assets.GetPropertySet(); int counter = 0; try { IWorkspace workspaceName = (new SdeWorkspaceFactoryClass()).Open(propertySet, 0); IVersionedWorkspace versionedWorkspace = (IVersionedWorkspace)workspaceName; IEnumVersionInfo enumVersionInfo = versionedWorkspace.Versions; enumVersionInfo.Reset(); IVersionInfo existversionInfo = enumVersionInfo.Next(); while (existversionInfo != null) { if (!existversionInfo.VersionName.Trim().Equals("MSD.DTS_EDIT")) { existversionInfo = enumVersionInfo.Next(); } else { versionedWorkspace.FindVersion("MSD.DTS_EDIT").Delete(); break; } } enumVersionInfo.Reset(); IVersion version = (IVersion)((IFeatureWorkspace)workspaceName); string name = version.VersionInfo.VersionName; IVersion dtsVersion = version.CreateVersion("DTS_EDIT"); dtsVersion.Access = esriVersionAccess.esriVersionAccessPublic; dtsVersion.Description = "Update DTS to MSD Ownership via DTS app"; if (dtsVersion.VersionName.Contains("DTS_EDIT")) { IMultiuserWorkspaceEdit multiuserWorkspaceEdit = (IMultiuserWorkspaceEdit)dtsVersion; IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)dtsVersion; IVersionEdit4 versionEdit = (IVersionEdit4)workspaceEdit; if (multiuserWorkspaceEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMVersioned)) { multiuserWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned); versionEdit.Reconcile4("MSD.QC", true, false, false, false); workspaceEdit.StartEditOperation(); ILog log = Assets.logger; DateTime now = DateTime.Now; log.Debug(string.Concat("GetUpdateAssets start at ", now.ToString())); counter = Assets.GetUpdateAssets(assetModifieds, counter, workspaceEdit); ILog log1 = Assets.logger; now = DateTime.Now; log1.Debug(string.Concat("GetUpdateAssets end at ", now.ToString())); if (versionEdit.CanPost()) { versionEdit.Post("MSD.QC"); } workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(true); } } this.dtEndTime = DateTime.Now; this.tsDiff = this.dtEndTime.Subtract(this.dtStartTime); this.dlTimeDiff = this.tsDiff.TotalMilliseconds; Assets.logger.Debug(string.Concat("UpdateAssets end at ", this.dtStartTime.ToString(), " Total diff : ", this.dlTimeDiff.ToString())); num = counter; } catch (COMException cOMException) { COMException ex = cOMException; Assets.logger.Debug(string.Concat("Error from UpdateAssets : ", ex.Message, " ", ex.StackTrace)); throw ex; } catch (Exception exception) { Exception ex = exception; Assets.logger.Debug(string.Concat("Error from UpdateAssets : ", ex.Message, " ", ex.StackTrace)); throw ex; } return(num); }
public SDETable(ITable table, IWorkspace workspace) { _table = table; _workspace = workspace; _workspaceEdit = (IWorkspaceEdit)_workspace; multiWspEdit = (IMultiuserWorkspaceEdit)_workspace; }
public void Calculate(List<object> newId) { #region tinh gia dat //cachtinhdongia = "[giadatduong] * [hesodatsxkd]"; //cachtinhdongia = "DonGiaSxkdMattienDt(Multiply([giadatduong],[hesodatsxkd]))"; //cachtinhdongia = "DonGiaOcoNnMattienDt([giadatduong])"; //cachtinhdongia = "DonGiaOcoSxkdMattienDt([giadatduong])"; //cachtinh="[giadatduong] * [dientich]"; //cachtinh = "GiaDatSxkdMattienDt([giadatduong] * [hesodatsxkd] * [dientich])"; //cachtinh = "DonGiaOcoNnMattienDt(Multiply([giadatduong],[giadatnongnghiep]))"; #region khoi tao cac bien SdeConnection conn = new SdeConnection(); ISdeConnectionInfo sdeConn = conn as ISdeConnectionInfo; _wspEdit = (IWorkspaceEdit)sdeConn.Workspace; _mwspEdit = (IMultiuserWorkspaceEdit)sdeConn.Workspace; IFeatureWorkspace fw = (IFeatureWorkspace)sdeConn.Workspace; copyTool = new DataManager(sdeConn.Workspace, sdeConn.Environment); this._fcName = new TnFeatureClassName(sdeConn.Workspace); this._tblName = new TnTableName(sdeConn.Workspace); string tgdDraft = string.Format("{0}_{1}", DataNameTemplate.Thua_Gia_Dat_Draft, this._currentConfig.NamApDung); string gdd = string.Format("{0}_{1}", DataNameTemplate.Gia_Dat_Duong, this._currentConfig.NamApDung); string gdhem = string.Format("{0}_{1}", DataNameTemplate.Gia_Hem, this._currentConfig.NamApDung); string gdhemPhu = string.Format("{0}_{1}", DataNameTemplate.Gia_Hem_Phu, this._currentConfig.NamApDung); string thuaName = string.Format("{0}_{1}", DataNameTemplate.Thua, this._currentConfig.NamApDung); string gdNnName=string.Format("{0}_{1}", DataNameTemplate.Gia_Dat_Nongnghiep, this._currentConfig.NamApDung); string gdPnnNtName = string.Format("{0}_{1}", DataNameTemplate.Gia_Dat_Pnn_Nongthon, this._currentConfig.NamApDung); _fcName.FC_THUA.NAME = thuaName; _fcName.FC_THUA.InitIndex(); _fcName.FC_THUA_GIADAT_DRAFT.NAME = tgdDraft; _fcName.FC_THUA_GIADAT_DRAFT.InitIndex(); _tblName.GIA_DAT_DUONG.NAME = gdd; _tblName.GIA_DAT_DUONG.InitIndex(); _fcName.FC_GIA_DAT_HEM.NAME = gdhem; _fcName.FC_GIA_DAT_HEM.InitIndex(); _fcName.FC_GIA_DAT_HEM_PHU.NAME = gdhemPhu; _fcName.FC_GIA_DAT_HEM_PHU.InitIndex(); _tblName.GIA_DAT_NONGNGHIEP.NAME = gdNnName; _tblName.GIA_DAT_NONGNGHIEP.InitIndex(); _tblName.GIA_DAT_O_NONGTHON.NAME = gdPnnNtName; _tblName.GIA_DAT_O_NONGTHON.InitIndex(); IFeatureClass tgdDraftFeatureClass = null; try { tgdDraftFeatureClass = fw.OpenFeatureClass(tgdDraft); } catch { MessageBox.Show("Không tìm thấy bảng " + tgdDraft); return; } IFeatureClass fcGiaDatHem = null; try { fcGiaDatHem = fw.OpenFeatureClass(gdhem); } catch { MessageBox.Show("Không tìm thấy bảng " + gdhem); } IFeatureClass fcGiaDatHemPhu = null; try { fcGiaDatHemPhu = fw.OpenFeatureClass(gdhemPhu); } catch { MessageBox.Show("Không tìm thấy bảng " + gdhemPhu); } ITable tblLoaiDat; ITable tblThuaGiaDatDraft; ITable tblGiaDatDuong; ITable tblHesoVitri; ITable tblTenDuong; ITable tblGiaDatNn; ITable tblGiaDatPnnNt; IFeatureClass fcThua; IFeatureClass fcXa; IFeatureClass fcDuong; IFeatureClass fcKtvhxh; IFeatureClass fcHemChinh; #endregion #region dinh nghia cac bien try { fcThua = fw.OpenFeatureClass(thuaName); } catch { MessageBox.Show("Không tìm thấy bảng " + thuaName); return; } try { tblTenDuong = fw.OpenTable(DataNameTemplate.Ten_Duong); } catch(Exception ex) { MessageBox.Show("Không tìm thấy bảng " + DataNameTemplate.Ten_Duong); return; } try { tblLoaiDat = fw.OpenTable(DataNameTemplate.Loai_Dat); tblThuaGiaDatDraft = (ITable)tgdDraftFeatureClass; //tblThuaGiaDat = fw.OpenTable(_fcName.FC_THUA_GIADAT.NAME); tblGiaDatDuong = fw.OpenTable(gdd); tblHesoVitri = fw.OpenTable(DataNameTemplate.He_So_K); } catch { MessageBox.Show("Không tìm thấy bảng " + tgdDraft); return; } try { tblGiaDatNn = fw.OpenTable(gdNnName); } catch (Exception ex) { MessageBox.Show("Không tìm thấy bảng " + gdNnName); return; } try { tblGiaDatPnnNt = fw.OpenTable(gdPnnNtName); } catch (Exception ex) { MessageBox.Show("Không tìm thấy bảng " + gdPnnNtName); return; } try { fcXa = fw.OpenFeatureClass(DataNameTemplate.Ranh_Xa_Poly); } catch { MessageBox.Show("Không tìm thấy bảng " + DataNameTemplate.Ranh_Xa_Poly); return; } try { fcHemChinh = fw.OpenFeatureClass(DataNameTemplate.Hem); } catch { MessageBox.Show("Không tìm thấy bảng " + DataNameTemplate.Hem); return; } ISDETableEditor sdeTblTgdEditor = new SDETable(tblThuaGiaDatDraft, sdeConn.Workspace); IQueryFilter qrf = new QueryFilterClass(); #endregion string paramTableName = DataNameTemplate.Thong_So + "_" + _currentConfig.NamApDung; ITable paramTable = fw.OpenTable(paramTableName); Dictionary<string, object> pars4TinhGia = new Dictionary<string, object>(); Dictionary<string, object> pars4TinhDonGia = new Dictionary<string, object>(); IQueryFilter q = new QueryFilterClass(); q.WhereClause = ""; ICursor parCursor = paramTable.Search(q, false); IRow parRow = null; try { while ((parRow = parCursor.NextRow()) != null) { string parName = parRow.get_Value(parRow.Fields.FindField(_tblName.THONG_SO.TEN_THONG_SO)).ToString(); object parVal = parRow.get_Value(parRow.Fields.FindField(_tblName.THONG_SO.GIA_TRI)); try { pars4TinhGia.Add(parName, parVal); pars4TinhDonGia.Add(parName, parVal); } catch (Exception ex) { continue; } } } catch (Exception) { } finally { Marshal.ReleaseComObject(parCursor); } pars4TinhGia.Add(ExpressionParameters.GiaDatDuong, 0); pars4TinhGia.Add(ExpressionParameters.DienTichPl, 0); pars4TinhGia.Add(ExpressionParameters.GiaDatNn,0); pars4TinhGia.Add(ExpressionParameters.GiaDatONT, 0); pars4TinhGia.Add(ExpressionParameters.GiaDatHemChinh, 0); pars4TinhGia.Add(ExpressionParameters.GiaDatHemPhu, 0); pars4TinhDonGia.Add(ExpressionParameters.GiaDatDuong,0); pars4TinhDonGia.Add(ExpressionParameters.GiaDatNn,0); pars4TinhDonGia.Add(ExpressionParameters.GiaDatONT, 0); pars4TinhDonGia.Add(ExpressionParameters.GiaDatHemChinh, 0); pars4TinhDonGia.Add(ExpressionParameters.GiaDatHemPhu, 0); #region vong lap tung id #region khoi dau int rowTgdNnHandleUpdate = 0; string cachtinh=""; string cachtinhdongia = ""; bool result = false; List<object[,]> pairColValTgd = new List<object[,]>(); CalculationEventArg evt = new CalculationEventArg(); if (_caller != null) { evt.Reset(); evt.Log = "\n\nBắt đầu tính giá cho các thửa vừa xác định vị trí"; _caller.onCalculating(evt); } int len = newId.Count; int thuaCount = 1; //MessageBox.Show(len.ToString()); #endregion foreach (object o in newId) { #region lay thong tin thua gia dat IRow tgdRowNew = tblThuaGiaDatDraft.GetRow((int)o); string mathuaNew = tgdRowNew.get_Value(tgdRowNew.Fields.FindField(_fcName.FC_THUA_GIADAT_DRAFT.MA_THUA)).ToString(); string maduongNew = tgdRowNew.get_Value(tgdRowNew.Fields.FindField(_fcName.FC_THUA_GIADAT_DRAFT.MA_DUONG)).ToString(); string hesovitriNew = tgdRowNew.get_Value(tgdRowNew.Fields.FindField(_fcName.FC_THUA_GIADAT_DRAFT.HE_SO_K)).ToString(); object dientich = tgdRowNew.get_Value(tgdRowNew.Fields.FindField(_fcName.FC_THUA_GIADAT_DRAFT.DIEN_TICH)); object dientichpl = tgdRowNew.get_Value(tgdRowNew.Fields.FindField(_fcName.FC_THUA_GIADAT_DRAFT.DIEN_TICH_PHAP_LY)); object khoagia = tgdRowNew.get_Value(tgdRowNew.Fields.FindField(_fcName.FC_THUA_GIADAT_DRAFT.LOCKED)); object mahem=tgdRowNew.get_Value(tgdRowNew.Fields.FindField(_fcName.FC_THUA_GIADAT_DRAFT.MA_HEM)); object dorongHem=0; object tenHem = ""; //MessageBox.Show("line 237 CalcLandprice, maduong=" + maduongNew); if (khoagia != null) { if (khoagia.ToString() != "0" && khoagia.ToString()!="") { //MessageBox.Show(khoagia.ToString()); if (_caller != null) { evt.Reset(); evt.IdThuaKhoaGia = o; evt.mathua = mathuaNew; _caller.onCalculating(evt); } continue; } } #endregion #region lay cach tinh qrf.WhereClause = string.Format("{0}='{1}'", "hesovitri", hesovitriNew); ICursor curNew = tblHesoVitri.Search(qrf, false); try { IRow rowNew = curNew.NextRow(); if (rowNew != null) { cachtinh = rowNew.get_Value(_tblName.HESO_VITRI.GetIndex(_tblName.HESO_VITRI.CACH_TINH)).ToString(); cachtinhdongia = rowNew.get_Value(_tblName.HESO_VITRI.GetIndex(_tblName.HESO_VITRI.CACH_TINH_DON_GIA)).ToString(); //MessageBox.Show("line 262 CalcLandprice, cachtinhdongia=" + cachtinhdongia); } } catch (COMException comExc) { } finally { Marshal.ReleaseComObject(curNew); } Evaluation evalTinhGia = new Evaluation(cachtinh); Evaluation evalTinhDonGia = new Evaluation(cachtinhdongia); Evaluation evalCachtinh = new Evaluation(cachtinhdongia); #endregion #region lay gia dat duong //MessageBox.Show("line 365 maduong=" + maduongNew); qrf.WhereClause = string.Format("{0}='{1}'", _tblName.GIA_DAT_DUONG.MA_DUONG, maduongNew); ICursor gdDuongCur = null; gdDuongCur = tblGiaDatDuong.Search(qrf, false); IRow gdDuongRow = null; double giaduong = 0; try { if ((gdDuongRow = gdDuongCur.NextRow()) != null) { result = double.TryParse(gdDuongRow.get_Value(_tblName.GIA_DAT_DUONG.GetIndex(_tblName.GIA_DAT_DUONG.GIA_DAT)).ToString(), out giaduong); if (!result) { giaduong = 0; } //MessageBox.Show("line 292 CalcLandprice, giaduong=" + giaduong.ToString()); } } catch (COMException comExc) { } finally { Marshal.ReleaseComObject(gdDuongCur); } #endregion #region lay ten duong qrf.WhereClause = string.Format("{0}='{1}'", _tblName.TEN_DUONG.MA_DUONG, maduongNew); ICursor tenDuongCur = null; tenDuongCur = tblTenDuong.Search(qrf, false); IRow tenDuongRow = null; object tenduong = ""; object batdau = ""; object ketthuc = ""; try { if ((tenDuongRow = tenDuongCur.NextRow()) != null) { tenduong = tenDuongRow.get_Value(_tblName.TEN_DUONG.GetIndex(_tblName.TEN_DUONG.TEN_DUONG)); batdau = tenDuongRow.get_Value(_tblName.TEN_DUONG.GetIndex(_tblName.TEN_DUONG.BAT_DAU)); ketthuc = tenDuongRow.get_Value(_tblName.TEN_DUONG.GetIndex(_tblName.TEN_DUONG.KET_THUC)); } } catch (COMException comExc) { giaduong = 0; } finally { Marshal.ReleaseComObject(tenDuongCur); } #endregion #region lay loai dat, loai xa qrf.WhereClause = string.Format("{0}='{1}'", _fcName.FC_THUA.MA_THUA, mathuaNew); IFeatureCursor thuaCur = null; thuaCur = fcThua.Search(qrf, false); IFeature thuaFt = null; object loaidat = ""; object maxa = ""; try { if ((thuaFt = thuaCur.NextFeature()) != null) { loaidat = thuaFt.get_Value(_fcName.FC_THUA.GetIndex(_fcName.FC_THUA.LOAI_DAT)); maxa = thuaFt.get_Value(_fcName.FC_THUA.GetIndex(_fcName.FC_THUA.MA_XA)); } #region kiem tra co dat nong nghiep foreach (string s in TnLoaiDats.NONG_NGHIEP) { if (loaidat.ToString().Contains(s)) { _loaidatNn = s; break; } else { _loaidatNn = ""; } } #endregion } catch (COMException comExc) { } finally { Marshal.ReleaseComObject(thuaCur); } #endregion //danh cho thua co dat nong nghiep #region lay ma xa va gia dat nong nghiep object loaixa = ""; object giadatNnDeGhi = 0; object giadatNnDeTinh = 0; int loaiDoThi = 0; object loaiDatNnDeTinh = ""; string nnStart = hesovitriNew.Substring(0, 1); string nnEnd = hesovitriNew.Substring(hesovitriNew.Length - 1, 1); object giadatPnnNt = 0; double giahem = 0; double giahemPhu = 0; if (nnStart=="5" || nnStart=="2"|| nnStart=="1") { qrf.WhereClause = string.Format("{0}='{1}'", _fcName.FC_RANH_XA_POLY.MA_XA, maxa); IFeatureCursor xaFcr = fcXa.Search(qrf, false); IFeature xaFt = null; try { if ((xaFt = xaFcr.NextFeature()) != null) { loaixa = xaFt.get_Value(xaFt.Fields.FindField(_fcName.FC_RANH_XA_POLY.MA_LOAI_XA)); result = int.TryParse(xaFt.get_Value(xaFt.Fields.FindField(_fcName.FC_RANH_XA_POLY.MA_LOAI_XA)).ToString(), out loaiDoThi); } } catch (Exception ex) { loaixa = ""; } finally { Marshal.ReleaseComObject(xaFcr); } if (loaixa != "") { #region neu la dat o nong thon if (nnStart == "2") { object vitriPnn; object khuvucPnn; getVitriPnnNt(hesovitriNew, out vitriPnn, out khuvucPnn); qrf.WhereClause = string.Format("{0}='{1}' and {2}='{3}' and {4}='{5}'", _tblName.GIA_DAT_O_NONGTHON.MA_LOAI_XA, loaixa, _tblName.GIA_DAT_O_NONGTHON.VI_TRI, vitriPnn, _tblName.GIA_DAT_O_NONGTHON.MA_KHU_VUC, khuvucPnn); //MessageBox.Show("line 471 CalcLandprice, qrf=" + qrf.WhereClause); ICursor gdPnnCur = tblGiaDatPnnNt.Search(qrf, false); IRow gdPnnRow = null; try { if ((gdPnnRow = gdPnnCur.NextRow()) != null) { giadatPnnNt = gdPnnRow.get_Value(gdPnnRow.Fields.FindField(_tblName.GIA_DAT_O_NONGTHON.GIA_DAT)); } else { giadatPnnNt = 0; } //MessageBox.Show("line 484 CalcLandprice, giadat=" + giadatPnnNt); } catch (Exception ex) { giadatPnnNt = 0; } finally { Marshal.ReleaseComObject(gdPnnCur); } } #endregion #region neu co dat nong nghiep if (nnStart == "5" || (nnStart == "2" && nnEnd == "2") || nnStart == "1") { loaiDatNnDeTinh = _loaidatNn; object vitriNn = getVitriNongNghiep(hesovitriNew); if (loaiDoThi != 0) { vitriNn = 1; loaiDatNnDeTinh = "LNQ"; } qrf.WhereClause = string.Format("{0}='{1}' and {2}='{3}' and {4}='{5}'", _tblName.GIA_DAT_NONGNGHIEP.MA_LOAI_DAT, loaiDatNnDeTinh, _tblName.GIA_DAT_NONGNGHIEP.MA_LOAI_XA, loaixa, _tblName.GIA_DAT_NONGNGHIEP.VI_TRI, vitriNn); ICursor gdNnCur = tblGiaDatNn.Search(qrf, false); IRow gdNnRow = null; try { if ((gdNnRow = gdNnCur.NextRow()) != null) { giadatNnDeGhi = gdNnRow.get_Value(gdNnRow.Fields.FindField(_tblName.GIA_DAT_NONGNGHIEP.GIA_DAT)); } else { giadatNnDeGhi = 0; } } catch (Exception ex) { giadatNnDeGhi = 0; } finally { Marshal.ReleaseComObject(gdNnCur); } //MessageBox.Show(string.Format("line 331 CalcLandprice giadatnndegi={0}", giadatNnDeGhi)); //neu ko phai dat thuan nong nghiep if (nnStart != "1") { if (double.Parse(dientichpl.ToString()) < 200) { giadatNnDeTinh = 0; } else { giadatNnDeTinh = giadatNnDeGhi; } } else { giadatNnDeTinh = giadatNnDeGhi; } } #endregion } //lay gia dat nn o vi tri theo quy dinh (vt3) //qrf.WhereClause=string.Format("{0}='{1}' and {2}='{3}'",_tblName.GIA_DAT_NONGNGHIEP.MA_LOAI_DAT,_loaidatNn,_tblName.GIA_DAT_NONGNGHIEP.MA_LOAI_XA,) } #endregion if (mahem != null) { #region lay thong tin hem //MessageBox.Show("line 567 CalcLandprice, mahem=" + mahem); if (mahem.ToString() != "0" && mahem.ToString() != "") { qrf.WhereClause = string.Format("{0}='{1}'", _fcName.FC_HEM.MA_HEM, mahem); IFeatureCursor hemFcur = fcHemChinh.Search(qrf, false); IFeature hemFt = null; int maHemChinh = 0; try { if ((hemFt = hemFcur.NextFeature()) != null) { dorongHem = hemFt.get_Value(hemFt.Fields.FindField(_fcName.FC_HEM.DO_RONG)); tenHem = hemFt.get_Value(hemFt.Fields.FindField(_fcName.FC_HEM.TEN_HEM)); maduongNew = hemFt.get_Value(hemFt.Fields.FindField(_fcName.FC_HEM.MA_DUONG)).ToString(); result = int.TryParse(hemFt.get_Value(hemFt.Fields.FindField(_fcName.FC_HEM.HEM_CHINH)).ToString(), out maHemChinh); if (!result) { maHemChinh = 0; } //MessageBox.Show("line 586 CalcLandprice,mahemchinh=" + maHemChinh); } } catch (Exception ex) { //MessageBox.Show("line 566 CalcLandprice, ex=" + ex.ToString()); } finally { Marshal.ReleaseComObject(hemFcur); } #region lay gia dat hem chinh string hsvitriHem = getHesoHem(hesovitriNew); //MessageBox.Show("line 597 hsvitrihem=" + hsvitriHem); if (hsvitriHem == "0") { continue; } if (maHemChinh == 0) { qrf.WhereClause = string.Format("{0}='{1}' and {2}='{3}'", _fcName.FC_GIA_DAT_HEM.MA_HEM, mahem, _fcName.FC_GIA_DAT_HEM.HE_SO, hsvitriHem); //MessageBox.Show("line 603 CalcLandprice, qrf=" + qrf.WhereClause); IFeatureCursor gdHemCur = null; gdHemCur = fcGiaDatHem.Search(qrf, false); IFeature gdHemRow = null; //MessageBox.Show("line 588 CalcLandprice, giaHem=" + _fcName.FC_GIA_DAT_HEM.GetIndex(_fcName.FC_GIA_DAT_HEM.GIA_DAT)); try { if ((gdHemRow = gdHemCur.NextFeature()) != null) { result = double.TryParse(gdHemRow.get_Value(_fcName.FC_GIA_DAT_HEM.GetIndex(_fcName.FC_GIA_DAT_HEM.GIA_DAT)).ToString(), out giahem); if (!result) { giahem = 0; } //MessageBox.Show("line 588 CalcLandprice, giaHem=" + giahem.ToString()); } } catch (COMException comExc) { //MessageBox.Show("line 593 CalcLandprice comexc=" + comExc.ToString()); } finally { Marshal.ReleaseComObject(gdHemCur); } } #endregion #region lay gia hem phu else { qrf.WhereClause = string.Format("{0}='{1}' and {2}='{3}'", _fcName.FC_GIA_DAT_HEM_PHU.MA_HEM, mahem, _fcName.FC_GIA_DAT_HEM_PHU.HE_SO, hsvitriHem); //MessageBox.Show("line 632 CalcLandprice, qrf=" + qrf.WhereClause); IFeatureCursor gdHemPhuCur = null; gdHemPhuCur = fcGiaDatHemPhu.Search(qrf, false); IFeature gdHemPhuRow = null; //MessageBox.Show("line 588 CalcLandprice, giaHem=" + _fcName.FC_GIA_DAT_HEM.GetIndex(_fcName.FC_GIA_DAT_HEM.GIA_DAT)); try { if ((gdHemPhuRow = gdHemPhuCur.NextFeature()) != null) { result = double.TryParse(gdHemPhuRow.get_Value(_fcName.FC_GIA_DAT_HEM_PHU.GetIndex(_fcName.FC_GIA_DAT_HEM_PHU.GIA_DAT)).ToString(), out giahemPhu); if (!result) { giahemPhu = 0; } //MessageBox.Show("line 646 CalcLandprice, giaHemPhu=" + giahemPhu.ToString()); } } catch (COMException comExc) { //MessageBox.Show("line 593 CalcLandprice comexc=" + comExc.ToString()); } finally { Marshal.ReleaseComObject(gdHemPhuCur); } } #endregion #region lay gia duong tu lop gia hem qrf.WhereClause = string.Format("{0}='{1}'", _tblName.GIA_DAT_DUONG.MA_DUONG, maduongNew); gdDuongCur = null; gdDuongCur = tblGiaDatDuong.Search(qrf, false); gdDuongRow = null; giaduong = 0; try { if ((gdDuongRow = gdDuongCur.NextRow()) != null) { result = double.TryParse(gdDuongRow.get_Value(_tblName.GIA_DAT_DUONG.GetIndex(_tblName.GIA_DAT_DUONG.GIA_DAT)).ToString(), out giaduong); if (!result) { giaduong = 0; } //MessageBox.Show("line 292 CalcLandprice, giaduong=" + giaduong.ToString()); } } catch (COMException comExc) { } finally { Marshal.ReleaseComObject(gdDuongCur); } #endregion } #endregion } //MessageBox.Show(string.Format("line 346 CalcLandprice giadatnndegi={0}, giadatnndetinh={1}", giadatNnDeGhi, giadatNnDeTinh)); #region lay gia dat o nong thon int intHsk = int.Parse(hesovitriNew); #endregion #region tinh gia //evalTinhGia.Giadatduong = giaduong; //evalTinhGia.Dientich = dientich; //evalTinhGia.Dientichpl = dientichpl; //evalTinhGia.GiadatNn = giadatNnDeTinh; //evalTinhDonGia.Giadatduong = giaduong; //evalTinhDonGia.GiadatNn = giadatNnDeTinh; //Dictionary<string, object> pars = new Dictionary<string, object>(); //MessageBox.Show("line 609 CalcLandprice, giaHem=" + giahem.ToString()); pars4TinhGia[ExpressionParameters.GiaDatDuong] = giaduong; pars4TinhGia[ExpressionParameters.DienTichPl] = dientichpl; pars4TinhGia[ExpressionParameters.GiaDatNn] = giadatNnDeTinh; pars4TinhGia[ExpressionParameters.GiaDatONT] = giadatPnnNt; pars4TinhGia[ExpressionParameters.GiaDatHemChinh] = giahem; pars4TinhGia[ExpressionParameters.GiaDatHemPhu] = giahemPhu; //pars.Add(ExpressionParameters.HeSoDatSxkd, _currentConfig.PGiaDatSxkddt); evalTinhGia.Params = pars4TinhGia; //Dictionary<string, object> pars1 = new Dictionary<string, object>(); //pars1.Add(ExpressionParameters.GiaDatDuong, giaduong); //pars1.Add(ExpressionParameters.GiaDatNn, giadatNnDeTinh); //pars1.Add(ExpressionParameters.HeSoDatSxkd, _currentConfig.PGiaDatSxkddt); pars4TinhDonGia[ExpressionParameters.GiaDatDuong] = giaduong; pars4TinhDonGia[ExpressionParameters.DienTichPl] = dientichpl; pars4TinhDonGia[ExpressionParameters.GiaDatNn] = giadatNnDeTinh; pars4TinhDonGia[ExpressionParameters.GiaDatONT] = giadatPnnNt; pars4TinhDonGia[ExpressionParameters.GiaDatHemChinh] = giahem; pars4TinhDonGia[ExpressionParameters.GiaDatHemPhu] = giahemPhu; evalTinhDonGia.Params = pars4TinhDonGia; object giaMoiTinh = evalTinhGia.EvaluateLandPrice(); object dongiaMoiTinh = evalTinhDonGia.EvaluateLandPrice(); //MessageBox.Show(string.Format("line 660 CalcLandprice dongia={0}", dongiaMoiTinh)); #endregion #region ghi cach tinh _methodBuilder.BatDau = batdau; _methodBuilder.CachTinh = cachtinh; _methodBuilder.CachTinhDonGia = cachtinhdongia; _methodBuilder.GiaDatNN = giadatNnDeGhi; _methodBuilder.GiaDuong = giaduong; _methodBuilder.KetThuc = ketthuc; _methodBuilder.LoaiDat = loaidat; _methodBuilder.TenDuong = tenduong; _methodBuilder.DoRongHem = dorongHem; _methodBuilder.LoaiXa = loaixa; string strCachtinh=_methodBuilder.GetMethodString(hesovitriNew); //evt.Reset(); //evt.Log = string.Format("\n\nĐộ dài cách tính:{0}, cachtinh={1}",strCachtinh.Length,strCachtinh); //_caller.onCalculating(evt); //MessageBox.Show(string.Format("line 241 CalcLandprice {0}, {1}",hesovitriNew,TnHeSoK.DatOMatTienDt)); //if (hesovitriNew == TnHeSoK.DatOMatTienDt.ToString()) //{ // strCachtinh = string.Format("Đất ở đô thị ({0}), mặt tiền đường {1} (giá={2}) đoạn từ {3} đến {4}. Giá đất = {5}", loaidat, tenduong, giaduong, batdau, ketthuc, cachtinhdongia); // //MessageBox.Show(string.Format("line 241 CalcLandprice \n{0}", strCachtinh)); //} //else if (hesovitriNew == TnHeSoK.DatSxkdMatTienDt.ToString()) //{ // strCachtinh = string.Format("Đất sxkd tại đô thị ({0}) (hệ số ={1}), mặt tiền đường {2} (giá={3}) đoạn từ {4} đến {5}. Giá đất = {6}", loaidat, _currentConfig.PGiaDatSxkddt, tenduong,giaduong, batdau, ketthuc, cachtinhdongia); //} //else if (hesovitriNew == TnHeSoK.DatONnMatTien.ToString()) //{ // strCachtinh = string.Format("Đất ở tại đô thị có đất nông nghiệp ({0}) (giá đất nn ={1}), mặt tiền đường {2} (giá={3}) đoạn từ {4} đến {5}. Giá đất = {6}", loaidat, giadatNnDeGhi, tenduong, giaduong, batdau, ketthuc, cachtinhdongia); //} #endregion #region lay cach ghi cach tinh gia //string ct = string.Format(cachtinh); //MessageBox.Show(evalCachtinh.EvaluateMethod().ToString()); #endregion #region luu thong tin gia va cach tinh pairColValTgd.Add(new object[,] { { _fcName.FC_THUA_GIADAT_DRAFT.GetIndex(_fcName.FC_THUA_GIADAT_DRAFT.DON_GIA), dongiaMoiTinh } }); pairColValTgd.Add(new object[,] { { _fcName.FC_THUA_GIADAT_DRAFT.GetIndex(_fcName.FC_THUA_GIADAT_DRAFT.GIA_DAT), giaMoiTinh } }); pairColValTgd.Add(new object[,] { { _fcName.FC_THUA_GIADAT_DRAFT.GetIndex(_fcName.FC_THUA_GIADAT_DRAFT.CACH_TINH), strCachtinh } }); sdeTblTgdEditor.CacheData(o, rowTgdNnHandleUpdate, pairColValTgd, EnumTypeOfEdit.UPDATE); rowTgdNnHandleUpdate++; pairColValTgd.Clear(); #endregion #region ---log if (_caller != null) { evt.Reset(); evt.IdThuaTinhGia = o;// new object[,] { { o, "tui", "soto", "sothua" } }; evt.mathua = mathuaNew; _caller.onCalculating(evt); evt.Reset(); if (thuaCount < len) { if (thuaCount % 10 == 0) { evt.Log = string.Format("\n---Đã tính cho {0} thửa----", thuaCount); } thuaCount++; } else if (thuaCount == len) { evt.Log = string.Format("\n---Đã tính cho {0} thửa---", thuaCount); } _caller.onCalculating(evt); } #endregion } #endregion #region luu thong tin vao bang gia dat if (!sdeTblTgdEditor.IsEditing()) { sdeTblTgdEditor.StartEditing(esriMultiuserEditSessionMode.esriMESMVersioned); sdeTblTgdEditor.StartEditOperation(); } //else //{ // //try // //{ // // sdeTblTgdEditor.SaveEdit(); // // sdeTblTgdEditor.StopEditOperation(); // // sdeTblTgdEditor.StopEditing(true); // //} // //catch // //{ // // sdeTblTgdEditor.StopEditOperation(); // // sdeTblTgdEditor.StopEditing(false); // //} // //sdeTblTgdEditor.StartEditing(esriMultiuserEditSessionMode.esriMESMVersioned); // //sdeTblTgdEditor.StartEditOperation(); //} #region ----log if (_caller != null) { evt.Log = string.Format("\n----||| Đang lưu bảng {0} |||---- ", tgdDraft); _caller.onCalculating(evt); } #endregion try { sdeTblTgdEditor.SaveEdit(); sdeTblTgdEditor.StopEditOperation(); sdeTblTgdEditor.StopEditing(true); } catch (Exception ex) { sdeTblTgdEditor.StopEditOperation(); sdeTblTgdEditor.StopEditing(false); } #region ----log if (_caller != null) { evt.Log = string.Format("\n----||| Đã lưu bảng {0} |||---- ", tgdDraft); _caller.onCalculating(evt); } #endregion #endregion #region loc gia dat ThreadStart filterThread =()=>fil(newId); Thread t = new Thread(filterThread); t.Start(); //while (!t.IsAlive) ; //Thread.Sleep(1); //t.Abort(); t.Join(); #endregion #endregion }
public void CalcGiaHemPhu(List<object> newId) { #region khoi tao cac bien SdeConnection conn = new SdeConnection(); ISdeConnectionInfo sdeConn = conn as ISdeConnectionInfo; _wspEdit = (IWorkspaceEdit)sdeConn.Workspace; _mwspEdit = (IMultiuserWorkspaceEdit)sdeConn.Workspace; IFeatureWorkspace fw = (IFeatureWorkspace)sdeConn.Workspace; copyTool = new DataManager(sdeConn.Workspace, sdeConn.Environment); this._fcName = new TnFeatureClassName(sdeConn.Workspace); this._tblName = new TnTableName(sdeConn.Workspace); string gdHemPhu = string.Format("{0}_{1}", DataNameTemplate.Gia_Hem_Phu, this._currentConfig.NamApDung); string gdHemChinh = string.Format("{0}_{1}", DataNameTemplate.Gia_Hem, this._currentConfig.NamApDung); _fcName.FC_GIA_DAT_HEM_PHU.NAME = gdHemPhu; _fcName.FC_GIA_DAT_HEM_PHU.InitIndex(); _fcName.FC_GIA_DAT_HEM.NAME = gdHemChinh; _fcName.FC_GIA_DAT_HEM.InitIndex(); IFeatureClass gdhPhuFeatureClass = null; ITable tblgdHemPhu = null; try { gdhPhuFeatureClass = fw.OpenFeatureClass(gdHemPhu); tblgdHemPhu = (ITable)gdhPhuFeatureClass; } catch { MessageBox.Show("Không tìm thấy bảng " + gdHemPhu); return; } IFeatureClass gdhChinhFeatureClass; ITable tblHesoVitri; ITable tblTenDuong; ITable tblHemChinh; #endregion #region dinh nghia cac bien try { tblTenDuong = fw.OpenTable(DataNameTemplate.Ten_Duong); } catch (Exception ex) { MessageBox.Show("Không tìm thấy bảng " + DataNameTemplate.Ten_Duong); return; } try { gdhChinhFeatureClass = fw.OpenFeatureClass(gdHemChinh); } catch (Exception ex) { MessageBox.Show("Không tìm thấy bảng " + gdHemChinh); return; } try { tblHemChinh = fw.OpenTable(DataNameTemplate.Hem); } catch (Exception ex) { MessageBox.Show("Không tìm thấy bảng " + DataNameTemplate.Hem); return; } ISDETableEditor sdeTblGdhEditor = new SDETable(tblgdHemPhu, sdeConn.Workspace); IQueryFilter qrf = new QueryFilterClass(); #endregion #region vong lap tung id #region khoi dau int rowGdhHandleUpdate = 0; string cachtinh = ""; string cachtinhdongia = ""; bool result = false; List<object[,]> pairColValTgd = new List<object[,]>(); CalculationEventArg evt = new CalculationEventArg(); if (_caller != null) { evt.Reset(); evt.Log = "\n\nBắt đầu tính giá cho các hẻm vừa xác định vị trí"; _caller.onCalculating(evt); } int len = newId.Count; int thuaCount = 1; //MessageBox.Show(len.ToString()); #endregion foreach (object o in newId) { if (!((int)o > 0)) { //MessageBox.Show("line 737 CalcLandprice: không thể tính cho hẻm có id=" + o); continue; } #region lay thong tin hem gia dat IRow gdhRowNew = null; try { gdhRowNew = tblgdHemPhu.GetRow((int)o); } catch (Exception ex) { } if (gdhRowNew == null) { continue; } string maHemChinhNew = gdhRowNew.get_Value(gdhRowNew.Fields.FindField(_fcName.FC_GIA_DAT_HEM_PHU.MA_HEM_CHINH)).ToString(); int hesovitriNew; result = int.TryParse(gdhRowNew.get_Value(gdhRowNew.Fields.FindField(_fcName.FC_GIA_DAT_HEM_PHU.HE_SO)).ToString(), out hesovitriNew); object khoagia = gdhRowNew.get_Value(gdhRowNew.Fields.FindField(_fcName.FC_GIA_DAT_HEM_PHU.LOCKED)); object mahem = gdhRowNew.get_Value(gdhRowNew.Fields.FindField(_fcName.FC_GIA_DAT_HEM_PHU.MA_HEM)); int dorongHem = 0; object tenHem = ""; //MessageBox.Show("line 237 CalcLandprice, maduong=" + maduongNew); if (khoagia != null) { if (khoagia.ToString() != "0" && khoagia.ToString() != "") { //MessageBox.Show(khoagia.ToString()); //evt.Reset(); //evt.IdThuaKhoaGia = o; //evt.mathua = mahem; //_caller.onCalculating(evt); continue; } } #endregion #region lay gia dat hem chinh qrf.WhereClause = string.Format("{0}='{1}'", _fcName.FC_GIA_DAT_HEM.MA_HEM, maHemChinhNew); IFeatureCursor gdHemChinhCur = null; gdHemChinhCur = gdhChinhFeatureClass.Search(qrf, false); IFeature gdHemChinhRow = null; double giaHemChinh = 0; object maduong = 0; try { if ((gdHemChinhRow = gdHemChinhCur.NextFeature()) != null) { result = double.TryParse(gdHemChinhRow.get_Value(_fcName.FC_GIA_DAT_HEM.GetIndex(_fcName.FC_GIA_DAT_HEM.GIA_DAT)).ToString(), out giaHemChinh); if (!result) { giaHemChinh = 0; } maduong=gdHemChinhRow.get_Value(_fcName.FC_GIA_DAT_HEM.GetIndex(_fcName.FC_GIA_DAT_HEM.MA_DUONG)); //MessageBox.Show("line 1259 CalcLandprice, giahemchinh=" + giaHemChinh.ToString()); } } catch (COMException comExc) { } finally { Marshal.ReleaseComObject(gdHemChinhCur); } #endregion if (mahem != null) { #region lay thong tin hem if (mahem.ToString() != "0" && mahem.ToString() != "") { qrf.WhereClause = string.Format("{0}='{1}'", _fcName.FC_HEM.MA_HEM, mahem); ICursor hemFcur = tblHemChinh.Search(qrf, false); IRow hemRow = null; try { if ((hemRow = hemFcur.NextRow()) != null) { object dorong = hemRow.get_Value(hemRow.Fields.FindField(_fcName.FC_HEM.DO_RONG)); result = int.TryParse(dorong.ToString(), out dorongHem); if (!result) { dorongHem = 0; } tenHem = hemRow.get_Value(hemRow.Fields.FindField(_fcName.FC_HEM.TEN_HEM)); } } catch (Exception ex) { } finally { Marshal.ReleaseComObject(hemFcur); } } #endregion } #region lay ten duong qrf.WhereClause = string.Format("{0}='{1}'", _tblName.TEN_DUONG.MA_DUONG, maduong); ICursor tenDuongCur = null; tenDuongCur = tblTenDuong.Search(qrf, false); IRow tenDuongRow = null; object tenduong = ""; object batdau = ""; object ketthuc = ""; try { if ((tenDuongRow = tenDuongCur.NextRow()) != null) { tenduong = tenDuongRow.get_Value(_tblName.TEN_DUONG.GetIndex(_tblName.TEN_DUONG.TEN_DUONG)); batdau = tenDuongRow.get_Value(_tblName.TEN_DUONG.GetIndex(_tblName.TEN_DUONG.BAT_DAU)); ketthuc = tenDuongRow.get_Value(_tblName.TEN_DUONG.GetIndex(_tblName.TEN_DUONG.KET_THUC)); } } catch (COMException comExc) { giaHemChinh = 0; } finally { Marshal.ReleaseComObject(tenDuongCur); } #endregion object giaMoiTinh = 0; double hesorong = 1; double hesosau = 1; #region chon chieu rong if (dorongHem < 3.5) { hesorong = _currentConfig.PHemChinhRongDuoi3_5m; } else if (dorongHem < 6) { hesorong = _currentConfig.PHemChinhRongTren3_5m; } else { hesorong = _currentConfig.PHemChinhRongTren6m; } #endregion #region chon chieu sau if (hesovitriNew == 1) //chieu sau <100m { hesosau = _currentConfig.PHemSauDuoi100m; } else if (hesovitriNew == 2) { hesosau = _currentConfig.PHemSauDuoi200m; } else { hesosau = _currentConfig.PHemSauTren200m; } #endregion giaMoiTinh = giaHemChinh * hesorong * hesosau; //MessageBox.Show("line 868 CalcLandprice giamoitinh=" + giaMoiTinh); pairColValTgd.Add(new object[,] { { _fcName.FC_GIA_DAT_HEM_PHU.GetIndex(_fcName.FC_GIA_DAT_HEM_PHU.GIA_DAT), giaMoiTinh } }); sdeTblGdhEditor.CacheData(o, 0, pairColValTgd, EnumTypeOfEdit.UPDATE); pairColValTgd.Clear(); } #endregion #region luu thong tin vao bang gia dat if (!sdeTblGdhEditor.IsEditing()) { sdeTblGdhEditor.StartEditing(true); sdeTblGdhEditor.StartEditOperation(); } else { try { sdeTblGdhEditor.SaveEdit(); sdeTblGdhEditor.StopEditOperation(); sdeTblGdhEditor.StopEditing(true); } catch { sdeTblGdhEditor.StopEditOperation(); sdeTblGdhEditor.StopEditing(false); } sdeTblGdhEditor.StartEditing(esriMultiuserEditSessionMode.esriMESMVersioned); sdeTblGdhEditor.StartEditOperation(); } #region ----log if (_caller != null) { evt.Log = string.Format("\n----||| Đang lưu vị trí các thửa vào bảng {0} |||---- ", gdHemPhu); _caller.onCalculating(evt); } #endregion try { sdeTblGdhEditor.SaveEdit(); sdeTblGdhEditor.StopEditOperation(); sdeTblGdhEditor.StopEditing(true); } catch (Exception ex) { MessageBox.Show("line 1405 CalcGiaHemChinh ex=" + ex.ToString()); sdeTblGdhEditor.StopEditOperation(); sdeTblGdhEditor.StopEditing(false); } #region ----log if (_caller != null) { evt.Log = string.Format("\n----||| Đã lưu vị trí các thửa vào bảng {0} |||---- ", gdHemPhu); _caller.onCalculating(evt); } #endregion #endregion }