public bool Deletar()
        {
            Episodio = (Episodio)FormularioSimples();
            if (ValidarSimples())
            {
                var atual = (Episodio)Rep.Buscar(Episodio);
                if (atual == null)
                {
                    Utils.Pausar("Episodio não localizado");
                    return(false);
                }

                return(Rep.Deletar(Episodio));
            }
            else
            {
                return(false);
            }
        }
 public ActionResult AddOrEdit(ServiceList model)
 {
     if (!ModelState.IsValid)
     {
         return(UIHelper.Result());
     }
     try
     {
         if (model._id == 0)
         {
             if (!CheckRepeat(model))
             {
                 Alert.Show("已有相同记录存在!", MessageBoxIcon.Warning);
             }
             else
             {
                 model._id         = (int)(Rep.Max(t => t._id) ?? 0) + 1;
                 model.PrimaryId   = (int)(Rep.Max(t => t.PrimaryId) ?? 0) + 1;
                 model.SecondaryId = (int)(Rep.Max(t => t.SecondaryId) ?? 0) + 1;
                 SetRegContent(model);
                 Rep.Add(model);
                 // 关闭本窗体(触发窗体的关闭事件)
                 PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
             }
         }
         else
         {
             SetRegContent(model);
             Rep.Update(t => t._id == Convert.ToInt32(model._id), Builders <ServiceList> .Update.Set(t => t.ServiceName, model.ServiceName)
                        .Set(t => t.SecondaryName, model.SecondaryName)
                        .Set(t => t.Host, model.Host)
                        .Set(t => t.Version, model.Version)
                        .Set(t => t.Remark, model.Remark));
             // 关闭本窗体(触发窗体的关闭事件)
             PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
         }
     }
     catch (Exception ex)
     {
         Alert.Show(ex.Message, MessageBoxIcon.Warning);
     }
     return(UIHelper.Result());
 }
Пример #3
0
 public ActionResult GetOrderById(int id)
 {
     try
     {
         var result = Rep.GetOrderById(id);
         if (result != null)
         {
             return(Ok(Mapper.Map <Order, OrderViewModel>(result)));
         }
         else
         {
             return(NotFound());
         }
     }
     catch (Exception ex)
     {
         Log.LogError($"Failed to retrive order by id :{ex}");
         return(BadRequest("Failed to retrieve order"));
     }
 }
        /// <summary>
        /// Check if all links in diagram are visible (diagram local approach).
        /// </summary>
        /// <returns></returns>
        public bool IsCompleteDiagram()
        {
            EA.Diagram dia = Rep.GetDiagramByID(_diaObj.DiagramID);

            foreach (EA.DiagramLink l in dia.DiagramLinks)
            {
                if (l.IsHidden == true)
                {
                    var con          = Rep.GetConnectorByID(l.ConnectorID);
                    var sourceObject = dia.GetDiagramObjectByID(con.SupplierID, "");
                    var targetObject = dia.GetDiagramObjectByID(con.ClientID, "");
                    if ((sourceObject.ElementID == _diaObj.ElementID && sourceObject.ObjectType == _diaObj.ObjectType) ||
                        (targetObject.ElementID == _diaObj.ElementID && targetObject.ObjectType == _diaObj.ObjectType))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Пример #5
0
            ///<summary>
            /// 获取地址
            /// </summary>
            /// <param name="LinkStr">连接字符串,储存在fother</param>
            /// <returns>歌曲地址</returns>
            public static string GetSong(string LinkStr)
            {
                HttpWebRequest  Req;
                HttpWebResponse Rep;

                try
                {
                    Req = (HttpWebRequest)WebRequest.Create(@"http://5sing.kugou.com/m/detail/" + LinkStr + "-1.html");
                    Rep = (HttpWebResponse)Req.GetResponse();
                    StreamReader Reader = new StreamReader(Rep.GetResponseStream());
                    string       str    = Reader.ReadToEnd();
                    str = Regex.Split(str, "<audio src=\"")[1];
                    str = Regex.Split(str, "\" id=\"player\" volume=\"0.5\"></audio>")[0];
                    return(str);
                }
                catch (Exception ex)
                {
                    return("");
                }
            }
Пример #6
0
            /// <summary>
            /// 获取歌曲下载信息
            /// </summary>
            /// <param name="Hash">必选,歌曲Hash</param>
            /// <returns>歌曲地址</returns>
            public static string GetSongUrl(string Hash)
            {
                HttpWebRequest  Req;
                HttpWebResponse Rep;

                try
                {
                    Req = (HttpWebRequest)WebRequest.Create(@"http://trackercdn.kugou.com/i/?cmd=4&hash=" + Hash + @"&key=" + GetMd5HashStr(Hash + "kgcloud") + "&pid=1");
                    Rep = (HttpWebResponse)Req.GetResponse();
                    StreamReader Reader = new StreamReader(Rep.GetResponseStream());
                    string       str    = Reader.ReadToEnd();
                    System.Diagnostics.Debug.WriteLine(str);
                    JObject p = JObject.Parse(str);
                    return(p["url"].ToString());
                }
                catch (Exception ex)
                {
                    return("");
                }
            }
Пример #7
0
        static void ItemUI(Rep ρ, ref bool dirty)
        {
            if (Skip(ρ))
            {
                return;
            }
            Section(ρ.header);
            BeginHorizontal();
            var style = toggle;

            style.richText = true;
            bool flag = Toggle(ρ.@sel, ρ.alt != null
                                ? $"<color=brown>{ρ.alt}</color>"
                                : ρ.a, Width(60)
                               /*, EditorStyles.richText */);

            dirty |= ρ.@sel != flag;
            ρ.@sel = flag;
            Label(ρ.name);
            EndHorizontal();
        }
Пример #8
0
        /// <summary>
        /// Abre la ventana detalle en modo Add
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 18/04/2016
        /// </history>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            frmRepDetail frmRepDetail = new frmRepDetail();

            frmRepDetail.Owner    = this;
            frmRepDetail.enumMode = EnumMode.Add;
            if (frmRepDetail.ShowDialog() == true)
            {
                Rep rep = frmRepDetail.rep;
                if (ValidateFilter(rep))//Verificamos que cumpla con los filtros
                {
                    List <Rep> lstReps = (List <Rep>)dgrReps.ItemsSource;
                    lstReps.Add(rep);                                       //Agregamos el registro
                    lstReps.Sort((x, y) => string.Compare(x.rpID, y.rpID)); //Ordenamos la lista
                    int nIndex = lstReps.IndexOf(rep);                      //Obtenemos la posicion del registro
                    dgrReps.Items.Refresh();                                //Actualizamos la vista
                    GridHelper.SelectRow(dgrReps, nIndex);                  //Seleccionamos el registro nuevo
                    StatusBarReg.Content = lstReps.Count + " Reps.";        //Actualizamos el contador
                }
            }
        }
Пример #9
0
    public DualCallReport ConvertToRePort(PublicClassDualCall dc, string dateCreate, Rep rp)
    {
        DualCallReport sendreport = new DualCallReport();


        if (dateCreate == null)
        {
            dateCreate = DateTime.Today.ToString();
        }
        controlpage.maindata.dateSendReport = dateCreate;
        sendreport.clientDate                       = dateCreate;
        sendreport.ObjectiveID                      = dc.longterm.ObjectiveID;
        sendreport.AM_ID                            = UserAuthentication.instance.aminfo.AM_ID;
        sendreport.rep                              = rp;
        sendreport.step1.adoctor                    = dc.step1.adoctor;
        sendreport.step1.bkadoctor                  = dc.step1.bkadoctor;
        sendreport.step1.odoctor                    = dc.step1.odoctor;
        sendreport.step1.period                     = dc.step1.period;
        sendreport.step2.Achieve                    = dc.step2.Achieve;
        sendreport.step2.datefrom                   = dc.step2.datefrom;
        sendreport.step2.dateto                     = dc.step2.dateto;
        sendreport.step2.longterm                   = ReplateText(dc.step2.longterm);
        sendreport.step2.howto                      = ReplateText(dc.step2.howto);
        sendreport.step3.objective                  = (int)dc.step3.dataChar[0];
        sendreport.step3.CatchyHook                 = (int)dc.step3.dataChar[1];
        sendreport.step3.KeyMessage                 = (int)dc.step3.dataChar[2];
        sendreport.step3.EvisualAd                  = (int)dc.step3.dataChar[3];
        sendreport.step3.DocumentUsed               = (int)dc.step3.dataChar[4];
        sendreport.step3.BrandReminder              = (int)dc.step3.dataChar[5];
        sendreport.step3.Interaction                = (int)dc.step3.dataChar[6];
        sendreport.step3.Comitment                  = (int)dc.step3.dataChar[7];
        sendreport.step3.QualityOfNote              = (int)dc.step3.dataChar[8];
        sendreport.step4.QualityNoteEvaluate        = ReplateText(dc.step4.evaluaateQualityofNotes);
        sendreport.step5.Evaluatetheoptimization    = ReplateText(dc.step5.evaluaateQualityofVisit);
        sendreport.step6.Evaluateknowledgeandskills = ReplateText(dc.step6.evaluateProductExpertise);
        sendreport.step7.Agreementbetween           = ReplateText(dc.step7.evaluateCommentAgreement);

        return(sendreport);
    }
        //
        // GET: /Service/Manage/
        public override ActionResult Index()
        {
            var type   = Request["type"];
            var filter = !string.IsNullOrEmpty(type)
                ? t => t.ServiceType == (ServiceTypeEnum)Enum.Parse(typeof(ServiceTypeEnum), type)
                : (Expression <Func <ServiceList, bool> >)null;

            _typeFilter = filter;
            var hostList = new List <ListItem>
            {
                new ListItem("全部", "", true)
            };

            hostList.AddRange(Rep.Distinct(t => t.Host, filter).Select(t => new ListItem(t, t)));
            ViewBag.ddlHost   = hostList.ToArray();
            ViewBag.TreeNodes = _tree.GetTreeNodes(filter);
            var list = Rep.QueryByPage(0, PageSize, out var count, filter);

            ViewBag.RecordCount = count;
            ViewBag.PageSize    = PageSize;
            return(View(list));
        }
Пример #11
0
        public AwaitableWrapper WriteReply(Rep rep, AddrType atyp, byte[] addr, int port)
        {
            if (Status == Socks5Status.ReplySent)
            {
                throw getException("Socks5 reply has been already sent.");
            }
            Status = Socks5Status.ReplySent;
            var buf = this.buf;

            this.buf = null;
            buf[0]   = (0x05);
            buf[1]   = ((byte)rep);
            buf[2]   = (0x00);
            buf[3]   = ((byte)AddrType.IPv4Address);
            for (int i = 0; i < 4; i++)
            {
                buf[4 + i] = addr[i];
            }
            buf[8] = (0x00);
            buf[9] = (0x00);
            return(Stream.WriteAsyncR(new BytesSegment(buf, 0, 10)));
        }
Пример #12
0
 public ActionResult AddOrEdit(AppContacts model, bool isAdd = false)
 {
     if (!ModelState.IsValid)
     {
         return(UIHelper.Result());
     }
     try
     {
         if (isAdd)
         {
             if (!CheckRepeat(model))
             {
                 Alert.Show("已有相同记录存在!", MessageBoxIcon.Warning);
             }
             else
             {
                 Rep.Add(model);
                 // 关闭本窗体(触发窗体的关闭事件)
                 PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
             }
         }
         else
         {
             Rep.Update(t => t._id == model._id, Builders <AppContacts> .Update.Set(t => t.Tel, model.Tel)
                        .Set(t => t.Email, model.Email)
                        .Set(t => t.WeiXin_UID, model.WeiXin_UID)
                        .Set(t => t.DingTalk_UID, model.DingTalk_UID)
                        .Set(t => t.AlarmType, model.AlarmType)
                        .Set(t => t.Remark, model.Remark));
             // 关闭本窗体(触发窗体的关闭事件)
             PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
         }
     }
     catch (Exception ex)
     {
         Alert.Show(ex.Message, MessageBoxIcon.Warning);
     }
     return(UIHelper.Result());
 }
Пример #13
0
        public void Conv_numarrayfrom1and0to21_string1returned()
        {
            Stopwatch stopWatch = new Stopwatch();

            // arrange
            int[]  x        = { 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 };
            string expected = "1";

            // act
            stopWatch.Start();
            string actual = Rep.Check(x);

            stopWatch.Stop();

            // assert
            Assert.AreEqual(expected, actual);
            TimeSpan ts          = stopWatch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                 ts.Hours, ts.Minutes, ts.Seconds,
                                                 ts.Milliseconds / 10);

            Console.WriteLine("RunTime " + elapsedTime);
        }
 public ActionResult RegService(int id, FormCollection values)
 {
     try
     {
         var model = Rep.Get(t => t._id == id);
         if (model.IsApproved)
         {
             Alert.Show("服务已经审批", MessageBoxIcon.Warning);
             return(UIHelper.Result());
         }
         var serverName = $"{model.ServiceName}/{model.SecondaryName}";
         //ServerDiscoveryHelper.ServiceRegister(serverName, model.Version, model.RegContent);
         Rep.Update(t => t._id == id, Builders <ServiceList> .Update.Set(t => t.IsApproved, true));
         ShowNotify("注册成功");
         OnUpdated(values);
     }
     catch (Exception e)
     {
         Alert.Show(e.Message, MessageBoxIcon.Warning);
         throw;
     }
     return(UIHelper.Result());
 }
Пример #15
0
        /// <summary>
        /// Llena el grid de Reps
        /// </summary>
        /// <param name="rep">Objeto a seleccionar</param>
        /// <history>
        /// [emoguel] created 18/04/2016
        /// </history>
        private async void LoadReps(Rep rep = null)
        {
            try
            {
                status.Visibility = Visibility.Visible;
                int        nIndex  = 0;
                List <Rep> lstReps = await BRReps.GetReps(_repFilter, _nStatus);

                dgrReps.ItemsSource = lstReps;
                if (lstReps.Count > 0 && rep != null)
                {
                    rep    = lstReps.Where(rp => rp.rpID == rep.rpID).FirstOrDefault();
                    nIndex = lstReps.IndexOf(rep);
                }
                GridHelper.SelectRow(dgrReps, nIndex);
                StatusBarReg.Content = lstReps.Count + " Reps.";
                status.Visibility    = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
        }
Пример #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (eBase.showHelp())
            {
                Response.Write("<div class=\"tips\" style=\"margin-bottom:8px;\">");
                Response.Write("<b>对应关系</b><br>");
                Response.Write("设置数据子模块回填数据到主模块的对应关系。");
                Response.Write("</div> ");
            }

            me     = eOleDB.getDataTable("select * from a_eke_sysModels where modelID='" + modelid + "'").Select()[0];
            parent = eOleDB.getDataTable("select * from a_eke_sysModels where modelID='" + me["ParentID"].ToString() + "'").Select()[0];


            List();
            System.IO.StringWriter sw  = new System.IO.StringWriter();
            HtmlTextWriter         htw = new HtmlTextWriter(sw);

            Rep.RenderControl(htw);
            Rep.Visible = false;
            Response.Write(sw.ToString());
            Response.End();
        }
Пример #17
0
        public void Conv_numarray01and1and0001and00001_string1returned()
        {
            Stopwatch stopWatch = new Stopwatch();

            // arrange
            int[]  x        = { 01, 1, 0001, 00001 };
            string expected = "1";

            // act
            stopWatch.Start();
            string actual = Rep.Check(x);

            stopWatch.Stop();

            // assert
            Assert.AreEqual(expected, actual);
            TimeSpan ts          = stopWatch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                 ts.Hours, ts.Minutes, ts.Seconds,
                                                 ts.Milliseconds / 10);

            Console.WriteLine("RunTime " + elapsedTime);
        }
Пример #18
0
    public bool EditorOnly_SetSuper(ref Rep rep, VisClass _super)
    {
        VisClass class2 = _super;
        int      num    = 50;

        while (class2 != null)
        {
            if (class2 == this)
            {
                Debug.LogError("Self Reference Detected", this);
                return(false);
            }
            class2 = class2._super;
            if (--num <= 0)
            {
                Debug.LogError("Circular Dependancy Detected", this);
                return(false);
            }
        }
        rep         = null;
        this._super = _super;
        return(true);
    }
        public ActionResult AddOrEdit(int?id)
        {
            ViewBag.ServiceList = _group.Find().ToList().Select(t => new ListItem
            {
                Text  = t.ServiceNameCN,
                Value = t.ServiceNameCN
            }).ToArray();
            if (id == null)
            {
                return(View());
            }
            var model = Rep.Get(t => t._id == id);

            if (model == null)
            {
                return(HttpNotFound());
            }
            if (!string.IsNullOrWhiteSpace(model.RegContent))
            {
                InitAddr(model);
            }
            return(View(model));
        }
Пример #20
0
        public void Conv_string2147483647_numarray2147483647returned()
        {
            Stopwatch stopWatch = new Stopwatch();

            // arrange
            string x = "2147483647";

            int[] expected = { 2147483647 };

            // act
            stopWatch.Start();
            int[] actual = Rep.Conv(x);
            stopWatch.Stop();

            // assert
            CollectionAssert.AreEqual(expected, actual);
            TimeSpan ts          = stopWatch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                 ts.Hours, ts.Minutes, ts.Seconds,
                                                 ts.Milliseconds / 10);

            Console.WriteLine("RunTime " + elapsedTime);
        }
        /// <summary>
        /// Inventory a Module. It adds the EA Interface reference to the Interface Element if exists.
        /// </summary>
        public void Inventory()
        {
            // get interface: Interface
            string sql = $@"select object_id 
                              from t_object 
                              where name = '{Name}'             AND
                                    object_type = 'Interface' ";

            // Get Element list from sql=2
            EA.Collection col = Rep.GetElementSet(sql, 2);
            if (col.Count > 1)
            {
                MessageBox.Show("More than one 'Interface' available.", "Can't inventory Interface {Name}");
                return;
            }
            if (col.Count == 0)
            {
                El = null;
            }
            else
            {  // Interface existing
                El = (EA.Element)col.GetAt(0);
                List <MethodItem> methods = new List <MethodItem>();
                foreach (EA.Method m in El.Methods)
                {
                    methods.Add(new MethodItem(m, m.Name));
                }
                // update existing methods
                var existingMethods = from provided in ProvidedFunctions
                                      join ea in methods on provided.Name equals ea.Name
                                      select new { ea.Method, provided };
                foreach (var f in existingMethods)
                {
                    f.provided.Op = f.Method;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            dr = eOleDB.getDataTable("select * from a_eke_sysModels where ModelID='" + modelid + "'").Select()[0];



            if (eBase.showHelp())
            {
                Response.Write("<div class=\"tips\" style=\"margin-bottom:6px;\">");
                Response.Write("<b>搜索</b><br>");
                Response.Write("设置列表搜索条件。");
                Response.Write("</div> ");
            }

            Response.Write("<div style=\"margin:6px 0px 8px 0px;\">");
            Response.Write("&nbsp;搜索列数:<input type=\"text\" value=\"" + dr["searchcolumncount"].ToString() + "\" oldvalue=\"" + dr["searchcolumncount"].ToString() + "\"  class=\"edit\" style=\"width:40px;\" onBlur=\"setModel(this,'searchcolumncount');\" />");
            if (eBase.showHelp())
            {
                Response.Write(" <img src=\"images/help.gif\" align=\"absmiddle\" border=\"0\" onclick=\"showHelp(107);\" title=\"查看帮助\" alt=\"查看帮助\" style=\"cursor:pointer;margin-bottom:4px;\">");
            }
            Response.Write("</div> ");

            eList datalist = new eList("a_eke_sysModelConditions");

            datalist.Where.Add("delTag=0 and ModelID='" + modelid + "'");
            datalist.OrderBy.Add("show desc,px,addTime");
            Rep.ItemDataBound += new RepeaterItemEventHandler(Rep_ItemDataBound);
            datalist.Bind(Rep);

            System.IO.StringWriter sw  = new System.IO.StringWriter();
            HtmlTextWriter         htw = new HtmlTextWriter(sw);

            Rep.RenderControl(htw);
            Rep.Visible = false;//不输出,要在获取后设,不然取不到内容。
            Response.Write(sw.ToString());
            Response.End();
        }
Пример #23
0
        public DataResponse <bool> Delete(int repid)
        {
            var response = new DataResponse <bool>();

            try
            {
                base.DBInit();
                Rep rep = DBEntity.Reps.Find(repid);
                try
                {
                    DBEntity.RepServiceMappers.RemoveRange(DBEntity.RepServiceMappers.Where(u => u.RepId == repid));
                    DBEntity.SaveChanges();
                    DBEntity.Reps.Remove(rep);
                    if (DBEntity.SaveChanges() > 0)
                    {
                        response.Status  = DataResponseStatus.OK;
                        response.Message = "Successfully Deleted.";
                        response.Model   = true;
                    }
                }
                catch (DbUpdateException ex)
                {
                    response.Status  = DataResponseStatus.InternalServerError;
                    response.Message = "There are some releted item in database, please delete those first.";
                    response.Model   = false;
                }
            }
            catch (Exception ex)
            {
                ex.Log();
            }
            finally
            {
                base.DBClose();
            }
            return(response);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (eBase.showHelp())
            {
                Response.Write("<div class=\"tips\" style=\"margin-bottom:8px;\">");
                Response.Write("<b>导出</b><br>");
                Response.Write("设置模块导出到Excel的列及宽度。");
                Response.Write("</div> ");
            }

            eList datalist = new eList("a_eke_sysModelItems");

            datalist.Where.Add("ModelID='" + modelid + "' and delTag=0");
            datalist.OrderBy.Add("showExport desc,ExportOrder,  addTime");
            datalist.Bind(Rep);


            System.IO.StringWriter sw  = new System.IO.StringWriter();
            HtmlTextWriter         htw = new HtmlTextWriter(sw);

            Rep.RenderControl(htw);
            Rep.Visible = false;
            Response.Write(sw.ToString());
        }
        /// <summary>
        /// Inventory a Module. It adds the EA Module reference if exists.
        /// </summary>
        public void InventoryAddEaModuleReference()
        {
            // get module: Component, Stereotype: 'LE Modul'
            string sql = $@"select object_id 
                              from t_object 
                              where name = '{Name}'             AND
                                    object_type = 'Component'   AND
                                    Stereotype = 'LE Modul'";

            EA.Collection col = Rep.GetElementSet(sql, 2);
            if (col.Count > 1)
            {
                MessageBox.Show("More than one 'LE Module' available.", "Can't inventory Module {Name}");
                return;
            }
            if (col.Count == 0)
            {
                El = null;
            }
            else
            {
                El = (EA.Element)col.GetAt(0);
            }
        }
 public override byte[] ToBytes() => ByteHelpers.Combine(new byte[] { Ver.ToByte(), Rep.ToByte(), Rsv.ToByte(), Atyp.ToByte() }, BndAddr.ToBytes(), BndPort.ToBytes());
Пример #27
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Reps EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToReps(Rep rep)
 {
     base.AddObject("Reps", rep);
 }
Пример #28
0
        private void btnPrintSET_Click(object sender, EventArgs e)
        {
            bool bMod = false;

            if (sUserID == "admin" || sUserID == "system" || sUserID == "demo")
            {
                bMod = true;
            }

            if (!Directory.Exists(sProPath + "\\UAP\\Runtime\\print"))
            {
                Directory.CreateDirectory(sProPath + "\\UAP\\Runtime\\print");
            }
            if (!Directory.Exists(sProPath + "\\UAP\\Runtime\\print\\Model"))
            {
                Directory.CreateDirectory(sProPath + "\\UAP\\Runtime\\print\\Model");
            }
            if (!Directory.Exists(sProPath + "\\UAP\\Runtime\\print\\User"))
            {
                Directory.CreateDirectory(sProPath + "\\UAP\\Runtime\\print\\User");
            }

            if (bMod)
            {
                if (File.Exists(sPrintLayOutMod))
                {
                    Rep.LoadLayout(sPrintLayOutMod);
                }
            }
            else
            {
                if (File.Exists(sPrintLayOutUser))
                {
                    Rep.LoadLayout(sPrintLayOutUser);
                }
                else if (File.Exists(sPrintLayOutMod))
                {
                    Rep.LoadLayout(sPrintLayOutMod);
                }
            }

            Rep.ShowDesignerDialog();

            DialogResult d = MessageBox.Show("是否保存?模板调整将在下次打开窗体时体现\n是:保存打印模板\n否:恢复默认打印模板\n", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk);

            if (DialogResult.Yes == d)
            {
                if (bMod)
                {
                    Rep.SaveLayoutToXml(sPrintLayOutMod);
                }
                else
                {
                    Rep.SaveLayoutToXml(sPrintLayOutUser);
                }
            }
            else if (DialogResult.No == d)
            {
                if (File.Exists(sPrintLayOutUser))
                {
                    File.Delete(sPrintLayOutUser);
                }
            }
        }
        /// <summary>
        /// Sort diagram objects alphabetic like:
        /// - Classifier
        /// - Port, Parameter, Pin
        /// - Packages
        /// If it sorts for Ports, it ignores other element types.
        /// </summary>
        /// <returns></returns>
        public override bool SortAlphabetic()
        {
            //EA.Element el = _rep.GetElementByID(diaObj.ElementID);
            var list = from item in _eaDia.SelObjects
                       let el = Rep.GetElementByID(item.ElementID)
                                select new { item.ElementID, el.Name, el.Type, item.left, item.right, item.top, item.bottom, item }
            into temp
            where temp.Type != "RequiredInterface" && temp.Type != "ProvidedInterface"
            orderby temp.Name
            select temp;
            var llist = list.ToList();  // run query

            // sort only Port, Pin, Parameter
            if (llist.Count(t => t.Type == "Port" || t.Type == "Pin" || t.Type == "Parameter") > 0)
            {
                llist = llist.Where(t => t.Type == "Port" || t.Type == "Pin" || t.Type == "Parameter").ToList();
            }
            // nothing to sort
            if (llist.Count() < 2)
            {
                return(false);
            }

            // estimate the direction
            bool isVertical =
                (Math.Abs(llist[0].top - llist[1].top)) >
                (Math.Abs(llist[0].left - llist[1].left))
                    ? true
                    : false;

            if (isVertical)
            {
                // vertical
                int topItem    = llist.Max(t => t.top);
                int bottomItem = llist.Min(t => t.bottom);
                int sum        = llist.Sum(t => t.top - t.bottom);
                int diff       = (topItem - bottomItem - sum) / (llist.Count - 1);
                int top        = topItem;
                foreach (var item in llist)
                {
                    int itemDif = item.item.top - item.item.bottom;
                    item.item.top    = top;
                    item.item.bottom = item.item.top - itemDif;
                    top = item.item.bottom - diff;
                    item.item.Update();
                }
                Rep.ReloadDiagram(_eaDia.Dia.DiagramID);
                return(true);
            }
            else
            {
                // horizontal
                int leftItem  = llist.Min(t => t.left);
                int rightItem = llist.Max(t => t.right);
                int sum       = llist.Sum(t => t.right - t.left);
                int diff      = (rightItem - leftItem - sum) / (llist.Count - 1);
                int left      = leftItem;
                foreach (var item in llist)
                {
                    int itemDif = item.item.right - item.item.left;
                    item.item.left  = left;
                    item.item.right = item.item.left + itemDif;
                    left            = item.item.right + diff;
                    item.item.Update();
                }
                Rep.ReloadDiagram(_eaDia.Dia.DiagramID);
                return(true);
            }
        }
Пример #30
0
        public static void WriteSettings()
        {
            try
            {
                XDocument doc = XDocument.Load("Settings.xml");

                doc.Root.Element("SaveTab").ReplaceWith(new XElement("SaveTab",
                                                                     new XAttribute("SO", SaleOrderId.Trim()),
                                                                     new XAttribute("RP", Rep.Trim()),
                                                                     new XAttribute("Comments", Comments.Trim()),
                                                                     new XAttribute("Licence", Licence)
                                                                     ));

                doc.Save("Settings.xml");
            }
            catch { }
        }
Пример #31
0
 private Table(Rep rep)
 {
     rep_ = rep;
 }
Пример #32
0
        /// <summary>				
        /// Attempt to open the table that is stored in bytes [0..file_size)
        /// of "file", and read the metadata entries necessary to allow
        /// retrieving data from the table.
        ///
        /// If successful, returns ok and sets "*table" to the newly opened
        /// table.  The client should delete "*table" when no longer needed.
        /// If there was an error while initializing the table, sets "*table"
        /// to NULL and returns a non-ok status.  Does not take ownership of
        /// "*source", but the client must ensure that "source" remains live
        /// for the duration of the returned table's lifetime.
        ///
        /// *file must remain live while this Table is in use.				
        /// </summary>
        public static Status Open(Options options, RandomAccessFile file, UInt64 size, out Table table)
        {
            table = null;
            if (size < Footer.kEncodedLength)
            {
                return Status.InvalidArgument("file is too short to be an sstable");
            }

            ByteArrayPointer footerSpace = new ByteArrayPointer(Footer.kEncodedLength);

            Slice footerInput;
            Status s = file.Read(size - Footer.kEncodedLength, Footer.kEncodedLength, out footerInput, footerSpace);
            if (!s.IsOk) return s;

            Footer footer = new Footer();
            s = footer.DecodeFrom(ref footerInput);
            if (!s.IsOk) return s;

            // Read the index block
            BlockContents contents;
            Block indexBlock = null;
            if (s.IsOk)
            {
                s = FormatHelper.ReadBlock(file, ReadOptions.Default, footer.IndexHandle, out contents);
                if (s.IsOk)
                {
                    indexBlock = new Block(contents);
                }
            }

            if (s.IsOk)
            {
                // We've successfully read the footer and the index block: we're
                // ready to serve requests.

                Rep rep = new Rep();
                rep.Options = options;
                rep.File = file;
                rep.MetaindexHandle = footer.MetaindexHandle;
                rep.IndexBlock = indexBlock;
                rep.CacheId = (options.BlockCache != null ? options.BlockCache.NewId() : 0);
                rep.FilterData = ByteArrayPointer.Null;
                rep.Filter = null;
                table = new Table(rep);
                table.ReadMeta(footer);
            }

            return s;
        }