public bool UpdateReportDataDuringProduction(ProductionObject productionData, int userId) { // call private method here that determines what reports should be updated GetDataToBeInsertedInPersistentTableFormat(RecordType.Purchase, userId, productionData: productionData); throw new NotImplementedException(); }
public void StartProduction(ProductionObject productionObj) { _productionObject = productionObj; _productionObject.Timer = _monoBehaviour.GetComponent <MonoBehaviour>().StartCoroutine(StartProductionTimer()); _productionData.Add(_productionObject.Index, _productionObject); RemoveParts(); Production.Cells[_productionObject.Index].SetStateBusy(); }
public JsonResult CreateProductionRecord(ProductionObject prodObject) { if (prodObject != null) { if (User.Identity.IsAuthenticated) { var userId = User.Identity.GetUserId <int>(); if (userId > 0) { try { _logger.Info("{0} {1}\n\tProduction Start Date: {2}\n\tProduction End Date: {3}\n\tProduction Date: {4}\n\tCreateProduction: {5}", User.Identity.Name, Request.Url.ToString(), prodObject.ProductionStart, prodObject.ProductionEnd, prodObject.ProductionDate, new JavaScriptSerializer().Serialize(prodObject)); } catch (Exception ex) { _logger.Error(ex, "Logging error"); } int returnResult = _production.CreateProduction(prodObject, userId); if (returnResult > 0) { string message = "Production record created successfully."; return(Json(message)); } else { string message = "Failed to create production record!"; return(Json(message)); } } else { return(Json("Unable to find UserId!")); } } else { return(Json("Unauthenticated user!")); } } else { return(Json("Backend received empty, undefined, or null Object from the client!")); } }
public bool IsEnoughParts(ProductionObject productionObj) { var recipe = _productsController.GetProduct(productionObj.Key).GetRecipe(productionObj.Quality); foreach (var partObj in recipe.Parts) { var data = partObj.data; var store = _controllersResolver.GetStoreByType(data.ItemType); var isEnough = store.GetItem(data.Slug).IsEnoughCount(partObj); if (!isEnough) { return(false); } } return(true); }
public void LoadStoreData(ProductionsLoadObject data, MonoBehaviour monoBehaviour) { _monoBehaviour = monoBehaviour; Production.InitCells(data.count); foreach (var prodObj in data.production) { //TODO сделать билдер для продакшн объекта var production = new ProductionObject { Key = prodObj.key, Quality = EnumParse.ParseStringToEnum <ItemQuality>(prodObj.quality), Index = prodObj.index, TimeEnd = prodObj.timeEnd, IsLoad = true }; StartProduction(production); } }
public JsonResult UpdateProduction(ProductionObject pObj) { if (pObj != null) { if (User.Identity.IsAuthenticated) { var userId = User.Identity.GetUserId <int>(); if (userId > 0) { bool returnResult = _production.UpdateProduction(pObj, userId); if (returnResult) { string message = "Production record updated successfully."; return(Json(message)); } else { string message = "Failed to update production record!"; return(Json(message)); } } else { return(Json("Unable to find UserId!")); } } else { return(Json("Unauthenticated user!")); } } else { return(Json("Back End received empty or undefined or null Object from the client")); } }
private void GetDataToBeInsertedInPersistentTableFormat(RecordType recordType, int userId, PurchaseObject purchaseData = null, ProductionObject productionData = null) { //update storage report if (purchaseData != null) { try { // update line 2 UpdateStorageReportCellValue(purchaseData, userId, (int)PersistReportRow.DepositedInBulkStorage); // update line 2 row total UpdateStorageReportCellValue(purchaseData, userId, (int)PersistReportRow.DepositedInBulkStorage, (int)PersistReportColumn.Total); // update line 6 UpdateStorageReportCellValue(purchaseData, userId, (int)PersistReportRow.TotalLines_1_Through_5); // update line 6 row total UpdateStorageReportCellValue(purchaseData, userId, (int)PersistReportRow.TotalLines_1_Through_5, (int)PersistReportColumn.Total); // update line 23 (= line 6 - line 17 - line 18) // update line 23 (= line 6 - line 17 - line 18) row total // update line 24 UpdateStorageReportCellValue(purchaseData, userId, (int)PersistReportRow.TotalLines_7_Through_23); // update line 24 row total UpdateStorageReportCellValue(purchaseData, userId, (int)PersistReportRow.TotalLines_7_Through_23, (int)PersistReportColumn.Total); // update line 1 for next month UpdateStorageReportCellValue(purchaseData, userId, (int)PersistReportRow.OnHandFirstOfMonth); // update line 1 row total for next month UpdateStorageReportCellValue(purchaseData, userId, (int)PersistReportRow.OnHandFirstOfMonth, (int)PersistReportColumn.Total); CompleteDbTransaction(); } catch (Exception e) { throw e; } } }
public static async Task <int> CreateProductionAsync(HttpClient httpClient, int workspaceId) { try { string url = $"/Relativity.REST/api/Relativity.Productions.Services.IProductionModule/Production%20Manager/CreateSingleAsync"; Production prodSettings = new Production() { Details = new Details() { BrandingFontSize = Constants.Production.BRANDING_FONT_SIZE, EmailRecipients = "", ScaleBrandingFont = false }, Footers = new Footers() { LeftFooter = new Leftfooter() { Type = "None", Field = new Field1() { ArtifactID = 0, Name = "", ViewFieldID = 0 }, FreeText = "", FriendlyName = "Left Header" } }, Headers = new Headers() { LeftHeader = new Leftheader() { Type = "None", Field = new Field() { ArtifactID = 0, Name = "", ViewFieldID = 0 }, FreeText = "", FriendlyName = "Left Header" } }, Name = Constants.Production.NAME, Numbering = new Numbering() { AttachmentRelationalField = new Attachmentrelationalfield() { ArtifactID = 0, Name = "", ViewFieldID = 0 }, BatesPrefix = Constants.Production.BATES_PREFIX, BatesStartNumber = Constants.Production.BATES_START_NUMBER, BatesSuffix = Constants.Production.BATES_SUFFIX, NumberOfDigitsForDocumentNumbering = Constants.Production.NUMBER_OF_DIGITS_FOR_DOCUMENT_NUMBERING, NumberingType = "PageLevel" }, ShouldCopyInstanceOnWorkspaceCreate = false, SortOrder = "" }; ProductionObject newProduction = new ProductionObject() { Production = prodSettings, workspaceArtifactID = workspaceId }; string request = JsonConvert.SerializeObject(newProduction); Console2.WriteDisplayStartLine($"Creating Production [Name: {Constants.Production.NAME}]"); HttpResponseMessage response = RESTConnectionManager.MakePost(httpClient, url, request); string result = response.Content.ReadAsStringAsync().Result; bool success = HttpStatusCode.OK == response.StatusCode; if (!success) { throw new Exception("Failed to create production set."); } int productionArtifactId = Convert.ToInt32(result); Console2.WriteDebugLine($"Production ArtifactId: {productionArtifactId}"); Console2.WriteDisplayEndLine("Created Production!"); return(productionArtifactId); } catch (Exception ex) { throw new Exception("An error occured when creating Production", ex); } }
public List <ProductionObject> GetOrderedProductionReportObjects(ProductionQuery queryBuilder) { try { using (var db = new DPRDataMigrationEngineDBEntities()) { if (queryBuilder != null) { if (queryBuilder.StartDate != null && queryBuilder.StartDate.Value.Year > 0001 && queryBuilder.EndDate != null && queryBuilder.EndDate.Value.Year > 0001) { var startYear = queryBuilder.StartDate.Value.Year; var startMonth = queryBuilder.StartDate.Value.Month; var endYear = queryBuilder.EndDate.Value.Year; var endMonth = queryBuilder.EndDate.Value.Month; var query = ( from p in db.Productions.Where(m => (queryBuilder.FieldId > 0 && m.FieldId == queryBuilder.FieldId && queryBuilder.ProductId < 1 && ((m.Year >= startYear && m.Month >= startMonth) && (m.Year <= endYear && m.Month <= endMonth))) || (queryBuilder.ProductId > 0 && queryBuilder.FieldId < 1 && m.ProductId == queryBuilder.ProductId && ((m.Year >= startYear && m.Month >= startMonth) && (m.Year <= endYear && m.Month <= endMonth))) || (queryBuilder.FieldId > 0 && queryBuilder.ProductId > 0 && queryBuilder.ProductId > 0 && queryBuilder.FieldId > 0 && m.FieldId == queryBuilder.FieldId && m.ProductId == queryBuilder.ProductId && ((m.Year >= startYear && m.Month >= startMonth) && (m.Year <= endYear && m.Month <= endMonth))) || (queryBuilder.FieldId < 1 && queryBuilder.ProductId < 1 && ((m.Year >= startYear && m.Month >= startMonth) && (m.Year <= endYear && m.Month <= endMonth)))) join f in db.Fields on p.FieldId equals f.FieldId where ((queryBuilder.FieldId > 0 && f.FieldId == queryBuilder.FieldId) || (f.FieldId == p.FieldId && queryBuilder.FieldId < 1)) join c in db.Companies on f.CompanyId equals c.CompanyId where ((queryBuilder.CompanyId > 0 && c.CompanyId == queryBuilder.CompanyId) || (queryBuilder.CompanyId < 1 && c.CompanyId == f.CompanyId)) join z in db.Zones on f.ZoneId equals z.ZoneId //where ((queryBuilder.ZoneId > 0 && z.ZoneId == queryBuilder.ZoneId && z.ZoneId == f.ZoneId) || (z.ZoneId == f.ZoneId && queryBuilder.ZoneId < 1)) join t in db.Terrains on f.TerrainId equals t.TerrainId //where ((queryBuilder.TerrainId > 0 && // t.TerrainId == queryBuilder.TerrainId) || (queryBuilder.TerrainId < 1 && t.TerrainId == f.TerrainId)) join pd in db.Products on p.ProductId equals pd.ProductId where ((queryBuilder.ProductId > 0 && pd.ProductId == queryBuilder.ProductId) || (queryBuilder.ProductId < 1 && p.ProductId == pd.ProductId)) join b in db.Blocks on f.BlockId equals b.BlockId where ((queryBuilder.BlockId > 0 && b.BlockId == queryBuilder.BlockId) || (b.BlockId == f.BlockId && queryBuilder.BlockId < 1)) select new ProductionObject() { ProductName = pd.Name, BlockName = b.Name, FieldName = f.Name, CompanyName = c.Name, ZoneName = z.Name, TerrainName = t.Name, Quantity = p.Quantity, Year = p.Year, Month = p.Month, Remark = p.Remark, APIGravity = p.APIGravity }).ToList(); if (!query.Any()) { return(new List <ProductionObject>()); } query.ForEach(j => { var quantityOut = 0; var result2 = int.TryParse(j.Quantity, out quantityOut); if (result2) { j.Quantity = Convert.ToDecimal(j.Quantity).ToString("#,##0"); } else { j.Quantity = "0"; } var monthOut = j.Month; if (monthOut > 0) { j.Period = Enum.GetName(typeof(Months), monthOut) + "/" + j.Year; } if (monthOut < 1) { j.Period = j.Year.ToString(CultureInfo.InvariantCulture); } }); return(query.OrderBy(v => v.ProductName).ToList()); } if (queryBuilder.StartDate != null && queryBuilder.StartDate.Value.Year > 0001 && ((queryBuilder.EndDate != null && queryBuilder.EndDate.Value.Year == 0001) || (queryBuilder.EndDate == null))) { var startYear = queryBuilder.StartDate.Value.Year; var startMonth = queryBuilder.StartDate.Value.Month; var query = ( from p in db.Productions.Where(m => (queryBuilder.FieldId > 0 && m.FieldId == queryBuilder.FieldId && queryBuilder.ProductId < 1 && (m.Year == startYear && m.Month == startMonth)) || (queryBuilder.ProductId > 0 && queryBuilder.FieldId < 1 && m.ProductId == queryBuilder.ProductId && (m.Year == startYear && m.Month == startMonth)) || (queryBuilder.FieldId > 0 && queryBuilder.ProductId > 0 && queryBuilder.ProductId > 0 && queryBuilder.FieldId > 0 && m.FieldId == queryBuilder.FieldId && m.ProductId == queryBuilder.ProductId && (m.Year == startYear && m.Month == startMonth)) || (queryBuilder.FieldId < 1 && queryBuilder.ProductId < 1 && (m.Year == startYear && m.Month == startMonth))) join f in db.Fields on p.FieldId equals f.FieldId where ((queryBuilder.FieldId > 0 && f.FieldId == queryBuilder.FieldId) || (f.FieldId == p.FieldId && queryBuilder.FieldId < 1)) join c in db.Companies on f.CompanyId equals c.CompanyId where ((queryBuilder.CompanyId > 0 && c.CompanyId == queryBuilder.CompanyId) || (queryBuilder.CompanyId < 1 && c.CompanyId == f.CompanyId)) join z in db.Zones on f.ZoneId equals z.ZoneId //where ((queryBuilder.ZoneId > 0 && z.ZoneId == queryBuilder.ZoneId && z.ZoneId == f.ZoneId) || (z.ZoneId == f.ZoneId && queryBuilder.ZoneId < 1)) join t in db.Terrains on f.TerrainId equals t.TerrainId //where ((queryBuilder.TerrainId > 0 && // t.TerrainId == queryBuilder.TerrainId) || (queryBuilder.TerrainId < 1 && t.TerrainId == f.TerrainId)) join pd in db.Products on p.ProductId equals pd.ProductId where ((queryBuilder.ProductId > 0 && pd.ProductId == queryBuilder.ProductId) || (queryBuilder.ProductId < 1 && p.ProductId == pd.ProductId)) join b in db.Blocks on f.BlockId equals b.BlockId where ((queryBuilder.BlockId > 0 && f.BlockId == queryBuilder.BlockId) || (b.BlockId == f.BlockId && queryBuilder.BlockId < 1)) select new { pp = p, pdd = pd, bb = b, ff = f, cc = c, zz = z, tt = t, }).ToList(); if (!query.Any()) { return(new List <ProductionObject>()); } var xlt = new List <ProductionObject>(); query.ForEach(m => { var p = m.pp; var pd = m.pdd; var b = m.bb; var f = m.ff; var c = m.cc; var z = m.zz; var t = m.tt; var j = new ProductionObject() { ProductName = pd.Name, BlockName = b.Name, FieldName = f.Name, CompanyName = c.Name, ZoneName = z.Name, TerrainName = t.Name, Quantity = p.Quantity, Year = p.Year, Month = p.Month, Remark = p.Remark, APIGravity = p.APIGravity }; var quantityOut = 0; var result2 = int.TryParse(j.Quantity, out quantityOut); if (result2) { j.Quantity = Convert.ToDecimal(j.Quantity).ToString("#,##0"); } else { j.Quantity = "0"; } var monthOut = j.Month; if (monthOut > 0) { j.Period = Enum.GetName(typeof(Months), monthOut) + "/" + j.Year; } if (monthOut < 1) { j.Period = j.Year.ToString(CultureInfo.InvariantCulture); } xlt.Add(j); }); return(xlt.OrderBy(v => v.ProductName).ToList()); //return new List<ProductionObject>(); } //if (queryBuilder.Year < 1 && queryBuilder.Month > 0) //{ // var query = ( // from // p in db.Productions.Where(m => // (queryBuilder.FieldId > 0 && m.FieldId == queryBuilder.FieldId && queryBuilder.ProductId < 1 && (m.Month == queryBuilder.Month)) || // (queryBuilder.ProductId > 0 && queryBuilder.FieldId < 1 && m.ProductId == queryBuilder.ProductId && (m.Month == queryBuilder.Month)) || // (queryBuilder.FieldId > 0 && queryBuilder.ProductId > 0 && queryBuilder.ProductId > 0 && queryBuilder.FieldId > 0 && m.FieldId == queryBuilder.FieldId && m.ProductId == queryBuilder.ProductId && (m.Month == queryBuilder.Month)) || // (queryBuilder.FieldId < 1 && queryBuilder.ProductId < 1 && (m.Month == queryBuilder.Month))) // join f in db.Fields on p.FieldId equals f.FieldId where ((queryBuilder.FieldId > 0 && f.FieldId == queryBuilder.FieldId) || (f.FieldId == p.FieldId && queryBuilder.FieldId < 1)) // join c in db.Companies on f.CompanyId equals c.CompanyId where // ((queryBuilder.CompanyId > 0 && c.CompanyId == queryBuilder.CompanyId) || (queryBuilder.CompanyId < 1 && c.CompanyId == f.CompanyId)) // join z in db.Zones on f.ZoneId equals z.ZoneId // where ((queryBuilder.ZoneId > 0 && z.ZoneId == queryBuilder.ZoneId && z.ZoneId == f.ZoneId) || (z.ZoneId == f.ZoneId && queryBuilder.ZoneId < 1)) // join t in db.Terrains on f.TerrainId equals t.TerrainId // where ((queryBuilder.TerrainId > 0 && // t.TerrainId == queryBuilder.TerrainId) || (queryBuilder.TerrainId < 1 && t.TerrainId == f.TerrainId)) // join pd in db.Products on p.ProductId equals pd.ProductId // where // ((queryBuilder.ProductId > 0 && pd.ProductId == queryBuilder.ProductId) || // (queryBuilder.ProductId < 1 && p.ProductId == pd.ProductId)) // join b in db.Blocks on f.BlockId equals b.BlockId // where // ((queryBuilder.BlockId > 0 && f.BlockId == queryBuilder.BlockId) || // (b.BlockId == f.BlockId && queryBuilder.BlockId < 1)) // select new ProductionObject() // { // ProductName = pd.Name, // BlockName = b.Name, // FieldName = f.Name, // CompanyName = c.Name, // ZoneName = z.Name, // TerrainName = t.Name, // Quantity = p.Quantity, // Year = p.Year, // Month = p.Month, // Remark = p.Remark, // APIGravity = p.APIGravity // }).ToList(); // if (!query.Any()) // { // return new List<ProductionObject>(); // } // query.ForEach(j => // { // var quantityOut = 0; // var result2 = int.TryParse(j.Quantity, out quantityOut); // if (result2) // { // j.Quantity = Convert.ToDecimal(j.Quantity).ToString("#,##0"); // } // else // { // j.Quantity = "0"; // } // var monthOut = j.Month; // if (monthOut > 0) // { // j.Period = Enum.GetName(typeof (Months), monthOut) + "/" + j.Year; // } // if (monthOut < 1) // { // j.Period = j.Year.ToString(CultureInfo.InvariantCulture); // } // }); // return query.OrderBy(v => v.ProductName).ToList(); //} if (((queryBuilder.StartDate != null && queryBuilder.StartDate.Value.Year == 0001) || (queryBuilder.StartDate == null)) && ((queryBuilder.EndDate != null && queryBuilder.EndDate.Value.Year == 0001) || queryBuilder.EndDate == null)) { var query = ( from p in db.Productions.Where(m => (queryBuilder.FieldId > 0 && m.FieldId == queryBuilder.FieldId && queryBuilder.ProductId < 1) || (queryBuilder.ProductId > 0 && queryBuilder.FieldId < 1 && m.ProductId == queryBuilder.ProductId) || (queryBuilder.FieldId > 0 && queryBuilder.ProductId > 0 && queryBuilder.ProductId > 0 && queryBuilder.FieldId > 0 && m.FieldId == queryBuilder.FieldId && m.ProductId == queryBuilder.ProductId) || (queryBuilder.FieldId < 1 && queryBuilder.ProductId < 1)) join f in db.Fields on p.FieldId equals f.FieldId where ((queryBuilder.FieldId > 0 && f.FieldId == queryBuilder.FieldId) || (f.FieldId == p.FieldId && queryBuilder.FieldId < 1)) join c in db.Companies on f.CompanyId equals c.CompanyId where ((queryBuilder.CompanyId > 0 && c.CompanyId == queryBuilder.CompanyId) || (queryBuilder.CompanyId < 1 && c.CompanyId == f.CompanyId)) join z in db.Zones on f.ZoneId equals z.ZoneId //where ((queryBuilder.ZoneId > 0 && z.ZoneId == queryBuilder.ZoneId && z.ZoneId == f.ZoneId) || (z.ZoneId == f.ZoneId && queryBuilder.ZoneId < 1)) join t in db.Terrains on f.TerrainId equals t.TerrainId //where ((queryBuilder.TerrainId > 0 && // t.TerrainId == queryBuilder.TerrainId) || (queryBuilder.TerrainId < 1 && t.TerrainId == f.TerrainId)) join pd in db.Products on p.ProductId equals pd.ProductId where ((queryBuilder.ProductId > 0 && pd.ProductId == queryBuilder.ProductId) || (queryBuilder.ProductId < 1 && p.ProductId == pd.ProductId)) join b in db.Blocks on f.BlockId equals b.BlockId where ((queryBuilder.BlockId > 0 && f.BlockId == queryBuilder.BlockId) || (b.BlockId == f.BlockId && queryBuilder.BlockId < 1)) select new ProductionObject() { ProductName = pd.Name, BlockName = b.Name, FieldName = f.Name, CompanyName = c.Name, ZoneName = z.Name, TerrainName = t.Name, Quantity = p.Quantity, Year = p.Year, Month = p.Month, Remark = p.Remark, APIGravity = p.APIGravity }).ToList(); if (!query.Any()) { return(new List <ProductionObject>()); } query.ForEach(j => { var quantityOut = 0; var result2 = int.TryParse(j.Quantity, out quantityOut); if (result2) { j.Quantity = Convert.ToDecimal(j.Quantity).ToString("#,##0"); } else { j.Quantity = "0"; } var monthOut = j.Month; if (monthOut > 0) { j.Period = Enum.GetName(typeof(Months), monthOut) + "/" + j.Year; } if (monthOut < 1) { j.Period = j.Year.ToString(CultureInfo.InvariantCulture); } }); return(query.OrderBy(v => v.ProductName).ToList()); } } return(new List <ProductionObject>()); } } catch (Exception e) { ErrorLogger.LogEror(e.StackTrace, e.Source, e.Message); return(new List <ProductionObject>()); } }