Example #1
1
        public Image3D(string workingDirectory, IList<Image2D> images)
        {
            this.WorkingDirectory = workingDirectory;

            this.OriginalSlices = images.ToArray();
            this.Slices = images.ToArray();
        }
Example #2
1
        public DataTable GetQueryResult(string Connection,
                            IList<string> lstPdLine, IList<string> Model, bool IsWithoutShift, string ModelCategory)
        {
            string methodName = MethodBase.GetCurrentMethod().Name;
            BaseLog.LoggingBegin(logger, methodName);
            try
            {
                string SQLText = "";
                StringBuilder sb = new StringBuilder();
                
                sb.AppendLine("SELECT DISTINCT a.ProductID,a.CUSTSN,b.InfoValue as 'IMGCL',c.Line ");
                sb.AppendLine("FROM Product a  (NOLOCK) ");
                sb.AppendLine("INNER JOIN ProductInfo b (NOLOCK) ON b.ProductID = a.ProductID ");
                sb.AppendLine("INNER JOIN ProductStatus c (NOLOCK) ON c.ProductID = a.ProductID ");
                sb.AppendLine("WHERE  b.InfoType='IMGCL' ");

                if (lstPdLine.Count > 0)
                {
                    if (IsWithoutShift)
                    {
                        sb.AppendFormat("AND SUBSTRING(c.Line,1,1) in ('{0}') ", string.Join("','", lstPdLine.ToArray()));
                    }
                    else
                    {
                        sb.AppendFormat("AND c.Line in ('{0}') ", string.Join("','", lstPdLine.ToArray()));
                    }
                }
                if (Model.Count > 0)
                {
                    sb.AppendFormat("AND a.ProductID in ('{0}') ", string.Join("','", Model.ToArray()));
                }
                if (ModelCategory != "")
                {
                    sb.AppendFormat(" AND dbo.CheckModelCategory(a.Model,'" + ModelCategory + "')='Y' ");
                }              
                SQLText = sb.ToString();
                return SQLHelper.ExecuteDataFill(Connection,
                                                 System.Data.CommandType.Text,
                                                 SQLText
                                                 );
            }
            catch (Exception e)
            {

                BaseLog.LoggingError(logger, MethodBase.GetCurrentMethod(), e);
                throw;
            }
            finally
            {
                BaseLog.LoggingEnd(logger, methodName);
            }
        }
Example #3
1
        public MultilayerPerceptron(int numInputs, int numOutputs, IList<int> hiddenLayerSizes)
        {
            if (numInputs <= 0)
                throw new NeuralNetworkException($"Argument {nameof(numInputs)} must be positive; was {numInputs}.");

            if (numOutputs <= 0)
                throw new NeuralNetworkException($"Argument {nameof(numOutputs)} must be positive; was {numOutputs}.");

            if (hiddenLayerSizes == null || !hiddenLayerSizes.Any())
                throw new NeuralNetworkException($"Argument {nameof(hiddenLayerSizes)} cannot be null or empty.");

            if (hiddenLayerSizes.Any(h => h <= 0))
            {
                var badSize = hiddenLayerSizes.First(h => h <= 0);
                var index = hiddenLayerSizes.IndexOf(badSize);
                throw new NeuralNetworkException($"Argument {nameof(hiddenLayerSizes)} must contain only positive " +
                                                $"values; was {badSize} at index {index}.");
            }

            NumInputs = numInputs;
            NumOutputs = numOutputs;
            HiddenLayerSizes = hiddenLayerSizes.ToArray();

            Weights = new double[hiddenLayerSizes.Count + 1][];

            for (var i = 0; i < hiddenLayerSizes.Count + 1; i++)
            {
                if (i == 0)
                    Weights[i] = new double[(numInputs + 1) * hiddenLayerSizes[0]];
                else if (i < hiddenLayerSizes.Count)
                    Weights[i] = new double[(hiddenLayerSizes[i-1] + 1) * hiddenLayerSizes[i]];
                else
                    Weights[i] = new double[(hiddenLayerSizes[hiddenLayerSizes.Count - 1] + 1) * numOutputs];
            }
        }
Example #4
1
 public PathRecord(IVertex target, double weight, IList<IEdge> edgeTracks)
 {
     Target = target;
     Weight = weight;
     EdgeTracks = edgeTracks.ToArray();
     ParseVertexTracks(edgeTracks);
 }
Example #5
1
		public FunctionCall(Expression root, Token parenToken, IList<Expression> args, Executable owner)
			: base(root.FirstToken, owner)
		{
			this.Root = root;
			this.ParenToken = parenToken;
			this.Args = args.ToArray();
		}
Example #6
1
        public DataTable GetPdLine(string customer, IList<string> lstProcess, string DBConnection)
        {
            string methodName = MethodBase.GetCurrentMethod().Name;
            BaseLog.LoggingBegin(logger, methodName);

            try
            {
                string SQLText = @" SELECT Line,Descr FROM Line (NOLOCK) WHERE [email protected] "; // AND Stage IN (@process) ORDER BY 1";                
                SQLText += string.Format(" AND Stage IN ('{0}')", string.Join("','", lstProcess.ToArray()));
                SQLText += " ORDER BY 1";
                return SQLHelper.ExecuteDataFill(DBConnection,
                                                 System.Data.CommandType.Text,
                                                 SQLText,
                                                 SQLHelper.CreateSqlParameter("@customer", 32, customer, ParameterDirection.Input));
                                                 //SQLHelper.CreateSqlParameter("@process", 32, process, ParameterDirection.Input));
            }
            catch (Exception e)
            {

                BaseLog.LoggingError(logger, MethodBase.GetCurrentMethod(), e);
                throw;
            }
            finally
            {
                BaseLog.LoggingEnd(logger, methodName);
            }
        }
 public ImportStatement(Token importToken, IList<Token> importChain, IList<Token> fromChain, Token asValue)
     : base(importToken)
 {
     this.ImportChain = importChain.ToArray();
     this.FromChain = fromChain == null ? null : fromChain.ToArray();
     this.AsValue = asValue;
 }
Example #8
1
        public static void ExtractConfigfileFromJar(string reefJar, IList<string> configFiles, string dropFolder)
        {
            var configFileNames = string.Join(" ", configFiles.ToArray());
            var startInfo = new ProcessStartInfo
            {
                FileName = GetJarBinary(),
                Arguments = @"xf " + reefJar + " " + configFileNames,
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                UseShellExecute = false,
                CreateNoWindow = true
            };

            LOGGER.Log(Level.Info,
                "extracting files from jar file with \r\n" + startInfo.FileName + "\r\n" + startInfo.Arguments);
            using (var process = Process.Start(startInfo))
            {
                var outReader = process.StandardOutput;
                var errorReader = process.StandardError;
                var output = outReader.ReadToEnd();
                var error = errorReader.ReadToEnd();
                process.WaitForExit();
                if (process.ExitCode != 0)
                {
                    throw new InvalidOperationException("Failed to extract files from jar file with stdout :" + output +
                                                        "and stderr:" + error);
                }
            }
            LOGGER.Log(Level.Info, "files are extracted.");
        }
Example #9
1
 public void Serialize(IList<Employee> employees)
 {
     using (var stream = new FileStream(FilePath, FileMode.Truncate))
     {
         serializer.Serialize(stream, employees.ToArray());
     }
 }
Example #10
1
        public bool SignalExternalCommandLineArgs(IList<string> args)
        {
            // handle command line arguments of second instance
            HandleArguments(args.ToArray());

            return true;
        }
 public SystemFunctionInvocation(Token prefix, Token root, IList<Expression> args)
     : base(prefix)
 {
     this.Root = root;
     this.Name = root.Value;
     this.Args = args.ToArray();
 }
Example #12
0
		// The reason why I still run this function with actuallyDoThis = false is so that other platforms can still be exported to
		// and potentially crash if the implementation was somehow broken on Python (or some other future platform that doesn't have traditional switch statements).
		internal static Executable[] RemoveBreaksForElifedSwitch(bool actuallyDoThis, IList<Executable> executables)
		{
			List<Executable> newCode = new List<Executable>(executables);
			if (newCode.Count == 0) throw new Exception("A switch statement contained a case that had no code and a fallthrough.");
			if (newCode[newCode.Count - 1] is BreakStatement)
			{
				newCode.RemoveAt(newCode.Count - 1);
			}
			else if (newCode[newCode.Count - 1] is ReturnStatement)
			{
				// that's okay.
			}
			else
			{
				throw new Exception("A switch statement contained a case with a fall through.");
			}

			foreach (Executable executable in newCode)
			{
				if (executable is BreakStatement)
				{
					throw new Exception("Can't break out of case other than at the end.");
				}
			}

			return actuallyDoThis ? newCode.ToArray() : executables.ToArray();
		}
        public bool CheckGoodsIssueFIFO(string locationCode, string itemCode, DateTime baseManufatureDate, IList<string> huIdList)
        {
            DetachedCriteria criteria = DetachedCriteria.For<LocationLotDetail>();
            criteria.SetProjection(Projections.Count("Id"));

            criteria.CreateAlias("Hu", "hu");
            criteria.CreateAlias("Location", "loc");
            criteria.CreateAlias("Item", "item");

            criteria.Add(Expression.IsNotNull("Hu"));
            criteria.Add(Expression.Gt("Qty", new Decimal(0)));
            criteria.Add(Expression.Eq("item.Code", itemCode));
            criteria.Add(Expression.Eq("loc.Code", locationCode));
            criteria.Add(Expression.Lt("hu.ManufactureDate", baseManufatureDate));
            criteria.Add(Expression.Not(Expression.In("hu.HuId", huIdList.ToArray<string>())));

            IList<int> list = this.criteriaMgr.FindAll<int>(criteria);
            if (list[0] > 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
Example #14
0
        /// <summary>
        /// Decompresses a file.
        /// </summary>
        public static byte[] Decompress( IList<byte> bytes )
        {
            List<byte> result = new List<byte>( 1024 * 1024 );
            using( GZipStream stream = new GZipStream( new MemoryStream( bytes.ToArray() ), CompressionMode.Decompress, false ) )
            {
                byte[] buffer = new byte[2048];

                int b = 0;
                while( true )
                {
                    b = stream.Read( buffer, 0, 2048 );
                    if( b < 2048 )
                        break;
                    else
                        result.AddRange( buffer );
                }

                if( b > 0 )
                {
                    result.AddRange( buffer.Sub( 0, b - 1 ) );
                }
            }

            return result.ToArray();
        }
Example #15
0
    public static Tuple<int, int> FindTwoSum(IList<int> list, int sum)
    {
        var newList = list.ToArray();
        var pairs = (from number in list where newList.Contains(sum - number) select Tuple.Create(Array.IndexOf(newList, number), Array.LastIndexOf(newList, sum - number))).ToList();

        return pairs.Count > 0 ? pairs[0] : null;
    }
Example #16
0
		public Annotation(Token firstToken, Token typeToken, IList<Expression> args)
		{
			this.FirstToken = firstToken;
			this.TypeToken = typeToken;
			this.Type = typeToken.Value;
			this.Args = args.ToArray();
		}
        public HRESULT[] WriteVQT(IList<string> itemIds, IList<OpcDaVQT> values)
        {
            if (itemIds.Count != values.Count)
                throw new ArgumentException("Invalid size of values", "values");

            var vqts = new OPCITEMVQT[values.Count];
            for (int i = 0; i < values.Count; i++)
            {
                OpcDaVQT opcItemValue = values[i];
                vqts[i].bQualitySpecified = false;
                if (opcItemValue.Quality != short.MinValue)
                {
                    vqts[i].bQualitySpecified = true;
                    vqts[i].wQuality = opcItemValue.Quality;
                }

                vqts[i].bTimeStampSpecified = false;
                if (opcItemValue.Timestamp != DateTimeOffset.MinValue)
                {
                    vqts[i].bTimeStampSpecified = true;
                    vqts[i].ftTimeStamp = FileTimeConverter.ToFileTime(opcItemValue.Timestamp);
                }

                vqts[i].vDataValue = opcItemValue.Value;
            }

            string[] pszItemIDs = itemIds.ToArray();
            var ppErrors = new HRESULT[pszItemIDs.Length];
            DoComCall(ComObject, "IOPCItemIO::WriteVQT",
                () => ComObject.WriteVQT(pszItemIDs.Length, pszItemIDs, vqts, out ppErrors), pszItemIDs.Length, pszItemIDs);
            return ppErrors;
        }
        public OpcDaVQTE[] Read(IList<string> itemIds, IList<TimeSpan> maxAge)
        {
            if (maxAge == null)
                maxAge = new TimeSpan[itemIds.Count];
            if (itemIds.Count != maxAge.Count)
                throw new ArgumentException("Invalid size of maxAge", "maxAge");

            int[] intMaxAge = ArrayHelpers.CreateMaxAgeArray(maxAge, itemIds.Count);

            string[] pszItemIDs = itemIds.ToArray();
            var ppvValues = new object[pszItemIDs.Length];
            var ppwQualities = new short[pszItemIDs.Length];
            var ppftTimeStamps = new FILETIME[pszItemIDs.Length];
            var ppErrors = new HRESULT[pszItemIDs.Length];
            DoComCall(ComObject, "IOPCItemIO::Read", () =>
                    ComObject.Read(pszItemIDs.Length, pszItemIDs, intMaxAge, out ppvValues, out ppwQualities,
                        out ppftTimeStamps, out ppErrors), pszItemIDs.Length, pszItemIDs,
                maxAge);

            var result = new OpcDaVQTE[itemIds.Count];
            for (int i = 0; i < ppvValues.Length; i++)
            {
                var vqte = new OpcDaVQTE
                {
                    Value = ppvValues[i],
                    Quality = ppwQualities[i],
                    Timestamp = FileTimeConverter.FromFileTime(ppftTimeStamps[i]),
                    Error = ppErrors[i]
                };
                result[i] = vqte;
            }
            return result;
        }
Example #19
0
		public IfStatement(Token ifToken, Expression condition, IList<Executable> trueCode, IList<Executable> falseCode, Executable owner)
			: base(ifToken, owner)
		{
			this.Condition = condition;
			this.TrueCode = trueCode.ToArray();
			this.FalseCode = falseCode.ToArray();
		}
Example #20
0
        public DataTable GetDefectInfo(string DBConnection, DateTime StartTime, DateTime EndTime, IList<string> Family, IList<string> PdLine, IList<string> Model, IList<string> Station)
        {
            string strSQL =
               @"SELECT TOP 1000 a.ID,a.Line,a.Station,a.ActionName,a.PCBNo,c.Descr,a.Editor,a.Cdt	   
                  FROM PCBTestLog a
	              LEFT JOIN PCBTestLog_DefectInfo b on a.ID=b.PCBTestLogID
	              LEFT JOIN DefectCode c on c.Defect = b.DefectCodeID	
                  WHERE a.Status = 0  
	              AND a.PCBNo IN (
		                SELECT a.PCBNo FROM PCB a				
			            RIGHT JOIN ModelBOM b ON b.Component = a.PCBModelID AND b.Material_group = 'MB'
			            RIGHT JOIN Model c ON c.Model = b.Material  AND c.Family IN ('{0}')	
                        RIGHT JOIN dbo.PartInfo d ON InfoType='MB' AND d.PartNo = a.PCBModelID AND InfoValue in ('{1}') 
                   )
	               AND a.Cdt BETWEEN @StartTime AND @EndTime
                   AND a.Station IN ('{2}')
                   AND a.Line IN ('{3}');
                ";

            strSQL = string.Format(strSQL, string.Join("','", Family.ToArray()), string.Join("','", Model.ToArray()), string.Join("','", Station.ToArray()), string.Join("','", PdLine.ToArray()));

            DataTable dt = SQLHelper.ExecuteDataFill(DBConnection,
                                                                                System.Data.CommandType.Text,
                                                                               strSQL, new SqlParameter("@StartTime", StartTime), new SqlParameter("@EndTime", EndTime));

            return dt;
        }
        /// <summary>
        /// Disassembles the given code
        /// </summary>
        /// <param name="generatedCode">The generated code</param>
        public static string Disassemble(IList<byte> generatedCode)
        {
            var strBuffer = new StringBuilder();
            var buffer = new UnmanagedBuffer(generatedCode.ToArray());

            var disasm = new Disasm();
            disasm.Archi = 64;

            int offset = 0;
            while (offset < generatedCode.Count)
            {
                disasm.EIP = new IntPtr(buffer.Ptr.ToInt64() + offset);
                int result = BeaEngine64.Disasm(disasm);

                if (result == (int)BeaConstants.SpecialInfo.UNKNOWN_OPCODE)
                {
                    break;
                }

                //strBuffer.AppendLine("0x" + offset.ToString("X") + " " + disasm.CompleteInstr);
                strBuffer.AppendLine(disasm.CompleteInstr);
                offset += result;
            }

            return strBuffer.ToString();
        }
        public IList<Interval> Merge(IList<Interval> intervals)
        {
            Interval[] intervalArr = intervals.ToArray();
            Array.Sort(intervalArr, new Comparison<Interval>(comparerInterval));

            if (intervalArr.Length < 1)
                return intervalArr;

            IList<Interval> result = new List<Interval>();
            Interval current = intervalArr[0];
            for (int i = 1; i < intervalArr.Length; i++)
            {
                Interval next = intervalArr[i];

                if (next.start > current.end)
                {
                    result.Add(current);
                    current = next;
                }
                else
                {
                    current.end = Math.Max(current.end, next.end);
                }
            }
            result.Add(current);

            return result;
        }
Example #23
0
		public ForEachLoop(Token forToken, Token iteratorVariable, Expression iterableExpression, IList<Executable> body)
			: base(forToken)
		{
			this.IteratorVariable = iteratorVariable;
			this.IterableExpression = iterableExpression;
			this.Body = body.ToArray();
		}
 /// <summary>
 /// Initializes a new cellular automaton with the specified states that has the specified rule.
 /// </summary>
 /// <param name="rule">A rule number</param>
 /// <param name="length">A length of cells</param>
 /// <param name="initialState">An initial state</param>
 public LinearCellularAutomaton(byte rule, int length, IList<bool> initialState)
     : this(rule, length)
 {
     _density = (double)initialState.Count(b => b) / length;
     state = initialState.ToArray();
     _initialState = new System.Collections.ObjectModel.ReadOnlyCollection<bool>(initialState);
 }
Example #25
0
		public Instantiate(Token firstToken, Token firstClassNameToken, string name, IList<Expression> args, Executable owner)
			: base(firstToken, owner)
		{
			this.NameToken = firstClassNameToken;
			this.Name = name;
			this.Args = args.ToArray();
		}
		void IMemcachedNodeLocator.Initialize(IList<IMemcachedNode> nodes)
		{
			// we do not care about dead nodes
			if (this.nodes != null) return;

			this.nodes = nodes.ToArray();
		}
Example #27
0
 public static DataTable Select(string sql, IList<SQLiteParameter> cmdparams = null)
 {
     SQLiteConnection cnn = Connect;
     if (cnn == null)
         return null;
     DataTable dt = new DataTable();
     SQLiteCommand Comm = null;
     SQLiteDataReader Reader = null;
     try
     {
         Comm = new SQLiteCommand(cnn);
         Comm.CommandText = sql;
         if (cmdparams != null)
             Comm.Parameters.AddRange(cmdparams.ToArray());
         Comm.CommandTimeout = TIMEOUT;
         Reader = Comm.ExecuteReader();
         dt.Load(Reader);
     }
     catch (Exception e)
     {
         _Err = e.Message;
         return null;
     }
     finally
     {
         if (Reader != null)
             Reader.Close();
         if (Comm != null)
             Comm.Dispose();
     }
     return dt;
 }
Example #28
0
		public SliceExpression(Expression root, Token bracketToken, IList<Expression> components)
			: base(root.FirstToken)
		{
			this.Root = root;
			this.BracketToken = bracketToken;
			this.Components = components.ToArray();
		}
Example #29
0
      public DataTable GetModel(string DBConnection,  IList<String> PdLine,  DateTime From, DateTime To)
     {
         DataTable Result = null;
         string selectSQL = "";
         string groupbySQL = "";

         groupbySQL += "GROUP by  b.Descr";

         string orderbySQL = "ORDER BY  b.Descr";
         StringBuilder sb = new StringBuilder();
         //sb.AppendLine("WITH [TEMP] AS (");
         sb.AppendLine(" select distinct b.Descr as Family from PCBLog a  inner join  Part b on a.PCBModel=b.PartNo ");


         //sb.AppendLine("INNER JOIN PCB b ON a.PCBNo = b.PCBNo AND e.PartNo = b.PCBModelID ");
         sb.AppendLine("WHERE a.Cdt Between @StartTime AND @EndTime and  b.BomNodeType='MB'   ");
         if (PdLine.Count > 0)
         {
             sb.AppendFormat("AND a.Line in ('{0}') ", string.Join("','", PdLine.ToArray()));
         }


         sb.AppendFormat("{0}  ", groupbySQL);
         sb.AppendFormat("{0}  ", orderbySQL); 
          Result = SQLHelper.ExecuteDataFill(DBConnection, System.Data.CommandType.Text,
                                                 sb.ToString(), new SqlParameter("@StartTime", From), new SqlParameter("@EndTime", To));

         return Result;
     }
Example #30
0
		public ForEachLoop(Token forToken, Token iterationVariable, Expression iterationExpression, IList<Executable> code, Executable owner)
			: base(forToken, owner)
		{
			this.IterationVariable = iterationVariable;
			this.IterationExpression = iterationExpression;
			this.Code = code.ToArray();
		}