Пример #1
0
        protected void Load(IObjectSpace os, crmContractDeal deal_sale, LineKey key, IDictionary <TrwBudgetKey, IList <TrwBudgetValue> > keys)
        {
            crmDealVersion deal_version = deal_sale.Current;

            foreach (crmStage stage in deal_version.StageStructure.Stages)
            {
                Load(os, deal_version, stage, key, keys);
            }
        }
Пример #2
0
        public override bool Equals(object obj)
        {
            if (obj == null || !(obj is LineKey))
            {
                return(false);
            }
            LineKey other = (LineKey)obj;

            return((other.p0 == p0 && other.p1 == p1) || (other.p0 == p1 && other.p1 == p0));
        }
        private void btnDeleteLine_Click(object sender, RoutedEventArgs e)
        {
            if (LineType == LineType.NestedObjectOpening || (LineType == LineType.DeletedLine && typeBeforeDelete == LineType.NestedObjectOpening))
            {
                var args = new LineEventArgs();
                args.LineNumber       = LineNumber;
                args.OriginalLineType = LineType;

                InnerDocumentDelete?.Invoke(this, args);
            }
            else
            {
                if (!LineKey.Equals("_id"))
                {
                    SetLineAsDeleted();
                }
            }
        }
Пример #4
0
        //
        protected void Load(IObjectSpace os, TrwSubjectDealSale trw_deal_sale, IDictionary <TrwBudgetKey, IList <TrwBudgetValue> > keys)
        {
            LineKey key = new LineKey();

            key.TrwSubject = trw_deal_sale.TrwSubject;
// This property set from trw_deal_sale
//            key.Subject = trw_deal_sale.Subject;
            key.Deal  = trw_deal_sale.Deal;
            key.Party = key.Deal.Customer;
            if (trw_deal_sale.DealBudget != null)
            {
                key.TrwContract = trw_deal_sale.DealBudget;
            }
            if (key.Deal != null)
            {
                key.TrwOrder = key.Subject.TrwOrders.FirstOrDefault(x => x.Deal == key.Deal);
                Load(os, key.Deal, key, keys);
            }
        }
Пример #5
0
    public void Init()
    {
        editableVertexPrefab = EditManager.Instance.editableVertexPrefab;
        editableLinePrefab   = EditManager.Instance.editableLinePrefab;

        mesh = GetComponentInChildren <MeshFilter>().mesh;

        Dictionary <Vector3, List <int> > vertexDict = new Dictionary <Vector3, List <int> >();

        Vector3[] vertices = mesh.vertices;
        for (int v = 0; v < vertices.Length; v++)
        {
            if (!vertexDict.ContainsKey(vertices[v]))
            {
                vertexDict[vertices[v]] = new List <int>();
            }
            vertexDict[vertices[v]].Add(v);
            this.vertices.Add(vertices[v]);
        }

        EditableVertex[] eVertices = new EditableVertex[mesh.vertexCount];

        foreach (var vertex in vertexDict.Keys)
        {
            Vector3 scaleVertex = vertex;
            scaleVertex.x *= meshTransform.localScale.x;
            scaleVertex.y *= meshTransform.localScale.y;
            scaleVertex.z *= meshTransform.localScale.z;

            EditableVertex eVertex = Instantiate(editableVertexPrefab, scaleVertex + transform.position, Quaternion.identity);
            eVertex.Initialize(this, vertexDict[vertex]);
            foreach (var idx in vertexDict[vertex])
            {
                eVertices[idx] = eVertex;
            }
        }

        int[] aArr = new int[] { 0, 0, 1 };
        int[] bArr = new int[] { 1, 2, 2 };

        var lines = new Dictionary <LineKey, EditableLine>();

        int[] triangles = mesh.triangles;
        for (int t = 0; t < triangles.Length; t += 3)
        {
            int idx = triangles[t];

            for (int i = 0; i < 3; i++)
            {
                int ta = t + aArr[i];
                int tb = t + bArr[i];

                LineKey key = new LineKey(eVertices[triangles[ta]], eVertices[triangles[tb]]);
                if (lines.ContainsKey(key))
                {
                    lines[key].tIndices.Add(idx);
                }
                else
                {
                    EditableLine line = Instantiate(editableLinePrefab);
                    line.Initialize(this, eVertices[triangles[ta]], eVertices[triangles[tb]], idx);
                    lines[key] = line;
                }
            }
        }

        var pairsToDelete = new List <KeyValuePair <LineKey, EditableLine> >();

        Vector3[] normals = mesh.normals;
        foreach (var linePair in lines)
        {
            print(linePair.Value.tIndices.Count);

            bool         delete = true;
            EditableLine line   = linePair.Value;

            Vector3 normal = normals[line.tIndices[0]];
            for (int i = 1; i < line.tIndices.Count; i++)
            {
                if (normals[line.tIndices[i]] != normal)
                {
                    delete = false;
                    break;
                }
            }
            if (delete)
            {
                pairsToDelete.Add(linePair);
            }
        }

        foreach (var pair in pairsToDelete)
        {
            lines.Remove(pair.Key);
            Destroy(pair.Value.gameObject);
        }

        foreach (var line in lines.Values)
        {
            //things.Add(line);
            if (!listeningList.ContainsKey(line.point0))
            {
                listeningList[line.point0] = new List <IUpdatable>();
            }
            listeningList[line.point0].Add(line);

            if (!listeningList.ContainsKey(line.point1))
            {
                listeningList[line.point1] = new List <IUpdatable>();
            }
            listeningList[line.point1].Add(line);
        }
    }
Пример #6
0
        protected void Load(IObjectSpace os, crmDealVersion deal_version, crmStage stage, LineKey key, IDictionary <TrwBudgetKey, IList <TrwBudgetValue> > keys)
        {
            foreach (crmDeliveryUnit unit in stage.DeliveryPlan.DeliveryUnits)
            {
                foreach (crmDeliveryItem item in unit.DeliveryItems)
                {
//                    TrwBudgetPeriodValue period_value = TrwBudgetMaster.TrwPeriod.ValueGet(unit.DatePlane);
                    TrwBudgetValue budget_value = null;
                    TrwBudgetKey   budget_key   = keys.Keys.FirstOrDefault(
                        x => x.DealSale == key.Deal &&
                        x.Subject == key.Subject &&
                        x.Order == item.Order &&
                        x.Party == key.Party &&
                        x.ObligationValuta == item.Valuta &&
                        x.TrwContractSale == key.TrwContract &&
                        x.TrwOrderSale == key.TrwOrder &&
                        x.TrwSaleNomenclature == item.TrwSaleNomenclature
                        );
                    if (budget_key == null)
                    {
                        budget_key = os.CreateObject <TrwBudgetKey>();
                        BudgetMaster.BudgetKeys.Add(budget_key);
                        // budget_key.SubjectBudget = this;
                        // budget_key.BudgetBase = this;
                        budget_key.DealSale            = key.Deal;
                        budget_key.Party               = key.Party;
                        budget_key.Subject             = key.Subject;
                        budget_key.Order               = item.Order;
                        budget_key.ObligationValuta    = item.Valuta;
                        budget_key.TrwContractSale     = key.TrwContract;
                        budget_key.TrwOrderSale        = key.TrwOrder;
                        budget_key.TrwSaleNomenclature = item.TrwSaleNomenclature;
                        keys[budget_key]               = new List <TrwBudgetValue>();
                        foreach (TrwBudgetPeriodValue period_value in BudgetMaster.BudgetPeriod.PeriodValues)
                        {
                            budget_value = os.CreateObject <TrwBudgetValue>();
                            budget_key.TrwBudgetValues.Add(budget_value);
                            BudgetValues.Add(budget_value);
                            BudgetMaster.BudgetValues.Add(budget_value);
                            if (period_value.Month < 0 && period_value.Month < 13)
                            {
                                budget_value.Date = new DateTime(BudgetMaster.BudgetPeriod.Year, period_value.Month, 1);
                                budget_value.Date.AddMonths(1);
                                budget_value.Date.AddDays(-1);
                            }
                            else
                            {
                                if (period_value.Month == 0)
                                {
                                    budget_value.Date = new DateTime(BudgetMaster.BudgetPeriod.Year - 1, 12, 31);
                                }
                                else
                                {
                                    budget_value.Date = new DateTime(BudgetMaster.BudgetPeriod.Year + 1, 01, 01);
                                }
                            }
                            BudgetMaster.BudgetPeriod.ValueGet(budget_value.Date).BudgetValues.Add(budget_value);
                            if (BudgetMaster.BudgetPeriod.Valuta == budget_key.ObligationValuta)
                            {
                                budget_value.ObligationRate = 1;
                            }
                            else
                            {
                                budget_value.ObligationRate = BudgetMaster.BudgetPeriod.CurrencyExchanges.FirstOrDefault(x => x.Valuta == budget_key.ObligationValuta).Rate;
                            }
                            keys[budget_key].Add(budget_value);
                        }
                    }
                    budget_value = keys[budget_key].FirstOrDefault(
                        x => x.Date == unit.DatePlane &&
                        x.ObligationValuta == item.Valuta
                        );
                    if (budget_value == null)
                    {
                        budget_value = os.CreateObject <TrwBudgetValue>();
                        budget_key.TrwBudgetValues.Add(budget_value);
                        BudgetValues.Add(budget_value);
                        BudgetMaster.BudgetValues.Add(budget_value);
                        budget_value.Date = unit.DatePlane;
                        BudgetMaster.BudgetPeriod.ValueGet(budget_value.Date).BudgetValues.Add(budget_value);
                        keys[budget_key].Add(budget_value);
                    }
                    budget_value.SummCost += item.SummCost;
                    budget_value.SummVat  += item.SummNDS;
                    budget_value.SummAll   = budget_value.SummCost + budget_value.SummVat;
                }
            }
        }