예제 #1
0
 public static string SendProperty(ControlPropertyInfo propertyInfo)
 {
     try
     {
         RestClient client = new RestClient("http://192.168.20.3:8080/article/setWidget");
         client.Timeout = 5000;
         RestRequest request = new RestRequest(Method.POST);
         request.AddHeader("Accept", "*/*");
         long fileSize = 0;
         if (propertyInfo != null && propertyInfo.files != null && propertyInfo.files.Length > 0)
         {
             for (int i = 0; i < propertyInfo.files.Length; i++)
             {
                 FileInfo fileinfo = new FileInfo(propertyInfo.files[i]);
                 fileSize += fileinfo.Length;
                 request.AddFile("files", propertyInfo.files[i]);
             }
         }
         propertyInfo.filesize = fileSize;
         JObject jobj = JObject.FromObject(propertyInfo);
         SortedDictionary <string, object> target = KeySort(jobj);
         target.Remove("sign");
         string json = Newtonsoft.Json.JsonConvert.SerializeObject(target);
         string sign = DES3.Encrypt(json, DES3.Build3DesKey("ReformerDisplay2021" + propertyInfo.id));
         propertyInfo.sign = sign;
         string data = Newtonsoft.Json.JsonConvert.SerializeObject(propertyInfo);
         request.AddParameter("data", data); request.AlwaysMultipartFormData = true;
         IRestResponse response = client.Execute(request);
         return(response.Content);
     }
     catch (Exception ex)
     {
         return(string.Empty);
     }
 }
예제 #2
0
        public static List <ControlPropertyInfo> GetPropertyFromPanel(Panel panel)
        {
            List <ControlPropertyInfo> propertyList = new List <ControlPropertyInfo>();

            foreach (Control control in panel.Controls)
            {
                ControlPropertyInfo propertyInfo = new ControlPropertyInfo();
                propertyInfo.id       = control.Name;
                propertyInfo.style    = 0;
                propertyInfo.color    = ConvertColorToRGB(control.ForeColor);
                propertyInfo.bg_color = ConvertColorToRGB(control.BackColor);
                propertyInfo.lines    = 1;
                propertyInfo.text     = control.Text;
                TagInfo tagInfo = control.Tag as TagInfo;
                if (tagInfo.Type == "image")
                {
                    propertyInfo.files    = new string[1];
                    propertyInfo.files[0] = tagInfo.Info;
                }
                propertyList.Add(propertyInfo);
            }
            return(propertyList);
        }