Exemple #1
0
            public void Add(object value)
            {
                if (this.value == null)
                {
                    this.value = new ArrayList();
                }
                string strType = value.GetType().ToString();

                if (value is string)
                {
                    this.value.Add((String)value.ToString());
                }
                else if (value is int)
                {
                    this.value.Add(new integer((int)value));
                }
                else if (value is uint)
                {
                    this.value.Add(new integer((int)(uint)value));
                }
                else if (value is double)
                {
                    this.value.Add(new Float((double)value));
                }
                else
                {
                    this.value.Add(value);
                }
            }
 public bool IgnoreNotice(List<ArrivalNoticeQuery> list)
 {
     ArrayList arrList = new ArrayList();
     string mailBody = string.Empty;
     MailHelper mailHelper = new MailHelper();
     try
     {
         for (int i = 0; i < list.Count; i++)
         {
             arrList.Add(_IArrivalNoticeDao.IgnoreNotice(list[i]));
         }
         //_mysqlDao.ExcuteSqls(arrList)
         if (_mysqlDao.ExcuteSqls(arrList))
         {
             return true;
         }
         else
         {
             return false;
         }
      
     }
     catch (Exception ex)
     {
         throw new Exception("ArrivalNoticeMgr-->IgnoreNotice-->" + arrList.ToString() + ex.Message, ex);
     }
 }
Exemple #3
0
        /// <summary>
        /// Returns the shape indexes of the polygons falling in the specified polygon.
        /// </summary>
        /// <returns>True if some are found.</returns>
        public static bool SelectPolygonsWithPolygon(ref MapWinGIS.Shapefile inputSF, ref MapWinGIS.Shape polygon, ref System.Collections.ArrayList results)
        {
            MapWinUtility.Logger.Dbg("SelectPolygonsWithPolygon(inputSF: " + Macro.ParamName(inputSF) + ", \n" +
                                     "                          polygon: " + Macro.ParamName(polygon) + ", \n" +
                                     "                          results: " + results.ToString() + ")");
            int numShapes = inputSF.NumShapes;

            results = new System.Collections.ArrayList();

            for (int i = 0; i <= numShapes - 1; i++)
            {
                MapWinGIS.Shape currShape = new MapWinGIS.ShapeClass();
                currShape = inputSF.get_Shape(i);
                bool boundsIntersect = Globals.CheckBounds(ref currShape, ref polygon);
                if (boundsIntersect)
                {
                    //check that actual intersection occurs
                    MapWinGIS.Shape intersectShp = new MapWinGIS.ShapeClass();
                    intersectShp = SpatialOperations.Intersection(currShape, polygon);
                    if (intersectShp.numPoints > 0)
                    {
                        //shape has at least a small portion inside polygon
                        results.Add(i);
                    } //end of checking for intersection
                }     //end of checking bounds
            }         //end of looping through shapes
            MapWinUtility.Logger.Dbg("Finished SelectPolygonWithPolygon");
            return(results.Count > 0);
        }
Exemple #4
0
 public bool DeleteMailGroup(List<MailGroupQuery> list)
 {
     ArrayList arrayList = new ArrayList();
     try
     {
         for (int i = 0; i < list.Count; i++)
         {
             arrayList.Add(_IMailGroupDao.DeleteMailGroup(list[i]));
         }
         return _mysqlDao.ExcuteSqls(arrayList);
     }
     catch (Exception ex)
     {
         throw new Exception("MailGroupMgr-->DeleteMailGroup-->"+arrayList.ToString()+ ex.Message, ex);
     }
 }
        public void AssignCountry(int TourId, ArrayList Country)
        {
            TourmasterStoreprocedures objempentity = new TourmasterStoreprocedures();
            objempentity.AssignCountry(TourId, Country.ToString());

        }
 public bool UpdateByVendor(List<Model.PriceMasterTemp> priceMasterTempList, List<ItemPrice> itemPrices)
 {
     ArrayList sqls = new ArrayList();
     try
     {
         if (priceMasterTempList != null)
         {
             foreach (var item in priceMasterTempList)
             {
                 sqls.Add(_priceMasterTempDao.UpdateByVendor(item));
             }
         }
         //if (itemPrices != null)
         //{
         //    ItemPriceTempMgr itemPriceTempMgr = new ItemPriceTempMgr("");
         //    foreach (var item in itemPrices)
         //    {
         //        sqls.Add(itemPriceTempMgr.Update(item));
         //    }
         //}
         MySqlDao mySqlDao = new MySqlDao(connctionString);
         return mySqlDao.ExcuteSqls(sqls);
     }
     catch (Exception ex)
     {
         throw new Exception("PriceMasterTempMgr-->UpdateByVendor-->" + ex.Message + sqls.ToString(), ex);
     }
 }
        public bool SaveByVendor(List<Model.PriceMasterTemp> priceMasterTempList, List<List<ItemPrice>> itemPrices, ArrayList others)
        {
            if (priceMasterTempList == null)
            {
                return false;
            }
            if (itemPrices != null && itemPrices.Count > 0 && priceMasterTempList.Count != itemPrices.Count)
            {
                return false;
            }
            ArrayList sqls = new ArrayList();
            ArrayList prices = new ArrayList();
            try
            {
                ItemPriceTempMgr itemPriceTempMgr = new ItemPriceTempMgr("");
                foreach (var item in priceMasterTempList)
                {
                    sqls.Add(_priceMasterTempDao.SaveByVendor(item));

                    //if (itemPrices != null && itemPrices.Count > 0)
                    //{
                    //    ArrayList price = new ArrayList();
                    //    List<ItemPrice> items = itemPrices[priceMasterTempList.IndexOf(item)];
                    //    if (items != null)
                    //    {
                    //        foreach (var tp in items)
                    //        {
                    //            price.Add(itemPriceTempMgr.Save(tp));
                    //        }
                    //    }
                    //    prices.Add(price);
                    //}
                }
                return _priceMasterTempDao.Save(sqls, prices, others);
            }
            catch (Exception ex)
            {
                throw new Exception("PriceMasterTempMgr-->SaveByVendor-->" + ex.Message + sqls.ToString(), ex);
            }
        }
        /// <summary>
        /// 刪除組合商品的父商品和子商品價格數據
        /// </summary>
        /// <param name="delTemp"></param>
        /// <returns></returns>
        public bool comboPriceDeleteByVendor(ProductComboTemp delTemp)
        {
            ArrayList sqls = new ArrayList();
            try
            {
                //刪除item_price_temp子商品的數據中的數據
                ItemPriceTempMgr itemPriceMgr = new ItemPriceTempMgr("");
                sqls.Add(itemPriceMgr.DeleteByVendor(delTemp.Parent_Id, delTemp.Combo_Type, delTemp.Writer_Id));

                //刪除price_master_temp中的數據
                PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr("");
                sqls.Add(priceMasterTempMgr.DeleteByVendor(new PriceMasterTemp { writer_Id = delTemp.Writer_Id, product_id = delTemp.Parent_Id, combo_type = delTemp.Combo_Type }));

                return _mySql.ExcuteSqls(sqls);
            }
            catch (Exception ex)
            {
                throw new Exception("ProductComboTempMgr.comboPriceDeleteByVendor-->" + ex.Message + sqls.ToString(), ex);
            }
        }
 public bool CancelOrder(List<TicketMasterQuery> list)
 {
     ArrayList arrList = new ArrayList();
     try
     {
         for (int i = 0; i < list.Count; i++)
         {
             arrList.Add(_tmDao.CancelOrderTM(list[i]));
             arrList.Add(_tmDao.CancelOrderTD(list[i]));
         }
       return     _tmDao.ExecSql(arrList);
     }
     catch(Exception ex)
     {
         throw new Exception("MailGroupMgr-->CancelOrder-->" + arrList.ToString() + ex.Message, ex);
     }
 }
		protected virtual void InsertCreated(object forObj, int exceptionLimit)
		{
			this.Context.LogManager.Debug(this, "Inserting objects that are up for creation", "");	 // do not localize			

			try
			{
				long cnt;
				int cntStale = 0;
				bool noCheck = false;
				IList stillDirty = new ArrayList() ;
				ArrayList insertObjects = new ArrayList();
				cnt = m_listCreated.Count;
				IObjectManager om = this.Context.ObjectManager;
				IPersistenceEngine pe = this.Context.PersistenceEngine;
				while (cnt > 0)
				{
					try
					{
						insertObjects.Clear();
						foreach (object obj in m_listCreated)
						{
							try
							{
								if (forObj != null)
								{
									if (obj == forObj)
									{
										insertObjects.Add(obj);
									}
								}
								else
								{
									if (noCheck)
									{							
										if (MayInsert(obj, true, true))
										{							
											insertObjects.Add(obj);
											noCheck = false;
										}
									}
									else
									{
										if (MayInsert(obj, true, false))
										{							
											insertObjects.Add(obj);
										}							
									}
								}							
							}
							catch (Exception ex)
							{
								if (exceptionLimit > 0 && exceptions.Count >= exceptionLimit - 1)
									throw ex;
								exceptions.Add(ex);
							}
						}
						foreach (object obj in insertObjects)
						{
							//this should be the only necessary try block in this 
							//method (and it ought only to be around the call to the
							//persistence engine, at that) but we add the other tries
							//to ensure that some exception from the framework doesn't
							//ruin the beautiful concept with collecting exceptions :-)
							try 
							{
								m_listCreated.Remove(obj);
								m_listInserted.Add(obj);
								stillDirty.Clear() ;
								pe.InsertObject(obj, stillDirty);
								om.SetObjectStatus(obj, ObjectStatus.Clean);
								this.Context.LogManager.Debug(this, "Inserted object", "Type: " + obj.GetType().ToString() + " Still dirty: " + stillDirty.ToString() ); // do not localize
								if (stillDirty.Count > 0)
								{
									IList cloneList = new ArrayList();
									foreach (object clone in stillDirty)
									{
										cloneList.Add(clone);
									}
									m_hashStillDirty[obj] = cloneList ;
								}
							}
							catch (Exception ex)
							{
								if (exceptionLimit > 0 && exceptions.Count >= exceptionLimit - 1)
									throw ex;
								exceptions.Add(ex);
							}
						}
						if (m_listCreated.Count == cnt)
						{
							noCheck = true;
							cntStale++;
							if (cntStale > 1)
							{
								throw new NPersistException("Cyclic dependency among objects up for creation could not be resolved!"); // do not localize
							}
						}
						else
						{
							cntStale = 0;
							noCheck = false;
						}
						if (forObj != null)
						{
							cnt = 0;
						}
						else
						{
							cnt = m_listCreated.Count;
						}
					}
					catch (Exception ex)
					{
						if (exceptionLimit > 0 && exceptions.Count >= exceptionLimit - 1)
							throw ex;
						exceptions.Add(ex);
					}
				}				
			}
			catch (Exception ex)
			{
				if (exceptionLimit > 0 && exceptions.Count >= exceptionLimit - 1)
					throw ex;
				exceptions.Add(ex);
			}
		}
        private Hashtable XMLRPCRequest(Hashtable ReqParams, string method)
        {
            ArrayList SendParams = new ArrayList();
            SendParams.Add(ReqParams);

            XmlRpcResponse Resp;
            try
            {
                XmlRpcRequest Req = new XmlRpcRequest(method, SendParams);
                Resp = Req.Send(m_connectionString, 30000);
            }
            catch (WebException ex)
            {
                m_log.ErrorFormat(

                    "[UserLogModule]: XmlRpcDataConnector::WebException > Url:{0}, Method: {1}, Params: {2}, " +
                    "Exception: {3}", m_connectionString, method, SendParams.ToString(), ex);

                Hashtable ErrorHash = new Hashtable();
                ErrorHash["success"] = false;
                ErrorHash["errorMessage"] = "Unable to log User data at this time. ";
                ErrorHash["errorURI"] = "";

                return ErrorHash;
            }
            catch (SocketException ex)
            {
                m_log.ErrorFormat(
                        "[UserLogModule]: XmlRpcDataConnector::SocketException > Url:{0}, Method: {1}, Params: {2}, " +
                        "Exception: {3}", m_connectionString, method, SendParams.ToString(), ex);

                Hashtable ErrorHash = new Hashtable();
                ErrorHash["success"] = false;
                ErrorHash["errorMessage"] = "Unable to log user data at this time. ";
                ErrorHash["errorURI"] = "";

                return ErrorHash;
            }
            catch (XmlException ex)
            {
                m_log.ErrorFormat(
                        "[UserLogModule]: XmlRpcDataConnector::XmlException > Url:{0}, Method: {1}, Params: {2}, " +
                        "Exception: {3}", m_connectionString, method, SendParams.ToString(), ex);

                Hashtable ErrorHash = new Hashtable();
                ErrorHash["success"] = false;
                ErrorHash["errorMessage"] = "Unable to log user data at this time. ";
                ErrorHash["errorURI"] = "";

                return ErrorHash;
            }
            if (Resp.IsFault)
            {
                Hashtable ErrorHash = new Hashtable();
                ErrorHash["success"] = false;
                ErrorHash["errorMessage"] = "Unable to log user data at this time. ";
                ErrorHash["errorURI"] = "";
                return ErrorHash;
            }

            Hashtable RespData = (Hashtable)Resp.Value;
            return RespData;
        }
		private IParameter[] GetMatchingParameterListForSetters(IPicoContainer container)
		{
			if (setters == null)
			{
				InitializeSetterAndTypeLists();
			}

			IParameter[] matchingParameterList = new IParameter[setters.Count];
			ArrayList nonMatchingParameterPositions = new ArrayList(); // was Set
			IParameter[] currentParameters = parameters != null ? parameters : CreateDefaultParameters(setterTypes);
			for (int i = 0; i < currentParameters.Length; i++)
			{
				IParameter parameter = currentParameters[i];
				bool failedDependency = true;
				for (int j = 0; j < setterTypes.Length; j++)
				{
					if (matchingParameterList[j] == null && parameter.IsResolvable(container, this, setterTypes[j]))
					{
						matchingParameterList[j] = parameter;
						failedDependency = false;
						break;
					}
				}
				if (failedDependency)
				{
					nonMatchingParameterPositions.Add(i);
				}
			}

			ArrayList unsatisfiableDependencyTypes = new ArrayList();
			for (int i = 0; i < matchingParameterList.Length; i++)
			{
				if (matchingParameterList[i] == null)
				{
					unsatisfiableDependencyTypes.Add(setterTypes[i]);
				}
			}
			if (unsatisfiableDependencyTypes.Count > 0)
			{
				throw new UnsatisfiableDependenciesException(this, unsatisfiableDependencyTypes);
			}
			else if (nonMatchingParameterPositions.Count > 0)
			{
				throw new PicoInitializationException("Following parameters do not match any of the setters for "
					+ ComponentImplementation + ": " + nonMatchingParameterPositions.ToString());
			}
			return matchingParameterList;
		}
 ///	<summary>
 /// If an instance of x is enclosed in a y which is in a z, return
 /// a String of these instance names in order from topmost to lowest;
 /// here that would be "[z y x]".
 /// </summary>
 public String getEnclosingInstanceStackString()
 {
     IList names = new ArrayList();
     StringTemplate p = this;
     while ( p!=null )
     {
         String name = p.getName();
         names.Insert(0,name+(p.passThroughAttributes?"(...)":""));
         p = p.enclosingInstance;
     }
     return names.ToString().Replace(",","");
 }
        public bool Delete(List<PromotionsAmountDiscountCustom> list)
        {
            ArrayList arrList = new ArrayList();
            try
            {
                for (int i = 0; i < list.Count; i++)
                {
                    arrList.Add(string.Format("delete from promotions_amount_discount where id='{0}';", list[i].id));
                }
                return _mySql.ExcuteSqls(arrList);
            }
            catch (Exception ex)
            {
                throw new Exception("PromotionAmountDiscountsDao-->Delete-->+" + arrList.ToString() + ex.Message, ex);
            }

        }
        /// <summary>
        /// tries to guesstimate the speaker of sSource dialog line
        /// </summary>
        /// <param name="sSource"></param>
        /// <param name="sBefore"></param>
        /// <param name="sAfter"></param>
        /// <param name="confidence"></param>
        /// <returns></returns>
        private string GetSpeaker(string sSource, string sBefore, string sAfter, 
            string sBeforeSpeaker, out double confidence)
        {
            string sContext = sBefore + " " + sAfter;

            if (characters == null)
            {
                throw new Exception("GetSPeaker - we need a character array");
            }

            if (pronouns == null)
            {
                throw new Exception("pronouns not defined? DId you build the AI table?");
            }

            if (kb == null)
            {
                throw new Exception("knowledge base needs to be built");
            }

            if (GETSPEAKER_RegexForPronouns == "")
            {
                throw new Exception("pronouns were not defined.");
            }

            if (hesaids == null)
            {
                throw new Exception("we need the hesaid regex built");
            }
            if (pronounRegex == null)
            {
                throw new Exception("we need the pronoun regex built");
            }

            if (sSource.IndexOf("Listen,") > -1)
            {
              //  int breaker = 9;
            }

            // This worked to get he and shes and whatnot but I wanted to try something
            // more elabroate
            //Regex caps = new Regex(@"(\bhe|\bI\b|\bit\b|\bHe\b|\bShe\b|\bshe\b|(\b[A-Z]\w*))");

            MatchCollection matches = hesaids.Matches(sContext);

            confidence = 0.0;

            ArrayList output = new ArrayList();

            foreach (Match match in matches)
            {
                // remove the 'said' bit from the string
                string sValue = match.Value;

                //ToDo: Potential slow (but only about one second
                foreach (string s in saidisms)
                {
                    if (sValue.IndexOf(s) > -1) // this did not improve speed
                    {
                        sValue = sValue.Replace(s, "");
                    }
                }

                sValue = sValue.Trim();
                output.Add(sValue);

            }

            // now check for pronouns
              ///  Regex pronouns = new Regex(@"(\bhe|\bI\b|\bit\b|\bHe\b|\bShe\b|\bshe\b)");
              //  matches = pronouns.Matches(sContext);

            /////////////////////////
            //
            // Rules Reference
            // in case I get confused
            //
            // 1. he/she said will trump  (includes pronoun he/she but only if followed with a saidism)
            // 2. then we look for a previous speaker (i.e., if line of dialog before me had a speaker, use that)
            // 2. then we look for a Name
            // 3. then we look for the most likely name
            // ToDo: 4 - just look for presence of pronouns
            // ToDo: 5. If we still do not have a match we try to match a Pronoun with a Name
            //
            //////////////////////////////////////////////////////

            //////////////////////////////////////
            //
            // NO MATCH
            //
            // 1. Now we get into advanced stuff trying to dig up the talker
            //
            //////////////////////////////////////

               // if (matches.Count == 0 /*&& bFoundExactlyOne == false*/)
            {
                // a. previous speaker. If there is a previous speaker lets try that
                if (sBeforeSpeaker != "" && sBeforeSpeaker != "none")
                {
                   // sOutput = sBeforeSpeaker;
                    output.Add(sBeforeSpeaker);
                 //   bFoundExactlyOne = true;
                    confidence = 0.40;
                }

                // Was there a name of a 'Character' on the previous or next line?
                // if so, add to output

                MatchCollection nameMatches = nameRegex.Matches(sBefore + sAfter);
                if (nameMatches.Count > 0)
                {
                    // we found a copy name matches
                    foreach (Match match in nameMatches)
                    {
                        output.Add(match.Value);
                    }

                }

            }

            //////////////////////////////////////////////
            //
            // Pronouns
            //
            // Just look for presence of pronouns if still can't find matches
            //
            /////////////////////////////////////////////
            if (output.Count == 0)
            {

                MatchCollection pronounMatches = pronounRegex.Matches( (sBefore + sAfter).ToLower());
                if (pronounMatches.Count > 0)
                {
                    // we found a copy name matches
                    foreach (Match match in pronounMatches)
                    {
                        output.Add(match.Value);
                    }
                    if (output.Count == 1)
                    {
                        confidence = 0.14;
                       /* bFoundExactlyOne = true;*/
                    }
                    else if (output.Count > 1)
                    {
                        confidence = 0.08;
                    }
                }
            }

            if (output.Count == 1)
            {
                confidence = 0.90;

            }

            ///////////////////////////////////////////////
            //
            // Pronoun Replacement
            //
            // We replace pronouns with proper nouns
            //
            // so at this point we have hesaid with He, Her, et cetera
            // we replace each with a name
            //
            //
            //
            //////////////////////////////////////////////

            // a. If IsPronoun
            for (int matchCount = 0; matchCount < output.Count; matchCount++)
            {

                Relationship bestRelationship = kb.GetMostLikelyDeducedFact(
                     output[matchCount].ToString().ToLower(),
                     sContext,
                     GETSPEAKER_CONTEXTWEIGHT);

                 // now we REPLACE WITH a relationship match if there is one
                if (bestRelationship != null && output[matchCount].ToString() != bestRelationship.B)
                {
                    string sMes = "";// String.Format("Dialog: {0} Context: {1}", sSource, sContext);
                    lg.Instance.Line("WriteThink->GetSpeaker", ProblemType.MESSAGE,
                        output[matchCount] + " has been replaced by "+ bestRelationship.B + " "+
                        sMes
                        );
                    output[matchCount] = bestRelationship.B;
                    confidence = 0.03;
                }

            } // for

            /////////////////////////////////////////
            //
            // TOO MANY MATCHES
            //
            // 1. Now we isolate who might have (logically) spoken
            //
            //   A. Are they the same?
            //   B. Now the same? Pick most likely
            //
            ////////////////////////////////////////////

            // - Too many still? Consolidate down to one if possible
            if (output.Count > 1)
            {
                // Are they all the same? If so, pass with a reasonable confidence
                // sort and if first and lst entry are the same we are just one
                output.Sort();
                if (output[0].ToString() == output[output.Count - 1].ToString())
                {
                    string svalue = output[0].ToString();
                    output.Clear();
                    output.Add(svalue); // add value back into cleared list
                    confidence = 0.50;
                }
            }

            if (output.Count > 1) // only should trigger if we hav emore than 1
            {

                {

                    // now we attempt to see which pronoun, noun, was mentioned most and use that
                    Hashtable hash = new Hashtable();
                    foreach (string s in output)
                    {
                        int nValue = 1;
                        if (hash.ContainsKey(s))
                        {
                            nValue = (int)hash[s];
                            nValue++;
                            hash[s] = nValue;
                        }
                        else
                            hash.Add(s, nValue);
                    }
                    string sMaxValue = "";
                    int nMaxValue = -1;
                    foreach (DictionaryEntry dict in hash)
                    {
                        if ((int)dict.Value > nMaxValue)
                        {
                            sMaxValue = dict.Key.ToString();
                            nMaxValue = (int)dict.Value;
                        }
                    }

                    // okay now we have a max value
                    output.Clear();
                    if (sMaxValue == "I")
                    {
                    //    int breaker = 9;
                    }
                    output.Add(sMaxValue);

                    Console.WriteLine(output.ToString());
                    confidence = 0.15;

                }
            }

            if (output.Count < 1)
            {
                lg.Instance.Line("WriteThink->GetSpeaker", ProblemType.MESSAGE,"no match found " + "pick most popular");
                output.Add(CharacterInDialogClass.GetMostLikelyName(characters, CharacterInDialogClass.gender.any));
            }

            string sOutput = "";
            // transfoer to string
            foreach (string s in output)
            {
                if (output.Count > 1)
                {
                    throw new Exception("At this point there should only be one match");
                }

                // convert returned name to NAME (i.e., an alias of doctor turns into Rutger)

                string sdelimiter = "";
                if (sOutput != "")
                {
                    sdelimiter = ", ";
                }
                sOutput = sOutput + sdelimiter +  CharacterInDialogClass.GetNameFromAlias(s, characters);
            }

            return sOutput;
        }
 public void AssignStartEndCity(int TourId, ArrayList STARTENDCITY)
 {
     TourmasterStoreprocedures objempentity = new TourmasterStoreprocedures();
     objempentity.AssignCountry(TourId, STARTENDCITY.ToString());
 }
        internal ArrayList GetWindow(
            GetWindowCmdletBase cmdlet,
            // 20130513
            bool win32,
            Process[] processes,
            string[] processNames,
            int[] processIds,
            string[] windowNames,
            string automationId,
            string className,
            bool testMode)
        {
            ArrayList aeWndCollection =
                new ArrayList();

            cmdlet.WriteVerbose(cmdlet, "getting the root element");
            rootElement =
                System.Windows.Automation.AutomationElement.RootElement;
            if (rootElement == null)
            {
                cmdlet.WriteVerbose(cmdlet, "rootElement == null");
                return aeWndCollection;
            }
            else
            {
                cmdlet.WriteVerbose(cmdlet, "rootElement: " + rootElement.Current);
            }

            // 20130529
            bool wasFound = false;
            do {

                // 20130513
                //if (null != processes && processes.Length > 0) {
                if (win32) {

                    cmdlet.WriteVerbose(cmdlet, "getting a window via Win32 API");
                    aeWndCollection = getWindowCollectionViaWin32(cmdlet.First, cmdlet.Recurse, cmdlet.Name, cmdlet.AutomationId, cmdlet.Class);

                } else if (null != processes && processes.Length > 0) {
                    cmdlet.WriteVerbose(cmdlet, "getting a window by process");
                    aeWndCollection = getWindowCollectionFromProcess(processes, cmdlet.First, cmdlet.Recurse, cmdlet.Name, cmdlet.AutomationId, cmdlet.Class);

                } else if (null != processIds && processIds.Length > 0) {

                    cmdlet.WriteVerbose(cmdlet, "getting a window by PID");
                    aeWndCollection = getWindowCollectionByPID(processIds, cmdlet.First, cmdlet.Recurse, cmdlet.Name, cmdlet.AutomationId, cmdlet.Class);

                } else if (null != processNames && processNames.Length > 0) {

                    cmdlet.WriteVerbose(cmdlet, "getting a window by name");
                    aeWndCollection = getWindowCollectionByProcessName(processNames, cmdlet.First, cmdlet.Recurse, cmdlet.Name, cmdlet.AutomationId, cmdlet.Class);

                } else if ((null != windowNames && windowNames.Length > 0) ||
                           (null != automationId && 0 < automationId.Length) ||
                           (null != className && 0 < className.Length)) {

                    cmdlet.WriteVerbose(cmdlet, "getting a window by name, automationId, className");
                    aeWndCollection = getWindowCollectionByName(windowNames, automationId, className, cmdlet.Recurse);
                }

                // 20130228
                // filtering result window collection by SearchCriteria
                if (null != aeWndCollection && 0 < aeWndCollection.Count) {

                    cmdlet.WriteVerbose(cmdlet, "one or several windows were found by name, process name, process id or process object");

                    if (null != cmdlet.SearchCriteria && 0 < cmdlet.SearchCriteria.Length) {

                        cmdlet.WriteVerbose(cmdlet, "processing SearchCriteria");

                        aeWndCollection =
                            cmdlet.getFiltredElementsCollection(
                                cmdlet,
                                aeWndCollection);
                    }
                }

                // filtering result window collection by having a control(s) with properties as from WithControl
                if (null != aeWndCollection && 0 < aeWndCollection.Count) {

                    cmdlet.WriteVerbose(cmdlet, "one or several windows were not excluded by SearchCriteria");

                    if (null != cmdlet.WithControl && 0 < cmdlet.WithControl.Length) {

                        cmdlet.WriteVerbose(cmdlet, "processing WithControl");

                        ArrayList filteredWindows =
                            new ArrayList();

                        foreach (AutomationElement window in aeWndCollection) {

                            cmdlet.WriteVerbose(cmdlet, "searching for control(s) for every window, one by one");

                            GetControlCmdletBase cmdletCtrl =
                                new GetControlCmdletBase();
                            //cmdletCtrl.InputObject = (AutomationElement[])aeWndCollection.ToArray();
                            cmdletCtrl.InputObject =
                                // 20130316
                                //(AutomationElement[])aeWndCollection.ToArray(typeof(AutomationElement));
                                new AutomationElement[]{ window };
                            cmdletCtrl.SearchCriteria = cmdlet.WithControl;
                            cmdletCtrl.Timeout = 0;

                            cmdlet.WriteVerbose(cmdlet, "searching for one or more controls");

                            // 20130301
                            try {

                                ArrayList controlsList =
                                    GetControl(cmdletCtrl);

                                cmdlet.WriteVerbose(cmdlet, "after the search");

                                if (null != controlsList && 0 < controlsList.Count) {

                                    cmdlet.WriteVerbose(cmdlet, "ths list of controls that are on the window is not empty");

                                    filteredWindows.Add(window);
                                }

                            // 20130301
                            }

                            catch (Exception eWindowIsGone) {

                                // forcing to a next loop
                                aeWndCollection.Clear();
                                break;

                            }
                        }

                        aeWndCollection = filteredWindows;
                    }
                }

                // 20130529
                if (cmdlet.WaitNoWindow && wasFound && (null == aeWndCollection || 0 == aeWndCollection.Count)) {

                    cmdlet.Wait = false;
                }

                if (cmdlet.WaitNoWindow && !wasFound && null != aeWndCollection && 0 != aeWndCollection.Count) {

                    wasFound = true;
                    aeWndCollection = null;
                }

                if (null != aeWndCollection && aeWndCollection.Count > 0) {

                    cmdlet.WriteVerbose(cmdlet, "aeWndCollection != null");

                }
                // 20120123
                // checkTimeout(ref aeWnd, true);
                // 20120824
                //checkTimeout(cmdlet, aeWnd, true);
                checkTimeout(cmdlet, aeWndCollection, true);

                System.Threading.Thread.Sleep(Preferences.OnSleepDelay);

            } while (cmdlet.Wait);
            try {

                if (null != aeWndCollection && (int)((AutomationElement)aeWndCollection[0]).Current.ProcessId > 0) {

                    cmdlet.WriteVerbose(cmdlet, "" + aeWndCollection.ToString());
                    cmdlet.WriteVerbose(cmdlet,
                                        "aeWnd.Current.GetType() = " +
                                        ((AutomationElement)aeWndCollection[0]).GetType().Name);

                } // 20120127

                CurrentData.CurrentWindow = (AutomationElement)aeWndCollection[aeWndCollection.Count -1];
                // 20120824
                //return aeWnd;
                //return aeWndCollection;
            } catch (Exception eEvaluatingWindowAndWritingToPipeline) {

                //WriteDebug(cmdlet, "exception: " +
                cmdlet.WriteVerbose(
                    cmdlet,
                    "exception: " +
                    eEvaluatingWindowAndWritingToPipeline.Message);

                cmdlet.WriteVerbose(this, "<<<< ==  ==  writing/nullifying CurrentWindow  ==  == >>>>>");

                CurrentData.CurrentWindow = null;

            }

            return aeWndCollection;
        }
Exemple #18
0
 public bool BonusMasterAdd(List<BonusMasterQuery> list)
 {
     Serial serial = new Serial();
     ArrayList arrayList = new ArrayList();
     try
     {
         //define('SERIAL_ID_BONUS_MASTER',		27);	// 購物金流水號
         serial = _ISerialDao.GetSerialById(27);
         for (int i = 0; i < list.Count; i++)
         {
             //得到+1後的serialValue,是bonus_master的master_id
             serial.Serial_Value++;
             list[i].master_id = Convert.ToUInt32(serial.Serial_Value);
             //更新serial表
             arrayList.Add(_ISerialDao.UpdateAutoIncreament(serial));
             //插入BonusMaster數據
             arrayList.Add(_IBonusMasterDao.InsertBonusMaster(list[i]));
         }
         return _mysqlDao.ExcuteSqls(arrayList);
     }
     catch (Exception ex)
     {
         throw new Exception("BonusMasterMgr-->BonusMasterAdd-->" + arrayList.ToString() + ex.Message, ex);
     }
 }