예제 #1
0
        /// <summary>
        /// 结束任务流程
        /// </summary>
        /// <param name="taskName"></param>
        public void FinishTask(string taskName)
        {
            IFeatureWorkspace   ws = Util.ServerWorkspace as IFeatureWorkspace;
            IVersionedWorkspace vw = ws as IVersionedWorkspace;

            if (taskName.ToLower() == vw.DefaultVersion.VersionName.ToLower())
            {
                return;
            }
            IVersion       ver = vw.FindVersion(taskName);
            IVersionEdit4  ve  = ver as IVersionEdit4;
            IWorkspaceEdit wse = ver as IWorkspaceEdit;

            wse.StartEditing(true);
            ve.Reconcile4(vw.DefaultVersion.VersionName, true, true, true, true);
            if (ve.CanPost())
            {
                ve.Post(vw.DefaultVersion.VersionName);
            }
            ITable       task_tbl = ws.OpenTable("TaskLog");
            IQueryFilter filter   = new QueryFilterClass();

            filter.WhereClause = "TaskName = '" + taskName + "'";
            ICursor cur = task_tbl.Search(filter, false);
            IRow    rw  = cur.NextRow();

            if (rw != null)
            {
                rw.set_Value(task_tbl.FindField("Status"), TaskManager.FINISH_STATUS);
                rw.set_Value(task_tbl.FindField("FinishDate"), DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                rw.Store();
            }
            wse.StopEditing(true);
            ver.Delete();
        }
예제 #2
0
        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)
            {
            }
        }
예제 #3
0
        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);
        }