/* ======================================================================================== */
        #endregion

        #region [ PRIVATE METHODS ]
        /* ======================================================================================== */
        /// <summary>
        /// Обновляет визуальное состояние узла.
        /// </summary>
        private void Refresh()
        {
            FormsExtensions.InvokeControl <TreeView>(this.TreeView, tn =>
            {
                this.Text = this.Device.Name + ": (" + this.Device.Address.ToString() + "/" + this.Device.ProcessorSlot.ToString() + ")";
                switch (this.Task.ServerState)
                {
                case ServerState.Off:
                    this.ImageIndex = 0;
                    break;

                case ServerState.TcpConnection:
                case ServerState.Register:
                case ServerState.ForwardOpen:
                    this.ImageIndex = 1;
                    break;

                case ServerState.Init:
                case ServerState.Run:
                    this.ImageIndex = 2;
                    break;

                case ServerState.Error:
                    this.ImageIndex = 3;
                    break;
                }

                this.SelectedImageIndex = this.ImageIndex;
            });
        }
Example #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Recorder_Error(object sender, EventArgs e)
 {
     FormsExtensions.InvokeControl <Form>(this, act =>
     {
         MessageBox.Show("Error of recording tag data.", "Recorder", MessageBoxButtons.OK, MessageBoxIcon.Error);
     });
 }
Example #3
0
#pragma warning restore 649

        protected virtual int?GetCurrentStepIndex(CustomFormContainerBlock currentBlock, Guid expectedFormGuid)
        {
            if (currentBlock.Form.FormGuid == expectedFormGuid)
            {
                int result;
                if (int.TryParse(this.GetParamValue("__FormCurrentStepIndex"), out result))
                {
                    return(result);
                }
            }
            if (currentBlock.Form.IsAllStepsAreNotLinked())
            {
                return(0);
            }
            var currentPageLink = FormsExtensions.GetCurrentPageLink();
            var num2            = 0;

            foreach (var step in currentBlock.Form.Steps)
            {
                if (currentPageLink.CompareToIgnoreWorkID(step.AttachedContentLink))
                {
                    return(num2);
                }
                num2++;
            }
            return(null);
        }
Example #4
0
        public IEnumerable <Tuple <string, string> > GetExtraResources()
        {
            var currentPageLanguage = FormsExtensions.GetCurrentPageLanguage();
            var publicVirtualPath   = ModuleHelper.GetPublicVirtualPath(Constants.ModuleName);

            return(new List <Tuple <string, string> >()
            {
                new Tuple <string, string>("script", publicVirtualPath + "/ClientResources/ViewMode/RecaptchaElementBlock.js"),
                new Tuple <string, string>("script", string.Format("https://www.google.com/recaptcha/api.js?onload=initRecaptchaElements&render=explicit&hl={0}", currentPageLanguage))
            });
        }
Example #5
0
        /// <summary>
        /// Вызывает установку состояний головного окна управления в соответствии с текущим выделенным объектом.
        /// </summary>
        private void RefreshStateOfHeadControl()
        {
            bool removeButtonVisible = this.SelectedEthernetDeviceNode != null &&
                                       this.SelectedEthernetDeviceNode.Task.ProcessState == TaskProcessState.Stop &&
                                       this.SelectedEthernetDeviceNode.Task.ServerState == ServerState.Off;

            string connectButtonText = (this.SelectedEthernetDeviceNode == null ||
                                        this.SelectedEthernetDeviceNode.Task.ProcessState == TaskProcessState.Stop) ? "Online" : "Offline";

            FormsExtensions.InvokeControl <ToolStrip>(this.toolStrip, b =>
            {
                this.toolStripButton_Remove.Enabled = removeButtonVisible;
            });
        }
Example #6
0
        /* ======================================================================================== */
        #endregion

        #region [ PRIVATE METHODS ]
        /* ======================================================================================== */
        /// <summary>
        /// Вызывает установку состояний окна редактирования свойств в соответствии с текущим выделенным объектом.
        /// </summary>
        private void RefreshStateOfPropertyControl()
        {
            string stateText = "";
            Color  backColor = this.BackColor;

            if (this.SelectedEthernetDeviceNode != null)
            {
                switch (this.SelectedEthernetDeviceNode.Task.ServerState)
                {
                case ServerState.Off:
                {
                    stateText = "offline";
                    backColor = Color.LightGray;
                }
                break;

                case ServerState.Init:
                case ServerState.Run:
                {
                    stateText = "online";
                    backColor = Color.Chartreuse;
                }
                break;

                case ServerState.Error:
                {
                    stateText = "error";
                    backColor = Color.Tomato;
                }
                break;

                default:
                {
                    stateText = "connection";
                    backColor = Color.Aqua;
                }
                break;
                }
            }

            FormsExtensions.InvokeControl <TextBox>(this.textBoxStatus, t => t.Text      = stateText);
            FormsExtensions.InvokeControl <TextBox>(this.textBoxStatus, t => t.BackColor = backColor);

            bool value = this.SelectedEthernetDeviceNode != null && this.SelectedEthernetDeviceNode.Task.ProcessState == TaskProcessState.Stop;

            FormsExtensions.InvokeControl <TextBox>(this.textBoxDeviceName, t => t.Enabled             = value);
            FormsExtensions.InvokeControl <TextBox>(this.textBoxDeviceIpAddress, t => t.Enabled        = value);
            FormsExtensions.InvokeControl <NumericUpDown>(this.numericUpDownSlotNumber, n => n.Enabled = value);
            FormsExtensions.InvokeControl <NumericUpDown>(this.numericUpDownSlotNumber, n => n.Visible = this.SelectedEthernetDeviceNode != null);
        }
Example #7
0
        /* ======================================================================================== */
        #endregion

        #region [ EVENT SUBSCRIPTIONS - CLX CONTROL ]
        /* ======================================================================================== */
        /// <summary>
        /// Подписка на событие : TreeNode_EthernetDevice : Одно из свойств устройства было изменено.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void treeNode_EthernetDevice_DevicePropertyWasChanged(object sender, DeviceEventArgs e)
        {
            // Вызываем перерисовывание списка серверов.
            FormsExtensions.InvokeControl <TreeView>(this.treeView, t => t.Refresh());

            // Устанвливаем блокировки окна редактирования свойств.
            if (this.SelectedEthernetDeviceNode == sender)
            {
                RefreshStateOfPropertyControl();
            }

            // Вызываем событие.
            Event_DevicePropertyWasChanged(e.Device);
        }
 public IEnumerable <Tuple <string, string> > GetExtraResources()
 {
     if (!string.IsNullOrWhiteSpace(Settings.Instance.GoogleMapsApiV3Url))
     {
         var publicVirtualPath   = ModuleHelper.GetPublicVirtualPath(Constants.ModuleName);
         var currentPageLanguage = FormsExtensions.GetCurrentPageLanguage();
         return(new List <Tuple <string, string> >()
         {
             new Tuple <string, string>("script", string.Format(Settings.Instance.GoogleMapsApiV3Url, currentPageLanguage)),
             new Tuple <string, string>("script", publicVirtualPath + "/ClientResources/ViewMode/AddressesElementBlock.js")
         });
     }
     return(new List <Tuple <string, string> >());
 }
Example #9
0
        /// <summary>
        /// Determines whether current user already submitted the form or not.
        /// </summary>
        public override bool IsMatch(IPrincipal principal, HttpContextBase httpContext)
        {
            var formGuid         = Guid.Parse(Model.SelectedForm);
            var hasAlreadyPosted = FormsExtensions.HasAlreadyPosted(formGuid, httpContext);

            if (Model.SubmissionStatus == SubmissionStatus.HasSubmitted)
            {
                return(hasAlreadyPosted);
            }
            else
            {
                return(!hasAlreadyPosted);
            }
        }
Example #10
0
        private void InitJs(IRequiredClientResourceList instance)
        {
            List <string> scripts;
            List <string> css;
            var           scriptContent = "var epi = epi||{}; epi.EPiServer = epi.EPiServer||{}; epi.EPiServer.Forms = epi.EPiServer.Forms||{};\r\nepi.EPiServer.Forms.InjectFormOwnJQuery = "
                                          + EPiServerFormsSection.Instance.InjectFormOwnJQuery.ToString().ToLowerInvariant()
                                          +
                                          ";epi.EPiServer.Forms.OriginalJQuery = typeof jQuery !== 'undefined' ? jQuery : undefined;";

            instance.RequireScriptInline(scriptContent, "EPiServerForms_saveOriginalJQuery.js", new List <string>())
            .AtHeader();
            if (EPiServerFormsSection.Instance.InjectFormOwnJQuery)
            {
                var list2 = new List <string> {
                    "EPiServerForms_saveOriginalJQuery.js"
                };
                instance.RequireScript(
                    ModuleHelper.GetWebResourceUrl(typeof(FormContainerBlockController),
                                                   "EPiServer.Forms.ClientResources.ViewMode.jquery-1.7.2.min.js"),
                    "Forms.jquery.js", list2).AtHeader();
            }
            var webResourceContent = ModuleHelper.GetWebResourceContent(typeof(FormContainerBlockController),
                                                                        "EPiServer.Forms.ClientResources.ViewMode.EPiServerForms_prerequisite.js");

            FormsExtensions.GetFormExternalResources(out scripts, out css);
            webResourceContent = webResourceContent
                                 .Replace("___CurrentPageLink___", FormsExtensions.GetCurrentPageLink().ToString())
                                 .Replace("___CurrentPageLanguage___", FormsExtensions.GetCurrentPageLanguage())
                                 .Replace("___ExternalScriptSources___", scripts.ToJson())
                                 .Replace("___ExternalCssSources___", css.ToJson())
                                 .Replace("___UploadExtensionBlackList___", FormsExtensions.GetUploadExtensionBlackList())
                                 .Replace("___Messages___", FormsExtensions.GetCommonMessages())
                                 .Replace("___LocalizedResources___", FormsExtensions.GetLocalizedResources().ToJson());
            var dependencies = new List <string> {
                "Forms.jquery.js"
            };

            instance.RequireScriptInline(webResourceContent, "EPiServerForms_prerequisite.js", dependencies).AtHeader();
            var list6 = new List <string>
            {
                "Forms.jquery.js",
                "EPiServerForms_prerequisite.js"
            };

            instance.RequireScript(
                ModuleHelper.GetWebResourceUrl(typeof(FormContainerBlockController),
                                               "EPiServer.Forms.ClientResources.ViewMode.EPiServerForms.js"),
                "EPiServerForms.js", list6).AtFooter();
        }
Example #11
0
        /// <summary>
        /// Подписка на событие : TreeNode_EthernetDevice : Изменилось состояние задачи устройства.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void treeNode_EthernetDevice_TaskStateWasChanged(object sender, TaskEventArgs e)
        {
            // Вызываем перерисовывание списка серверов.
            FormsExtensions.InvokeControl <TreeView>(this.treeView, t => t.Refresh());

            // Устанвливаем статус сервера в окне редактирования свойств.
            if (this.SelectedEthernetDeviceNode == sender)
            {
                RefreshStateOfPropertyControl();
                RefreshStateOfHeadControl();
            }

            // Вызываем событие.
            Event_TaskStateWasChanged(e.Task);
        }
Example #12
0
        /// <summary>
        ///     check codeplex's rss feed to see if we have a new release available.
        /// </summary>
        private static void CheckForNewRelease(CommandLineArgs commandLineArgs, bool forceCheck = false)
        {
            if (forceCheck == false)
            {
                if (!Settings.CheckForNewRelease)
                {
                    Log.Debug("The user has choosen to deny Terminals the update check.");
                    return;
                }
            }

            Boolean checkForUpdate = true;
            string  releaseFile    = Path.Combine(AssemblyInfo.DirectoryConfigFiles, "LastUpdateCheck.txt");

            if (File.Exists(releaseFile))
            {
                string text = null;
                using (FileStream fs = new FileStream(releaseFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite & FileShare.Delete))
                {
                    using (StreamReader stream = new StreamReader(fs))
                    {
                        text = stream.ReadToEnd().Trim();;
                    }
                }

                if (text != String.Empty)
                {
                    DateTime lastUpdate = DateTime.MinValue;
                    if (DateTime.TryParse(text, out lastUpdate))
                    {
                        //don't run the update if the file is today or later .. if we have checked today or not
                        if (lastUpdate.Date >= DateTime.Now.Date)
                        {
                            Log.Debug("No need to check for a new Terminals release. The release has already been checked recently.");
                            checkForUpdate = false;
                        }
                    }
                }
            }

            if (checkForUpdate)
            {
                Log.Debug("Start to check for a new Terminals release.");

                try
                {
                    Log.Debug("Connecting to the internet to github.com to check if a new Terminals version is available.");

                    XmlReader responseReader = XmlReader.Create(Configuration.Url.GitHubReleasesFeed);

                    Log.Debug("Loading syndication feed.");

                    SyndicationFeed feed = SyndicationFeed.Load(responseReader);

                    // Only the first element would be enough normally - but to be sure
                    // check all of the releases
                    foreach (SyndicationItem item in feed.Items)
                    {
                        // Don't check this release - it's deprecated
                        if (item.Title.Text.ToUpperInvariant().Contains("DEPRECATED"))
                        {
                            continue;
                        }

                        // Don't check this release - it's broken
                        if (item.Title.Text.ToUpperInvariant().Contains("BROKEN"))
                        {
                            continue;
                        }

                        string         title    = item.Title.Text;
                        string         version  = title.Replace("Terminals", "").Trim();
                        DateTimeOffset feedDate = item.LastUpdatedTime;

                        Log.Debug("Release '" + title + "' has been discovered.");

                        try
                        {
                            feedDate = Convert.ToDateTime(Web.HTTPAsString(string.Format(Configuration.Url.GitHubLatestRelease_Binary, version).Replace("Terminals.zip", "TerminalsBuildDate")).Replace("?", ""));
                            Log.Info("Received release date \"" + feedDate.ToString() + "\" from the TerminalsBuildDate file stored on GitHub in " + title);
                        }
                        catch (Exception ex)
                        {
                            Log.Debug("Unable to get the release date from the TerminalsBuildDate file stored on GitHub in " + title + ". Using the syndication feed date.", ex);
                        }

                        //check the date the item was build (stored in TerminalsBuildDate), if not available check when it has been published (date in syndication feed).
                        // If the build date is old than the feed date, then it's probably a new build!
                        if (new Version(version) >= AssemblyInfo.Version && feedDate > AssemblyInfo.BuildDate)
                        {
                            dynamic content = item.Content;

                            // Skip prereleases if we aren't already on a prerelease of the same version
                            if (AssemblyInfo.Version < new Version(version) && content.Text.ToLowerInvariant().Contains("this is just a preview"))
                            {
                                continue;
                            }

                            Log.Debug("Release '" + title + "'(" + feedDate.ToString() + ") is newer than the currently installed Terminals version '" + AssemblyInfo.Version + "'(" + AssemblyInfo.BuildDate.ToString() + ").");

                            FormsExtensions.InvokeIfNecessary(Invoker, () => { MainForm.ReleaseAvailable = true; MainForm.ReleaseDescription = title; });

                            Settings.UpdateSource = string.Format(Configuration.Url.GitHubLatestRelease_Binary, version);
                            commandLineArgs.AutomaticallyUpdate = true;
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Warn("Unable to check for a new Terminals version on " + Configuration.Url.GitHubRepositry, ex);
                }

                File.WriteAllText(releaseFile, DateTime.Now.ToString());
            }
        }