コード例 #1
0
ファイル: Program.cs プロジェクト: Javanei/clientes
        public static List<ADSK.File> findByCheckinDate(DocumentService documentService, String checkinDate)
        {
            LOG.imprimeLog(System.DateTime.Now + " ===== findByCheckinDate: [" + checkinDate + "]");
            List<ADSK.File> fileList = new List<ADSK.File>();
            List<ADSK.File> fileListTmp = new List<ADSK.File>();
            List<string> allf = new List<string>();

            ADSK.PropDef prop = GetPropertyDefinition("CheckoutUserName", documentService);
            if (prop != null)
            {
                propid = (int)prop.Id;
                /* Faz a pesquisa */
                string bookmark = string.Empty;
                ADSK.SrchStatus status = null;

                ADSK.SrchCond[] conditions = new ADSK.SrchCond[1];
                conditions[0] = new ADSK.SrchCond();
                conditions[0].SrchOper = Condition.IS_NOT_EMPTY.Code;
                conditions[0].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[0].PropDefId = propid;

                prop = GetPropertyDefinition("ClientFileName", documentService);
                propid = (int)prop.Id;

                /*conditions[1] = new ADSK.SrchCond();
                conditions[1].SrchOper = Condition.CONTAINS.Code;
                conditions[1].SrchTxt = ".idw";
                conditions[1].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[1].PropDefId = propid;
                conditions[1].SrchRule = ADSK.SearchRuleType.May;

                conditions[2] = new ADSK.SrchCond();
                conditions[2].SrchOper = Condition.CONTAINS.Code;
                conditions[2].SrchTxt = ".pdf";
                conditions[2].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[2].PropDefId = propid;
                conditions[2].SrchRule = ADSK.SearchRuleType.May;

                conditions[3] = new ADSK.SrchCond();
                conditions[3].SrchOper = Condition.CONTAINS.Code;
                conditions[3].SrchTxt = ".dwg";
                conditions[3].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[3].PropDefId = propid;
                conditions[3].SrchRule = ADSK.SearchRuleType.May;*/

                while (status == null || fileListTmp.Count < status.TotalHits)
                {
                    ADSK.File[] files = documentService.FindFilesBySearchConditions(
                        conditions, /*SrchCond [] conditions*/
                        null, /*SrchSort [] sortConditions*/
                        folderIds, /*Long [] folderIds*/
                        true, /*Boolean recurseFolders*/
                        true, /*Boolean latestOnly*/
                        ref bookmark, /*[out] String bookmark*/
                        out status /*[out] SrchStatus searchstatus*/
                    );
                    if (files != null)
                    {
                        foreach (ADSK.File f in files)
                        {
                            fileListTmp.Add(f);
                            if (f.Name.ToLower().EndsWith(".idw"))
                            {
                                string fcode = f.Name.Substring(0, f.Name.Length - 4);
                                if (!allf.Contains(fcode))
                                {
                                    allf.Add(fcode);
                                    LOG.imprimeLog(System.DateTime.Now + " Adicionado via checkout =====-> " + f.Name + "(" + f.FileSize + ") - CkInDate: " + f.CkInDate.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss"));
                                    fileList.Add(f);
                                }
                            }
                        }
                        foreach (ADSK.File f in files)
                        {
                            if (f.Name.ToLower().EndsWith(".dwg"))
                            {
                                string fcode = f.Name.Substring(0, f.Name.Length - 4);
                                if (!allf.Contains(fcode))
                                {
                                    allf.Add(fcode);
                                    LOG.imprimeLog(System.DateTime.Now + " Adicionado via checkout =====-> " + f.Name + "(" + f.FileSize + ") - CkInDate: " + f.CkInDate.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss"));
                                    fileList.Add(f);
                                }
                            }
                        }
                        foreach (ADSK.File f in files)
                        {
                            if (f.Name.ToLower().EndsWith(".pdf"))
                            {
                                string fcode = f.Name.Substring(0, f.Name.Length - 4);
                                if (!allf.Contains(fcode))
                                {
                                    allf.Add(fcode);
                                    LOG.imprimeLog(System.DateTime.Now + " Adicionado via checkout =====-> " + f.Name + "(" + f.FileSize + ") - CkInDate: " + f.CkInDate.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss"));
                                    fileList.Add(f);
                                }
                            }
                        }
                        /*
                        foreach (ADSK.File f in files)
                        {
                            fileListTmp.Add(f);
                            if (f.Name.ToLower().EndsWith(".pdf") || f.Name.ToLower().EndsWith(".idw") || f.Name.ToLower().EndsWith(".dwg"))
                            {
                                LOG.imprimeLog(System.DateTime.Now + " Adicionado via checkout =====-> " + f.Name + "(" + f.FileSize + ")");
                                fileList.Add(f);
                            }
                        }
                        */
                    }
                }
            }

            /*ADSK.PropDef*/
            prop = GetPropertyDefinition("CheckInDate", documentService);
            if (prop != null)
            {
                fileListTmp = new List<ADSK.File>();
                propid = (int)prop.Id;
                /* Faz a pesquisa */
                string bookmark = string.Empty;
                ADSK.SrchStatus status = null;

                ADSK.SrchCond[] conditions = new ADSK.SrchCond[1];
                conditions[0] = new ADSK.SrchCond();
                conditions[0].SrchOper = Condition.GREATER_THAN_OR_EQUAL.Code /*(long)SrchOperator.GreatherThan*/;
                conditions[0].SrchTxt = checkinDate;
                conditions[0].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[0].PropDefId = propid;

                prop = GetPropertyDefinition("ClientFileName", documentService);
                propid = (int)prop.Id;

                /*conditions[1] = new ADSK.SrchCond();
                conditions[1].SrchOper = Condition.CONTAINS.Code;
                conditions[1].SrchTxt = ".idw";
                conditions[1].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[1].PropDefId = propid;
                conditions[1].SrchRule = ADSK.SearchRuleType.May;

                conditions[2] = new ADSK.SrchCond();
                conditions[2].SrchOper = Condition.CONTAINS.Code;
                conditions[2].SrchTxt = ".pdf";
                conditions[2].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[2].PropDefId = propid;
                conditions[2].SrchRule = ADSK.SearchRuleType.May;

                conditions[3] = new ADSK.SrchCond();
                conditions[3].SrchOper = Condition.CONTAINS.Code;
                conditions[3].SrchTxt = ".dwg";
                conditions[3].PropTyp = ADSK.PropertySearchType.SingleProperty;
                conditions[3].PropDefId = propid;
                conditions[3].SrchRule = ADSK.SearchRuleType.May;*/

                while (status == null || fileListTmp.Count < status.TotalHits)
                {
                    /*ADSK.FileFolder[] folders = documentService.FindFileFoldersBySearchConditions(
                        conditions,
                        null,
                        folderIds,
                        true,
                        true,
                        ref bookmark,
                        out status
                    );

                    if (folders != null)
                    {
                        foreach (ADSK.FileFolder f in folders)
                        {
                            //if (f.File != null)
                            //{
                            fileList.Add(f.File);
                            //}
                        }
                    }*/
                    ADSK.File[] files = documentService.FindFilesBySearchConditions(
                        conditions, /*SrchCond [] conditions*/
                        null, /*SrchSort [] sortConditions*/
                        folderIds, /*Long [] folderIds*/
                        true, /*Boolean recurseFolders*/
                        true, /*Boolean latestOnly*/
                        ref bookmark, /*[out] String bookmark*/
                        out status /*[out] SrchStatus searchstatus*/
                    );
                    if (files != null)
                    {
                        foreach (ADSK.File f in files)
                        {
                            fileListTmp.Add(f);
                            if (f.Name.ToLower().EndsWith(".idw"))
                            {
                                string fcode = f.Name.Substring(0, f.Name.Length - 4);
                                if (!allf.Contains(fcode))
                                {
                                    allf.Add(fcode);
                                    LOG.imprimeLog(System.DateTime.Now + " Adicionado via normal =====-> " + f.Name + "(" + f.FileSize + ") - CkInDate: " + f.CkInDate.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss"));
                                    fileList.Add(f);
                                }
                            }
                        }
                        foreach (ADSK.File f in files)
                        {
                            if (f.Name.ToLower().EndsWith(".dwg"))
                            {
                                string fcode = f.Name.Substring(0, f.Name.Length - 4);
                                if (!allf.Contains(fcode))
                                {
                                    allf.Add(fcode);
                                    LOG.imprimeLog(System.DateTime.Now + " Adicionado via normal =====-> " + f.Name + "(" + f.FileSize + ") - CkInDate: " + f.CkInDate.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss"));
                                    fileList.Add(f);
                                }
                            }
                        }
                        foreach (ADSK.File f in files)
                        {
                            if (f.Name.ToLower().EndsWith(".pdf"))
                            {
                                string fcode = f.Name.Substring(0, f.Name.Length - 4);
                                if (!allf.Contains(fcode))
                                {
                                    allf.Add(fcode);
                                    LOG.imprimeLog(System.DateTime.Now + " Adicionado via normal =====-> " + f.Name + "(" + f.FileSize + ") - CkInDate: " + f.CkInDate.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss"));
                                    fileList.Add(f);
                                }
                            }
                        }
                        /*
                        foreach (ADSK.File f in files)
                        {
                            fileListTmp.Add(f);
                            if (f.Name.ToLower().EndsWith(".pdf") || f.Name.ToLower().EndsWith(".idw") || f.Name.ToLower().EndsWith(".dwg"))
                            {
                                if (!fileList.Contains(f))
                                {
                                    LOG.imprimeLog(System.DateTime.Now + " Adicionado via normal =====-> " + f.Name + "(" + f.FileSize + ")");
                                    fileList.Add(f);
                                }
                            }
                        }
                        */
                    }

                    //ADSK.File[] files = documentService.FindFilesBySearchConditions(
                    //    conditions, /*SrchCond [] conditions*/
                    //    null, /*SrchSort [] sortConditions*/
                    //    null, /*Long [] folderIds*/
                    //    true, /*Boolean recurseFolders*/
                    //    true, /*Boolean latestOnly*/
                    //    ref bookmark, /*[out] String bookmark*/
                    //    out status /*[out] SrchStatus searchstatus*/
                    //);

                    //if (files != null)
                    //    fileList.AddRange(files);
                }
            }
            return fileList;
        }