public QueryTermVector(System.String queryString, Analyzer analyzer)
		{
			if (analyzer != null)
			{
				TokenStream stream = analyzer.TokenStream("", new System.IO.StringReader(queryString));
				if (stream != null)
				{
					System.Collections.ArrayList terms = new System.Collections.ArrayList();
					try
					{
						bool hasMoreTokens = false;
						
						stream.Reset();
						TermAttribute termAtt = (TermAttribute) stream.AddAttribute(typeof(TermAttribute));
						
						hasMoreTokens = stream.IncrementToken();
						while (hasMoreTokens)
						{
							terms.Add(termAtt.Term());
							hasMoreTokens = stream.IncrementToken();
						}
						ProcessTerms((System.String[]) terms.ToArray(typeof(System.String)));
					}
					catch (System.IO.IOException e)
					{
					}
				}
			}
		}
Example #2
0
		public static System.Collections.ArrayList GetPainterDialogs( int painter_hwnd )
		{
			System.Collections.ArrayList dialogs = new System.Collections.ArrayList();

			foreach (int hwnd in libshell.GetChildWindows( libshell.GetDesktopWindow() ) )
			{
				string wclass = libshell.GetWindowClass( hwnd );
				string wtitle = libshell.GetWindowTextW( hwnd );
				if ( wclass == WindowClassEnum.ASITHREEDWindowClass )
				{
					if ( libshell.GetRootOwner(hwnd) == painter_hwnd )
					{
						// The Color Set shows up in this enumeration
						// But we don't consider it a dialog so
						// we ignore it

						if (wtitle!= WindowTextEnum.ColorSetWindowText  )
						{
							dialogs.Add( hwnd );
						}
					}
				}
				else if (wclass == WindowClassEnum.DialogWindowClass)
				{
					if ( libshell.GetRootOwner(hwnd) == painter_hwnd )
					{
						dialogs.Add( hwnd );
					}

				}

			}
			return dialogs;
		}
Example #3
0
        public void fillData()
        {
            int idGDV = int.Parse(Request.Cookies["MaGDV"].Value);

            DataTable dt = daoNews.GetListByGDV(idGDV);
            PagedDataSource pgitems = new PagedDataSource();
            System.Data.DataView dv = new System.Data.DataView(dt);
            pgitems.DataSource = dv;
            pgitems.AllowPaging = true;
            pgitems.PageSize = 20;
            if (PageNumber >= pgitems.PageCount) PageNumber = 0;
            pgitems.CurrentPageIndex = PageNumber;
            if (pgitems.PageCount > 1)
            {
                rptPages.Visible = true;
                System.Collections.ArrayList pages = new System.Collections.ArrayList();
                for (int i = 0; i < pgitems.PageCount; i++)
                    pages.Add((i + 1).ToString());
                rptPages.DataSource = pages;
                rptPages.DataBind();
            }
            else
                rptPages.Visible = false;

            repeaterList.DataSource = pgitems;
            repeaterList.DataBind();
        }
Example #4
0
 public void ListInit()
 {
     var l = new System.Collections.ArrayList()
     {
         1, 2, 3, 4
     };
 }
        public void TestExecute()
        {
            SpreadsheetCompiler converter = new SpreadsheetCompiler();
            System.IO.Stream stream = Assembly.GetAssembly(this.GetType()).GetManifestResourceStream("org.drools.dotnet.examples.resources.data.IntegrationExampleTest.xls");
            System.String drl = converter.Compile(stream, InputType.XLS);
            Assert.IsNotNull(drl);
            //COMPILE
            PackageBuilder builder = new PackageBuilder();
            builder.AddPackageFromDrl(drl);

            Package pkg = builder.GetPackage();
            Assert.IsNotNull(pkg);
            System.Console.Out.WriteLine(pkg.GetErrorSummary());
            Assert.AreEqual(0, builder.GetErrors().Length);

            RuleBase rb = RuleBaseFactory.NewRuleBase();
            rb.AddPackage(pkg);

            WorkingMemory wm = rb.NewWorkingMemory();

            //ASSERT AND FIRE
            wm.assertObject(new Cheese("stilton", 42));
            wm.assertObject(new Person("michael", "stilton", 42));
            System.Collections.IList list = new System.Collections.ArrayList();
            wm.setGlobal("list", list);
            wm.fireAllRules();
            Assert.AreEqual(1, list.Count);
        }
Example #6
0
        public FreeTabCtrl()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            UpdateStyles();

            InitializeComponent();

            if (normalImage == null)
            {
                hoverImage = FreeTab.Properties.Resources.tab_hover;
                normalImage = FreeTab.Properties.Resources.tab_normal;
                focusedImage = FreeTab.Properties.Resources.tab_pushed;
            }

            this.TabPanel.Location = this.Location;

            this.TabContent.Location = new Point(this.Location.X,
                  this.Location.Y + normalImage.Height + top_padding);

            tabArray = new System.Collections.ArrayList();
            tabHash = new System.Collections.Hashtable();
            normal_height = normalImage.Height - click_stretch*2;
            normal_Y = this.TabContent.Location.Y - normal_height;

            this.Resize += new EventHandler(FreeTabCtrl_Resize);

            //setActivate(0);
        }
 private int insertToDB()
 {
     DTO.Invoice invoice = new DTO.Invoice();
     System.Collections.ArrayList details = new System.Collections.ArrayList();
     for (int i = 0; i < grdItems.Rows.Count; i++)
     {
         DTO.InvoiceDetail d = new DTO.InvoiceDetail();
         DTO.Product p = new DTO.Product();
         p.Productid = int.Parse(grdItems.Rows[i].Cells[7].Value.ToString());
         d.Quantity = int.Parse(grdItems.Rows[i].Cells[2].Value.ToString());
         d.Priceout = decimal.Parse(grdItems.Rows[i].Cells[3].Value.ToString());
         d.Dicount = decimal.Parse(grdItems.Rows[i].Cells[4].Value.ToString());
         d.Pricein = decimal.Parse(grdItems.Rows[i].Cells[8].Value.ToString());
         d.Product = p;
         details.Add(d);
     }
     
     DTO.Member member = new DTO.Member();
     member.Memberid = (int)cboMember.SelectedValue;            ///
     invoice.Staff = UserSession.Session.Staff;
     invoice.Member = member;
     invoice.Remark = "";
     invoice.Discount = decimal.Parse(txtDiscount.Text.Replace("%", "").Replace(" ",""));
     invoice.InvoiceDetail = details;
     return new DAO.InvoiceDAO().addInvoice(invoice);
 }
 public MultiFormatUPCEANReader(System.Collections.Hashtable hints)
 {
     System.Collections.ArrayList possibleFormats = hints == null?null:(System.Collections.ArrayList) hints[DecodeHintType.POSSIBLE_FORMATS];
     readers = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
     if (possibleFormats != null)
     {
         if (possibleFormats.Contains(BarcodeFormat.EAN_13))
         {
             readers.Add(new EAN13Reader());
         }
         else if (possibleFormats.Contains(BarcodeFormat.UPC_A))
         {
             readers.Add(new UPCAReader());
         }
         if (possibleFormats.Contains(BarcodeFormat.EAN_8))
         {
             readers.Add(new EAN8Reader());
         }
         if (possibleFormats.Contains(BarcodeFormat.UPC_E))
         {
             readers.Add(new UPCEReader());
         }
     }
     if ((readers.Count == 0))
     {
         readers.Add(new EAN13Reader());
         // UPC-A is covered by EAN-13
         readers.Add(new EAN8Reader());
         readers.Add(new UPCEReader());
     }
 }
		public MultiFormatOneDReader(System.Collections.Hashtable hints)
		{
			System.Collections.ArrayList possibleFormats = hints == null?null:(System.Collections.ArrayList) hints[DecodeHintType.POSSIBLE_FORMATS];
			bool useCode39CheckDigit = hints != null && hints[DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT] != null;
			readers = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
			if (possibleFormats != null)
			{
				if (possibleFormats.Contains(BarcodeFormat.EAN_13) || possibleFormats.Contains(BarcodeFormat.UPC_A) || possibleFormats.Contains(BarcodeFormat.EAN_8) || possibleFormats.Contains(BarcodeFormat.UPC_E))
				{
					readers.Add(new MultiFormatUPCEANReader(hints));
				}
				if (possibleFormats.Contains(BarcodeFormat.CODE_39))
				{
					readers.Add(new Code39Reader(useCode39CheckDigit));
				}
				if (possibleFormats.Contains(BarcodeFormat.CODE_128))
				{
					readers.Add(new Code128Reader());
				}
				if (possibleFormats.Contains(BarcodeFormat.ITF))
				{
					readers.Add(new ITFReader());
				}
			}
			if ((readers.Count == 0))
			{
				readers.Add(new MultiFormatUPCEANReader(hints));
				readers.Add(new Code39Reader());
				readers.Add(new Code128Reader());
				readers.Add(new ITFReader());
			}
		}
Example #10
0
 public void CalcolaCF_return_correct_fiscalcode()
 {
     var listaErrori = new System.Collections.ArrayList();
     var codice = new CodiceFiscale();
     var codiceFiscale = codice.CalcolaCF("LUCIANO", "BENASSI", 'M', "09/10/1955", "G972", listaErrori);
     Assert.IsTrue(codiceFiscale == "BNSLCN55R09G972K");
 }
Example #11
0
 /// <summary>
 /// Performs a pathping
 /// </summary>
 /// <param name="ipaTarget">The target</param>
 /// <param name="iHopcount">The maximum hopcount</param>
 /// <param name="iTimeout">The timeout for each ping</param>
 /// <returns>An array of PingReplys for the whole path</returns>
 public static PingReply[] PerformPathping(IPAddress ipaTarget, int iHopcount, int iTimeout)
 {
     System.Collections.ArrayList arlPingReply = new System.Collections.ArrayList();
     Ping myPing = new Ping();
     PingReply prResult = null;
     int iTimeOutCnt = 0;
     for (int iC1 = 1; iC1 < iHopcount && iTimeOutCnt<5; iC1++)
     {
         prResult = myPing.Send(ipaTarget, iTimeout, new byte[10], new PingOptions(iC1, false));
         if (prResult.Status == IPStatus.Success)
         {
             iC1 = iHopcount;
             iTimeOutCnt = 0;
         }
         else if (prResult.Status == IPStatus.TtlExpired)
         {
             iTimeOutCnt = 0;
         }
         else if (prResult.Status == IPStatus.TimedOut)
         {
             iTimeOutCnt++;
         }
         arlPingReply.Add(prResult);
     }
     PingReply[] prReturnValue = new PingReply[arlPingReply.Count];
     for (int iC1 = 0; iC1 < arlPingReply.Count; iC1++)
     {
         prReturnValue[iC1] = (PingReply)arlPingReply[iC1];
     }
     return prReturnValue;
 }
Example #12
0
        static void Main(string[] args)
        {
            Toy doll = new Toy();
            doll.Make = "rubber";
            doll.Model = "barbie";
            doll.Name = "Elsa";

            Toy car = new Toy();
            car.Make = "plastic";
            car.Model = "BMW";
            car.Name = "SPUR";

            System.Collections.ArrayList myArrayList = new System.Collections.ArrayList();
            myArrayList.Add(doll);
            myArrayList.Add(car);

            System.Collections.Specialized.ListDictionary myDictionary
                = new System.Collections.Specialized.ListDictionary();

            myDictionary.Add(doll.Name, doll);
            myDictionary.Add(car.Name, car);
            foreach (object o in myArrayList)
            {
                Console.WriteLine(((Toy)o).Name);
            }

            Console.WriteLine(((Toy)myDictionary["Elsa"]).Model);
            Console.ReadLine();
        }
	private static void InitXR()
	{
		try
		{
			string FILEP = "file:\\";
			string EXT = "-netz.resources";
			string path = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
			if(path.StartsWith(FILEP)) path = path.Substring(FILEP.Length, path.Length - FILEP.Length);
			string[] files = Directory.GetFiles(path, "*" + EXT);
			if((files != null) && (files.Length > 0))
			{
				xrRm = new System.Collections.ArrayList();
				for(int i = 0; i < files.Length; i++)
				{
					string name = Path.GetFileName(files[i]);
					name = name.Substring(0, name.Length - EXT.Length);
					ResourceManager temp = ResourceManager.CreateFileBasedResourceManager(name + "-netz", path, null);
					if(temp != null)
					{
						xrRm.Add(temp);
					}
				}
			}
		}catch
		{
			// fail silently here if something bad with regard to permissions happens
		}
	}
Example #14
0
 public FrmFormwork(Framework.Entity.Chapter chapter, object type)
 {
     InitializeComponent();
     @class = type;
     templateList = contentService.GetContentTemplateByTitle(chapter.Title);
     CbxFormworkType.SelectedIndex = 0;
 }
		/// <summary> Given a string that contains HL7 messages, and possibly other junk, 
		/// returns an array of the HL7 messages.  
		/// An attempt is made to recognize segments even if there is other 
		/// content between segments, for example if a log file logs segments 
		/// individually with timestamps between them.  
		/// 
		/// </summary>
		/// <param name="theSource">a string containing HL7 messages 
		/// </param>
		/// <returns> the HL7 messages contained in theSource
		/// </returns>
        private static System.String[] getHL7Messages(System.String theSource)
        {
            System.Collections.ArrayList messages = new System.Collections.ArrayList(20);
            Match startMatch = new Regex("^MSH", RegexOptions.Multiline).Match(theSource);

            foreach (Group group in startMatch.Groups)
            {
                System.String messageExtent = getMessageExtent(theSource.Substring(group.Index), "^MSH");

                char fieldDelim = messageExtent[3];

                Match segmentMatch = Regex.Match(messageExtent, "^[A-Z]{3}\\" + fieldDelim + ".*$", RegexOptions.Multiline);

                System.Text.StringBuilder msg = new System.Text.StringBuilder();
                foreach (Group segGroup in segmentMatch.Groups)
                {
                    msg.Append(segGroup.Value.Trim());
                    msg.Append('\r');
                }

                messages.Add(msg.ToString());
            }

            String[] retVal = new String[messages.Count];
            messages.CopyTo(retVal);

            return retVal;
        }
        public StartUIACacheRequestCommand()
        {
            System.Collections.ArrayList defaultPropertiesList =
                new System.Collections.ArrayList();
            defaultPropertiesList.Add("Name");
            defaultPropertiesList.Add("AutomationId");
            defaultPropertiesList.Add("ClassName");
            defaultPropertiesList.Add("ControlType");
            defaultPropertiesList.Add("NativeWindowHandle");
            defaultPropertiesList.Add("BoundingRectangle");
            defaultPropertiesList.Add("ClickablePoint");
            defaultPropertiesList.Add("IsEnabled");
            defaultPropertiesList.Add("IsOffscreen");
            this.Property = (string[])defaultPropertiesList.ToArray(typeof(string));

            System.Collections.ArrayList defaultPatternsList =
                new System.Collections.ArrayList();
            defaultPatternsList.Add("ExpandCollapsePattern");
            defaultPatternsList.Add("InvokePattern");
            defaultPatternsList.Add("ScrollItemPattern");
            defaultPatternsList.Add("SelectionItemPattern");
            defaultPatternsList.Add("SelectionPattern");
            defaultPatternsList.Add("TextPattern");
            defaultPatternsList.Add("TogglePattern");
            defaultPatternsList.Add("ValuePattern");
            this.Pattern = (string[])defaultPatternsList.ToArray(typeof(string));

            this.Scope = "SUBTREE";

            this.Filter = "RAW";
        }
Example #17
0
        public void loadComment(int idNews)
        {
            DataTable dt = daoNews.GetListComment(idNews);
            PagedDataSource pgitems = new PagedDataSource();
            System.Data.DataView dv = new System.Data.DataView(dt);
            pgitems.DataSource = dv;
            pgitems.AllowPaging = true;
            pgitems.PageSize = 20;
            if (PageNumber >= pgitems.PageCount) PageNumber = 0;
            pgitems.CurrentPageIndex = PageNumber;
            if (pgitems.PageCount > 1)
            {
                rptPagesComment.Visible = true;
                System.Collections.ArrayList pages = new System.Collections.ArrayList();
                for (int i = 0; i < pgitems.PageCount; i++)
                    pages.Add((i + 1).ToString());
                rptPagesComment.DataSource = pages;
                rptPagesComment.DataBind();
            }
            else
                rptPagesComment.Visible = false;

            rptComment.DataSource = pgitems;
            rptComment.DataBind();

            lblNumberComment.Text = "("+ dt.Rows.Count +")";
        }
Example #18
0
        /**************************************************
         * 函数名称:GetSubElementByAttribute(string XmlPath, string FatherElenetName, string AttributeName, int AttributeIndex, int ArrayLength)
         * 功能说明:根据父节点属性值读取子节点值
         * 参    数: XmlPath:xml路径;FatherElenetName:父节点名;AttributeName:属性值;AttributeIndex:属性索引;ArrayLength:要返回的节点数组长度
         * 适应用Xml:
         * <root>
          *   <page name="/index.aspx">
           *      <title>域名注册、虚拟主机、企业邮局、服务器托管、网站空间租用|---第一商务</title>
           *      <keywords>虚拟主机,域名注册,服务器托管,杭州,服务器租用,</keywords>
           *      <description>描述内容 </description>
          *    </page>
         * </root>
         *           ArrayList al = new ArrayList();
         *           al = EC.XmlObject.GetSubElementByAttribute(XmlPath, "page", "/index.aspx", 0, 3);
         *           for (int i = 0; i < al.Count; i++)
         *           {
         *               Response.Write(al[i].ToString());
         *               Response.Write("<br>");
         *           }
         ************************************************/
        /// <summary>
        /// 根据父节点属性读取字节点值
        /// </summary>
        /// <param name="XmlPath">xml路径</param>
        /// <param name="FatherElenetName">父节点名</param>
        /// <param name="AttributeName">属性值</param>
        /// <param name="AttributeIndex">属性索引</param>
        /// <param name="ArrayLength">要返回的节点数组长度</param>
        /// <returns></returns>
        public static System.Collections.ArrayList GetSubElementByAttribute(string XmlPath, string FatherElenetName, string AttributeName, int AttributeIndex, int ArrayLength)
        {
            System.Collections.ArrayList al = new System.Collections.ArrayList();
            XmlDocument docXml = new XmlDocument();
            docXml.Load(@XmlPath);
            XmlNodeList xn = docXml.DocumentElement.ChildNodes;
            //遍历第一层节点
            foreach (XmlElement element in xn)
            {
                //判断父节点是否为指定节点
                if (element.Name == FatherElenetName)
                {
                    //判断父节点属性的索引是否大于指定索引
                    if (element.Attributes.Count < AttributeIndex)
                        return null;
                    //判断父节点的属性值是否等于指定属性
                    if (element.Attributes[AttributeIndex].Value == AttributeName)
                    {
                        XmlNodeList xx = element.ChildNodes;
                        if (xx.Count > 0)
                        {
                            for (int i = 0; i < ArrayLength & i < xx.Count; i++)
                            {
                                al.Add(xx[i].InnerText);
                            }
                        }
                    }

                }
            }
            return al;
        }
 public XYPlotStyleCollectionController(G2DPlotStyleCollection doc)
 {
   _doc = doc;
   _tempdoc = new System.Collections.ArrayList();
   for(int i=0;i<_doc.Count;i++)
     _tempdoc.Add(_doc[i]);
 }
Example #20
0
 public Tokenizer(string source, string delimiters)
 {
     this.elements = new System.Collections.ArrayList();
     this.delimiters = delimiters;
     this.source = source;
     this.ReTokenize();
 }
Example #21
0
		public virtual CacheEntry[] GetCacheEntries()
		{
			System.Collections.IList result = new System.Collections.ArrayList(17);
			System.Collections.IEnumerator outerKeys = caches.Keys.GetEnumerator();
			while (outerKeys.MoveNext())
			{
				System.Type cacheType = (System.Type) outerKeys.Current;
				Cache cache = (Cache) caches[cacheType];
				System.Collections.IEnumerator innerKeys = cache.readerCache.Keys.GetEnumerator();
				while (innerKeys.MoveNext())
				{
					// we've now materialized a hard ref
					System.Object readerKey = innerKeys.Current;
					// innerKeys was backed by WeakHashMap, sanity check
					// that it wasn't GCed before we made hard ref
					if (null != readerKey && cache.readerCache.Contains(readerKey))
					{
						System.Collections.IDictionary innerCache = ((System.Collections.IDictionary) cache.readerCache[readerKey]);
						System.Collections.IEnumerator entrySetIterator = new System.Collections.Hashtable(innerCache).GetEnumerator();
						while (entrySetIterator.MoveNext())
						{
							System.Collections.DictionaryEntry mapEntry = (System.Collections.DictionaryEntry) entrySetIterator.Current;
							Entry entry = (Entry) mapEntry.Key;
							result.Add(new CacheEntryImpl(readerKey, entry.field, cacheType, entry.type, entry.custom, entry.locale, mapEntry.Value));
						}
					}
				}
			}
			return (CacheEntry[]) new System.Collections.ArrayList(result).ToArray(typeof(CacheEntry));
		}
Example #22
0
 public FrmConretestrength1(Framework.Entity.Chapter chapter, object type)
 {
     InitializeComponent();
     @class = type;
     templateList = contentService.GetContentTemplateByTitle(chapter.Title);
     chaptertemp = chapter;
 }
        /// <summary>
        /// Makes string safe for xml parsing, replacing control chars with '?'
        /// </summary>
        /// <param name="encodedString">string to make safe</param>
        /// <returns>xml safe string</returns>
        private static string CharacterSafeString(string encodedString)
        {
            /*The default code page for the system will be used.
            Since all code pages use the same lower 128 bytes, this should be sufficient
            for finding uprintable control characters that make the xslt processor error.
            We use characters encoded by the default code page to avoid mistaking bytes as
            individual characters on non-latin code pages.*/
            char[] encodedChars = System.Text.Encoding.Default.GetChars(System.Text.Encoding.Default.GetBytes(encodedString));

            System.Collections.ArrayList pos = new System.Collections.ArrayList();
            for (int x = 0; x < encodedChars.Length; x++)
            {
                char currentChar = encodedChars[x];
                //unprintable characters are below 0x20 in Unicode tables
                //some control characters are acceptable. (carriage return 0x0D, line feed 0x0A, horizontal tab 0x09)
                if (currentChar < 32 && (currentChar != 9 && currentChar != 10 && currentChar != 13))
                {
                    //save the array index for later replacement.
                    pos.Add(x);
                }
            }
            foreach (int index in pos)
            {
                encodedChars[index] = '?';//replace unprintable control characters with ?(3F)
            }
            return System.Text.Encoding.Default.GetString(System.Text.Encoding.Default.GetBytes(encodedChars));
        }
Example #24
0
		/// <summary>
		/// Constructs a new <code>JrpcgenVersionInfo</code> object containing
		/// information about a programs' version and a set of procedures
		/// defined by this program version.
		/// </summary>
		/// <remarks>
		/// Constructs a new <code>JrpcgenVersionInfo</code> object containing
		/// information about a programs' version and a set of procedures
		/// defined by this program version.
		/// </remarks>
		/// <param name="versionId">
		/// Identifier defined for this version of a
		/// particular ONC/RPC program.
		/// </param>
		/// <param name="versionNumber">Version number.</param>
		/// <param name="procedures">Vector of procedures defined for this ONC/RPC program.</param>
		public JrpcgenVersionInfo(string versionId, string versionNumber, System.Collections.ArrayList
			 procedures)
		{
			this.versionId = versionId;
			this.versionNumber = versionNumber;
			this.procedures = procedures;
		}
 public FrmScaffoldPowerCalculate(Framework.Entity.Chapter chapter, object type)
 {
     InitializeComponent();
     @class = type;
     templateList = contentService.GetContentTemplateByTitle(chapter.Title);
     CbxScaffoldType.SelectedIndex = 0;
 }
 protected void LoadData()
 {
     QuiTrinhDAO qtdao = new QuiTrinhDAO();
     DataTable dt = new DataTable();
     dt = qtdao.DSQuiTrinh();
     PagedDataSource pgitems = new PagedDataSource();
     System.Data.DataView dv = new System.Data.DataView(dt);
     pgitems.DataSource = dv;
     pgitems.AllowPaging = true;
     pgitems.PageSize = 15;
     pgitems.CurrentPageIndex = PageNumber;
     if (pgitems.PageCount > 1)
     {
         rptPages.Visible = true;
         System.Collections.ArrayList pages = new System.Collections.ArrayList();
         for (int i = 0; i < pgitems.PageCount; i++)
             pages.Add((i + 1).ToString());
         rptPages.DataSource = pages;
         rptPages.DataBind();
     }
     else
         rptPages.Visible = false;
     rpTinTuc.DataSource = pgitems;
     rpTinTuc.DataBind();
 }
 public MultiFormatOneDReader(System.Collections.Hashtable hints)
 {
     System.Collections.ArrayList possibleFormats = hints == null ? null : (System.Collections.ArrayList) hints[DecodeHintType.POSSIBLE_FORMATS];
     readers = new System.Collections.ArrayList();
     if (possibleFormats != null) {
       if (possibleFormats.Contains(BarcodeFormat.EAN_13) ||
           possibleFormats.Contains(BarcodeFormat.UPC_A) ||
           possibleFormats.Contains(BarcodeFormat.EAN_8) ||
           possibleFormats.Contains(BarcodeFormat.UPC_E))
       {
         readers.Add(new MultiFormatUPCEANReader(hints));
       }
       if (possibleFormats.Contains(BarcodeFormat.CODE_39)) {
           readers.Add(new Code39Reader());
       }
       if (possibleFormats.Contains(BarcodeFormat.CODE_128))
       {
           readers.Add(new Code128Reader());
       }
       if (possibleFormats.Contains(BarcodeFormat.ITF))
       {
           readers.Add(new ITFReader());
       }
     }
     if (readers.Count==0) {
         readers.Contains(new MultiFormatUPCEANReader(hints));
         readers.Contains(new Code39Reader());
         readers.Contains(new Code128Reader());
       // TODO: Add ITFReader once it is validated as production ready, and tested for performance.
       //readers.addElement(new ITFReader());
     }
 }
Example #28
0
        public void fillData()
        {
            DataTable dt = newsDao.GetListSearchByYearMonth(year, month);
            PagedDataSource pgitems = new PagedDataSource();
            System.Data.DataView dv = new System.Data.DataView(dt);
            pgitems.DataSource = dv;
            pgitems.AllowPaging = true;
            pgitems.PageSize = 20;
            if (PageNumber >= pgitems.PageCount) PageNumber = 0;
            pgitems.CurrentPageIndex = PageNumber;
            if (pgitems.PageCount > 1)
            {
                rptPages.Visible = true;
                System.Collections.ArrayList pages = new System.Collections.ArrayList();
                for (int i = 0; i < pgitems.PageCount; i++)
                    pages.Add((i + 1).ToString());
                rptPages.DataSource = pages;
                rptPages.DataBind();
            }
            else
                rptPages.Visible = false;

            repeaterList.DataSource = pgitems;
            repeaterList.DataBind();
        }
Example #29
0
		/// <summary>
		/// Construct a new <code>JrpcgenProgramInfo</code> object containing the
		/// programs's identifier and number, as well as the versions defined
		/// for this particular ONC/RPC program.
		/// </summary>
		/// <remarks>
		/// Construct a new <code>JrpcgenProgramInfo</code> object containing the
		/// programs's identifier and number, as well as the versions defined
		/// for this particular ONC/RPC program.
		/// </remarks>
		/// <param name="programId">Identifier defined for this ONC/RPC program.</param>
		/// <param name="programNumber">Program number assigned to this ONC/RPC program.</param>
		/// <param name="versions">Vector of versions defined for this ONC/RPC program.</param>
		public JrpcgenProgramInfo(string programId, string programNumber, System.Collections.ArrayList
			 versions)
		{
			this.programId = programId;
			this.programNumber = programNumber;
			this.versions = versions;
		}
Example #30
0
        /// <summary>
        /// Anche nelle sottodirectory
        /// </summary>
        /// <param name="path"></param>
        /// <param name="pattern"></param>
        /// <returns></returns>
        public static System.Collections.ArrayList GetFiles(string path, string pattern)
        {
            System.Collections.ArrayList list = new System.Collections.ArrayList();
            try
            {
                list.AddRange(System.IO.Directory.GetFiles(path, pattern));
            }
            catch { }

            string[] dirs = null;
            try
            {
                dirs = System.IO.Directory.GetDirectories(path);
            }
            catch { }

            if (dirs != null)
            {
                foreach (string dir in dirs)
                {
                    list.AddRange(GetFiles(dir, pattern));
                }
            }
            return list;
        }
Example #31
0
        public virtual string AttemptFindId(string name, int?year, string language)
        {
            string id          = null;
            string matchedName = null;
            string url3        = string.Format(search3, UrlEncode(name), ApiKey, language);
            var    json        = Helper.ToJsonDict(Helper.FetchJson(url3));

            List <string> possibleTitles = new List <string>();

            if (json != null)
            {
                System.Collections.ArrayList results = (System.Collections.ArrayList)json["results"];
                if (results == null || results.Count == 0)
                {
                    //try replacing numbers
                    foreach (var pair in ReplaceStartNumbers)
                    {
                        if (name.StartsWith(pair.Key))
                        {
                            name = name.Remove(0, pair.Key.Length);
                            name = pair.Value + name;
                        }
                    }
                    foreach (var pair in ReplaceEndNumbers)
                    {
                        if (name.EndsWith(pair.Key))
                        {
                            name = name.Remove(name.IndexOf(pair.Key), pair.Key.Length);
                            name = name + pair.Value;
                        }
                    }
                    Logger.ReportInfo("MovieDBProvider - No results.  Trying replacement numbers: " + name);
                    url3    = string.Format(search3, UrlEncode(name), ApiKey, language);
                    json    = Helper.ToJsonDict(Helper.FetchJson(url3));
                    results = (System.Collections.ArrayList)json["results"];
                }
                if (results != null)
                {
                    string compName = GetComparableName(name);
                    foreach (Dictionary <string, object> possible in results)
                    {
                        matchedName = null;
                        id          = possible["id"].ToString();
                        string n = (string)possible["title"];
                        if (GetComparableName(n) == compName)
                        {
                            matchedName = n;
                        }
                        else
                        {
                            n = (string)possible["original_title"];
                            if (GetComparableName(n) == compName)
                            {
                                matchedName = n;
                            }
                        }

                        Logger.ReportVerbose("MovieDbProvider - " + compName + " didn't match " + n);
                        //if main title matches we don't have to look for alternatives
                        if (matchedName == null)
                        {
                            //that title didn't match - look for alternatives
                            url3 = string.Format(altTitleSearch, id, ApiKey, Kernel.Instance.ConfigData.MetadataCountryCode);
                            string resp     = Helper.FetchJson(url3);
                            var    response = Helper.ToJsonDict(resp);
                            //Logger.ReportVerbose("Alt Title response: " + resp);
                            if (response != null)
                            {
                                try
                                {
                                    System.Collections.ArrayList altTitles = (System.Collections.ArrayList)response["titles"];
                                    foreach (Dictionary <string, object> title in altTitles)
                                    {
                                        string t = GetComparableName((string)((Dictionary <string, object>)title).GetValueOrDefault("title", ""));
                                        if (t == compName)
                                        {
                                            Logger.ReportVerbose("MovieDbProvider - " + compName + " matched " + t);
                                            matchedName = t;
                                            break;
                                        }
                                        else
                                        {
                                            Logger.ReportVerbose("MovieDbProvider - " + compName + " did not match " + t);
                                        }
                                    }
                                }
                                catch (Exception e)
                                {
                                    Logger.ReportException("MovieDbProvider - Error in alternate title search.", e);
                                }
                            }
                        }

                        if (matchedName != null)
                        {
                            Logger.ReportVerbose("Match " + matchedName + " for " + name);
                            if (year != null)
                            {
                                DateTime r;
                                DateTime.TryParse(possible["release_date"].ToString(), out r);
                                if ((r != null))
                                {
                                    if (Math.Abs(r.Year - year.Value) > 1) // allow a 1 year tolerance on release date
                                    {
                                        Logger.ReportVerbose("Result " + matchedName + " released on " + r + " did not match year " + year);
                                        continue;
                                    }
                                }
                            }
                            //matched name and year
                            return(matchedName != null ? id : null);
                        }
                    }
                }
            }
            return(null);
        }
 public static System.Collections.ArrayList Synchronized(System.Collections.ArrayList list)
 {
     throw null;
 }
Example #33
0
        protected virtual void ProcessMainInfo(string json)
        {
            var    jsonDict = Helper.ToJsonDict(json);
            IMovie movie    = Item as IMovie;

            if (jsonDict != null)
            {
                movie.Name     = (string)jsonDict.GetValueOrDefault <string, object>("title", null) ?? (string)jsonDict.GetValueOrDefault <string, object>("name", null);
                movie.Overview = (string)jsonDict.GetValueOrDefault <string, object>("overview", "");
                movie.Overview = movie.Overview != null?movie.Overview.Replace("\n\n", "\n") : null;

                movie.TagLine = (string)jsonDict.GetValueOrDefault <string, object>("tagline", "");
                movie.ImdbID  = (string)jsonDict.GetValueOrDefault <string, object>("imdb_id", "");
                movie.TmdbID  = moviedbId;
                float  rating;
                string voteAvg    = jsonDict.GetValueOrDefault <string, object>("vote_average", "").ToString();
                string cultureStr = Kernel.Instance.ConfigData.PreferredMetaDataLanguage + "-" + Kernel.Instance.ConfigData.MetadataCountryCode;
                System.Globalization.CultureInfo culture;
                try
                {
                    culture = new System.Globalization.CultureInfo(cultureStr);
                }
                catch
                {
                    culture = System.Globalization.CultureInfo.CurrentCulture; //default to windows settings if other was invalid
                }
                Logger.ReportVerbose("Culture for numeric conversion is: " + culture.Name);
                if (float.TryParse(voteAvg, System.Globalization.NumberStyles.AllowDecimalPoint, culture, out rating))
                {
                    movie.ImdbRating = rating;
                }

                //release date and certification are retrieved based on configured country
                System.Collections.ArrayList releases = (System.Collections.ArrayList)jsonDict.GetValueOrDefault <string, object>("countries", null);
                if (releases != null)
                {
                    string usRelease = null, usCert = null;
                    string ourRelease = null, ourCert = null;
                    string ourCountry = Kernel.Instance.ConfigData.MetadataCountryCode;
                    foreach (Dictionary <string, object> release in releases)
                    {
                        string country = (string)release.GetValueOrDefault <string, object>("iso_3166_1", null);
                        //grab the us info so we can default to it if need be
                        if (country == "US")
                        {
                            usRelease = (string)release.GetValueOrDefault <string, object>("release_date", "");
                            usCert    = (string)release.GetValueOrDefault <string, object>("certification", "");
                        }
                        if (ourCountry != "US")
                        {
                            if (country == ourCountry)
                            {
                                ourRelease = (string)release.GetValueOrDefault <string, object>("release_date", "");
                                ourCert    = (string)release.GetValueOrDefault <string, object>("certification", "");
                            }
                        }
                    }

                    if (!string.IsNullOrEmpty(ourRelease))
                    {
                        movie.ProductionYear = Int32.Parse(ourRelease.Substring(0, 4));
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(usRelease))
                        {
                            movie.ProductionYear = Int32.Parse(usRelease.Substring(0, 4));
                        }
                    }
                    if (!string.IsNullOrEmpty(ourCert))
                    {
                        movie.MpaaRating = ourCountry + "-" + ourCert;
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(usCert))
                        {
                            movie.MpaaRating = usCert;
                        }
                    }
                }

                //if that still didn't find a rating and we are a boxset, use the one from our first child
                if (movie.MpaaRating == null && movie is BoxSet)
                {
                    var boxset = movie as BoxSet;
                    if (boxset != null)
                    {
                        Logger.ReportInfo("MovieDbProvider - Using rating of first child of boxset...");
                        boxset.MpaaRating = boxset.Children.Count > 0 ? boxset.Children[0].OfficialRating : null;
                    }
                }

                //mediainfo should override this metadata
                if (movie.MediaInfo != null && movie.MediaInfo.RunTime > 0)
                {
                    movie.RunningTime = movie.MediaInfo.RunTime;
                }
                else
                {
                    int runtime;
                    if (Int32.TryParse(jsonDict.GetValueOrDefault <string, object>("runtime", "").ToString(), out runtime))
                    {
                        movie.RunningTime = runtime;
                    }
                }

                //studios
                System.Collections.ArrayList studios = (System.Collections.ArrayList)jsonDict.GetValueOrDefault <string, object>("production_companies", null);
                if (studios != null)
                {
                    //always clear so they don't double up
                    movie.Studios = new List <string>();
                    foreach (Dictionary <string, object> studio in studios)
                    {
                        string name = (string)studio.GetValueOrDefault <string, object>("name", "");
                        if (name != null)
                        {
                            movie.Studios.Add(name);
                        }
                    }
                }

                //genres
                System.Collections.ArrayList genres = (System.Collections.ArrayList)jsonDict.GetValueOrDefault <string, object>("genres", null);
                if (genres != null)
                {
                    //always clear so they don't double up
                    movie.Genres = new List <string>();
                    foreach (Dictionary <string, object> genre in genres)
                    {
                        string name = (string)genre.GetValueOrDefault <string, object>("name", "");
                        if (name != null)
                        {
                            movie.Genres.Add(name);
                        }
                    }
                }

                //we will need this if we save people images
                string tmdbImageUrl = Kernel.Instance.ConfigData.TmdbImageUrl + Kernel.Instance.ConfigData.FetchedProfileSize;

                //actors
                System.Collections.ArrayList cast         = (System.Collections.ArrayList)jsonDict.GetValueOrDefault <string, object>("cast", null);
                SortedList <int, Actor>      sortedActors = new SortedList <int, Actor>();
                if (cast != null)
                {
                    // always clear so they don't double up
                    movie.Actors = new List <Actor>();
                    foreach (Dictionary <string, object> person in cast)
                    {
                        string name = (string)person.GetValueOrDefault <string, object>("name", "");
                        string role = (string)person.GetValueOrDefault <string, object>("character", "");
                        if (name != null)
                        {
                            try
                            {
                                sortedActors.Add(Convert.ToInt32(person["order"].ToString()), new Actor()
                                {
                                    Name = name, Role = role
                                });
                            }
                            catch (ArgumentException e)
                            {
                                Logger.ReportException("Actor " + name + " has duplicate order of " + person["order"].ToString() + " in tmdb data.", e);
                            }
                            if (Kernel.Instance.ConfigData.DownloadPeopleImages && person["profile_path"] != null && !File.Exists(Path.Combine(ApplicationPaths.AppIBNPath, "People/" + name) + "/folder.jpg"))
                            {
                                try
                                {
                                    string dir = Path.Combine(ApplicationPaths.AppIBNPath, "People/" + name);
                                    if (!Directory.Exists(dir))
                                    {
                                        Directory.CreateDirectory(dir);
                                    }
                                    DownloadAndSaveImage(tmdbImageUrl + (string)person["profile_path"], dir, "folder");
                                }
                                catch (Exception e)
                                {
                                    Logger.ReportException("Error attempting to download/save actor image", e);
                                }
                            }
                        }
                    }
                    //now add them to movie in proper order
                    movie.Actors.AddRange(sortedActors.Values);
                }

                //directors and writers are both in "crew"
                System.Collections.ArrayList crew = (System.Collections.ArrayList)jsonDict.GetValueOrDefault <string, object>("crew", null);
                if (crew != null)
                {
                    //always clear these so they don't double up
                    movie.Directors = new List <string>();
                    movie.Writers   = new List <string>();
                    foreach (Dictionary <string, object> person in crew)
                    {
                        string name = (string)person["name"];
                        string job  = (string)person["job"];
                        if (name != null)
                        {
                            switch (job)
                            {
                            case "Director":
                                movie.Directors.Add(name);
                                break;

                            case "Screenplay":
                                movie.Writers.Add(name);
                                break;
                            }
                        }
                    }
                }
            }
        }
 public static System.Collections.ArrayList FixedSize(System.Collections.ArrayList list)
 {
     throw null;
 }
Example #35
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="infoUtente"></param>
        /// <param name="trasmissione"></param>
        /// <param name="corr"></param>
        /// <param name="ragione"></param>
        /// <param name="note"></param>
        /// <param name="tipoTrasm"></param>
        /// <param name="scadenza"></param>
        /// <returns></returns>
        protected DocsPaVO.trasmissione.Trasmissione AddTrasmissioneSingola(
            DocsPaVO.utente.InfoUtente infoUtente,
            DocsPaVO.trasmissione.Trasmissione trasmissione,
            DocsPaVO.utente.Corrispondente corr,
            DocsPaVO.trasmissione.RagioneTrasmissione ragione,
            string note,
            string tipoTrasm,
            int scadenza)
        {
            if (trasmissione.trasmissioniSingole != null)
            {
                // controllo se esiste la trasmissione singola associata a corrispondente selezionato

                foreach (DocsPaVO.trasmissione.TrasmissioneSingola ts in trasmissione.trasmissioniSingole)
                {
                    if (ts.corrispondenteInterno.systemId.Equals(corr.systemId))
                    {
                        if (ts.daEliminare)
                        {
                            ts.daEliminare = false;
                            return(trasmissione);
                        }
                        else
                        {
                            return(trasmissione);
                        }
                    }
                }
            }

            // Aggiungo la trasmissione singola
            DocsPaVO.trasmissione.TrasmissioneSingola trasmissioneSingola = new DocsPaVO.trasmissione.TrasmissioneSingola();
            trasmissioneSingola.tipoTrasm             = tipoTrasm;
            trasmissioneSingola.corrispondenteInterno = corr;
            trasmissioneSingola.ragione     = ragione;
            trasmissioneSingola.noteSingole = note;
            //Imposto la data di scadenza
            if (scadenza > 0)
            {
                string          dataScadenza = "";
                System.DateTime data         = System.DateTime.Now.AddDays(scadenza);
                dataScadenza = data.Day + "/" + data.Month + "/" + data.Year;
                trasmissioneSingola.dataScadenza = dataScadenza;
            }

            // Aggiungo la lista di trasmissioniUtente
            if (corr is DocsPaVO.utente.Ruolo)
            {
                trasmissioneSingola.tipoDest = DocsPaVO.trasmissione.TipoDestinatario.RUOLO;

                DocsPaVO.utente.Corrispondente[] listaUtenti = GetUtenti(infoUtente, corr);

                if (listaUtenti.Length == 0)
                {
                    trasmissioneSingola = null;
                }

                //ciclo per utenti se dest è gruppo o ruolo
                for (int i = 0; i < listaUtenti.Length; i++)
                {
                    DocsPaVO.trasmissione.TrasmissioneUtente trasmissioneUtente = new DocsPaVO.trasmissione.TrasmissioneUtente();
                    trasmissioneUtente.utente = (DocsPaVO.utente.Utente)listaUtenti[i];
                    trasmissioneSingola.trasmissioneUtente.Add(trasmissioneUtente);
                }
            }

            if (corr is DocsPaVO.utente.Utente)
            {
                trasmissioneSingola.tipoDest = DocsPaVO.trasmissione.TipoDestinatario.UTENTE;
                DocsPaVO.trasmissione.TrasmissioneUtente trasmissioneUtente = new DocsPaVO.trasmissione.TrasmissioneUtente();
                trasmissioneUtente.utente = (DocsPaVO.utente.Utente)corr;
                trasmissioneSingola.trasmissioneUtente.Add(trasmissioneUtente);
            }

            if (corr is DocsPaVO.utente.UnitaOrganizzativa)
            {
                DocsPaVO.utente.UnitaOrganizzativa theUo = (DocsPaVO.utente.UnitaOrganizzativa)corr;
                DocsPaVO.addressbook.QueryCorrispondenteAutorizzato qca = new DocsPaVO.addressbook.QueryCorrispondenteAutorizzato();
                qca.ragione = trasmissioneSingola.ragione;
                qca.ruolo   = trasmissione.ruolo;

                System.Collections.ArrayList ruoli = BusinessLogic.Utenti.addressBookManager.getRuoliRiferimentoAutorizzati(qca, theUo);
                foreach (DocsPaVO.utente.Ruolo r in ruoli)
                {
                    trasmissione = AddTrasmissioneSingola(infoUtente, trasmissione, r, ragione, note, tipoTrasm, scadenza);
                }

                return(trasmissione);
            }

            if (trasmissioneSingola != null)
            {
                trasmissione.trasmissioniSingole.Add(trasmissioneSingola);
            }

            return(trasmissione);
        }
Example #36
0
 public static bool showUnusedAttributeWarning(Element e, System.Collections.ArrayList usedAtts)
 {
     return(getUnusedAttributes(e, usedAtts).size() > 0);
 }
 public static System.Collections.ArrayList ReadOnly(System.Collections.ArrayList list)
 {
     throw null;
 }
Example #38
0
        /// <summary> Return a array of SourceFiles whose names match
        /// the specified string. The array is sorted by name.
        /// The input can be mx.controls.xxx which will
        /// </summary>
        public virtual SourceFile[] getFiles(String matchString)
        {
            bool doStartsWith = false;
            bool doIndexOf    = false;
            bool doEndsWith   = false;

            bool leadingAsterisk  = matchString.StartsWith("*") && matchString.Length > 1; //$NON-NLS-1$
            bool trailingAsterisk = matchString.EndsWith("*");                             //$NON-NLS-1$
            bool usePath          = matchString.IndexOf('.') > -1;

            if (leadingAsterisk && trailingAsterisk)
            {
                matchString = matchString.Substring(1, (matchString.Length - 1) - (1));
                doIndexOf   = true;
            }
            else if (leadingAsterisk)
            {
                matchString = matchString.Substring(1);
                doEndsWith  = true;
            }
            else if (trailingAsterisk)
            {
                matchString  = matchString.Substring(0, (matchString.Length - 1) - (0));
                doStartsWith = true;
            }
            else if (usePath)
            {
                doIndexOf = true;
            }
            else
            {
                doStartsWith = true;
            }

            SourceFile[] files = FileList;
            System.Collections.ArrayList fileList = new System.Collections.ArrayList();
            int n          = files.Length;
            int exactHitAt = -1;
            // If the matchString already starts with "." (e.g. ".as" or ".mxml"), then dotMatchString
            // will be equal to matchString; otherwise, dotMatchString will be "." + matchString
            String dotMatchString = (matchString.StartsWith("."))?matchString:("." + matchString);             //$NON-NLS-1$ //$NON-NLS-2$

            for (int i = 0; i < n; i++)
            {
                SourceFile sourceFile = files[i];
                bool       pathExists = (usePath && new System.Text.RegularExpressions.Regex(@".*[/\\].*").Match(sourceFile.FullPath).Success); //$NON-NLS-1$
                String     name       = pathExists?sourceFile.FullPath:sourceFile.Name;

                // if we are using the full path string, then prefix a '.' to our matching string so that abc.as and Gabc.as don't both hit
                String match = (usePath && pathExists)?dotMatchString:matchString;

                name = name.Replace('/', '.');                 // get rid of path identifiers and use dots
                name = name.Replace('\\', '.');                // would be better to modify the input string, but we don't know which path char will be used.

                // exact match? We are done
                if (name.Equals(match))
                {
                    exactHitAt = i;
                    break;
                }
                else if (doStartsWith && name.StartsWith(match))
                {
                    fileList.Add(sourceFile);
                }
                else if (doEndsWith && name.EndsWith(match))
                {
                    fileList.Add(sourceFile);
                }
                else if (doIndexOf && name.IndexOf(match) > -1)
                {
                    fileList.Add(sourceFile);
                }
            }

            // trim all others if we have an exact file match
            if (exactHitAt > -1)
            {
                fileList.Clear();
                fileList.Add(files[exactHitAt]);
            }

            SourceFile[] fileArray = (SourceFile[])SupportClass.ICollectionSupport.ToArray(fileList, new SourceFile[fileList.Count]);
            ArrayUtil.sort(fileArray, this);
            return(fileArray);
        }
 void IUserPrincipalModel.SetPermissions(System.Collections.ArrayList permissionSets)
 {
     this.SetPermissions(permissionSets);
 }
        private void ParseFieldList(string FieldList, bool AllowRelation)
        {
            /*
             * This code parses FieldList into FieldInfo objects  and then
             * adds them to the m_FieldInfo private member
             *
             * FieldList systax:  [relationname.]fieldname[ alias], ...
             */
            if (m_FieldList == FieldList)
            {
                return;
            }
            m_FieldInfo = new System.Collections.ArrayList();
            m_FieldList = FieldList;
            FieldInfo Field; string[] FieldParts; string[] Fields = FieldList.Split(',');
            int       i;

            for (i = 0; i <= Fields.Length - 1; i++)
            {
                Field = new FieldInfo();
                //parse FieldAlias
                FieldParts = Fields[i].Trim().Split(' ');
                switch (FieldParts.Length)
                {
                case 1:
                    //to be set at the end of the loop
                    break;

                case 2:
                    Field.FieldAlias = FieldParts[1];
                    break;

                default:
                    throw new Exception("Too many spaces in field definition: '" + Fields[i] + "'.");
                }
                //parse FieldName and RelationName
                FieldParts = FieldParts[0].Split('.');
                switch (FieldParts.Length)
                {
                case 1:
                    Field.FieldName = FieldParts[0];
                    break;

                case 2:
                    if (AllowRelation == false)
                    {
                        throw new Exception("Relation specifiers not permitted in field list: '" + Fields[i] + "'.");
                    }
                    Field.RelationName = FieldParts[0].Trim();
                    Field.FieldName    = FieldParts[1].Trim();
                    break;

                default:
                    throw new Exception("Invalid field definition: " + Fields[i] + "'.");
                }
                if (Field.FieldAlias == null)
                {
                    Field.FieldAlias = Field.FieldName;
                }
                m_FieldInfo.Add(Field);
            }
        }
Example #41
0
        public Model.Table[] GetTables()
        {
            string sql = string.Format(@"SELECT TABLE_NAME,
		                                        (
			                                        SELECT
			                                        CAST(
			                                         CASE 
				                                        WHEN tbl.is_ms_shipped = 1 THEN 1
				                                        WHEN (
					                                        SELECT 
						                                        major_id 
					                                        FROM 
						                                        sys.extended_properties 
					                                        WHERE 
						                                        major_id = tbl.object_id and 
						                                        minor_id = 0 and 
						                                        class = 1 and 
						                                        name = N'microsoft_database_tools_support') 
					                                        IS NOT NULL THEN 1
				                                        ELSE 0
			                                        END          
						                                         AS bit) AS [IsSystemObject]
			                                        FROM
			                                        sys.tables AS tbl
			                                        WHERE
			                                        (tbl.name = T.TABLE_NAME and SCHEMA_NAME(tbl.schema_id)=N'dbo')
		                                        ) AS IsSystemObject
                                        FROM INFORMATION_SCHEMA.TABLES T
                                        WHERE TABLE_TYPE = 'BASE TABLE'
                                        ORDER BY T.TABLE_NAME", DatabaseName);

            System.Collections.ArrayList        arrTableNames = new System.Collections.ArrayList();
            System.Data.SqlClient.SqlDataReader dr            = null;

            try
            {
                dr = RunQuerySqlClient(sql);
                bool isSystemObject;
                int  isSysObjectColumnOrdinal = dr.GetOrdinal("IsSystemObject");

                while (dr.Read())
                {
                    isSystemObject = dr.IsDBNull(isSysObjectColumnOrdinal) ? false : (bool)dr[isSysObjectColumnOrdinal];

                    if (!isSystemObject || Model.Database.IncludeSystemObjects)
                    {
                        arrTableNames.Add((string)dr["TABLE_NAME"]);
                    }
                }
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
            }
            List <Model.Table> tables = new List <Model.Table>();

            for (int i = 0; i < arrTableNames.Count; i++)
            {
                Model.Table table = GetNewTable((string)arrTableNames[i]);
                tables.Add(table);
            }
            return((Model.Table[])tables.ToArray());
        }
Example #42
0
        /// <summary>
        /// Создает  массив, в котором располагаются операторы и символы представленные в обратной польской записи (безскобочной)
        /// На этом же этапе отлавливаются почти все остальные ошибки (см код). По сути - это компиляция.
        /// </summary>
        /// <returns>массив обратной польской записи</returns>
        public static System.Collections.ArrayList CreateStack()
        {
            //Собственно результирующий массив
            System.Collections.ArrayList strarr = new System.Collections.ArrayList(30);
            //Стек с операторами где они временно храняться
            System.Collections.Stack operators = new System.Collections.Stack(15);
            string expr = expression;

            //пооператорная обработка выражения
            while (expr != "")
            {
                string op = expr.Substring(0, expr.IndexOf(" "));
                expr = expr.Substring(expr.IndexOf(" ") + 1);
                switch (op)
                {
                case "(":     //1
                {
                    //Кладем в стэк
                    operators.Push(op);
                    break;
                }

                case "m":     //4
                {
                    //вытаскиваем из стека все операторы чей приоритет больше либо равен унарному минусу
                    while (operators.Count != 0 && (operators.Peek().ToString() == "m" || operators.Peek().ToString() == "p"))
                    {
                        if (strarr.Capacity > strarr.Count)
                        {
                            strarr.Add(operators.Pop());
                        }
                        else
                        {
                            // переполнгение стека - возвращем null
                            return(null);
                        }
                    }
                    operators.Push(op);
                    break;
                }

                case "p":     //4
                {
                    while (operators.Count != 0 && (operators.Peek().ToString() == "m" || operators.Peek().ToString() == "p"))
                    {
                        if (strarr.Capacity > strarr.Count)
                        {
                            strarr.Add(operators.Pop());
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    operators.Push(op);
                    break;
                }

                case "*":     //3
                {
                    while (operators.Count != 0 && (operators.Peek().ToString() == "*" || operators.Peek().ToString() == "/" || operators.Peek().ToString() == "mod" || operators.Peek().ToString() == "m" || operators.Peek().ToString() == "p"))
                    {
                        if (strarr.Capacity > strarr.Count)
                        {
                            strarr.Add(operators.Pop());
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    operators.Push(op);
                    break;
                }

                case "/":     //3
                {
                    while (operators.Count != 0 && (operators.Peek().ToString() == "*" || operators.Peek().ToString() == "/" || operators.Peek().ToString() == "mod" || operators.Peek().ToString() == "m" || operators.Peek().ToString() == "p"))
                    {
                        if (strarr.Capacity > strarr.Count)
                        {
                            strarr.Add(operators.Pop());
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    operators.Push(op);
                    break;
                }

                case "mod":     //3
                {
                    while (operators.Count != 0 && (operators.Peek().ToString() == "*" || operators.Peek().ToString() == "/" || operators.Peek().ToString() == "mod" || operators.Peek().ToString() == "m" || operators.Peek().ToString() == "p"))
                    {
                        if (strarr.Capacity > strarr.Count)
                        {
                            strarr.Add(operators.Pop());
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    operators.Push(op);
                    break;
                }

                case "+":     //2
                {
                    while (operators.Count != 0 && (operators.Peek().ToString() == "*" || operators.Peek().ToString() == "/" || operators.Peek().ToString() == "mod" || operators.Peek().ToString() == "+" || operators.Peek().ToString() == "-" || operators.Peek().ToString() == "m" || operators.Peek().ToString() == "p"))
                    {
                        if (strarr.Capacity > strarr.Count)
                        {
                            strarr.Add(operators.Pop());
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    operators.Push(op);
                    break;
                }

                case "-":     //2
                {
                    while (operators.Count != 0 && (operators.Peek().ToString() == "*" || operators.Peek().ToString() == "/" || operators.Peek().ToString() == "mod" || operators.Peek().ToString() == "+" || operators.Peek().ToString() == "-" || operators.Peek().ToString() == "m" || operators.Peek().ToString() == "p"))
                    {
                        if (strarr.Capacity > strarr.Count)
                        {
                            strarr.Add(operators.Pop());
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    operators.Push(op);
                    break;
                }

                case ")":
                {
                    while (operators.Peek().ToString() != "(")
                    {
                        if (strarr.Capacity > strarr.Count)
                        {
                            strarr.Add(operators.Pop());
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    operators.Pop();
                    break;
                }

                default:
                {
                    //на входе - число - помещаем в выходной массив
                    if (strarr.Capacity > strarr.Count)
                    {
                        strarr.Add(op);
                    }
                    else
                    {
                        return(null);
                    }
                    break;
                }
                }
            }
            //записываем все что осталовь в стеке в выходной массив
            while (operators.Count != 0)
            {
                strarr.Add(operators.Pop());
            }
            return(strarr);
        }
        private void ParseGroupByFieldList(string FieldList)
        {
            /*
             * Parses FieldList into FieldInfo objects and adds them to the GroupByFieldInfo private member
             *
             * FieldList syntax: fieldname[ alias]|operatorname(fieldname)[ alias],...
             *
             * Supported Operators: count,sum,max,min,first,last
             */
            if (GroupByFieldList == FieldList)
            {
                return;
            }
            GroupByFieldInfo = new System.Collections.ArrayList();
            FieldInfo Field; string[] FieldParts; string[] Fields = FieldList.Split(',');

            for (int i = 0; i <= Fields.Length - 1; i++)
            {
                Field = new FieldInfo();
                //Parse FieldAlias
                FieldParts = Fields[i].Trim().Split(' ');
                switch (FieldParts.Length)
                {
                case 1:
                    //to be set at the end of the loop
                    break;

                case 2:
                    Field.FieldAlias = FieldParts[1];
                    break;

                default:
                    throw new ArgumentException("Too many spaces in field definition: '" + Fields[i] + "'.");
                }
                //Parse FieldName and Aggregate
                FieldParts = FieldParts[0].Split('(');
                switch (FieldParts.Length)
                {
                case 1:
                    Field.FieldName = FieldParts[0];
                    break;

                case 2:
                    Field.Aggregate = FieldParts[0].Trim().ToLower();        //we're doing a case-sensitive comparison later
                    Field.FieldName = FieldParts[1].Trim(' ', ')');
                    break;

                default:
                    throw new ArgumentException("Invalid field definition: '" + Fields[i] + "'.");
                }
                if (Field.FieldAlias == null)
                {
                    if (Field.Aggregate == null)
                    {
                        Field.FieldAlias = Field.FieldName;
                    }
                    else
                    {
                        Field.FieldAlias = Field.Aggregate + "of" + Field.FieldName;
                    }
                }
                GroupByFieldInfo.Add(Field);
            }
            GroupByFieldList = FieldList;
        }