Example #1
0
        public TypeTree(StreamReader stream)
        {
            Attributes = stream.ReadInt32();
            Embeded    = stream.ReadByte();

            var baseClassCount = stream.ReadInt32();

            for (var i = 0; i < baseClassCount; i++)
            {
                var entry = new TypeEntry(stream)
                {
                    Index = i
                };
                BaseClasses.Add(entry);

                if (Embeded == 0)
                {
                    continue;
                }

                if (entry.TypeId == (int)CommonTypeIds.MonoBehaviour)
                {
                    var info = new TypeTreeInfo(stream);
                    if (!ScriptTypeInfos.TryAdd(entry.Unknown2, info))
                    {
                        Log.Print(LogType.Warning, $"Multiple scripts with id={entry.Unknown2}!");
                    }
                }
                else
                {
                    TypeInfos.Add(entry.TypeId, new TypeTreeInfo(stream));
                }
            }
        }
Example #2
0
        protected override bool TryGetValue(object key, bool direct, out object member)
        {
            var name = key as string;

            if (name != null)
            {
                if (Members.TryGetValue(name, out member))
                {
                    if (!direct)
                    {
                        var prop = member as Property;
                        if (prop != null)
                        {
                            member = prop.Value;
                        }
                    }
                    return(true);
                }
                foreach (var baseClass in BaseClasses.Reverse())
                {
                    if (baseClass().TryGetValue(key, direct, out member))
                    {
                        return(true);
                    }
                }
            }
            member = null;
            return(false);
        }
Example #3
0
        public void ShouldInjectDependenciesForRootObjectBaseClass()
        {
            var            pdi   = new DependencyInjector();
            var            @base = new BaseClasses();
            InjectionState @is;

            (_, @is) = pdi.CreateAndInjectDependencies(@base);
            (SomeClassUser scu, InjectionState is2) = pdi.CreateAndInjectDependencies <SomeClassUser>(@is);
            Assert.IsNotNull(scu.BaseClasses);
            Assert.IsNotNull(scu.SomeBaseClass);
            Assert.IsNotNull(scu.SomeInterface);
        }
Example #4
0
        /// <summary>
        /// Gets all base classes (including base classes of base classes).
        /// </summary>
        internal IEnumerable <Symbol> GetAllBaseClasses()
        {
            List <Symbol> unprocessed = BaseClasses.ToList();

            while (unprocessed.Count > 0)
            {
                List <Symbol> symbols = unprocessed;

                unprocessed = new List <Symbol>();
                foreach (var symbol in symbols)
                {
                    yield return(symbol);

                    unprocessed.AddRange(symbol.BaseClasses);
                }
            }
        }
        /// <summary>
        /// Gets information about the inheritance of a node in the concentrator.
        /// </summary>
        /// <param name="To">Address of server.</param>
        /// <param name="NodeID">Node ID</param>
        /// <param name="SourceID">Optional Source ID</param>
        /// <param name="Partition">Optional Partition</param>
        /// <param name="Language">Code of desired language.</param>
        /// <param name="ServiceToken">Optional Service token.</param>
        /// <param name="DeviceToken">Optional Device token.</param>
        /// <param name="UserToken">Optional User token.</param>
        /// <param name="Callback">Method to call when response is returned.</param>
        /// <param name="State">State object to pass on to callback method.</param>
        public void GetNodeInheritance(string To, string NodeID, string SourceID, string Partition, string Language,
                                       string ServiceToken, string DeviceToken, string UserToken, StringsResponseEventHandler Callback, object State)
        {
            StringBuilder Xml = new StringBuilder();

            Xml.Append("<getNodeInheritance xmlns='");
            Xml.Append(ConcentratorServer.NamespaceConcentrator);
            Xml.Append("'");
            this.AppendNodeAttributes(Xml, NodeID, SourceID, Partition);
            this.AppendTokenAttributes(Xml, ServiceToken, DeviceToken, UserToken);

            if (!string.IsNullOrEmpty(Language))
            {
                Xml.Append("' xml:lang='");
                Xml.Append(XML.Encode(Language));
            }

            Xml.Append("'/>");

            this.client.SendIqGet(To, Xml.ToString(), (sender, e) =>
            {
                List <string> BaseClasses = new List <string>();
                XmlElement E;

                if (e.Ok && (E = e.FirstElement) != null && E.LocalName == "getNodeInheritanceResponse" && E.NamespaceURI == ConcentratorServer.NamespaceConcentrator)
                {
                    foreach (XmlNode N in E)
                    {
                        if (N is XmlElement E2 && E2.LocalName == "baseClasses")
                        {
                            foreach (XmlNode N2 in E2.ChildNodes)
                            {
                                if (N2 is XmlElement E3 && E3.LocalName == "value")
                                {
                                    BaseClasses.Add(E3.InnerText);
                                }
                            }
                        }
                    }
 private string EvaluateFormula(string formula, BaseClasses.Data.BaseRecord dataSourceForEvaluate, string format, System.Collections.Generic.IDictionary<string,object> variables, bool includeDS)
 {
     return EvaluateFormula_Base(formula, dataSourceForEvaluate, format, variables, includeDS);
 }
        public string EvaluateFormula_Base(string formula, BaseClasses.Data.BaseRecord dataSourceForEvaluate, string format, System.Collections.Generic.IDictionary<string, object> variables, bool includeDS)
        {
            FormulaEvaluator e = new FormulaEvaluator();

            // add variables for formula evaluation
            if (variables != null)
            {
                System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, object>> enumerator = variables.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    e.Variables.Add(enumerator.Current.Key, enumerator.Current.Value);
                }
            }

            if (includeDS)
            {

            }

            e.CallingControl = this;

            // All variables referred to in the formula are expected to be
            // properties of the DataSource.  For example, referring to
            // UnitPrice as a variable will refer to DataSource.UnitPrice
            e.DataSource = dataSourceForEvaluate;

            // Define the calling control.
            e.CallingControl = this;

            object resultObj = e.Evaluate(formula);
            if (resultObj == null)
                return "";

            if ( !string.IsNullOrEmpty(format) && (string.IsNullOrEmpty(formula) || formula.IndexOf("Format(") < 0) )
            {
                return FormulaUtils.Format(resultObj, format);
            }
            else
            {
                return resultObj.ToString();
            }
        }
 public string EvaluateFormula(string formula, BaseClasses.Data.BaseRecord dataSourceForEvaluate, string format, System.Collections.Generic.IDictionary<string, object> variables)
 {
     return EvaluateFormula(formula, dataSourceForEvaluate, format, variables, true);
 }
 public virtual string EvaluateFormula(string formula, BaseClasses.Data.BaseRecord dataSourceForEvaluate)
 {
     return this.EvaluateFormula(formula, dataSourceForEvaluate, null, null, true, null);
 }
 public virtual string EvaluateFormula(string formula, BaseClasses.Data.BaseRecord dataSourceForEvaluate, System.Collections.Generic.IDictionary<string, object> variables, FormulaEvaluator e)
 {
     return this.EvaluateFormula(formula, dataSourceForEvaluate, null, variables, true, e);
 }
        /// <summary>
        /// Evaluates the formula
        /// </summary>
        public static string EvaluateFormula(string formula, BaseClasses.Data.BaseRecord dataSourceForEvaluate, string format, string name)
        {
            BaseFormulaEvaluator e = new BaseFormulaEvaluator();
            if(dataSourceForEvaluate != null)
                e.Evaluator.Variables.Add(name, dataSourceForEvaluate);
            e.DataSource = dataSourceForEvaluate;
            object resultObj = e.Evaluate(formula);

            if (resultObj == null)
                return "";
            if (!string.IsNullOrEmpty(format))
                return BaseFormulaUtils.Format(resultObj, format);
            else
            return resultObj.ToString();
        }
Example #12
0
 protected override IEnumerable <string> GetMemberNames()
 {
     return(Members.Keys.Concat(BaseClasses.SelectMany(x => x().GetMemberNames())).Distinct());
 }
Example #13
0
 /// <summary>
 ///     Searches for a device base class based on the passed base class identification number
 /// </summary>
 /// <param name="baseClassId">The base class identification number to search for.</param>
 /// <returns>An instance of <see cref="PCIDeviceBaseClass" /> class if a base class is found; otherwise null.</returns>
 public static PCIDeviceBaseClass GetDeviceBaseClass(byte baseClassId)
 {
     return(BaseClasses.FirstOrDefault(baseClass => baseClass.BaseClassId == baseClassId));
 }
Example #14
0
 public void AddBaseClass(BaseClass baseClass)
 {
     BaseClasses.Add(baseClass);
 }
Example #15
0
 //  Tentando utilizar mais de herança e polimorfismo,
 //  Mais sou muito burro para tal
 public void AddVitalidadeAtributes(BaseClasses baseClasses)
 {
 }
 private string EvaluateFormula(string formula, BaseClasses.Data.BaseRecord dataSourceForEvaluate)
 {
     return EvaluateFormula(formula, dataSourceForEvaluate, null, null, true);
 }
Example #17
0
        /// <summary>
        /// Полное копирование текущего объекта
        /// </summary>
        /// <returns>Полная копия объекта</returns>
        public ScheduleCompleteSegment FullCopy()
        {
            var result = new ScheduleCompleteSegment();

            result.AircraftType        = AircraftType;
            result.ArrivalDaysChange   = ArrivalDaysChange;
            result.ArrivalTime         = ArrivalTime;
            result.ArrivalTimeString   = ArrivalTimeString;
            result.Charterer           = Charterer;
            result.DepartureDaysChange = DepartureDaysChange;
            result.DepartureTime       = DepartureTime;
            result.DepartureTimeString = DepartureTimeString;
            result.EndDate             = EndDate;
            result.ETicket             = ETicket;
            result.FlightNumber        = FlightNumber;
            result.FlightTime          = FlightTime;
            result.ID          = ID;
            result.MarkAirline = MarkAirline;
            result.OpAirline   = OpAirline;
            result.StartDate   = StartDate;

            if (ArrAirp != null)
            {
                result.ArrAirp             = new AirportInformation();
                result.ArrAirp.AirportCode = ArrAirp.AirportCode;
                result.ArrAirp.CityCode    = ArrAirp.CityCode;
                result.ArrAirp.Terminal    = ArrAirp.Terminal;
                result.ArrAirp.UTC         = ArrAirp.UTC;
            }

            if (DepAirp != null)
            {
                result.DepAirp             = new AirportInformation();
                result.DepAirp.AirportCode = DepAirp.AirportCode;
                result.DepAirp.CityCode    = DepAirp.CityCode;
                result.DepAirp.Terminal    = DepAirp.Terminal;
                result.DepAirp.UTC         = DepAirp.UTC;
            }

            if (BaseClasses != null && BaseClasses.Count > 0)
            {
                result.BaseClasses = new List <BaseClass>();
                BaseClasses.ForEach(bc => { result.BaseClasses.Add(bc); });
            }

            if (OperatedDaysOfWeek != null && OperatedDaysOfWeek.Count > 0)
            {
                result.OperatedDaysOfWeek = new DaysOfWeekList();
                OperatedDaysOfWeek.ForEach(dow => { result.OperatedDaysOfWeek.Add(dow); });
            }

            if (StopPoints != null && StopPoints.Count > 0)
            {
                result.StopPoints = new List <StopPoint>();

                foreach (var stopPoint in StopPoints)
                {
                    var point = new StopPoint();

                    point.AirportCode = stopPoint.AirportCode;
                    point.ArrDateTime = stopPoint.ArrDateTime;
                    point.CityCode    = stopPoint.CityCode;
                    point.DepDateTime = stopPoint.DepDateTime;
                    point.Terminal    = stopPoint.Terminal;
                    point.UTC         = stopPoint.UTC;

                    result.StopPoints.Add(point);
                }
            }

            return(result);
        }
Example #18
0
        static void Main(string[] args)
        {
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };

            HelperHouseManagementService            helperHouseManagementService            = new HelperHouseManagementService();
            HelperOrganizationRegistryCommonService helperOrganizationRegistryCommonService = new HelperOrganizationRegistryCommonService();
            HelperBillService helperBillService = new HelperBillService();

            string typeRes = null;

            do
            {
                foreach (var tmpSupplyResourceContract in helperHouseManagementService.GetSupplyResourceContractData(_orgPPAGUID, _ExportContractRootGUID).exportSupplyResourceContractResult.Items)
                {
                    typeRes = tmpSupplyResourceContract.ToString();
                    if (tmpSupplyResourceContract.GetType() == typeof(_HouseManagementService.exportSupplyResourceContractResultType))
                    {
                        var tmpExportSupplyResourceContract = tmpSupplyResourceContract as _HouseManagementService.exportSupplyResourceContractResultType;
                        if (tmpExportSupplyResourceContract.VersionStatus == _HouseManagementService.exportSupplyResourceContractResultTypeVersionStatus.Posted &&
                            tmpExportSupplyResourceContract.Item1.GetType() == typeof(_HouseManagementService.ExportSupplyResourceContractTypeOrganization))
                        {
                            Console.WriteLine("ContractRootGUID: {0}", tmpExportSupplyResourceContract.ContractRootGUID);
                            _ContractRootGUID  = tmpExportSupplyResourceContract.ContractRootGUID;
                            _OrgRootEntityGUID = ((_HouseManagementService.ExportSupplyResourceContractTypeOrganization)tmpExportSupplyResourceContract.Item1).orgRootEntityGUID;
                            #region Экспорт информации о второй стороне договора
                            foreach (var itemOrgRegistry in helperOrganizationRegistryCommonService.GetOrgRegistry(_OrgRootEntityGUID).exportOrgRegistryResult.Items)
                            {
                                var ResultTypeOrgVersion = itemOrgRegistry as _OrganizationRegistryCommonService.exportOrgRegistryResultType;
                                var ItemLegalType        = ResultTypeOrgVersion.OrgVersion.Item as _OrganizationRegistryCommonService.LegalType;
                                Console.WriteLine("Organization full name: {0}", ItemLegalType.FullName);
                                _OrgRootOrganizationINN = ItemLegalType.INN;
                            }
                            #endregion
                            #region Экспорт состояния оплаты
                            foreach (var tmpExportSettlements in helperBillService.GetSettlements(_orgPPAGUID, _ContractRootGUID).exportSettlementsResult.Items)
                            {
                                if (tmpExportSettlements.GetType() == typeof(_BillsService.ErrorMessageType) &&
                                    ((_BillsService.ErrorMessageType)tmpExportSettlements).ErrorCode != "INT002012")
                                {
                                    var ErrorMessage = tmpExportSettlements as _BillsService.ErrorMessageType;
                                    BaseClasses.OutputError(ErrorMessage.ErrorCode, ErrorMessage.Description);
                                }
                                else
                                {
                                    if (tmpExportSettlements.GetType() != typeof(_BillsService.ErrorMessageType))
                                    {
                                        var resultExportSettlements          = tmpExportSettlements as _BillsService.ExportSettlementResultType;
                                        var reportingPeriodExportSettlements = resultExportSettlements.ReportingPeriod as _BillsService.ExportSettlementResultTypeReportingPeriod[];
                                        isExistValue = reportingPeriodExportSettlements
                                                       .Any(obj => obj.ReportPeriodStatus.Status == _BillsService.ExportSettlementResultTypeReportingPeriodReportPeriodStatusStatus.Posted &&
                                                            obj.Month == DateTime.Now.AddMonths(-2).Month &&
                                                            obj.Year == DateTime.Now.AddMonths(-2).Year);
                                        _SettlementGUID   = resultExportSettlements.SettlementGUID;
                                        _ContractRootGUID = null;
                                    }
                                    else
                                    {
                                        _SettlementGUID = null;
                                        isExistValue    = false;
                                    }
                                    if (isExistValue)
                                    {
                                        BaseClasses.OutputMessage(_OrgRootOrganizationINN + " Data for the period " + DateTime.Now.AddMonths(-2).Month + "." + DateTime.Now.AddMonths(-2).Year + " already exist");
                                    }
                                    else
                                    {
                                        #region Получение сведений о расчетах
                                        string connectionString = @"Data Source=storage;Initial Catalog=master;User Id=" + ConfigurationManager.AppSettings["db_login"] + ";Password="******"db_pass"];
                                        string sqlExpression    = @"WITH t1
                                                                 AS (
                                                                    SELECT 
                                                                        CASE 
                                                                            WHEN [BAccount_ID] = 62.0
                                                                                THEN d.[InvSum] + d.[InvVat]
                                                                            ELSE 0
                                                                            END AS TotalDebSum
                                                                        ,CASE 
                                                                            WHEN [BAccount_ID] = 62.5
                                                                                THEN d.[InvSum] + d.[InvVat]
                                                                            ELSE 0
                                                                            END AS TotalAvansSum
                                                                        ,CASE 
                                                                            WHEN p.PayoffType = 0
                                                                                THEN p.PayoffSum
                                                                            ELSE 0
                                                                            END AS TotalPayoffSum
                                                                    FROM [VKAbon].[dbo].[Debit] d
                                                                    LEFT JOIN [VKAbon].[dbo].[Abon_Details] ad ON d.Abon_ID = ad.Abon_ID
                                                                    LEFT JOIN (
                                                                        SELECT Debit_ID
                                                                            ,SUM(PayoffSum) AS PayoffSum
                                                                            ,PayoffType
                                                                        FROM [VKAbon].[dbo].Payoff
                                                                        GROUP BY Debit_ID
                                                                            ,PayoffType
                                                                        ) p ON d.Debit_ID = p.Debit_ID
                                                                    WHERE ad.INN = @INN
                                                                        AND YEAR(DebitDate) = @yearnumber
                                                                        AND MONTH([DebitDate]) = @monthnumber
                                                                        AND ad.DEnd = '2079-01-01'
                                                                    )
                                                                 SELECT
                                                                    SUM(TotalDebSum) AS TotalDebSum
                                                                    ,SUM(TotalAvansSum) AS TotalAvansSum
                                                                    ,SUM(TotalPayoffSum) AS TotalPayoffSum
                                                                    ,SUM(TotalDebSum) - SUM(TotalPayoffSum) - SUM(TotalAvansSum) AS TotalSaldo
                                                                 FROM t1
                                                                 HAVING
                                                                 SUM(TotalDebSum) IS NOT NULL
                                                                 AND SUM(TotalAvansSum) IS NOT NULL
                                                                 AND SUM(TotalPayoffSum) IS NOT NULL
                                                                 AND SUM(TotalDebSum) - SUM(TotalPayoffSum) - SUM(TotalAvansSum) IS NOT NULL";
                                        using (SqlConnection connection = new SqlConnection(connectionString))
                                        {
                                            connection.Open();
                                            SqlCommand   command = new SqlCommand(sqlExpression, connection);
                                            SqlParameter _INN    = new SqlParameter("@INN", _OrgRootOrganizationINN);
                                            command.Parameters.Add(_INN);
                                            SqlParameter _Month = new SqlParameter("@monthnumber", DateTime.Now.AddMonths(-2).Month);
                                            command.Parameters.Add(_Month);
                                            SqlParameter _Year = new SqlParameter("@yearnumber", DateTime.Now.AddMonths(-2).Year);
                                            command.Parameters.Add(_Year);
                                            SqlDataReader reader = command.ExecuteReader();
                                            if (reader.HasRows)
                                            {
                                                while (reader.Read())
                                                {
                                                    _TotalDebSum    = Convert.ToDecimal(reader["TotalDebSum"]);
                                                    _TotalAvansSum  = Convert.ToDecimal(reader["TotalAvansSum"]);
                                                    _TotalPayoffSum = Convert.ToDecimal(reader["TotalPayoffSum"]);
                                                    _TotalSaldo     = Convert.ToDecimal(reader["TotalSaldo"]);
                                                }
                                                #region Импорт состояния расчетов за период
                                                foreach (var itemResultImportSettlement in helperBillService.SetRSOSettlements(_orgPPAGUID, _ContractRootGUID, _SettlementGUID, DateTime.Now.AddMonths(-2), _TotalDebSum, _TotalPayoffSum, _TotalSaldo, _TotalAvansSum).ImportResult.Items)
                                                {
                                                    if (itemResultImportSettlement.GetType() == typeof(_BillsService.ErrorMessageType))
                                                    {
                                                        var ErrorMessage = itemResultImportSettlement as _BillsService.ErrorMessageType;
                                                        BaseClasses.OutputError(ErrorMessage.ErrorCode, ErrorMessage.Description);
                                                    }
                                                    else
                                                    {
                                                        var ResultType = itemResultImportSettlement as _BillsService.CommonResultType;
                                                        if (ResultType.Items[0].GetType() == typeof(_BillsService.CommonResultTypeError))
                                                        {
                                                            var ResultTypeError = ResultType.Items[0] as _BillsService.CommonResultTypeError;
                                                            BaseClasses.OutputError(ResultTypeError.ErrorCode, ResultTypeError.Description);
                                                        }
                                                        else
                                                        {
                                                            BaseClasses.OutputMessage(_OrgRootOrganizationINN + " Data import " + ResultType.Items[0]);
                                                        }
                                                    }
                                                }
                                                #endregion
                                            }
                                            else
                                            {
                                                BaseClasses.OutputMessage(_OrgRootOrganizationINN + " Settlements in our system is absent");
                                            }
                                            reader.Close();
                                            connection.Close();
                                        }
                                        #endregion
                                    }
                                }
                            }
                            #endregion
                            Console.WriteLine("-----------------------");
                        }
                    }
                    else
                    {
                        _ExportContractRootGUID = tmpSupplyResourceContract.ToString();
                    }
                }
            }while (typeRes != "True");

            Console.Read();
        }