Ejemplo n.º 1
0
        public object GetValue(int id)
        {
            object result = null;

            using (SqlCommand command = new SqlCommand())
            {
                command.CommandText = "uspGetCustomValue";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@RefID", id);
                command.Parameters.AddWithValue("@CustomFieldID", CustomFieldID);

                object o = (BaseCollection as CustomFields).ExecuteScalar(command, "CustomValues");
                if (o != null && o != DBNull.Value)
                {
                    result = o;
                }
                else if (FieldType == CustomFieldType.PickList)
                {
                    string[] items = ListValues.Split('|');
                    if (items.Length > 0)
                    {
                        result = items[0];
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public override string GetStepParameters()
        {
            var parameters = new List <string>();

            parameters.Add(Name != null ? Name.ToStepValue() : "$");
            parameters.Add(Description != null ? Description.ToStepValue() : "$");
            parameters.Add(ListValues != null ? ListValues.ToStepValue() : "$");
            parameters.Add(Unit != null ? Unit.ToStepValue() : "$");

            return(string.Join(", ", parameters.ToArray()));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Sets the <paramref name="fieldName"/> list's values list as
 /// <paramref name="fieldValues"/>, meaning they're referenced
 /// </summary>
 /// <param name="fieldName"></param>
 /// <param name="fieldValues"></param>
 /// <param name="addIfNotFound"></param>
 public void SetList(string fieldName, List <string> fieldValues, bool addIfNotFound = true)
 {
     if (ListValues.TryGetValue(fieldName, out List <string> unused))
     {
         ListValues[fieldName] = fieldValues;
     }
     else if (addIfNotFound)
     {
         ListValues.Add(fieldName, fieldValues);
     }
 }
Ejemplo n.º 4
0
        public ActionResult <ListValuesResponse> Post(ListValues request)
        {
            ListValuesResponse ret = new ListValuesResponse();
            GXSelectArgs       arg = GXSelectArgs.SelectAll <GXValue>();

            if (request.Ids != null && request.Ids.Length != 0)
            {
                arg.Where.And <GXValue>(q => request.Ids.Contains(q.AttributeId));
            }
            ret.Items = host.Connection.Select <GXValue>(arg).ToArray();
            return(ret);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Returns a reference of items within the specific list
 /// </summary>
 /// <param name="fieldName"></param>
 /// <param name="listValues"></param>
 /// <returns></returns>
 public bool TryGetList(string fieldName, out List <string> listValues)
 {
     if (ListValues.TryGetValue(fieldName, out List <string> values))
     {
         listValues = values;
         return(true);
     }
     else
     {
         listValues = null;
         return(false);
     }
 }
Ejemplo n.º 6
0
        public IList <Entities.Master.Unit> GetAllUnits()
        {
            Unit         tmpData;
            IList <Unit> list = new List <Unit>();

            try
            {
                Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString);

                Query = "SELECT Code, descript, 1 factor " +
                        " FROM MEASURE WHERE code = 'EA' ";

                ds = ReturnDataSet(Query, null, "MEASURE", Command.Connection);

                if (ds == null || ds.Tables.Count == 0)
                {
                    return(null);
                }

                //En el dataset, Tables: 1 - UOFM
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    //Solo para unidades equivalentes en unidad base
                    //if (Double.Parse(dr["factor"].ToString(), ListValues.DoubleFormat()) > 0)
                    //{
                    //Map Properties
                    tmpData = new Unit();

                    tmpData.Company      = CurCompany; // WType.GetDefaultCompany();
                    tmpData.Name         = dr["descript"].ToString();
                    tmpData.ErpCode      = dr["Code"].ToString();
                    tmpData.ErpCodeGroup = WmsSetupValues.DEFAULT;
                    tmpData.BaseAmount   = double.Parse(dr["factor"].ToString(), ListValues.DoubleFormat());
                    tmpData.IsFromErp    = true;
                    list.Add(tmpData);
                    //}
                }

                return(list);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetUnits", ListValues.EventType.Error, ex, null,
                                         ListValues.ErrorCategory.ErpConnection);
                //throw;
                return(null);
            }
        }
Ejemplo n.º 7
0
 public IEnumerable <object> Any(ListValues request)
 {
     if (request.Id != 0)
     {
         return(new[] {
             new { id = request.Id, Name = $"Value{request.Id}" }
         });
     }
     return(new[] {
         new { id = 1, Name = "Value1" },
         new { id = 2, Name = "Value2" },
         new { id = 3, Name = "Value3" },
         new { id = 4, Name = "Value4" },
         new { id = 5, Name = "Value5" },
     });
 }
Ejemplo n.º 8
0
        // TODO: async preload and cache icons?
        internal void ReloadViewList()
        {
            ListValues.Clear();
            ListValues.AddRange(
                PluginList.Select(p =>
                                  new CustomListTableData.CustomCellInfo(
                                      p.Plugin.Name,
                                      $"{p.Plugin.Author} <size=80%>{p.Plugin.Version}</size>",
                                      p.Icon,
                                      Enumerable.Empty <Sprite>()
                                      .AppendIf(p.Plugin.IsBare, Helpers.LibrarySprite)
                                      .AppendIf(p.State == PluginState.Disabled, Helpers.XSprite)
                                      .AppendIf(p.State == PluginState.Enabled &&
                                                p.Plugin.RuntimeOptions == RuntimeOptions.DynamicInit, Helpers.OSprite)
                                      .AppendIf(p.State == PluginState.Ignored, Helpers.WarnSprite))));

            customListTableData?.tableView?.ReloadData();
        }
Ejemplo n.º 9
0
        //UNITS
        /// <summary>
        /// Get Unit from Dynamics GP
        /// </summary>
        /// <returns></returns>
        public IList <Unit> GetAllUnits()
        {
            Unit         tmpData;
            IList <Unit> list = new List <Unit>();

            try
            {
                ds = DynamicsGP_ec.GetDataSet(DynamicsGP_ec.RetreiveData("WSUofMSchedule", false, 2, 0, "", true)); //WSUofMSchedule

                if (ds.Tables.Count == 0)
                {
                    return(null);
                }


                //En el dataset, Tables: 1 - UOFM
                foreach (DataRow dr in ds.Tables[2].Rows)
                {
                    //Solo para unidades equivalentes en unidad base
                    if (Double.Parse(dr["QTYBSUOM"].ToString(), ListValues.DoubleFormat()) > 0)
                    {
                        //Map Properties
                        tmpData = new Unit();

                        tmpData.Company      = CurCompany; // WType.GetDefaultCompany();
                        tmpData.Name         = dr["UOFM"].ToString();
                        tmpData.ErpCode      = dr["UOFM"].ToString();
                        tmpData.ErpCodeGroup = dr["UOMSCHDL"].ToString();
                        tmpData.BaseAmount   = double.Parse(dr["QTYBSUOM"].ToString(), ListValues.DoubleFormat());
                        tmpData.IsFromErp    = true;
                        list.Add(tmpData);
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetUnits", ListValues.EventType.Error, ex, null,
                                         ListValues.ErrorCategory.ErpConnection);
                //throw;
                return(null);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Obtiene current qty de unidad basica o logistica
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public Double SelectCurrentQty(Label data, Product product, bool includeLabeled)
        {
            //Dice si se debeincluir tambien en el inventario el producto marcado.

            StringBuilder sql = new StringBuilder("select Sum(l.CurrQty*l.Unit.BaseAmount) from Label l Where l.Status.StatusID = :id4 and l.Node.NodeID = :nd0 ");

            Parms = new List <Object[]>();

            if (data.Bin != null && data.Bin.BinID != 0 && data.LabelType.DocTypeID == LabelType.BinLocation)
            {
                sql.Append(" and l.Bin.BinID = :id2 ");
                Parms.Add(new Object[] { "id2", data.Bin.BinID });

                if (!includeLabeled)
                {                                         //Solo cuenta lo que este UnLabeled en el BIN
                    sql.Append(" and l.Printed = :fl1 "); //FatherLabel.LabelID is null
                    Parms.Add(new Object[] { "fl1", false });
                }
            }
            else if (data.LabelID != 0 && (data.LabelType.DocTypeID == LabelType.ProductLabel || data.LabelType.DocTypeID == LabelType.UniqueTrackLabel))
            {
                sql.Append(" and (l.LabelID = :id1 OR l.FatherLabel.LabelID = :id1)");
                Parms.Add(new Object[] { "id1", data.LabelID });
            }

            if (product != null && product.ProductID != 0)
            {
                sql.Append(" and  l.Product.ProductID = :id3 ");
                Parms.Add(new Object[] { "id3", product.ProductID });
            }

            Parms.Add(new Object[] { "id4", EntityStatus.Active });
            Parms.Add(new Object[] { "nd0", NodeType.Stored });

            IQuery query = Factory.Session.CreateQuery(sql.ToString());

            SetParameters(query);

            try { return(Double.Parse(query.UniqueResult().ToString(), ListValues.DoubleFormat())); }
            catch { return(0); }
        }
Ejemplo n.º 11
0
        private IList <DocumentLine> GetKitAssemblyDocumentLines(Document doc)
        {
            DocumentLine         tmpData;
            IList <DocumentLine> list = new List <DocumentLine>();
            Status lineStatus         = WType.GetStatus(new Status {
                StatusID = DocStatus.New
            });


            int    curLine   = 1;
            string curMaster = "";


            Query = GetErpQuery("KITDOC_LINE").Replace("__DOCUMENT", doc.ErpMaster.ToString());

            DataSet ds = ReturnDataSet(Query, null, "KITDOC_LINE", Command.Connection);

            if (ds == null || ds.Tables.Count == 0)
            {
                return(null);
            }


            if (ds.Tables[0].Select("rowid=0").Length == 0)
            {
                return(null);
            }

            try
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    tmpData       = new DocumentLine();
                    tmpData.Date1 = doc.Date1;

                    tmpData.LineNumber        = int.Parse(dr["rowid"].ToString()); //curLine++;
                    tmpData.Sequence          = tmpData.LineNumber;
                    tmpData.LinkDocLineNumber = int.Parse(dr["row_padre"].ToString());
                    tmpData.Note = dr["type"].ToString();

                    //TODO: Revisar el Status en GP para traer el equivalente
                    tmpData.LineStatus   = lineStatus;
                    tmpData.Document     = doc;
                    tmpData.IsDebit      = false;
                    tmpData.Quantity     = double.Parse(dr["f470_cant_base"].ToString(), ListValues.DoubleFormat());
                    tmpData.CreatedBy    = WmsSetupValues.SystemUser;
                    tmpData.CreationDate = DateTime.Now;

                    curMaster        = "Location";
                    tmpData.Location = doc.Location; //WType.GetLocation(new Location { Company = CurCompany, ErpCode = dr["LOCNCODE"].ToString() });

                    try
                    {
                        curMaster       = "Product";
                        tmpData.Product = WType.GetProduct(new Product {
                            Company = CurCompany, ProductCode = dr["item_id"].ToString()
                        });;

                        curMaster    = "Unit";
                        tmpData.Unit = WType.GetUnit(new Unit {
                            ErpCode = dr["unit_id"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup
                        });
                    }
                    catch (Exception ex)
                    {
                        ExceptionMngr.WriteEvent("GetKitAssemblyDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                                 ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                        continue;
                        //{
                        //    //Pone el Default Product
                        //    tmpData.Product = WType.GetProduct(new Product { Company = CurCompany, ProductCode = WmsSetupValues.DEFAULT });
                        //    tmpData.LineDescription = "Unknown: " + dr["ITEMNMBR"].ToString() + ", " + dr["ITEMDESC"].ToString();

                        //    curMaster = "Unit";
                        //    tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["UOFM"].ToString() });
                    }

                    list.Add(tmpData);
                }

                return((list.Count > 0) ? list : null);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetKitAssemblyDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                         ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                throw;
                //return null;
            }
        }
        private IList <DocumentLine> GetShippingDocumentLines(Document doc, Company company, string docID, bool useRemain)
        {
            DocumentLine         tmpData;
            IList <DocumentLine> list = new List <DocumentLine>();
            Status lineStatus         = WType.GetStatus(new Status {
                StatusID = DocStatus.New
            });


            int    curLine   = 0;
            string curMaster = "";


            try
            {
                Query = GetErpQuery("SALESORDER_LINE").Replace("__DOCUMENT", docID);

                DataSet ds = ReturnDataSet(Query, null, "SALESORDER_LINE", Command.Connection);

                if (ds == null || ds.Tables.Count == 0)
                {
                    return(null);
                }



                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    tmpData       = new DocumentLine();
                    tmpData.Date1 = doc.Date1;
                    curMaster     = "";

                    try { tmpData.Date2 = DateTime.Parse(dr["f431_fecha_entrega"].ToString()); }
                    catch { }
                    try { tmpData.Date3 = DateTime.Parse(dr["f431_fecha_cumplido"].ToString()); }
                    catch { }

                    tmpData.LineNumber = int.Parse(dr["f431_rowid"].ToString());
                    tmpData.Sequence   = tmpData.LineNumber;
                    curLine            = tmpData.LineNumber;

                    //TODO: Revisar el Status en GP para traer el equivalente
                    tmpData.LineStatus = GetShippingStatus(0);
                    tmpData.Document   = doc;
                    tmpData.IsDebit    = false;

                    if (useRemain)
                    {
                        tmpData.Quantity = double.Parse(dr["f431_cant_facturada_base"].ToString(), new NumberFormatInfo {
                            NumberDecimalSeparator = Separator
                        });
                    }
                    else
                    {
                        tmpData.Quantity = double.Parse(dr["f431_cant_facturada_base"].ToString(), ListValues.DoubleFormat());
                    }

                    //tmpData.QtyCancel = double.Parse(dr["QTYCANCE"].ToString(), ListValues.DoubleFormat());
                    //tmpData.QtyBackOrder = double.Parse(dr["QTYTBAOR"].ToString(), ListValues.DoubleFormat());
                    //tmpData.QtyPending = tmpData.Quantity - tmpData.QtyCancel - double.Parse(dr["QTYPRINV"].ToString(), ListValues.DoubleFormat());
                    //tmpData.QtyAllocated = double.Parse(dr["ATYALLOC"].ToString(), ListValues.DoubleFormat());
                    tmpData.CreatedBy    = WmsSetupValues.SystemUser;
                    tmpData.CreationDate = DateTime.Now;

                    curMaster        = "Location:" + dr["cod_bodega"].ToString();
                    tmpData.Location = WType.GetLocation(new Location {
                        Company = company, ErpCode = dr["cod_bodega"].ToString()
                    });

                    try
                    {
                        curMaster       = "Product:" + dr["f121_rowid_item"].ToString();
                        tmpData.Product = WType.GetProduct(new Product {
                            Company = company, ProductCode = dr["f121_rowid_item"].ToString()
                        });
                        tmpData.LineDescription = dr["f120_descripcion"].ToString();

                        curMaster    = "Uom:" + dr["f431_id_unidad_medida"].ToString();
                        tmpData.Unit = WType.GetUnit(new Unit {
                            ErpCode = dr["f431_id_unidad_medida"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup
                        });
                    }
                    catch
                    {
                        //Pone el Default Product
                        tmpData.Product = WType.GetProduct(new Product {
                            Company = doc.Location.Company, ProductCode = WmsSetupValues.DEFAULT
                        });
                        tmpData.LineDescription = "Unknown: " + dr["f121_rowid_item"].ToString() + ", " + dr["f120_descripcion"].ToString();

                        curMaster    = "Uom:" + dr["f431_id_unidad_medida"].ToString();
                        tmpData.Unit = WType.GetUnit(new Unit {
                            ErpCode = dr["f431_id_unidad_medida"].ToString()
                        });
                    }

                    //Manage Prices
                    curMaster             = "Prices Product:" + dr["f121_rowid_item"].ToString();
                    tmpData.UnitPrice     = double.Parse(dr["f431_precio_unitario_base"].ToString(), ListValues.DoubleFormat());
                    tmpData.ExtendedPrice = double.Parse(dr["subtotal"].ToString(), ListValues.DoubleFormat());

                    //Asignacion de Address
                    curMaster = "Address Doc:" + doc.DocNumber;
                    //tmpData.DocumentLineAddresses = GetShippingDocumentAddress(tmpData.Document, tmpData, dr);


                    list.Add(tmpData);
                }

                return((list.Count > 0) ? list : null);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetShippingDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                         ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;
                return(null);
            }
        }
Ejemplo n.º 13
0
 public SearchTemplate(List <int> listAddresses, List <int> listValues, bool exactMatch) : this()
 {
     ListAddresses.AddRange(listAddresses);
     ListValues.AddRange(listAddresses);
     ExactMatch = exactMatch;
 }
Ejemplo n.º 14
0
        private IList <DocumentLine> GetPurchaseReturnsLines(Document doc, DataRow[] dLines, DataTable dtQty)
        {
            DocumentLine         tmpData;
            IList <DocumentLine> list = new List <DocumentLine>();
            Status lineStatus         = WType.GetStatus(new Status {
                StatusID = DocStatus.New
            });


            int    curLine   = 0;
            string curMaster = "";

            DataRow[] qtyReceipt;

            try
            {
                foreach (DataRow dr in dLines)
                {
                    tmpData       = new DocumentLine();
                    tmpData.Date1 = doc.Date1;
                    curMaster     = "";


                    tmpData.LineNumber = int.Parse(dr["RCPTLNNM"].ToString());
                    tmpData.Sequence   = tmpData.LineNumber;
                    curLine            = tmpData.LineNumber;

                    try
                    {
                        qtyReceipt = dtQty.Select("RCPTLNNM = '" + dr["RCPTLNNM"].ToString() + "' AND POPRCTNM='" + dr["POPRCTNM"].ToString() + "'");

                        //Console.WriteLine("RCPTLNNM = " + dr["RCPTLNNM"].ToString() + " AND POPRCTNM='" + dr["POPRCTNM"].ToString() + "'" + qtyReceipt.Length.ToString());

                        tmpData.Quantity = double.Parse(qtyReceipt[0]["QTYRESERVED"].ToString(), ListValues.DoubleFormat());
                    }
                    catch (Exception ez) {
                        ExceptionMngr.WriteEvent("QTYRESERVED: " + dr["POPRCTNM"].ToString() + "," + dr["RCPTLNNM"].ToString(),
                                                 ListValues.EventType.Error, ez, null, ListValues.ErrorCategory.ErpConnection);

                        tmpData.Quantity = 0;
                    }


                    //TODO: Revisar el Status en GP para traer el equivalente
                    tmpData.LineStatus   = GetShippingStatus(0);
                    tmpData.Document     = doc;
                    tmpData.IsDebit      = false;
                    tmpData.CreatedBy    = WmsSetupValues.SystemUser;
                    tmpData.CreationDate = DateTime.Now;

                    curMaster        = "Location:" + dr["LOCNCODE"].ToString();
                    tmpData.Location = WType.GetLocation(new Location {
                        Company = CurCompany, ErpCode = dr["LOCNCODE"].ToString()
                    });

                    try
                    {
                        curMaster       = "Product:" + dr["ITEMNMBR"].ToString();
                        tmpData.Product = WType.GetProduct(new Product {
                            Company = CurCompany, ProductCode = dr["ITEMNMBR"].ToString()
                        });;
                        tmpData.LineDescription = dr["ITEMDESC"].ToString();

                        curMaster    = "Uom:" + dr["UOFM"].ToString();
                        tmpData.Unit = WType.GetUnit(new Unit {
                            ErpCode = dr["UOFM"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup
                        });
                    }
                    catch (Exception ex)
                    {
                        ExceptionMngr.WriteEvent("GetPurchaseReturnsLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                                 ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                        continue;

                        //{
                        //    //Pone el Default Product
                        //    tmpData.Product = WType.GetProduct(new Product { Company = CurCompany, ProductCode = WmsSetupValues.DEFAULT });
                        //    tmpData.LineDescription = "Unknown: " + dr["ITEMNMBR"].ToString() + ", " + dr["ITEMDESC"].ToString();

                        //    curMaster = "Uom:" + dr["UOFM"].ToString();
                        //    tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["UOFM"].ToString() });
                    }



                    //Manage Prices
                    tmpData.UnitPrice     = double.Parse(dr["UNITCOST"].ToString(), ListValues.DoubleFormat());
                    tmpData.ExtendedPrice = double.Parse(dr["EXTDCOST"].ToString(), ListValues.DoubleFormat());

                    //Asignacion de Address
                    //tmpData.DocumentLineAddresses = GetShippingDocumentAddress(tmpData.Document, tmpData, dr);

                    list.Add(tmpData);
                }

                return((list.Count > 0) ? list : null);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetPurchaseReturnsLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                         ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;
                return(null);
            }
        }
Ejemplo n.º 15
0
        private IList <DocumentLine> GetReceivingDocumentLines(Document doc, Company company, DataRow[] dLines)
        {
            DocumentLine         tmpData;
            IList <DocumentLine> list = new List <DocumentLine>();
            //Status lineStatus = WType.GetStatus(new Status { StatusID = DocStatus.New });

            int    curLine   = 0;
            string curMaster = "";

            try
            {
                foreach (DataRow dr in dLines)
                {
                    tmpData       = new DocumentLine();
                    tmpData.Date1 = doc.Date1;
                    curMaster     = "";

                    tmpData.Date2       = DateTime.Parse(dr["REQDATE"].ToString());
                    tmpData.Date3       = DateTime.Parse(dr["PRMSHPDTE"].ToString());
                    tmpData.Date4       = DateTime.Parse(dr["PRMDATE"].ToString());
                    tmpData.LineNumber  = int.Parse(dr["ORD"].ToString());
                    tmpData.AccountItem = dr["VNDITNUM"].ToString();
                    tmpData.Sequence    = tmpData.LineNumber;

                    curLine              = tmpData.LineNumber;
                    tmpData.Document     = doc;
                    tmpData.IsDebit      = false;
                    tmpData.Quantity     = double.Parse(dr["QTYORDER"].ToString(), ListValues.DoubleFormat());
                    tmpData.QtyCancel    = double.Parse(dr["QTYCANCE"].ToString(), ListValues.DoubleFormat());
                    tmpData.QtyPending   = double.Parse(dr["QTYUNCMTBASE"].ToString(), ListValues.DoubleFormat());
                    tmpData.CreatedBy    = WmsSetupValues.SystemUser;
                    tmpData.CreationDate = DateTime.Now;

                    curMaster          = "Status:" + dr["POLNESTA"].ToString();
                    tmpData.LineStatus = GetReceivingStatus(int.Parse(dr["POLNESTA"].ToString())); //doc.DocStatus;
                    curMaster          = "Location:" + dr["LOCNCODE"].ToString();
                    tmpData.Location   = WType.GetLocation(new Location {
                        Company = company, ErpCode = dr["LOCNCODE"].ToString()
                    });

                    try
                    {
                        curMaster       = "Product:" + dr["ITEMNMBR"].ToString();
                        tmpData.Product = WType.GetProduct(new Product {
                            Company = company, ProductCode = dr["ITEMNMBR"].ToString()
                        });
                        tmpData.LineDescription = dr["ITEMDESC"].ToString();

                        curMaster    = "Uom:" + dr["UOFM"].ToString();
                        tmpData.Unit = WType.GetUnit(new Unit {
                            ErpCode = dr["UOFM"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup
                        });
                    }
                    catch (Exception ex)
                    {
                        ExceptionMngr.WriteEvent("GetReceiptDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                                 ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                        continue;

                        //    //Pone el Default Product
                        //    tmpData.Product = WType.GetProduct(new Product { Company = company, ProductCode = WmsSetupValues.DEFAULT });
                        //    tmpData.LineDescription = "Unknown: " + dr["ITEMNMBR"].ToString() + ", " + dr["ITEMDESC"].ToString();

                        //    curMaster = "Uom:" + dr["UOFM"].ToString();
                        //    tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["UOFM"].ToString() });
                    }

                    //Unit - Price, Cost
                    tmpData.UnitCost     = double.Parse(dr["UNITCOST"].ToString(), ListValues.DoubleFormat());
                    tmpData.ExtendedCost = double.Parse(dr["EXTDCOST"].ToString(), ListValues.DoubleFormat());

                    //SOP POP Link
                    object[] sop_popLink = GetSOP_POPLink(doc.DocNumber, tmpData.LineNumber, doc.DocType.DocTypeID);
                    if (sop_popLink != null)
                    {
                        tmpData.LinkDocNumber     = sop_popLink[0].ToString();
                        tmpData.LinkDocLineNumber = int.Parse(sop_popLink[1].ToString());
                    }


                    list.Add(tmpData);
                }

                return((list.Count > 0) ? list : null);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetReceiptDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                         ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;
                return(null);
            }
        }
Ejemplo n.º 16
0
        public ActionResult Category()
        {
            // The values of weight and height are obtained if you have permission.
            double height_user = 0;
            double weight_user = 0;

            foreach (Claim claim in ClaimsPrincipal.Current.Claims)
            {
                if (claim.Type.Equals("extension_Access") && claim.Value.Equals("False"))
                {
                    ViewBag.Error   = "You don't have permissions.";
                    ViewBag.Explain = "Contact your admin to obtain permission to access the panel.";
                    return(View("Error"));
                }
                else if (claim.Type.Equals("extension_Weight"))
                {
                    weight_user = Double.Parse(claim.Value);
                }
                else if (claim.Type.Equals("extension_Height"))
                {
                    height_user = Double.Parse(claim.Value);
                }
            }

            // You get the value of BMI
            ViewBag.bmi = (weight_user / (height_user * height_user)) * 10000;

            // Initializes values to post the counters of the categories
            double valor       = 0;
            int    underweight = 0;
            int    normal      = 0;
            int    preobesity  = 0;
            int    obesity     = 0;

            // Gets the values from the uploaded file and posts them to the corresponding counters
            string file = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/data.json");
            string Json = System.IO.File.ReadAllText(file);
            JavaScriptSerializer ser        = new JavaScriptSerializer();
            ListValues           personlist = ser.Deserialize <ListValues>(Json);

            foreach (var item in personlist.Values)
            {
                valor = (item.Weight / (item.Height * item.Height));
                if (valor < 18.5)
                {
                    underweight++;
                }
                else if (valor <= 24.9)
                {
                    normal++;
                }
                else if (valor <= 29.9)
                {
                    preobesity++;
                }
                else
                {
                    obesity++;
                }
            }

            // Values are passed on to the view
            ViewBag.underweight = underweight;
            ViewBag.normal      = normal;
            ViewBag.preobesity  = preobesity;
            ViewBag.obesity     = obesity;

            // Through the user's data, it determines which category corresponds to the user
            int category;

            if (ViewBag.bmi < 18.5)
            {
                category = underweight;
            }
            else if (ViewBag.bmi <= 24.9)
            {
                category = normal;
            }
            else if (ViewBag.bmi <= 29.9)
            {
                category = preobesity;
            }
            else
            {
                category = obesity;
            }

            // Once it is known which category corresponds to the user, it is counted in the corresponding
            // category and the percentile is found with respect to the counter of people that obtains each category.

            // IMPORTANT: The percentile is calculated on this sample of category counters as simple data, it could
            // also have been calculated by obtaining a list with the calculated values of each user's BMI and
            // obtaining a more precise value. Since, for 1-2 million entries I think that is not adequate, this
            // could have been solved if instead of loading a file, that file was used to update data through the
            // Entity Framework.
            var percentile = 0;
            var values     = new int[] { underweight, normal, preobesity, obesity };
            var n          = values.Length;

            foreach (var i in values)
            {
                var pr = ((values.Count(v => v < i) + (.5 * values.Count(v => v == i))) / n);
                if (pr < category)
                {
                    percentile += 1;
                }
            }

            ViewBag.percentile = percentile;

            return(View());
        }
Ejemplo n.º 17
0
        public bool Load(string fullPath)
        {
            if (!File.Exists(fullPath))
            {
                return(false);
            }

            StringValues.Clear();
            ListValues.Clear();
            IsConfigLoaded = false;

            // YML Parser
            try
            {
                bool          isNextLineList = false;
                string        listName       = "";
                List <string> currentList    = new List <string>();
                string[]      configLines    = File.ReadAllLines(fullPath);
                for (int i = 0; i < configLines.Length; i++)
                {
                    string line = configLines[i];
                    // even if in the middle of a list, still allow empty spaces
                    if (line == string.Empty || line.TrimStart()[0] == '#')
                    {
                        continue;
                    }

                    // parse lists. cannot parse lists within a list... not yet atleast ;)
                    if (isNextLineList)
                    {
                        string trimmedListItemStart = line.TrimStart();
                        if (trimmedListItemStart[0] == '-')
                        {
                            string listItem = trimmedListItemStart.After("-").TrimStart().TrimEnd();
                            currentList.Add(listItem);

                            // last line
                            if ((i + 1) == configLines.Length)
                            {
                                if (isNextLineList)
                                {
                                    isNextLineList = false;
                                    ListValues.Add(listName, new List <string>(currentList));
                                    listName = "";
                                    currentList.Clear();
                                    break;
                                }
                            }

                            continue;
                        }
                        else
                        {
                            ListValues.Add(listName, new List <string>(currentList));
                            listName = "";
                            currentList.Clear();
                            isNextLineList = false;
                        }
                    }

                    // parse fields. "string" and "bool" pairs are treaded the same when loading and saving
                    // tho they can be parsed to "true" or "false" as a bool later on... see TryGetBoolean
                    string trimmedStart = line.TrimStart();
                    string trimmedEnd   = line.TrimEnd();
                    string fieldName    = trimmedStart.Before(":");
                    string fieldValue   = trimmedEnd.After(":").TrimStart();
                    if (fieldName.IsEmpty() || fieldName[0] == ':')
                    {
                        continue;
                    }

                    // this is the only thing that can tell if looking for a field/value
                    // or a field/list. fieldValue will always be empty unless you put a
                    // value after the colon. if you put something after the colon then
                    // add the - listValues... idek what could happen but it could break
                    if (fieldValue.IsEmpty())
                    {
                        isNextLineList = true;
                        listName       = fieldName;
                    }
                    else
                    {
                        StringValues.Add(fieldName, fieldValue);
                    }
                }

                ConfigPath     = fullPath;
                IsConfigLoaded = true;
                return(true);
            }
            catch
            {
                StringValues.Clear();
                ListValues.Clear();
                IsConfigLoaded = false;
                return(false);
            }
        }
Ejemplo n.º 18
0
 public void Clear()
 {
     ListValues.Clear(); ListAddresses.Clear();
 }
Ejemplo n.º 19
0
 public void AddListValues(List <int> listValues)
 {
     ListValues.AddRange(listValues);
 }
Ejemplo n.º 20
0
        private IList <DocumentLine> GetKitAssemblyDocumentLines(Document doc)
        {
            DocumentLine         tmpData;
            IList <DocumentLine> list = new List <DocumentLine>();
            Status lineStatus         = WType.GetStatus(new Status {
                StatusID = DocStatus.New
            });


            int    curLine   = 1;
            string curMaster = "";

            // BM10300 - KitAssembly Document Lines
            DataSet ds = ReturnDataSet("SELECT * FROM BM10300 WHERE 1=1 ", "TRX_ID='" + doc.DocNumber + "'", "BM10300", Command.Connection);


            if (ds == null || ds.Tables.Count == 0)
            {
                return(null);
            }


            try
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    tmpData       = new DocumentLine();
                    tmpData.Date1 = doc.Date1;

                    tmpData.LineNumber        = int.Parse(dr["Component_ID"].ToString()); //curLine++;
                    tmpData.Sequence          = tmpData.LineNumber;
                    tmpData.LinkDocLineNumber = int.Parse(dr["Parent_Component_ID"].ToString());
                    tmpData.Note = dr["BM_Component_Type"].ToString();

                    //TODO: Revisar el Status en GP para traer el equivalente
                    tmpData.LineStatus   = lineStatus;
                    tmpData.Document     = doc;
                    tmpData.IsDebit      = false;
                    tmpData.Quantity     = double.Parse(dr["Extended_Standard_Quantity"].ToString(), ListValues.DoubleFormat());
                    tmpData.CreatedBy    = WmsSetupValues.SystemUser;
                    tmpData.CreationDate = DateTime.Now;

                    curMaster        = "Location";
                    tmpData.Location = WType.GetLocation(new Location {
                        Company = CurCompany, ErpCode = dr["LOCNCODE"].ToString()
                    });

                    try
                    {
                        curMaster       = "Product";
                        tmpData.Product = WType.GetProduct(new Product {
                            Company = CurCompany, ProductCode = dr["ITEMNMBR"].ToString()
                        });;

                        curMaster    = "Unit";
                        tmpData.Unit = WType.GetUnit(new Unit {
                            ErpCode = dr["UOFM"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup
                        });
                    }
                    catch (Exception ex)
                    {
                        ExceptionMngr.WriteEvent("GetKitAssemblyDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                                 ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                        continue;
                        //{
                        //    //Pone el Default Product
                        //    tmpData.Product = WType.GetProduct(new Product { Company = CurCompany, ProductCode = WmsSetupValues.DEFAULT });
                        //    tmpData.LineDescription = "Unknown: " + dr["ITEMNMBR"].ToString() + ", " + dr["ITEMDESC"].ToString();

                        //    curMaster = "Unit";
                        //    tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["UOFM"].ToString() });
                    }

                    list.Add(tmpData);
                }

                return((list.Count > 0) ? list : null);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetKitAssemblyDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                         ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                throw;
                //return null;
            }
        }