示例#1
0
        public static bool Update()
        {
            DateTime ISRTime = UtilsDateTime.UTC_To_Israel_Time();
            DateTime UTCNow  = new DateTime(DateTime.UtcNow.Ticks);

            if (Last_Config_Update_ISR.AddMinutes(ConfigUpdateAsMinutes) < ISRTime)
            {
                lock (locker1)
                {
                    if (Last_Config_Update_ISR.AddMinutes(ConfigUpdateAsMinutes) < ISRTime)
                    {
                        lock (locker2)
                        {
                            if (Last_Config_Update_ISR.AddMinutes(ConfigUpdateAsMinutes) < ISRTime)
                            {
                                if (ConfigurationManager.AppSettings["AZURE"].Equals("true"))
                                {
                                    RenewProjectToken = RoleEnvironment.GetConfigurationSettingValue("RenewProjectToken").ToString().Equals("true");
                                }
                                else
                                {
                                    RenewProjectToken = ConfigurationManager.AppSettings["RenewProjectToken"].ToString().Equals("true");
                                }



                                List <API_UI_UserResponse_GetResult> UIResponse_DB = UtilsDB.API_UI_UserResponse_Get(AppManagerGuid, ISRTime);
                                Projects = UtilsDB.API_Project_Get(AppManagerGuid, ISRTime, RenewProjectToken);

                                List <UIOut> UIResponse_TEMP = new List <UIOut>();
                                foreach (API_UI_UserResponse_GetResult UI in UIResponse_DB)
                                {
                                    UIResponse_TEMP.Add(new Models.UIOut()
                                    {
                                        ID = UI.ID, MSG = UI.Text, ProjectID = UI.ProjectID
                                    });
                                }
                                UIResponse = UIResponse_TEMP;

                                #region MyRegion CONFIGURATION

                                if (ConfigurationManager.AppSettings["AZURE"].Equals("true"))
                                {
                                    AllowedDomains   = RoleEnvironment.GetConfigurationSettingValue("AllowedDomains").ToString().Split(',').ToList();
                                    RestrictServerIP = RoleEnvironment.GetConfigurationSettingValue("RestrictServerIP").ToString().Equals("true");
                                    // Dog_StartDate = DateTime.ParseExact(RoleEnvironment.GetConfigurationSettingValue("Dog_StartDate").ToString(), "yyyy-MM-dd", null);
                                    // Dog_EndDate = DateTime.ParseExact(RoleEnvironment.GetConfigurationSettingValue("Dog_EndDate").ToString(), "yyyy-MM-dd", null);
                                    Cat_StartDate = DateTime.ParseExact(RoleEnvironment.GetConfigurationSettingValue("Cat_StartDate").ToString(), "yyyy-MM-dd", null);
                                    Cat_EndDate   = DateTime.ParseExact(RoleEnvironment.GetConfigurationSettingValue("Cat_EndDate").ToString(), "yyyy-MM-dd", null);

                                    ConfigUpdateAsMinutes             = int.Parse(RoleEnvironment.GetConfigurationSettingValue("ConfigUpdateAsMinutes").ToString());
                                    ClientFetchDataInterval_AsMinutes = int.Parse(RoleEnvironment.GetConfigurationSettingValue("ClientFetchDataInterval_AsMinutes").ToString());

                                    // Dog_ServerToken = Guid.Parse(RoleEnvironment.GetConfigurationSettingValue("Dog_ServerToken").ToString());
                                    Cat_ServerToken = Guid.Parse(RoleEnvironment.GetConfigurationSettingValue("Cat_ServerToken").ToString());

                                    IP_MinuteCycle     = int.Parse(RoleEnvironment.GetConfigurationSettingValue("IP_MinuteCycle").ToString());
                                    IP_AllowedPerCycle = int.Parse(RoleEnvironment.GetConfigurationSettingValue("IP_AllowedPerCycle").ToString());

                                    Unique_MinuteCycle                = int.Parse(RoleEnvironment.GetConfigurationSettingValue("Unique_MinuteCycle").ToString());
                                    Unique_AllowedPerCycle            = int.Parse(RoleEnvironment.GetConfigurationSettingValue("Unique_AllowedPerCycle").ToString());
                                    Local_Cache_Refresh_Hour_Interval = int.Parse(RoleEnvironment.GetConfigurationSettingValue("Local_Cache_Refresh_Hour_Interval").ToString());
                                }
                                else
                                {
                                    RenewProjectToken = ConfigurationManager.AppSettings["RenewProjectToken"].ToString().Equals("true");
                                    RestrictServerIP  = ConfigurationManager.AppSettings["RestrictServerIP"].ToString().Equals("true");
                                    AllowedDomains    = ConfigurationManager.AppSettings["AllowedDomains"].ToString().Split(',').ToList();
                                    Local_Cache_Refresh_Hour_Interval = int.Parse(ConfigurationManager.AppSettings["Local_Cache_Refresh_Hour_Interval"].ToString());
                                    //  Dog_StartDate = DateTime.ParseExact(ConfigurationManager.AppSettings["Dog_StartDate"].ToString(), "yyyy-MM-dd", null);
                                    //  Dog_EndDate = DateTime.ParseExact(ConfigurationManager.AppSettings["Dog_EndDate"].ToString(), "yyyy-MM-dd", null);
                                    Cat_StartDate = DateTime.ParseExact(ConfigurationManager.AppSettings["Cat_StartDate"].ToString(), "yyyy-MM-dd", null);
                                    Cat_EndDate   = DateTime.ParseExact(ConfigurationManager.AppSettings["Cat_EndDate"].ToString(), "yyyy-MM-dd", null);

                                    ConfigUpdateAsMinutes             = int.Parse(ConfigurationManager.AppSettings["ConfigUpdateAsMinutes"].ToString());
                                    ClientFetchDataInterval_AsMinutes = int.Parse(ConfigurationManager.AppSettings["ClientFetchDataInterval_AsMinutes"].ToString());

                                    //  Dog_ServerToken = Guid.Parse(ConfigurationManager.AppSettings["Dog_ServerToken"].ToString());
                                    Cat_ServerToken = Guid.Parse(ConfigurationManager.AppSettings["Cat_ServerToken"].ToString());

                                    IP_MinuteCycle     = int.Parse(ConfigurationManager.AppSettings["IP_MinuteCycle"].ToString());
                                    IP_AllowedPerCycle = int.Parse(ConfigurationManager.AppSettings["IP_AllowedPerCycle"].ToString());

                                    Unique_MinuteCycle     = int.Parse(ConfigurationManager.AppSettings["Unique_MinuteCycle"].ToString());
                                    Unique_AllowedPerCycle = int.Parse(ConfigurationManager.AppSettings["Unique_AllowedPerCycle"].ToString());
                                }

                                #endregion

                                Last_Config_Update_ISR = new DateTime(ISRTime.Ticks);
                            }
                        }
                    }
                }
            }

            return(true);
        }