Beispiel #1
0
        public static void ActFiles_normalizationName()
        {
            MATCFileNameFull q = new MATCFileNameFull();
            FTDataSet ds = new FTDataSet();
            CommonTableAdapter cta = new CommonTableAdapter();
            ActFilesforUpdateNameTableAdapter f4 = new ActFilesforUpdateNameTableAdapter();
            f4.Fill(ds.ActFilesforUpdateName);
            try
            {
                /*var rr = ds.ActFilesforUpdateName.Where(selector =>
                {
                    MATCFileNameFullExtensoinResult match1 = RegEx.GetMATCFileNameFullExtensoinResult(selector["name"].ToString()).FirstOrDefault();
                    if (match1 != null && string.IsNullOrEmpty(match1.Name)) { return true; } else { return false; };
                }).ToList();*/
                foreach (DataRow dr in ds.ActFilesforUpdateName.Rows)
                {
                    string _result = null;
                    MATCFileNameFullExtensoinResult match = RegEx.GetMATCFileNameFullExtensoinResult(dr["name"].ToString().Trim()).FirstOrDefault();
                    if (match != null)
                    {
                        Console.WriteLine(dr["name"].ToString() + " добавляется");
                        if (string.IsNullOrEmpty(match.Name))
                        { _result = match.UNOM + "_фото_" + dr["fdate"].ToString() + "_" + dr["Hash"].ToString() + "." + match.Extension; }
                        else
                        { _result = match.UNOM + match.Name + "_" + dr["fdate"].ToString() + "_" + dr["Hash"].ToString() + "." + match.Extension; }
                        if (dr["Name"].ToString() != _result)
                        {
                            //dr.SetField<string>("Name", _result);
                            try
                            {
                                cta.Update_ActFiles_names_Query(_result, dr["path_locator"].ToString());
                                Console.WriteLine(_result);
                            }
                            catch (Exception e)
                            { Console.WriteLine(_result + e.Message); }
                        };
                    }
                    else
                    {
                        _result = dr["UNOM"].ToString() + "_фото_" + dr["fdate"].ToString() + "_" + dr["Hash"].ToString() + "." + dr["file_type"].ToString();
                        Console.WriteLine(dr["name"].ToString() + " добавляется");
                        cta.Update_ActFiles_names_Query(_result, dr["path_locator"].ToString());
                    };
                }
            }
            finally
            {
                if (ds.ActFilesforUpdateName.HasErrors)
                {
                }
                else
                    // If no errors, AcceptChanges.
                    if (ds.ActFilesforUpdateName.GetChanges() != null)
                {
                    //ds.Files4forUpdateName.AcceptChanges();
                    f4.Update(ds.ActFilesforUpdateName);
                }

            }
        }
Beispiel #2
0
        public static void correctDateToFiles(string fileNamePart)
        {
            CommonTableAdapter upA = new CommonTableAdapter();
            FTDataSet ds = new FTDataSet();
            FilesforUpdateNameTableAdapter files = new FilesforUpdateNameTableAdapter();
            files.Fill(ds.FilesforUpdateName);
            MATCFileNameFull q = new MATCFileNameFull();
            try
            {
                foreach (DataRow dr in ds.FilesforUpdateName.Rows)
                {
                    MATCFileNameFullExtensoinResult match = RegEx.GetMATCFileNameFullExtensoinResult(dr["name"].ToString()).FirstOrDefault();
                    string _result = null;
                    if (match != null)
                    {
                        _result = match.UNOM + match.Name + "_" + dr["fdate"].ToString() + match.Counter + "." + match.Extension;
                        if (dr["name"].ToString() != _result)
                        { dr["name"] = _result; }
                    }
                };
            }
            finally
            {
                if (ds.FilesforUpdateName.HasErrors)
                { }
                else // If no errors, AcceptChanges.

                        if (ds.FilesforUpdateName.GetChanges() != null)
                {
                    files.Update(ds.FilesforUpdateName);
                }
            }
        }
Beispiel #3
0
        public static SqlBoolean MATCFileNameFullExtensionExists(SqlString Input)
        {
            string           input = (Input.IsNull) ? string.Empty : Input.Value;
            MATCFileNameFull q     = new MATCFileNameFull();
            Regex            r     = new Regex("^(?<number>\\d{5}[Г|Д]У\\d{6})(?<name>[а-яА-Яa-zA-Z0-9_]*)*(?<date>_\\d{8}|\\d{14})(?<filecounter>_[a-zA-Z0-9]+)*\\.(?<extension>[a-zA-Z0-9]{0,4})$");

            //return q.IsMatch(input);
            return(r.IsMatch(input));
        }
Beispiel #4
0
        public static string MATCFileNameFullExtensionMatch6(SqlString Input)
        {
            string           input   = (Input.IsNull) ? string.Empty : Input.Value;
            MATCFileNameFull q       = new MATCFileNameFull();
            string           _result = null;

            foreach (Match wm in q.Matches(input))
            {
                if (wm.Groups.Count == 6)
                {
                    _result = wm.Groups[5].ToString();
                }
            }
            return(_result);
        }
Beispiel #5
0
 public static void SetFiles_HashToName(SqlInt16 Count)
 {
     using (SqlConnection connection = new SqlConnection("context connection=true"))
     {
         string sql = "SELECT fc.name,Hash,cast( fc.path_locator as varchar(1000)) path_locator FROM Files fc INNER JOIN FilesHash fch ON fc.path_locator = fch.path_locator WHERE NOT fc.name LIKE '%' + fch.Hash + '%' and (name LIKE '%паспорт%' OR name LIKE '%макет%')";
         connection.Open();
         MATCFileNameFull q        = new MATCFileNameFull();
         SqlDataAdapter   daFiles  = new SqlDataAdapter(sql, connection);
         DataTable        tblFiles = new DataTable();
         daFiles.Fill(tblFiles);
         string str = "asdasdasdasdasdasdasdasd";
         SqlContext.Pipe.Send(str.PadRight(1000));
         SqlCommand update = new SqlCommand("UPDATE Files SET name= @newname WHERE stream_id	= @path_locator", connection);
         update.Parameters.Add("@newname", SqlDbType.NVarChar, 500);
         update.Parameters.Add("@path_locator", SqlDbType.VarChar, 1000);
         update.Prepare();
         try
         {
             foreach (DataRow dr in tblFiles.Rows)
             {
                 string _result = null;
                 foreach (Match wm in q.Matches(dr["name"].ToString()))
                 {
                     if (wm.Groups.Count == 6)
                     {
                         string _name = null;
                         foreach (Capture cm in wm.Groups[2].Captures)
                         {
                             _name += cm.Value;
                         }
                         _result = wm.Groups[1].ToString() + _name + "_" + wm.Groups[3].ToString() + wm.Groups[4].ToString() + "_" + dr["Hash"].ToString() + "." + wm.Groups[5].ToString();
                         update.Parameters["@newname"].Value      = _result;
                         update.Parameters["@path_locator"].Value = dr["path_locator"];
                         update.ExecuteNonQuery();
                     }
                 }
             }
             ;
         }
         finally
         {
             connection.Close();
         }
     }
 }
Beispiel #6
0
        public static string MATCFileNameFullExtensionMatch3(SqlString Input)
        {
            string           input = (Input.IsNull) ? string.Empty : Input.Value;
            MATCFileNameFull q     = new MATCFileNameFull();
            string           _name = null;

            foreach (Match wm in q.Matches(input))
            {
                if (wm.Groups.Count == 6)
                {
                    foreach (Capture cm in wm.Groups[2].Captures)
                    {
                        _name += cm.Value;
                    }
                }
            }
            return(_name);
        }
Beispiel #7
0
        public static void mainFileContainer_insertFoto()
        {
            MATCFileNameFull q = new MATCFileNameFull();
            FTDataSet ds = new FTDataSet();
            mainFileContainer_for_updateNameTableAdapter f4 = new mainFileContainer_for_updateNameTableAdapter();
            string _name = "_фото";
            f4.Fill(ds.mainFileContainer_for_updateName);
            try
            {
                var rr = ds.mainFileContainer_for_updateName.Where(selector =>
                  {
                      MATCFileNameFullExtensoinResult match1 = RegEx.GetMATCFileNameFullExtensoinResult(selector["name"].ToString()).FirstOrDefault();
                      if (match1 != null && string.IsNullOrEmpty(match1.Name)) { return true; } else { return false; };
                  });
                foreach (DataRow dr in ds.mainFileContainer_for_updateName.Rows)
                {
                    MATCFileNameFullExtensoinResult match = RegEx.GetMATCFileNameFullExtensoinResult(dr["name"].ToString()).FirstOrDefault();
                    if (match != null && string.IsNullOrEmpty(match.Name))
                    {
                        string _result = null;
                        _result = match.UNOM + _name + "_" + dr["fdate"].ToString() + "_" + dr["Hash"].ToString() + "." + match.Extension;
                        if (dr["Name"].ToString() != _result)
                        {
                            dr.SetField<string>("Name", _result);
                        };
                    };
                }
            }
            finally
            {
                if (ds.mainFileContainer_for_updateName.HasErrors)
                {
                }
                else
                    // If no errors, AcceptChanges.
                    if (ds.mainFileContainer_for_updateName.GetChanges() != null)
                {
                    //ds.Files4forUpdateName.AcceptChanges();
                    f4.Update(ds.mainFileContainer_for_updateName);
                }

            }
        }
Beispiel #8
0
        public static IEnumerable <MATCFileNameFullExtensoinResult> GetMATCFileNameFullExtensoinResult(string input)
        {
            MATCFileNameFull q = new MATCFileNameFull();
            List <MATCFileNameFullExtensoinResult> result = new List <MATCFileNameFullExtensoinResult>();

            foreach (Match wm in q.Matches(input))
            {
                if (wm.Groups.Count == 6)
                {
                    string _name = null;
                    foreach (Capture cm in wm.Groups[2].Captures)
                    {
                        _name += cm.Value;
                    }
                    result.Add(new MATCFileNameFullExtensoinResult(wm.Groups[1].ToString(), _name, wm.Groups[3].ToString(), wm.Groups[4].ToString(), wm.Groups[5].ToString()));
                }
            }

            return(result);
        }
Beispiel #9
0
        public static void Files4updateName_insertFoto(string fileNamePart)
        {
            MATCFileNameFull q = new MATCFileNameFull();
            FTDataSet ds = new FTDataSet();
            Files4forUpdateNameTableAdapter f4 = new Files4forUpdateNameTableAdapter();
            string _name = "_фото";
            f4.Fill(ds.Files4forUpdateName, null);
            try
            {
                foreach (DataRow dr in ds.Files4forUpdateName.Rows)
                {
                    MATCFileNameFullExtensoinResult match = RegEx.GetMATCFileNameFullExtensoinResult(dr["name"].ToString()).FirstOrDefault();
                    if (match != null && string.IsNullOrEmpty(match.Name))
                    {
                        string _result = null;
                        _result = match.UNOM + _name + "_" + dr["fdate"].ToString() + "_" + dr["Hash"].ToString() + "." + match.Extension;
                        if (dr["Name"].ToString() != _result)
                        {
                            dr.SetField<string>("Name", _result);
                        };
                    };
                }
            }
            finally
            {
                if (ds.Files4forUpdateName.HasErrors)
                {
                }
                else
                    // If no errors, AcceptChanges.
                    if (ds.Files4forUpdateName.GetChanges() != null)
                {
                    //ds.Files4forUpdateName.AcceptChanges();
                    f4.Update(ds.Files4forUpdateName);
                }

            }
        }
Beispiel #10
0
        public static void mainFileContainer_normalizationName()
        {
            MATCFileNameFull q = new MATCFileNameFull();
            FTDataSet ds = new FTDataSet();
            CommonTableAdapter cta = new CommonTableAdapter();
            mainFileContainer_for_updateNameTableAdapter f4 = new mainFileContainer_for_updateNameTableAdapter();
            f4.Connection.ConnectionString = "Data Source=MAKSIMOV;Initial Catalog=GBUMATC;Persist Security Info=True;Connection Timeout=50000000;User ID=Бушмакин;Password=453459";
            FTDataSet.mainFileContainer_for_updateNameDataTable wtable = ds.mainFileContainer_for_updateName;
            f4.Fill(wtable);
            try
            {
                /*var rr = wtable.Where(selector =>
                {
                    MATCFileNameFullExtensoinResult match1 = RegEx.GetMATCFileNameFullExtensoinResult(selector["name"].ToString()).FirstOrDefault();
                    if (match1 != null && string.IsNullOrEmpty(match1.Name)) { return true; } else { return false; };
                }).ToList();*/
                foreach (DataRow dr in wtable.Rows)
                {
                    string _result = null;
                    MATCFileNameFullExtensoinResult match = RegEx.GetMATCFileNameFullExtensoinResult(dr["name"].ToString().Trim()).FirstOrDefault();
                    if (match != null)
                    {
                        Console.WriteLine(dr["name"].ToString() + " добавляется");
                        if (string.IsNullOrEmpty(match.Name))
                        { _result = match.UNOM + "_фото_" + dr["fdate"].ToString() + "_" + dr["Hash"].ToString() + "." + match.Extension; }
                        else
                        { _result = match.UNOM + match.Name + "_" + dr["fdate"].ToString() + "_" + dr["Hash"].ToString() + "." + match.Extension; }
                        if (dr["Name"].ToString() != _result)
                        {
                            dr.SetField<string>("Name", _result);
                            try
                            {
                                //cta.Update_mainFileContainer_Query(_result, dr["path_locator"].ToString());
                                Console.WriteLine(_result);
                            }
                            catch (Exception e)
                            { Console.WriteLine(_result + e.Message); }
                        };
                    }
                    else
                    {
                        //_result = dr["UNOM"].ToString() + "_фото_" + dr["fdate"].ToString() + "_" + dr["Hash"].ToString() + "." + dr["file_type"].ToString();
                        Console.WriteLine(dr["name"].ToString() + " херня-с");
                        //cta.Update_ActFiles_names_Query(_result, dr["path_locator"].ToString());
                        //dr.SetField<string>("Name", _result);
                    };
                }
            }
            finally
            {
                if (wtable.HasErrors)
                {
                }
                else
                    // If no errors, AcceptChanges.
                    if (wtable.GetChanges() != null)
                {
                    //ds.Files4forUpdateName.AcceptChanges();
                    f4.Update(wtable);
                }

            }
        }