コード例 #1
0
ファイル: Chart-Test.aspx.cs プロジェクト: hsmaheen/ADSMS
 public static List<Object> getChartData()
 {
     CollectionHelper cph = new CollectionHelper();
     stationeryEntities db = new stationeryEntities();
     List<Object> chartdata = new List<object>();
     DataTable charttable = new DataTable();
     List<ChartData> finalchart = new List<ChartData>();
     var q = from dep in db.departments
             from disb in db.disbursements
             from dd in db.disbursementdetails
             from i in db.items
             where
               i.ItemID == dd.DisbItemID &&
               disb.DisbID == dd.DisbID &&
               dep.DepID == disb.DisbDepID
             group new { i, dd } by new
             {
                 i.ItemDescription,
                 dd.DisbItemQuantDelivered
             } into g
             orderby
               g.Sum(p => p.dd.DisbItemQuantReq)
             select new
             {
                 g.Key.ItemDescription,
                 Qunatity_Delivered = (System.Int32?)g.Sum(p => p.dd.DisbItemQuantReq)
             };
     chartdata = q.ToList<Object>();
     return chartdata;
 }
コード例 #2
0
 public BillsTicketCounter(string ExchangeConn, string TicketingConn)
     : this()
 {
     LogManager.WriteLog("BillsTicketCounter:BillsTicketCounter() Entry", LogManager.enumLogLevel.Info);
     LogManager.WriteLog("BillsTicketCounter:BillsTicketCounter() Site Code : " + ManualCashEntry.sSiteCode, LogManager.enumLogLevel.Debug);
     ExchangeConnectionString = ExchangeConn;
     TicketingConnectionString = TicketingConn;
     _objCollectionHelper = new CollectionHelper(ExchangeConn);
     _objExchangeHelper = new ExchangeHelper(ExchangeConn);
     _objTicketsHelper = new TicketsHelper(TicketingConn);
     LogManager.WriteLog("BillsTicketCounter:BillsTicketCounter() Exit", LogManager.enumLogLevel.Info);
 }
コード例 #3
0
 public BillsTicketCounter()
 {
     InitializeComponent();
     MessageBox.childOwner = this;
     btnExceptionTickets.Visibility = (Settings.HANDLE_EXCEPTIONTICKETS_COUNTER) ? Visibility.Visible : Visibility.Collapsed;
     if (!String.IsNullOrEmpty(ManualCashEntry.sSiteCode))
     {
         txtHeader.Text += "\t\t\t\t" + Application.Current.FindResource("ManualCashEntry_xaml_lblSiteCode").ToString().Trim() + " " + ManualCashEntry.sSiteCode;
     }
     _objCollectionHelper = new CollectionHelper();
     _objExchangeHelper = new ExchangeHelper();
     _objTicketsHelper = new TicketsHelper();
 }
コード例 #4
0
 public CashEntry(int batch, DeclarationFilterBy filterBy, string filterValue, string SiteCode, int CurrentIndex,IList<UndeclaredCollectionRecord> Collections)
     : this()
 {
     _objCollectionHelper = new CollectionHelper();
     _objExchangeHelper = new ExchangeHelper();
     _objTicketsHelper = new TicketsHelper();
     oDeclarationBiz = new DeclarationBiz();
     txtSiteInfo.Text = Application.Current.FindResource("ManualCashEntry_xaml_lblSiteCode").ToString().Trim() + " " + SiteCode;
     _IsPartCollection = (batch == 0) ? true : false;
     bEnableDefaultZero = Settings.ManualCashEntryEnableZero;
     this.Initialize(batch, filterBy, filterValue, CurrentIndex, Collections);
     cmbPosition.Focus();
 }
コード例 #5
0
        public List <string> SaveIrregularityIncident(List <IrregularityIncident> obj)
        {
            //validate Business Rule
            List <string> ErrorMessage = new List <string>();
            DataTable     dtCreateIrr  = CollectionHelper.ConvertTo(obj, "Active,UpdatedByUser,CreatedByUser");

            dtCreateIrr.Columns.Remove("TransData");  //ADDED

            //string TranData = CargoFlash.Cargo.Business.Common.Base64ToString(obj[0].TransData.ToString());
            //var dtCreateTranData = JsonConvert.DeserializeObject<DataTable>(obj[0].TransData.ToString());
            DataTable    dtSubCategory = CollectionHelper.ConvertTo(obj[0].TransData.ToList(), ""); //added
            BaseBusiness baseBusiness  = new BaseBusiness();

            if (dtSubCategory.Rows.Count == 0)
            {
                //For Customised Validation Messages like 'Record Already Exists' etc
                string serverErrorMessage = baseBusiness.ReadServerErrorMessages(1000, "IrregularityIncident");
                if (!string.IsNullOrEmpty(serverErrorMessage))
                {
                    ErrorMessage.Add(serverErrorMessage);
                }
                return(ErrorMessage);
            }

            if (!baseBusiness.ValidateBaseBusiness("IrregularityIncident", dtCreateIrr, "SAVE"))
            {
                ErrorMessage = baseBusiness.ErrorMessage;
                return(ErrorMessage);
            }
            //SqlParameter param = new SqlParameter();
            //param.ParameterName = "@IrregularityIncidentTable";
            //param.SqlDbType = System.Data.SqlDbType.Structured;
            //param.Value = dtCreateIrr;
            //SqlParameter[] Parameters = { param };
            SqlParameter[] Parameters = { new SqlParameter("@IrregularityIncidentTable", dtCreateIrr), new SqlParameter("@tt", dtSubCategory) };
            int            ret        = (int)SqlHelper.ExecuteScalar(DMLConnectionString.WebConfigConnectionString, "CreateIrregularityIncidentAndSubcategory", Parameters);

            if (ret > 0)
            {
                if (ret > 1000)
                {
                    //For Customised Validation Messages like 'Record Already Exists' etc
                    string serverErrorMessage = baseBusiness.ReadServerErrorMessages(ret, "IrregularityIncident");
                    if (!string.IsNullOrEmpty(serverErrorMessage))
                    {
                        ErrorMessage.Add(serverErrorMessage);
                    }
                }

                else
                {
                    //For DataBase Exceptions like 'Foreign Key refrence Errors' etc
                    string dataBaseExceptionMessage = baseBusiness.ReadServerErrorMessages(ret, baseBusiness.DatabaseExceptionFileName);
                    if (!string.IsNullOrEmpty(dataBaseExceptionMessage))
                    {
                        ErrorMessage.Add(dataBaseExceptionMessage);
                    }
                }
            }

            return(ErrorMessage);
        }
コード例 #6
0
ファイル: WordLibrary.cs プロジェクト: zyhh/imewlconverter
 public override string ToString()
 {
     return("WordLibrary 汉字:" + word + "Codes:" +
            CollectionHelper.ListToString(Codes[0]) + ";词频:" + count);
 }
コード例 #7
0
        public BillsTicketCounter(int batch, DeclarationFilterBy filterBy, string filterValue, string SiteCode, string ExchangeConn, string TicketingConn, int CollectionIndex)
            : this(batch, filterBy, filterValue, SiteCode, CollectionIndex)
        {
            LogManager.WriteLog("BillsTicketCounter:BillsTicketCounter() Entry", LogManager.enumLogLevel.Info);
            LogManager.WriteLog("BillsTicketCounter:BillsTicketCounter() Site Code : " + SiteCode, LogManager.enumLogLevel.Debug);
            ExchangeConnectionString = ExchangeConn;
            TicketingConnectionString = TicketingConn;
            _objCollectionHelper = new CollectionHelper(ExchangeConn);
            _objExchangeHelper = new ExchangeHelper(ExchangeConn);
            _objTicketsHelper = new TicketsHelper(TicketingConn);
            _CurrentCollectionIndex = CollectionIndex;
            RefreshData(_CurrentCollectionIndex);
            LogManager.WriteLog("BillsTicketCounter:BillsTicketCounter() Exit", LogManager.enumLogLevel.Info);


        }
コード例 #8
0
        private IDictionary <string, string[]> BindPropertyResults(string alias, HbmReturnDiscriminator discriminatorSchema,
                                                                   HbmReturnProperty[] returnProperties, PersistentClass pc)
        {
            Dictionary <string, string[]> propertyresults = new Dictionary <string, string[]>();

            // maybe a concrete SQLpropertyresult type, but Map is exactly what is required at the moment

            if (discriminatorSchema != null)
            {
                propertyresults["class"] = GetResultColumns(discriminatorSchema).ToArray();
            }

            List <HbmReturnProperty> properties    = new List <HbmReturnProperty>();
            List <string>            propertyNames = new List <string>();

            foreach (HbmReturnProperty returnPropertySchema in returnProperties ?? Array.Empty <HbmReturnProperty>())
            {
                string name = returnPropertySchema.name;
                if (pc == null || name.IndexOf('.') == -1)
                {
                    //if dotted and not load-collection nor return-join
                    //regular property
                    properties.Add(returnPropertySchema);
                    propertyNames.Add(name);
                }
                else
                {
                    // Reorder properties
                    // 1. get the parent property
                    // 2. list all the properties following the expected one in the parent property
                    // 3. calculate the lowest index and insert the property

                    int    dotIndex    = name.LastIndexOf('.');
                    string reducedName = name.Substring(0, dotIndex);
                    IValue value       = pc.GetRecursiveProperty(reducedName).Value;
                    IEnumerable <Mapping.Property> parentPropIter;
                    if (value is Component)
                    {
                        Component comp = (Component)value;
                        parentPropIter = comp.PropertyIterator;
                    }
                    else if (value is ToOne)
                    {
                        ToOne           toOne        = (ToOne)value;
                        PersistentClass referencedPc = mappings.GetClass(toOne.ReferencedEntityName);
                        if (toOne.ReferencedPropertyName != null)
                        {
                            try
                            {
                                parentPropIter =
                                    ((Component)referencedPc.GetRecursiveProperty(toOne.ReferencedPropertyName).Value).PropertyIterator;
                            }
                            catch (InvalidCastException e)
                            {
                                throw new MappingException("dotted notation reference neither a component nor a many/one to one", e);
                            }
                        }
                        else
                        {
                            try
                            {
                                parentPropIter = ((Component)referencedPc.IdentifierProperty.Value).PropertyIterator;
                            }
                            catch (InvalidCastException e)
                            {
                                throw new MappingException("dotted notation reference neither a component nor a many/one to one", e);
                            }
                        }
                    }
                    else
                    {
                        throw new MappingException("dotted notation reference neither a component nor a many/one to one");
                    }
                    bool          hasFollowers = false;
                    List <string> followers    = new List <string>();
                    foreach (Mapping.Property prop in parentPropIter)
                    {
                        string currentPropertyName = prop.Name;
                        string currentName         = reducedName + '.' + currentPropertyName;
                        if (hasFollowers)
                        {
                            followers.Add(currentName);
                        }
                        if (name.Equals(currentName))
                        {
                            hasFollowers = true;
                        }
                    }

                    int index         = propertyNames.Count;
                    int followersSize = followers.Count;
                    for (int loop = 0; loop < followersSize; loop++)
                    {
                        string follower     = followers[loop];
                        int    currentIndex = GetIndexOfFirstMatchingProperty(propertyNames, follower);
                        index = currentIndex != -1 && currentIndex < index ? currentIndex : index;
                    }
                    propertyNames.Insert(index, name);
                    properties.Insert(index, returnPropertySchema);
                }
            }

            var uniqueReturnProperty = new HashSet <string>();

            foreach (HbmReturnProperty returnPropertySchema in properties)
            {
                string name = returnPropertySchema.name;
                if ("class".Equals(name))
                {
                    throw new MappingException(
                              "class is not a valid property name to use in a <return-property>, use <return-discriminator> instead"
                              );
                }
                //TODO: validate existing of property with the chosen name. (secondpass )
                List <string> allResultColumns = GetResultColumns(returnPropertySchema);

                if (allResultColumns.Count == 0)
                {
                    throw new MappingException(
                              "return-property for alias " + alias +
                              " must specify at least one column or return-column name"
                              );
                }
                if (uniqueReturnProperty.Contains(name))
                {
                    throw new MappingException(
                              "duplicate return-property for property " + name +
                              " on alias " + alias
                              );
                }
                uniqueReturnProperty.Add(name);

                // the issue here is that for <return-join/> representing an entity collection,
                // the collection element values (the property values of the associated entity)
                // are represented as 'element.{propertyname}'.  Thus the StringHelper.root()
                // here puts everything under 'element' (which additionally has significant
                // meaning).  Probably what we need to do is to something like this instead:
                //      String root = StringHelper.root( name );
                //      String key = root; // by default
                //      if ( !root.equals( name ) ) {
                //	        // we had a dot
                //          if ( !root.equals( alias ) {
                //              // the root does not apply to the specific alias
                //              if ( "elements".equals( root ) {
                //                  // we specifically have a <return-join/> representing an entity collection
                //                  // and this <return-property/> is one of that entity's properties
                //                  key = name;
                //              }
                //          }
                //      }
                // but I am not clear enough on the intended purpose of this code block, especially
                // in relation to the "Reorder properties" code block above...
                //			String key = StringHelper.root( name );
                string   key = name;
                string[] intermediateResults;
                if (!propertyresults.TryGetValue(key, out intermediateResults))
                {
                    propertyresults[key] = allResultColumns.ToArray();
                }
                else
                {
                    throw new NotImplementedException();
                    // 2013-02-24: In 89994bc113e1bb35bf6bcd0b7408d08340bfbccd, 2008-05-29, the intermediateResults
                    // variable was changed from ArrayList to string[]. The following code line was there before.
                    // Since an array cannot be modified, it seems this code line has never been hit since then.
                    // While working on NH-3345, I'm adding an ambigous overload for AddAll(), and I don't want to
                    // try to understand this code right now, so comment it out instead. /Oskar
                    //ArrayHelper.AddAll(intermediateResults, allResultColumns); // TODO: intermediateResults not used after this
                }
            }

            Dictionary <string, string[]> newPropertyResults = new Dictionary <string, string[]>();

            foreach (KeyValuePair <string, string[]> entry in propertyresults)
            {
                newPropertyResults[entry.Key] = entry.Value;
            }
            return(newPropertyResults.Count == 0 ? (IDictionary <string, string[]>)CollectionHelper.EmptyDictionary <string, string[]>() : newPropertyResults);
        }
コード例 #9
0
ファイル: WordLibrary.cs プロジェクト: zyhh/imewlconverter
 /// <summary>
 /// 获得拼音字符串
 /// </summary>
 /// <param name="split">每个拼音之间的分隔符</param>
 /// <param name="buildType">组装拼音字符串的方式</param>
 /// <returns></returns>
 public string GetPinYinString(string split, BuildType buildType)
 {
     return(CollectionHelper.GetString(PinYin, split, buildType));
 }
コード例 #10
0
        public override Code GetCodeOfString(string str)
        {
            foreach (char c in str)
            {
                if (!Dictionary.ContainsKey(c))
                {
                    return(null);
                }
            }
            if (str.Length == 1)
            {
                var c = new List <string>();
                foreach (Cangjie cangjy in Dictionary[str[0]])
                {
                    c.Add(cangjy.Code);
                }

                return(new Code(c, false));
            }
            IList <IList <string> > codes = new List <IList <string> >();
            var sb = new StringBuilder();

            if (str.Length == 2) //第一个字2码(首尾码),第二字3码(取首次尾码)
            {
                codes.Add(GetFirstAndLastCode(str[0]));
                codes.Add(GetFirstSecondLastCode(str[1]));
            }
            if (str.Length == 3) //221取码
            {
                codes.Add(GetFirstAndLastCode(str[0]));
                IList <string> code2 = GetFirstAndLastCode(str[1]);
                codes.Add(code2);
                if (code2[0].Length == 1) //212取码
                {
                    codes.Add(GetFirstAndLastCode(str[2]));
                }
                else
                {
                    codes.Add(GetLastCode(str[2]));
                }
            }
            if (str.Length == 4) //首2字当字首取2码,剩下的2字当字身3码(第3字2码,第4字尾码)。
            {
                codes.Add(GetFirstCode(str[0]));
                codes.Add(GetLastCode(str[1]));
                IList <string> code3 = GetFirstAndLastCode(str[2]);
                codes.Add(code3);
                if (code3[0].Length == 1)
                {
                    codes.Add(GetFirstAndLastCode(str[3]));
                }
                else
                {
                    codes.Add(GetLastCode(str[3]));
                }
            }
            if (str.Length >= 5) //首2字当字首取2码,剩下的3字当字身3码(第3字1码,第4字尾码  ,5字尾码)。
            {
                codes.Add(GetFirstCode(str[0]));
                codes.Add(GetLastCode(str[1]));
                codes.Add(GetFirstCode(str[2]));
                codes.Add(GetLastCode(str[str.Length - 2]));
                codes.Add(GetLastCode(str[str.Length - 1]));
            }

            IList <string> result = CollectionHelper.Descartes(codes);

            return(new Code(result, false));
        }
コード例 #11
0
ファイル: FinamTask.cs プロジェクト: simiden/StockSharp
 public FinamSettings(HydraTaskSettings settings)
     : base(settings)
 {
     CollectionHelper.TryAdd(ExtensionInfo, "CandleDayStep", 30);
 }
コード例 #12
0
ファイル: ZBuffer.cs プロジェクト: GVNCoder/Zlo4NET
 /// <summary>
 /// Sets empty buffer
 /// </summary>
 public void Clear() => _buffer = CollectionHelper.GetEmptyEnumerable<byte>().ToArray();
コード例 #13
0
 /// <summary>
 /// Handles jobs that should be executed at a specific time.
 /// </summary>
 /// <param name="time">The time.</param>
 protected virtual void HandleJobs(DateTimeOffset time)
 {
     CollectionHelper.ForAll(this.GetJobsToExecute(time),
                             this.HandleJobItem,
                             time);
 }
コード例 #14
0
        /// <summary>
        /// Update the Entity into the database
        /// </summary>
        /// <param name="Schedule">list of Schedule to be updated</param>
        public List <string> UpdateSchedule(List <CargoFlash.Cargo.Model.Schedule.ScheduleDetails> ScheduleDetail)
        {
            try
            {
                //validate Business Rule
                List <string> ErrorMessage     = new List <string>();
                DataTable     dtCreateSchedule = CollectionHelper.ConvertTo(ScheduleDetail, "dt,ScheduleTypeName, CarrierCode, CAO, Active, Sch, ViaRoute, Text_ViaRoute,IsOperatedasTruck,Charter");
                DataTable     dt = ScheduleDetail[0].dt;
                dtCreateSchedule.Columns.Remove("Sch");
                dtCreateSchedule.Columns.Remove("ViaRoute");
                dtCreateSchedule.Columns.Remove("Text_ViaRoute");
                dtCreateSchedule.Columns.Remove("CAO");
                dtCreateSchedule.Columns.Remove("Active");
                BaseBusiness baseBusiness = new BaseBusiness();
                if (!baseBusiness.ValidateBaseBusiness("Schedule", dtCreateSchedule, "UPDATE"))
                {
                    ErrorMessage = baseBusiness.ErrorMessage;
                    return(ErrorMessage);
                }

                var dtCreateScheduleCheckDate = (new DataView(dt, "DAY1=1 OR DAY2=1 OR DAY3=1 OR DAY4=1 OR DAY5=1 OR DAY6=1 OR DAY7=1", "SNo", DataViewRowState.CurrentRows)).ToTable();

                var duplicate = dtCreateScheduleCheckDate.AsEnumerable().GroupBy(r => new
                {
                    StartDate   = r["StartDate"],
                    EndDate     = r["EndDate"],
                    Origin      = r["HdnOrigin"],
                    Destination = r["HdnDestination"],
                    DAY1        = r["DAY1"],
                    DAY2        = r["DAY2"],
                    DAY3        = r["DAY3"],
                    DAY4        = r["DAY4"],
                    DAY5        = r["DAY5"],
                    DAY6        = r["DAY6"],
                    DAY7        = r["DAY7"]
                }).Where(gr => gr.Count() > 1).ToList();

                if (duplicate.Any())
                {
                    ErrorMessage.Add("Same Days are not allowed");
                    return(ErrorMessage);
                }

                SqlParameter param = new SqlParameter();
                param.ParameterName = "@Schedule";
                param.SqlDbType     = System.Data.SqlDbType.Structured;
                param.Value         = dtCreateSchedule;
                SqlParameter paraTrans = new SqlParameter();
                paraTrans.ParameterName = "@ScheduleTransType";
                paraTrans.SqlDbType     = System.Data.SqlDbType.Structured;
                paraTrans.Value         = ScheduleDetail[0].dt;
                SqlParameter[] Parameters = { param, paraTrans };

                //DataSet ds = CargoFlash.SoftwareFactory.Data.SqlHelper.ExecuteDataset(DMLConnectionString.WebConfigConnectionString, System.Data.CommandType.StoredProcedure, "spUpdateSchedule", Parameters);

                string ret = (string)SqlHelper.ExecuteScalar(DMLConnectionString.WebConfigConnectionString, "spUpdateSchedule", Parameters);

                if (ret != "")
                {
                    string serverErrorMessage = ret;
                    if (!string.IsNullOrEmpty(serverErrorMessage))
                    {
                        ErrorMessage.Add(serverErrorMessage);
                    }

                    //if (ret > 1000)
                    //{
                    //    //For Customised Validation Messages like 'Record Already Exists' etc
                    //    string serverErrorMessage = baseBusiness.ReadServerErrorMessages(ret, "Schedule");
                    //    if (!string.IsNullOrEmpty(serverErrorMessage))
                    //        ErrorMessage.Add(serverErrorMessage);
                    //}
                    //else
                    //{
                    //    //For DataBase Exceptions like 'Foreign Key refrence Errors' etc
                    //    string dataBaseExceptionMessage = baseBusiness.ReadServerErrorMessages(ret, baseBusiness.DatabaseExceptionFileName);
                    //    if (!string.IsNullOrEmpty(dataBaseExceptionMessage))
                    //        ErrorMessage.Add(dataBaseExceptionMessage);
                    //}
                }
                // ErrorMessage.Add(valuesno);
                return(ErrorMessage);
            }
            catch (Exception ex)//
            {
                throw ex;
            }
            //try {
            ////validate Business Rule
            //List<string> ErrorMessage = new List<string>();
            //DataTable dtCreateSchedule = CollectionHelper.ConvertTo(Schedule, "");
            //dtCreateSchedule.Columns.Remove("Sch");
            //BaseBusiness baseBusiness = new BaseBusiness();

            //if (!baseBusiness.ValidateBaseBusiness("Schedule", dtCreateSchedule, "UPDATE"))
            //{
            //    ErrorMessage = baseBusiness.ErrorMessage;
            //    return ErrorMessage;
            //}
            //SqlParameter param = new SqlParameter();
            //param.ParameterName = "@ScheduleTable";
            //param.SqlDbType = System.Data.SqlDbType.Structured;
            //param.Value = dtCreateSchedule;
            //SqlParameter[] Parameters = { param };
            //int ret = (int)SqlHelper.ExecuteScalar(DMLConnectionString.WebConfigConnectionString, "UpdateSchedule", Parameters);
            //if (ret > 0)
            //{
            //    if (ret > 1000)
            //    {
            //        //For Customised Validation Messages like 'Record Already Exists' etc
            //        string serverErrorMessage = baseBusiness.ReadServerErrorMessages(ret, "Schedule");
            //        if (!string.IsNullOrEmpty(serverErrorMessage))
            //            ErrorMessage.Add(serverErrorMessage);
            //    }
            //    else
            //    {

            //        //For DataBase Exceptions like 'Foreign Key refrence Errors' etc
            //        string dataBaseExceptionMessage = baseBusiness.ReadServerErrorMessages(ret, baseBusiness.DatabaseExceptionFileName);
            //        if (!string.IsNullOrEmpty(dataBaseExceptionMessage))
            //            ErrorMessage.Add(dataBaseExceptionMessage);
            //    }


            //}

            //return ErrorMessage;
            //}
            //catch(Exception ex)//
            //{
            //    throw ex;
            //}
        }
コード例 #15
0
ファイル: ZBuffer.cs プロジェクト: GVNCoder/Zlo4NET
 public ZBuffer()
 {
     _buffer = CollectionHelper.GetEmptyEnumerable<byte>()
         .ToArray();
 }
コード例 #16
0
ファイル: QueryKey.cs プロジェクト: weelink/nhibernate-core
        public override bool Equals(object other)
        {
            QueryKey that = (QueryKey)other;

            if (!_sqlQueryString.Equals(that._sqlQueryString))
            {
                return(false);
            }
            if (_firstRow != that._firstRow ||
                _maxRows != that._maxRows)
            {
                return(false);
            }

            if (!Equals(_customTransformer, that._customTransformer))
            {
                return(false);
            }

            if (_types == null)
            {
                if (that._types != null)
                {
                    return(false);
                }
            }
            else
            {
                if (that._types == null)
                {
                    return(false);
                }
                if (_types.Length != that._types.Length)
                {
                    return(false);
                }

                for (int i = 0; i < _types.Length; i++)
                {
                    if (!_types[i].Equals(that._types[i]))
                    {
                        return(false);
                    }
                    if (!Equals(_values[i], that._values[i]))
                    {
                        return(false);
                    }
                }
            }

            // BagEquals is less efficient than a SetEquals or DictionaryEquals, but serializing dictionaries causes
            // issues on deserialization if GetHashCode or Equals are called in its deserialization callback. And
            // building sets or dictionaries on the fly will in most cases be worst than BagEquals, unless re-coding
            // its short-circuits.
            if (!CollectionHelper.BagEquals(_filters, that._filters))
            {
                return(false);
            }
            if (!CollectionHelper.BagEquals(_namedParameters, that._namedParameters, NamedParameterComparer.Instance))
            {
                return(false);
            }

            if (!CollectionHelper.SequenceEquals <int>(_multiQueriesFirstRows, that._multiQueriesFirstRows))
            {
                return(false);
            }
            if (!CollectionHelper.SequenceEquals <int>(_multiQueriesMaxRows, that._multiQueriesMaxRows))
            {
                return(false);
            }
            return(true);
        }
コード例 #17
0
ファイル: HqlFixture.cs プロジェクト: spahnke/nhibernate-core
 protected HQLQueryPlan CreateQueryPlan(string hql, bool scalar)
 {
     return(new QueryExpressionPlan(new StringQueryExpression(hql), scalar, CollectionHelper.EmptyDictionary <string, IFilter>(), Sfi));
 }
コード例 #18
0
 public void FindParentTest()
 {
     var entity  = list.First(w => w.Id == 5);
     var parent  = CollectionHelper.FindParent <Tree, int>(list, entity);
     var parent2 = list.FindParent(2, 1);
 }
コード例 #19
0
 protected override bool AreCollectionElementsEqual(IEnumerable original, IEnumerable target)
 {
     return(CollectionHelper.BagEquals((IEnumerable <T>)original, (IEnumerable <T>)target));
 }
コード例 #20
0
ファイル: QueryKey.cs プロジェクト: PeterJee/vtms
        public override bool Equals(object other)
        {
            QueryKey that = (QueryKey)other;

            if (!_sqlQueryString.Equals(that._sqlQueryString))
            {
                return(false);
            }
            if (_firstRow != that._firstRow ||
                _maxRows != that._maxRows)
            {
                return(false);
            }

            if (!Equals(_customTransformer, that._customTransformer))
            {
                return(false);
            }

            if (_types == null)
            {
                if (that._types != null)
                {
                    return(false);
                }
            }
            else
            {
                if (that._types == null)
                {
                    return(false);
                }
                if (_types.Length != that._types.Length)
                {
                    return(false);
                }

                for (int i = 0; i < _types.Length; i++)
                {
                    if (!_types[i].Equals(that._types[i]))
                    {
                        return(false);
                    }
                    if (!Equals(_values[i], that._values[i]))
                    {
                        return(false);
                    }
                }
            }

            if (!CollectionHelper.SetEquals(_filters, that._filters))
            {
                return(false);
            }

            if (!CollectionHelper.DictionaryEquals(_namedParameters, that._namedParameters))
            {
                return(false);
            }

            if (!CollectionHelper.CollectionEquals <int>(_multiQueriesFirstRows, that._multiQueriesFirstRows))
            {
                return(false);
            }
            if (!CollectionHelper.CollectionEquals <int>(_multiQueriesMaxRows, that._multiQueriesMaxRows))
            {
                return(false);
            }
            return(true);
        }
コード例 #21
0
 public virtual TBuilder HtmlAttributes(object attributes)
 {
     return(this.HtmlAttributes(CollectionHelper.ObjectToDictionary(attributes)));
 }
コード例 #22
0
 public JoinFragment ToJoinFragment()
 {
     return(ToJoinFragment(CollectionHelper.EmptyDictionary <string, IFilter>(), true));
 }
コード例 #23
0
 /// <summary>
 ///
 /// </summary>
 /// <see cref="CollectionHelper.Where(IEnumerable, Func{object, long, bool})" />
 public static IEnumerable Where(this IEnumerable seq, Func <object, long, bool> predicate)
 {
     return(CollectionHelper.Where(seq, predicate));
 }
コード例 #24
0
 private async void SongClickExecute(ItemClickEventArgs item)
 {
     var track = (LastTrack)item.ClickedItem;
     await CollectionHelper.SaveTrackAsync(track);
 }
コード例 #25
0
 public static bool IsNullOrEmpty <T>(this ICollection <T> collection)
 {
     return(CollectionHelper.IsNullOrEmpty(collection));
 }
コード例 #26
0
 public IList <string> GetCodeString(string split, BuildType buildType)
 {
     return(CollectionHelper.CartesianProduct(Codes, split, buildType));
 }
コード例 #27
0
        // Public Methods (1) 

        /// <summary>
        ///
        /// </summary>
        /// <see cref="CollectionHelper.AddRange{T}(ICollection{T}, IEnumerable{T})" />
        public static void AddRange <T>(this ICollection <T> coll, IEnumerable <T> seq)
        {
            CollectionHelper.AddRange <T>(coll, seq);
        }
コード例 #28
0
        public ManualCashEntry(string strExchangeConnection, string strTicketingConnection)
            : this()
        {
            ExchangeConnectionString = strExchangeConnection;
            TicketingConnectionString = strTicketingConnection;
            if (Security.SecurityHelper.HasAccess("BMC.Presentation.CommonCDOforDeclaration"))
            {
                isCommonCDO = true;
                objColHelper = new CollectionHelper(ExchangeConnectionString);
            }
            else
            {

                isCommonCDO = false;
            }
        }
コード例 #29
0
ファイル: WordLibrary.cs プロジェクト: zyhh/imewlconverter
 public string ToDisplayString()
 {
     return("汉字:" + word + (string.IsNullOrEmpty(WubiCode) ? ";编码:" + CollectionHelper.ListToString(CollectionHelper.Descartes(Codes)) : "五笔:" + WubiCode) + ";词频:" +
            count);
 }
コード例 #30
0
        /// <summary>
        /// Creates a propxy <see cref="Type" /> for the interface of <typeparamref name="T" />.
        /// </summary>
        /// <param name="modBuilder">The module builder to use.</param>
        /// <param name="proxyTypeNamePrefixProvider">The logic that returns the prefix for the full name of the proxy type to create.</param>
        /// <param name="proxyTypeNameProvider">The logic that returns the name part of the proxy type to create.</param>
        /// <param name="proxyTypeNameSuffixProvider">The logic that returns the suffix for the full name of the proxy type to create.</param>
        /// <returns>The created type object.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="modBuilder" /> is <see langword="null" />.
        /// </exception>
        public Type CreateType(ModuleBuilder modBuilder,
                               TypeNameProvider proxyTypeNamePrefixProvider,
                               TypeNameProvider proxyTypeNameProvider,
                               TypeNameProvider proxyTypeNameSuffixProvider)
        {
            if (modBuilder == null)
            {
                throw new ArgumentNullException("modBuilder");
            }

            string prefix = proxyTypeNamePrefixProvider == null ? null
                                                                : (StringHelper.AsString(proxyTypeNamePrefixProvider(this.InterfaceType)) ?? string.Empty).Trim();
            string name = proxyTypeNameProvider == null ? null
                                                        : (StringHelper.AsString(proxyTypeNameProvider(this.InterfaceType)) ?? string.Empty).Trim();
            string suffix = proxyTypeNameSuffixProvider == null ? null
                                                                : (StringHelper.AsString(proxyTypeNameSuffixProvider(this.InterfaceType)) ?? string.Empty).Trim();

            Type baseType = typeof(object);

            TypeBuilder typeBuilder = modBuilder.DefineType(string.Format("{0}{1}{2}",
                                                                          prefix,
                                                                          name,
                                                                          suffix),
                                                            TypeAttributes.Public | TypeAttributes.Class,
                                                            baseType);

            typeBuilder.AddInterfaceImplementation(this.InterfaceType);

            List <PropertyInfo> properties = new List <PropertyInfo>();

            CollectProperties(properties, this.InterfaceType);

            // properties
            {
                foreach (PropertyInfo p in properties)
                {
                    string propertyName = p.Name;
                    Type   propertyType = p.PropertyType;

                    PropertyBuilder propertyBuilder = typeBuilder.DefineProperty(propertyName,
                                                                                 PropertyAttributes.None,
                                                                                 propertyType,
                                                                                 Type.EmptyTypes);

                    string fieldName = char.ToLower(propertyName[0]) +
                                       new string(CollectionHelper.ToArray(CollectionHelper.Skip(propertyName, 1)));

                    FieldBuilder field = typeBuilder.DefineField("_" + fieldName,
                                                                 propertyType,
                                                                 FieldAttributes.Family);

                    // getter
                    {
                        MethodBuilder methodBuilder = typeBuilder.DefineMethod("get_" + propertyName,
                                                                               MethodAttributes.Public | MethodAttributes.Virtual,
                                                                               propertyType,
                                                                               Type.EmptyTypes);

                        ILGenerator ilGen = methodBuilder.GetILGenerator();

                        ilGen.Emit(OpCodes.Ldarg_0);      // load "this"
                        ilGen.Emit(OpCodes.Ldfld, field); // load the property's underlying field onto the stack
                        ilGen.Emit(OpCodes.Ret);          // return the value on the stack

                        propertyBuilder.SetGetMethod(methodBuilder);
                    }

                    // setter
                    {
                        MethodBuilder methodBuilder = typeBuilder.DefineMethod("set_" + propertyName,
                                                                               MethodAttributes.Public | MethodAttributes.Virtual,
                                                                               typeof(void),
                                                                               new Type[] { propertyType });

                        ILGenerator ilGen = methodBuilder.GetILGenerator();

                        ilGen.Emit(OpCodes.Ldarg_0);      // load "this"
                        ilGen.Emit(OpCodes.Ldarg_1);      // load "value" onto the stack
                        ilGen.Emit(OpCodes.Stfld, field); // set the field equal to the "value" on the stack
                        ilGen.Emit(OpCodes.Ret);          // return nothing

                        propertyBuilder.SetSetMethod(methodBuilder);
                    }
                }
            }

            // constructor
            {
                ConstructorInfo baseConstructor = baseType.GetConstructor(new Type[0]);

                ConstructorBuilder constructorBuilder = typeBuilder.DefineConstructor(MethodAttributes.Public,
                                                                                      CallingConventions.Standard,
                                                                                      Type.EmptyTypes);

                ILGenerator ilGen = constructorBuilder.GetILGenerator();
                ilGen.Emit(OpCodes.Ldarg_0);                  // load "this"
                ilGen.Emit(OpCodes.Call, baseConstructor);    // call the base constructor

                //TODO
                // define initial values

                ilGen.Emit(OpCodes.Ret);    // return nothing
            }

            return(typeBuilder.CreateType());
        }
コード例 #31
0
 public static BlockLengthCode MakeCode(int length)
 {
     return(new BlockLengthCode(CollectionHelper.FindRangeIndex(BlockLengthCodeRanges, length)));
 }
コード例 #32
0
        //  CR# 157474 -Ends
        //
        #endregion Variable Declaration
        //
        #region Constructor
        //
        public CDeclaration()
        {
            try
            {
                LogInfo("START Loading Declaration Screen");
                InitializeComponent();
                ExchangeConnectionString = String.Empty;
                TicketingConnectionString = String.Empty;
                SiteCode = String.Empty;
                _NoOfMachinesPerThread = Convert.ToInt32(ConfigurationManager.AppSettings["NoOfDeclarationMachinesPerThread"]);
                if (_NoOfMachinesPerThread == 0) _NoOfMachinesPerThread = 1;
                _WaitTime = Convert.ToInt32(ConfigurationManager.AppSettings["DeclarationWaitTime"]);
                if (_WaitTime == 0) _WaitTime = 1;
                ManualCashEntry.sSiteCode = String.Empty;
                pgDeclaration.Visibility = Visibility.Collapsed;
                txtPGStatus.Visibility = Visibility.Collapsed;
                txtFilterText.PreviewMouseUp += new System.Windows.Input.MouseButtonEventHandler(txtFilterText_PreviewMouseUp);
               
                _collectionHelper = new CollectionHelper();

                isCommonCDOforDeclaration = false;

                if (Login._siteconfig != null && Login._siteconfig.Count > 0)
                {
                    isCommonCDOforDeclaration = true;
                    this.cboSiteCode.SelectionChanged -= cboSiteCode_SelectionChanged;
                    cboSiteCode.ItemsSource = Login._siteconfig;
                    this.cboSiteCode.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.cboSiteCode_SelectionChanged);
                    cboSiteCode.SelectedItem = Login._siteconfig.Find(m => m.SiteCode == Settings.SiteCode);
                }
                else
                {
                    CustomizeDeclaration();
                }

                CustomizeColumns();
                btnCashEntry.Visibility = Visibility.Collapsed;
                bool IsCounterEnabled = _collectionHelper.IsNoteCounterVisible();

                if (IsCounterEnabled)
                {
                    btnBillCounter.Content = FindResource("CDeclaration_xaml_btnBillCounter").ToString();
                }
                else
                {
                    btnBillCounter.Content = FindResource("CDeclaration_xaml_btnCashEntry").ToString();
                }

                if (Settings.CentralizedDeclaration)
                {
                    btnAcceptAll.Visibility = Visibility.Hidden;
                    btnBillCounter.Visibility = Visibility.Hidden;
                   
                }
                IsPartCollectionDeclaration = Security.SecurityHelper.HasAccess("BMC.Presentation.CDeclaration.PartCollectionDeclaration");
                SetCombo();
                LogInfo("END Loading Declaration Screen");
                
            }
            catch (Exception Ex)
            {
                MessageBox.ShowBox("MessageID425", BMC_Icon.Error);
                LogError("CDeclaration", Ex);
                SetDefaultCombo();
                dgDeclaration.ItemsSource = null;
            }
            finally
            {
                SetVisibilityForCurrencys();
            }
        }
コード例 #33
0
 /// <summary>
 ///
 /// </summary>
 /// <see cref="CollectionHelper.IsEmpty(IEnumerable)" />
 public static bool IsEmpty(this IEnumerable seq)
 {
     return(CollectionHelper.IsEmpty(seq));
 }
コード例 #34
0
        public ManualCashEntry()
        {
            InitializeComponent();
            _currentCurrency = txt500;
            _currentCurrency.TextChanged += CurrentCurrencyTextChanged;
            TicketEntryScreen.Visibility = Visibility.Collapsed;
            //txtTicketValue.AddHandler(TextBox.PreviewKeyDownEvent, new KeyEventHandler(txtTicketValue_KeyDown), true);
            txtScanedTicket.AddHandler(TextBox.PreviewKeyDownEvent, new KeyEventHandler(txtScanedTicket_KeyDown), true);
            var d = Convert.ToDecimal(1.1);
            decimal.TryParse(d.ToString(new CultureInfo(ExtensionMethods.CurrentCurrenyCulture)), NumberStyles.Currency, new CultureInfo(ExtensionMethods.CurrentCurrenyCulture), out d);
            btnDot.Content = d.ToString(new CultureInfo(ExtensionMethods.CurrentCurrenyCulture)).Substring(1, 1);
            this.DataContext = this;
            ShowCurrencyByRegion();
            MessageBox.childOwner = this;
            TokenValue = 1;

            if (Settings.TicketDeclaration.ToUpper() == "AUTO" || Settings.TicketDeclaration.ToUpper() == "METER")
            {
                txtTicketsIn.IsEnabled = false;
            }
            //if (Security.SecurityHelper.HasAccess("BMC.Presentation.CommonCDOforDeclaration"))
            //{
            //    isCommonCDOforDeclaration = true;
            //}
            //CalculateTotal();

            this.txt500.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.CurrentCurrencyTextChanged);
            this.txt200.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.CurrentCurrencyTextChanged);
            this.txt100.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.CurrentCurrencyTextChanged);
            this.txt50.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.CurrentCurrencyTextChanged);
            this.txt20.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.CurrentCurrencyTextChanged);
            this.txt10.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.CurrentCurrencyTextChanged);
            this.txt5.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.CurrentCurrencyTextChanged);
            this.txt2.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.CurrentCurrencyTextChanged);
            this.txt1.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.CurrentCurrencyTextChanged);
            this.txtTotalCoins.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.CurrentCurrencyTextChanged);
            this.txtTicketsIn.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.CurrentCurrencyTextChanged);
            if (!String.IsNullOrEmpty(sSiteCode))
            {
                this.tbHeader.Text += "\t      " + Application.Current.FindResource("ManualCashEntry_xaml_lblSiteCode").ToString().Trim() + " " + sSiteCode;
                this.tbHeader1.Text += "\t\t  " + Application.Current.FindResource("ManualCashEntry_xaml_lblSiteCode").ToString().Trim() + " " + sSiteCode;
            }
            objColHelper = new CollectionHelper();

        }
コード例 #35
0
        public BillsTicketCounter(int batch, DeclarationFilterBy filterBy, string filterValue, string SiteCode, int CurrentIndex)
        {
            InitializeComponent();
            LogManager.WriteLog("BillsTicketCounter:BillsTicketCounter() Entry", LogManager.enumLogLevel.Info);
            LogManager.WriteLog("BillsTicketCounter:BillsTicketCounter() Site Code : "+SiteCode, LogManager.enumLogLevel.Debug);
            try
            {
                _CurrentCollectionIndex = CurrentIndex;
                //CollectionHelper _collectionHelper = new CollectionHelper();
                this._filterBy = filterBy;
                this._filterValue = filterValue;
                this._batchNo = batch;
                this._SiteCode = SiteCode;
                _objCollectionHelper = new CollectionHelper();
                _objExchangeHelper = new ExchangeHelper();
                _objTicketsHelper = new TicketsHelper();
                btnExceptionTickets.Visibility = (Settings.HANDLE_EXCEPTIONTICKETS_COUNTER) ? Visibility.Visible : Visibility.Collapsed;
                RefreshData(_CurrentCollectionIndex);

                //this.txtAsset.Text = lstCollections[1].AssetNo;
                //this.txtPosition.Text = lstCollections[1].Position;
                //this.iCollectionNo = lstCollections[1].CollectionNo;
                //_CollectionNo = lstCollections[1].CollectionNo;
                //this.sPosition = lstCollections[1].Position;
                //this.txtGame.Text = "";

                MessageBox.childOwner = this;

                if (!String.IsNullOrEmpty(ManualCashEntry.sSiteCode))
                {
                    txtHeader.Text += "\t\t\t\t" + Application.Current.FindResource("ManualCashEntry_xaml_lblSiteCode").ToString().Trim() + " " + _SiteCode;
                }
                bool IsCounterEnabled = _objCollectionHelper.IsNoteCounterVisible();
                if (!IsCounterEnabled)
                {
                    btnApply.Visibility = Visibility.Hidden;
                    btnStart.Visibility = Visibility.Hidden;
                    btnClearAll.Visibility = Visibility.Hidden;
                }

            }
            catch (Exception Ex)
            {
                ExceptionManager.Publish(Ex);
            }
            LogManager.WriteLog("BillsTicketCounter:BillsTicketCounter() Exit", LogManager.enumLogLevel.Info);

        }
コード例 #36
0
        /// <summary>
        /// Completes construction of the blob asset and returns a reference to the asset in unmanaged memory.
        /// </summary>
        /// <remarks>Use the <see cref="BlobAssetReference{T}"/> to access the blob asset. When the asset is no longer
        /// needed, call<see cref="BlobAssetReference{T}.Dispose()"/> to destroy the blob asset and free its allocated
        /// memory.</remarks>
        /// <param name="allocator">The type of memory to allocate. Unless the asset has a very short life span, use
        /// <see cref="Allocator.Persistent"/>.</param>
        /// <typeparam name="T">The data type of the struct used to construct the asset's root. Use the same struct type
        /// that you used when calling <see cref="ConstructRoot{T}"/>.</typeparam>
        /// <returns></returns>
        public BlobAssetReference <T> CreateBlobAssetReference <T>(Allocator allocator) where T : struct
        {
            var offsets      = new NativeArray <int>(m_allocations.Length + 1, Allocator.Temp);
            var sortedAllocs = new NativeArray <SortedIndex>(m_allocations.Length, Allocator.Temp);

            offsets[0] = 0;
            for (int i = 0; i < m_allocations.Length; ++i)
            {
                offsets[i + 1]  = offsets[i] + m_allocations[i].size;
                sortedAllocs[i] = new SortedIndex {
                    p = m_allocations[i].p, index = i
                };
            }
            int dataSize = offsets[m_allocations.Length];

            sortedAllocs.Sort();
            var sortedPatches = new NativeArray <SortedIndex>(m_patches.Length, Allocator.Temp);

            for (int i = 0; i < m_patches.Length; ++i)
            {
                sortedPatches[i] = new SortedIndex {
                    p = (byte *)m_patches[i].offsetPtr, index = i
                }
            }
            ;
            sortedPatches.Sort();

            byte *buffer = (byte *)UnsafeUtility.Malloc(sizeof(BlobAssetHeader) + dataSize, 16, allocator);
            byte *data   = buffer + sizeof(BlobAssetHeader);

            for (int i = 0; i < m_allocations.Length; ++i)
            {
                UnsafeUtility.MemCpy(data + offsets[i], m_allocations[i].p, m_allocations[i].size);
            }

            int iAlloc     = 0;
            var allocStart = m_allocations[sortedAllocs[0].index].p;
            var allocEnd   = allocStart + m_allocations[sortedAllocs[0].index].size;

            for (int i = 0; i < m_patches.Length; ++i)
            {
                int  patchIndex = sortedPatches[i].index;
                int *offsetPtr  = (int *)sortedPatches[i].p;

                while (offsetPtr > allocEnd)
                {
                    ++iAlloc;
                    allocStart = m_allocations[sortedAllocs[iAlloc].index].p;
                    allocEnd   = allocStart + m_allocations[sortedAllocs[iAlloc].index].size;
                }

                var patch = m_patches[patchIndex];

                int offsetPtrInData = offsets[sortedAllocs[iAlloc].index] + (int)((byte *)offsetPtr - allocStart);
                int targetPtrInData = offsets[patch.target.allocIndex] + patch.target.offset;

                *(int *)(data + offsetPtrInData) = targetPtrInData - offsetPtrInData;
                if (patch.length != 0)
                {
                    *(int *)(data + offsetPtrInData + 4) = patch.length;
                }
            }

            sortedPatches.Dispose();
            sortedAllocs.Dispose();
            offsets.Dispose();

            BlobAssetHeader *header = (BlobAssetHeader *)buffer;

            *header = new BlobAssetHeader();
            header->Length    = (int)dataSize;
            header->Allocator = allocator;

            // @TODO use 64bit hash
            header->Hash = math.hash(buffer + sizeof(BlobAssetHeader), dataSize);

            BlobAssetReference <T> blobAssetReference;

            blobAssetReference.m_data.m_Align8Union = 0;
            header->ValidationPtr = blobAssetReference.m_data.m_Ptr = buffer + sizeof(BlobAssetHeader);

            return(blobAssetReference);
        }

        void *AllocationToPointer(BlobDataRef blobDataRef)
        {
            return(m_allocations[blobDataRef.allocIndex].p + blobDataRef.offset);
        }

        BlobAllocation EnsureEnoughRoomInChunk(int size, int alignment)
        {
            if (m_currentChunkIndex == -1)
            {
                return(AllocateNewChunk());
            }

            var alloc       = m_allocations[m_currentChunkIndex];
            int startOffset = CollectionHelper.Align(alloc.size, alignment);

            if (startOffset + size > m_chunkSize)
            {
                return(AllocateNewChunk());
            }

            UnsafeUtility.MemClear(alloc.p + alloc.size, startOffset - alloc.size);

            alloc.size = startOffset;
            return(alloc);
        }

        BlobDataRef Allocate(int size, int alignment)
        {
            if (size > m_chunkSize)
            {
                size = CollectionHelper.Align(size, 16);
                var allocIndex = m_allocations.Length;
                var mem        = (byte *)UnsafeUtility.Malloc(size, alignment, m_allocator);
                UnsafeUtility.MemClear(mem, size);
                m_allocations.Add(new BlobAllocation {
                    p = mem, size = size
                });
                return(new BlobDataRef {
                    allocIndex = allocIndex, offset = 0
                });
            }

            BlobAllocation alloc = EnsureEnoughRoomInChunk(size, alignment);

            var offset = alloc.size;

            UnsafeUtility.MemClear(alloc.p + alloc.size, size);
            alloc.size += size;
            m_allocations[m_currentChunkIndex] = alloc;
            return(new BlobDataRef {
                allocIndex = m_currentChunkIndex, offset = offset
            });
        }

        BlobAllocation AllocateNewChunk()
        {
            // align size of last chunk to 16 bytes so chunks can be concatenated without breaking alignment
            if (m_currentChunkIndex != -1)
            {
                var currentAlloc = m_allocations[m_currentChunkIndex];
                currentAlloc.size = CollectionHelper.Align(currentAlloc.size, 16);
                m_allocations[m_currentChunkIndex] = currentAlloc;
            }

            m_currentChunkIndex = m_allocations.Length;
            var alloc = new BlobAllocation {
                p = (byte *)UnsafeUtility.Malloc(m_chunkSize, 16, m_allocator), size = 0
            };

            m_allocations.Add(alloc);
            return(alloc);
        }
コード例 #37
0
        //
        private void cboSiteCode_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            try
            {
                LogManager.WriteLog("cboSiteCode_SelectionChanged Entry", LogManager.enumLogLevel.Debug);
                LogManager.WriteLog("Selected Site Code is " + (cboSiteCode.SelectedItem as SiteConfig).SiteCode, LogManager.enumLogLevel.Debug);
                if (!CollectionHelper.IsServerConnected((cboSiteCode.SelectedItem as SiteConfig).ExchangeConnectionString))
                {
                    LogManager.WriteLog("Unable to connect to the server", LogManager.enumLogLevel.Debug);
                    SetDefaultSiteCode(false, e);
                    LogManager.WriteLog("Returning without any message", LogManager.enumLogLevel.Debug);
                    return;
                }
                _collectionHelper = new CollectionHelper((cboSiteCode.SelectedItem as SiteConfig).ExchangeConnectionString);

                if (!_collectionHelper.IsAuthorized(SecurityHelper.CurrentUser.SecurityUserID, "BMC.Presentation.CommonCDOforDeclaration"))
                {
                    LogManager.WriteLog("User does not have authentication", LogManager.enumLogLevel.Debug);
                    SetDefaultSiteCode(true,e);
                    return;
                }

                CheckDeclarationMethod();

                SetCombo();
            }
            catch (Exception Ex)
            {
                LogError("cboSiteCode_SelectionChanged", Ex);
                SetDefaultCombo();
                dgDeclaration.ItemsSource = null;
            }
            LogManager.WriteLog("cboSiteCode_SelectionChanged Exit", LogManager.enumLogLevel.Debug);
        }
コード例 #38
0
        public void Handle(LogLine logLine, IHsGameState gameState, IGame game)
        {
            var match = LogConstants.GameModeRegex.Match(logLine.Line);

            if (match.Success)
            {
                game.CurrentMode  = GetMode(match.Groups["curr"].Value);
                game.PreviousMode = GetMode(match.Groups["prev"].Value);

                if ((DateTime.Now - logLine.Time).TotalSeconds < 5 && _lastAutoImport < logLine.Time &&
                    game.CurrentMode == Mode.TOURNAMENT)
                {
                    _lastAutoImport = logLine.Time;
                    var decks = DeckImporter.FromConstructed();
                    if (decks.Any() && (Config.Instance.ConstructedAutoImportNew || Config.Instance.ConstructedAutoUpdate))
                    {
                        DeckManager.ImportDecks(decks, false, Config.Instance.ConstructedAutoImportNew,
                                                Config.Instance.ConstructedAutoUpdate);
                    }
                }

                if (game.PreviousMode == Mode.GAMEPLAY && game.CurrentMode != Mode.GAMEPLAY)
                {
                    gameState.GameHandler.HandleInMenu();
                }

                if (game.CurrentMode == Mode.HUB && !_checkedMirrorStatus && (DateTime.Now - logLine.Time).TotalSeconds < 5)
                {
                    CheckMirrorStatus();
                    if (CollectionHelper.IsAwaitingUpdate)
                    {
                        CollectionHelper.TryUpdateCollection().Forget();
                    }
                }

                if (game.CurrentMode == Mode.DRAFT)
                {
                    Watchers.ArenaWatcher.Run();
                }
                else
                {
                    Watchers.ArenaWatcher.Stop();
                }

                if (game.CurrentMode == Mode.PACKOPENING)
                {
                    Watchers.PackWatcher.Run();
                }
                else
                {
                    Watchers.PackWatcher.Stop();
                }

                if (game.CurrentMode == Mode.TAVERN_BRAWL)
                {
                    Core.Game.CacheBrawlInfo();
                }

                API.GameEvents.OnModeChanged.Execute(game.CurrentMode);
            }
            else if (logLine.Line.Contains("Gameplay.Start"))
            {
                gameState.Reset();
                gameState.GameHandler.HandleGameStart(logLine.Time);
            }
        }
コード例 #39
0
 public IEnumerable <IXmlElement> Elements()
 {
     return(CollectionHelper.OfType <IXmlElement>(this.Nodes()));
 }
コード例 #40
0
        public void UpdateGroupPageRightTrans(List <ChildPagesPermissionCollection> childPagesPermissionTrueCollection, List <ChildPagesPermissionCollection> childPagesPermissionFalseCollection)
        {
            int returnValue = 0;
            //Added By Shivali Thakur for Audit Log
            DataTable dtUpdateGroupPageRightsTrue  = CollectionHelper.ConvertTo(childPagesPermissionTrueCollection, "");
            DataTable dtUpdateGroupPageRightsFalse = CollectionHelper.ConvertTo(childPagesPermissionFalseCollection, "");
            var       usr       = ((CargoFlash.Cargo.Model.UserLogin)(System.Web.HttpContext.Current.Session["UserDetail"])).UserSNo;
            var       UserGroup = ((CargoFlash.Cargo.Model.UserLogin)(System.Web.HttpContext.Current.Session["UserDetail"])).GroupName;
            var       Name      = ((CargoFlash.Cargo.Model.UserLogin)(System.Web.HttpContext.Current.Session["UserDetail"])).UserName;

            System.Web.HttpBrowserCapabilities browser = System.Web.HttpContext.Current.Request.Browser;
            var       Browser      = browser.Browser;
            IPAddress ipAddress    = Array.FindLast(Dns.GetHostEntry(string.Empty).AddressList, a => a.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork);
            var       city         = ((CargoFlash.Cargo.Model.UserLogin)(System.Web.HttpContext.Current.Session["UserDetail"])).CityCode;
            var       TerminalSNo  = ((CargoFlash.Cargo.Model.UserLogin)(System.Web.HttpContext.Current.Session["UserDetail"])).TerminalSNo;
            var       TerminalName = ((CargoFlash.Cargo.Model.UserLogin)(System.Web.HttpContext.Current.Session["UserDetail"])).NewTerminalName;


            SqlParameter User = new SqlParameter("@User", SqlDbType.Int);

            User.Value     = usr;
            User.Direction = ParameterDirection.Input;

            SqlParameter GroupName = new SqlParameter("@UserGroup", SqlDbType.Text);

            GroupName.Value     = UserGroup;
            GroupName.Direction = ParameterDirection.Input;

            SqlParameter UserName = new SqlParameter("@UName", SqlDbType.Text);

            UserName.Value     = Name.ToString();
            UserName.Direction = ParameterDirection.Input;

            SqlParameter Brows = new SqlParameter("@Browser", SqlDbType.Text);

            Brows.Value     = Browser;
            Brows.Direction = ParameterDirection.Input;

            SqlParameter ip = new SqlParameter("@ip", SqlDbType.Text);

            ip.Direction = ParameterDirection.Input;
            ip.Value     = ipAddress.ToString();

            SqlParameter LoginCity = new SqlParameter("@LoginCity", SqlDbType.Text);

            LoginCity.Value     = city;
            LoginCity.Direction = ParameterDirection.Input;

            SqlParameter TSNo = new SqlParameter("@TerminalSNo", SqlDbType.Int);

            TSNo.Direction = ParameterDirection.Input;
            TSNo.Value     = TerminalSNo;

            SqlParameter TName = new SqlParameter("@TerminalName", SqlDbType.Text);

            TName.Direction = ParameterDirection.Input;
            TName.Value     = TerminalName;

            SqlParameter paramTrue = new SqlParameter();

            paramTrue.ParameterName = "@GroupPageRightTransTable";
            paramTrue.SqlDbType     = System.Data.SqlDbType.Structured;
            paramTrue.Value         = dtUpdateGroupPageRightsTrue;

            SqlParameter paramFalse = new SqlParameter();

            paramFalse.ParameterName = "@GroupPageRightTransTable2";
            paramFalse.SqlDbType     = System.Data.SqlDbType.Structured;
            paramFalse.Value         = dtUpdateGroupPageRightsFalse;

            SqlParameter errorMessage = new SqlParameter("@ErrorMessage", SqlDbType.Text);

            errorMessage.Direction = ParameterDirection.Output;
            errorMessage.Size      = 250;

            SqlParameter errorNumber = new SqlParameter("@ErrorNumber", SqlDbType.Int);

            errorMessage.Direction = ParameterDirection.Output;
            errorMessage.Size      = 32;
            SqlParameter[] Parameters = { User, GroupName, UserName, Brows, ip, LoginCity, TSNo, TName, paramTrue, paramFalse, errorNumber, errorMessage };

            //DataSet ds = SqlHelper.ExecuteDataset(connectionString, "UpdateGroupPageRightTrans", Parameters);

            int ret = SqlHelper.ExecuteNonQuery(DMLConnectionString.WebConfigConnectionString, "UpdateGroupPageRightTrans", Parameters);

            if (ret != -1)
            {
                //Error
                returnValue = Convert.ToInt32(errorNumber.Value);
            }
        }