Exemple #1
0
 public void SetMailSetting(XmlDocument webconfigDoc)
 {
     ConfigUtility.SetAppSettingsNodeValue(webconfigDoc,
                                           ConfigUtility.Const_KeyMSMQMail,
                                           IsOpenFunction ? "true" : "false");
     //ConfigUtility.SetNodeValue(webconfigDoc, _SystemServiceModelPath, "endpoint",
     //                           new XmlNodeAttributesModel(ConfigUtility.Const_endpointname,
     //                                                      ConfigUtility.Const_KeyServiceMailName),
     //                           new XmlNodeAttributesModel(ConfigUtility.Const_endpointaddress,
     //                                                      ABCClientSetView1.ServerAddress));
     //ConfigUtility.SetNodeValue(webconfigDoc, _SystemServiceModelPath, "endpoint",
     //                           new XmlNodeAttributesModel(ConfigUtility.Const_endpointname,
     //                                                      ConfigUtility.Const_KeyServiceMailName),
     //                           new XmlNodeAttributesModel(ConfigUtility.Const_endpointbinding,
     //                                                      ABCClientSetView1.ServerBinding));
     //ConfigUtility.SetNodeValue(webconfigDoc, _SystemServiceModelPath, "endpoint",
     //                           new XmlNodeAttributesModel(ConfigUtility.Const_endpointname,
     //                                                      ConfigUtility.Const_KeyServiceMailName),
     //                           new XmlNodeAttributesModel(ConfigUtility.Const_endpointcontract,
     //                                                      ABCClientSetView1.ServerContract));
     //ConfigUtility.SetNodeValue(webconfigDoc, _SystemServiceModelPath, "endpoint",
     //                           new XmlNodeAttributesModel(ConfigUtility.Const_endpointname,
     //                                                      ConfigUtility.Const_KeyServiceMailName),
     //                           new XmlNodeAttributesModel(ConfigUtility.Const_endpointbindingConfiguration,
     //                                                      ABCClientSetView1.ServerBindingConfiguration));
 }
Exemple #2
0
        /// <summary>
        /// 全局初始化
        /// </summary>
        public static void Initialize()
        {
            // 设置连接字符串
            string source = AppConfig.GetAppSetting("ConnectionSource");

            if (string.IsNullOrEmpty(source))
            {
                throw new PoseidonException(ErrorCode.DatabaseConnectionNotFound);
            }

            string connection = "";

            if (source == "dbconfig")
            {
                string name = AppConfig.GetAppSetting("DbConnection");
                connection = ConfigUtility.GetConnectionString(name);
            }
            else if (source == "appconfig")
            {
                connection = AppConfig.GetConnectionString();
            }

            if (string.IsNullOrEmpty(connection))
            {
                throw new PoseidonException(ErrorCode.DatabaseConnectionNotFound);
            }

            Cache.Instance.Add("ConnectionString", connection);

            // 设置数据库访问类型
            string dalPrefix = AppConfig.GetAppSetting("DALPrefix");

            Cache.Instance.Add("DALPrefix", dalPrefix);
        }
Exemple #3
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            var hash = Hasher.SHA1Encrypt(this.txtPassword.Text);
            var result = CallerFactory<IUserService>.Instance.Login(this.txtUserName.Text, hash);

            if (result)
            {
                if (this.chkRemember.Checked)
                {
                    SaveRemember();
                }
                else
                {
                    ConfigUtility.RemoveRememberUser();
                }

                this.user = CallerFactory<IUserService>.Instance.FindByUserName(this.txtUserName.Text);
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageUtil.ShowWarning("用户名或密码错误");
                this.txtPassword.Text = "";
                return;
            }
        }
Exemple #4
0
        public void ColoredInitializeDataRefreshCorrectly()
        {
            TraceSource source    = new TraceSource("colored1Source");
            var         listener1 = source.Listeners.OfType <ColoredConsoleTraceListener>().First();

            // Verify values are correct before changing
            Assert.IsFalse(listener1.UseErrorStream);

            var configPath = ConfigUtility.GetConfigDirFromTestRunDirectory(TestContext.TestRunDirectory);

            using (var file = new FileResetScope(configPath))
            {
                var doc               = XDocument.Parse(file.OriginalText);
                var configuration     = doc.Root; //.Element("configuration");
                var systemDiagnostics = configuration.Element("system.diagnostics");
                var sharedListeners   = systemDiagnostics.Element("sharedListeners");
                var listenerConfig    = sharedListeners.Elements().First(x => x.Attribute("name").Value == "colored1");

                listenerConfig.SetAttributeValue("initializeData", true);

                doc.Save(configPath);
                Trace.Refresh();

                var listener2 = source.Listeners.OfType <ColoredConsoleTraceListener>().First();
                Assert.IsTrue(listener2.UseErrorStream);
                Assert.AreNotSame(listener1, listener2);
            }
        }
Exemple #5
0
 protected void UpdateButton_Click(object sender, EventArgs e)
 {
     if (AckBox.Checked)
     {
         string message;
         if (ValidateConnection(ConnectionString.Text, out message))
         {
             ConfigUtility.UpdateConnectionString(ConnectionString.Text, EncryptIt.Enabled ? EncryptIt.Checked : false);
             SavedMessage.Text             = "Connection string updated at " + LocaleHelper.LocalNow.ToShortTimeString() + ".";
             SavedMessage.Visible          = true;
             ExistingConnectionString.Text = ConnectionString.Text;
             AckBox.Checked = false;
         }
         else
         {
             ErrorMessage.Text    = "A connection could not be established for the given connection string.  Connection string not updated.  (The server said: " + message + ")";
             ErrorMessage.Visible = true;
         }
     }
     else
     {
         ErrorMessage.Text    = "You did not acknowledge the warning.  Connection string not updated.";
         ErrorMessage.Visible = true;
     }
 }
Exemple #6
0
 /// <summary>
 /// 记住用户名密码
 /// </summary>
 private void SaveRemember()
 {
     if (ConfigUtility.CheckRememberUser())
         ConfigUtility.UpdateRememberUser(this.txtUserName.Text, this.txtPassword.Text);
     else
         ConfigUtility.SaveRememberUser(this.txtUserName.Text, this.txtPassword.Text);
 }
Exemple #7
0
        public JsonResult ResetPwd(int id = 0)
        {
            PublicUser publicUser = ncBase.CurrentEntities.PublicUser.Where(o => o.UserID == id).FirstOrDefault();

            if (publicUser.IsNull())
            {
                return(Json(new { status = 1, msg = "没有找到用户!(用户ID:" + id + ")" }));
            }
            string passWordAdorn = ConfigUtility.GetValue("PassWordAdorn");
            string passWord      = string.Empty;

            if (string.IsNullOrEmpty(publicUser.Tel))
            {
                passWord = Convert.ToString(publicUser.UserID);
            }
            PublicUserModel loginUser = this.GetLoginUser();

            passWord            = publicUser.Tel;
            publicUser.Password = StringUtility.ToMd5String(passWordAdorn + passWord);
            ncBase.CurrentEntities.SaveChanges();
            OperatorLog operatorLog = new OperatorLog();

            operatorLog.Note    = "重置密码,被重置用户ID:" + publicUser.UserID + " 新密码:" + passWord;
            operatorLog.Type    = 1;
            operatorLog.Uid     = loginUser.UserID;
            operatorLog.AddTime = DateTime.Now;
            ncBase.CurrentEntities.AddToOperatorLog(operatorLog);
            ncBase.CurrentEntities.SaveChanges();

            return(Json(new { status = 0, msg = "密码重置成功, 新密码:" + passWord }));
        }
        private static string GetRemoteConfigFile()
        {
            string remoteFile = System.Web.Configuration.WebConfigurationManager.AppSettings[RemoteConfigFileAppSettingKey];

            if (remoteFile == null)
            {
                remoteFile = LocalConfigurationManager.MapConfigPath(RemoteConfigurationManagerConfigFileName);
            }
            else
            {
                remoteFile = LocalConfigurationManager.MapConfigPath(remoteFile);
            }
            if (!File.Exists(remoteFile))
            {
                LoggerWrapper.Logger.Info("配置文件" + remoteFile + "' 不存在, 将会在 '" + ConfigUtility.DefaultApplicationConfigFolder + "'创建新的默认配置文件");
                remoteFile = ConfigUtility.Combine(ConfigUtility.DefaultApplicationConfigFolder, RemoteConfigurationManagerConfigFileName);

                // 如果 "RemoteConfigurationManager.config" 不存在时必须在此创建默认配置
                if (!File.Exists(remoteFile))
                {
                    Directory.CreateDirectory(ConfigUtility.DefaultApplicationConfigFolder);
                    using (XmlTextWriter writer = new XmlTextWriter(remoteFile, Encoding.UTF8))
                    {
                        writer.WriteStartElement(RemoteConfigurationManagerConfiguration.TagName);
                        RemoteConfigurationManagerConfiguration.DefaultConfig.WriteXml(writer);
                        writer.WriteEndElement();
                    }
                }
            }
            return(remoteFile);
        }
Exemple #9
0
        public override void Initialize(Dictionary <string, object> settings)
        {
            string pluginNamespace = GetContainerNamespace();
            //load types specific to this host into TypeContainer
            TagConfigDatabase tagConfigDatabase = TagConfigDatabase.Instance;

            tagConfigDatabase.Load(ConfigUtility.ReadFile(settings.GetValueOrNull("OpcTagConfigFile") as string));
            TagStateManager tagStateManager = new TagStateManager(tagConfigDatabase);

            settings["TagStateManager"]   = tagStateManager;
            settings["TagConfigDatabase"] = tagConfigDatabase;

            //configure receiver
            TypeContainer            tc           = TypeContainer.Instance;
            IProcessor               opcReceiver  = tc.GetInstance <IReceiver>(pluginNamespace) as IProcessor;
            IConverter <object, Tag> opcConverter = tc.GetInstance <IConverter <object, Tag> >(pluginNamespace);

            settings["Logger"]          = tc.GetInstance <ILogger>();
            settings["OpcTagConverter"] = opcConverter;
            if (opcReceiver != null)
            {
                this.AddReceiver("OpcReceiver", opcReceiver);
            }

            //configure IotHub Sender: need "IotHubConfigFile", "TagStateManager", "TagToIotHubMessageConverter" in settings
            settings["TagToIotHubMessageConverter"] = tc.GetInstance <IConverter <Tag, object> >(pluginNamespace);
            IProcessor iotHubSender = tc.GetInstance <ISender>(pluginNamespace) as IProcessor;

            if (iotHubSender != null)
            {
                this.AddSender("IotHubSender", iotHubSender);
            }

            base.Initialize(settings);
        }
Exemple #10
0
        void SetRootPosition()
        {
            /*double angleOfDashboard = 35f;
             * double distanceFromDashboard = _distance + 1f;
             *
             * double yOpp = Math.Tan(angleOfDashboard) * distanceFromDashboard;
             * double zHyp = yOpp / Math.Sin(angleOfDashboard);*/

            //InternalOverlay.SetAttachment(AttachmentType.Absolute, new OpenTK.Vector3(0f, 1f, _distance), new OpenTK.Vector3(0, 180, 0));

            if (_screenIndex > 0)
            {
                return;
            }

            if (ConfigUtility.Get <string>("desktop.position", "Opposite Dashboard") == "Opposite Dashboard")
            {
                InternalOverlay.SetAttachment(AttachmentType.AbsoluteRelative, new OpenTK.Vector3(0f, 0.5f, 2f + _distance), new OpenTK.Vector3(0, 180, 0), "vrub.anchor.dashboard");
            }
            else
            {
                InternalOverlay.SetAttachment(AttachmentType.Absolute, new OpenTK.Vector3(0, 1f, _distance), new OpenTK.Vector3(0, 180, 0));
            }

            InternalOverlay.Width = _width;
            InternalOverlay.Alpha = 0.95f;
        }
Exemple #11
0
        public static IManage.IManSession AdminSession()
        {
            IManage.IManSession imSession = null;
            var currentUser = ConfigUtility.GetImAdminLoginInfo().Item1;

            if (!dictIManageDms.ContainsKey(currentUser))
            {
                IManage.ManDMS dms = new IManage.ManDMS();

                dictIManageDms.Add(currentUser, dms);

                imSession = dms.Sessions.Add(ConfigUtility.GetImSrvr().Item1);

                imSession.Login(ConfigUtility.GetImAdminLoginInfo().Item1, ConfigUtility.GetImAdminLoginInfo().Item2);

                return(imSession);
            }
            else
            {
                var dms = dictIManageDms[currentUser];
                imSession = dms.Sessions.ItemByName(ConfigUtility.GetImSrvr().Item1);

                if (imSession != null && imSession.Connected)
                {
                    return(imSession);
                }
                else
                {
                    imSession.Login(ConfigUtility.GetImAdminLoginInfo().Item1, ConfigUtility.GetImAdminLoginInfo().Item2);
                    return(imSession);
                }
            }
        }
Exemple #12
0
 public static string PutFile(string bucket, string key, Stream stream)
 {
     try
     {
         var    scope   = bucket + ":" + key;
         var    policy  = new PutPolicy(scope);
         string upToken = policy.Token();
         var    extra   = new PutExtra();
         var    client  = new IOClient();
         var    ret     = client.Put(upToken, key, stream, extra);
         if (ret.OK)
         {
             return(string.Format(ConfigUtility.GetValue("QiNiuDomain"), bucket) + ret.key);
         }
         else
         {
             return("");
         }
     }
     catch (Exception e)
     {
         log4net.LogManager.GetLogger("ImageUpload").Error(e.Message);
         return("");
     }
 }
Exemple #13
0
 public void GetFunctionSetting(XmlDocument webconfigDoc)
 {
     cbIsAutoAssess.Checked =
         ConfigUtility.GetAppSettingsNodeBoolValue(webconfigDoc, ConfigUtility.Const_KeyIsAutoAssess);
     cbIsAutoEmployeeResidenceDateRearch.Checked =
         ConfigUtility.GetAppSettingsNodeBoolValue(webconfigDoc,
                                                   ConfigUtility.Const_KeyIsAutoEmployeeResidenceDateRearch);
     cbIsAutoRemindEmployeeConfirmAttendance.Checked =
         ConfigUtility.GetAppSettingsNodeBoolValue(webconfigDoc,
                                                   ConfigUtility.Const_KeyIsAutoRemindEmployeeConfirmAttendance);
     cbIsAutoRemindVacation.Checked =
         ConfigUtility.GetAppSettingsNodeBoolValue(webconfigDoc,
                                                   ConfigUtility.Const_KeyIsAutoRemindVacation);
     cbIsAutoRemindContract.Checked =
         ConfigUtility.GetAppSettingsNodeBoolValue(webconfigDoc,
                                                   ConfigUtility.Const_KeyIsAutoRemindContract);
     cbIsAutoRemindProbationDateRearch.Checked =
         ConfigUtility.GetAppSettingsNodeBoolValue(webconfigDoc,
                                                   ConfigUtility.Const_KeyIsAutoRemindProbationDateRearch);
     txtBeforeEmployeeResidenceDateRearchDays.Text = ConfigUtility.GetAppSettingsNodeValue(webconfigDoc,
                                                                                           ConfigUtility.
                                                                                           Const_KeyBeforeEmployeeResidenceDateRearchDays);
     txtBeforeRemindVacationDays.Text = ConfigUtility.GetAppSettingsNodeValue(webconfigDoc,
                                                                              ConfigUtility.
                                                                              Const_KeyBeforeRemindVacationDays);
     txtBeforeRemindContractDays.Text = ConfigUtility.GetAppSettingsNodeValue(webconfigDoc,
                                                                              ConfigUtility.
                                                                              Const_KeyBeforeRemindContractDays);
     txtBeforeRemindProbationDateRearchDays.Text = ConfigUtility.GetAppSettingsNodeValue(webconfigDoc,
                                                                                         ConfigUtility.
                                                                                         Const_KeyBeforeProbationDateRearchDays);
 }
 public void SetSMSSetting(XmlDocument webconfigDoc)
 {
     ConfigUtility.SetAppSettingsNodeValue(webconfigDoc,
                                           ConfigUtility.Const_KeyClientListenAddress,
                                           txtClientListenAddress.Text.Trim());
     ConfigUtility.SetAppSettingsNodeValue(webconfigDoc,
                                           ConfigUtility.Const_KeySmsConfig,
                                           ABCClientSetView1.IsOpenFunction ? "true" : "false");
     ConfigUtility.SetNodeValue(webconfigDoc, _SystemServiceModelPath, "endpoint",
                                new XmlNodeAttributesModel(ConfigUtility.Const_endpointname,
                                                           ConfigUtility.Const_KeyServiceSmsName),
                                new XmlNodeAttributesModel(ConfigUtility.Const_endpointaddress,
                                                           ABCClientSetView1.ServerAddress));
     ConfigUtility.SetNodeValue(webconfigDoc, _SystemServiceModelPath, "endpoint",
                                new XmlNodeAttributesModel(ConfigUtility.Const_endpointname,
                                                           ConfigUtility.Const_KeyServiceSmsName),
                                new XmlNodeAttributesModel(ConfigUtility.Const_endpointbinding,
                                                           ABCClientSetView1.ServerBinding));
     ConfigUtility.SetNodeValue(webconfigDoc, _SystemServiceModelPath, "endpoint",
                                new XmlNodeAttributesModel(ConfigUtility.Const_endpointname,
                                                           ConfigUtility.Const_KeyServiceSmsName),
                                new XmlNodeAttributesModel(ConfigUtility.Const_endpointcontract,
                                                           ABCClientSetView1.ServerContract));
     ConfigUtility.SetNodeValue(webconfigDoc, _SystemServiceModelPath, "endpoint",
                                new XmlNodeAttributesModel(ConfigUtility.Const_endpointname,
                                                           ConfigUtility.Const_KeyServiceSmsName),
                                new XmlNodeAttributesModel(ConfigUtility.Const_endpointbindingConfiguration,
                                                           ABCClientSetView1.ServerBindingConfiguration));
 }
Exemple #15
0
        public static string GrabPic(string imgUrl, bool isLocalHost = false)
        {
            string fileExt = string.Empty;
            string newUrl  = imgUrl;

            byte[] buffer   = Core.Utilities.HttpUtility.GetData(imgUrl, null, false);
            int    extIndex = imgUrl.LastIndexOf(".");

            fileExt = imgUrl.Substring(extIndex, imgUrl.Length - extIndex);
            using (MemoryStream target = new MemoryStream(buffer))
            {
                if (isLocalHost)
                {
                    newUrl = QiniuService.PutFileStringStream(target, "WX", fileExt);
                }
                else
                {
                    byte[] data     = target.ToArray();
                    string md5      = ToMd5String(data);
                    var    path     = @"Images\temp\";
                    var    fullPath = AppDomain.CurrentDomain.BaseDirectory + path;
                    if (!Directory.Exists(fullPath))
                    {
                        Directory.CreateDirectory(fullPath);
                    }
                    System.IO.File.WriteAllBytes(fullPath + md5 + fileExt, data);
                    newUrl = ConfigUtility.GetValue("QiNiuDomain") + md5 + fileExt;
                }
            }
            return(newUrl);
        }
Exemple #16
0
        IEnumerator LoadTexture(GameMapTempFolder temp)
        {
            string path = Path.Combine(
                temp.folderPath,
                temp.chunkHeader.backgroundFileCode
                );

            bool hasTexture = File.Exists(path);

            if (!hasTexture)
            {
                yield break;
            }

            path = ConfigUtility.fileLoadPath(path);

            WWW texture = new WWW(path);

            //yield return texture;

            while (!texture.isDone)
            {
                GameLoadingDialog.getInstance.ReportProgress(0.66f + texture.progress / 3f);
                yield return(null);
            }

            if (!string.IsNullOrEmpty(texture.error))
            {
                Debug.LogError("Temp Folder texture Error : " + texture.error);
            }

            backgorundImage.mainTexture = texture.texture;
        }
Exemple #17
0
 public void SetCompanyInfo(XmlDocument webconfigDoc)
 {
     ConfigUtility.SetNodeInnerTextValue(webconfigDoc, ConfigUtility._CompanyPath,
                                         Const_ATTENDANCEISNORMALISINCLUDEOUTINTIME,
                                         txtATTENDANCEISNORMALISINCLUDEOUTINTIME.Text);
     ConfigUtility.SetNodeInnerTextValue(webconfigDoc, ConfigUtility._CompanyPath, Const_SYSTEMMAILCOMMAND,
                                         txtSYSTEMMAILCOMMAND.Text);
     ConfigUtility.SetNodeInnerTextValue(webconfigDoc, ConfigUtility._CompanyPath, Const_COMPANYFAX,
                                         txtCOMPANYFAX.Text);
     ConfigUtility.SetNodeInnerTextValue(webconfigDoc, ConfigUtility._CompanyPath, Const_COMPANYTEL,
                                         txtCOMPANYTEL.Text);
     ConfigUtility.SetNodeInnerTextValue(webconfigDoc, ConfigUtility._CompanyPath, Const_COMPANYTITLE,
                                         txtCOMPANYTITLE.Text);
     ConfigUtility.SetNodeInnerTextValue(webconfigDoc, ConfigUtility._CompanyPath, Const_DEFAULTPASSWORD,
                                         txtDEFAULTPASSWORD.Text);
     ConfigUtility.SetNodeInnerTextValue(webconfigDoc, ConfigUtility._CompanyPath, Const_LOCALHOSTADDRESS,
                                         txtLOCALHOSTADDRESS.Text);
     ConfigUtility.SetNodeInnerTextValue(webconfigDoc, ConfigUtility._CompanyPath, Const_SMTPHOST,
                                         txtSMTPHOST.Text);
     ConfigUtility.SetNodeInnerTextValue(webconfigDoc, ConfigUtility._CompanyPath, Const_SYSTEMID,
                                         txtSYSTEMID.Text);
     ConfigUtility.SetNodeInnerTextValue(webconfigDoc, ConfigUtility._CompanyPath, Const_SYSTEMMAILADDRESS,
                                         txtSYSTEMMAILADDRESS.Text);
     ConfigUtility.SetNodeInnerTextValue(webconfigDoc, ConfigUtility._CompanyPath, Const_USERNAMEMAILADDRESS,
                                         txtUSERNAMEMAILADDRESS.Text);
     ConfigUtility.SetNodeInnerTextValue(webconfigDoc, ConfigUtility._CompanyPath, Const_USERNAMEPASSWORD,
                                         txtUSERNAMEPASSWORD.Text);
     ConfigUtility.SetNodeInnerTextValue(webconfigDoc, ConfigUtility._CompanyPath, Const_HELPADDRESS,
                                         txtHELPADDRESS.Text);
     ConfigUtility.SetNodeInnerTextValue(webconfigDoc, ConfigUtility._CompanyPath, Const_MAILTOHR,
                                         txtMAILTOHR.Text);
 }
Exemple #18
0
        public static IMANADMIN.NRTSession UsrSession()
        {
            IMANADMIN.NRTSession nrtSession = null;
            var currentUser = AmUtil.GetCurrentUser;

            if (!dictNrtDms.ContainsKey(currentUser))
            {
                IMANADMIN.NRTDMS dms = new IMANADMIN.NRTDMS();

                dictNrtDms.Add(currentUser, dms);

                nrtSession = dms.Sessions.Add(ConfigUtility.GetImSrvr().Item1);

                return(GetUsrSession(nrtSession));
            }
            else
            {
                var dms = dictNrtDms[currentUser];
                nrtSession = dms.Sessions.Item(ConfigUtility.GetImSrvr().Item1);

                if (nrtSession != null && nrtSession.Connected)
                {
                    return(nrtSession);
                }

                return(GetUsrSession(nrtSession));
            }
        }
Exemple #19
0
        public IEnumerator LoadImage(string filepath)
        {
            var popup = PopupLoading.Creat();

            yield return(new WaitForEndOfFrame());

            //WWW www = new WWW ("file://" + filepath);
            WWW www = new WWW(ConfigUtility.fileLoadPath(filepath));

            yield return(www);

            Destroy(popup);
            yield return(new WaitForEndOfFrame());

            try {
                if (ConfigUtility.isSupportedTextureType(Path.GetExtension(filepath)))
                {
                    editor.gameScreen.setBackgroundImage(www.texture);
                }
                else
                {
                    editor.debugLog.LogWarning(ExceptionList.openFileError.Value);
                    yield break;
                }
            } catch {
                editor.debugLog.LogWarning(ExceptionList.openFileError.Value);
                yield break;
            }
            editor.getTrackMap.header.BackgroundFileFullName = filepath;
            editor.debugLog.Log(MessageList.openFileSuccess.Value);
        }
Exemple #20
0
        void RefreshConfigs()
        {
            configList.Groups.Clear();
            configList.Items.Clear();

/*            configList.Groups.AddRange(new ListViewGroup[] {
 *              new ListViewGroup("VRUB Settings"),
 *              new ListViewGroup("Addon Settings"),
 *              new ListViewGroup("Disabled Addons"),
 *          });*/

            //configList.Items.Add(new ListViewItem() { /*Group = configList.Groups[0],*/ Text = "Basic Settings", });

            _layouts = ConfigUtility.GetLayouts();

            foreach (KeyValuePair <string, List <ConfigLayout> > layout in _layouts)
            {
                configList.Items.Add(new ListViewItem()
                {
                    Text = layout.Value.Count > 0 && layout.Value[0].Addon != null ? "Addon: " + layout.Value[0].Addon.Name : layout.Key, // TODO: Titles for custom layouts.
                    Tag  = layout.Key,
                    /*Group = layout.Key.Enabled ? configList.Groups[1] : configList.Groups[2],*/
                    ForeColor = layout.Value.Count > 0 && layout.Value[0].Addon != null && !layout.Value[0].Addon.Enabled ? SystemColors.ScrollBar : SystemColors.WindowText,
                });
            }

            configGrid.ExpandAllGridItems();
        }
Exemple #21
0
        public static Addon Parse(string folder, string keyPrefix = "builtin")
        {
            Addon newAddon = new Addon();

            newAddon._keyPrefix = keyPrefix;
            newAddon.BasePath   = folder;
            newAddon.ProcessManifest();

            if (keyPrefix != "builtin")
            {
                newAddon.SudoAccess = false;
            }

            Logger.Info("[ADDON] Found Addon: " + newAddon.Key + " - " + newAddon.Name);

            newAddon.Interops.Add("permissions", new Permissions.PermissionInterop(newAddon));
            newAddon.SetupConfig();


            if (keyPrefix == "builtin")
            {
                newAddon._pluginsEnabled = true;
            }

            if (newAddon.Enabled)
            {
                newAddon.OnEnabled(false);
            }

            ConfigUtility.RegisterAddonConfig(newAddon);

            return(newAddon);
        }
Exemple #22
0
        private static TypeContainer GetTypeContainerFromCode()
        {
            TypeContainer tc = TypeContainer.Instance;

            //UNCOMMENT THE FOLLOWING CODE until tc.GetRegistryAsXml() to genterate XML for first time
            // and copy XML into TypeConfig.xml as it will save you time from manually configuring XML
            //////register PlugIn libraries
            ////register OPC receivers, converters
            //tc.Register<ILogger, ConsoleLogger>();
            //tc.Register<IProcessor, OpcReceiver<IMessage>>("OPCUA");
            //tc.Register<IConverter<object, Tag>, OpcTagToTagStateConverter>("OPCUA");

            ////register IotHub sender
            //tc.Register<IConverter<Tag, object>, ToIotHubMessageConverter>("IotHub");
            //tc.Register<IProcessor, IoTHubSender<Tag>>("IotHub");

            ////register additional libraries from Azure Connector; we don't have to Dictionary<string, object>ally load them
            ////  as there are not expected to be changed by the PlugIn writers
            //tc.Register<IServiceHost, TelemetryHost>();

            //string configXml = tc.GetRegistryAsXml();
            //UNCOMMENT - ENDS
            string workingDirectory = ConfigUtility.GetCurrentWorkingDirectory();

            tc.AddAssemblyProbingPath(workingDirectory + @"\..\..\..\SharedBin");
            tc.LoadFromFile("TypeConfig.xml");
            return(tc);
        }
Exemple #23
0
        // Called when Settings are deserialized (read) from file.
        public void OnSettingsDeserialized()
        {
            PluginLog.Log("ActionCameraPlugin", "OnSettingsDeserialized");
            ConfigUtility utility = new ConfigUtility(_settings.configurationName);

            cameraDirector.SetSettings(utility.Config);
        }
        public void MemoryInitializeDataRefreshCorrectly()
        {
            TraceSource source    = new TraceSource("inmemory1Source");
            var         listener1 = source.Listeners.OfType <InMemoryTraceListener>().First();

            listener1.Clear();
            source.TraceEvent(TraceEventType.Warning, 1, "A");

            // Verify values are correct before changing
            Assert.AreEqual(10, listener1.Limit);
            Assert.AreEqual(1, listener1.GetEvents().Length);

            var configPath = ConfigUtility.GetConfigDirFromTestRunDirectory(TestContext.TestRunDirectory);

            using (var file = new FileResetScope(configPath))
            {
                var doc               = XDocument.Parse(file.OriginalText);
                var configuration     = doc.Root; //.Element("configuration");
                var systemDiagnostics = configuration.Element("system.diagnostics");
                var sharedListeners   = systemDiagnostics.Element("sharedListeners");
                var listenerConfig    = sharedListeners.Elements().First(x => x.Attribute("name").Value == "inmemory1");

                listenerConfig.SetAttributeValue("initializeData", "20");

                doc.Save(configPath);
                Trace.Refresh();

                var listener2 = source.Listeners.OfType <InMemoryTraceListener>().First();
                Assert.AreEqual(20, listener2.Limit);
                Assert.AreEqual(0, listener2.GetEvents().Length);
                Assert.AreNotSame(listener1, listener2);
            }
        }
Exemple #25
0
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>UserID大于0:成功 ,小于0:各种失败</returns>
        public virtual int addPublicUser(PublicUserModel entity)
        {
            string    passWordAdorn = ConfigUtility.GetValue("PassWordAdorn");
            DbCommand cmd           = GetStoredProcCommand("P_Api_addPublicUser");

            AddOutParameter(cmd, "@UserID", DbType.Int32, 4);
            AddInParameter(cmd, "@Name", DbType.String, entity.Name);
            AddInParameter(cmd, "@Password", DbType.String, StringUtility.ToMd5String(passWordAdorn + entity.Password));
            AddInParameter(cmd, "@Portrait", DbType.String, entity.Portrait);
            AddInParameter(cmd, "@Molblie", DbType.String, entity.Molblie);
            AddInParameter(cmd, "@Tel", DbType.String, entity.Tel);
            AddInParameter(cmd, "@NickName", DbType.String, entity.NickName);
            AddInParameter(cmd, "@EnrolnName", DbType.String, entity.EnrolnName);
            AddInParameter(cmd, "@Sex", DbType.Int32, entity.Sex);
            AddInParameter(cmd, "@Address", DbType.String, entity.Address);
            AddInParameter(cmd, "@Email", DbType.String, entity.Email);
            AddInParameter(cmd, "@QQ", DbType.String, entity.QQ);
            AddInParameter(cmd, "@IP", DbType.String, entity.IP);
            AddInParameter(cmd, "@CityID", DbType.Int32, entity.CityID);
            AddInParameter(cmd, "@CompanyId", DbType.Int32, entity.CompanyId);
            AddInParameter(cmd, "@StoreId", DbType.Int32, entity.StoreId);
            AddInParameter(cmd, "@LastLoginIP", DbType.String, entity.LastLoginIP);
            AddInParameter(cmd, "@VipType", DbType.Int32, entity.VipType);
            AddInParameter(cmd, "@DistrictId", DbType.Int32, entity.DistrictId);
            AddInParameter(cmd, "@RegionId", DbType.Int32, entity.RegionId);
            AddInParameter(cmd, "@Points", DbType.Int32, 100); //初始赠送积分
            AddInParameter(cmd, "@Remarks", DbType.String, entity.Remarks);
            ExecuteNonQuery(cmd);
            int outUserId = 0;

            int.TryParse(cmd.Parameters["@UserID"].Value.ToString(), out outUserId);
            return(outUserId);
        }
Exemple #26
0
        public static IMANADMIN.NRTSession AdminSession()
        {
            IMANADMIN.NRTSession nrtSession = null;
            var currentUser = ConfigUtility.GetImAdminLoginInfo().Item1;

            if (!dictNrtDms.ContainsKey(currentUser))
            {
                IMANADMIN.NRTDMS dms = new IMANADMIN.NRTDMS();

                dictNrtDms.Add(currentUser, dms);

                nrtSession = dms.Sessions.Add(ConfigUtility.GetImSrvr().Item1);

                nrtSession.Login(ConfigUtility.GetImAdminLoginInfo().Item1, ConfigUtility.GetImAdminLoginInfo().Item2);

                return(nrtSession);
            }
            else
            {
                var dms = dictNrtDms[currentUser];
                nrtSession = dms.Sessions.Item(ConfigUtility.GetImSrvr().Item1);

                if (nrtSession != null && nrtSession.Connected)
                {
                    return(nrtSession);
                }

                nrtSession.Login(ConfigUtility.GetImAdminLoginInfo().Item1, ConfigUtility.GetImAdminLoginInfo().Item2);

                return(nrtSession);
            }
        }
Exemple #27
0
 public void SetFunctionSetting(XmlDocument webconfigDoc)
 {
     ConfigUtility.SetAppSettingsNodeValue(webconfigDoc,
                                           ConfigUtility.Const_KeyIsAutoAssess,
                                           cbIsAutoAssess.Checked ? "true" : "false");
     ConfigUtility.SetAppSettingsNodeValue(webconfigDoc,
                                           ConfigUtility.Const_KeyIsAutoEmployeeResidenceDateRearch,
                                           cbIsAutoEmployeeResidenceDateRearch.Checked ? "true" : "false");
     ConfigUtility.SetAppSettingsNodeValue(webconfigDoc,
                                           ConfigUtility.Const_KeyIsAutoRemindEmployeeConfirmAttendance,
                                           cbIsAutoRemindEmployeeConfirmAttendance.Checked ? "true" : "false");
     ConfigUtility.SetAppSettingsNodeValue(webconfigDoc,
                                           ConfigUtility.Const_KeyIsAutoRemindVacation,
                                           cbIsAutoRemindVacation.Checked ? "true" : "false");
     ConfigUtility.SetAppSettingsNodeValue(webconfigDoc,
                                           ConfigUtility.Const_KeyIsAutoRemindContract,
                                           cbIsAutoRemindContract.Checked ? "true" : "false");
     ConfigUtility.SetAppSettingsNodeValue(webconfigDoc,
                                           ConfigUtility.Const_KeyIsAutoRemindProbationDateRearch,
                                           cbIsAutoRemindProbationDateRearch.Checked ? "true" : "false");
     ConfigUtility.SetAppSettingsNodeValue(webconfigDoc,
                                           ConfigUtility.Const_KeyBeforeEmployeeResidenceDateRearchDays,
                                           txtBeforeEmployeeResidenceDateRearchDays.Text.Trim());
     ConfigUtility.SetAppSettingsNodeValue(webconfigDoc,
                                           ConfigUtility.Const_KeyBeforeRemindVacationDays,
                                           txtBeforeRemindVacationDays.Text.Trim());
     ConfigUtility.SetAppSettingsNodeValue(webconfigDoc,
                                           ConfigUtility.Const_KeyBeforeRemindContractDays,
                                           txtBeforeRemindContractDays.Text.Trim());
     ConfigUtility.SetAppSettingsNodeValue(webconfigDoc,
                                           ConfigUtility.Const_KeyBeforeProbationDateRearchDays,
                                           txtBeforeRemindProbationDateRearchDays.Text.Trim());
 }
Exemple #28
0
        public ActionResult Register(string code = "")
        {
            InvitationCode invitationCode = new InvitationCode();
            //PublicUserModel loginUser = this.GetLoginUser();
            //if (loginUser != null && loginUser.UserID > 0)
            //{
            //    return Redirect("/Home");
            //}

            List <Regions> regionList = ncBase.CurrentEntities.Regions.Where(r => r.Layer == 1).ToList();

            ViewData["RegionList"] = regionList;

            if (ConfigUtility.GetBoolValue("InvitationRegister") || !string.IsNullOrEmpty(code))
            {
                invitationCode =
                    ncBase.CurrentEntities.InvitationCode.Where(o => o.Code == code && o.IsUsed == false)
                    .FirstOrDefault();
                if (invitationCode.IsNull())
                {
                    return(RedirectToAction("InvitationRegister", "User"));
                }
            }

            return(View(invitationCode));
        }
Exemple #29
0
        public static void Register(HttpConfiguration config)
        {
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
            config.Formatters.Remove(config.Formatters.XmlFormatter);

            config.Routes.MapHttpRoute(
                name: "Api",
                routeTemplate: "{namespace}/{controller}/{action}/{id}",
                defaults: new { version = "1", id = RouteParameter.Optional }, constraints: new { version = @"^\d+$" }
                );



            config.Filters.Add(new WatchActionExecutedAttribute());
            config.Filters.Add(new ExceptionLogAttribute());
            config.Filters.Add(new ValidateRequestAttribute());
            config.IncludeErrorDetailPolicy = ConfigUtility.GetBoolValue("OnProduction")
                                                  ? IncludeErrorDetailPolicy.Never
                                                  : IncludeErrorDetailPolicy.Always;

            //  config.Services.Replace(typeof(IHttpControllerSelector), new NamespaceHttpControllerSelector(config));
        }
Exemple #30
0
        /// <summary>
        ///     Gets the base page HTML.
        /// </summary>
        /// <param name="helper">The helper.</param>
        /// <param name="gridName">Name of the grid.</param>
        /// <param name="grid">The grid.</param>
        /// <param name="pageParameters">The page parameters.</param>
        /// <returns>System.String.</returns>
        /// TODO Edit XML Comment Template for GetBasePageHtml
        public string GetBasePageHtml(
            HtmlHelper helper,
            string gridName,
            IMvcGridDefinition grid,
            object pageParameters)
        {
            var preload = "";

            if (grid.QueryOnPageLoad &&
                grid.PreloadData)
            {
                try
                {
                    preload = RenderPreloadedGridHtml(
                        helper,
                        grid,
                        gridName,
                        pageParameters);
                }
                catch (Exception ex)
                {
                    var showDetails = ConfigUtility
                                      .GetShowErrorDetailsSetting();

                    if (showDetails)
                    {
                        var detail = "<div class='alert alert-danger'>";

                        detail += HttpUtility.HtmlEncode(ex.ToString())
                                  .Replace("\r\n", "<br />");

                        detail += "</div>";
                        preload = detail;
                    }
                    else
                    {
                        preload = grid.ErrorMessageHtml;
                    }
                }
            }

            var baseGridHtml =
                MvcGridHtmlGenerator.GenerateBasePageHtml(
                    gridName,
                    grid,
                    pageParameters);

            baseGridHtml = baseGridHtml.Replace("%%PRELOAD%%", preload);

            var containerRenderingModel = new ContainerRenderingModel
            {
                InnerHtmlBlock = baseGridHtml
            };

            var html =
                RenderContainerHtml(helper, grid, containerRenderingModel);

            return(html);
        }