示例#1
0
        public void TestUserControlImage()
        {
            Console.WriteLine("TestUserControlImage");

            ConfigFile         configFile         = new ConfigFile();
            SetupConfiguration setupConfiguration = new SetupConfiguration();

            configFile.Children.Add(setupConfiguration);
            ControlImage image = new ControlImage();

            image.ResourceId = "RES_BANNER_DOESNTEXIST";
            setupConfiguration.Children.Add(image);
            ComponentCmd cmd = new ComponentCmd();

            cmd.command = "cmd.exe /C exit /b 0";
            setupConfiguration.Children.Add(cmd);
            string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");

            Console.WriteLine("Writing '{0}'", configFilename);
            configFile.SaveAs(configFilename);
            Assert.AreEqual(-1, dotNetInstallerExeUtils.Run(configFilename));
            image.ResourceId = "RES_BANNER";
            configFile.SaveAs(configFilename);
            Assert.AreEqual(0, dotNetInstallerExeUtils.Run(configFilename));
            File.Delete(configFilename);
        }
示例#2
0
        // with delegate Ajax on click
        public static MenuItem ClientInsertMenuItem(Terrasoft.UI.WebControls.PageSchemaUserControl page, string menuOwnerClientID, int index,
                                                    string name, string caption, ControlImage controlImage, string clickCode, Action <string> onClickHandler)
        {
            var script = string.Empty;

            script += string.Format("if ({0}.getMenu().items.get({1}) &&  {0}.menu.items.get({1}).id == '{2}' ) {{\n", menuOwnerClientID, index, name);
            script += string.Format(" {0}.menu.removeByIndex({1}); }}\n", menuOwnerClientID, index);
            var menuItem = GetMenuItem(page, menuOwnerClientID, name, caption, controlImage, clickCode);

            menuItem.AjaxEvents.Click.Event += delegate(object sender, Terrasoft.UI.WebControls.Controls.AjaxEventArgs e) {
                var clickedMenuItemCode = e.ExtraParameters[0].Value;
                onClickHandler(clickedMenuItemCode);
            };

            /*menuItem.AjaxEvents.MenuItemClick.Event += delegate(object sender, Terrasoft.UI.WebControls.Controls.AjaxEventArgs e) {
             *                                                                              var clickedMenuItemCode = e.ExtraParameters[2].Value;
             *                                                                              onClickHandler(clickedMenuItemCode);
             *                                                                              };
             */
            script += string.Format("window.{0} = {1};\n", menuItem.ClientID, menuItem.GenerateControlScript(true, null));
            script += string.Format("{0}.getMenu().insert({2}, window.{1});\n", menuOwnerClientID, menuItem.ClientID, index);
            var scriptManager = ScriptManager.GetCurrent(page.AspPage);

            scriptManager.AddScript(script);
            return(menuItem);
        }
示例#3
0
 private void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
 }
        public async Task <string> SendControlRapport(List <ControlAnswer> imageSendList, ControlReport report)
        {
            try
            {
                List <ControlAnswer> sendList = new List <ControlAnswer>();
                foreach (var controlAnswerImage in imageSendList)
                {
                    ControlAnswer sendAnswer = new ControlAnswer();
                    sendAnswer.controlQuestionId = controlAnswerImage.controlQuestionId;
                    sendAnswer.startTime         = controlAnswerImage.startTime;
                    sendAnswer.endTime           = controlAnswerImage.endTime;
                    sendAnswer.testOk            = controlAnswerImage.testOk;
                    sendAnswer.comment           = controlAnswerImage.comment;
                    if (controlAnswerImage.images != null)
                    {
                        sendAnswer.images = new List <ControlImage>();
                        foreach (ControlImage imgPath in controlAnswerImage.images)
                        {
                            var storageFile = await ApplicationData.Current.LocalFolder.GetFileAsync(imgPath.fileName);

                            var buffer = await Windows.Storage.FileIO.ReadBufferAsync(storageFile);

                            var bufferArray = buffer.ToArray();
                            _client = new HttpClient();
                            MultipartFormDataContent form = new MultipartFormDataContent();
                            form.Add(new ByteArrayContent(bufferArray), "image", imgPath.fileName);
                            HttpResponseMessage response = await _client.PostAsync(_apiControlImage, form);

                            response.EnsureSuccessStatusCode();
                            _client.Dispose();
                            var          responsemessage = response.Content.ReadAsStringAsync().Result;
                            ControlImage img             = JsonConvert.DeserializeObject <ControlImageWrapper>(responsemessage).data;
                            sendAnswer.images.Add(img);
                        }
                    }
                    sendList.Add(sendAnswer);
                }
                report.controlAnswers = sendList;
                var sendReport = JsonConvert.SerializeObject(report, Formatting.None, new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                });
                using (_client = new HttpClient())
                {
                    HttpResponseMessage response = await _client.PostAsync(_apiControlReport, new StringContent(sendReport, Encoding.UTF8, "application/json"));

                    response.EnsureSuccessStatusCode();
                }
                return("Ok");
            }
            catch (Exception)
            {
                return("Nok");
            }
        }
示例#5
0
        // with delegate Ajax on click
        public static MenuItem ClientAppendMenuItem(Terrasoft.UI.WebControls.PageSchemaUserControl page, string menuOwnerClientID,
                                                    string name, string caption, ControlImage controlImage, string clickCode, Action <string> onClickHandler)
        {
            var script   = string.Empty;
            var menuItem = GetMenuItem(page, menuOwnerClientID, name, caption, controlImage, clickCode);

            menuItem.AjaxEvents.Click.Event += delegate(object sender, Terrasoft.UI.WebControls.Controls.AjaxEventArgs e) {
                var clickedMenuItemCode = e.ExtraParameters[0].Value;
                onClickHandler(clickedMenuItemCode);
            };
            script += string.Format("window.{0} = {1};\n", menuItem.ClientID, menuItem.GenerateControlScript(true, null));
            script += string.Format("{0}.getMenu().addItem(window.{1});\n", menuOwnerClientID, menuItem.ClientID);
            var scriptManager = ScriptManager.GetCurrent(page.AspPage);

            scriptManager.AddScript(script);
            return(menuItem);
        }
示例#6
0
        // with specified Signal on click
        public static MenuItem ClientInsertMenuItem(Terrasoft.UI.WebControls.PageSchemaUserControl page, string menuOwnerClientID, int index,
                                                    string name, string caption, ControlImage controlImage, string clickCode, string signalName)
        {
            var script = string.Empty;

            script += string.Format("if ({0}.getMenu().items.get({1}) &&  {0}.menu.items.get({1}).id == '{2}' ) {{\n", menuOwnerClientID, index, name);
            script += string.Format(" {0}.menu.removeByIndex({1}); }}\n", menuOwnerClientID, index);
            var menuItem = GetMenuItem(page, menuOwnerClientID, name, caption, controlImage, clickCode);

            if (!string.IsNullOrEmpty(signalName))
            {
                menuItem.AjaxEvents.Click.SignalName = signalName;
                menuItem.AjaxEvents.Click.AjaxEventTargetControlID = menuOwnerClientID;
            }
            script += string.Format("window.{0} = {1};\n", menuItem.ClientID, menuItem.GenerateControlScript(true, null));
            script += string.Format("{0}.getMenu().insert({2}, window.{1});\n", menuOwnerClientID, menuItem.ClientID, index);
            var scriptManager = ScriptManager.GetCurrent(page.AspPage);

            scriptManager.AddScript(script);
            return(menuItem);
        }
示例#7
0
        public static void AppendMenuItem <T>(T ownerComponent, string code, string caption, ControlImage image)
            where T : Button
        {
            var menuItem = new Terrasoft.UI.WebControls.Controls.MenuItem();

            menuItem.UId     = Guid.NewGuid();
            menuItem.Name    = ownerComponent + "_" + code;
            menuItem.Caption = caption;
            menuItem.Tag     = code;
            menuItem.Image   = image;
            ownerComponent.Menu.Add(menuItem);
            if (Terrasoft.UI.WebControls.Ext.IsAjaxRequest)
            {
                ownerComponent.Menu.AddCaptionItem(menuItem);
            }
        }
示例#8
0
        private static Terrasoft.UI.WebControls.Controls.MenuItem GetMenuItem(Terrasoft.UI.WebControls.PageSchemaUserControl page, string menuOwnerClientID,
                                                                              string name, string caption, ControlImage controlImage, string clickCode)
        {
            var menuItem = new Terrasoft.UI.WebControls.Controls.MenuItem();

            menuItem.CreatedByAjax   = true;
            menuItem.EnableViewState = false;
            menuItem.Name            = name;
            menuItem.UId             = Guid.NewGuid();
            menuItem.Tag             = clickCode;
            menuItem.Caption         = caption;
            menuItem.Image           = controlImage;

            return(menuItem);
        }
示例#9
0
        /// <summary>
        /// ######### ########### ## ###### "##### # ######" # ############ ###### ####### ###### ## ###########
        /// # ######## HtmlEdit ## #######
        /// </summary>
        /// <param name="userConnection">UserConnection ######## ############</param>
        /// <param name="htmlEdit">######## HtmlEdit</param>
        /// <param name="entitySchema">##### #######, # ####### ######### ###########</param>
        /// <param name="entityId">UId #######, # ####### ######### ###########</param>
        public static void SaveAndInsertImage(UserConnection userConnection, HtmlEdit htmlEdit, EntitySchema entitySchema, Guid entityId)
        {
            // ######### ####### #####
            if (Page.Request.Files.Count == 0)
            {
                return;
            }

            // ######## ##### ###### "##### # ######", #### ##### ##### ### - ###### ## ######
            EntitySchemaManager esm       = userConnection.EntitySchemaManager;
            string       fileSchemaName   = entitySchema.Name + "File";
            EntitySchema fileEntitySchema = esm.FindInstanceByName(fileSchemaName);

            if (fileEntitySchema == null)
            {
                return;
            }

            string         fileFieldName = htmlEdit.ClientID + "_loadedImage-file";
            HttpPostedFile file          = Page.Request.Files[fileFieldName];
            string         fileName      = file.FileName;

            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }
            // ######## ###### #### ### ###### #####
            Stream fileStream = file.InputStream;

            fileStream.Position = 0;
            long fileSize = fileStream.Length;
            var  fileData = new byte[fileStream.Length];

            fileStream.Read(fileData, 0, fileData.Length);

            var img = Image.FromStream(fileStream);

            if (GraphicUtilities.GetImageFormat(img.RawFormat) == null)
            {
                var warning       = GetLocalizableStringValue(userConnection, "Warning");
                var fileTypeError = GetLocalizableStringValue(userConnection, "FileTypeError");

                const string messageCallback = @" function() {{}} ";

                string showMessageScript = ClientScriptUtilities.GetMessageScript(warning, fileTypeError,
                                                                                  MessageBoxButtons.Ok, MessageBoxIcon.Information, messageCallback);
                ScriptManager.AddScript(showMessageScript);
                return;
            }

            // crea Entity ### ###### ##### # ######### ##
            var fileUId        = Guid.NewGuid();
            var fileRepository = ClassFactory.Get <FileRepository>(
                new ConstructorArgument("userConnection", userConnection));
            var fileEntityInfo = new FileEntityUploadInfo(fileSchemaName, fileUId, fileName);

            fileEntityInfo.ParentColumnName  = entitySchema.Name;
            fileEntityInfo.ParentColumnValue = entityId;
            fileEntityInfo.TotalFileLength   = fileData.Length;
            fileEntityInfo.Content           = new MemoryStream(fileData);
            fileRepository.UploadFile(fileEntityInfo);

            // ####### ###### ControlImage # ############## ###
            var controlImage = new ControlImage {
                // ###### ##### ###########. # ###### ###### ## Entity
                Source = ControlImageSource.EntityColumn,
                // ## ##### EntitySchema-# ##### ######## Entity
                SchemaUId = fileEntitySchema.UId,
                // ######### ####### (ID ######)
                EntityPrimaryColumnValue = fileUId,
                // ####### ## ####### ##### ######## ######. #### ###### #### UsePrimaryImageColumn, ######### ## ###########
                EntitySchemaColumnUId = fileEntitySchema.Columns.GetByName("Data").UId,
                UsePrimaryImageColumn = false
            };

            // ### ##### ######## ########## ###### ControlImage ###### ######## ##########.
            // ######### ###### ### ##### ##### ########### # ######### #######.
            // ## ###### ###### ## ###### ############## ############# ###### # ######## ### ## ######
            string controlImageValue = Json.Serialize(controlImage, new ControlImageJsonConverter());

            ScriptManager.AddScript(string.Format("{0}.insertImage({1})", htmlEdit.ClientID, controlImageValue));
        }