示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InsertListOnlineRequest"/> class.
 /// </summary>
 /// <param name="document">The document.</param>
 /// <param name="listInsert">List object.</param>
 /// <param name="loadEncoding">Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.</param>
 /// <param name="password">Password for opening an encrypted document.</param>
 /// <param name="destFileName">Result path of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document.</param>
 /// <param name="revisionAuthor">Initials of the author to use for revisions.If you set this parameter and then make some changes to the document programmatically, save the document and later open the document in MS Word you will see these changes as revisions.</param>
 /// <param name="revisionDateTime">The date and time to use for revisions.</param>
 public InsertListOnlineRequest(System.IO.Stream document, ListInsert listInsert, string loadEncoding = null, string password = null, string destFileName = null, string revisionAuthor = null, string revisionDateTime = null)
 {
     this.Document         = document;
     this.ListInsert       = listInsert;
     this.LoadEncoding     = loadEncoding;
     this.Password         = password;
     this.DestFileName     = destFileName;
     this.RevisionAuthor   = revisionAuthor;
     this.RevisionDateTime = revisionDateTime;
 }
        protected virtual void OnDebugServiceDisconnected(object sender, SledDebugServiceEventArgs e)
        {
            // Clear GUI
            Editor.View = null;

            CleanupCollection();

            LookingUp = false;
            ListInsert.Clear();
            ListNameInsert.Clear();
            ListNameInsertDict.Clear();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="InsertListRequest"/> class.
 /// </summary>
 /// <param name="name">The filename of the input document.</param>
 /// <param name="listInsert">List object.</param>
 /// <param name="folder">Original document folder.</param>
 /// <param name="storage">Original document storage.</param>
 /// <param name="loadEncoding">Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.</param>
 /// <param name="password">Password for opening an encrypted document.</param>
 /// <param name="destFileName">Result path of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document.</param>
 /// <param name="revisionAuthor">Initials of the author to use for revisions.If you set this parameter and then make some changes to the document programmatically, save the document and later open the document in MS Word you will see these changes as revisions.</param>
 /// <param name="revisionDateTime">The date and time to use for revisions.</param>
 public InsertListRequest(string name, ListInsert listInsert, string folder = null, string storage = null, string loadEncoding = null, string password = null, string destFileName = null, string revisionAuthor = null, string revisionDateTime = null)
 {
     this.Name             = name;
     this.ListInsert       = listInsert;
     this.Folder           = folder;
     this.Storage          = storage;
     this.LoadEncoding     = loadEncoding;
     this.Password         = password;
     this.DestFileName     = destFileName;
     this.RevisionAuthor   = revisionAuthor;
     this.RevisionDateTime = revisionDateTime;
 }
        protected virtual void OnDebugServiceLookupEnd()
        {
            if (ListInsert.Count > 0)
            {
                ListInsert.RemoveAt(0);
            }

            LookingUp = false;

            foreach (var collection in Collection)
            {
                collection.ValidationEnded();
            }
        }
        public async Task <IActionResult> post([FromBody] ListInsert list)
        {
            if (list == null)
            {
                return(TempRes.result(400, Request.GetDisplayUrl(), list, "Data List Tidak Boleh Kosong"));
            }

            // MODELSTATE BASED VALIDATION
            ModelState.Clear();
            TryValidateModel(list);
            if (!ModelState.IsValid)
            {
                return(TempRes.result(400, Request.GetDisplayUrl(), list, ModelState.Values.SelectMany(ms => ms.Errors).FirstOrDefault().ErrorMessage));
            }

            var newlist = await _listQ.insert(list);

            return(TempRes.result(200, Request.GetDisplayUrl(), newlist));
        }
        protected virtual void TreeListViewAdapterItemLazyLoad(object sender, TreeListViewAdapter.ItemLazyLoadEventArgs e)
        {
            if (!DebugService.IsConnected || DebugService.IsDebugging)
            {
                return;
            }

            // Get object as a Lua variable
            var luaVar = e.Item.As <TType>();

            if (luaVar == null)
            {
                return;
            }

            // Item already being looked up
            if (ListInsert.Contains(luaVar))
            {
                return;
            }

            if (luaVar.What == SledLuaVarBaseType.InvalidVarWhat)
            {
                return;
            }

            // Get lookup string
            var lookUp = SledLuaVarLookUpType.FromLuaVar(luaVar, SledLuaVarLookUpContextType.Normal);

            // Convert string to SCMP message
            var scmp = new Scmp.LuaVarLookUp(LuaLanguagePlugin.LanguageId, lookUp);

            //SledOutDevice.OutLine(SledMessageType.Error, "[Variable Lookup] {0}", lookUp.ToString());

            luaVar.Expanded = true;

            // Keep track of item so that children can be added properly
            ListInsert.Add(luaVar);

            // Send lookup message
            DebugService.SendScmp(scmp);
        }
        protected virtual void OnDebugServiceUpdateBegin(object sender, SledDebugServiceBreakpointEventArgs e)
        {
            if (Collection.Count > 0)
            {
                Collection[0].ValidationBeginning();
            }

            // Save while items still in collection & on GUI
            if (Collection.Count > 0)
            {
                Collection[0].SaveExpandedStates();
            }

            Editor.SaveState();

            // Clear GUI
            Editor.View = null;

            // Clear out all items
            for (var i = 0; i < Collection.Count; i++)
            {
                Collection[i].Variables.Clear();

                if (i > 0)
                {
                    Collection[i].ResetExpandedStates();
                }
            }

            if (Collection.Count > 0)
            {
                Editor.View = Collection[0];
            }

            // Reset
            ListInsert.Clear();
            ListNameInsert.Clear();
            ListNameInsertDict.Clear();
        }
示例#8
0
 private void ReceiveMsg()
 {
     while (receiveFlag)
     {
         try
         {
             IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
             Byte[]     receiveBytes     = udpClient.Receive(ref RemoteIpEndPoint);
             //ReceiveData:0000;
             if (receiveFlag)
             {
                 if (receiveBytes.Length > 4)
                 {
                     //可能返回0.0.0.0未配置的设备。过滤掉。
                     if (IPAddress.Any.ToString() != RemoteIpEndPoint.Address.ToString())
                     {
                         using MemoryStream memoryStream = new MemoryStream(receiveBytes);
                         using BinaryReader binaryReader = new BinaryReader(memoryStream);
                         string IPAddr       = RemoteIpEndPoint.Address.ToString();
                         MKInfo mikroTikInfo = new MKInfo()
                         {
                             IPAddr = IPAddr
                         };
                         //TLV格式的数据指针偏移4
                         binaryReader.BaseStream.Position = 4;
                         //开始读取TLV格式的数据
                         //递归方法读取二进制流的数据。
                         ReadBytes(binaryReader, ref mikroTikInfo);
                         //注释掉
                         //逐一读取二进制流的数据
                         //ReadBytes_v2(binaryReader,ref mikroTikInfo);
                         //更新List集合里面的数据
                         //主要更新Uptime的数据
                         int i = int.MinValue;
                         foreach (MKInfo t in mikroTikInfos)
                         {
                             if (t.MacAddr == mikroTikInfo.MacAddr)
                             {
                                 //删除集合List的数据。
                                 i = mikroTikInfos.IndexOf(t);
                                 break;
                             }
                         }
                         if (i >= 0)
                         {
                             //删除集合中存在元素
                             ListRemove lr = new ListRemove(MikroTikInfoRemove);
                             lr(i);
                             //插入到删除元素得位置
                             ListInsert li = new ListInsert(MikroTikInfoInsert);
                             li(i, mikroTikInfo);
                         }
                         else
                         {
                             //追加集合List的数据
                             ListAdd la = new ListAdd(MikroTikInfoAdd);
                             la(mikroTikInfo);
                         }
                     }
                 }
             }
         }
         catch (ObjectDisposedException) { }
         catch (SocketException) { }
         catch (Exception) { }
     }
     udpClient.Dispose();
 }
示例#9
0
文件: Form1.cs 项目: Aegisub/SSATool
        private void TextToList(TextBox tb, ListInsert type)
        {
            int index = GetFirstSelected();
            if (index == -1)
                MessageBox.Show("Select an item in the list first.");
            else {
                int indexIns;

                switch (type) {
                    case ListInsert.AfterLine:
                        indexIns = index + 1;
                        break;

                    case ListInsert.BeforeLine:
                        indexIns = index;
                        break;

                    default:
                        lineColl.RemoveAt(index);
                        indexIns = index;
                        break;
                }
                for (int lIndex = tb.Lines.Length - 1; lIndex != -1; lIndex--) {
                    string thisline = (string)tb.Lines.GetValue(lIndex);
                    if (!String.IsNullOrEmpty(thisline))
                        lineColl.Insert(indexIns, Line.ParseLine(thisline));
                }
                listSSA.VirtualListSize = lineColl.Count;
                DrawListOnScreen(); //update list on screen
            }
        }
        protected virtual void OnDebugServiceLookupBegin()
        {
            LookingUp = true;

            // If not during an update it's a
            // manual lookup and we are good to go
            if (!DebugService.IsUpdateInProgress)
            {
                return;
            }

            // Uh-oh
            if (ListNameInsert.Count <= 0)
            {
                return;
            }

            // Find where to place the incoming variable
            try
            {
                var pieces = new List <string>();
                {
                    Pair <string, IList <SledLuaVarNameTypePairType> > temp;
                    if (!ListNameInsertDict.TryGetValue(ListNameInsert[0], out temp))
                    {
                        throw new InvalidOperationException("Unknown variable");
                    }

                    pieces.AddRange(temp.Second.Select(kv => kv.Name)); // to navigate to the right table
                    pieces.Add(temp.First);                             // actual variable name
                }

                TType insert = null;

                // Try and find where the variable should be inserted
                for (var i = 0; i < pieces.Count; i++)
                {
                    IList <TType> lstVariables;

                    if (i == 0)
                    {
                        lstVariables = Collection[0].Variables;
                    }
                    else
                    {
                        if (insert == null)
                        {
                            throw new InvalidOperationException("Variable not found");
                        }

                        lstVariables =
                            new List <TType>(
                                insert.Variables.Select(v => v.As <TType>()));
                    }

                    var iPos = -1;

                    for (var j = 0; j < lstVariables.Count; j++)
                    {
                        if (string.Compare(lstVariables[j].DisplayName, pieces[i], StringComparison.Ordinal) != 0)
                        {
                            continue;
                        }

                        iPos = j;
                        break;
                    }

                    if (iPos == -1)
                    {
                        throw new InvalidOperationException("Variable not found");
                    }

                    insert = lstVariables[iPos];
                }

                if (insert == null)
                {
                    throw new InvalidOperationException("Variable not found");
                }

                // Finally found where to place lookups
                ListInsert.Add(insert);
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLineDebug(SledMessageType.Error, "{0}: Exception in OnDebugServiceLookupBegin: {1}", this, ex.Message);
            }
            finally
            {
                // Remove the item we just used
                if (ListNameInsert.Count > 0)
                {
                    ListNameInsertDict.Remove(ListNameInsert[0]);
                    ListNameInsert.RemoveAt(0);
                }
            }
        }