예제 #1
0
        static bool GetDBList(out Dictionary <int, string> server)
        {
            server = new Dictionary <int, string>();

            int ret = RsWSAStartup();

            if (ret != 0)
            {
                LogUtil.Error1("RsWSAStartup={0}", ret);

                ret = RsWSACleanup();
                if (ret != 0)
                {
                    LogUtil.Error1("Retry: RsWSACleanup={0}", ret);
                }

                ret = RsWSAStartup();
                if (ret != 0)
                {
                    LogUtil.Error1("Retry: RsWSAStartup={0}", ret);
                }
            }

            int cnt;
            var errmsg = new StringBuilder(IRCOM_MAX_MESSAGE_LENGTH);

            var ptr = RsGetDBList(AppUtil.rsAddr, AppUtil.rsPort, out cnt, out ret, errmsg);

            if (ptr == null || ret != 0)
            {
                LogUtil.Error2("RsGetDBList={0} {1}", ret, errmsg);
                return(false);
            }

            try
            {
                for (int i = 0; i < cnt; i++)
                {
                    var path = Marshal.PtrToStringAnsi(ptr + 64 * i);
                    server.Add(i - 1, path);
                }
                return(true);
            }
            finally
            {
                RsFree(ptr);
            }
        }
예제 #2
0
        public static bool Delete(string path, bool delayDelete = false)
        {
            try
            {
                if (Directory.Exists(path))
                {
                    Directory.Delete(path, true);
                }
                else
                {
                    File.Delete(path);
                }
                return(true);
            }
            catch (Exception ex)
            {
                if (delayDelete && AppUtil.DeletePath != "")
                {
                    try
                    {
                        if (!Directory.Exists(AppUtil.DeletePath))
                        {
                            Directory.CreateDirectory(AppUtil.DeletePath);
                        }

                        while (true)
                        {
                            var file = Path.Combine(AppUtil.DeletePath, DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".go");
                            if (!File.Exists(file))
                            {
                                File.WriteAllText(file, path);
                                return(false);
                            }
                            System.Threading.Thread.Sleep(1);
                        }
                    }
                    catch (Exception ex2)
                    {
                        LogUtil.Error2("{0} [{1}]", ex2.Message, path);
                    }
                }

                LogUtil.Error2("{0} [{1}]", ex.Message, path);
                return(false);
            }
        }
예제 #3
0
        static bool GetStudyList(RBStudyQuery query, out List <RBStudy> studyList)
        {
            studyList = new List <RBStudy>();

            int cnt;
            int ret;
            var errmsg = new StringBuilder(IRCOM_MAX_MESSAGE_LENGTH);

            var ptr = RsGetStudyList(AppUtil.rsAddr, AppUtil.rsPort, ref query, out cnt, out ret, errmsg);

            if (ptr == null || ret != 0)
            {
                LogUtil.Error2("RsGetStudyList[{0}] {1}", ret, errmsg);
                return(false);
            }

            try
            {
                for (int i = 0; i < cnt; i++)
                {
                    var study = (RBStudy)Marshal.PtrToStructure(ptr + Marshal.SizeOf(typeof(RBStudy)) * i, typeof(RBStudy));
                    if (study.NoOfImg == 0)
                    {
                        continue;
                    }

                    if (study.DBStatus == RB_STATUS_DBLOCK)
                    {
                        LogUtil.Warn1("RB_STATUS_DBLOCK: {0}", study.StudyUID);
                        continue;
                    }

                    studyList.Add(study);
                }
                return(true);
            }
            finally
            {
                RsFree(ptr);
            }
        }
예제 #4
0
        static bool GetImageList(RBObjectQuery query, out List <RBImage> imageList)
        {
            imageList = new List <RBImage>();

            int cnt;
            int ret;
            var errmsg = new StringBuilder(IRCOM_MAX_MESSAGE_LENGTH);

            var ptr = RsGetImageList(AppUtil.rsAddr, AppUtil.rsPort, ref query, out cnt, out ret, errmsg);

            if (ptr == null || ret != 0)
            {
                LogUtil.Error2("RsGetImageList[{0}] {1}", ret, errmsg);
                return(false);
            }

            try
            {
                for (int i = 0; i < cnt; i++)
                {
                    var image = (RBImage)Marshal.PtrToStructure(ptr + Marshal.SizeOf(typeof(RBImage)) * i, typeof(RBImage));
                    if (image.ObjectType != RB_OBJECT_IMAGE)
                    {
                        continue;
                    }

                    if (image.DBStatus == RB_STATUS_DBLOCK)
                    {
                        LogUtil.Warn1("RB_STATUS_DBLOCK: {0}", image.InstUID);
                        continue;
                    }

                    imageList.Add(image);
                }
                return(true);
            }
            finally
            {
                RsFree(ptr);
            }
        }