Ejemplo n.º 1
0
        public static byte[] ToSendData <T>(this T content, CommonCommands CommandKey, int Seq = 0) where T : class
        {
            var commandData = BitConverter.GetBytes((int)CommandKey);//协议命令只占4位,如果占的位数长过协议,那么协议解析肯定会出错的

            var dataBody = content.ObjectToBytes();

            var cs = Encoding.UTF8.GetBytes(CS);

            var dataLen = BitConverter.GetBytes(dataBody.Length);//int类型占4位,根据协议这里也只能4位,否则会出错

            var seq = BitConverter.GetBytes(Seq);

            var sendData = new byte[14 + dataBody.Length + 2];//命令加内容长度为8

            // +----+-------+---+----+-------------------------+-----+
            // |  C | KEY   | l |  S |                         |  C  |
            // |    | name  | e |  e |    request body         |     |
            // |  S |  (4)  | n |  q |                         |  S  |
            // | (2)|       |(4)| (4)|                         | (2) |
            // +----+-------+---+----+-------------------------+-----+

            Array.ConstrainedCopy(cs, 0, sendData, 0, 2);
            Array.ConstrainedCopy(commandData, 0, sendData, 2, 4);
            Array.ConstrainedCopy(dataLen, 0, sendData, 6, 4);
            Array.ConstrainedCopy(seq, 0, sendData, 10, 4);
            Array.ConstrainedCopy(dataBody, 0, sendData, 14, dataBody.Length);
            Array.ConstrainedCopy(cs, 0, sendData, sendData.Length - 2, 2);
            return(sendData);
        }
Ejemplo n.º 2
0
        public DocumentData GetPriceCodeReportByJobId(string jobId)
        {
            List <long> selectedJobId = jobId.Split(',').Select(Int64.Parse).ToList();
            List <Task> tasks         = new List <Task>();
            NavSalesOrderPostedInvoiceResponse navSalesOrderPostedInvoiceResponse = CommonCommands.GetCachedNavSalesOrderValues();
            NavSalesOrderItemResponse          navSalesOrderItemResponse          = CommonCommands.GetCachedNavSalesOrderItemValues();
            DocumentData        documentData     = null;
            List <DocumentData> documentDataList = new List <DocumentData>();

            foreach (var currentJobId in selectedJobId)
            {
                tasks.Add(Task.Factory.StartNew(() =>
                {
                    var currentNavSalesOrder = navSalesOrderPostedInvoiceResponse.NavSalesOrder.FirstOrDefault(x => x.M4PL_Job_ID.ToLong() == currentJobId);
                    if (currentNavSalesOrder != null && !string.IsNullOrEmpty(currentNavSalesOrder.No))
                    {
                        var currentSalesLineItem = navSalesOrderItemResponse.NavSalesOrderItem.Where(x => x.Document_No.Equals(currentNavSalesOrder.No, StringComparison.OrdinalIgnoreCase));
                        if (currentSalesLineItem.Any() && currentSalesLineItem.Count() > 0)
                        {
                            documentDataList.Add(GetPriceCodeReportDataByJobId(currentJobId, currentSalesLineItem.ToList()));
                        }
                    }
                }));
            }

            if (tasks.Count > 0)
            {
                Task.WaitAll(tasks.ToArray());
            }
            documentDataList = documentDataList.Where(x => x != null).Any() ? documentDataList.Where(x => x != null).ToList() : new List <DocumentData>();
            if (documentDataList?.Count > 1)
            {
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
                    {
                        foreach (var trackingDocument in documentDataList)
                        {
                            var entry = archive.CreateEntry(trackingDocument.DocumentName, CompressionLevel.Fastest);
                            using (var zipStream = entry.Open())
                            {
                                zipStream.Write(trackingDocument.DocumentContent, 0, trackingDocument.DocumentContent.Length);
                            }
                        }
                    }
                    documentData = new DocumentData();
                    documentData.DocumentContent = memoryStream.ToArray();
                    documentData.DocumentName    = string.Format("{0}.zip", "ConsolidatedPriceCode");
                    documentData.ContentType     = "application/zip";
                }
            }
            else if (documentDataList?.Count == 1)
            {
                return(documentDataList[0]);
            }

            return(documentData);
        }
Ejemplo n.º 3
0
 void Update()
 {
     foreach (InputManager im in DataStorage.GetSetControllers.Values)
     {
         if (im.GetButtonStartPressed)
         {
             CommonCommands.LoadMainMenu();
         }
     }
 }
Ejemplo n.º 4
0
 //Starts the first game
 public void StartGame()
 {
     if (DataStorage.GetSetControllers.Count > 1) //If more than one player is connected
     {
         //Prepare the game loop
         DataStorage.AmountOfGames = DataStorage.GetSetGamesLeft = int.Parse(amountOfRoundsText.text);
         FindPlayableScenes();
         //Load the first game
         CommonCommands.LoadNextScene();
     }
 }
Ejemplo n.º 5
0
        public DocumentStatus IsPriceCodeDataPresentForJobInNAV(string jobId)
        {
            if (string.IsNullOrEmpty(jobId))
            {
                return(new DocumentStatus()
                {
                    IsAttachmentPresent = false, IsPODPresent = false
                });
            }

            List <long>    selectedJobId  = jobId.Split(',').Select(Int64.Parse).ToList();
            List <Task>    tasks          = new List <Task>();
            DocumentStatus documentStatus = new DocumentStatus()
            {
                IsAttachmentPresent = false, IsPODPresent = false
            };
            NavSalesOrderPostedInvoiceResponse navSalesOrderPostedInvoiceResponse = CommonCommands.GetCachedNavSalesOrderValues();
            NavSalesOrderItemResponse          navSalesOrderItemResponse          = CommonCommands.GetCachedNavSalesOrderItemValues();

            if (navSalesOrderPostedInvoiceResponse == null || (navSalesOrderPostedInvoiceResponse != null && navSalesOrderPostedInvoiceResponse.NavSalesOrder == null) || (navSalesOrderPostedInvoiceResponse != null && navSalesOrderPostedInvoiceResponse.NavSalesOrder != null && navSalesOrderPostedInvoiceResponse.NavSalesOrder.Count == 0))
            {
                return(documentStatus);
            }
            else if (navSalesOrderItemResponse == null || (navSalesOrderItemResponse != null && navSalesOrderItemResponse.NavSalesOrderItem == null) || (navSalesOrderItemResponse != null && navSalesOrderItemResponse.NavSalesOrderItem != null && navSalesOrderItemResponse.NavSalesOrderItem.Count == 0))
            {
                return(documentStatus);
            }

            foreach (var currentJob in selectedJobId)
            {
                tasks.Add(Task.Factory.StartNew(() =>
                {
                    var currentNavSalesOrder = navSalesOrderPostedInvoiceResponse.NavSalesOrder.FirstOrDefault(x => x.M4PL_Job_ID.ToLong() == currentJob);
                    if (currentNavSalesOrder != null && !string.IsNullOrEmpty(currentNavSalesOrder.No))
                    {
                        var currentSalesLineItem = navSalesOrderItemResponse.NavSalesOrderItem.Where(x => x.Document_No.Equals(currentNavSalesOrder.No, StringComparison.OrdinalIgnoreCase));
                        if (currentSalesLineItem.Any() && currentSalesLineItem.Count() > 0)
                        {
                            documentStatus.IsAttachmentPresent = true;
                        }
                    }
                }));
            }

            if (tasks.Count > 0)
            {
                Task.WaitAll(tasks.ToArray());
            }

            return(documentStatus);
        }
Ejemplo n.º 6
0
 void CheckIfGameDone()
 {
     if (!gameEnded) //If game not ended
     {
         //Update teams
         tm.UpdateTeams();
         //Check if game ended
         gameEnded = tm.IsThereOneTeamLeft();
         if (gameEnded)                                                                //If game ended
         {
             CommonCommands.NextGame(tm.GetTeamFirstPlace(), tm.GetTeamSecondPlace()); //Start next game
         }
     }
 }
Ejemplo n.º 7
0
        private static void PrepareUi()
        {
            try {
                ToolTipService.ShowOnDisabledProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(true));
                ToolTipService.InitialShowDelayProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(300));
                ToolTipService.BetweenShowDelayProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(600));
                ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(60000));
                ItemsControl.IsTextSearchCaseSensitiveProperty.OverrideMetadata(typeof(ComboBox), new FrameworkPropertyMetadata(true));
            } catch (Exception e) {
                Logging.Error(e);
            }

            PopupHelper.Initialize();
            CommonCommands.SetHelper(new SomeCommonCommandsHelper());
        }
Ejemplo n.º 8
0
        public static NavSalesOrder StartOrderUpdationProcessForNAV(ActiveUser activeUser, List <long> jobIdList, string soNumber, string poNumber, string navAPIUrl, string navAPIUserName, string navAPIPassword, string vendorNo, bool electronicInvoice, List <SalesOrderItem> salesOrderItemRequest)
        {
            string dimensionCode       = string.Empty;
            string divisionCode        = string.Empty;
            bool   allLineItemsUpdated = true;
            string proFlag             = null;
            NavSalesOrderRequest navSalesOrderRequest = _commands.GetSalesOrderCreationData(activeUser, jobIdList, Entities.EntitiesAlias.SalesOrder);

            if (navSalesOrderRequest == null)
            {
                return(null);
            }
            var dimensions = CommonCommands.GetSalesOrderDimensionValues(navAPIUserName, navAPIPassword, navAPIUrl);

            if (dimensions != null && dimensions.NavSalesOrderDimensionValues != null && dimensions.NavSalesOrderDimensionValues.Count > 0)
            {
                divisionCode = dimensions.NavSalesOrderDimensionValues.Where(x => !string.IsNullOrEmpty(x.Dimension_Code) && x.Dimension_Code.ToUpper() == "DIVISION" && x.ERPId == navSalesOrderRequest.Sell_to_Customer_No).Any()
                                        ? dimensions.NavSalesOrderDimensionValues.Where(x => !string.IsNullOrEmpty(x.Dimension_Code) && x.Dimension_Code.ToUpper() == "DIVISION" && x.ERPId == navSalesOrderRequest.Sell_to_Customer_No).FirstOrDefault().Code
                                        : string.Empty;

                if (!string.IsNullOrEmpty(navSalesOrderRequest.Ship_from_City) && !string.IsNullOrEmpty(navSalesOrderRequest.Ship_from_County))
                {
                    string dimensionMatchCode = navSalesOrderRequest.Ship_from_City.Length >= 3 ? string.Format("{0}{1}", navSalesOrderRequest.Ship_from_City.Substring(0, 3), navSalesOrderRequest.Ship_from_County) : string.Empty;
                    if (!string.IsNullOrEmpty(dimensionMatchCode))
                    {
                        dimensionCode = dimensions.NavSalesOrderDimensionValues.Where(codeMatch => !string.IsNullOrEmpty(codeMatch.Code) && codeMatch.Code.Length > 4 && codeMatch.Code.Substring(codeMatch.Code.Length - 5).ToUpper() == dimensionMatchCode.ToUpper()).Any() ?
                                        dimensions.NavSalesOrderDimensionValues.Where(codeMatch => !string.IsNullOrEmpty(codeMatch.Code) && codeMatch.Code.Length > 4 && codeMatch.Code.Substring(codeMatch.Code.Length - 5).ToUpper() == dimensionMatchCode.ToUpper()).FirstOrDefault().Code : dimensionCode;
                    }
                }
            }

            navSalesOrderRequest.Shortcut_Dimension_2_Code = dimensionCode;
            navSalesOrderRequest.Shortcut_Dimension_1_Code = divisionCode;
            navSalesOrderRequest.Electronic_Invoice        = electronicInvoice;
            NavSalesOrder navSalesOrderResponse = UpdateSalesOrderForNAV(activeUser, navSalesOrderRequest, navAPIUrl, navAPIUserName, navAPIPassword, soNumber);

            if (navSalesOrderResponse != null && !string.IsNullOrWhiteSpace(navSalesOrderResponse.No))
            {
                salesOrderItemRequest.ForEach(x => x.Document_No = navSalesOrderResponse.No);
                //Task.Run(() =>
                //{
                UpdateSalesOrderItemDetails(activeUser, jobIdList, navAPIUrl, navAPIUserName, navAPIPassword, dimensionCode, divisionCode, navSalesOrderResponse.No, ref allLineItemsUpdated, ref proFlag, electronicInvoice, salesOrderItemRequest);
                //});
            }

            return(navSalesOrderResponse);
        }
Ejemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        this.lsys = new LSystem.LSystem();

        lsys.Rules = new Dictionary <string, string> {
            { "1", "FF-[1]++F+F" }
        };
//		lsys.Rules = new Dictionary<string, string> { { "1", "FF-[1]++F+F+1" } };
//		lsys.Rules = new Dictionary<string, string> { { "1", "F+F-F([1]" } };

//		lsys.Rules = new Dictionary<string, string> {
//			{ "1", "FFF+[2]F+(>[---1]" },
//			{ "2", "FFF[1]+[1]+[1]+[1]" }
//		};

        lsys.Angle         = this.angle;
        lsys.SegmentLength = this.segmentLength;

        var cmd = new CommonCommands();

        cmd.Angle         = this.angle;
        cmd.AngleAxis     = this.angleAxis;
        cmd.SegmentAxis   = this.segmentAxis;
        cmd.SegmentLength = this.segmentLength;
        lsys.AddCommand(cmd);

        this.segmentDrawer = new VectorLineSegmentDrawer();
        var segCmd = new SegmentCommand();

        segCmd.Segment     = this.segmentDrawer;
        segCmd.SegmentAxis = this.segmentAxis;

        lsys.AddCommand(segCmd);

        this.totalTime = lsys.Duration(this.generations);
        Debug.Log(string.Format("totalTime = {0}", this.totalTime));

//		lsys.Draw(Vector3.zero, this.generations);
    }
Ejemplo n.º 10
0
 public void CheckNoBounce()
 {
     if ((playerListLeft.Count + playerListRight.Count == 2) && twoLeft)
     {
         if (canEnd && ableToRemove)
         {
             Time.timeScale = 1;
             timeScale      = 1f;
             if (rb.position.x <= leftEnd)
             {
                 CommonCommands.NextGame(playerListLeft, playerListRight);
             }
             else if (rb.position.x >= rightEnd)
             {
                 CommonCommands.NextGame(playerListRight, playerListLeft);
             }
             canEnd = false;
         }
     }
     else if (canEnd && canRemove && !twoLeft && ableToRemove)
     {
         //Debug.Log("REMOVE!!!!");
         canRemove    = false;
         timerTextOut = 4f;
         if (rb.position.x <= leftEnd)
         {
             playerOut.text = "Player " + playerListLeft[playerListLeft.Count - 1] + " out! ";
             playerListLeft.RemoveAt(playerListLeft.Count - 1);
         }
         else if (rb.position.x >= rightEnd)
         {
             playerOut.text = "Player " + playerListRight[playerListRight.Count - 1] + " out! ";
             playerListRight.RemoveAt(playerListRight.Count - 1);
         }
         resetGame    = true;
         justRemoved  = true;
         ableToRemove = false;
     }
 }
Ejemplo n.º 11
0
        public IList <NavCostCode> GetAllCostCode()
        {
            List <NavCostCode> navCostCodeList = null;

            if (!M4PLBusinessConfiguration.NavRateReadFromItem.ToBoolean())
            {
                navCostCodeList = GetNavCostCodeData();
                if (navCostCodeList != null && navCostCodeList.Count > 0)
                {
                    _commands.Put(ActiveUser, navCostCodeList);
                }
            }
            else
            {
                NAVOrderItemResponse navOrderItemResponse = CommonCommands.GetNAVOrderItemResponse();
                if (navOrderItemResponse?.OrderItemList?.Count > 0)
                {
                    _orderItemCommands.UpdateNavCostCode(ActiveUser, navOrderItemResponse.OrderItemList);
                    navCostCodeList = new List <NavCostCode>();
                }
            }

            return(navCostCodeList);
        }
Ejemplo n.º 12
0
        public static String PrepareCommandText <TDataObject>(CommonCommands command, params SqlParameter[] parameters)
            where TDataObject : class, Framework.Data.IDataObjectBase, new()
        {
            TDataObject dataObj     = new TDataObject( );
            String      dataObjName = dataObj.Metadata.DataObjectNameSingular;
            String      action      = command.ToString( ).Replace("Record", String.Empty);
            String      tailEnd     = String.Empty;

            if (command == CommonCommands.RecordList)
            {
                dataObjName = dataObj.Metadata.DataObjectNamePlural;
                if (parameters != null && parameters.Any( ))
                {
                    List <String> paramNames = new List <String>( );
                    foreach (SqlParameter param in parameters)
                    {
                        paramNames.Add(param.ParameterName.Replace("@", String.Empty));
                    }
                    tailEnd = String.Format("By{0}", String.Join(String.Empty, paramNames.ToArray( )));
                }
            }

            return(String.Format("[{0}].[{1}{2}{3}{4}]", dataObj.Metadata.DataObjectSchemaName, StoredProcedureNamePrefix, dataObjName, action, tailEnd));
        }
Ejemplo n.º 13
0
        public IList <JobAdvanceReport> GetPagedData(PagedDataInfo pagedDataInfo)
        {
            IList <JobAdvanceReport> result = null;
            bool isCostChargeReport         = false;
            bool isPriceChargeReport        = false;

            result              = _commands.GetPagedData(ActiveUser, pagedDataInfo);
            isCostChargeReport  = result != null && result.Count > 0 && (result.ToList().Where(x => x.IsCostChargeReport).Any());
            isPriceChargeReport = result != null && result.Count > 0 && (result.ToList().Where(x => x.IsPriceChargeReport).Any());
            if (isCostChargeReport || isPriceChargeReport)
            {
                IList <JobAdvanceReport> updatedResult           = new List <JobAdvanceReport>();
                JobAdvanceReport         currentJobAdvanceReport = null;
                int jobItemCount = 1;
                if (isPriceChargeReport)
                {
                    NavSalesOrderPostedInvoiceResponse navSalesOrderPostedInvoiceResponse = CommonCommands.GetCachedNavSalesOrderValues();
                    NavSalesOrderItemResponse          navSalesOrderItemResponse          = CommonCommands.GetCachedNavSalesOrderItemValues();
                    foreach (var currentJob in result)
                    {
                        var currentNavSalesOrder = navSalesOrderPostedInvoiceResponse.NavSalesOrder.FirstOrDefault(x => x.M4PL_Job_ID.ToLong() == currentJob.JobId);
                        if (currentNavSalesOrder != null && !string.IsNullOrEmpty(currentNavSalesOrder.No))
                        {
                            var currentSalesLineItem = navSalesOrderItemResponse.NavSalesOrderItem.Where(x => x.Document_No.Equals(currentNavSalesOrder.No, StringComparison.OrdinalIgnoreCase));
                            if (currentSalesLineItem.Any() && currentSalesLineItem.Count() > 0)
                            {
                                foreach (var salesLineItem in currentSalesLineItem)
                                {
                                    currentJobAdvanceReport = currentJob.DeepCopy();
                                    currentJobAdvanceReport.RateChargeCode = string.IsNullOrEmpty(salesLineItem.Cross_Reference_No) ? salesLineItem.No : salesLineItem.Cross_Reference_No;
                                    currentJobAdvanceReport.RateTitle      = salesLineItem.Description;
                                    currentJobAdvanceReport.RateAmount     = salesLineItem.Unit_Price;
                                    currentJobAdvanceReport.Id             = currentJob.Id;
                                    updatedResult.Add(currentJobAdvanceReport);
                                    jobItemCount = jobItemCount + 1;
                                }
                            }
                        }
                    }
                }
                else
                {
                    NavPurchaseOrderPostedInvoiceResponse navPurchaseOrderPostedInvoiceResponse = CommonCommands.GetCachedNavPurchaseOrderValues();
                    NavPurchaseOrderItemResponse          navPurchaseOrderItemResponse          = CommonCommands.GetCachedNavPurchaseOrderItemValues();
                    foreach (var currentJob in result)
                    {
                        var currentNavPurchaseOrder = navPurchaseOrderPostedInvoiceResponse.NavPurchaseOrder.FirstOrDefault(x => x.M4PL_Job_ID.ToLong() == currentJob.JobId);
                        if (currentNavPurchaseOrder != null && !string.IsNullOrEmpty(currentNavPurchaseOrder.No))
                        {
                            var currentPurchaseLineItem = navPurchaseOrderItemResponse.NavPurchaseOrderItem.Where(x => x.Document_No.Equals(currentNavPurchaseOrder.No, StringComparison.OrdinalIgnoreCase));
                            if (currentPurchaseLineItem.Any() && currentPurchaseLineItem.Count() > 0)
                            {
                                foreach (var purchaseLineItem in currentPurchaseLineItem)
                                {
                                    currentJobAdvanceReport = currentJob.DeepCopy();
                                    currentJobAdvanceReport.RateChargeCode = string.IsNullOrEmpty(purchaseLineItem.Cross_Reference_No) ? purchaseLineItem.No : purchaseLineItem.Cross_Reference_No;
                                    currentJobAdvanceReport.RateTitle      = purchaseLineItem.Description;
                                    currentJobAdvanceReport.RateAmount     = purchaseLineItem.Unit_Cost_LCY;
                                    currentJobAdvanceReport.Id             = currentJob.Id;
                                    updatedResult.Add(currentJobAdvanceReport);
                                    jobItemCount = jobItemCount + 1;
                                }
                            }
                        }
                    }
                }

                pagedDataInfo.TotalCount = updatedResult != null && updatedResult.Count > 0 ? updatedResult.Count : 0;
                return(updatedResult);
            }

            return(result);
        }
Ejemplo n.º 14
0
 public CommonCommandPacket(CommonCommands command)
 {
     _command = command;
 }
Ejemplo n.º 15
0
        public async Task LoveSomeone(params IUser[] users)
        {
            var embedded = CommonCommands.LoveSomeone(Context.Message.MentionedUsers, Context.Message.MentionedRoles, Context.Message.Author.Username);

            await ReplyAsync("", false, embedded.Build());
        }
Ejemplo n.º 16
0
        public static NavPurchaseOrder UpdatePurchaseOrderForNAV(ActiveUser activeUser, List <long> jobIdList, string poNumer, string navAPIUrl, string navAPIUserName, string navAPIPassword, bool electronicInvoice, List <PurchaseOrderItem> purchaseOrderItemRequest)
        {
            string           navPurchaseOrderJson     = string.Empty;
            string           dimensionCode            = string.Empty;
            string           divisionCode             = string.Empty;
            NavPurchaseOrder navPurchaseOrderResponse = null;
            string           proFlag = null;

            Newtonsoft.Json.Linq.JObject jsonObject = null;
            string serviceCall = string.Format("{0}/PurchaseOrder('Order', '{1}')", navAPIUrl, poNumer);

            try
            {
                NavPurchaseOrder        existingSalesOrderData  = GetPurchaseOrderForNAV(navAPIUrl, navAPIUserName, navAPIPassword, poNumer);
                NavPurchaseOrderRequest navPurchaseOrderRequest = _purchaseCommands.GetPurchaseOrderCreationData(activeUser, jobIdList, Entities.EntitiesAlias.PurchaseOrder);
                if (navPurchaseOrderRequest == null)
                {
                    return(null);
                }
                var dimensions = CommonCommands.GetSalesOrderDimensionValues(navAPIUserName, navAPIPassword, navAPIUrl);
                if (dimensions != null && dimensions.NavSalesOrderDimensionValues != null && dimensions.NavSalesOrderDimensionValues.Count > 0)
                {
                    divisionCode = dimensions.NavSalesOrderDimensionValues.Where(x => !string.IsNullOrEmpty(x.Dimension_Code) && x.Dimension_Code.ToUpper() == "DIVISION" && x.ERPId == navPurchaseOrderRequest.Sell_to_Customer_No).Any()
                                                ? dimensions.NavSalesOrderDimensionValues.Where(x => !string.IsNullOrEmpty(x.Dimension_Code) && x.Dimension_Code.ToUpper() == "DIVISION" && x.ERPId == navPurchaseOrderRequest.Sell_to_Customer_No).FirstOrDefault().Code
                                                : string.Empty;

                    if (!string.IsNullOrEmpty(navPurchaseOrderRequest.Ship_from_City) && !string.IsNullOrEmpty(navPurchaseOrderRequest.Ship_from_County))
                    {
                        string dimensionMatchCode = navPurchaseOrderRequest.Ship_from_City.Length >= 3 ? string.Format("{0}{1}", navPurchaseOrderRequest.Ship_from_City.Substring(0, 3), navPurchaseOrderRequest.Ship_from_County) : string.Empty;
                        if (!string.IsNullOrEmpty(dimensionMatchCode))
                        {
                            dimensionCode = dimensions.NavSalesOrderDimensionValues.Where(codeMatch => !string.IsNullOrEmpty(codeMatch.Code) && codeMatch.Code.Length > 4 && codeMatch.Code.Substring(codeMatch.Code.Length - 5).ToUpper() == dimensionMatchCode.ToUpper()).Any() ?
                                            dimensions.NavSalesOrderDimensionValues.Where(codeMatch => !string.IsNullOrEmpty(codeMatch.Code) && codeMatch.Code.Length > 4 && codeMatch.Code.Substring(codeMatch.Code.Length - 5).ToUpper() == dimensionMatchCode.ToUpper()).FirstOrDefault().Code : dimensionCode;
                        }
                    }
                }

                navPurchaseOrderRequest.Shortcut_Dimension_2_Code = dimensionCode;
                navPurchaseOrderRequest.Shortcut_Dimension_1_Code = divisionCode;
                navPurchaseOrderRequest.Electronic_Invoice        = electronicInvoice;
                NetworkCredential myCredentials = new NetworkCredential(navAPIUserName, navAPIPassword);
                HttpWebRequest    request       = (HttpWebRequest)WebRequest.Create(serviceCall);
                request.Credentials = myCredentials;
                request.KeepAlive   = false;
                request.ContentType = "application/json";
                request.Method      = "PATCH";
                request.Headers.Add(HttpRequestHeader.IfMatch, existingSalesOrderData.DataETag);
                using (var streamWriter = new StreamWriter(request.GetRequestStream()))
                {
                    navPurchaseOrderJson = JsonConvert.SerializeObject(navPurchaseOrderRequest);
                    jsonObject           = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(navPurchaseOrderJson);
                    jsonObject.Property("Ship_from_City").Remove();
                    jsonObject.Property("Ship_from_County").Remove();
                    navPurchaseOrderJson = jsonObject.ToString();
                    streamWriter.Write(navPurchaseOrderJson);
                }

                WebResponse response = request.GetResponse();

                using (Stream navPurchaseOrderResponseStream = response.GetResponseStream())
                {
                    using (TextReader navPurchaseOrderReader = new StreamReader(navPurchaseOrderResponseStream))
                    {
                        string responceString = navPurchaseOrderReader.ReadToEnd();

                        using (var stringReader = new StringReader(responceString))
                        {
                            navPurchaseOrderResponse = Newtonsoft.Json.JsonConvert.DeserializeObject <NavPurchaseOrder>(responceString);
                        }
                    }
                }

                if (navPurchaseOrderResponse != null && !string.IsNullOrWhiteSpace(navPurchaseOrderResponse.No))
                {
                    if (purchaseOrderItemRequest != null && purchaseOrderItemRequest.Count > 0)
                    {
                        purchaseOrderItemRequest.ForEach(x => x.Document_No = navPurchaseOrderResponse.No);
                    }

                    UpdateLineItemInformationForPurchaseOrder(activeUser, jobIdList, navAPIUrl, navAPIUserName, navAPIPassword, dimensionCode, divisionCode, navPurchaseOrderResponse.No, out proFlag, electronicInvoice, purchaseOrderItemRequest);
                }
            }
            catch (Exception exp)
            {
                proFlag = Entities.ProFlag.H.ToString();
                _logger.Log(exp, string.Format("Error is occuring while Updating the purchase order: Request Url is: {0}, Request body json was {1}", serviceCall, navPurchaseOrderJson), string.Format("Purchase order updation for JobId: {0}", Newtonsoft.Json.JsonConvert.SerializeObject(jobIdList)), LogType.Error);
            }

            _commands.UpdateJobProFlag(activeUser, proFlag, jobIdList, Entities.EntitiesAlias.PurchaseOrder);
            return(navPurchaseOrderResponse);
        }
Ejemplo n.º 17
0
 //Sends the winner to "CommonCommands" or removes players from the list if there are more than 2 players left
 public void EndGame(List <int> firstList, List <int> secondList, int bounces, int howMany)
 {
     if ((bounces >= howMany))
     {
         if ((playerListLeft.Count + playerListRight.Count) <= 2 && canEnd && twoLeft && ableToRemove)
         {
             Time.timeScale = 1;
             timeScale      = 1f;
             if (left)
             {
                 if (ballCollision.nrOfBouncesGood > 1)
                 {
                     CommonCommands.NextGame(firstList, secondList);
                 }
                 else if (ballCollision.nrOfBouncesBad > 0)
                 {
                     CommonCommands.NextGame(firstList, secondList);
                 }
             }
             else if (!left)
             {
                 if (ballCollision.nrOfBouncesGood > 1)
                 {
                     CommonCommands.NextGame(secondList, firstList);
                 }
                 else if (ballCollision.nrOfBouncesBad > 0)
                 {
                     CommonCommands.NextGame(secondList, firstList);
                 }
             }
             canEnd = false;
         }
         else if (canEnd && canRemove && !twoLeft && ableToRemove)
         {
             canRemove = false;
             if (left)
             {
                 timerTextOut = 4f;
                 if (howMany == 1)
                 {
                     playerOut.text = "Player " + playerListLeft[playerListLeft.Count - 1] + " out! ";
                     playerListLeft.RemoveAt(playerListLeft.Count - 1);
                 }
                 else if (howMany == 2)
                 {
                     playerOut.text = "Player " + playerListLeft[0] + " out! ";
                     playerListLeft.RemoveAt(0);
                 }
             }
             else if (!left)
             {
                 timerTextOut = 4f;
                 if (howMany == 1)
                 {
                     playerOut.text = "Player " + playerListRight[playerListRight.Count - 1] + " out! ";
                     playerListRight.RemoveAt(playerListRight.Count - 1);
                 }
                 else if (howMany == 2)
                 {
                     playerOut.text = "Player " + playerListRight[0] + " out! ";
                     playerListRight.RemoveAt(0);
                 }
             }
             justRemoved  = true;
             resetGame    = true;
             ableToRemove = false;
         }
         if (howMany == 2)
         {
             ballCollision.nrOfBouncesGood = 0;
         }
         else if (howMany == 1)
         {
             ballCollision.nrOfBouncesBad = 0;
         }
     }
 }