Example #1
0
        public int EditModel(IModel model)
        {
            INF objModel = (INF)model;
            //编写带参数的SQL语句
            StringBuilder sqlBuilder = new StringBuilder();

            sqlBuilder.Append("Update INF set Length=@Length,Width=@Width where INFId=@INFId");
            //定义参数数组
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@Length", objModel.Length),
                new SqlParameter("@Width", objModel.Width),

                new SqlParameter("@INFId", objModel.INFId)
            };
            try
            {
                return(SQLHelper.Update(sqlBuilder.ToString(), param));
            }
            catch (SqlException ex)
            {
                throw new Exception("数据库操作出现异常:" + ex.Message);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
 public INF(INF inf)
 {
     this.EXTINF            = inf.EXTINF;
     this.EXTINF_TYPE       = inf.EXTINF_TYPE;
     this.PROGRAM_DATE_TIME = inf.PROGRAM_DATE_TIME;
     this.URL = inf.URL;
 }
Example #3
0
 public override int GetHashCode()
 {
     unchecked {
         int hash = 17;
         hash = hash * 23 + INF.GetHashCode();
         hash = hash * 23 + Name.GetHashCode();
         return(hash);
     }
 }
Example #4
0
        /// <summary>
        /// m3u8文件的解析
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public static M3U8Model Parse(string content)
        {
            var lines = content.Split('\n');

            if (!lines.Any())
            {
                throw new InvalidOperationException("The content is Empty");
            }

            string firstLine = lines[0];

            if (firstLine != "#EXTM3U")
            {
                throw new InvalidOperationException("The provided URL does not link to a well-formed M3U8 playlist.");
            }

            Regex regex = new Regex(@"^\#[\w\-]+:", RegexOptions.IgnoreCase);

            M3U8Model m3u8 = new M3U8Model();

            for (int i = 1; i < lines.Length; i++)
            {
                string line = lines[i];
                if (!regex.IsMatch(line))
                {
                    continue;
                }
                string tag = regex.Match(line).Value;

                switch (tag)
                {
                case "#EXTINF:":
                    string preLine  = lines[i - 1];
                    string nextLine = lines[i + 1];
                    INF    inf      = new INF()
                    {
                        URL         = nextLine,
                        EXTINF      = Regex.Match(line, @"^\#EXTINF:(?<Value>[\d\.]+)").Groups["Value"].Value.GetValue <float>(),
                        EXTINF_TYPE = "live"
                    };
                    if (preLine.StartsWith("#EXT-X-PROGRAM-DATE-TIME:"))
                    {
                        inf.PROGRAM_DATE_TIME = preLine.Replace("#EXT-X-PROGRAM-DATE-TIME:", string.Empty).GetValue <DateTime>();
                    }
                    m3u8.INFLIST.Add(inf);
                    break;
                }
            }
            return(m3u8);
        }
        /// <summary>
        /// Cria a chave com base em uma NF-e.
        /// </summary>
        /// <param name="nfe"></param>
        /// <returns></returns>
        public static ChaveNFe Create(INF nfe)
        {
            /*
             *
             * A chave de acesso é composta por:
             *
             * Descrição: UF	AAMM da emissão	CNPJ do Emitente	Modelo	Série	Número da NF-e	Forma de emissão	Código Numérico	DV
             * Caracteres 02	04	            14	                02	    03	    09	            01	                08	            01
             *
             * O tamanho do campo  cNF- código numérico da NF-e foi reduzido para oito posições
             * para  não  alterar  o  tamanho  da  chave  de  acesso  da  NF-e  de  44  posições  que  passa  ser
             * composta pelos seguintes campos que se encontram dispersos na NF-e :
             *
             * •  cUF- Código da UF do emitente do Documento Fiscal
             * •  AAMM- Ano e Mês de emissão da NF-e
             * •  CNPJ- CNPJ do emitente
             * Nota Fiscal Eletrônica
             * Manual de Integração - Contribuinte
             * Pág. 85 / 232
             * •  mod- Modelo do Documento Fiscal
             * •  serie- Série do Documento Fiscal
             * •  nNF- Número do Documento Fiscal
             * •  tpEmis – forma de emissão da NF-e
             *
             *
             */
            string eguid = nfe.EGUID;

            if(nfe.EGUID.Length > 9)
                eguid = nfe.EGUID.ToString().Substring(0, 9);
            else
                eguid = nfe.EGUID.ToString().PadRight(9, '0');

            StringBuilder chaveStringBuilder = new StringBuilder();
            chaveStringBuilder.Append(nfe.Empresa.Enderecos.First(W => W.Principal).Endereco.Estado.CodigoIBGE);
            chaveStringBuilder.Append(String.Format("{0:yyMM}", nfe.DataEmissao));
            chaveStringBuilder.Append(nfe.Empresa.GetCPFCNPJ(false));
            chaveStringBuilder.Append(nfe.Modelo);
            chaveStringBuilder.Append(nfe.Serie.Serie.PadLeft(3, '0'));
            chaveStringBuilder.Append(eguid);
            chaveStringBuilder.Append(Unimake.Convert.ToInt(Settings.NFe.TipoEmissao));
            chaveStringBuilder.Append(eguid.Substring(1));
            chaveStringBuilder.Append(CalculaModulo11(chaveStringBuilder.ToString()));

            if(chaveStringBuilder.Length != 44)
                throw new Exception("Não foi possível gerar a chave da NF-e " + nfe.GUID.ToString());

            return chaveStringBuilder.ToString();
        }
Example #6
0
    public void Add(string text, LOG_TYPE log)
    {
        while (ListLoged.Count > 10)
        {
            ListLoged.Remove(ListLoged[0]);
        }
        INF inf = new INF(text, log);

        ListLoged.Add(inf);
        logtype.Add("[" + inf.date_time + "][" + inf.log_type + "]" + inf.message);
        while (logtype.Count > 150)
        {
            logtype.Remove(logtype[0]);
        }
    }
Example #7
0
        public FrmINF(Drawing drawing, ModuleTree tree) : this()
        {
            objINF = (INF)objINFService.GetModelByModuleTreeId(tree.ModuleTreeId.ToString());
            if (objINF == null)
            {
                return;
            }
            this.Text = drawing.ODPNo + " / Item: " + drawing.Item + " / Module: " + tree.Module + " - " + tree.CategoryName;
            Category objCategory = objCategoryService.GetCategoryByCategoryId(tree.CategoryId.ToString());

            pbModelImage.Image = objCategory.ModelImage.Length == 0
                ? Image.FromFile("NoPic.png")
                : (Image) new SerializeObjectToString().DeserializeObject(objCategory.ModelImage);
            FillData();
        }
Example #8
0
        private void btnEditData_Click(object sender, EventArgs e)
        {
            //必填项目
            if (pbModelImage.Tag.ToString().Length == 0)
            {
                return;
            }
            if (!DataValidate.IsDecimal(txtLength.Text.Trim()) || Convert.ToDecimal(txtLength.Text.Trim()) < 50m)
            {
                MessageBox.Show("请认真检查长度", "提示信息");
                txtLength.Focus();
                txtLength.SelectAll();
                return;
            }
            if (!DataValidate.IsDecimal(txtWidth.Text.Trim()) || Convert.ToDecimal(txtWidth.Text.Trim()) < 20m)
            {
                MessageBox.Show("请认真检查宽度", "提示信息");
                txtWidth.Focus();
                txtWidth.SelectAll();
                return;
            }


            //封装对象
            INF objINF = new INF()
            {
                INFId = Convert.ToInt32(pbModelImage.Tag),

                Length = Convert.ToDecimal(txtLength.Text.Trim()),
                Width  = Convert.ToDecimal(txtWidth.Text.Trim())
            };

            //提交修改
            try
            {
                if (objINFService.EditModel(objINF) == 1)
                {
                    MessageBox.Show("制图数据修改成功", "提示信息");
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #9
0
        public IModel GetModelByWhereSql(string whereSql)
        {
            string sql =
                "select INFId,ModuleTreeId,Length,Width from INF";

            sql += whereSql;
            SqlDataReader objReader = SQLHelper.GetReader(sql);
            INF           objModel  = null;

            if (objReader.Read())
            {
                objModel = new INF()
                {
                    INFId        = Convert.ToInt32(objReader["INFId"]),
                    ModuleTreeId = Convert.ToInt32(objReader["ModuleTreeId"]),
                    //最好不要用=null去判断,提示类型转换错误
                    Length = objReader["Length"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["Length"]),
                    Width  = objReader["Width"].ToString().Length == 0 ? 0 : Convert.ToDecimal(objReader["Width"])
                };
            }
            objReader.Close();
            return(objModel);
        }
Example #10
0
        /// <summary>
        /// Reimprime a nfe 
        /// </summary>
        /// <param name="nfe">NFE </param>
        protected internal void ImprimeNFE(INF nfe)
        {
            // Informa os endereços de email para envio ao cliente
            string emails = string.Empty;
            foreach(ICanalComunicacao c in nfe.DadoPessoa.Cliente.CanaisComunicacao.Where(
                                              k => k.TipoCanal == Enuns.Cadastro.Pessoa.TipoCanal.EMailNFe
                                              ).ToList())
            {
                if(!string.IsNullOrEmpty(emails))
                    emails += " ";
                emails += "\"" + c.IdentificadorCanal + "\"";
            }
            ProcessStartInfo psi = new ProcessStartInfo
            {
                Arguments = String.Format("a=\"{0}\" v={1} m={2} " + (!string.IsNullOrEmpty(emails) ? "e={3}" : ""),
                                            Path.Combine(Settings.NFe.DiretorioInstalacao,
                                            Settings.EmpresaAtual.GetCPFCNPJ(false),
                                            "Enviado",
                                            "Autorizados",
                                            nfe.DataEmissao.ToString("yyyyMM"),
                                            nfe.Chave + "-procNFe.xml"),
                                            Convert.ToInt16(Settings.NFe.ExibeDANFE),
                                            Convert.ToInt16(Settings.NFe.ImprimeAutomaticamente),
                                            emails
                                            ),

                ErrorDialog = true,
                UseShellExecute = false,
                FileName = Path.Combine(Settings.NFe.DiretorioInstalacao, "unidanfe.exe")
            };

            Process process = Process.Start(psi);
        }
Example #11
0
        /// <summary>
        /// Envia nfe 
        /// </summary>
        /// <param name="nfe">objeto nfe</param>
        protected internal void EnviaNFE(INF nfe, bool saveObj = false)
        {
            if(MessageBox.AskYesNo("Deseja enviar a Nota Fiscal Eletrônica à SEFAZ ?", "Emitir Nota Fiscal Eletrônica") ==
                System.Windows.Forms.DialogResult.Yes)
            {
                try
                {

                    Wait.Show();

                    LogNFe.Save(Enuns.TipoEvento.NFeGerarXML,
                                "Gerando o XML da nota fiscal eletrônica para envia-la à Secretaria da Fazenda",
                                nfe.Chave, nfe.StatusNF);

                    string fileName = nfe.Chave + "-nfe.xml";
                    string filePath = Path.Combine(Settings.NFe.PastaEnvio, fileName);
                    ((NFe.IGenerateNFe)nfe).GenerateXML().Save(filePath);

                    LogNFe.Save(Enuns.TipoEvento.NFeGeradoXML, "Gerado o XML da nota fiscal eletrônica com sucesso", nfe.Chave, nfe.StatusNF);

                    OpenPOS.NFe.NFeResult result = ((OpenPOS.Data.Abstract.Faturamento.Lancamento.Movimento.NF.NFBase)nfe).ProcessaResposta();

                    if(result.Success)
                    {
                        txtStatusNF.Text = result.Status.ToString();
                        nfe.StatusNF = result.Status;
                        nfe.Chave = txtChave.Text = result.Chave;
                        nfe.InfProt = txtNumProtocolo.Text = result.Protocolo;
                        nfe.Motivo = txtMotivo.Text = result.Motivo;

                        InformacaoProtocolo informacaoProtocolo = new InformacaoProtocolo();
                        informacaoProtocolo.StatusNF = result.Status;
                        informacaoProtocolo.Chave = result.Chave;
                        informacaoProtocolo.InfProt = result.Protocolo;
                        informacaoProtocolo.Motivo = result.Motivo;

                        nfe.Save(informacaoProtocolo);

                        LogNFe.Save(Enuns.TipoEvento.NFeAutorizado,
                                    "Autorizado o uso da NF-e",
                                    nfe.Chave,
                                    nfe.StatusNF);

                        if(saveObj)
                        {
                            nfe.Temp = true;
                            nfe.Save();
                        }
                        ImprimeNFE((INF)CurrentObject);

                        LogNFe.Save(Enuns.TipoEvento.NFeImpressa,
                                    "Nota fiscal eletrônica está impressa",
                                    nfe.Chave,
                                    nfe.StatusNF);
                    }
                    else
                    {
                        string motivo = result.Motivo == null ? result.Message : result.Motivo;

                        LogNFe.Save(Enuns.TipoEvento.Erro,
                            result.Motivo = motivo == null ? "Ocorreu um erro" : motivo,
                            result.Chave = result.Chave == null ? nfe.Chave : result.Chave,
                            result.Status = result.Status == null ? NFe.Status.NaoDefinido : result.Status);

                        MessageBox.ShowWarning(result.Motivo);
                    }
                }
                catch(Exception ex)
                {
                    LogNFe.Save(Enuns.TipoEvento.Erro,
                        ex.Message,
                        nfe.Chave,
                        nfe.StatusNF);
                    MessageBox.ShowError(ex);
                }
                finally
                {
                    Wait.Close();
                }
            }
        }
Example #12
0
 /// <summary>
 /// 插入资源
 /// </summary>
 /// <param name="inf"></param>
 public void Push(INF inf)
 {
     INFLIST.Add(inf);
 }
Example #13
0
 /// <summary>
 /// Salva o erro ao tentar executar alguma ação no envio da nota
 /// </summary>
 /// <param name="nfe">Nota fiscal que está tentando realizar a ação</param>
 /// <param name="ex"></param>
 public static GUID Save(INF nfe, Exception ex)
 {
     return Save(new LogNFe
     {
         TipoEvento = Enuns.TipoEvento.Erro,
         Evento = "Ocorreram erros ao tentar realizar uma ação na nota fiscal",
         ChaveNFe = String.IsNullOrEmpty(nfe.Chave) ? nfe.GUID.ToString().PadLeft(44, '0') : nfe.Chave.ToString(),
         Descricao = ex != null ? ex.ToString() : ""
     });
 }
Example #14
0
        public void AutoDrawing(SldWorks swApp, ModuleTree tree, string projectPath)
        {
            //创建项目模型存放地址
            string itemPath = projectPath + @"\" + tree.Module + "-" + tree.CategoryName;

            if (!Directory.Exists(itemPath))
            {
                Directory.CreateDirectory(itemPath);
            }
            else
            {
                DialogResult result =
                    MessageBox.Show("模型文件夹" + itemPath + "存在,如果之前pack已经执行过,将不执行pack过程而是直接修改模型,如果要继续请点击YES,否请点击No中断作图", "提示信息",
                                    MessageBoxButtons.YesNo);
                if (result == DialogResult.No)
                {
                    return;
                }
            }
            //Pack的后缀
            string suffix = tree.Module + "-" + tree.ODPNo.Substring(tree.ODPNo.Length - 6);
            //判断文件是否存在,如果存在将不执行pack,如果不存在则执行pack
            //packango后需要接收打包完成的地址,参数为后缀
            string packedAssyPath = itemPath + @"\" + tree.CategoryName.ToLower() + "_" + suffix + ".sldasm";

            if (!File.Exists(packedAssyPath))
            {
                packedAssyPath = CommonFunc.PackAndGoFunc(suffix, swApp, tree.ModelPath, itemPath);
            }

            //查询参数
            INF item = (INF)objINFService.GetModelByModuleTreeId(tree.ModuleTreeId.ToString());

            swApp.CommandInProgress = true; //告诉SolidWorks,现在是用外部程序调用命令
            int warnings = 0;
            int errors   = 0;

            suffix = "_" + suffix;//后缀
            ModelDoc2         swModel = default(ModelDoc2);
            ModelDoc2         swPart  = default(ModelDoc2);
            AssemblyDoc       swAssy  = default(AssemblyDoc);
            Component2        swComp;
            Feature           swFeat        = default(Feature);
            object            configNames   = null;
            ModelDocExtension swModelDocExt = default(ModelDocExtension);
            bool   status     = false;
            string compReName = string.Empty;

            //打开Pack后的模型
            swModel = swApp.OpenDoc6(packedAssyPath, (int)swDocumentTypes_e.swDocASSEMBLY,
                                     (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings) as ModelDoc2;
            swAssy = swModel as AssemblyDoc;                                                  //装配体
            string assyName = swModel.GetTitle().Substring(0, swModel.GetTitle().Length - 7); //获取装配体名称

            swModelDocExt = (ModelDocExtension)swModel.Extension;
            //打开装配体后必须重建,使Pack后的零件名都更新到带后缀的状态,否则程序出错
            swModel.ForceRebuild3(true);
            //TopOnly参数设置成true,只重建顶层,不重建零件内部

            /*注意SolidWorks单位是m,计算是应当/1000m
             * 整形与整形运算得出的结果仍然时整形,1640 / 1000m结果为0,因此必须将其中一个转化成decimal型,使用后缀m就可以了
             * (int)不进行四舍五入,Convert.ToInt32会四舍五入
             */
            //-----------计算中间值,----------

            try
            {
                //----------Top Level----------

                //----------W板----------
                //重命名装配体内部
                compReName = "F[INF-" + tree.Module + "]{" + (int)item.Length + "}(" + (int)item.Width + ")";
                status     = swModelDocExt.SelectByID2(CommonFunc.AddSuffix(suffix, "F-1") + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                if (status)
                {
                    swModelDocExt.RenameDocument(compReName);
                }
                swModel.ClearSelection2(true);
                status = swModelDocExt.SelectByID2(compReName + "-1" + "@" + assyName, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                swModel.ClearSelection2(true);
                if (status)
                {
                    swComp = swAssy.GetComponentByName(compReName + "-1");
                    swPart = swComp.GetModelDoc2(); //打开零件
                    swPart.Parameter("D2@Skizze1").SystemValue = item.Length / 1000m;
                    swPart.Parameter("D1@Skizze1").SystemValue = item.Width / 1000m;
                }
                swModel.ForceRebuild3(true);    //设置成true,直接更新顶层,速度很快,设置成false,每个零件都会更新,很慢
                swModel.Save();                 //保存,很耗时间
                swApp.CloseDoc(packedAssyPath); //关闭,很快
            }
            catch (Exception ex)
            {
                throw new Exception(packedAssyPath + "作图过程发生异常,详细:" + ex.Message);
            }
            finally
            {
                swApp.CommandInProgress = false; //及时关闭外部命令调用,否则影响SolidWorks的使用
            }
        }
Example #15
0
 void OnGUI()
 {
     if (Style == null)
     {
         Texture2D[] texture = new Texture2D[3];
         string[]    str     = new string[] { "Ok.png", "Warning.png", "Danger.png" };
         for (int s = 0; s < str.Length; s++)
         {
             texture[s] = cext.loadImage(Application.dataPath + "/Style/" + str[s]);
         }
         Style    = new GUIStyle[3];
         Style[0] = new GUIStyle();
         Style[0].normal.background = texture[0];
         Style[1] = new GUIStyle();
         Style[1].normal.background = texture[1];
         Style[2] = new GUIStyle();
         Style[2].normal.background = texture[2];
     }
     if (ListLoged.Count > 0)
     {
         for (int s = 0; s < ListLoged.Count; s++)
         {
             Rect rect = new Rect(Screen.width - 300f, 0f, 300f, 50f);
             INF  inf  = ListLoged[s];
             inf.Lifetime -= FengGameManagerMKII.deltaTime;
             if (inf.Lifetime < 1)
             {
                 inf.upd_time += FengGameManagerMKII.deltaTime;
                 if (inf.upd_time > 0.1)
                 {
                     inf.upd_time = 0;
                     if (inf.transparament > 0)
                     {
                         inf.transparament = inf.transparament - 0.1f;
                     }
                 }
             }
             if (inf.Lifetime < 0)
             {
                 ListLoged.Remove(inf);
                 return;
             }
             GUI.depth = -999;
             Color color = new Color(1f, 1f, 1f, inf.transparament);
             GUI.backgroundColor = color;
             rect.y = (50 * s);
             GUI.Box(rect, "", tex(inf.log_type));
             GUIStyle style = new GUIStyle(GUI.skin.label);
             style.alignment        = TextAnchor.UpperLeft;
             style.normal.textColor = color;
             rect.x      = rect.x + 35f;
             rect.y      = rect.y + 5f;
             rect.width  = 260f;
             rect.height = 50;
             GUI.Label(rect, "<size=15>" + inf.message + "</size>", style);
             rect.y = rect.y + 25f;
             rect.x = rect.x + 200f;
             GUI.Label(rect, "<size=12>" + inf.date_time + "</size>", style);
         }
     }
 }