Example #1
0
        public HttpResponseMessage SavePO(PurchaseHeaderStructure headerStructure,
                                          PurchaseItemStructure itemStructure,
                                          PurchaseService purServ,
                                          TEVendorPaymentMilestone value,
                                          PurchaseItemwise purItemCond)

        {
            bool res = true;
            int  headerStructureID = 0, itemID = 0, serviceID = 0,
                 PaymntID = 0, ConditionID = 0;
            HttpResponseMessage hrm   = new HttpResponseMessage();
            SuccessInfo         sinfo = new SuccessInfo();
            FailInfo            finfo = new FailInfo();

            try
            {
                headerStructureID = SavePurchaseHeaderStructure(headerStructure);
                if (headerStructureID > 0)
                {
                    itemStructure.HeaderStructureID = headerStructureID;
                    purServ.HeaderStructureID       = headerStructureID;
                    value.ContextIdentifier         = value.ContextIdentifier;
                    purItemCond.HeaderStructureID   = headerStructureID;

                    //itemID = SavePurchaseItemStructure(itemStructure);
                    serviceID = SavePurchaseService(purServ);
                    PaymntID  = PostPOMilestones(value);
                    //ConditionID = SavePurchaseItemWiseCondition(purItemCond);
                }
            }
            catch (Exception ex)
            {
                res = false;
            }
            if (res)
            {
                sinfo.errorcode    = 0;
                sinfo.errormessage = "Successfully Saved";
                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new { info = sinfo })
                });
            }
            else
            {
                finfo.errorcode    = 1;
                finfo.errormessage = "Failed To Save";
                return(new HttpResponseMessage()
                {
                    StatusCode = System.Net.HttpStatusCode.NotAcceptable, Content = new JsonContent(new { info = finfo })
                });
            }
        }
Example #2
0
        public CDev(int idNo, string name = "", int chanNum = 16)
        {
            this._idNo = idNo;

            this._name = name;

            this.ChanMax = chanNum;

            for (int i = 0; i < chanNum; i++)
            {
                SerialNo.Add("");
                Result.Add(0);
                FailInfo.Add("");
                HpResult.Add(new CHPPara.CStepVal());
            }
        }
Example #3
0
        public HttpResponseMessage SavePO(PurchaseHeaderStructure headerStructure,
                                          List <PurchaseItemStructure> itemStructure,
                                          List <PurchaseService> purServ,
                                          List <TEVendorPaymentMilestone> paymntMilestone,
                                          List <PurchaseItemwise> purItemCond)

        {
            bool res = true;
            int  headerStructureID = 0, itemID = 0, serviceID = 0,
                 PaymntID = 0, ConditionID = 0;
            HttpResponseMessage hrm   = new HttpResponseMessage();
            SuccessInfo         sinfo = new SuccessInfo();
            FailInfo            finfo = new FailInfo();

            try
            {
                headerStructureID = SavePurchaseHeaderStructure(headerStructure);
                if (headerStructureID > 0)
                {
                    if (itemStructure.Count > 0)
                    {
                        foreach (PurchaseItemStructure item in itemStructure)
                        {
                            item.HeaderStructureID = headerStructureID;
                            // itemID = SavePurchaseItemStructure(item);
                        }
                    }
                    if (purServ.Count > 0)
                    {
                        foreach (PurchaseService purch in purServ)
                        {
                            purch.HeaderStructureID = headerStructureID;
                            serviceID = SavePurchaseService(purch);
                        }
                    }
                    if (paymntMilestone.Count > 0)
                    {
                        foreach (TEVendorPaymentMilestone mstn in paymntMilestone)
                        {
                            mstn.ContextIdentifier = headerStructureID.ToString();
                            PaymntID = PostPOMilestones(mstn);
                        }
                    }
                    if (purItemCond.Count > 0)
                    {
                        foreach (PurchaseItemwise purchItem in purItemCond)
                        {
                            purchItem.HeaderStructureID = headerStructureID;
                            //ConditionID = SavePurchaseItemWiseCondition(purchItem);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                res = false;
            }
            if (res)
            {
                sinfo.errorcode    = 0;
                sinfo.errormessage = "Successfully Saved";
                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new { info = sinfo })
                });
            }
            else
            {
                finfo.errorcode    = 1;
                finfo.errormessage = "Failed To Save";
                return(new HttpResponseMessage()
                {
                    StatusCode = System.Net.HttpStatusCode.NotAcceptable, Content = new JsonContent(new { info = finfo })
                });
            }
        }
Example #4
0
 public virtual void PostKnifeThrowFail(ILocalGame game, FailInfo failInfo)
 {
 }
        public static void Run(int numThreads, int duration, Action iteration, Action threadInitializer = null, Action threadFinalizer = null)
        {
            // Heat
            try
            {
                iteration();
            }
            catch (Exception ex)
            {
            }


            Dictionary <int, object> totalThreads = new Dictionary <int, object>();
            long           totalActions           = 0;
            Barrier        b       = new Barrier(numThreads);
            List <Thread>  threads = new List <Thread>();
            FailCollection fails   = new FailCollection();

            int[] numbers = new int[numThreads];
            int   index   = 0;

            foreach (var action in Enumerable.Range(1, numThreads))
            {
                var    a       = action;
                int    current = index;
                Thread t       = new Thread(() =>
                {
                    lock (totalThreads) totalThreads[Thread.CurrentThread.ManagedThreadId] = null;

                    if (threadInitializer != null)
                    {
                        threadInitializer();
                    }

                    int n1 = 0;
                    b.SignalAndWait();
                    Stopwatch sw = Stopwatch.StartNew();
                    do
                    {
                        try
                        {
                            iteration();
                            Interlocked.Increment(ref totalActions);
                            n1++;
                        }
                        catch (Exception ex)
                        {
                            FailInfo fi = new FailInfo(ex, current);
                            fails.SmartAdd(fi);
                            DumpException("Stress Action failed: " + ex);
                        }
                    }while (sw.ElapsedMilliseconds < duration);

                    if (threadFinalizer != null)
                    {
                        threadFinalizer();
                    }

                    lock (numbers) numbers[current] = n1;
                    b.SignalAndWait();
                })
                {
                    IsBackground = true
                };

                t.Start();
                threads.Add(t);
                index++;
            }

            foreach (var thread in threads)
            {
                thread.Join();
            }

            string totalActionsAs =
                totalActions + " = " + string.Join("+", numbers.Select(x => x.ToString()));

            if (numThreads == 1)
            {
                totalActionsAs = totalActions.ToString();
            }

            Trace.WriteLine(string.Format(
                                "  Workers: {0}. Total actions: {1}, threads: {2}",
                                numThreads,
                                totalActionsAs,
                                totalThreads.Count));

            if (fails.Count > 0)
            {
                var asStr = fails
                            .OrderByDescending(x => x.Count)
                            .Select(x => string.Format("   :) #{0}, {1} times {2}", x.Worker, x.Count, x.Reason));

                Trace.WriteLine(string.Join(Environment.NewLine, asStr));
            }
        }
Example #6
0
        public override void PostKnifeThrowFail(ILocalGame game, FailInfo failInfo)
        {
            base.PostKnifeThrowFail(game, failInfo);

            m_timeLeftToRestart = m_restartTimeout;
        }